⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net-fd.c

📁 Linux2.4.20针对三星公司的s3c2440内核基础上的一些设备驱动代码
💻 C
📖 第 1 页 / 共 4 页
字号:
static __devinitdata struct usb_interface_description net_interfaces[] = {	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"",                #else                        iInterface:"Simple Network Data Interface",                #endif                bInterfaceClass:LINEO_CLASS,                bInterfaceSubClass:LINEO_SUBCLASS_SAFENET,                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        bInterfaceProtocol:LINEO_SAFENET_CRC_PADDED,                #else                        bInterfaceProtocol:LINEO_SAFENET_CRC,                #endif                alternates:sizeof (net_data_alternate_descriptions) / sizeof (struct usb_alternate_description),                alternate_list:net_data_alternate_descriptions,},};#endif				/* CONFIG_USBD_NET_SAFE *//* USB CDC Configuration ********************************************************************* */#ifdef CONFIG_USBD_NET_CDC/* * CDC Ethernet Configuration *//* Communication Interface Class descriptions */static struct usb_class_description cdc_comm_class_descriptions[] = {	{ CS_INTERFACE, USB_ST_HEADER,  0, { header: { bcdCDC: CLASS_BCD_VERSION, } }},	{ CS_INTERFACE, USB_ST_ENF,     0,	      {ethernet_networking:		      {iMACAddress:NULL,			      bmEthernetStatistics: 0, wMaxSegmentSize:1514,              wNumberMCFilters: 0, bNumberPowerFilters:0,}}},	{ CS_INTERFACE, USB_ST_UF,      1, { union_function: { bMasterInterface: 0, bSlaveInterface: { 1 }, }}},};/* Data Interface Alternate 1 endpoints */static __devinitdata struct usb_endpoint_description net_alt_1_endpoints[] = {      {bEndpointAddress:CONFIG_USBD_NET_OUT_ENDPOINT,	      bmAttributes:BULK,	      wMaxPacketSize:CONFIG_USBD_NET_OUT_PKTSIZE,	      bInterval:0,	      direction:OUT,              transferSize:MAXTRANSFER + 2,},      {bEndpointAddress:CONFIG_USBD_NET_IN_ENDPOINT,	      bmAttributes:BULK,	      wMaxPacketSize:CONFIG_USBD_NET_IN_PKTSIZE,	      bInterval:0,	      direction:IN,              transferSize:MAXTRANSFER + 2,},#if defined(CONFIG_USBD_NET_INT_ENDPOINT) && (CONFIG_USBD_NET_INT_ENDPOINT > 0)      {bEndpointAddress:CONFIG_USBD_NET_INT_ENDPOINT,	      bmAttributes:INTERRUPT,	      wMaxPacketSize:CONFIG_USBD_NET_INT_PKTSIZE,	      bInterval:10,	      direction:IN,              transferSize:CONFIG_USBD_NET_INT_PKTSIZE,},#endif};/* Data Interface Alternate description(s) */static __devinitdata struct usb_alternate_description cdc_comm_alternate_descriptions[] = {	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"",                #else                        iInterface:"CDC Network Comm Interface",                #endif                bAlternateSetting:0,                classes:sizeof (cdc_comm_class_descriptions) / sizeof (struct usb_class_description),                class_list:cdc_comm_class_descriptions,},};static __devinitdata struct usb_alternate_description cdc_data_alternate_descriptions[] = {	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"Bulk Disabled",                #else                        iInterface:"CDC Network Data Interface - Disabled mode",                #endif#ifdef CONFIG_ARCH_LUBBOCK                bAlternateSetting:1,},#else                bAlternateSetting:0,},#endif	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"Data Enabled",                #else                        iInterface:"CDC Network Data Interface - Bulk mode",                #endif#ifdef CONFIG_ARCH_LUBBOCK                bAlternateSetting:0,#else                bAlternateSetting:1,#endif                endpoints:sizeof (net_alt_1_endpoints) / sizeof (struct usb_endpoint_description),                endpoint_list:net_alt_1_endpoints,},};/* Interface description(s) */static __devinitdata struct usb_interface_description cdc_interfaces[] = {	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"",                #else                        iInterface:"CDC Network Communication Interface",                #endif                bInterfaceClass:COMMUNICATIONS_INTERFACE_CLASS,                bInterfaceSubClass:COMMUNICATIONS_ENCM_SUBCLASS,                bInterfaceProtocol:COMMUNICATIONS_NO_PROTOCOL,                alternates:sizeof (cdc_comm_alternate_descriptions) / sizeof (struct usb_alternate_description),                alternate_list:cdc_comm_alternate_descriptions,},	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"",                #else                        iInterface:"CDC Network Data Interface",                #endif                bInterfaceClass:DATA_INTERFACE_CLASS,                bInterfaceSubClass:COMMUNICATIONS_NO_SUBCLASS,                bInterfaceProtocol:COMMUNICATIONS_NO_PROTOCOL,                alternates:sizeof (cdc_data_alternate_descriptions) / sizeof (struct usb_alternate_description),                alternate_list:cdc_data_alternate_descriptions,},};#endif				/* CONFIG_USBD_NET_CDC *//* USB MDLM Configuration ******************************************************************** */#ifdef CONFIG_USBD_NET_MDLM/* * MDML Ethernet Configuration *//* Communication Interface Class descriptions */static struct usb_class_description mdlm_comm_class_descriptions[] = {{ CS_INTERFACE, USB_ST_HEADER,  0, { header: { bcdCDC: CLASS_BCD_VERSION, } }},	{ CS_INTERFACE, USB_ST_MDLM, 0, { mobile_direct: {                                bcdVersion:0x0100,                                bGUID:{                                            0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6,                                            0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f}}}	 },      { CS_INTERFACE, USB_ST_MDLMD, 2, {mobile_direct_detail:{                                                      // XXX FIXME                                bGuidDescriptorType:0x00,                                bDetailData:{0x0, 0x3}}}      },      //{ CS_INTERFACE,  USB_ST_MDLMD, 1, { mobile_direct_detail: {      //    bGuidDescriptorType: 0x01,	//    bDetailData: { 0x02 } } }	//},	{ CS_INTERFACE, USB_ST_ENF, 0,	      {ethernet_networking:		      {iMACAddress:"402233445566",                                bmEthernetStatistics: 0, wMaxSegmentSize:1514,                                wNumberMCFilters: 0, bNumberPowerFilters:0,}}	 },	//{ CS_INTERFACE,  USB_ST_UF,      1, { union_function: { bMasterInterface: 0, bSlaveInterface: { 0 }, }}},};/* Data Interface Alternate 1 endpoints */static __devinitdata struct usb_endpoint_description mdlm_alt_1_endpoints[] = {      {bEndpointAddress:CONFIG_USBD_NET_OUT_ENDPOINT,	      bmAttributes:BULK,	      wMaxPacketSize:CONFIG_USBD_NET_OUT_PKTSIZE,	      bInterval:0,	      direction:OUT,              transferSize:MAXTRANSFER + 2,},      {bEndpointAddress:CONFIG_USBD_NET_IN_ENDPOINT,	      bmAttributes:BULK,	      wMaxPacketSize:CONFIG_USBD_NET_IN_PKTSIZE,	      bInterval:0,	      direction:IN,              transferSize:MAXTRANSFER + 2,},#if defined(CONFIG_USBD_NET_INT_ENDPOINT) && (CONFIG_USBD_NET_INT_ENDPOINT > 0)      {bEndpointAddress:CONFIG_USBD_NET_INT_ENDPOINT,	      bmAttributes:INTERRUPT,	      wMaxPacketSize:CONFIG_USBD_NET_INT_PKTSIZE,	      bInterval:10,	      direction:IN,              transferSize:CONFIG_USBD_NET_INT_PKTSIZE,},#endif};/* Data Interface Alternate description(s) */static __devinitdata struct usb_alternate_description mdlm_alternate_descriptions[] = {	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"",                #else                        iInterface:"MDLM Network Communication Interface",                #endif                bAlternateSetting:0,                classes:sizeof (mdlm_comm_class_descriptions) / sizeof (struct usb_class_description),                class_list:mdlm_comm_class_descriptions,                endpoints:sizeof (mdlm_alt_1_endpoints) / sizeof (struct usb_endpoint_description),                endpoint_list:mdlm_alt_1_endpoints,},};/* Interface description(s) */static __devinitdata struct usb_interface_description mdlm_interfaces[] = {	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iInterface:"",                #else                        iInterface:"MDLM Network Interface",                #endif                bInterfaceClass:COMMUNICATIONS_INTERFACE_CLASS,                bInterfaceSubClass:COMMUNICATIONS_MDLM_SUBCLASS,                bInterfaceProtocol:COMMUNICATIONS_NO_PROTOCOL,                alternates:sizeof (mdlm_alternate_descriptions) / sizeof (struct usb_alternate_description),                alternate_list:mdlm_alternate_descriptions,},};#endif				/* CONFIG_USBD_NET_CDC *//* USB Configuration ************************************************************************* *//* Configuration description(s) */struct __devinitdata usb_configuration_description net_description[] = {#ifdef CONFIG_USBD_NET_CDC	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iConfiguration:"",                #else                        iConfiguration:"CDC 1.1 Configuration",                #endif                bmAttributes:BMATTRIBUTE,                bMaxPower:BMAXPOWER,                interfaces:sizeof (cdc_interfaces) / sizeof (struct usb_interface_description),                interface_list:cdc_interfaces,},#endif				/* CONFIG_USBD_NET_CDC */#ifdef CONFIG_USBD_NET_MDLM	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iConfiguration:"",                #else	                iConfiguration:"MDLM Network Configuration",                #endif	        bmAttributes:BMATTRIBUTE,	        bMaxPower:BMAXPOWER,	        interfaces:sizeof (mdlm_interfaces) / sizeof (struct usb_interface_description),                interface_list:mdlm_interfaces,},#endif				/* CONFIG_USBD_NET_SAFE */#ifdef CONFIG_USBD_NET_SAFE	{                #if defined(CONFIG_USBD_NET_NO_STRINGS)                        iConfiguration:"",                #else                        iConfiguration:"USB Simple Ethernet Configuration",                #endif                bmAttributes:BMATTRIBUTE,                bMaxPower:BMAXPOWER,                interfaces:sizeof (net_interfaces) / sizeof (struct usb_interface_description),                interface_list:net_interfaces,},#endif				/* CONFIG_USBD_NET_SAFE */};/* Device Description */struct __devinitdata usb_device_description net_device_description = {	bDeviceClass:COMMUNICATIONS_DEVICE_CLASS,        bDeviceSubClass:COMMUNICATIONS_ENCM_SUBCLASS,	bDeviceProtocol:0,	// XXX	idVendor:CONFIG_USBD_VENDORID,	idProduct:CONFIG_USBD_PRODUCTID,	iManufacturer:CONFIG_USBD_MANUFACTURER,	iProduct:CONFIG_USBD_PRODUCT_NAME,	iSerialNumber:CONFIG_USBD_SERIAL_NUMBER_STR,};#undef NET_DESTRUCTOR#ifdef NET_DESTRUCTOR#warning DESTRUCTORvoid net_dev_kfree_skb_any (struct sk_buff *skb){	printk (KERN_DEBUG		"net_dev_kfree_skb: skb: %p head: %p data: %p tail: %p end: %p len: %d\n", skb,		skb->head, skb->data, skb->tail, skb->end, skb->len);}#endif/* * * net_dev_alloc_skb - allocate an skb  * @len: * * Allocate an skb.  */static __inline__ struct sk_buff *net_dev_alloc_skb (int len){	struct sk_buff *skb;	if ((skb = netproto_dev_alloc_skb (len))) {#ifdef NET_DESTRUCTOR		skb->destructor = net_dev_kfree_skb_any;#endif	}	return skb;}static int net_xmit_skb (int, struct sk_buff *);static int net_set_addr (int, void *, int);static int net_tx_timeout (int);/* Intialize and destroy network interfaces ************************************************** *//* * * net_create - create an interface * @device: usb device instance * */void net_create (struct usb_device_instance *device, struct usb_function_instance *function){	int i;	struct usb_net_private *net_private;	dbg_init (1, "---> privdata: %p", function->privdata);        // lock and find an empty slot        {			// get module lock, search for empty device slot, if successful allocate and save                unsigned long flags;                write_lock_irqsave (&net_rwlock, flags);                // check if we already have an interface                if ((net_private = function->privdata) && (net_private->flags & NET_INUSE)) {                        write_unlock_irqrestore (&net_rwlock, flags);                        return;                }                // serial number munge                for (i = 0; i < MAX_INTERFACES; i++) {                        dbg_init (1, "i: %d net_private_array[i].device: %p\n", i, net_private_array[i].device);                        if (!net_private_array[i].flags) {                                break;                        }                }                if (i >= MAX_INTERFACES) {                        dbg_init (1, "%s i >= MAX_INTERFACES %d %d", device->name, i, MAX_INTERFACES);                        write_unlock_irqrestore (&net_rwlock, flags);			return;		}		net_private = &net_private_array[i];		net_private->flags |= NET_INUSE;		net_private->index = i;		write_unlock_irqrestore (&net_rwlock, flags);	}	function->privdata = net_private;	dbg_init (1, "function->privdata set to: %p\n", function->privdata);	net_private->device = device;#ifdef CONFIG_ARCH_SA1100	net_private->first = 1;#endif	MOD_INC_USE_COUNT;	// should check for buffer overflow...	if (strlen (if_name) < (IFNAMSIZ - 3)) {		sprintf (net_private->name, "%s%d", if_name, net_private->index);	} else {		dbg_init (0, "if_name too long or too short\n");		net_private->name[0] = '\0';	}	// create network interface	if ((net_private->interface = netproto_create (net_private->name, net_xmit_skb, net_set_addr,                                         net_tx_timeout, default_dev_addr, ETH_ALEN, 1500, 1, 4000, 0)) < 0)         {	// lock and modify device array		dbg_init (0, "FAILED\n");		return;	}	net_private->flags |= NET_ATTACHED;#if 0#ifdef CONFIG_USBD_NET_CDC	switch (device->configuration) {	case 1:		net_private->crc = 1;	case 0:		net_private->maxtransfer = MAXTRANSFER + 4 + in_pkt_sz;		break;	}#else				/* CONFIG_USBD_NET_CDC */        device->interface = 0;        device->alternate = 0;	net_private->crc = 1;	net_private->maxtransfer = MAXTRANSFER + 4 + in_pkt_sz;#endif				/* CONFIG_USBD_NET_CDC */#else	net_private->crc = 1;	net_private->maxtransfer = MAXTRANSFER + 4 + in_pkt_sz;#endif	net_private->device = device;#if 0	netproto_on (net_private->interface);#endif}/* * * net_destroy - destroy an interface * @device: usb device instance * */void net_destroy (struct usb_device_instance *device){	struct usb_net_private *net_private;	struct usb_function_instance *function;	int port = 0;		// XXX compound device	dbg_init (1, "-      -       -       ");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -