iPXE
acm.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 FILE_SECBOOT ( PERMITTED );
26 
27 #include <stdint.h>
28 #include <string.h>
29 #include <errno.h>
30 #include <byteswap.h>
31 #include <ipxe/profile.h>
32 #include <ipxe/usb.h>
33 #include <ipxe/usbnet.h>
34 #include <ipxe/rndis.h>
35 #include "acm.h"
36 
37 /** @file
38  *
39  * USB RNDIS driver
40  *
41  */
42 
43 /** Interrupt completion profiler */
44 static struct profiler acm_intr_profiler __profiler =
45  { .name = "acm.intr" };
46 
47 /** Bulk IN completion profiler */
48 static struct profiler acm_in_profiler __profiler =
49  { .name = "acm.in" };
50 
51 /** Bulk OUT profiler */
52 static struct profiler acm_out_profiler __profiler =
53  { .name = "acm.out" };
54 
55 /******************************************************************************
56  *
57  * USB RNDIS communications interface
58  *
59  ******************************************************************************
60  */
61 
62 /**
63  * Complete interrupt transfer
64  *
65  * @v ep USB endpoint
66  * @v iobuf I/O buffer
67  * @v rc Completion status code
68  */
69 static void acm_intr_complete ( struct usb_endpoint *ep,
70  struct io_buffer *iobuf, int rc ) {
71  struct acm_device *acm = container_of ( ep, struct acm_device,
72  usbnet.intr );
73  struct rndis_device *rndis = acm->rndis;
74  struct usb_setup_packet *message;
75 
76  /* Profile completions */
77  profile_start ( &acm_intr_profiler );
78 
79  /* Ignore packets cancelled when the endpoint closes */
80  if ( ! ep->open )
81  goto ignore;
82 
83  /* Drop packets with errors */
84  if ( rc != 0 ) {
85  DBGC ( acm, "ACM %p interrupt failed: %s\n",
86  acm, strerror ( rc ) );
87  DBGC_HDA ( acm, 0, iobuf->data, iob_len ( iobuf ) );
88  goto error;
89  }
90 
91  /* Extract message header */
92  if ( iob_len ( iobuf ) < sizeof ( *message ) ) {
93  DBGC ( acm, "ACM %p underlength interrupt:\n", acm );
94  DBGC_HDA ( acm, 0, iobuf->data, iob_len ( iobuf ) );
95  rc = -EINVAL;
96  goto error;
97  }
98  message = iobuf->data;
99 
100  /* Parse message header */
101  switch ( message->request ) {
102 
104  case cpu_to_le16 ( 0x0001 ) : /* qemu seems to use this value */
105  acm->responded = 1;
106  break;
107 
108  default:
109  DBGC ( acm, "ACM %p unrecognised interrupt:\n", acm );
110  DBGC_HDA ( acm, 0, iobuf->data, iob_len ( iobuf ) );
111  rc = -ENOTSUP;
112  goto error;
113  }
114 
115  /* Free I/O buffer */
116  free_iob ( iobuf );
117  profile_stop ( &acm_intr_profiler );
118 
119  return;
120 
121  error:
122  rndis_rx_err ( rndis, iob_disown ( iobuf ), rc );
123  ignore:
124  free_iob ( iobuf );
125  return;
126 }
127 
128 /** Interrupt endpoint operations */
131 };
132 
133 /******************************************************************************
134  *
135  * USB RNDIS data interface
136  *
137  ******************************************************************************
138  */
139 
140 /**
141  * Complete bulk IN transfer
142  *
143  * @v ep USB endpoint
144  * @v iobuf I/O buffer
145  * @v rc Completion status code
146  */
147 static void acm_in_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf,
148  int rc ) {
149  struct acm_device *acm = container_of ( ep, struct acm_device,
150  usbnet.in );
151  struct rndis_device *rndis = acm->rndis;
152 
153  /* Profile receive completions */
154  profile_start ( &acm_in_profiler );
155 
156  /* Ignore packets cancelled when the endpoint closes */
157  if ( ! ep->open )
158  goto ignore;
159 
160  /* Record USB errors against the RNDIS device */
161  if ( rc != 0 ) {
162  DBGC ( acm, "ACM %p bulk IN failed: %s\n",
163  acm, strerror ( rc ) );
164  goto error;
165  }
166 
167  /* Hand off to RNDIS */
168  rndis_rx ( rndis, iob_disown ( iobuf ) );
169 
170  profile_stop ( &acm_in_profiler );
171  return;
172 
173  error:
174  rndis_rx_err ( rndis, iob_disown ( iobuf ), rc );
175  ignore:
176  free_iob ( iobuf );
177 }
178 
179 /** Bulk IN endpoint operations */
182 };
183 
184 /**
185  * Transmit packet
186  *
187  * @v acm USB RNDIS device
188  * @v iobuf I/O buffer
189  * @ret rc Return status code
190  */
191 static int acm_out_transmit ( struct acm_device *acm,
192  struct io_buffer *iobuf ) {
193  int rc;
194 
195  /* Profile transmissions */
196  profile_start ( &acm_out_profiler );
197 
198  /* Enqueue I/O buffer */
199  if ( ( rc = usb_stream ( &acm->usbnet.out, iobuf, 0 ) ) != 0 )
200  return rc;
201 
202  profile_stop ( &acm_out_profiler );
203  return 0;
204 }
205 
206 /**
207  * Complete bulk OUT transfer
208  *
209  * @v ep USB endpoint
210  * @v iobuf I/O buffer
211  * @v rc Completion status code
212  */
213 static void acm_out_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf,
214  int rc ) {
215  struct acm_device *acm = container_of ( ep, struct acm_device,
216  usbnet.out );
217  struct rndis_device *rndis = acm->rndis;
218 
219  /* Report TX completion */
220  rndis_tx_complete_err ( rndis, iobuf, rc );
221 }
222 
223 /** Bulk OUT endpoint operations */
226 };
227 
228 /******************************************************************************
229  *
230  * USB RNDIS control interface
231  *
232  ******************************************************************************
233  */
234 
235 /**
236  * Send control packet
237  *
238  * @v acm USB RNDIS device
239  * @v iobuf I/O buffer
240  * @ret rc Return status code
241  */
242 static int acm_control_transmit ( struct acm_device *acm,
243  struct io_buffer *iobuf ) {
244  struct rndis_device *rndis = acm->rndis;
245  struct usb_device *usb = acm->usb;
246  int rc;
247 
248  /* Send packet as an encapsulated command */
249  if ( ( rc = cdc_send_encapsulated_command ( usb, acm->usbnet.comms,
250  iobuf->data,
251  iob_len ( iobuf ) ) ) != 0){
252  DBGC ( acm, "ACM %p could not send encapsulated command: %s\n",
253  acm, strerror ( rc ) );
254  return rc;
255  }
256 
257  /* Complete packet immediately */
258  rndis_tx_complete ( rndis, iobuf );
259 
260  return 0;
261 }
262 
263 /**
264  * Receive control packet
265  *
266  * @v acm USB RNDIS device
267  * @ret rc Return status code
268  */
269 static int acm_control_receive ( struct acm_device *acm ) {
270  struct rndis_device *rndis = acm->rndis;
271  struct usb_device *usb = acm->usb;
272  struct io_buffer *iobuf;
273  struct rndis_header *header;
274  size_t mtu = ACM_RESPONSE_MTU;
275  size_t len;
276  int rc;
277 
278  /* Allocate I/O buffer */
279  iobuf = alloc_iob ( mtu );
280  if ( ! iobuf ) {
281  rc = -ENOMEM;
282  goto err_alloc;
283  }
284 
285  /* Get encapsulated response */
286  if ( ( rc = cdc_get_encapsulated_response ( usb, acm->usbnet.comms,
287  iobuf->data, mtu ) ) != 0 ){
288  DBGC ( acm, "ACM %p could not get encapsulated response: %s\n",
289  acm, strerror ( rc ) );
290  goto err_get_response;
291  }
292 
293  /* Fix up buffer length */
294  header = iobuf->data;
295  len = le32_to_cpu ( header->len );
296  if ( len > mtu ) {
297  DBGC ( acm, "ACM %p overlength encapsulated response\n", acm );
298  DBGC_HDA ( acm, 0, iobuf->data, mtu );
299  rc = -EPROTO;
300  goto err_len;
301  }
302  iob_put ( iobuf, len );
303 
304  /* Hand off to RNDIS */
305  rndis_rx ( rndis, iob_disown ( iobuf ) );
306 
307  return 0;
308 
309  err_len:
310  err_get_response:
311  free_iob ( iobuf );
312  err_alloc:
313  return rc;
314 }
315 
316 /******************************************************************************
317  *
318  * RNDIS interface
319  *
320  ******************************************************************************
321  */
322 
323 /**
324  * Open RNDIS device
325  *
326  * @v rndis RNDIS device
327  * @ret rc Return status code
328  */
329 static int acm_open ( struct rndis_device *rndis ) {
330  struct acm_device *acm = rndis->priv;
331  int rc;
332 
333  /* Open USB network device */
334  if ( ( rc = usbnet_open ( &acm->usbnet ) ) != 0 )
335  goto err_open;
336 
337  return 0;
338 
339  usbnet_close ( &acm->usbnet );
340  err_open:
341  return rc;
342 }
343 
344 /**
345  * Close RNDIS device
346  *
347  * @v rndis RNDIS device
348  */
349 static void acm_close ( struct rndis_device *rndis ) {
350  struct acm_device *acm = rndis->priv;
351 
352  /* Close USB network device */
353  usbnet_close ( &acm->usbnet );
354 }
355 
356 /**
357  * Transmit packet
358  *
359  * @v rndis RNDIS device
360  * @v iobuf I/O buffer
361  * @ret rc Return status code
362  */
363 static int acm_transmit ( struct rndis_device *rndis,
364  struct io_buffer *iobuf ) {
365  struct acm_device *acm = rndis->priv;
366  struct rndis_header *header = iobuf->data;
367 
368  /* Sanity check */
369  assert ( iob_len ( iobuf ) >= sizeof ( *header ) );
370  assert ( iob_len ( iobuf ) == le32_to_cpu ( header->len ) );
371 
372  /* Transmit packet via appropriate mechanism */
373  if ( header->type == cpu_to_le32 ( RNDIS_PACKET_MSG ) ) {
374  return acm_out_transmit ( acm, iobuf );
375  } else {
376  return acm_control_transmit ( acm, iobuf );
377  }
378 }
379 
380 /**
381  * Poll for completed and received packets
382  *
383  * @v rndis RNDIS device
384  */
385 static void acm_poll ( struct rndis_device *rndis ) {
386  struct acm_device *acm = rndis->priv;
387  int rc;
388 
389  /* Poll USB bus */
390  usb_poll ( acm->bus );
391 
392  /* Refill rings */
393  if ( ( rc = usbnet_refill ( &acm->usbnet ) ) != 0 )
394  rndis_rx_err ( rndis, NULL, rc );
395 
396  /* Retrieve encapsulated response, if applicable */
397  if ( acm->responded ) {
398 
399  /* Clear flag */
400  acm->responded = 0;
401 
402  /* Get encapsulated response */
403  if ( ( rc = acm_control_receive ( acm ) ) != 0 )
404  rndis_rx_err ( rndis, NULL, rc );
405  }
406 }
407 
408 /** USB RNDIS operations */
410  .open = acm_open,
411  .close = acm_close,
412  .transmit = acm_transmit,
413  .poll = acm_poll,
414 };
415 
416 /******************************************************************************
417  *
418  * USB interface
419  *
420  ******************************************************************************
421  */
422 
423 /**
424  * Probe device
425  *
426  * @v func USB function
427  * @v config Configuration descriptor
428  * @ret rc Return status code
429  */
430 static int acm_probe ( struct usb_function *func,
431  struct usb_configuration_descriptor *config ) {
432  struct usb_device *usb = func->usb;
433  struct rndis_device *rndis;
434  struct acm_device *acm;
435  int rc;
436 
437  /* Allocate and initialise structure */
438  rndis = alloc_rndis ( sizeof ( *acm ) );
439  if ( ! rndis ) {
440  rc = -ENOMEM;
441  goto err_alloc;
442  }
444  rndis->netdev->dev = &func->dev;
445  acm = rndis->priv;
446  acm->usb = usb;
447  acm->bus = usb->port->hub->bus;
448  acm->rndis = rndis;
449  usbnet_init ( &acm->usbnet, func, &acm_intr_operations,
451  usb_refill_init ( &acm->usbnet.intr, 0, 0, ACM_INTR_MAX_FILL );
453 
454  /* Describe USB network device */
455  if ( ( rc = usbnet_describe ( &acm->usbnet, config ) ) != 0 ) {
456  DBGC ( acm, "ACM %p could not describe: %s\n",
457  acm, strerror ( rc ) );
458  goto err_describe;
459  }
460 
461  /* Register RNDIS device */
462  if ( ( rc = register_rndis ( rndis ) ) != 0 )
463  goto err_register;
464 
465  usb_func_set_drvdata ( func, acm );
466  return 0;
467 
469  err_register:
470  err_describe:
471  free_rndis ( rndis );
472  err_alloc:
473  return rc;
474 }
475 
476 /**
477  * Remove device
478  *
479  * @v func USB function
480  */
481 static void acm_remove ( struct usb_function *func ) {
482  struct acm_device *acm = usb_func_get_drvdata ( func );
483  struct rndis_device *rndis = acm->rndis;
484 
485  /* Unregister RNDIS device */
486  unregister_rndis ( rndis );
487 
488  /* Free RNDIS device */
489  free_rndis ( rndis );
490 }
491 
492 /** USB CDC-ACM device IDs */
493 static struct usb_device_id cdc_acm_ids[] = {
494  {
495  .name = "cdc-acm",
496  .vendor = USB_ANY_ID,
497  .product = USB_ANY_ID,
498  },
499 };
500 
501 /** USB CDC-ACM driver */
502 struct usb_driver cdc_acm_driver __usb_driver = {
503  .ids = cdc_acm_ids,
504  .id_count = ( sizeof ( cdc_acm_ids ) / sizeof ( cdc_acm_ids[0] ) ),
507  .score = USB_SCORE_DEPRECATED,
508  .probe = acm_probe,
509  .remove = acm_remove,
510 };
511 
512 /** USB RF-RNDIS device IDs */
513 static struct usb_device_id rf_rndis_ids[] = {
514  {
515  .name = "rf-rndis",
516  .vendor = USB_ANY_ID,
517  .product = USB_ANY_ID,
518  },
519 };
520 
521 /** USB RF-RNDIS driver */
522 struct usb_driver rf_rndis_driver __usb_driver = {
523  .ids = rf_rndis_ids,
524  .id_count = ( sizeof ( rf_rndis_ids ) / sizeof ( rf_rndis_ids[0] ) ),
527  .score = USB_SCORE_DEPRECATED,
528  .probe = acm_probe,
529  .remove = acm_remove,
530 };
struct rndis_device * alloc_rndis(size_t priv_len)
Allocate RNDIS device.
Definition: rndis.c:1001
A USB driver.
Definition: usb.h:1407
#define EINVAL
Invalid argument.
Definition: errno.h:429
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A USB device ID.
Definition: usb.h:1361
static void acm_intr_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete interrupt transfer.
Definition: acm.c:69
struct usb_bus * bus
USB bus.
Definition: acm.h:36
#define ACM_RESPONSE_MTU
Encapsulated response buffer size.
Definition: acm.h:68
#define iob_put(iobuf, len)
Definition: iobuf.h:125
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
Definition: usb.h:496
int(* open)(struct rndis_device *rndis)
Open RNDIS device.
Definition: rndis.h:290
unsigned int comms
Communications interface.
Definition: usbnet.h:21
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:718
static void acm_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
Definition: acm.c:213
#define le32_to_cpu(value)
Definition: byteswap.h:114
const char * name
Name.
Definition: usb.h:1363
Error codes.
static int acm_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: acm.c:430
#define CDC_RESPONSE_AVAILABLE
Response available.
Definition: cdc.h:45
Deprecated driver.
Definition: usb.h:1451
#define USB_SUBCLASS_CDC_ACM
CDC-ACM subclass.
Definition: acm.h:17
static void acm_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
Definition: acm.c:147
static void rndis_tx_complete(struct rndis_device *rndis, struct io_buffer *iobuf)
Complete message transmission.
Definition: rndis.h:365
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:153
struct usbnet_device usbnet
USB network device.
Definition: acm.h:40
struct arbelprm_completion_with_error error
Definition: arbel.h:12
void unregister_rndis(struct rndis_device *rndis)
Unregister RNDIS device.
Definition: rndis.c:1055
#define ACM_IN_MAX_FILL
Bulk IN maximum fill level.
Definition: acm.h:56
int responded
An encapsulated response is available.
Definition: acm.h:43
#define DBGC(...)
Definition: compiler.h:505
static int acm_control_transmit(struct acm_device *acm, struct io_buffer *iobuf)
Send control packet.
Definition: acm.c:242
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
Definition: usb.c:546
A data structure for storing profiling information.
Definition: profile.h:27
static struct usb_device_id rf_rndis_ids[]
USB RF-RNDIS device IDs.
Definition: acm.c:513
int open
Endpoint is open.
Definition: usb.h:419
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:174
static struct usb_device_id cdc_acm_ids[]
USB CDC-ACM device IDs.
Definition: acm.c:493
struct usb_endpoint intr
Interrupt endpoint.
Definition: usbnet.h:28
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:131
static struct rndis_operations acm_operations
USB RNDIS operations.
Definition: acm.c:409
#define ENOTSUP
Operation not supported.
Definition: errno.h:590
#define USB_CLASS_WIRELESS
Class code for wireless devices.
Definition: acm.h:23
struct usb_endpoint out
Bulk OUT endpoint.
Definition: usbnet.h:32
#define USB_PROTOCOL_RADIO_RNDIS
Radio frequency RNDIS device protocol.
Definition: acm.h:29
#define ENOMEM
Not enough space.
Definition: errno.h:535
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:217
A USB endpoint.
Definition: usb.h:404
const char * name
Name.
Definition: profile.h:29
static void acm_close(struct rndis_device *rndis)
Close RNDIS device.
Definition: acm.c:349
struct usb_port * port
USB port.
Definition: usb.h:727
static void acm_poll(struct rndis_device *rndis)
Poll for completed and received packets.
Definition: acm.c:385
static void acm_remove(struct usb_function *func)
Remove device.
Definition: acm.c:481
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:36
struct net_device * netdev
Network device.
Definition: rndis.h:320
static int cdc_get_encapsulated_response(struct usb_device *usb, unsigned int interface, void *data, size_t len)
Get encapsulated response.
Definition: cdc.h:98
FILE_SECBOOT(PERMITTED)
#define DBGC_HDA(...)
Definition: compiler.h:506
ring len
Length.
Definition: dwmac.h:231
An RNDIS device.
Definition: rndis.h:318
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:617
static int cdc_send_encapsulated_command(struct usb_device *usb, unsigned int interface, void *data, size_t len)
Send encapsulated command.
Definition: cdc.h:81
struct usb_device * usb
USB device.
Definition: acm.h:34
#define USB_SUBCLASS_WIRELESS_RADIO
Radio frequency device subclass.
Definition: acm.h:26
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:707
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:161
USB RNDIS Ethernet driver.
Profiling.
void rndis_rx_err(struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
Discard packet from underlying transport layer.
Definition: rndis.c:867
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
Definition: usbnet.c:152
#define cpu_to_le32(value)
Definition: byteswap.h:108
A USB device.
Definition: usb.h:723
#define EPROTO
Protocol error.
Definition: errno.h:625
#define ACM_INTR_MAX_FILL
Interrupt maximum fill level.
Definition: acm.h:50
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
Definition: usb.h:1072
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
int register_rndis(struct rndis_device *rndis)
Register RNDIS device.
Definition: rndis.c:1027
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:160
static struct usb_endpoint_driver_operations acm_out_operations
Bulk OUT endpoint operations.
Definition: acm.c:224
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1389
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:30
#define ACM_IN_MTU
Bulk IN buffer size.
Definition: acm.h:62
static struct usb_endpoint_driver_operations acm_in_operations
Bulk IN endpoint operations.
Definition: acm.c:180
Remote Network Driver Interface Specification.
A USB RNDIS network device.
Definition: acm.h:32
RNDIS device operations.
Definition: rndis.h:283
void rndis_rx(struct rndis_device *rndis, struct io_buffer *iobuf)
Receive packet from underlying transport layer.
Definition: rndis.c:830
struct usb_device * usb
USB device.
Definition: usb.h:678
static struct profiler acm_intr_profiler __profiler
Interrupt completion profiler.
Definition: acm.c:44
A USB setup data packet.
Definition: usb.h:83
static void rndis_init(struct rndis_device *rndis, struct rndis_operations *op)
Initialise an RNDIS device.
Definition: rndis.h:340
#define USB_CLASS_CDC
Class code for communications devices.
Definition: cdc.h:16
static int acm_open(struct rndis_device *rndis)
Open RNDIS device.
Definition: acm.c:329
struct device * dev
Underlying hardware device.
Definition: netdevice.h:365
static struct usb_endpoint_driver_operations acm_intr_operations
Interrupt endpoint operations.
Definition: acm.c:129
RNDIS message header.
Definition: rndis.h:24
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
USB network devices.
A USB configuration descriptor.
Definition: usb.h:210
#define USB_ANY_ID
Match-anything ID.
Definition: usb.h:1373
Universal Serial Bus (USB)
static int acm_transmit(struct rndis_device *rndis, struct io_buffer *iobuf)
Transmit packet.
Definition: acm.c:363
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
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:45
void * data
Start of data.
Definition: iobuf.h:53
struct usb_hub * hub
USB hub.
Definition: usb.h:815
void * priv
Driver private data.
Definition: rndis.h:326
struct ena_llq_option header
Header locations.
Definition: ena.h:16
#define RNDIS_PACKET_MSG
RNDIS packet message.
Definition: rndis.h:220
#define USB_PROTOCOL_ACM_RNDIS
CDC-ACM RNDIS device protocol.
Definition: acm.h:20
#define cpu_to_le16(value)
Definition: byteswap.h:107
struct usb_driver cdc_acm_driver __usb_driver
USB CDC-ACM driver.
Definition: acm.c:502
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:278
char message[VMCONSOLE_BUFSIZE]
Definition: vmconsole.c:54
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:128
USB endpoint driver operations.
Definition: usb.h:489
struct device dev
Generic device.
Definition: usb.h:682
A USB function.
Definition: usb.h:674
static int acm_out_transmit(struct acm_device *acm, struct io_buffer *iobuf)
Transmit packet.
Definition: acm.c:191
struct usb_bus * bus
USB bus.
Definition: usb.h:845
static int acm_control_receive(struct acm_device *acm)
Receive control packet.
Definition: acm.c:269
void free_rndis(struct rndis_device *rndis)
Free RNDIS device.
Definition: rndis.c:1067
void rndis_tx_complete_err(struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
Complete message transmission.
Definition: rndis.c:128
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
String functions.
struct rndis_device * rndis
RNDIS device.
Definition: acm.h:38
struct usb_device_id * ids
USB ID table.
Definition: usb.h:1409
A persistent I/O buffer.
Definition: iobuf.h:38
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:55