iPXE
ecm.h
Go to the documentation of this file.
00001 #ifndef _ECM_H
00002 #define _ECM_H
00003 
00004 /** @file
00005  *
00006  * CDC-ECM USB Ethernet driver
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <ipxe/usb.h>
00013 #include <ipxe/usbnet.h>
00014 #include <ipxe/cdc.h>
00015 
00016 /** CDC-ECM subclass */
00017 #define USB_SUBCLASS_CDC_ECM 0x06
00018 
00019 /** Set Ethernet packet filter */
00020 #define ECM_SET_ETHERNET_PACKET_FILTER                                  \
00021         ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE |          \
00022           USB_REQUEST_TYPE ( 0x43 ) )
00023 
00024 /** Ethernet packet types */
00025 enum ecm_ethernet_packet_filter {
00026         /** Promiscuous mode */
00027         ECM_PACKET_TYPE_PROMISCUOUS = 0x0001,
00028         /** All multicast packets */
00029         ECM_PACKET_TYPE_ALL_MULTICAST = 0x0002,
00030         /** Unicast packets */
00031         ECM_PACKET_TYPE_DIRECTED = 0x0004,
00032         /** Broadcast packets */
00033         ECM_PACKET_TYPE_BROADCAST = 0x0008,
00034         /** Specified multicast packets */
00035         ECM_PACKET_TYPE_MULTICAST = 0x0010,
00036 };
00037 
00038 /** An Ethernet Functional Descriptor */
00039 struct ecm_ethernet_descriptor {
00040         /** Descriptor header */
00041         struct usb_descriptor_header header;
00042         /** Descriptor subtype */
00043         uint8_t subtype;
00044         /** MAC address string */
00045         uint8_t mac;
00046         /** Ethernet statistics bitmap */
00047         uint32_t statistics;
00048         /** Maximum segment size */
00049         uint16_t mtu;
00050         /** Multicast filter configuration */
00051         uint16_t mcast;
00052         /** Number of wake-on-LAN filters */
00053         uint8_t wol;
00054 } __attribute__ (( packed ));
00055 
00056 /** A CDC-ECM network device */
00057 struct ecm_device {
00058         /** USB device */
00059         struct usb_device *usb;
00060         /** USB bus */
00061         struct usb_bus *bus;
00062         /** Network device */
00063         struct net_device *netdev;
00064         /** USB network device */
00065         struct usbnet_device usbnet;
00066 };
00067 
00068 /** Interrupt maximum fill level
00069  *
00070  * This is a policy decision.
00071  */
00072 #define ECM_INTR_MAX_FILL 2
00073 
00074 /** Bulk IN maximum fill level
00075  *
00076  * This is a policy decision.
00077  */
00078 #define ECM_IN_MAX_FILL 8
00079 
00080 /** Bulk IN buffer size
00081  *
00082  * This is a policy decision.
00083  */
00084 #define ECM_IN_MTU ( ETH_FRAME_LEN + 4 /* possible VLAN header */ )
00085 
00086 extern struct ecm_ethernet_descriptor *
00087 ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config,
00088                           struct usb_interface_descriptor *interface );
00089 extern int ecm_fetch_mac ( struct usb_device *usb,
00090                            struct ecm_ethernet_descriptor *desc,
00091                            uint8_t *hw_addr );
00092 
00093 #endif /* _ECM_H */