xref: /haiku/src/add-ons/kernel/drivers/network/ether/usb_ecm/Driver.h (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
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 <Drivers.h>
10 #include <KernelExport.h>
11 #include <OS.h>
12 #include <USB3.h>
13 
14 #include <util/kernel_cpp.h>
15 
16 #define DRIVER_NAME	"usb_ecm"
17 #define MAX_DEVICES	8
18 
19 /* class and subclass codes */
20 #define USB_INTERFACE_CLASS_CDC			0x02
21 #define USB_INTERFACE_SUBCLASS_ECM		0x06
22 #define USB_INTERFACE_CLASS_CDC_DATA	0x0a
23 #define USB_INTERFACE_SUBCLASS_DATA		0x00
24 
25 /* communication device descriptor subtypes */
26 #define FUNCTIONAL_SUBTYPE_UNION		0x06
27 #define FUNCTIONAL_SUBTYPE_ETHERNET		0x0f
28 
29 typedef struct ethernet_functional_descriptor_s {
30 	uint8	functional_descriptor_subtype;
31 	uint8	mac_address_index;
32 	uint32	ethernet_statistics;
33 	uint16	max_segment_size;
34 	uint16	num_multi_cast_filters;
35 	uint8	num_wakeup_pattern_filters;
36 } _PACKED ethernet_functional_descriptor;
37 
38 /* notification definitions */
39 #define CDC_NOTIFY_NETWORK_CONNECTION		0x00
40 #define CDC_NOTIFY_CONNECTION_SPEED_CHANGE	0x2a
41 
42 typedef struct cdc_notification_s {
43 	uint8	request_type;
44 	uint8	notification_code;
45 	uint16	value;
46 	uint16	index;
47 	uint16	data_length;
48 	uint8	data[0];
49 } _PACKED cdc_notification;
50 
51 typedef struct cdc_connection_speed_s {
52 	uint32	upstream_speed; /* in bits/s */
53 	uint32	downstream_speed; /* in bits/s */
54 } _PACKED cdc_connection_speed;
55 
56 extern usb_module_info *gUSBModule;
57 
58 extern "C" {
59 status_t	usb_ecm_device_added(usb_device device, void **cookie);
60 status_t	usb_ecm_device_removed(void *cookie);
61 
62 status_t	init_hardware();
63 void		uninit_driver();
64 
65 const char **publish_devices();
66 device_hooks *find_device(const char *name);
67 }
68 
69 #define	TRACE(x...)			/*dprintf(DRIVER_NAME ": " x)*/
70 #define TRACE_ALWAYS(x...)	dprintf(DRIVER_NAME ": " x)
71 
72 #endif //_USB_ECM_DRIVER_H_
73