1133359Sobrien/* 2133359Sobrien Driver for USB Ethernet Control Model devices 3226048Sobrien Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch> 4133359Sobrien Distributed under the terms of the MIT license. 5133359Sobrien*/ 6133359Sobrien#ifndef _USB_ECM_DRIVER_H_ 7133359Sobrien#define _USB_ECM_DRIVER_H_ 8133359Sobrien 9133359Sobrien#include <device_manager.h> 10133359Sobrien#include <Drivers.h> 11133359Sobrien#include <KernelExport.h> 12133359Sobrien#include <OS.h> 13133359Sobrien#include <USB3.h> 14133359Sobrien 15133359Sobrien#include <util/kernel_cpp.h> 16133359Sobrien 17133359Sobrien#define DRIVER_NAME "usb_ecm" 18133359Sobrien#define MAX_DEVICES 8 19133359Sobrien 20133359Sobrien/* class and subclass codes */ 21133359Sobrien#define USB_INTERFACE_CLASS_CDC 0x02 22133359Sobrien#define USB_INTERFACE_SUBCLASS_ECM 0x06 23133359Sobrien#define USB_INTERFACE_CLASS_CDC_DATA 0x0a 24133359Sobrien#define USB_INTERFACE_SUBCLASS_DATA 0x00 25133359Sobrien 26133359Sobrien/* communication device descriptor subtypes */ 27133359Sobrien#define FUNCTIONAL_SUBTYPE_UNION 0x06 28133359Sobrien#define FUNCTIONAL_SUBTYPE_ETHERNET 0x0f 29133359Sobrien 30133359Sobrientypedef struct ethernet_functional_descriptor_s { 31133359Sobrien uint8 functional_descriptor_subtype; 32133359Sobrien uint8 mac_address_index; 33133359Sobrien uint32 ethernet_statistics; 34139368Sobrien uint16 max_segment_size; 35139368Sobrien uint16 num_multi_cast_filters; 36139368Sobrien uint8 num_wakeup_pattern_filters; 37133359Sobrien} _PACKED ethernet_functional_descriptor; 38139368Sobrien 39139368Sobrien/* notification definitions */ 40139368Sobrien#define CDC_NOTIFY_NETWORK_CONNECTION 0x00 41133359Sobrien#define CDC_NOTIFY_CONNECTION_SPEED_CHANGE 0x2a 42139368Sobrien 43133359Sobrientypedef struct cdc_notification_s { 44139368Sobrien uint8 request_type; 45139368Sobrien uint8 notification_code; 46 uint16 value; 47 uint16 index; 48 uint16 data_length; 49 uint8 data[0]; 50} _PACKED cdc_notification; 51 52typedef 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 57extern usb_module_info *gUSBModule; 58extern device_manager_info *gDeviceManager; 59 60class ECMDevice; 61 62// bus manager device interface for peripheral driver 63typedef struct { 64 driver_module_info info; 65 66} usb_device_interface; 67 68 69typedef 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#ifdef TRACE_ECM 78#define TRACE(x...) dprintf(DRIVER_NAME ": " x) 79#define CALLED() TRACE("CALLED %s\n", __PRETTY_FUNCTION__) 80#else 81#define TRACE(x...) 82#define CALLED() 83#endif 84#define TRACE_ALWAYS(x...) dprintf(DRIVER_NAME ": " x) 85 86 87#endif //_USB_ECM_DRIVER_H_ 88