You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef _ECM_H
  2. #define _ECM_H
  3. /** @file
  4. *
  5. * CDC-ECM USB Ethernet driver
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <ipxe/usb.h>
  10. #include <ipxe/cdc.h>
  11. /** CDC-ECM subclass */
  12. #define USB_SUBCLASS_CDC_ECM 0x06
  13. /** CDC-ECM interfaces */
  14. enum ecm_interfaces {
  15. /** Communications interface */
  16. ECM_INTERFACE_COMMS = 0,
  17. /** Data interface */
  18. ECM_INTERFACE_DATA,
  19. ECM_INTERFACE_COUNT
  20. };
  21. /** Alternate setting for CDC-ECM data interface */
  22. #define ECM_DATA_ALTERNATE 1
  23. /** Set Ethernet packet filter */
  24. #define ECM_SET_ETHERNET_PACKET_FILTER \
  25. ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
  26. USB_REQUEST_TYPE ( 0x43 ) )
  27. /** Ethernet packet types */
  28. enum ecm_ethernet_packet_filter {
  29. /** Promiscuous mode */
  30. ECM_PACKET_TYPE_PROMISCUOUS = 0x0001,
  31. /** All multicast packets */
  32. ECM_PACKET_TYPE_ALL_MULTICAST = 0x0002,
  33. /** Unicast packets */
  34. ECM_PACKET_TYPE_DIRECTED = 0x0004,
  35. /** Broadcast packets */
  36. ECM_PACKET_TYPE_BROADCAST = 0x0008,
  37. /** Specified multicast packets */
  38. ECM_PACKET_TYPE_MULTICAST = 0x0010,
  39. };
  40. /** An Ethernet Functional Descriptor */
  41. struct ecm_ethernet_descriptor {
  42. /** Descriptor header */
  43. struct usb_descriptor_header header;
  44. /** Descriptor subtype */
  45. uint8_t subtype;
  46. /** MAC address string */
  47. uint8_t mac;
  48. /** Ethernet statistics bitmap */
  49. uint32_t statistics;
  50. /** Maximum segment size */
  51. uint16_t mtu;
  52. /** Multicast filter configuration */
  53. uint16_t mcast;
  54. /** Number of wake-on-LAN filters */
  55. uint8_t wol;
  56. } __attribute__ (( packed ));
  57. /** A CDC-ECM receive ring */
  58. struct ecm_rx_ring {
  59. /** USB endpoint */
  60. struct usb_endpoint ep;
  61. /** I/O buffer size */
  62. size_t mtu;
  63. /** Fill level */
  64. unsigned int fill;
  65. /** Maximum fill level */
  66. unsigned int max;
  67. };
  68. /** A CDC-ECM transmit ring */
  69. struct ecm_tx_ring {
  70. /** USB endpoint */
  71. struct usb_endpoint ep;
  72. };
  73. /** A CDC-ECM network device */
  74. struct ecm_device {
  75. /** USB device */
  76. struct usb_device *usb;
  77. /** USB bus */
  78. struct usb_bus *bus;
  79. /** Network device */
  80. struct net_device *netdev;
  81. /** Communications interface */
  82. unsigned int comms;
  83. /** Data interface */
  84. unsigned int data;
  85. /** Interrupt ring */
  86. struct ecm_rx_ring intr;
  87. /** Bulk IN ring */
  88. struct ecm_rx_ring in;
  89. /** Bulk OUT ring */
  90. struct ecm_tx_ring out;
  91. };
  92. /** Interrupt maximum fill level
  93. *
  94. * This is a policy decision.
  95. */
  96. #define ECM_INTR_MAX_FILL 2
  97. /** Bulk IN maximum fill level
  98. *
  99. * This is a policy decision.
  100. */
  101. #define ECM_IN_MAX_FILL 8
  102. /** Bulk IN buffer size
  103. *
  104. * This is a policy decision.
  105. */
  106. #define ECM_IN_MTU ( ETH_FRAME_LEN + 4 /* possible VLAN header */ )
  107. extern struct ecm_ethernet_descriptor *
  108. ecm_ethernet_descriptor ( struct usb_configuration_descriptor *config,
  109. struct usb_interface_descriptor *interface );
  110. extern int ecm_fetch_mac ( struct usb_device *usb,
  111. struct ecm_ethernet_descriptor *desc,
  112. uint8_t *hw_addr );
  113. #endif /* _ECM_H */