iPXE
Functions | Variables
ncm.c File Reference

CDC-NCM USB Ethernet driver. More...

#include <string.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/profile.h>
#include <ipxe/usb.h>
#include <ipxe/usbnet.h>
#include "ecm.h"
#include "ncm.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void ncm_intr_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete interrupt transfer. More...
 
static int ncm_in_prefill (struct ncm_device *ncm)
 Prefill bulk IN endpoint. More...
 
static void ncm_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete bulk IN transfer. More...
 
static int ncm_out_transmit (struct ncm_device *ncm, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void ncm_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
 Complete bulk OUT transfer. More...
 
static int ncm_open (struct net_device *netdev)
 Open network device. More...
 
static void ncm_close (struct net_device *netdev)
 Close network device. More...
 
static int ncm_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void ncm_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static int ncm_probe (struct usb_function *func, struct usb_configuration_descriptor *config)
 Probe device. More...
 
static void ncm_remove (struct usb_function *func)
 Remove device. More...
 

Variables

static struct profiler ncm_intr_profiler __profiler
 Interrupt completion profiler. More...
 
static struct usb_endpoint_driver_operations ncm_intr_operations
 Interrupt endpoint operations. More...
 
static struct usb_endpoint_driver_operations ncm_in_operations
 Bulk IN endpoint operations. More...
 
static struct usb_endpoint_driver_operations ncm_out_operations
 Bulk OUT endpoint operations. More...
 
static struct net_device_operations ncm_operations
 CDC-NCM network device operations. More...
 
static struct usb_device_id ncm_ids []
 CDC-NCM device IDs. More...
 
struct usb_driver ncm_driver __usb_driver
 CDC-NCM driver. More...
 

Detailed Description

CDC-NCM USB Ethernet driver.

Definition in file ncm.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ncm_intr_complete()

static void ncm_intr_complete ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  rc 
)
static

Complete interrupt transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 73 of file ncm.c.

74  {
75  struct ncm_device *ncm = container_of ( ep, struct ncm_device,
76  usbnet.intr );
77  struct net_device *netdev = ncm->netdev;
78  struct usb_setup_packet *message;
79  size_t len = iob_len ( iobuf );
80 
81  /* Profile completions */
82  profile_start ( &ncm_intr_profiler );
83 
84  /* Ignore packets cancelled when the endpoint closes */
85  if ( ! ep->open )
86  goto ignore;
87 
88  /* Ignore packets with errors */
89  if ( rc != 0 ) {
90  DBGC ( ncm, "NCM %p interrupt failed: %s\n",
91  ncm, strerror ( rc ) );
92  DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) );
93  goto error;
94  }
95 
96  /* Extract message header */
97  if ( len < sizeof ( *message ) ) {
98  DBGC ( ncm, "NCM %p underlength interrupt:\n", ncm );
99  DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) );
100  rc = -EINVAL;
101  goto error;
102  }
103  message = iobuf->data;
104 
105  /* Parse message header */
106  switch ( message->request ) {
107 
109  if ( message->value ) {
110  DBGC ( ncm, "NCM %p link up\n", ncm );
112  } else {
113  DBGC ( ncm, "NCM %p link down\n", ncm );
115  }
116  break;
117 
119  /* Ignore */
120  break;
121 
122  default:
123  DBGC ( ncm, "NCM %p unrecognised interrupt:\n", ncm );
124  DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) );
125  goto error;
126  }
127 
128  /* Free I/O buffer */
129  free_iob ( iobuf );
130  profile_stop ( &ncm_intr_profiler );
131 
132  return;
133 
134  error:
135  netdev_rx_err ( netdev, iob_disown ( iobuf ), rc );
136  ignore:
137  free_iob ( iobuf );
138  return;
139 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
struct arbelprm_completion_with_error error
Definition: arbel.h:12
#define DBGC(...)
Definition: compiler.h:505
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:186
int open
Endpoint is open.
Definition: usb.h:404
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
struct usb_endpoint intr
Interrupt endpoint.
Definition: usbnet.h:27
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:208
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct net_device * netdev
Network device.
Definition: ncm.h:142
#define DBGC_HDA(...)
Definition: compiler.h:506
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
static struct net_device * netdev
Definition: gdbudp.c:52
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define CDC_NETWORK_CONNECTION
Network connection notification.
Definition: cdc.h:49
#define CDC_CONNECTION_SPEED_CHANGE
Connection speed change notification.
Definition: cdc.h:54
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
A network device.
Definition: netdevice.h:348
A USB setup data packet.
Definition: usb.h:68
A CDC-NCM network device.
Definition: ncm.h:136
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:44
#define cpu_to_le16(value)
Definition: byteswap.h:106
char message[VMCONSOLE_BUFSIZE]
Definition: vmconsole.c:54
if(natsemi->flags &NATSEMI_64BIT) return 1

