Commit 2b3d942c authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

usb ethernet gadget: split out network core

Abstract the peripheral side Ethernet-over-USB link layer code from
the all-in-one Ethernet gadget driver into a component that can be
called by various functions, so the various flavors can be split
apart and selectively reused.

A notable difference from the approach taken with the serial link
layer code (beyond talking to NET not TTY) is that because of the
initialization requirements, this only supports one network link.
(And one set of Ethernet link addresses.)

That is, each configuration may have only one instance of a network
function.  This doesn't change behavior; the current code has that
same restriction.  If you want multiple logical links, that can
easily be done using network layer tools.
Signed-off-by: default avatarDavid Brownell <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 15b2d2b5
......@@ -25,7 +25,7 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o
C_UTILS = composite.o usbstring.o config.o epautoconf.o
g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS)
g_ether-objs := ether.o usbstring.o config.o epautoconf.o
g_ether-objs := ether.o u_ether.o $(C_UTILS)
g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS)
g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
gadgetfs-objs := inode.o
This diff is collapsed.
* u_ether.h -- interface to USB gadget "ethernet link" utilities
* Copyright (C) 2003-2005,2008 David Brownell
* Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
* Copyright (C) 2008 Nokia Corporation
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef __U_ETHER_H
#define __U_ETHER_H
#include <linux/err.h>
#include <linux/if_ether.h>
#include <linux/usb/composite.h>
#include <linux/usb/cdc.h>
* This represents the USB side of an "ethernet" link, managed by a USB
* function which provides control and (maybe) framing. Two functions
* in different configurations could share the same ethernet link/netdev.
* There is currently a limitation that one instance of this function
* may be present in any given configuration.
struct gether {
struct usb_function func;
/* updated by gether_{connect,disconnect} */
struct eth_dev *ioport;
/* endpoints handle full and/or high speeds */
struct usb_ep *in_ep;
struct usb_ep *out_ep;
/* descriptors match device speed at gether_connect() time */
struct usb_endpoint_descriptor *in;
struct usb_endpoint_descriptor *out;
bool is_zlp_ok;
u16 cdc_filter;
/* hooks for added framing, as needed for RNDIS and EEM.
* we currently don't support multiple frames per SKB.
u32 header_len;
struct sk_buff *(*wrap)(struct sk_buff *skb);
int (*unwrap)(struct sk_buff *skb);
/* called on network open/close */
void (*open)(struct gether *);
void (*close)(struct gether *);
/* netdev setup/teardown as directed by the gadget driver */
int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]);
void gether_cleanup(void);
/* connect/disconnect is handled by individual functions */
struct net_device *gether_connect(struct gether *);
void gether_disconnect(struct gether *);
#endif /* __U_ETHER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment