xref: /haiku/src/add-ons/kernel/drivers/network/ether/usb_ecm/Driver.h (revision 7b3e89c0944ae1efa9a8fc66c7303874b7a344b2)
1 /*
2 	Driver for USB Ethernet Control Model devices
3 	Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch>
4 	Distributed under the terms of the MIT license.
5 */
6 #ifndef _USB_ECM_DRIVER_H_
7 #define _USB_ECM_DRIVER_H_
8 
9 #include <device_manager.h>
10 #include <Drivers.h>
11 #include <KernelExport.h>
12 #include <OS.h>
13 #include <USB3.h>
14 
15 #include <util/kernel_cpp.h>
16 
17 #define DRIVER_NAME	"usb_ecm"
18 #define MAX_DEVICES	8
19 
20 /* class and subclass codes */
21 #define USB_INTERFACE_CLASS_CDC			0x02
22 #define USB_INTERFACE_SUBCLASS_ECM		0x06
23 #define USB_INTERFACE_CLASS_CDC_DATA	0x0a
24 #define USB_INTERFACE_SUBCLASS_DATA		0x00
25 
26 /* communication device descriptor subtypes */
27 #define FUNCTIONAL_SUBTYPE_UNION		0x06
28 #define FUNCTIONAL_SUBTYPE_ETHERNET		0x0f
29 
30 typedef struct ethernet_functional_descriptor_s {
31 	uint8	functional_descriptor_subtype;
32 	uint8	mac_address_index;
33 	uint32	ethernet_statistics;
34 	uint16	max_segment_size;
35 	uint16	num_multi_cast_filters;
36 	uint8	num_wakeup_pattern_filters;
37 } _PACKED ethernet_functional_descriptor;
38 
39 /* notification definitions */
40 #define CDC_NOTIFY_NETWORK_CONNECTION		0x00
41 #define CDC_NOTIFY_CONNECTION_SPEED_CHANGE	0x2a
42 
43 typedef struct cdc_notification_s {
44 	uint8	request_type;
45 	uint8	notification_code;
46 	uint16	value;
47 	uint16	index;
48 	uint16	data_length;
49 	uint8	data[0];
50 } _PACKED cdc_notification;
51 
52 typedef struct cdc_connection_speed_s {
53 	uint32	upstream_speed; /* in bits/s */
54 	uint32	downstream_speed; /* in bits/s */
55 } _PACKED cdc_connection_speed;
56 
57 extern usb_module_info *gUSBModule;
58 extern device_manager_info *gDeviceManager;
59 
60 class ECMDevice;
61 
62 // bus manager device interface for peripheral driver
63 typedef struct {
64         driver_module_info info;
65 
66 } usb_device_interface;
67 
68 
69 typedef struct {
70 	device_node*			node;
71 	::usb_device			usb_device;
72 	usb_device_interface*	usb;
73 	ECMDevice *				device;
74 } usb_ecm_driver_info;
75 
76 
77 
78 #define	TRACE(x...)			dprintf(DRIVER_NAME ": " x)
79 #define TRACE_ALWAYS(x...)	dprintf(DRIVER_NAME ": " x)
80 #define CALLED() 			TRACE("CALLED %s\n", __PRETTY_FUNCTION__)
81 
82 
83 #endif //_USB_ECM_DRIVER_H_
84