References CDC_CONNECTION_SPEED_CHANGE, CDC_NETWORK_CONNECTION, container_of, cpu_to_le16, io_buffer::data, DBGC, DBGC_HDA, EINVAL, error, free_iob(), usbnet_device::intr, iob_disown, iob_len(), len, message, netdev, ncm_device::netdev, netdev_link_down(), netdev_link_up(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and ncm_device::usbnet.

◆ ncm_in_prefill()

static int ncm_in_prefill ( struct ncm_device ncm)
static

Prefill bulk IN endpoint.

Parameters
ncmCDC-NCM device
Return values
rcReturn status code

Definition at line 159 of file ncm.c.

159  {
160  struct usb_bus *bus = ncm->bus;
161  size_t mtu;
162  unsigned int count;
163  int rc;
164 
165  /* Some devices have a very small number of internal buffers,
166  * and rely on being able to pack multiple packets into each
167  * buffer. We therefore want to use large buffers if
168  * possible. However, large allocations have a reasonable
169  * chance of failure, especially if this is not the first or
170  * only device to be opened.
171  *
172  * We therefore attempt to find a usable buffer size, starting
173  * large and working downwards until allocation succeeds.
174  * Smaller buffers will still work, albeit with a higher
175  * chance of packet loss and so lower overall throughput.
176  */
177  for ( mtu = ncm->mtu ; mtu >= NCM_MIN_NTB_INPUT_SIZE ; mtu >>= 1 ) {
178 
179  /* Attempt allocation at this MTU */
180  if ( mtu > NCM_MAX_NTB_INPUT_SIZE )
181  continue;
182  if ( mtu > bus->mtu )
183  continue;
184  count = ( NCM_IN_MIN_SIZE / mtu );
185  if ( count < NCM_IN_MIN_COUNT )
187  if ( ( count * mtu ) > NCM_IN_MAX_SIZE )
188  continue;
189  usb_refill_init ( &ncm->usbnet.in, 0, mtu, count );
190  if ( ( rc = usb_prefill ( &ncm->usbnet.in ) ) != 0 ) {
191  DBGC ( ncm, "NCM %p could not prefill %dx %zd-byte "
192  "buffers for bulk IN\n", ncm, count, mtu );
193  continue;
194  }
195 
196  DBGC ( ncm, "NCM %p using %dx %zd-byte buffers for bulk IN\n",
197  ncm, count, mtu );
198  return 0;
199  }
200 
201  DBGC ( ncm, "NCM %p could not prefill bulk IN endpoint\n", ncm );
202  return -ENOMEM;
203 }
#define NCM_IN_MIN_SIZE
Bulk IN ring minimum total buffer size.
Definition: ncm.h:164
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
size_t mtu
Maximum supported NTB input size.
Definition: ncm.h:147
#define DBGC(...)
Definition: compiler.h:505
int usb_prefill(struct usb_endpoint *ep)
Prefill endpoint recycled buffer list.
Definition: usb.c:602
#define NCM_MIN_NTB_INPUT_SIZE
Minimum allowed NTB input size.
Definition: ncm.h:71
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define NCM_IN_MIN_COUNT
Bulk IN ring minimum buffer count.
Definition: ncm.h:158
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
Definition: usb.h:601
#define NCM_MAX_NTB_INPUT_SIZE
Maximum allowed NTB input size (16-bit)
Definition: ncm.h:74
#define NCM_IN_MAX_SIZE
Bulk IN ring maximum total buffer size.
Definition: ncm.h:170
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
uint16_t count
Number of entries.
Definition: ena.h:22
A USB bus.
Definition: usb.h:949
uint8_t bus
Bus.
Definition: edd.h:14
struct usb_bus * bus
USB bus.
Definition: ncm.h:140

References bus, ncm_device::bus, count, DBGC, ENOMEM, usbnet_device::in, mtu, ncm_device::mtu, NCM_IN_MAX_SIZE, NCM_IN_MIN_COUNT, NCM_IN_MIN_SIZE, NCM_MAX_NTB_INPUT_SIZE, NCM_MIN_NTB_INPUT_SIZE, rc, usb_prefill(), usb_refill_init(), and ncm_device::usbnet.

Referenced by ncm_open().

◆ ncm_in_complete()

static void ncm_in_complete ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  rc 
)
static

Complete bulk IN transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 212 of file ncm.c.

213  {
214  struct ncm_device *ncm = container_of ( ep, struct ncm_device,
215  usbnet.in );
216  struct net_device *netdev = ncm->netdev;
217  struct ncm_transfer_header *nth;
218  struct ncm_datagram_pointer *ndp;
219  struct ncm_datagram_descriptor *desc;
220  struct io_buffer *pkt;
221  unsigned int remaining;
222  size_t ndp_offset;
223  size_t ndp_len;
224  size_t pkt_offset;
225  size_t pkt_len;
226  size_t headroom;
227  size_t len;
228 
229  /* Profile overall bulk IN completion */
230  profile_start ( &ncm_in_profiler );
231 
232  /* Ignore packets cancelled when the endpoint closes */
233  if ( ! ep->open )
234  goto ignore;
235 
236  /* Record USB errors against the network device */
237  if ( rc != 0 ) {
238  DBGC ( ncm, "NCM %p bulk IN failed: %s\n",
239  ncm, strerror ( rc ) );
240  goto error;
241  }
242 
243  /* Locate transfer header */
244  len = iob_len ( iobuf );
245  if ( sizeof ( *nth ) > len ) {
246  DBGC ( ncm, "NCM %p packet too short for NTH:\n", ncm );
247  rc = -EINVAL;
248  goto error;
249  }
250  nth = iobuf->data;
251 
252  /* Locate datagram pointer */
253  ndp_offset = le16_to_cpu ( nth->offset );
254  if ( ( ndp_offset + sizeof ( *ndp ) ) > len ) {
255  DBGC ( ncm, "NCM %p packet too short for NDP:\n", ncm );
256  rc = -EINVAL;
257  goto error;
258  }
259  ndp = ( iobuf->data + ndp_offset );
260  ndp_len = le16_to_cpu ( ndp->header_len );
261  if ( ndp_len < offsetof ( typeof ( *ndp ), desc ) ) {
262  DBGC ( ncm, "NCM %p NDP header length too short:\n", ncm );
263  rc = -EINVAL;
264  goto error;
265  }
266  if ( ( ndp_offset + ndp_len ) > len ) {
267  DBGC ( ncm, "NCM %p packet too short for NDP:\n", ncm );
268  rc = -EINVAL;
269  goto error;
270  }
271 
272  /* Process datagrams */
273  remaining = ( ( ndp_len - offsetof ( typeof ( *ndp ), desc ) ) /
274  sizeof ( ndp->desc[0] ) );
275  for ( desc = ndp->desc ; remaining && desc->offset ; remaining-- ) {
276 
277  /* Profile individual datagrams */
278  profile_start ( &ncm_in_datagram_profiler );
279 
280  /* Locate datagram */
281  pkt_offset = le16_to_cpu ( desc->offset );
282  pkt_len = le16_to_cpu ( desc->len );
283  if ( pkt_len < ETH_HLEN ) {
284  DBGC ( ncm, "NCM %p underlength datagram:\n", ncm );
285  rc = -EINVAL;
286  goto error;
287  }
288  if ( ( pkt_offset + pkt_len ) > len ) {
289  DBGC ( ncm, "NCM %p datagram exceeds packet:\n", ncm );
290  rc = -EINVAL;
291  goto error;
292  }
293 
294  /* Move to next descriptor */
295  desc++;
296 
297  /* Copy data to a new I/O buffer. Our USB buffers may
298  * be very large and so we choose to recycle the
299  * buffers directly rather than attempt reallocation
300  * while the device is running. We therefore copy the
301  * data to a new I/O buffer even if this is the only
302  * (or last) packet within the buffer.
303  *
304  * We reserve enough space at the start of each buffer
305  * to allow for our own transmission header, to
306  * support protocols such as ARP which may modify the
307  * received packet and reuse the same I/O buffer for
308  * transmission.
309  */
310  headroom = ( sizeof ( struct ncm_ntb_header ) + ncm->padding );
311  pkt = alloc_iob ( headroom + pkt_len );
312  if ( ! pkt ) {
313  /* Record error and continue */
315  continue;
316  }
317  iob_reserve ( pkt, headroom );
318  memcpy ( iob_put ( pkt, pkt_len ),
319  ( iobuf->data + pkt_offset ), pkt_len );
320 
321  /* Strip CRC, if present */
323  iob_unput ( pkt, 4 /* CRC32 */ );
324 
325  /* Hand off to network stack */
326  netdev_rx ( netdev, pkt );
327  profile_stop ( &ncm_in_datagram_profiler );
328  }
329 
330  /* Recycle I/O buffer */
331  usb_recycle ( &ncm->usbnet.in, iobuf );
332  profile_stop ( &ncm_in_profiler );
333 
334  return;
335 
336  error:
337  /* Record error against network device */
338  DBGC_HDA ( ncm, 0, iobuf->data, iob_len ( iobuf ) );
339  netdev_rx_err ( netdev, NULL, rc );
340  ignore:
341  usb_recycle ( &ncm->usbnet.in, iobuf );
342 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:116
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
struct ncm_datagram_pointer ndp
Datagram pointer.
Definition: ncm.h:130
CDC-NCM datagram pointer (16-bit)
Definition: ncm.h:102
struct arbelprm_completion_with_error error
Definition: arbel.h:12
CDC-NCM transfer header (16-bit)
Definition: ncm.h:77
#define DBGC(...)
Definition: compiler.h:505
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
int open
Endpoint is open.
Definition: usb.h:404
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
struct ncm_datagram_descriptor desc[0]
Datagram descriptors.
Definition: ncm.h:113
uint16_t offset
Offset of first datagram pointer.
Definition: ncm.h:87
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define ETH_HLEN
Definition: if_ether.h:9
static void usb_recycle(struct usb_endpoint *ep, struct io_buffer *iobuf)
Recycle I/O buffer.
Definition: usb.h:617
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct net_device * netdev
Network device.
Definition: ncm.h:142
#define DBGC_HDA(...)
Definition: compiler.h:506
uint16_t header_len
Header length.
Definition: ncm.h:106
CDC-NCM datagram descriptor (16-bit)
Definition: ncm.h:94
static struct net_device * netdev
Definition: gdbudp.c:52
uint16_t offset
Starting offset.
Definition: ncm.h:96
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define iob_unput(iobuf, len)
Definition: iobuf.h:131
#define NCM_DATAGRAM_POINTER_MAGIC_CRC
CDC-NCM datagram pointer CRC present flag.
Definition: ncm.h:120
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
A network device.
Definition: netdevice.h:348
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
uint16_t len
Length.
Definition: ncm.h:98
#define le16_to_cpu(value)
Definition: byteswap.h:112
A CDC-NCM network device.
Definition: ncm.h:136
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:470
uint32_t magic
Signature.
Definition: ncm.h:104
#define iob_reserve(iobuf, len)
Definition: iobuf.h:63
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:44
NTB constructed for transmitted packets (excluding padding)
Definition: ncm.h:126
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A persistent I/O buffer.
Definition: iobuf.h:32

References alloc_iob(), container_of, cpu_to_le32, io_buffer::data, DBGC, DBGC_HDA, ncm_datagram_pointer::desc, EINVAL, ENOMEM, error, ETH_HLEN, ncm_datagram_pointer::header_len, usbnet_device::in, iob_len(), iob_put, iob_reserve, iob_unput, le16_to_cpu, len, ncm_datagram_descriptor::len, ncm_datagram_pointer::magic, memcpy(), NCM_DATAGRAM_POINTER_MAGIC_CRC, ncm_ntb_header::ndp, netdev, ncm_device::netdev, netdev_rx(), netdev_rx_err(), NULL, ncm_transfer_header::offset, ncm_datagram_descriptor::offset, offsetof, usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), usb_recycle(), and ncm_device::usbnet.

◆ ncm_out_transmit()

static int ncm_out_transmit ( struct ncm_device ncm,
struct io_buffer iobuf 
)
static

Transmit packet.

Parameters
ncmCDC-NCM device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 356 of file ncm.c.

357  {
358  struct ncm_ntb_header *header;
359  size_t len = iob_len ( iobuf );
360  size_t header_len = ( sizeof ( *header ) + ncm->padding );
361  int rc;
362 
363  /* Profile transmissions */
364  profile_start ( &ncm_out_profiler );
365 
366  /* Prepend header */
367  if ( ( rc = iob_ensure_headroom ( iobuf, header_len ) ) != 0 )
368  return rc;
369  header = iob_push ( iobuf, header_len );
370 
371  /* Populate header */
373  header->nth.header_len = cpu_to_le16 ( sizeof ( header->nth ) );
374  header->nth.sequence = cpu_to_le16 ( ncm->sequence );
375  header->nth.len = cpu_to_le16 ( iob_len ( iobuf ) );
376  header->nth.offset =
377  cpu_to_le16 ( offsetof ( typeof ( *header ), ndp ) );
379  header->ndp.header_len = cpu_to_le16 ( sizeof ( header->ndp ) +
380  sizeof ( header->desc ) );
381  header->ndp.offset = cpu_to_le16 ( 0 );
382  header->desc[0].offset = cpu_to_le16 ( header_len );
383  header->desc[0].len = cpu_to_le16 ( len );
384  memset ( &header->desc[1], 0, sizeof ( header->desc[1] ) );
385 
386  /* Enqueue I/O buffer */
387  if ( ( rc = usb_stream ( &ncm->usbnet.out, iobuf, 0 ) ) != 0 )
388  return rc;
389 
390  /* Increment sequence number */
391  ncm->sequence++;
392 
393  profile_stop ( &ncm_out_profiler );
394  return 0;
395 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct ncm_datagram_pointer ndp
Datagram pointer.
Definition: ncm.h:130
#define iob_push(iobuf, len)
Definition: iobuf.h:80
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition: usb.c:528
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:31
uint16_t sequence
Transmitted packet sequence number.
Definition: ncm.h:149
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
#define cpu_to_le32(value)
Definition: byteswap.h:107
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
uint32_t len
Length.
Definition: ena.h:14
struct ena_aq_header header
Header.
Definition: ena.h:12
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define NCM_DATAGRAM_POINTER_MAGIC
CDC-NCM datagram pointer magic.
Definition: ncm.h:117
NTB constructed for transmitted packets (excluding padding)
Definition: ncm.h:126
#define NCM_TRANSFER_HEADER_MAGIC
CDC-NCM transfer header magic.
Definition: ncm.h:91
int iob_ensure_headroom(struct io_buffer *iobuf, size_t len)
Ensure I/O buffer has sufficient headroom.
Definition: iobuf.c:183
size_t padding
Alignment padding required on transmitted packets.
Definition: ncm.h:151
void * memset(void *dest, int character, size_t len) __nonnull

References cpu_to_le16, cpu_to_le32, header, iob_ensure_headroom(), iob_len(), iob_push, len, memset(), NCM_DATAGRAM_POINTER_MAGIC, NCM_TRANSFER_HEADER_MAGIC, ncm_ntb_header::ndp, offsetof, usbnet_device::out, ncm_device::padding, profile_start(), profile_stop(), rc, ncm_device::sequence, usb_stream(), and ncm_device::usbnet.

Referenced by ncm_transmit().

◆ ncm_out_complete()

static void ncm_out_complete ( struct usb_endpoint ep,
struct io_buffer iobuf,
int  rc 
)
static

Complete bulk OUT transfer.

Parameters
epUSB endpoint
iobufI/O buffer
rcCompletion status code

Definition at line 404 of file ncm.c.

405  {
406  struct ncm_device *ncm = container_of ( ep, struct ncm_device,
407  usbnet.out );
408  struct net_device *netdev = ncm->netdev;
409 
410  /* Report TX completion */
411  netdev_tx_complete_err ( netdev, iobuf, rc );
412 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:31
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct net_device * netdev
Network device.
Definition: ncm.h:142
static struct net_device * netdev
Definition: gdbudp.c:52
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
A network device.
Definition: netdevice.h:348
A CDC-NCM network device.
Definition: ncm.h:136
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:395

References container_of, netdev, ncm_device::netdev, netdev_tx_complete_err(), usbnet_device::out, rc, and ncm_device::usbnet.

◆ ncm_open()

static int ncm_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 432 of file ncm.c.

432  {
433  struct ncm_device *ncm = netdev->priv;
434  struct usb_device *usb = ncm->usb;
436  int rc;
437 
438  /* Reset sequence number */
439  ncm->sequence = 0;
440 
441  /* Prefill I/O buffers */
442  if ( ( rc = ncm_in_prefill ( ncm ) ) != 0 )
443  goto err_prefill;
444 
445  /* Set maximum input size */
446  memset ( &size, 0, sizeof ( size ) );
447  size.mtu = cpu_to_le32 ( ncm->usbnet.in.len );
448  if ( ( rc = usb_control ( usb, NCM_SET_NTB_INPUT_SIZE, 0,
449  ncm->usbnet.comms, &size,
450  sizeof ( size ) ) ) != 0 ) {
451  DBGC ( ncm, "NCM %p could not set input size to %zd: %s\n",
452  ncm, ncm->usbnet.in.len, strerror ( rc ) );
453  goto err_set_ntb_input_size;
454  }
455 
456  /* Set MAC address */
457  if ( ( rc = usb_control ( usb, NCM_SET_NET_ADDRESS, 0,
458  ncm->usbnet.comms, netdev->ll_addr,
459  netdev->ll_protocol->ll_addr_len ) ) != 0 ) {
460  DBGC ( ncm, "NCM %p could not set MAC address: %s\n",
461  ncm, strerror ( rc ) );
462  /* Ignore error and continue */
463  }
464 
465  /* Open USB network device */
466  if ( ( rc = usbnet_open ( &ncm->usbnet ) ) != 0 ) {
467  DBGC ( ncm, "NCM %p could not open: %s\n",
468  ncm, strerror ( rc ) );
469  goto err_open;
470  }
471 
472  return 0;
473 
474  usbnet_close ( &ncm->usbnet );
475  err_open:
476  err_set_ntb_input_size:
477  usb_flush ( &ncm->usbnet.in );
478  err_prefill:
479  return rc;
480 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned int comms
Communications interface.
Definition: usbnet.h:20
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
size_t len
Refill buffer payload length.
Definition: usb.h:423
static int ncm_in_prefill(struct ncm_device *ncm)
Prefill bulk IN endpoint.
Definition: ncm.c:159
#define DBGC(...)
Definition: compiler.h:505
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:753
Set NTB input size.
Definition: ncm.h:65
uint16_t sequence
Transmitted packet sequence number.
Definition: ncm.h:149
#define NCM_SET_NTB_INPUT_SIZE
Set NTB input size.
Definition: ncm.h:60
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
struct usb_device * usb
USB device.
Definition: ncm.h:138
#define cpu_to_le32(value)
Definition: byteswap.h:107
A USB device.
Definition: usb.h:706
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
#define NCM_SET_NET_ADDRESS
Set MAC address.
Definition: ncm.h:55
A CDC-NCM network device.
Definition: ncm.h:136
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
void usb_flush(struct usb_endpoint *ep)
Discard endpoint recycled buffer list.
Definition: usb.c:689
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:366
void * memset(void *dest, int character, size_t len) __nonnull
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:54

References usbnet_device::comms, cpu_to_le32, DBGC, usbnet_device::in, usb_endpoint::len, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memset(), ncm_in_prefill(), NCM_SET_NET_ADDRESS, NCM_SET_NTB_INPUT_SIZE, netdev, net_device::priv, rc, ncm_device::sequence, size, strerror(), ncm_device::usb, usb_control(), usb_flush(), ncm_device::usbnet, usbnet_close(), and usbnet_open().

◆ ncm_close()

static void ncm_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 487 of file ncm.c.

487  {
488  struct ncm_device *ncm = netdev->priv;
489 
490  /* Close USB network device */
491  usbnet_close ( &ncm->usbnet );
492 }
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
A CDC-NCM network device.
Definition: ncm.h:136
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127

References netdev, net_device::priv, ncm_device::usbnet, and usbnet_close().

◆ ncm_transmit()

static int ncm_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)
static

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 501 of file ncm.c.

502  {
503  struct ncm_device *ncm = netdev->priv;
504  int rc;
505 
506  /* Transmit packet */
507  if ( ( rc = ncm_out_transmit ( ncm, iobuf ) ) != 0 )
508  return rc;
509 
510  return 0;
511 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
static int ncm_out_transmit(struct ncm_device *ncm, struct io_buffer *iobuf)
Transmit packet.
Definition: ncm.c:356
A CDC-NCM network device.
Definition: ncm.h:136

References ncm_out_transmit(), netdev, net_device::priv, and rc.

◆ ncm_poll()

static void ncm_poll ( struct net_device netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 518 of file ncm.c.

518  {
519  struct ncm_device *ncm = netdev->priv;
520  int rc;
521 
522  /* Poll USB bus */
523  usb_poll ( ncm->bus );
524 
525  /* Refill endpoints */
526  if ( ( rc = usbnet_refill ( &ncm->usbnet ) ) != 0 )
527  netdev_rx_err ( netdev, NULL, rc );
528 
529 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition: usbnet.c:151
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition: usb.h:1049
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
A CDC-NCM network device.
Definition: ncm.h:136
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct usb_bus * bus
USB bus.
Definition: ncm.h:140

References ncm_device::bus, netdev, netdev_rx_err(), NULL, net_device::priv, rc, usb_poll(), ncm_device::usbnet, and usbnet_refill().

◆ ncm_probe()

static int ncm_probe ( struct usb_function func,
struct usb_configuration_descriptor config 
)
static

Probe device.

Parameters
funcUSB function
configConfiguration descriptor
Return values
rcReturn status code

Definition at line 553 of file ncm.c.

554  {
555  struct usb_device *usb = func->usb;
556  struct net_device *netdev;
557  struct ncm_device *ncm;
558  struct usb_interface_descriptor *comms;
559  struct ecm_ethernet_descriptor *ethernet;
560  struct ncm_ntb_parameters params;
561  int rc;
562 
563  /* Allocate and initialise structure */
564  netdev = alloc_etherdev ( sizeof ( *ncm ) );
565  if ( ! netdev ) {
566  rc = -ENOMEM;
567  goto err_alloc;
568  }
570  netdev->dev = &func->dev;
571  ncm = netdev->priv;
572  memset ( ncm, 0, sizeof ( *ncm ) );
573  ncm->usb = usb;
574  ncm->bus = usb->port->hub->bus;
575  ncm->netdev = netdev;
576  usbnet_init ( &ncm->usbnet, func, &ncm_intr_operations,
578  usb_refill_init ( &ncm->usbnet.intr, 0, 0, NCM_INTR_COUNT );
579  DBGC ( ncm, "NCM %p on %s\n", ncm, func->name );
580 
581  /* Describe USB network device */
582  if ( ( rc = usbnet_describe ( &ncm->usbnet, config ) ) != 0 ) {
583  DBGC ( ncm, "NCM %p could not describe: %s\n",
584  ncm, strerror ( rc ) );
585  goto err_describe;
586  }
587 
588  /* Locate Ethernet descriptor */
589  comms = usb_interface_descriptor ( config, ncm->usbnet.comms, 0 );
590  assert ( comms != NULL );
591  ethernet = ecm_ethernet_descriptor ( config, comms );
592  if ( ! ethernet ) {
593  DBGC ( ncm, "NCM %p has no Ethernet descriptor\n", ncm );
594  rc = -EINVAL;
595  goto err_ethernet;
596  }
597 
598  /* Fetch MAC address */
599  if ( ( rc = ecm_fetch_mac ( usb, ethernet, netdev->hw_addr ) ) != 0 ) {
600  DBGC ( ncm, "NCM %p could not fetch MAC address: %s\n",
601  ncm, strerror ( rc ) );
602  goto err_fetch_mac;
603  }
604 
605  /* Get NTB parameters */
606  if ( ( rc = usb_control ( usb, NCM_GET_NTB_PARAMETERS, 0,
607  ncm->usbnet.comms, &params,
608  sizeof ( params ) ) ) != 0 ) {
609  DBGC ( ncm, "NCM %p could not get NTB parameters: %s\n",
610  ncm, strerror ( rc ) );
611  goto err_ntb_parameters;
612  }
613 
614  /* Get maximum supported input size */
615  ncm->mtu = le32_to_cpu ( params.in.mtu );
616  DBGC2 ( ncm, "NCM %p maximum IN size is %zd bytes\n", ncm, ncm->mtu );
617 
618  /* Calculate transmit padding */
619  ncm->padding = ( ( le16_to_cpu ( params.out.remainder ) -
620  sizeof ( struct ncm_ntb_header ) - ETH_HLEN ) &
621  ( le16_to_cpu ( params.out.divisor ) - 1 ) );
622  DBGC2 ( ncm, "NCM %p using %zd-byte transmit padding\n",
623  ncm, ncm->padding );
624  assert ( ( ( sizeof ( struct ncm_ntb_header ) + ncm->padding +
625  ETH_HLEN ) % le16_to_cpu ( params.out.divisor ) ) ==
626  le16_to_cpu ( params.out.remainder ) );
627 
628  /* Register network device */
629  if ( ( rc = register_netdev ( netdev ) ) != 0 )
630  goto err_register;
631 
632  usb_func_set_drvdata ( func, ncm );
633  return 0;
634 
636  err_register:
637  err_ntb_parameters:
638  err_fetch_mac:
639  err_ethernet:
640  err_describe:
642  netdev_put ( netdev );
643  err_alloc:
644  return rc;
645 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
An Ethernet Functional Descriptor.
Definition: ecm.h:39
unsigned int comms
Communications interface.
Definition: usbnet.h:20
const char * name
Name.
Definition: usb.h:659
size_t mtu
Maximum supported NTB input size.
Definition: ncm.h:147
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define NCM_GET_NTB_PARAMETERS
Get NTB parameters.
Definition: ncm.h:22
#define DBGC(...)
Definition: compiler.h:505
struct usb_endpoint intr
Interrupt endpoint.
Definition: usbnet.h:27
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
Definition: usb.c:753
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
static struct usb_endpoint_driver_operations ncm_in_operations
Bulk IN endpoint operations.
Definition: ncm.c:345
#define ENOMEM
Not enough space.
Definition: errno.h:534
A USB interface descriptor.
Definition: usb.h:230
#define ETH_HLEN
Definition: if_ether.h:9
struct usb_port * port
USB port.
Definition: usb.h:710
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
struct net_device * netdev
Network device.
Definition: ncm.h:142
void * priv
Driver private data.
Definition: netdevice.h:425
struct ecm_ethernet_descriptor * ecm_ethernet_descriptor(struct usb_configuration_descriptor *config, struct usb_interface_descriptor *interface)
Locate Ethernet functional descriptor.
Definition: ecm.c:69
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
Definition: usb.h:601
static struct net_device * netdev
Definition: gdbudp.c:52
struct usb_device * usb
USB device.
Definition: ncm.h:138
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:690
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A USB device.
Definition: usb.h:706
struct usb_interface_descriptor * usb_interface_descriptor(struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate)
Locate USB interface descriptor.
Definition: usb.c:143
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
NTB parameters.
Definition: ncm.h:39
struct usbnet_device usbnet
USB network device.
Definition: ncm.h:144
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
int ecm_fetch_mac(struct usb_device *usb, struct ecm_ethernet_descriptor *desc, uint8_t *hw_addr)
Get hardware MAC address.
Definition: ecm.c:89
struct usb_device * usb
USB device.
Definition: usb.h:661
#define le16_to_cpu(value)
Definition: byteswap.h:112
A CDC-NCM network device.
Definition: ncm.h:136
static struct usb_endpoint_driver_operations ncm_out_operations
Bulk OUT endpoint operations.
Definition: ncm.c:415
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
static struct net_device_operations ncm_operations
CDC-NCM network device operations.
Definition: ncm.c:532
#define DBGC2(...)
Definition: compiler.h:522
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
Definition: usbnet.h:44
struct usb_hub * hub
USB hub.
Definition: usb.h:798
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:277
NTB constructed for transmitted packets (excluding padding)
Definition: ncm.h:126
struct device dev
Generic device.
Definition: usb.h:665
struct usb_bus * bus
USB bus.
Definition: usb.h:828
size_t padding
Alignment padding required on transmitted packets.
Definition: ncm.h:151
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static struct usb_endpoint_driver_operations ncm_intr_operations
Interrupt endpoint operations.
Definition: ncm.c:142
#define NCM_INTR_COUNT
Interrupt ring buffer count.
Definition: ncm.h:176
struct usb_bus * bus
USB bus.
Definition: ncm.h:140
void * memset(void *dest, int character, size_t len) __nonnull

References alloc_etherdev(), assert(), ncm_device::bus, usb_hub::bus, usbnet_device::comms, DBGC, DBGC2, net_device::dev, usb_function::dev, ncm_ntb_datagram_parameters::divisor, ecm_ethernet_descriptor(), ecm_fetch_mac(), EINVAL, ENOMEM, ETH_HLEN, usb_port::hub, net_device::hw_addr, ncm_ntb_parameters::in, usbnet_device::intr, le16_to_cpu, le32_to_cpu, memset(), ncm_ntb_datagram_parameters::mtu, ncm_device::mtu, usb_function::name, NCM_GET_NTB_PARAMETERS, ncm_in_operations, NCM_INTR_COUNT, ncm_intr_operations, ncm_operations, ncm_out_operations, netdev, ncm_device::netdev, netdev_init(), netdev_nullify(), netdev_put(), NULL, ncm_ntb_parameters::out, ncm_device::padding, usb_device::port, net_device::priv, rc, register_netdev(), ncm_ntb_datagram_parameters::remainder, strerror(), unregister_netdev(), ncm_device::usb, usb_function::usb, usb_control(), usb_func_set_drvdata(), usb_interface_descriptor(), usb_refill_init(), ncm_device::usbnet, usbnet_describe(), and usbnet_init().

◆ ncm_remove()

static void ncm_remove ( struct usb_function func)
static

Remove device.

Parameters
funcUSB function

Definition at line 652 of file ncm.c.

652  {
653  struct ncm_device *ncm = usb_func_get_drvdata ( func );
654  struct net_device *netdev = ncm->netdev;
655 
658  netdev_put ( netdev );
659 }
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:701
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
struct net_device * netdev
Network device.
Definition: ncm.h:142
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
A CDC-NCM network device.
Definition: ncm.h:136

References netdev, ncm_device::netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().

Variable Documentation

◆ __profiler

struct profiler ncm_out_profiler __profiler
static
Initial value:
=
{ .name = "ncm.intr" }

Interrupt completion profiler.

Bulk OUT profiler.

Bulk IN per-datagram profiler.

Bulk IN completion profiler.

Definition at line 44 of file ncm.c.

◆ ncm_intr_operations

struct usb_endpoint_driver_operations ncm_intr_operations
static
Initial value:
= {
.complete = ncm_intr_complete,
}
static void ncm_intr_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete interrupt transfer.
Definition: ncm.c:73

Interrupt endpoint operations.

Definition at line 142 of file ncm.c.

Referenced by ncm_probe().

◆ ncm_in_operations

struct usb_endpoint_driver_operations ncm_in_operations
static
Initial value:
= {
.complete = ncm_in_complete,
}
static void ncm_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
Definition: ncm.c:212

Bulk IN endpoint operations.

Definition at line 345 of file ncm.c.

Referenced by ncm_probe().

◆ ncm_out_operations

struct usb_endpoint_driver_operations ncm_out_operations
static
Initial value:
= {
.complete = ncm_out_complete,
}
static void ncm_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
Definition: ncm.c:404

Bulk OUT endpoint operations.

Definition at line 415 of file ncm.c.

Referenced by ncm_probe().

◆ ncm_operations

struct net_device_operations ncm_operations
static
Initial value:
= {
.open = ncm_open,
.close = ncm_close,
.transmit = ncm_transmit,
.poll = ncm_poll,
}
static void ncm_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: ncm.c:518
static int ncm_open(struct net_device *netdev)
Open network device.
Definition: ncm.c:432
static void ncm_close(struct net_device *netdev)
Close network device.
Definition: ncm.c:487
static int ncm_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: ncm.c:501

CDC-NCM network device operations.

Definition at line 532 of file ncm.c.

Referenced by ncm_probe().

◆ ncm_ids

struct usb_device_id ncm_ids[]
static
Initial value:
= {
{
.name = "cdc-ncm",
.vendor = USB_ANY_ID,
.product = USB_ANY_ID,
},
}
#define USB_ANY_ID
Match-anything ID.
Definition: usb.h:1329

CDC-NCM device IDs.

Definition at line 662 of file ncm.c.

◆ __usb_driver

struct usb_driver ncm_driver __usb_driver
Initial value:
= {
.ids = ncm_ids,
.id_count = ( sizeof ( ncm_ids ) / sizeof ( ncm_ids[0] ) ),
.score = USB_SCORE_NORMAL,
.probe = ncm_probe,
.remove = ncm_remove,
}
static int ncm_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: ncm.c:553
#define USB_SUBCLASS_CDC_NCM
CDC-NCM subclass.
Definition: ncm.h:19
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1345
Normal driver.
Definition: usb.h:1406
#define USB_CLASS_CDC
Class code for communications devices.
Definition: cdc.h:15
static void ncm_remove(struct usb_function *func)
Remove device.
Definition: ncm.c:652
static struct usb_device_id ncm_ids[]
CDC-NCM device IDs.
Definition: ncm.c:662

CDC-NCM driver.

Definition at line 671 of file ncm.c.