summaryrefslogtreecommitdiffstats
path: root/qemu/roms/ipxe/src/include/ipxe/usbnet.h
blob: 33a8f3f587cafe569d8d96d9dc9e8bb81611aba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _IPXE_USBNET_H
#define _IPXE_USBNET_H

/** @file
 *
 * USB network devices
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <ipxe/usb.h>

/** A USB network device */
struct usbnet_device {
	/** USB function */
	struct usb_function *func;

	/** Communications interface */
	unsigned int comms;
	/** Data interface */
	unsigned int data;
	/** Alternate setting for data interface */
	unsigned int alternate;

	/** Interrupt endpoint */
	struct usb_endpoint intr;
	/** Bulk IN endpoint */
	struct usb_endpoint in;
	/** Bulk OUT endpoint */
	struct usb_endpoint out;
};

/**
 * Initialise USB network device
 *
 * @v usbnet		USB network device
 * @v func		USB function
 * @v intr		Interrupt endpoint operations
 * @v in		Bulk IN endpoint operations
 * @v out		Bulk OUT endpoint operations
 */
static inline __attribute__ (( always_inline )) 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 ) {
	struct usb_device *usb = func->usb;

	usbnet->func = func;
	usb_endpoint_init ( &usbnet->intr, usb, intr );
	usb_endpoint_init ( &usbnet->in, usb, in );
	usb_endpoint_init ( &usbnet->out, usb, out );
}

extern int usbnet_open ( struct usbnet_device *usbnet );
extern void usbnet_close ( struct usbnet_device *usbnet );
extern int usbnet_refill ( struct usbnet_device *usbnet );
extern int usbnet_describe ( struct usbnet_device *usbnet,
			     struct usb_configuration_descriptor *config );

#endif /* _IPXE_USBNET_H */