📄 airo.c
字号:
/*====================================================================== Aironet driver for 4500 and 4800 series cards This code is released under both the GPL version 2 and BSD licenses. Either license may be used. The respective licenses are found at the end of this file. This code was developed by Benjamin Reed <breed@users.sourceforge.net> including portions of which come from the Aironet PC4500 Developer's Reference Manual and used with permission. Copyright (C) 1999 Benjamin Reed. All Rights Reserved. Permission to use code in the Developer's manual was granted for this driver by Aironet. Major code contributions were received from Javier Achirica <achirica@users.sourceforge.net> and Jean Tourrilhes <jt@hpl.hp.com>. Code was also integrated from the Cisco Aironet driver for Linux. Support for MPI350 cards was added by Fabrice Bellet <fabrice@bellet.info>.======================================================================*/#include <linux/config.h>#include <linux/init.h>#include <linux/kernel.h>#include <linux/module.h>#include <linux/proc_fs.h>#include <linux/smp_lock.h>#include <linux/sched.h>#include <linux/ptrace.h>#include <linux/slab.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/interrupt.h>#include <linux/in.h>#include <linux/bitops.h>#include <linux/scatterlist.h>#include <asm/io.h>#include <asm/system.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <linux/if_arp.h>#include <linux/ioport.h>#include <linux/pci.h>#include <asm/uaccess.h>#include "airo.h"#ifdef CONFIG_PCIstatic struct pci_device_id card_ids[] = { { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, { 0x14b9, 0x4500, PCI_ANY_ID, PCI_ANY_ID }, { 0x14b9, 0x4800, PCI_ANY_ID, PCI_ANY_ID, }, { 0x14b9, 0x0340, PCI_ANY_ID, PCI_ANY_ID, }, { 0x14b9, 0x0350, PCI_ANY_ID, PCI_ANY_ID, }, { 0x14b9, 0x5000, PCI_ANY_ID, PCI_ANY_ID, }, { 0x14b9, 0xa504, PCI_ANY_ID, PCI_ANY_ID, }, { 0, }};MODULE_DEVICE_TABLE(pci, card_ids);static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *);static void airo_pci_remove(struct pci_dev *);static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state);static int airo_pci_resume(struct pci_dev *pdev);static struct pci_driver airo_driver = { .name = "airo", .id_table = card_ids, .probe = airo_pci_probe, .remove = __devexit_p(airo_pci_remove), .suspend = airo_pci_suspend, .resume = airo_pci_resume,};#endif /* CONFIG_PCI *//* Include Wireless Extension definition and check version - Jean II */#include <linux/wireless.h>#define WIRELESS_SPY // enable iwspy support#include <net/iw_handler.h> // New driver API#define CISCO_EXT // enable Cisco extensions#ifdef CISCO_EXT#include <linux/delay.h>#endif/* Support Cisco MIC feature */#define MICSUPPORT#if defined(MICSUPPORT) && !defined(CONFIG_CRYPTO)#warning MIC support requires Crypto API#undef MICSUPPORT#endif/* Hack to do some power saving */#define POWER_ON_DOWN/* As you can see this list is HUGH! I really don't know what a lot of these counts are about, but they are all here for completeness. If the IGNLABEL macro is put in infront of the label, that statistic will not be included in the list of statistics in the /proc filesystem */#define IGNLABEL(comment) NULLstatic char *statsLabels[] = { "RxOverrun", IGNLABEL("RxPlcpCrcErr"), IGNLABEL("RxPlcpFormatErr"), IGNLABEL("RxPlcpLengthErr"), "RxMacCrcErr", "RxMacCrcOk", "RxWepErr", "RxWepOk", "RetryLong", "RetryShort", "MaxRetries", "NoAck", "NoCts", "RxAck", "RxCts", "TxAck", "TxRts", "TxCts", "TxMc", "TxBc", "TxUcFrags", "TxUcPackets", "TxBeacon", "RxBeacon", "TxSinColl", "TxMulColl", "DefersNo", "DefersProt", "DefersEngy", "DupFram", "RxFragDisc", "TxAged", "RxAged", "LostSync-MaxRetry", "LostSync-MissedBeacons", "LostSync-ArlExceeded", "LostSync-Deauth", "LostSync-Disassoced", "LostSync-TsfTiming", "HostTxMc", "HostTxBc", "HostTxUc", "HostTxFail", "HostRxMc", "HostRxBc", "HostRxUc", "HostRxDiscard", IGNLABEL("HmacTxMc"), IGNLABEL("HmacTxBc"), IGNLABEL("HmacTxUc"), IGNLABEL("HmacTxFail"), IGNLABEL("HmacRxMc"), IGNLABEL("HmacRxBc"), IGNLABEL("HmacRxUc"), IGNLABEL("HmacRxDiscard"), IGNLABEL("HmacRxAccepted"), "SsidMismatch", "ApMismatch", "RatesMismatch", "AuthReject", "AuthTimeout", "AssocReject", "AssocTimeout", IGNLABEL("ReasonOutsideTable"), IGNLABEL("ReasonStatus1"), IGNLABEL("ReasonStatus2"), IGNLABEL("ReasonStatus3"), IGNLABEL("ReasonStatus4"), IGNLABEL("ReasonStatus5"), IGNLABEL("ReasonStatus6"), IGNLABEL("ReasonStatus7"), IGNLABEL("ReasonStatus8"), IGNLABEL("ReasonStatus9"), IGNLABEL("ReasonStatus10"), IGNLABEL("ReasonStatus11"), IGNLABEL("ReasonStatus12"), IGNLABEL("ReasonStatus13"), IGNLABEL("ReasonStatus14"), IGNLABEL("ReasonStatus15"), IGNLABEL("ReasonStatus16"), IGNLABEL("ReasonStatus17"), IGNLABEL("ReasonStatus18"), IGNLABEL("ReasonStatus19"), "RxMan", "TxMan", "RxRefresh", "TxRefresh", "RxPoll", "TxPoll", "HostRetries", "LostSync-HostReq", "HostTxBytes", "HostRxBytes", "ElapsedUsec", "ElapsedSec", "LostSyncBetterAP", "PrivacyMismatch", "Jammed", "DiscRxNotWepped", "PhyEleMismatch", (char*)-1 };#ifndef RUN_AT#define RUN_AT(x) (jiffies+(x))#endif/* These variables are for insmod, since it seems that the rates can only be set in setup_card. Rates should be a comma separated (no spaces) list of rates (up to 8). */static int rates[8];static int basic_rate;static char *ssids[3];static int io[4];static int irq[4];staticint maxencrypt /* = 0 */; /* The highest rate that the card can encrypt at. 0 means no limit. For old cards this was 4 */static int auto_wep /* = 0 */; /* If set, it tries to figure out the wep mode */static int aux_bap /* = 0 */; /* Checks to see if the aux ports are needed to read the bap, needed on some older cards and buses. */static int adhoc;static int probe = 1;static int proc_uid /* = 0 */;static int proc_gid /* = 0 */;static int airo_perm = 0555;static int proc_perm = 0644;MODULE_AUTHOR("Benjamin Reed");MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet \ cards. Direct support for ISA/PCI/MPI cards and support \ for PCMCIA when used with airo_cs.");MODULE_LICENSE("Dual BSD/GPL");MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340/350");module_param_array(io, int, NULL, 0);module_param_array(irq, int, NULL, 0);module_param(basic_rate, int, 0);module_param_array(rates, int, NULL, 0);module_param_array(ssids, charp, NULL, 0);module_param(auto_wep, int, 0);MODULE_PARM_DESC(auto_wep, "If non-zero, the driver will keep looping through \the authentication options until an association is made. The value of \auto_wep is number of the wep keys to check. A value of 2 will try using \the key at index 0 and index 1.");module_param(aux_bap, int, 0);MODULE_PARM_DESC(aux_bap, "If non-zero, the driver will switch into a mode \than seems to work better for older cards with some older buses. Before \switching it checks that the switch is needed.");module_param(maxencrypt, int, 0);MODULE_PARM_DESC(maxencrypt, "The maximum speed that the card can do \encryption. Units are in 512kbs. Zero (default) means there is no limit. \Older cards used to be limited to 2mbs (4).");module_param(adhoc, int, 0);MODULE_PARM_DESC(adhoc, "If non-zero, the card will start in adhoc mode.");module_param(probe, int, 0);MODULE_PARM_DESC(probe, "If zero, the driver won't start the card.");module_param(proc_uid, int, 0);MODULE_PARM_DESC(proc_uid, "The uid that the /proc files will belong to.");module_param(proc_gid, int, 0);MODULE_PARM_DESC(proc_gid, "The gid that the /proc files will belong to.");module_param(airo_perm, int, 0);MODULE_PARM_DESC(airo_perm, "The permission bits of /proc/[driver/]aironet.");module_param(proc_perm, int, 0);MODULE_PARM_DESC(proc_perm, "The permission bits of the files in /proc");/* This is a kind of sloppy hack to get this information to OUT4500 and IN4500. I would be extremely interested in the situation where this doesn't work though!!! */static int do8bitIO = 0;/* Return codes */#define SUCCESS 0#define ERROR -1#define NO_PACKET -2/* Commands */#define NOP2 0x0000#define MAC_ENABLE 0x0001#define MAC_DISABLE 0x0002#define CMD_LOSE_SYNC 0x0003 /* Not sure what this does... */#define CMD_SOFTRESET 0x0004#define HOSTSLEEP 0x0005#define CMD_MAGIC_PKT 0x0006#define CMD_SETWAKEMASK 0x0007#define CMD_READCFG 0x0008#define CMD_SETMODE 0x0009#define CMD_ALLOCATETX 0x000a#define CMD_TRANSMIT 0x000b#define CMD_DEALLOCATETX 0x000c#define NOP 0x0010#define CMD_WORKAROUND 0x0011#define CMD_ALLOCATEAUX 0x0020#define CMD_ACCESS 0x0021#define CMD_PCIBAP 0x0022#define CMD_PCIAUX 0x0023#define CMD_ALLOCBUF 0x0028#define CMD_GETTLV 0x0029#define CMD_PUTTLV 0x002a#define CMD_DELTLV 0x002b#define CMD_FINDNEXTTLV 0x002c#define CMD_PSPNODES 0x0030#define CMD_SETCW 0x0031 #define CMD_SETPCF 0x0032 #define CMD_SETPHYREG 0x003e#define CMD_TXTEST 0x003f#define MAC_ENABLETX 0x0101#define CMD_LISTBSS 0x0103#define CMD_SAVECFG 0x0108#define CMD_ENABLEAUX 0x0111#define CMD_WRITERID 0x0121#define CMD_USEPSPNODES 0x0130#define MAC_ENABLERX 0x0201/* Command errors */#define ERROR_QUALIF 0x00#define ERROR_ILLCMD 0x01#define ERROR_ILLFMT 0x02#define ERROR_INVFID 0x03#define ERROR_INVRID 0x04#define ERROR_LARGE 0x05#define ERROR_NDISABL 0x06#define ERROR_ALLOCBSY 0x07#define ERROR_NORD 0x0B#define ERROR_NOWR 0x0C#define ERROR_INVFIDTX 0x0D#define ERROR_TESTACT 0x0E#define ERROR_TAGNFND 0x12#define ERROR_DECODE 0x20#define ERROR_DESCUNAV 0x21#define ERROR_BADLEN 0x22#define ERROR_MODE 0x80#define ERROR_HOP 0x81#define ERROR_BINTER 0x82#define ERROR_RXMODE 0x83#define ERROR_MACADDR 0x84#define ERROR_RATES 0x85#define ERROR_ORDER 0x86#define ERROR_SCAN 0x87#define ERROR_AUTH 0x88#define ERROR_PSMODE 0x89#define ERROR_RTYPE 0x8A#define ERROR_DIVER 0x8B#define ERROR_SSID 0x8C#define ERROR_APLIST 0x8D#define ERROR_AUTOWAKE 0x8E#define ERROR_LEAP 0x8F/* Registers */#define COMMAND 0x00#define PARAM0 0x02#define PARAM1 0x04#define PARAM2 0x06#define STATUS 0x08#define RESP0 0x0a#define RESP1 0x0c#define RESP2 0x0e#define LINKSTAT 0x10#define SELECT0 0x18#define OFFSET0 0x1c#define RXFID 0x20#define TXALLOCFID 0x22#define TXCOMPLFID 0x24#define DATA0 0x36#define EVSTAT 0x30#define EVINTEN 0x32#define EVACK 0x34#define SWS0 0x28#define SWS1 0x2a#define SWS2 0x2c#define SWS3 0x2e#define AUXPAGE 0x3A#define AUXOFF 0x3C#define AUXDATA 0x3E#define FID_TX 1#define FID_RX 2/* Offset into aux memory for descriptors */#define AUX_OFFSET 0x800/* Size of allocated packets */#define PKTSIZE 1840#define RIDSIZE 2048/* Size of the transmit queue */#define MAXTXQ 64/* BAP selectors */#define BAP0 0 // Used for receiving packets#define BAP1 2 // Used for xmiting packets and working with RIDS/* Flags */#define COMMAND_BUSY 0x8000#define BAP_BUSY 0x8000#define BAP_ERR 0x4000#define BAP_DONE 0x2000#define PROMISC 0xffff#define NOPROMISC 0x0000#define EV_CMD 0x10#define EV_CLEARCOMMANDBUSY 0x4000#define EV_RX 0x01#define EV_TX 0x02#define EV_TXEXC 0x04#define EV_ALLOC 0x08#define EV_LINK 0x80#define EV_AWAKE 0x100#define EV_TXCPY 0x400#define EV_UNKNOWN 0x800#define EV_MIC 0x1000 /* Message Integrity Check Interrupt */#define EV_AWAKEN 0x2000#define STATUS_INTS (EV_AWAKE|EV_LINK|EV_TXEXC|EV_TX|EV_TXCPY|EV_RX|EV_MIC)#ifdef CHECK_UNKNOWN_INTS#define IGNORE_INTS ( EV_CMD | EV_UNKNOWN)#else#define IGNORE_INTS (~STATUS_INTS)#endif/* RID TYPES */#define RID_RW 0x20/* The RIDs */#define RID_CAPABILITIES 0xFF00#define RID_APINFO 0xFF01#define RID_RADIOINFO 0xFF02#define RID_UNKNOWN3 0xFF03#define RID_RSSI 0xFF04#define RID_CONFIG 0xFF10#define RID_SSID 0xFF11#define RID_APLIST 0xFF12#define RID_DRVNAME 0xFF13#define RID_ETHERENCAP 0xFF14#define RID_WEP_TEMP 0xFF15#define RID_WEP_PERM 0xFF16#define RID_MODULATION 0xFF17#define RID_OPTIONS 0xFF18#define RID_ACTUALCONFIG 0xFF20 /*readonly*/#define RID_FACTORYCONFIG 0xFF21#define RID_UNKNOWN22 0xFF22#define RID_LEAPUSERNAME 0xFF23#define RID_LEAPPASSWORD 0xFF24#define RID_STATUS 0xFF50#define RID_BEACON_HST 0xFF51#define RID_BUSY_HST 0xFF52#define RID_RETRIES_HST 0xFF53#define RID_UNKNOWN54 0xFF54#define RID_UNKNOWN55 0xFF55#define RID_UNKNOWN56 0xFF56#define RID_MIC 0xFF57#define RID_STATS16 0xFF60#define RID_STATS16DELTA 0xFF61
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -