[ecm] Use generic USB network device framework
[ipxe.git] / src / drivers / net / ecm.h
1 #ifndef _ECM_H
2 #define _ECM_H
3
4 /** @file
5 *
6 * CDC-ECM USB Ethernet driver
7 *
8 */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <ipxe/usb.h>
13 #include <ipxe/usbnet.h>
14 #include <ipxe/cdc.h>
15
16 /** CDC-ECM subclass */
17 #define USB_SUBCLASS_CDC_ECM 0x06
18
19 /** Set Ethernet packet filter */
20 #define ECM_SET_ETHERNET_PACKET_FILTER \
21 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
22 USB_REQUEST_TYPE ( 0x43 ) )
23
24 /** Ethernet packet types */
25 enum ecm_ethernet_packet_filter {
26 /** Promiscuous mode */
27 ECM_PACKET_TYPE_PROMISCUOUS = 0x0001,
28 /** All multicast packets */
29 ECM_PACKET_TYPE_ALL_MULTICAST = 0x0002,
30 /** Unicast packets */
31 ECM_PACKET_TYPE_DIRECTED = 0x0004,
32 /** Broadcast packets */
33 ECM_PACKET_TYPE_BROADCAST = 0x0008,
34 /** Specified multicast packets */
35 ECM_PACKET_TYPE_MULTICAST = 0x0010,
36 };
37
38 /** An Ethernet Functional Descriptor */
39 struct ecm_ethernet_descriptor {
40 /** Descriptor header */
41 struct usb_descriptor_header header;
42 /** Descriptor subtype */
43 uint8_t subtype;
44 /** MAC address string */
45 uint8_t mac;
46 /** Ethernet statistics bitmap */
47 uint32_t statistics;
48 /** Maximum segment size */
49 uint16_t mtu;
50 /** Multicast filter configuration */
51 uint16_t mcast;
52 /** Number of wake-on-LAN filters */
53 uint8_t wol;
54 } __attribute__ (( packed ));
55
56 /** A CDC-ECM network device */
57 struct ecm_device {
58 /** USB device */
59 struct usb_device *usb;
60 /** USB bus */
61 struct usb_bus *bus;
62 /** Network device */
63 struct net_device *netdev;
64 /** USB network device */
65 struct usbnet_device usbnet;
66 };
67
68 /** Interrupt maximum fill level
69 *
70 * This is a policy decision.
71 */
72 #define ECM_INTR_MAX_FILL 2
73
74 /** Bulk IN maximum fill level
75 *
76 * This is a policy decision.
77 */
78 #define ECM_IN_MAX_FILL 8
79
80 /** Bulk IN buffer size
81 *
82 * This is a policy decision.
83 */
84 #define ECM_IN_MTU ( ETH_FRAME_LEN + 4 /* possible VLAN header */ )
85
86 extern struct ecm_ethernet_descriptor *
87 ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config,
88 struct usb_interface_descriptor *interface );
89 extern int ecm_fetch_mac ( struct usb_device *usb,
90 struct ecm_ethernet_descriptor *desc,
91 uint8_t *hw_addr );
92
93 #endif /* _ECM_H */