/* * This function packages a simple "CDC Subset" Ethernet port with no real * control mechanisms; just raw data transfer over two bulk endpoints. * The data transfer model is exactly that of CDC Ethernet, which is * why we call it the "CDC Subset". * * Because it's not standardized, this has some interoperability issues. * They mostly relate to driver binding, since the data transfer model is * so simple (CDC Ethernet). The original versions of this protocol used * specific product/vendor IDs: byteswapped IDs for Digital Equipment's * SA-1100 "Itsy" board, which could run Linux 2.4 kernels and supported * daughtercards with USB peripheral connectors. (It was used more often * with other boards, using the Itsy identifiers.) Linux hosts recognized * this with CONFIG_USB_ARMLINUX; these devices have only one configuration * and one interface. * * At some point, MCCI defined a (nonconformant) CDC MDLM variant called * "SAFE", which happens to have a mode which is identical to the "CDC * Subset" in terms of data transfer and lack of control model. This was * adopted by later Sharp Zaurus models, and by some other software which * Linux hosts recognize with CONFIG_USB_NET_ZAURUS. * * Because Microsoft's RNDIS drivers are far from robust, we added a few * descriptors to the CDC Subset code, making this code look like a SAFE * implementation. This lets you use MCCI's host side MS-Windows drivers * if you get fed up with RNDIS. It also makes it easier for composite * drivers to work, since they can use class based binding instead of * caring about specific product and vendor IDs.
*/
/* * "Simple" CDC-subset option is a simple vendor-neutral model that most * full speed controllers can handle: one interface, two bulk endpoints. * To assist host side drivers, we fancy it up a bit, and add descriptors so * some host side drivers will understand it as a "SAFE" variant. * * "SAFE" loosely follows CDC WMC MDLM, violating the spec in various ways. * Data endpoints live in the control interface, there's no data interface. * And it's not used to talk to a cell phone radio.
*/
/* since "usb_cdc_mdlm_detail_desc" is a variable length structure, we * can't really use its struct. All we do here is say that we're using * the submode of "SAFE" which directly matches the CDC Subset.
*/ static u8 mdlm_detail_desc[] = {
6,
USB_DT_CS_INTERFACE,
USB_CDC_MDLM_DETAIL_TYPE,
0, /* "SAFE" */
0, /* network control capabilities (none) */
0, /* network data capabilities ("raw" encapsulation) */
};
/* * in drivers/usb/gadget/configfs.c:configfs_composite_bind() * configurations are bound in sequence with list_for_each_entry, * in each configuration its functions are bound in sequence * with list_for_each_entry, so we assume no race condition * with regard to gether_opts->bound access
*/ if (!gether_opts->bound) {
mutex_lock(&gether_opts->lock);
gether_set_gadget(gether_opts->net, cdev->gadget);
status = gether_register_netdev(gether_opts->net);
mutex_unlock(&gether_opts->lock); if (status) return status;
gether_opts->bound = true;
}
us = usb_gstrings_attach(cdev, geth_strings,
ARRAY_SIZE(geth_string_defs)); if (IS_ERR(us)) return PTR_ERR(us);
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f); if (status < 0) goto fail;
subset_data_intf.bInterfaceNumber = status;
status = -ENODEV;
/* allocate instance-specific endpoints */
ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc); if (!ep) goto fail;
geth->port.in_ep = ep;
ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc); if (!ep) goto fail;
geth->port.out_ep = ep;
/* support all relevant hardware speeds... we expect that when * hardware is dual speed, all bulk-capable endpoints work at * both speeds
*/
hs_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress;
hs_subset_out_desc.bEndpointAddress =
fs_subset_out_desc.bEndpointAddress;
status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function,
ss_eth_function, ss_eth_function); if (status) goto fail;
/* NOTE: all that is done without knowing or caring about * the network link ... which is unavailable to this code * until we're activated via set_alt().
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.