📄 prism2sta.c
字号:
/* 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 */#define WLAN_DBVAR prism2_debug#include <wlan/version.h>#include <linux/config.h>#include <linux/version.h>#include <linux/module.h>#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,25))#include <linux/moduleparam.h>#endif#include <linux/kernel.h>#include <linux/sched.h>#include <linux/types.h>#include <linux/init.h>#include <linux/slab.h>#include <linux/wireless.h>#include <linux/netdevice.h>#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))#include <linux/tqueue.h>#else#include <linux/workqueue.h>#endif#include <asm/io.h>#include <linux/delay.h>#include <asm/byteorder.h>#include <linux/if_arp.h>#if (WLAN_HOSTIF == WLAN_PCMCIA)#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>#endif#include <wlan/wlan_compat.h>#if ((WLAN_HOSTIF == WLAN_PLX) || (WLAN_HOSTIF == WLAN_PCI))#include <linux/ioport.h>#include <linux/pci.h>#endif/*================================================================*//* Project Includes */#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>/*================================================================*//* Local Constants *//*================================================================*//* 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_PLX || WLAN_HOSTIF == WLAN_PCI)#ifdef CONFIG_PMstatic int prism2sta_suspend_pci(struct pci_dev *pdev, pm_message_t state);static int prism2sta_resume_pci(struct pci_dev *pdev);#endif#endif#if (WLAN_HOSTIF == WLAN_PCI)#endif /* WLAN_PCI */static wlandevice_t *create_wlan(void);/*----------------------------------------------------------------*//* --Module Parameters */int prism2_reset_holdtime=30; /* Reset hold time in ms */int prism2_reset_settletime=100; /* Reset settle time in ms */#if (WLAN_HOSTIF == WLAN_USB)static int prism2_doreset=0; /* Do a reset at init? */#elsestatic int prism2_doreset=1; /* Do a reset at init? */int prism2_bap_timeout=1000; /* BAP timeout */int prism2_irq_evread_max=20; /* Maximum number of * ev_reads (loops) * in irq handler */#endif#ifdef WLAN_INCLUDE_DEBUGint prism2_debug=0;module_param( prism2_debug, int, 0644);MODULE_PARM_DESC(prism2_debug, "prism2 debugging"); #endifmodule_param( prism2_doreset, int, 0644);MODULE_PARM_DESC(prism2_doreset, "Issue a reset on initialization");module_param( prism2_reset_holdtime, int, 0644);MODULE_PARM_DESC( prism2_reset_holdtime, "reset hold time in ms");module_param( prism2_reset_settletime, int, 0644);MODULE_PARM_DESC( prism2_reset_settletime, "reset settle time in ms");#if (WLAN_HOSTIF != WLAN_USB)module_param( prism2_bap_timeout, int, 0644);MODULE_PARM_DESC(prism2_bap_timeout, "BufferAccessPath Timeout in 10*n us");module_param( prism2_irq_evread_max, int, 0644);MODULE_PARM_DESC( prism2_irq_evread_max, "Maximim number of event reads in interrupt handler");#endifMODULE_LICENSE("Dual MPL/GPL");/*================================================================*//* Local Function Declarations */static 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, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg);static int prism2sta_getcardinfo(wlandevice_t *wlandev);static int prism2sta_globalsetup(wlandevice_t *wlandev);static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev);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_hostscanresults( 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_authreq_defer( wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);static void prism2sta_inf_psusercnt( wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);#ifdef CONFIG_PROC_FSstatic intprism2sta_proc_read( char *page, char **start, off_t offset, int count, int *eof, void *data);#endif/*================================================================*//* 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");}/*----------------------------------------------------------------* 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){ DBFENTER;#ifdef ANCIENT_MODULE_CODE MOD_INC_USE_COUNT;#endif /* 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 0;}/*----------------------------------------------------------------* 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;#ifdef ANCIENT_MODULE_CODE MOD_DEC_USE_COUNT;#endif /* 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.* p80211_hdr points to the 802.11 header for the packet.* 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, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; int result; DBFENTER; /* If necessary, set the 802.11 WEP bit */ if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { p80211_hdr->a3.fc |= host2ieee16(WLAN_SET_FC_ISWEP(1)); } result = hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep); 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){ hfa384x_t *hw = (hfa384x_t *)wlandev->priv; int result = 0; DBFENTER; switch( msg->msgcode ) { case DIDmsg_dot11req_mibget : WLAN_LOG_DEBUG(2,"Received mibget request\n"); result = prism2mgmt_mibset_mibget(wlandev, msg); break; case DIDmsg_dot11req_mibset : WLAN_LOG_DEBUG(2,"Received mibset request\n"); result = prism2mgmt_mibset_mibget(wlandev, msg); break; case DIDmsg_dot11req_powermgmt :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -