diff options
author | Michael Brown | 2015-02-09 17:36:06 +0100 |
---|---|---|
committer | Michael Brown | 2015-02-10 14:49:27 +0100 |
commit | 1bb9e88ba068eb394153179c91cacab9a2383066 (patch) | |
tree | b0b16cdf53e8d93bdb9a51aa82f9aaa75fd35259 /src/drivers/net/ecm.h | |
parent | [usb] Allow usb_stream() to enforce a terminating short packet (diff) | |
download | ipxe-1bb9e88ba068eb394153179c91cacab9a2383066.tar.gz ipxe-1bb9e88ba068eb394153179c91cacab9a2383066.tar.xz ipxe-1bb9e88ba068eb394153179c91cacab9a2383066.zip |
[ecm] Add support for CDC-ECM USB Ethernet devices
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/ecm.h')
-rw-r--r-- | src/drivers/net/ecm.h | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/src/drivers/net/ecm.h b/src/drivers/net/ecm.h index e8ec3fb6..9c754bce 100644 --- a/src/drivers/net/ecm.h +++ b/src/drivers/net/ecm.h @@ -12,13 +12,47 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/usb.h> #include <ipxe/cdc.h> +/** CDC-ECM subclass */ +#define USB_SUBCLASS_CDC_ECM 0x06 + +/** CDC-ECM interfaces */ +enum ecm_interfaces { + /** Communications interface */ + ECM_INTERFACE_COMMS = 0, + /** Data interface */ + ECM_INTERFACE_DATA, + ECM_INTERFACE_COUNT +}; + +/** Alternate setting for CDC-ECM data interface */ +#define ECM_DATA_ALTERNATE 1 + +/** Set Ethernet packet filter */ +#define ECM_SET_ETHERNET_PACKET_FILTER \ + ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \ + USB_REQUEST_TYPE ( 0x43 ) ) + +/** Ethernet packet types */ +enum ecm_ethernet_packet_filter { + /** Promiscuous mode */ + ECM_PACKET_TYPE_PROMISCUOUS = 0x0001, + /** All multicast packets */ + ECM_PACKET_TYPE_ALL_MULTICAST = 0x0002, + /** Unicast packets */ + ECM_PACKET_TYPE_DIRECTED = 0x0004, + /** Broadcast packets */ + ECM_PACKET_TYPE_BROADCAST = 0x0008, + /** Specified multicast packets */ + ECM_PACKET_TYPE_MULTICAST = 0x0010, +}; + /** An Ethernet Functional Descriptor */ struct ecm_ethernet_descriptor { /** Descriptor header */ struct usb_descriptor_header header; /** Descriptor subtype */ uint8_t subtype; - /** MAC addres string */ + /** MAC address string */ uint8_t mac; /** Ethernet statistics bitmap */ uint32_t statistics; @@ -30,6 +64,64 @@ struct ecm_ethernet_descriptor { uint8_t wol; } __attribute__ (( packed )); +/** A CDC-ECM receive ring */ +struct ecm_rx_ring { + /** USB endpoint */ + struct usb_endpoint ep; + /** I/O buffer size */ + size_t mtu; + /** Fill level */ + unsigned int fill; + /** Maximum fill level */ + unsigned int max; +}; + +/** A CDC-ECM transmit ring */ +struct ecm_tx_ring { + /** USB endpoint */ + struct usb_endpoint ep; +}; + +/** A CDC-ECM network device */ +struct ecm_device { + /** USB device */ + struct usb_device *usb; + /** USB bus */ + struct usb_bus *bus; + /** Network device */ + struct net_device *netdev; + + /** Communications interface */ + unsigned int comms; + /** Data interface */ + unsigned int data; + + /** Interrupt ring */ + struct ecm_rx_ring intr; + /** Bulk IN ring */ + struct ecm_rx_ring in; + /** Bulk OUT ring */ + struct ecm_tx_ring out; +}; + +/** Interrupt maximum fill level + * + * This is a policy decision. + */ +#define ECM_INTR_MAX_FILL 2 + +/** Bulk IN maximum fill level + * + * This is a policy decision. + */ +#define ECM_IN_MAX_FILL 8 + +/** Bulk IN buffer size + * + * This is a policy decision. + */ +#define ECM_IN_MTU ( ETH_FRAME_LEN + 4 /* possible VLAN header */ ) + extern struct ecm_ethernet_descriptor * ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface ); |