prism2sta.c

来自「Linux的无线局域网方案是一个Linux设备驱动程序和子系统 一揽子方案的用」· C语言 代码 · 共 2,232 行 · 第 1/5 页

C
2,232
字号
/* src/prism2/driver/prism2sta.c** Implements the station functionality for prism2** Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.* --------------------------------------------------------------------** linux-wlan**   The contents of this file are subject to the Mozilla Public*   License Version 1.1 (the "License"); you may not use this file*   except in compliance with the License. You may obtain a copy of*   the License at http://www.mozilla.org/MPL/**   Software distributed under the License is distributed on an "AS*   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or*   implied. See the License for the specific language governing*   rights and limitations under the License.**   Alternatively, the contents of this file may be used under the*   terms of the GNU Public License version 2 (the "GPL"), in which*   case the provisions of the GPL are applicable instead of the*   above.  If you wish to allow the use of your version of this file*   only under the terms of the GPL and not to allow others to use*   your version of this file under the MPL, indicate your decision*   by deleting the provisions above and replace them with the notice*   and other provisions required by the GPL.  If you do not delete*   the provisions above, a recipient may use your version of this*   file under either the MPL or the GPL.** --------------------------------------------------------------------** Inquiries regarding the linux-wlan Open Source project can be* made directly to:** AbsoluteValue Systems Inc.* info@linux-wlan.com* http://www.linux-wlan.com** --------------------------------------------------------------------** Portions of the development of this software were funded by * Intersil Corporation as part of PRISM(R) chipset product development.** --------------------------------------------------------------------** This file implements the module and linux pcmcia routines for the* prism2 driver.** --------------------------------------------------------------------*//*================================================================*//* System Includes */#include <linux/config.h>#define WLAN_DBVAR	prism2_debug#include <linux/version.h>#include <wlan/wlan_compat.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/types.h>#include <linux/slab.h>#include <linux/netdevice.h>#include <asm/io.h>#include <linux/delay.h>#include <asm/byteorder.h>#if (WLAN_HOSTIF == WLAN_PCMCIA)#include <pcmcia/config.h>#include <pcmcia/k_compat.h>#include <pcmcia/version.h>#include <pcmcia/cs_types.h>#include <pcmcia/cs.h>#include <pcmcia/cistpl.h>#include <pcmcia/ds.h>#include <pcmcia/cisreg.h>#include <pcmcia/driver_ops.h>#endif#if ((WLAN_HOSTIF == WLAN_PLX) || (WLAN_HOSTIF == WLAN_PCI))#include <linux/ioport.h>#include <linux/pci.h>#endif#if (WLAN_HOSTIF == WLAN_USB)#include <linux/usb.h>#endif/*================================================================*//* Project Includes */#include <wlan/version.h>#include <wlan/p80211types.h>#include <wlan/p80211hdr.h>#include <wlan/p80211mgmt.h>#include <wlan/p80211conv.h>#include <wlan/p80211msg.h>#include <wlan/p80211netdev.h>#include <wlan/p80211req.h>#include <wlan/p80211metadef.h>#include <wlan/p80211metastruct.h>#include <prism2/hfa384x.h>#include <prism2/prism2mgmt.h>#include <prism2/prism2wext.h>/*================================================================*//* Local Constants */#if (WLAN_HOSTIF == WLAN_PLX)#define PLX_ATTR_SIZE	0x1000	/* Attribute memory size - 4K bytes */#define COR_OFFSET	0x3e0	/* COR attribute offset of Prism2 PC card */#define COR_VALUE	0x41	/* Enable PC card with irq in level trigger */#define PLX_INTCSR	0x4c	/* Interrupt Control and Status Register */#define PLX_INTCSR_INTEN (1<<6) /* Interrupt Enable bit *//* Eumitcom PCI WL11000 PCI Adapter (PLX) board device+vendor ID */#define PCIVENDOR_EUMITCOM	0x1638UL#define PCIDEVICE_WL11000	0x1100UL/* Global Sun Tech GL24110P PCI Adapter (PLX) board device+vendor ID */#define PCIVENDOR_GLOBALSUN	0x16abUL#define PCIDEVICE_GL24110P	0x1101UL#define PCIDEVICE_GL24110P_ALT	0x1102UL/* Netgear MA301 PCI Adapter (PLX) board device+vendor ID */#define PCIVENDOR_NETGEAR	0x1385UL#define PCIDEVICE_MA301		0x4100UL/* Corega PCI Adapter (PLX) board device+vendor ID */#define PCIVENDOR_COREGA	0x15e8UL#define PCIDEVICE_CGWLPCIA11	0x0130UL/* US Robotics USR2410 PCI Adapter (PLX) board device+vendor ID */#define	PCIVENDOR_USROBOTICS    0x16ecUL#define PCIDEVICE_USR2410       0x3685UL/* Linksys WPC11 card with the WDT11 adapter (PLX) board device+vendor ID */#define	PCIVENDOR_Linksys       0x16abUL#define PCIDEVICE_Wpc11Wdt11    0x1102UL/* Corega PCI Adapter (PLX) board device+vendor ID */#define PCIVENDOR_COREGA	0x15e8UL#define PCIDEVICE_CGWLPCIA11	0x0130UL/* National Datacomm PCI Adapter (PLX) board device+vendor ID */#define PCIVENDOR_NDC		0x15e8UL#define PCIDEVICE_UNKNOWN_PARTNUM	0x0131UL/* PCI Class & Sub-Class code, Network-'Other controller' */#define PCI_CLASS_NETWORK_OTHERS 0x280#endif /* WLAN_PLX */#if (WLAN_HOSTIF == WLAN_PCI)#define PCI_TYPE		(PCI_USES_MEM | PCI_ADDR0 | PCI_NO_ACPI_WAKE)#define PCI_SIZE		0x1000		/* Memory size - 4K bytes *//* ISL3874A 11Mb/s WLAN controller */#define PCIVENDOR_INTERSIL	0x1260UL#define PCIDEVICE_ISL3874	0x3873UL /* [MSM] yeah I know...the ID says 					    3873. Trust me, it's a 3874. *//* PCI Class & Sub-Class code, Network-'Other controller' */#define PCI_CLASS_NETWORK_OTHERS 0x280#endif /* WLAN_PCI *//*================================================================*//* Local Macros *//*================================================================*//* Local Types *//*================================================================*//* Local Static Definitions */#if (WLAN_HOSTIF == WLAN_PCMCIA)#define DRIVER_SUFFIX	"_cs"#elif (WLAN_HOSTIF == WLAN_PLX)#define DRIVER_SUFFIX	"_plx"typedef char* dev_info_t;#elif (WLAN_HOSTIF == WLAN_PCI)#define DRIVER_SUFFIX	"_pci"typedef char* dev_info_t;#elif (WLAN_HOSTIF == WLAN_USB)#define DRIVER_SUFFIX	"_usb"typedef char* dev_info_t;#else#error "HOSTIF unsupported or undefined!"#endifstatic char		*version = "prism2" DRIVER_SUFFIX ".o: " WLAN_RELEASE;static dev_info_t	dev_info = "prism2" DRIVER_SUFFIX;#if (WLAN_HOSTIF == WLAN_PCMCIA)static dev_link_t	*dev_list = NULL;	/* head of instance list */#elif ((WLAN_HOSTIF == WLAN_PLX) || (WLAN_HOSTIF == WLAN_PCI))typedef struct pci_link {	void		*priv;	struct pci_link	*next;} pci_link_t;static pci_link_t	*dev_list = NULL;	/* head of instance list */#elif (WLAN_HOSTIF == WLAN_USB)typedef struct usb_link {	void		*priv;	struct usb_link	*next;} usb_link_t;static usb_link_t	*dev_list = NULL;	/* head of instance list */#endif/*-----------------------------------------------------------------*/ #if (WLAN_HOSTIF == WLAN_PLX || WLAN_HOSTIF == WLAN_PCI)#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))/* NOTE: The pci code in this driver is written to the * 2.4.x (or some 2.3.x and newer) pci support.  The declarations * inside this #if block are to provide backward compatibility to 2.2.x. * NOTE2: If you want to modify the pci support, please make sure you do  * it in a 2.4.x compliant way. */struct pci_device_id{	unsigned int vendor, device;        unsigned int subvendor, subdevice;        unsigned int class, class_mask;        unsigned long driver_data;};struct pci_driver{        struct {int a;} dummy;        char *name;        const struct pci_device_id *id_table;   /* NULL if wants all devices */        int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);        void (*remove) (struct pci_dev *dev);        int  (*save_state) (struct pci_dev *dev, u32 state);        int  (*suspend)(struct pci_dev *dev, u32 state);        int  (*resume) (struct pci_dev *dev);        int  (*enable_wake) (struct pci_dev *dev, u32 state, int enable);};#define PCI_ANY_ID	0xffffstatic int pci_register_driver(struct pci_driver *drv);static void pci_unregister_driver(struct pci_driver *drv);#define pci_resource_start(a,b) ((a)->base_address[(b)] & ~0xf)#define pci_enable_device(a) 0#endif /* (WLAN_HOSTIF == WLAN_PLX || WLAN_HOSTIF == WLAN_PCI) */#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) *//*-----------------------------------------------------------------*/ #if (WLAN_HOSTIF == WLAN_PLX)static struct pci_device_id pci_id_tbl[] = {	{		PCIVENDOR_EUMITCOM, PCIDEVICE_WL11000,		PCI_ANY_ID, PCI_ANY_ID,		0, 0,		/* Driver data, we just put the name here */		(unsigned long)"Eumitcom WL11000 PCI(PLX) card"		},	{		PCIVENDOR_GLOBALSUN, PCIDEVICE_GL24110P,		PCI_ANY_ID, PCI_ANY_ID,		0, 0, 		/* Driver data, we just put the name here */		(unsigned long)"Global Sun Tech GL24110P PCI(PLX) card"	},	{		PCIVENDOR_GLOBALSUN, PCIDEVICE_GL24110P_ALT,		PCI_ANY_ID, PCI_ANY_ID,		0, 0, 		/* Driver data, we just put the name here */		(unsigned long)"Global Sun Tech GL24110P PCI(PLX) card"	},	{		PCIVENDOR_NETGEAR, PCIDEVICE_MA301,		PCI_ANY_ID, PCI_ANY_ID,		0, 0, 		/* Driver data, we just put the name here */		(unsigned long)"Global Sun Tech GL24110P PCI(PLX) card"	},	{		PCIVENDOR_USROBOTICS, PCIDEVICE_USR2410,		PCI_ANY_ID, PCI_ANY_ID,		0, 0,		/* Driver data, we just put the name here */		(unsigned long)"US Robotics USR2415 PCI(PLX) card"		},	{		PCIVENDOR_Linksys, PCIDEVICE_Wpc11Wdt11,		PCI_ANY_ID, PCI_ANY_ID,		0, 0,		/* Driver data, we just put the name here */		(unsigned long)"Linksys WPC11 with WDT11 PCI(PLX) adapter"		},	{		PCIVENDOR_COREGA, PCIDEVICE_CGWLPCIA11,		PCI_ANY_ID, PCI_ANY_ID,		0, 0, 		/* Driver data, we just put the name here */		(unsigned long)"Corega CGWLPCIA11 PCI(PLX) card"	},	{		PCIVENDOR_NDC, PCIDEVICE_UNKNOWN_PARTNUM,		PCI_ANY_ID, PCI_ANY_ID,		0, 0, 		/* Driver data, we just put the name here */		(unsigned long)"National Datacomm (unknown part#) PCI(PLX) card"	},	{		0, 0, 0, 0, 0, 0, 0	}};/* Function declared here because of ptr reference below */static int prism2sta_probe_plx(struct pci_dev *pdev, 			const struct pci_device_id *id);struct pci_driver prism2_plx_drv_id = {	{},	"prism2_plx", 		/* Driver name */	pci_id_tbl, 		/* id table */	prism2sta_probe_plx,	/* probe function */        NULL,			/* remove function */        NULL,			/* save_state function */        NULL, 			/* suspend function */	NULL,			/* resume function */        NULL, 			/* enable_wake function */};#endif /* WLAN_PLX */#if (WLAN_HOSTIF == WLAN_PCI)static struct pci_device_id pci_id_tbl[] = {	{		PCIVENDOR_INTERSIL, PCIDEVICE_ISL3874,			PCI_ANY_ID, PCI_ANY_ID,		0, 0, 		/* Driver data, we just put the name here */		(unsigned long)"Intersil Prism2.5 ISL3874 11Mb/s WLAN Controller"	},	{		0, 0, 0, 0, 0, 0, 0	}};/* Function declared here because of ptr reference below */static int prism2sta_probe_pci(struct pci_dev *pdev, 				const struct pci_device_id *id);struct pci_driver prism2_pci_drv_id = {	{},	"prism2_pci", 		/* Driver name */	pci_id_tbl, 		/* id table */	prism2sta_probe_pci,	/* probe function */        NULL,			/* remove function */        NULL,			/* save_state function */        NULL, 			/* suspend function */	NULL,			/* resume function */        NULL, 			/* enable_wake function */};#endif /* WLAN_PCI */#if (WLAN_HOSTIF == WLAN_USB)typedef struct usb_prism_dev {	char	*name;	UINT16	vendor;	UINT16	device;	UINT32	priv;} usb_prism_dev_t;static usb_prism_dev_t usb_id_tbl[] = {	{		"Prism2.x 11Mbps WLAN USB Adapter", 		0x09aa, 		0x3642, 		0	}, 	{		"Actiontec Prism2.5 11Mbps WLAN USB Adapter", 		0x1668, 		0x0408, 		0	},	{		"Linksys WUSB11v2.5 11Mbps WLAN USB Adapter", 		0x066b, 		0x2212, 		0	},	{NULL, 0, 0, 0}	};/* Functions declared here because of ptr references below */#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))/* Note: this argument signature changed sometime in 2.3.x, the test * above is sufficient to handle 2.2.19 vs. 2.4.x. */static void*prism2sta_probe_usb(struct usb_device *dev, unsigned int ifnum);#elsestatic void*prism2sta_probe_usb( struct usb_device *dev, unsigned int ifnum,		const struct usb_device_id *id);#endifstatic void prism2sta_disconnect_usb(struct usb_device *dev, void *ptr);static void prism2sta_postdisconnect_usb(UINT32 arg);struct usb_driver prism2_usb_driver = {	"prism2_usb",			/* name */	prism2sta_probe_usb,		/* probe */	prism2sta_disconnect_usb,	/* disconnect */	{},				/* driver_list */	NULL,				/* fops */	0,				/* minor */	{},				/* serialize */	NULL				/* ioctl */};#endif /* WLAN_USB *//*----------------------------------------------------------------*//* --Module Parameters */int		prism2_debug=0;			/* Debug output level, */int		prism2_irq_evread_max=20;	/* Maximum number of 						 * ev_reads (loops)

⌨️ 快捷键说明

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