prism2sta.c

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

C
2,232
字号
						 * in irq handler 						 */#if (WLAN_HOSTIF == WLAN_USB)int		prism2_doreset=0;		/* Do a reset at init? */int		prism2_reset_holdtime=30;	/* Reset hold time in ms */int		prism2_reset_settletime=100;	/* Reset settle time in ms */#elseint		prism2_doreset=1;		/* Do a reset at init? */int		prism2_reset_holdtime=30;	/* Reset hold time in ms */int		prism2_reset_settletime=100;	/* Reset settle time in ms */#endifMODULE_PARM( prism2_debug, "i");	MODULE_PARM( prism2_irq_evread_max, "i");MODULE_PARM( prism2_doreset, "i");MODULE_PARM( prism2_reset_holdtime, "i");MODULE_PARM( prism2_reset_settletime, "i");#ifdef MODULE_LICENSEMODULE_LICENSE("Dual MPL/GPL");#endif#if (WLAN_HOSTIF == WLAN_PCMCIA)static u_int	irq_mask = 0xdeb8;		/* Interrupt mask */static int	irq_list[4] = { -1 };		/* Interrupt list */static u_int	prism2_ignorevcc=0;		/* Boolean, if set, we						 * ignore what the Vcc						 * is set to and what the CIS						 * says.						 */MODULE_PARM( irq_mask, "i");MODULE_PARM( irq_list, "1-4i");MODULE_PARM( prism2_ignorevcc, "i");#endif /* WLAN_PCMCIA *//*================================================================*//* Local Function Declarations */int		init_module(void);void		cleanup_module(void);#if (WLAN_HOSTIF == WLAN_PCMCIA)dev_link_t	*prism2sta_attach(void);static void	prism2sta_detach(dev_link_t *link);static void	prism2sta_config(dev_link_t *link);static void	prism2sta_release(UINT32 arg);static int 	prism2sta_event (event_t event, int priority, event_callback_args_t *args);#endifstatic int	prism2sta_open(wlandevice_t *wlandev);static int	prism2sta_close(wlandevice_t *wlandev);static void	prism2sta_reset(wlandevice_t *wlandev );static int	prism2sta_txframe(wlandevice_t *wlandev, wlan_pb_t *pb);static int	prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg);static void	prism2sta_hwremoved(wlandevice_t *wlandev);static int	prism2sta_getcardinfo(wlandevice_t *wlandev);static int	prism2sta_globalsetup(wlandevice_t *wlandev);static void	prism2sta_inf_handover(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_tallies(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_scanresults(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_chinforesults(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_linkstatus(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_assocstatus(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_authreq(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void	prism2sta_inf_psusercnt(			wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);#if (WLAN_HOSTIF == WLAN_USB)static voidprism2sta_getbssid_cb(	hfa384x_t *hw, 	UINT result, 	void *ctlxresult, 	void *usercb_data);static voidprism2sta_getportstatus_cb(	hfa384x_t *hw, 	UINT result, 	void *ctlxresult, 	void *usercb_data);#endif /* WLANHOSTIF == WLAN_USB *//*================================================================*//* Function Definitions *//*----------------------------------------------------------------* dmpmem** Debug utility function to dump memory to the kernel debug log.** Arguments:*	buf	ptr data we want dumped*	len	length of data** Returns: *	nothing* Side effects:** Call context:*	process thread*	interrupt----------------------------------------------------------------*/inline void dmpmem(void *buf, int n){	int c;	for ( c= 0; c < n; c++) {		if ( (c % 16) == 0 ) printk(KERN_DEBUG"dmp[%d]: ", c);		printk("%02x ", ((UINT8*)buf)[c]);		if ( (c % 16) == 15 ) printk("\n");	}	if ( (c % 16) != 0 ) printk("\n");}#if (WLAN_HOSTIF == WLAN_PCMCIA)/*----------------------------------------------------------------* cs_error** Utility function to print card services error messages.** Arguments:*	handle	client handle identifying this CS client*	func	CS function number that generated the error*	ret	CS function return code** Returns: *	nothing* Side effects:** Call context:*	process thread*	interrupt----------------------------------------------------------------*/static void cs_error(client_handle_t handle, int func, int ret){#if CS_RELEASE_CODE < 0x2911	CardServices(ReportError, dev_info, (void *)func, (void *)ret);#else	error_info_t err = { func, ret };	CardServices(ReportError, handle, &err);#endif}#endif/*-----------------------------------------------------------------*/ #if (WLAN_HOSTIF == WLAN_PLX || WLAN_HOSTIF == WLAN_PCI)#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))/* NOTE: See the note above about 2.4.x and pci support *//*----------------------------------------------------------------* pci_register_driver* pci_unregister_driver** 2.4.x PCI support function emulation for 2.2.x kernels.** Arguments:*	drv	2.4.x type driver description block** Returns: *	0	success*	~0	error** Side effects:** Call context:*	process thread----------------------------------------------------------------*/static int pci_register_driver(struct pci_driver *drv){	int			nfound = 0;	struct pci_dev		*pdev;	const struct pci_device_id	*id_tbl=drv->id_table;	DBFENTER;	/* Scan the bus for matching devices */	if (pcibios_present()) {		static int	pci_index = 0;		UINT8		pci_bus;		UINT8		pci_device_fn;		for(;pci_index < 0xff; pci_index++) {			u16	vendor;			u16	device;			int	idx;			if (pcibios_find_class(PCI_CLASS_NETWORK_OTHER<<8,pci_index, 				&pci_bus, &pci_device_fn) != PCIBIOS_SUCCESSFUL) 				break;			pcibios_read_config_word(pci_bus, pci_device_fn, 				PCI_VENDOR_ID, &vendor);			pcibios_read_config_word(pci_bus, pci_device_fn,				PCI_DEVICE_ID, &device);			for( idx = 0; id_tbl[idx].vendor; idx++) {				if (	id_tbl[idx].vendor == vendor &&					id_tbl[idx].device == device )					break; /* found one! */			} 			if (id_tbl[idx].vendor == 0) continue;			nfound++;			/* Probably an invalid assumption...but we'll assume the			 * card is alive for now.  TODO: need to add power management			 * stuff here.			 */			/* Collect the pci_device structure */			pdev = pci_find_slot(pci_bus, pci_device_fn);			/* Call the driver probe function */			(*(drv->probe))(pdev, &(id_tbl[idx]));		}	}	DBFEXIT;	return nfound;}static void pci_unregister_driver(struct pci_driver *drv){	return;}#endif#endif/*----------------------------------------------------------------* prism2sta_open** WLAN device open method.  Called from p80211netdev when kernel * device open (start) method is called in response to the * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP * from clear to set.** Arguments:*	wlandev		wlan device structure** Returns: *	0	success*	>0	f/w reported error*	<0	driver reported error** Side effects:** Call context:*	process thread----------------------------------------------------------------*/int prism2sta_open(wlandevice_t *wlandev){	int			result = 0;	DBFENTER;	MOD_INC_USE_COUNT;	/* We don't currently have to do anything else. 	 * The setup of the MAC should be subsequently completed via	 * the mlme commands.	 * Higher layers know we're ready from dev->start==1 and 	 * dev->tbusy==0.  Our rx path knows to pass up received/	 * frames because of dev->flags&IFF_UP is true. 	 */	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2sta_close** WLAN device close method.  Called from p80211netdev when kernel * device close method is called in response to the * SIOCSIIFFLAGS ioctl changing the flags bit IFF_UP * from set to clear.** Arguments:*	wlandev		wlan device structure** Returns: *	0	success*	>0	f/w reported error*	<0	driver reported error** Side effects:** Call context:*	process thread----------------------------------------------------------------*/int prism2sta_close(wlandevice_t *wlandev){	DBFENTER;	MOD_DEC_USE_COUNT;	/* We don't currently have to do anything else.	 * Higher layers know we're not ready from dev->start==0 and	 * dev->tbusy==1.  Our rx path knows to not pass up received	 * frames because of dev->flags&IFF_UP is false.	 */	DBFEXIT;	return 0;}/*----------------------------------------------------------------* prism2sta_reset** Not currently implented.** Arguments:*	wlandev		wlan device structure*	none** Returns: *	nothing** Side effects:** Call context:*	process thread----------------------------------------------------------------*/void prism2sta_reset(wlandevice_t *wlandev ){	DBFENTER;	DBFEXIT;	return;}/*----------------------------------------------------------------* prism2sta_txframe** Takes a frame from p80211 and queues it for transmission.** Arguments:*	wlandev		wlan device structure*	pb		packet buffer struct.  Contains an 802.11*			data frame.* Returns: *	0		Success and more buffs available*	1		Success but no more buffs*	2		Allocation failure*	4		Buffer full or queue busy** Side effects:** Call context:*	process thread----------------------------------------------------------------*/int prism2sta_txframe(wlandevice_t *wlandev, wlan_pb_t *pb ){	prism2sta_priv_t	*priv = (prism2sta_priv_t*)wlandev->priv;	hfa384x_t		*hw = priv->hw;	int			result;	DBFENTER;	/* If necessary, set the 802.11 WEP bit */	if ( priv->priv_invoked ) {		pb->p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1));	}	result = hfa384x_drvr_txframe( hw, pb);	DBFEXIT;	return result;}/*----------------------------------------------------------------* prism2sta_mlmerequest** wlan command message handler.  All we do here is pass the message* over to the prism2sta_mgmt_handler.** Arguments:*	wlandev		wlan device structure*	msg		wlan command message* Returns: *	0		success*	<0		successful acceptance of message, but we're*			waiting for an async process to finish before*			we're done with the msg.  When the asynch*			process is done, we'll call the p80211 *			function p80211req_confirm() .*	>0		An error occurred while we were handling*			the message.** Side effects:** Call context:*	process thread----------------------------------------------------------------*/int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg){	int result = 0;	DBFENTER;	switch( msg->msgcode )	{	case DIDmsg_dot11req_mibget :		WLAN_LOG_DEBUG0(2,"Received mibget request\n");		result = prism2mgmt_mibset_mibget(wlandev, msg);		break;	case DIDmsg_dot11req_mibset :		WLAN_LOG_DEBUG0(2,"Received mibset request\n");		result = prism2mgmt_mibset_mibget(wlandev, msg);		break;	case DIDmsg_dot11req_powermgmt :		WLAN_LOG_DEBUG0(2,"Received powermgmt request\n");		result = prism2mgmt_powermgmt(wlandev, msg);		break;	case DIDmsg_dot11req_scan :		WLAN_LOG_DEBUG0(2,"Received scan request\n");		result = prism2mgmt_scan(wlandev, msg);		break;	case DIDmsg_dot11req_scan_results :		WLAN_LOG_DEBUG0(2,"Received scan_results request\n");		result = prism2mgmt_scan_results(wlandev, msg);		break;	case DIDmsg_dot11req_join :		WLAN_LOG_DEBUG0(2,"Received join request\n");		result = prism2mgmt_join(wlandev, msg);		break;	case DIDmsg_dot11req_authenticate :		WLAN_LOG_DEBUG0(2,"Received authenticate request\n");		result = prism2mgmt_authenticate(wlandev, msg);		break;	case DIDmsg_dot11req_deauthenticate :		WLAN_LOG_DEBUG0(2,"Received mlme deauthenticate request\n");		result = prism2mgmt_deauthenticate(wlandev, msg);		break;	case DIDmsg_dot11req_associate :		WLAN_LOG_DEBUG0(2,"Received mlme associate request\n");		result = prism2mgmt_associate(wlandev, msg);

⌨️ 快捷键说明

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