6 * CDC-NCM USB Ethernet driver
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
18 /** CDC-NCM subclass */
19 #define USB_SUBCLASS_CDC_NCM 0x0d
21 /** Get NTB parameters */
22 #define NCM_GET_NTB_PARAMETERS \
23 ( USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
24 USB_REQUEST_TYPE ( 0x80 ) )
26 /** NTB datagram parameters */
27 struct ncm_ntb_datagram_parameters {
30 /** Alignment divisor */
32 /** Alignment remainder */
34 /** Alignment modulus */
36 } __attribute__ (( packed ));
39 struct ncm_ntb_parameters {
42 /** Supported formats */
44 /** IN datagram parameters */
45 struct ncm_ntb_datagram_parameters in;
48 /** OUT datagram parameters */
49 struct ncm_ntb_datagram_parameters out;
50 /** Maximum number of datagrams per OUT NTB */
52 } __attribute__ (( packed ));
54 /** Set NTB input size */
55 #define NCM_SET_NTB_INPUT_SIZE \
56 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
57 USB_REQUEST_TYPE ( 0x86 ) )
59 /** Set NTB input size */
60 struct ncm_set_ntb_input_size {
63 } __attribute__ (( packed ));
65 /** Minimum allowed NTB input size */
66 #define NCM_MIN_NTB_INPUT_SIZE 2048
68 /** Maximum allowed NTB input size (16-bit) */
69 #define NCM_MAX_NTB_INPUT_SIZE 65536
71 /** CDC-NCM transfer header (16-bit) */
72 struct ncm_transfer_header {
77 /** Sequence number */
81 /** Offset of first datagram pointer */
83 } __attribute__ (( packed ));
85 /** CDC-NCM transfer header magic */
86 #define NCM_TRANSFER_HEADER_MAGIC 0x484d434eUL
88 /** CDC-NCM datagram descriptor (16-bit) */
89 struct ncm_datagram_descriptor {
90 /** Starting offset */
94 } __attribute__ (( packed ));
96 /** CDC-NCM datagram pointer (16-bit) */
97 struct ncm_datagram_pointer {
102 /** Offset of next datagram pointer */
104 /** Datagram descriptors
106 * Must be terminated by an empty descriptor.
108 struct ncm_datagram_descriptor desc[0];
109 } __attribute__ (( packed ));
111 /** CDC-NCM datagram pointer magic */
112 #define NCM_DATAGRAM_POINTER_MAGIC 0x304d434eUL
114 /** CDC-NCM datagram pointer CRC present flag */
115 #define NCM_DATAGRAM_POINTER_MAGIC_CRC 0x01000000UL
117 /** NTB constructed for transmitted packets (excluding padding)
119 * This is a policy decision.
121 struct ncm_ntb_header {
122 /** Transfer header */
123 struct ncm_transfer_header nth;
124 /** Datagram pointer */
125 struct ncm_datagram_pointer ndp;
126 /** Datagram descriptors */
127 struct ncm_datagram_descriptor desc[2];
128 } __attribute__ (( packed ));
130 /** A CDC-NCM network device */
133 struct usb_device *usb;
136 /** Network device */
137 struct net_device *netdev;
138 /** USB network device */
139 struct usbnet_device usbnet;
141 /** Maximum supported NTB input size */
143 /** Transmitted packet sequence number */
145 /** Alignment padding required on transmitted packets */
149 /** Bulk IN ring minimum buffer count
151 * This is a policy decision.
153 #define NCM_IN_MIN_COUNT 3
155 /** Bulk IN ring minimum total buffer size
157 * This is a policy decision.
159 #define NCM_IN_MIN_SIZE 16384
161 /** Bulk IN ring maximum total buffer size
163 * This is a policy decision.
165 #define NCM_IN_MAX_SIZE 131072
167 /** Interrupt ring buffer count
169 * This is a policy decision.
171 #define NCM_INTR_COUNT 2