config USB_U_SERIAL
tristate
+config USB_U_ETHER
+ tristate
+
config USB_F_SERIAL
tristate
tristate "Ethernet Gadget (with CDC Ethernet support)"
depends on NET
select USB_LIBCOMPOSITE
+ select USB_U_ETHER
select CRC32
help
This driver implements Ethernet style communication, in one of
tristate "Network Control Model (NCM) support"
depends on NET
select USB_LIBCOMPOSITE
+ select USB_U_ETHER
select CRC32
help
This driver implements USB CDC NCM subclass standard. NCM is
config USB_FUNCTIONFS_ETH
bool "Include configuration with CDC ECM (Ethernet)"
depends on USB_FUNCTIONFS && NET
+ select USB_U_ETHER
help
Include a configuration with CDC ECM function (Ethernet) and the
Function Filesystem.
config USB_FUNCTIONFS_RNDIS
bool "Include configuration with RNDIS (Ethernet)"
depends on USB_FUNCTIONFS && NET
+ select USB_U_ETHER
help
Include a configuration with RNDIS function (Ethernet) and the Filesystem.
depends on NET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+ select USB_U_ETHER
select USB_F_ACM
help
This driver provides two functions in one configuration:
depends on PHONET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+ select USB_U_ETHER
select USB_F_ACM
help
The Nokia composite gadget provides support for acm, obex
select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+ select USB_U_ETHER
select USB_F_ACM
help
The Multifunction Composite Gadget provides Ethernet (RNDIS
obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
usb_f_obex-y := f_obex.o
obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o
+obj-$(CONFIG_USB_U_ETHER) += u_ether.o
#
# USB gadget drivers
/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();
+USB_ETHERNET_MODULE_PARAMETERS();
+
/*
* Kbuild is not very cooperative with respect to linking separately
* compiled library objects into one module. So for now we won't use
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/
#include "f_ecm.c"
-#include "u_ether.c"
/*-------------------------------------------------------------------------*/
NULL,
};
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
/*-------------------------------------------------------------------------*/
static struct usb_function *f_acm;
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- status = ecm_bind_config(c, hostaddr, the_dev);
+ status = ecm_bind_config(c, host_mac, the_dev);
if (status < 0)
return status;
}
/* set up network link layer */
- the_dev = gether_setup(cdev->gadget, hostaddr);
+ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
+ qmult);
if (IS_ERR(the_dev))
return PTR_ERR(the_dev);
#include "rndis.c"
#endif
#include "f_eem.c"
-#include "u_ether.c"
/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();
+USB_ETHERNET_MODULE_PARAMETERS();
+
/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
* Instead: allocate your own, using normal USB-IF procedures.
*/
NULL,
};
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
/*-------------------------------------------------------------------------*/
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- return rndis_bind_config(c, hostaddr, the_dev);
+ return rndis_bind_config(c, host_mac, the_dev);
}
static struct usb_configuration rndis_config_driver = {
if (use_eem)
return eem_bind_config(c, the_dev);
else if (can_support_ecm(c->cdev->gadget))
- return ecm_bind_config(c, hostaddr, the_dev);
+ return ecm_bind_config(c, host_mac, the_dev);
else
- return geth_bind_config(c, hostaddr, the_dev);
+ return geth_bind_config(c, host_mac, the_dev);
}
static struct usb_configuration eth_config_driver = {
int status;
/* set up network link layer */
- the_dev = gether_setup(cdev->gadget, hostaddr);
+ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
+ qmult);
if (IS_ERR(the_dev))
return PTR_ERR(the_dev);
# include "f_rndis.c"
# include "rndis.c"
# endif
-# include "u_ether.c"
+# include "u_ether.h"
-static u8 gfs_hostaddr[ETH_ALEN];
+static u8 gfs_host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
# ifdef CONFIG_USB_FUNCTIONFS_ETH
static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
#else
# define the_dev NULL
# define gether_cleanup(dev) do { } while (0)
-# define gfs_hostaddr NULL
+# define gfs_host_mac NULL
struct eth_dev;
#endif
USB_GADGET_COMPOSITE_OPTIONS();
+USB_ETHERNET_MODULE_PARAMETERS();
+
static struct usb_device_descriptor gfs_dev_desc = {
.bLength = sizeof gfs_dev_desc,
.bDescriptorType = USB_DT_DEVICE,
if (missing_funcs)
return -ENODEV;
#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
- the_dev = gether_setup(cdev->gadget, gfs_hostaddr);
+ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, gfs_host_mac,
+ qmult);
#endif
if (IS_ERR(the_dev)) {
ret = PTR_ERR(the_dev);
}
if (gc->eth) {
- ret = gc->eth(c, gfs_hostaddr, the_dev);
+ ret = gc->eth(c, gfs_host_mac, the_dev);
if (unlikely(ret < 0))
return ret;
}
# include "f_rndis.c"
# include "rndis.c"
#endif
-#include "u_ether.c"
+#include "u_ether.h"
USB_GADGET_COMPOSITE_OPTIONS();
+USB_ETHERNET_MODULE_PARAMETERS();
+
/***************************** Device Descriptor ****************************/
#define MULTI_VENDOR_NUM 0x1d6b /* Linux Foundation */
static struct fsg_common fsg_common;
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
static struct usb_function_instance *fi_acm;
static struct eth_dev *the_dev;
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- ret = rndis_bind_config(c, hostaddr, the_dev);
+ ret = rndis_bind_config(c, host_mac, the_dev);
if (ret < 0)
return ret;
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- ret = ecm_bind_config(c, hostaddr, the_dev);
+ ret = ecm_bind_config(c, host_mac, the_dev);
if (ret < 0)
return ret;
}
/* set up network link layer */
- the_dev = gether_setup(cdev->gadget, hostaddr);
+ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
+ qmult);
if (IS_ERR(the_dev))
return PTR_ERR(the_dev);
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/
#include "f_ncm.c"
-#include "u_ether.c"
/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();
+USB_ETHERNET_MODULE_PARAMETERS();
+
static struct usb_device_descriptor device_desc = {
.bLength = sizeof device_desc,
.bDescriptorType = USB_DT_DEVICE,
};
struct eth_dev *the_dev;
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
/*-------------------------------------------------------------------------*/
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- return ncm_bind_config(c, hostaddr, the_dev);
+ return ncm_bind_config(c, host_mac, the_dev);
}
static struct usb_configuration ncm_config_driver = {
int status;
/* set up network link layer */
- the_dev = gether_setup(cdev->gadget, hostaddr);
+ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
+ qmult);
if (IS_ERR(the_dev))
return PTR_ERR(the_dev);
#include "f_ecm.c"
#include "f_obex.c"
#include "f_phonet.c"
-#include "u_ether.c"
+#include "u_ether.h"
/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();
+USB_ETHERNET_MODULE_PARAMETERS();
+
#define NOKIA_VENDOR_ID 0x0421 /* Nokia */
#define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */
/*-------------------------------------------------------------------------*/
static struct usb_function *f_acm_cfg1;
static struct usb_function *f_acm_cfg2;
-static u8 hostaddr[ETH_ALEN];
+static u8 host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
enum {
if (status)
goto err_conf;
- status = ecm_bind_config(c, hostaddr, the_dev);
+ status = ecm_bind_config(c, host_mac, the_dev);
if (status) {
pr_debug("could not bind ecm config %d\n", status);
goto err_ecm;
goto err_ether;
}
- the_dev = gether_setup(cdev->gadget, hostaddr);
+ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
+ qmult);
if (IS_ERR(the_dev)) {
status = PTR_ERR(the_dev);
goto err_ether;
struct sk_buff_head rx_frames;
+ unsigned qmult;
+
unsigned header_len;
struct sk_buff *(*wrap)(struct gether *, struct sk_buff *skb);
int (*unwrap)(struct gether *,
#define DEFAULT_QLEN 2 /* double buffering by default */
-static unsigned qmult = 5;
-module_param(qmult, uint, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(qmult, "queue length multiplier at high/super speed");
-
/* for dual-speed hardware, use deeper queues at high/super speed */
-static inline int qlen(struct usb_gadget *gadget)
+static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
{
if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH ||
gadget->speed == USB_SPEED_SUPER))
if (gadget_is_dualspeed(dev->gadget))
req->no_interrupt = (dev->gadget->speed == USB_SPEED_HIGH ||
dev->gadget->speed == USB_SPEED_SUPER)
- ? ((atomic_read(&dev->tx_qlen) % qmult) != 0)
+ ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0)
: 0;
retval = usb_ep_queue(in, req, GFP_ATOMIC);
/*-------------------------------------------------------------------------*/
-/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */
-static char *dev_addr;
-module_param(dev_addr, charp, S_IRUGO);
-MODULE_PARM_DESC(dev_addr, "Device Ethernet Address");
-
-/* this address is invisible to ifconfig */
-static char *host_addr;
-module_param(host_addr, charp, S_IRUGO);
-MODULE_PARM_DESC(host_addr, "Host Ethernet Address");
-
static int get_ether_addr(const char *str, u8 *dev_addr)
{
if (str) {
*
* Returns negative errno, or zero on success
*/
-struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
- const char *netname)
+struct eth_dev *gether_setup_name(struct usb_gadget *g,
+ const char *dev_addr, const char *host_addr,
+ u8 ethaddr[ETH_ALEN], unsigned qmult, const char *netname)
{
struct eth_dev *dev;
struct net_device *net;
/* network device setup */
dev->net = net;
+ dev->qmult = qmult;
snprintf(net->name, sizeof(net->name), "%s%%d", netname);
if (get_ether_addr(dev_addr, net->dev_addr))
return dev;
}
+EXPORT_SYMBOL(gether_setup_name);
/**
* gether_cleanup - remove Ethernet-over-USB device
flush_work(&dev->work);
free_netdev(dev->net);
}
+EXPORT_SYMBOL(gether_cleanup);
/**
* gether_connect - notify network layer that USB link is active
}
if (result == 0)
- result = alloc_requests(dev, link, qlen(dev->gadget));
+ result = alloc_requests(dev, link, qlen(dev->gadget,
+ dev->qmult));
if (result == 0) {
dev->zlp = link->is_zlp_ok;
- DBG(dev, "qlen %d\n", qlen(dev->gadget));
+ DBG(dev, "qlen %d\n", qlen(dev->gadget, dev->qmult));
dev->header_len = link->header_len;
dev->unwrap = link->unwrap;
return ERR_PTR(result);
return dev->net;
}
+EXPORT_SYMBOL(gether_connect);
/**
* gether_disconnect - notify network layer that USB link is inactive
dev->port_usb = NULL;
spin_unlock(&dev->lock);
}
+EXPORT_SYMBOL(gether_disconnect);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("David Brownell");
#include "gadget_chips.h"
+#define QMULT_DEFAULT 5
+
+/*
+ * dev_addr: initial value
+ * changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx"
+ * host_addr: this address is invisible to ifconfig
+ */
+#define USB_ETHERNET_MODULE_PARAMETERS() \
+ static unsigned qmult = QMULT_DEFAULT; \
+ module_param(qmult, uint, S_IRUGO|S_IWUSR); \
+ MODULE_PARM_DESC(qmult, "queue length multiplier at high/super speed");\
+ \
+ static char *dev_addr; \
+ module_param(dev_addr, charp, S_IRUGO); \
+ MODULE_PARM_DESC(dev_addr, "Device Ethernet Address"); \
+ \
+ static char *host_addr; \
+ module_param(host_addr, charp, S_IRUGO); \
+ MODULE_PARM_DESC(host_addr, "Host Ethernet Address")
+
struct eth_dev;
/*
|USB_CDC_PACKET_TYPE_DIRECTED)
/* variant of gether_setup that allows customizing network device name */
-struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
- const char *netname);
+struct eth_dev *gether_setup_name(struct usb_gadget *g,
+ const char *dev_addr, const char *host_addr,
+ u8 ethaddr[ETH_ALEN], unsigned qmult, const char *netname);
/* netdev setup/teardown as directed by the gadget driver */
/* gether_setup - initialize one ethernet-over-usb link
* Returns negative errno, or zero on success
*/
static inline struct eth_dev *gether_setup(struct usb_gadget *g,
- u8 ethaddr[ETH_ALEN])
+ const char *dev_addr, const char *host_addr,
+ u8 ethaddr[ETH_ALEN], unsigned qmult)
{
- return gether_setup_name(g, ethaddr, "usb");
+ return gether_setup_name(g, dev_addr, host_addr, ethaddr, qmult, "usb");
}
void gether_cleanup(struct eth_dev *dev);