25 #include <linux/kernel.h>
26 #include <linux/module.h>
29 #include <linux/sched.h>
30 #include <linux/ptrace.h>
31 #include <linux/slab.h>
32 #include <linux/string.h>
36 #include <linux/bitops.h>
40 #include <asm/unaligned.h>
42 #include <linux/netdevice.h>
45 #include <linux/if_arp.h>
47 #include <linux/pci.h>
48 #include <asm/uaccess.h>
57 #define DRV_NAME "airo"
73 static void airo_pci_remove(
struct pci_dev *);
75 static int airo_pci_resume(
struct pci_dev *pdev);
80 .probe = airo_pci_probe,
82 .suspend = airo_pci_suspend,
83 .resume = airo_pci_resume,
88 #include <linux/wireless.h>
105 #define IGNLABEL(comment) NULL
106 static const char *statsLabels[] = {
141 "LostSync-MissedBeacons",
142 "LostSync-ArlExceeded",
144 "LostSync-Disassoced",
145 "LostSync-TsfTiming",
209 #define RUN_AT(x) (jiffies+(x))
218 static char *ssids[3];
227 static int auto_wep ;
232 static int probe = 1;
235 static int proc_uid ;
238 static int proc_gid ;
240 static int airo_perm = 0555;
242 static int proc_perm = 0644;
246 "Direct support for ISA/PCI/MPI cards and support for PCMCIA when used with airo_cs.");
255 "If non-zero, the driver will keep looping through the authentication options until an association is made. "
256 "The value of auto_wep is number of the wep keys to check. "
257 "A value of 2 will try using the key at index 0 and index 1.");
260 "If non-zero, the driver will switch into a mode that seems to work better for older cards with some older buses. "
261 "Before switching it checks that the switch is needed.");
264 "The maximum speed that the card can do encryption. "
265 "Units are in 512kbs. "
266 "Zero (default) means there is no limit. "
267 "Older cards used to be limited to 2mbs (4).");
278 MODULE_PARM_DESC(airo_perm,
"The permission bits of /proc/[driver/]aironet.");
285 static int do8bitIO ;
294 #define MAC_ENABLE 0x0001
295 #define MAC_DISABLE 0x0002
296 #define CMD_LOSE_SYNC 0x0003
297 #define CMD_SOFTRESET 0x0004
298 #define HOSTSLEEP 0x0005
299 #define CMD_MAGIC_PKT 0x0006
300 #define CMD_SETWAKEMASK 0x0007
301 #define CMD_READCFG 0x0008
302 #define CMD_SETMODE 0x0009
303 #define CMD_ALLOCATETX 0x000a
304 #define CMD_TRANSMIT 0x000b
305 #define CMD_DEALLOCATETX 0x000c
307 #define CMD_WORKAROUND 0x0011
308 #define CMD_ALLOCATEAUX 0x0020
309 #define CMD_ACCESS 0x0021
310 #define CMD_PCIBAP 0x0022
311 #define CMD_PCIAUX 0x0023
312 #define CMD_ALLOCBUF 0x0028
313 #define CMD_GETTLV 0x0029
314 #define CMD_PUTTLV 0x002a
315 #define CMD_DELTLV 0x002b
316 #define CMD_FINDNEXTTLV 0x002c
317 #define CMD_PSPNODES 0x0030
318 #define CMD_SETCW 0x0031
319 #define CMD_SETPCF 0x0032
320 #define CMD_SETPHYREG 0x003e
321 #define CMD_TXTEST 0x003f
322 #define MAC_ENABLETX 0x0101
323 #define CMD_LISTBSS 0x0103
324 #define CMD_SAVECFG 0x0108
325 #define CMD_ENABLEAUX 0x0111
326 #define CMD_WRITERID 0x0121
327 #define CMD_USEPSPNODES 0x0130
328 #define MAC_ENABLERX 0x0201
331 #define ERROR_QUALIF 0x00
332 #define ERROR_ILLCMD 0x01
333 #define ERROR_ILLFMT 0x02
334 #define ERROR_INVFID 0x03
335 #define ERROR_INVRID 0x04
336 #define ERROR_LARGE 0x05
337 #define ERROR_NDISABL 0x06
338 #define ERROR_ALLOCBSY 0x07
339 #define ERROR_NORD 0x0B
340 #define ERROR_NOWR 0x0C
341 #define ERROR_INVFIDTX 0x0D
342 #define ERROR_TESTACT 0x0E
343 #define ERROR_TAGNFND 0x12
344 #define ERROR_DECODE 0x20
345 #define ERROR_DESCUNAV 0x21
346 #define ERROR_BADLEN 0x22
347 #define ERROR_MODE 0x80
348 #define ERROR_HOP 0x81
349 #define ERROR_BINTER 0x82
350 #define ERROR_RXMODE 0x83
351 #define ERROR_MACADDR 0x84
352 #define ERROR_RATES 0x85
353 #define ERROR_ORDER 0x86
354 #define ERROR_SCAN 0x87
355 #define ERROR_AUTH 0x88
356 #define ERROR_PSMODE 0x89
357 #define ERROR_RTYPE 0x8A
358 #define ERROR_DIVER 0x8B
359 #define ERROR_SSID 0x8C
360 #define ERROR_APLIST 0x8D
361 #define ERROR_AUTOWAKE 0x8E
362 #define ERROR_LEAP 0x8F
373 #define LINKSTAT 0x10
377 #define TXALLOCFID 0x22
378 #define TXCOMPLFID 0x24
394 #define AUX_OFFSET 0x800
406 #define COMMAND_BUSY 0x8000
408 #define BAP_BUSY 0x8000
409 #define BAP_ERR 0x4000
410 #define BAP_DONE 0x2000
412 #define PROMISC 0xffff
413 #define NOPROMISC 0x0000
416 #define EV_CLEARCOMMANDBUSY 0x4000
419 #define EV_TXEXC 0x04
420 #define EV_ALLOC 0x08
422 #define EV_AWAKE 0x100
423 #define EV_TXCPY 0x400
424 #define EV_UNKNOWN 0x800
425 #define EV_MIC 0x1000
426 #define EV_AWAKEN 0x2000
427 #define STATUS_INTS (EV_AWAKE|EV_LINK|EV_TXEXC|EV_TX|EV_TXCPY|EV_RX|EV_MIC)
429 #ifdef CHECK_UNKNOWN_INTS
430 #define IGNORE_INTS ( EV_CMD | EV_UNKNOWN)
432 #define IGNORE_INTS (~STATUS_INTS)
439 #define RID_CAPABILITIES 0xFF00
440 #define RID_APINFO 0xFF01
441 #define RID_RADIOINFO 0xFF02
442 #define RID_UNKNOWN3 0xFF03
443 #define RID_RSSI 0xFF04
444 #define RID_CONFIG 0xFF10
445 #define RID_SSID 0xFF11
446 #define RID_APLIST 0xFF12
447 #define RID_DRVNAME 0xFF13
448 #define RID_ETHERENCAP 0xFF14
449 #define RID_WEP_TEMP 0xFF15
450 #define RID_WEP_PERM 0xFF16
451 #define RID_MODULATION 0xFF17
452 #define RID_OPTIONS 0xFF18
453 #define RID_ACTUALCONFIG 0xFF20
454 #define RID_FACTORYCONFIG 0xFF21
455 #define RID_UNKNOWN22 0xFF22
456 #define RID_LEAPUSERNAME 0xFF23
457 #define RID_LEAPPASSWORD 0xFF24
458 #define RID_STATUS 0xFF50
459 #define RID_BEACON_HST 0xFF51
460 #define RID_BUSY_HST 0xFF52
461 #define RID_RETRIES_HST 0xFF53
462 #define RID_UNKNOWN54 0xFF54
463 #define RID_UNKNOWN55 0xFF55
464 #define RID_UNKNOWN56 0xFF56
465 #define RID_MIC 0xFF57
466 #define RID_STATS16 0xFF60
467 #define RID_STATS16DELTA 0xFF61
468 #define RID_STATS16DELTACLEAR 0xFF62
469 #define RID_STATS 0xFF68
470 #define RID_STATSDELTA 0xFF69
471 #define RID_STATSDELTACLEAR 0xFF6A
472 #define RID_ECHOTEST_RID 0xFF70
473 #define RID_ECHOTEST_RESULTS 0xFF71
474 #define RID_BSSLISTFIRST 0xFF72
475 #define RID_BSSLISTNEXT 0xFF73
476 #define RID_WPA_BSSLISTFIRST 0xFF74
477 #define RID_WPA_BSSLISTNEXT 0xFF75
527 #define MOD_DEFAULT cpu_to_le16(0)
528 #define MOD_CCK cpu_to_le16(1)
529 #define MOD_MOK cpu_to_le16(2)
536 #define MODE_STA_IBSS cpu_to_le16(0)
537 #define MODE_STA_ESS cpu_to_le16(1)
538 #define MODE_AP cpu_to_le16(2)
539 #define MODE_AP_RPTR cpu_to_le16(3)
540 #define MODE_CFG_MASK cpu_to_le16(0xff)
541 #define MODE_ETHERNET_HOST cpu_to_le16(0<<8)
542 #define MODE_LLC_HOST cpu_to_le16(1<<8)
543 #define MODE_AIRONET_EXTEND cpu_to_le16(1<<9)
544 #define MODE_AP_INTERFACE cpu_to_le16(1<<10)
545 #define MODE_ANTENNA_ALIGN cpu_to_le16(1<<11)
546 #define MODE_ETHER_LLC cpu_to_le16(1<<12)
547 #define MODE_LEAF_NODE cpu_to_le16(1<<13)
548 #define MODE_CF_POLLABLE cpu_to_le16(1<<14)
549 #define MODE_MIC cpu_to_le16(1<<15)
551 #define RXMODE_BC_MC_ADDR cpu_to_le16(0)
552 #define RXMODE_BC_ADDR cpu_to_le16(1)
553 #define RXMODE_ADDR cpu_to_le16(2)
554 #define RXMODE_RFMON cpu_to_le16(3)
555 #define RXMODE_RFMON_ANYBSS cpu_to_le16(4)
556 #define RXMODE_LANMON cpu_to_le16(5)
557 #define RXMODE_MASK cpu_to_le16(255)
558 #define RXMODE_DISABLE_802_3_HEADER cpu_to_le16(1<<8)
559 #define RXMODE_FULL_MASK (RXMODE_MASK | RXMODE_DISABLE_802_3_HEADER)
560 #define RXMODE_NORMALIZED_RSSI cpu_to_le16(1<<9)
577 #define SCANMODE_ACTIVE cpu_to_le16(0)
578 #define SCANMODE_PASSIVE cpu_to_le16(1)
579 #define SCANMODE_AIROSCAN cpu_to_le16(2)
587 #define AUTH_OPEN cpu_to_le16(0x1)
588 #define AUTH_ENCRYPT cpu_to_le16(0x101)
589 #define AUTH_SHAREDKEY cpu_to_le16(0x102)
590 #define AUTH_ALLOW_UNENCRYPTED cpu_to_le16(0x200)
598 #define DISABLE_REFRESH cpu_to_le16(0xFFFF)
602 #define POWERSAVE_CAM cpu_to_le16(0)
603 #define POWERSAVE_PSP cpu_to_le16(1)
604 #define POWERSAVE_PSPCAM cpu_to_le16(2)
622 #define RADIOTYPE_DEFAULT cpu_to_le16(0)
623 #define RADIOTYPE_802_11 cpu_to_le16(1)
624 #define RADIOTYPE_LEGACY cpu_to_le16(2)
628 #define TXPOWER_DEFAULT 0
630 #define RSSI_DEFAULT 0
632 #define PREAMBLE_AUTO cpu_to_le16(0)
633 #define PREAMBLE_LONG cpu_to_le16(1)
634 #define PREAMBLE_SHORT cpu_to_le16(2)
646 #define MAGIC_ACTION_STSCHG 1
647 #define MAGIC_ACTION_RESUME 2
648 #define MAGIC_IGNORE_MCAST (1<<8)
649 #define MAGIC_IGNORE_BCAST (1<<9)
650 #define MAGIC_SWITCH_TO_PSP (0<<10)
651 #define MAGIC_STAY_IN_CAM (1<<10)
692 #define STAT_NOPACKETS 0
693 #define STAT_NOCARRIERSET 10
694 #define STAT_GOTCARRIERSET 11
695 #define STAT_WRONGSSID 20
696 #define STAT_BADCHANNEL 25
697 #define STAT_BADBITRATES 30
698 #define STAT_BADPRIVACY 35
699 #define STAT_APFOUND 40
700 #define STAT_APREJECTED 50
701 #define STAT_AUTHENTICATING 60
702 #define STAT_DEAUTHENTICATED 61
703 #define STAT_AUTHTIMEOUT 62
704 #define STAT_ASSOCIATING 70
705 #define STAT_DEASSOCIATED 71
706 #define STAT_ASSOCTIMEOUT 72
707 #define STAT_NOTAIROAP 73
708 #define STAT_ASSOCIATED 80
709 #define STAT_LEAPING 90
710 #define STAT_LEAPFAILED 91
711 #define STAT_LEAPTIMEDOUT 92
712 #define STAT_LEAPCOMPLETE 93
779 #define CAP_ESS cpu_to_le16(1<<0)
780 #define CAP_IBSS cpu_to_le16(1<<1)
781 #define CAP_PRIVACY cpu_to_le16(1<<4)
782 #define CAP_SHORTHDR cpu_to_le16(1<<5)
850 #define TXCTL_TXOK (1<<1)
851 #define TXCTL_TXEX (1<<2)
852 #define TXCTL_802_3 (0<<3)
853 #define TXCTL_802_11 (1<<3)
854 #define TXCTL_ETHERNET (0<<4)
855 #define TXCTL_LLC (1<<4)
856 #define TXCTL_RELEASE (0<<5)
857 #define TXCTL_NORELEASE (1<<5)
859 #define BUSY_FID 0x10000
862 #define AIROMAGIC 0xa55a
864 #ifdef SIOCIWFIRSTPRIV
865 #ifdef SIOCDEVPRIVATE
866 #define AIROOLDIOCTL SIOCDEVPRIVATE
867 #define AIROOLDIDIFC AIROOLDIOCTL + 1
870 #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
876 #define AIROIOCTL SIOCIWFIRSTPRIV
877 #define AIROIDIFC AIROIOCTL + 1
881 #define AIROGCAP 0 // Capability rid
882 #define AIROGCFG 1 // USED A LOT
883 #define AIROGSLIST 2 // System ID list
884 #define AIROGVLIST 3 // List of specified AP's
885 #define AIROGDRVNAM 4 // NOTUSED
886 #define AIROGEHTENC 5 // NOTUSED
887 #define AIROGWEPKTMP 6
888 #define AIROGWEPKNV 7
890 #define AIROGSTATSC32 9
891 #define AIROGSTATSD32 10
892 #define AIROGMICRID 11
893 #define AIROGMICSTATS 12
894 #define AIROGFLAGS 13
897 #define AIRORSWVERSION 17
901 #define AIROPCAP AIROGSTATSD32 + 40
902 #define AIROPVLIST AIROPCAP + 1
903 #define AIROPSLIST AIROPVLIST + 1
904 #define AIROPCFG AIROPSLIST + 1
905 #define AIROPSIDS AIROPCFG + 1
906 #define AIROPAPLIST AIROPSIDS + 1
907 #define AIROPMACON AIROPAPLIST + 1
908 #define AIROPMACOFF AIROPMACON + 1
909 #define AIROPSTCLR AIROPMACOFF + 1
910 #define AIROPWEPKEY AIROPSTCLR + 1
911 #define AIROPWEPKEYNV AIROPWEPKEY + 1
912 #define AIROPLEAPPWD AIROPWEPKEYNV + 1
913 #define AIROPLEAPUSR AIROPLEAPPWD + 1
917 #define AIROFLSHRST AIROPWEPKEYNV + 40
918 #define AIROFLSHGCHR AIROFLSHRST + 1
919 #define AIROFLSHSTFL AIROFLSHGCHR + 1
920 #define AIROFLSHPCHR AIROFLSHSTFL + 1
921 #define AIROFLPUTBUF AIROFLSHPCHR + 1
922 #define AIRORESTART AIROFLPUTBUF + 1
924 #define FLASHSIZE 32768
925 #define AUXMEMSIZE (256 * 1024)
934 static const char swversion[] =
"2.1";
937 #define NUM_MODULES 2
938 #define MIC_MSGLEN_MAX 2400
939 #define EMMH32_MSGLEN_MAX MIC_MSGLEN_MAX
940 #define AIRO_DEF_MTU 2312
978 unsigned int rid: 16;
1048 #define HOST_SET (1 << 0)
1049 #define HOST_INT_TX (1 << 1)
1050 #define HOST_INT_TXERR (1 << 2)
1051 #define HOST_LCC_PAYLOAD (1 << 4)
1052 #define HOST_DONT_RLSE (1 << 5)
1053 #define HOST_DONT_RETRY (1 << 6)
1054 #define HOST_CLR_AID (1 << 7)
1055 #define HOST_RTS (1 << 9)
1056 #define HOST_SHORT (1 << 10)
1090 #define MAX_KEY_SIZE 13 // 128 (?) bits
1091 #define MIN_KEY_SIZE 5 // 40 bits RC4 - WEP
1100 static const char version[] =
"airo.c 0.6 (Ben Reed & Javier Achirica)";
1106 static unsigned short IN4500(
struct airo_info *,
u16 register );
1108 static int enable_MAC(
struct airo_info *ai,
int lock);
1109 static void disable_MAC(
struct airo_info *ai,
int lock);
1110 static void enable_interrupts(
struct airo_info*);
1111 static void disable_interrupts(
struct airo_info*);
1114 static int aux_bap_read(
struct airo_info*,
__le16 *pu16Dst,
int bytelen,
1116 static int fast_bap_read(
struct airo_info*,
__le16 *pu16Dst,
int bytelen,
1118 static int bap_write(
struct airo_info*,
const __le16 *pu16Src,
int bytelen,
1121 static int PC4500_readrid(
struct airo_info*,
u16 rid,
void *
pBuf,
int len,
int lock);
1122 static int PC4500_writerid(
struct airo_info*,
u16 rid,
const void
1123 *
pBuf,
int len,
int lock);
1124 static int do_writerid(
struct airo_info*,
u16 rid,
const void *rid_data,
1125 int len,
int dummy );
1126 static u16 transmit_allocate(
struct airo_info*,
int lenPayload,
int raw);
1127 static int transmit_802_3_packet(
struct airo_info*,
int len,
char *pPacket);
1128 static int transmit_802_11_packet(
struct airo_info*,
int len,
char *pPacket);
1131 static void mpi_unmap_card(
struct pci_dev *
pci);
1132 static void mpi_receive_802_3(
struct airo_info *ai);
1133 static void mpi_receive_802_11(
struct airo_info *ai);
1134 static int waitbusy (
struct airo_info *ai);
1137 static int airo_thread(
void *
data);
1141 static void airo_read_wireless_stats (
struct airo_info *local);
1147 static void micinit(
struct airo_info *ai);
1148 static int micsetup(
struct airo_info *ai);
1155 static void airo_networks_free(
struct airo_info *ai);
1163 #define MPI_MAX_FIDS 1
1170 #define FLAG_RADIO_OFF 0
1171 #define FLAG_RADIO_DOWN 1
1172 #define FLAG_RADIO_MASK 0x03
1173 #define FLAG_ENABLED 2
1174 #define FLAG_ADHOC 3
1175 #define FLAG_MIC_CAPABLE 4
1176 #define FLAG_UPDATE_MULTI 5
1177 #define FLAG_UPDATE_UNI 6
1178 #define FLAG_802_11 7
1179 #define FLAG_PROMISC 8
1180 #define FLAG_PENDING_XMIT 9
1181 #define FLAG_PENDING_XMIT11 10
1183 #define FLAG_REGISTERED 12
1184 #define FLAG_COMMIT 13
1185 #define FLAG_RESET 14
1186 #define FLAG_FLASHING 15
1187 #define FLAG_WPA_CAPABLE 16
1191 #define JOB_XMIT11 2
1193 #define JOB_PROMISC 4
1196 #define JOB_AUTOWEP 7
1197 #define JOB_WSTATS 8
1198 #define JOB_SCAN_RESULTS 9
1235 #define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
1251 static inline int bap_read(
struct airo_info *ai,
__le16 *pu16Dst,
int bytelen,
1254 return ai->
bap_read(ai, pu16Dst, bytelen, whichbap);
1262 static int cmdreset(
struct airo_info *ai);
1263 static int setflashmode (
struct airo_info *ai);
1264 static int flashgchar(
struct airo_info *ai,
int matchbyte,
int dwelltime);
1265 static int flashputbuf(
struct airo_info *ai);
1268 #define airo_print(type, name, fmt, args...) \
1269 printk(type DRV_NAME "(%s): " fmt "\n", name, ##args)
1271 #define airo_print_info(name, fmt, args...) \
1272 airo_print(KERN_INFO, name, fmt, ##args)
1274 #define airo_print_dbg(name, fmt, args...) \
1275 airo_print(KERN_DEBUG, name, fmt, ##args)
1277 #define airo_print_warn(name, fmt, args...) \
1278 airo_print(KERN_WARNING, name, fmt, ##args)
1280 #define airo_print_err(name, fmt, args...) \
1281 airo_print(KERN_ERR, name, fmt, ##args)
1283 #define AIRO_FLASH(dev) (((struct airo_info *)dev->ml_priv)->flash)
1297 static int flashpchar(
struct airo_info *ai,
int byte,
int dwelltime);
1309 memcpy(old, cur,
sizeof(*cur));
1319 emmh32_setseed(&cur->
seed, key, key_len, tfm);
1324 static void micinit(
struct airo_info *ai)
1329 PC4500_readrid(ai,
RID_MIC, &mic_rid,
sizeof(mic_rid), 0);
1357 static int micsetup(
struct airo_info *ai) {
1363 if (IS_ERR(ai->
tfm)) {
1376 static const u8 micsnap[] = {0xAA,0xAA,0x03,0x00,0x40,0x96,0x00,0x02};
1406 if (!context->
valid)
1417 emmh32_init(&context->
seed);
1420 emmh32_update(&context->
seed,(
u8*)&mic->
seq,
sizeof(mic->
seq));
1421 emmh32_update(&context->
seed,(
u8*)(frame + 1),payLen);
1422 emmh32_final(&context->
seed, (
u8*)&mic->
mic);
1462 if (
memcmp ((
u8*)eth + 14, micsnap,
sizeof(micsnap)) == 0) {
1472 if (
memcmp (mic->
u.
snap, micsnap,
sizeof(micsnap)) != 0) {
1484 if ( (micSEQ & 1) == 0 ) {
1490 int mcast = eth->
da[0] & 1;
1495 if (!context->
valid) {
1505 emmh32_init(&context->
seed);
1508 emmh32_update(&context->
seed, (
u8 *)&mic->
seq,
sizeof(mic->
seq));
1509 emmh32_update(&context->
seed, (
u8 *)(eth + 1),payLen);
1511 emmh32_final(&context->
seed, digest);
1521 if (RxSeqValid(ai, context, mcast, micSEQ) ==
SUCCESS) {
1564 context->
window = (micSeq > 33) ? micSeq : 33;
1569 context->
window = (micSeq > 33) ? micSeq : 33;
1574 seq = micSeq - (context->
window - 33);
1582 MoveWindow(context,micSeq);
1590 if (!(context->
rx & index)) {
1595 MoveWindow(context,micSeq);
1602 static void MoveWindow(
miccntx *context,
u32 micSeq)
1607 if (micSeq > context->
window) {
1608 shift = (micSeq - context->
window) >> 1;
1612 context->
rx >>= shift;
1616 context->
window = micSeq;
1625 #define MIC_ACCUM(val) \
1626 context->accum += (u64)(val) * context->coeff[coeff_position++];
1628 static unsigned char aes_counter[16];
1641 crypto_cipher_setkey(tfm, pkey, 16);
1644 aes_counter[15] = (
u8)(counter >> 0);
1645 aes_counter[14] = (
u8)(counter >> 8);
1646 aes_counter[13] = (
u8)(counter >> 16);
1647 aes_counter[12] = (
u8)(counter >> 24);
1649 memcpy (plain, aes_counter, 16);
1650 crypto_cipher_encrypt_one(tfm, plain, plain);
1670 int coeff_position, byte_position;
1672 if (len == 0)
return;
1674 coeff_position = context->
position >> 2;
1677 byte_position = context->
position & 3;
1678 if (byte_position) {
1681 if (len == 0)
return;
1682 context->
part.
d8[byte_position++] = *pOctets++;
1685 }
while (byte_position < 4);
1700 context->
part.
d8[byte_position++] = *pOctets++;
1707 static u32 mask32[4] = { 0x00000000
L, 0xFF000000
L, 0xFFFF0000L, 0xFFFFFF00L };
1712 int coeff_position, byte_position;
1718 coeff_position = context->
position >> 2;
1721 byte_position = context->
position & 3;
1722 if (byte_position) {
1729 sum = context->
accum;
1730 stmp = (sum & 0xffffffff
LL) - ((sum >> 32) * 15);
1731 utmp = (stmp & 0xffffffff
LL) - ((stmp >> 32) * 15);
1732 sum = utmp & 0xffffffff
LL;
1733 if (utmp > 0x10000000fLL)
1737 digest[0] = (val>>24) & 0xFF;
1738 digest[1] = (val>>16) & 0xFF;
1739 digest[2] = (val>>8) & 0xFF;
1740 digest[3] = val & 0xFF;
1751 memset(&cmd, 0,
sizeof(cmd));
1756 issuecommand(ai, &cmd, &rsp);
1769 wkr,
sizeof(*wkr), lock);
1775 rc = PC4500_writerid(ai,
RID_WEP_TEMP, wkr,
sizeof(*wkr), lock);
1779 rc = PC4500_writerid(ai,
RID_WEP_PERM, wkr,
sizeof(*wkr), lock);
1788 return PC4500_readrid(ai,
RID_SSID, ssidr,
sizeof(*ssidr), 1);
1793 return PC4500_writerid(ai,
RID_SSID, pssidr,
sizeof(*pssidr), lock);
1796 static int readConfigRid(
struct airo_info *ai,
int lock)
1812 static inline void checkThrottle(
struct airo_info *ai)
1817 for(i=0; i<8; i++) {
1825 static int writeConfigRid(
struct airo_info *ai,
int lock)
1842 return PC4500_writerid( ai,
RID_CONFIG, &cfgr,
sizeof(cfgr), lock);
1847 return PC4500_readrid(ai,
RID_STATUS, statr,
sizeof(*statr), lock);
1852 return PC4500_readrid(ai,
RID_APLIST, aplr,
sizeof(*aplr), 1);
1857 return PC4500_writerid(ai,
RID_APLIST, aplr,
sizeof(*aplr), lock);
1867 return PC4500_readrid(ai, rid, sr,
sizeof(*sr), lock);
1870 static void try_auto_wep(
struct airo_info *ai)
1891 writeConfigRid(ai, 1);
1904 "register interrupt %d failed, rc %d",
1913 enable_interrupts(ai);
1919 netif_start_queue(dev);
1926 int npacks, pending;
1927 unsigned long flags;
1934 npacks = skb_queue_len (&ai->
txq);
1936 if (npacks >=
MAXTXQ - 1) {
1937 netif_stop_queue (dev);
1939 dev->
stats.tx_fifo_errors++;
1949 spin_unlock_irqrestore(&ai->
aux_lock,flags);
1950 netif_wake_queue (dev);
1954 mpi_send_packet (dev);
1966 static int mpi_send_packet (
struct net_device *dev)
1979 "%s: Dequeue'd zero in send_packet()",
2002 (
char *)&wifictlhdr8023,
sizeof(wifictlhdr8023));
2005 sizeof(wifictlhdr8023));
2007 sizeof(wifictlhdr8023) + 2 ;
2026 memcpy (sendbuf, &pMic,
sizeof(pMic));
2027 sendbuf +=
sizeof(pMic);
2035 memcpy(sendbuf, buffer, len);
2041 OUT4500(ai,
EVACK, 8);
2059 ai->
dev->stats.tx_aborted_errors++;
2061 ai->
dev->stats.tx_heartbeat_errors++;
2065 ai->
dev->stats.tx_carrier_errors++;
2098 static void airo_end_xmit(
struct net_device *dev) {
2103 int fid = priv->
xmit.fid;
2108 status = transmit_802_3_packet (priv, fids[fid], skb->
data);
2114 for (; i <
MAX_FIDS / 2 && (priv->
fids[
i] & 0xffff0000); i++);
2117 dev->
stats.tx_window_errors++;
2120 netif_wake_queue(dev);
2132 if ( skb ==
NULL ) {
2138 for( i = 0; i <
MAX_FIDS / 2 && (fids[
i] & 0xffff0000); i++ );
2139 for( j = i + 1; j <
MAX_FIDS / 2 && (fids[
j] & 0xffff0000); j++ );
2142 netif_stop_queue(dev);
2145 dev->
stats.tx_fifo_errors++;
2152 fids[
i] |= (len << 16);
2157 netif_stop_queue(dev);
2165 static void airo_end_xmit11(
struct net_device *dev) {
2170 int fid = priv->
xmit11.fid;
2175 status = transmit_802_11_packet (priv, fids[fid], skb->
data);
2184 dev->
stats.tx_window_errors++;
2187 netif_wake_queue(dev);
2201 netif_stop_queue(dev);
2206 if ( skb ==
NULL ) {
2213 for( j = i + 1; j <
MAX_FIDS && (fids[
j] & 0xffff0000); j++ );
2216 netif_stop_queue(dev);
2219 dev->
stats.tx_fifo_errors++;
2226 fids[
i] |= (len << 16);
2231 netif_stop_queue(dev);
2235 airo_end_xmit11(dev);
2239 static void airo_read_stats(
struct net_device *dev)
2250 readStatsRid(ai, &stats_rid,
RID_STATS, 0);
2262 dev->
stats.tx_fifo_errors;
2283 airo_read_stats(dev);
2289 static void airo_set_promisc(
struct airo_info *ai) {
2293 memset(&cmd, 0,
sizeof(cmd));
2297 issuecommand(ai, &cmd, &rsp);
2301 static void airo_set_multicast_list(
struct net_device *dev) {
2310 airo_set_promisc(ai);
2318 static int airo_set_mac_address(
struct net_device *dev,
void *
p)
2323 readConfigRid(ai, 1);
2327 writeConfigRid (ai, 1);
2335 static int airo_change_mtu(
struct net_device *dev,
int new_mtu)
2337 if ((new_mtu < 68) || (new_mtu > 2400))
2345 static void add_airo_dev(
struct airo_info *ai)
2353 static void del_airo_dev(
struct airo_info *ai)
2359 static int airo_close(
struct net_device *dev) {
2362 netif_stop_queue(dev);
2365 #ifdef POWER_ON_DOWN
2374 disable_interrupts( ai );
2390 disable_interrupts(ai);
2391 takedown_proc_entry( dev, ai );
2410 airo_networks_free (ai);
2421 mpi_unmap_card(ai->
pci);
2430 crypto_free_cipher(ai->
tfm);
2437 static int wll_header_parse(
const struct sk_buff *skb,
unsigned char *haddr)
2443 static void mpi_unmap_card(
struct pci_dev *pci)
2461 static int mpi_init_descriptors (
struct airo_info *ai)
2469 netif_stop_queue(ai->
dev);
2471 memset(&rsp,0,
sizeof(rsp));
2472 memset(&cmd,0,
sizeof(cmd));
2478 rc=issuecommand(ai, &cmd, &rsp);
2491 memset(&rsp,0,
sizeof(rsp));
2492 memset(&cmd,0,
sizeof(cmd));
2506 rc=issuecommand(ai, &cmd, &rsp);
2513 memset(&rsp,0,
sizeof(rsp));
2514 memset(&cmd,0,
sizeof(cmd));
2520 rc=issuecommand(ai, &cmd, &rsp);
2540 unsigned long mem_start, mem_len, aux_start, aux_len;
2544 unsigned char *vpackoff;
2545 unsigned char __iomem *pciaddroff;
2554 (
int)mem_start, (
int)mem_len);
2559 (
int)aux_start, (
int)aux_len);
2566 (
int)mem_start, (
int)mem_len);
2572 (
int)aux_start, (
int)aux_len);
2601 pciaddroff +=
sizeof(
RxFid);
2613 &wifictlhdr8023,
sizeof(wifictlhdr8023));
2615 pciaddroff +=
sizeof(
TxFid);
2629 pciaddroff +=
sizeof(
Rid);
2634 if (mpi_init_descriptors (ai) !=
SUCCESS)
2652 static const struct header_ops airo_header_ops = {
2653 .parse = wll_header_parse,
2657 .ndo_open = airo_open,
2658 .ndo_stop = airo_close,
2659 .ndo_start_xmit = airo_start_xmit11,
2660 .ndo_get_stats = airo_get_stats,
2661 .ndo_set_mac_address = airo_set_mac_address,
2662 .ndo_do_ioctl = airo_ioctl,
2663 .ndo_change_mtu = airo_change_mtu,
2666 static void wifi_setup(
struct net_device *dev)
2670 dev->wireless_handlers = &airo_handler_def;
2693 dev->wireless_data = ethdev->wireless_data;
2704 static int reset_card(
struct net_device *dev ,
int lock) {
2719 #define AIRO_MAX_NETWORK_COUNT 64
2720 static int airo_networks_allocate(
struct airo_info *ai)
2735 static void airo_networks_free(
struct airo_info *ai)
2741 static void airo_networks_initialize(
struct airo_info *ai)
2753 .ndo_open = airo_open,
2754 .ndo_stop = airo_close,
2755 .ndo_start_xmit = airo_start_xmit,
2756 .ndo_get_stats = airo_get_stats,
2757 .ndo_set_rx_mode = airo_set_multicast_list,
2758 .ndo_set_mac_address = airo_set_mac_address,
2759 .ndo_do_ioctl = airo_ioctl,
2760 .ndo_change_mtu = airo_change_mtu,
2765 .ndo_open = airo_open,
2766 .ndo_stop = airo_close,
2767 .ndo_start_xmit = mpi_start_xmit,
2768 .ndo_get_stats = airo_get_stats,
2769 .ndo_set_rx_mode = airo_set_multicast_list,
2770 .ndo_set_mac_address = airo_set_mac_address,
2771 .ndo_do_ioctl = airo_ioctl,
2772 .ndo_change_mtu = airo_change_mtu,
2778 int is_pcmcia,
struct pci_dev *pci,
2793 ai = dev->
ml_priv = netdev_priv(dev);
2798 if (pci && (pci->
device == 0x5000 || pci->
device == 0xa504)) {
2803 sema_init(&ai->
sem, 1);
2810 if (airo_networks_allocate (ai))
2812 airo_networks_initialize (ai);
2814 skb_queue_head_init (&ai->
txq);
2821 dev->wireless_handlers = &airo_handler_def;
2830 reset_card (dev, 1);
2842 if (mpi_map_card(ai, pci)) {
2865 ai->
wifidev = init_wifidev(ai, dev);
2869 rc = readCapabilityRid(ai, &cap_rid, 1);
2896 "versions older than 5.30.17.");
2911 if (setup_proc_entry(dev, dev->
ml_priv) < 0)
2926 mpi_unmap_card(ai->
pci);
2932 airo_networks_free(ai);
2942 return _init_airo_card ( irq, port, is_pcmcia,
NULL, dmdev);
2947 static int waitbusy (
struct airo_info *ai) {
2951 if ((++delay % 20) == 0)
2954 return delay < 10000;
2962 if (reset_card (dev, 1))
2975 enable_interrupts( ai );
2976 netif_wake_queue(dev);
2982 static void airo_send_event(
struct net_device *dev) {
2988 PC4500_readrid(ai,
RID_STATUS, &status_rid,
sizeof(status_rid), 0);
2990 wrqu.data.length = 0;
2991 wrqu.data.flags = 0;
2999 static void airo_process_scan_results (
struct airo_info *ai) {
3010 memset (loop_net, 0,
sizeof (loop_net->
bss));
3022 while((!rc) && (bss.index !=
cpu_to_le16(0xffff))) {
3030 if (tmp_net !=
NULL) {
3031 memcpy(tmp_net, &bss,
sizeof(tmp_net->
bss));
3053 wrqu.data.length = 0;
3054 wrqu.data.flags = 0;
3058 static int airo_thread(
void *
data) {
3076 init_waitqueue_entry(&wait,
current);
3094 unsigned long wake_at;
3133 airo_end_xmit11(dev);
3135 airo_read_stats(dev);
3137 airo_read_wireless_stats(ai);
3139 airo_set_promisc(ai);
3143 airo_send_event(dev);
3147 airo_process_scan_results(ai);
3160 if ((fc & 0xe0) == 0xc0)
3164 if ((fc & 0x300) == 0x300)
3170 static void airo_handle_cisco_mic(
struct airo_info *ai)
3179 #define STAT_NOBEACON 0x8000
3180 #define STAT_MAXRETRIES 0x8001
3181 #define STAT_MAXARL 0x8002
3182 #define STAT_FORCELOSS 0x8003
3183 #define STAT_TSFSYNC 0x8004
3184 #define STAT_DEAUTH 0x8100
3185 #define STAT_DISASSOC 0x8200
3186 #define STAT_ASSOC_FAIL 0x8400
3187 #define STAT_AUTH_FAIL 0x0300
3188 #define STAT_ASSOC 0x0400
3189 #define STAT_REASSOC 0x0600
3191 static void airo_print_status(
const char *devname,
u16 status)
3195 switch (status & 0xFF00) {
3239 static void airo_handle_link(
struct airo_info *ai)
3242 int scan_forceloss = 0;
3252 airo_print_status(ai->
dev->name, status);
3266 airo_send_event(ai->
dev);
3267 }
else if (!scan_forceloss) {
3268 if (auto_wep && !ai->
expires) {
3280 static void airo_handle_rx(
struct airo_info *ai)
3290 mpi_receive_802_11(ai);
3292 mpi_receive_802_3(ai);
3297 fid = IN4500(ai,
RXFID);
3301 bap_setup (ai, fid, 4,
BAP0);
3309 bap_setup(ai, fid, 0x36,
BAP0);
3310 bap_read(ai, &
hdr.len, 2,
BAP0);
3322 bap_read(ai, &fc,
sizeof (fc),
BAP0);
3327 skb = dev_alloc_skb(len + hdrlen + 2 + 2);
3329 ai->
dev->stats.rx_dropped++;
3333 skb_reserve(skb, 2);
3337 bap_read(ai, buffer + 1, hdrlen - 2,
BAP0);
3339 bap_read(ai, tmpbuf, 6,
BAP0);
3341 bap_read(ai, &v,
sizeof(v),
BAP0);
3345 bap_read(ai, tmpbuf, gap,
BAP0);
3348 "big. Problems will follow...");
3351 bap_read(ai, buffer + hdrlen/2, len,
BAP0);
3357 bap_read(ai, (
__le16 *) &micbuf,
sizeof (micbuf),
BAP0);
3359 bap_setup(ai, fid, 0x44,
BAP0);
3361 if (len <=
sizeof (micbuf)) {
3366 len -=
sizeof(micbuf);
3372 if (decapsulate(ai, &micbuf, (
etherHead*) buffer, len))
3379 if (success && (ai->
spy_data.spy_number > 0)) {
3385 sa = (
char *) buffer + 6;
3386 bap_setup(ai, fid, 8,
BAP0);
3389 sa = (
char *) buffer + 10;
3390 wstats.qual =
hdr.rssi[0];
3394 wstats.level = (
hdr.rssi[1] + 321) / 2;
3395 wstats.noise = ai->
wstats.qual.noise;
3409 skb_reset_mac_header(skb);
3421 static void airo_handle_tx(
struct airo_info *ai,
u16 status)
3423 int i, len = 0, index = -1;
3427 unsigned long flags;
3430 get_tx_error(ai, -1);
3433 if (!skb_queue_empty(&ai->
txq)) {
3434 spin_unlock_irqrestore(&ai->
aux_lock,flags);
3435 mpi_send_packet(ai->
dev);
3438 spin_unlock_irqrestore(&ai->
aux_lock,flags);
3439 netif_wake_queue(ai->
dev);
3448 if ((ai->
fids[i] & 0xffff) == fid) {
3449 len = ai->
fids[
i] >> 16;
3455 if (status & EV_TXEXC)
3456 get_tx_error(ai, index);
3458 OUT4500(ai,
EVACK, status & (
EV_TX | EV_TXEXC));
3462 if (index < MAX_FIDS / 2) {
3464 netif_wake_queue(ai->
dev);
3467 netif_wake_queue(ai->
wifidev);
3482 if (!netif_device_present(dev))
3486 status = IN4500(ai,
EVSTAT);
3487 if (!(status &
STATUS_INTS) || (status == 0xffff))
3493 OUT4500(ai,
EVACK, EV_AWAKE);
3494 OUT4500(ai,
EVACK, EV_AWAKE);
3497 if (!savedInterrupts) {
3498 savedInterrupts = IN4500(ai,
EVINTEN);
3503 OUT4500(ai,
EVACK, EV_MIC);
3504 airo_handle_cisco_mic(ai);
3509 airo_handle_link(ai);
3518 airo_handle_tx(ai, status);
3526 if (savedInterrupts)
3527 OUT4500(ai,
EVINTEN, savedInterrupts);
3545 outw( val, ai->
dev->base_addr + reg );
3547 outb( val & 0xff, ai->
dev->base_addr + reg );
3548 outb( val >> 8, ai->
dev->base_addr + reg + 1 );
3558 rc =
inw( ai->
dev->base_addr + reg );
3560 rc =
inb( ai->
dev->base_addr + reg );
3561 rc += ((
int)
inb( ai->
dev->base_addr + reg + 1 )) << 8;
3566 static int enable_MAC(
struct airo_info *ai,
int lock)
3584 memset(&cmd, 0,
sizeof(cmd));
3586 rc = issuecommand(ai, &cmd, &rsp);
3597 else if ((rsp.
status & 0xFF00) != 0) {
3605 static void disable_MAC(
struct airo_info *ai,
int lock ) {
3613 memset(&cmd, 0,
sizeof(cmd));
3615 issuecommand(ai, &cmd, &rsp);
3622 static void enable_interrupts(
struct airo_info *ai ) {
3624 OUT4500( ai,
EVINTEN, STATUS_INTS );
3627 static void disable_interrupts(
struct airo_info *ai ) {
3631 static void mpi_receive_802_3(
struct airo_info *ai)
3644 if (len < 12 || len > 2048)
3647 skb = dev_alloc_skb(len);
3649 ai->
dev->stats.rx_dropped++;
3659 if (len <=
sizeof(micbuf) +
ETH_ALEN * 2)
3662 off =
sizeof(micbuf);
3693 if (rxd.
valid == 0) {
3701 static void mpi_receive_802_11(
struct airo_info *ai)
3731 skb = dev_alloc_skb( len + hdrlen + 2 );
3733 ai->
dev->stats.rx_dropped++;
3737 memcpy ((
char *)buffer, ptr, hdrlen);
3741 gap = get_unaligned_le16(ptr);
3748 "gaplen too big. Problems will follow...");
3750 memcpy ((
char *)buffer + hdrlen, ptr, len);
3752 #ifdef IW_WIRELESS_SPY
3757 sa = (
char*)buffer + 10;
3762 wstats.level = (
hdr.rssi[1] + 321) / 2;
3763 wstats.noise = ai->
wstats.qual.noise;
3771 skb_reset_mac_header(skb);
3779 if (rxd.
valid == 0) {
3797 memset( &mySsid, 0,
sizeof( mySsid ) );
3806 if ( issuecommand( ai, &cmd, &rsp ) !=
SUCCESS ) {
3811 disable_MAC( ai, 0);
3816 if (issuecommand(ai, &cmd, &rsp) !=
SUCCESS) {
3822 if (!aux_bap || rsp.
status & 0xff00) {
3842 status = readConfigRid(ai, lock);
3845 status = readCapabilityRid(ai, &cap_rid, lock);
3848 status = PC4500_readrid(ai,
RID_RSSI,&rssi_rid,
sizeof(rssi_rid),lock);
3882 for( i = 0; i < 8 && rates[
i]; i++ ) {
3892 for( i = 0; i < 3 && ssids[
i]; i++ ) {
3893 size_t len =
strlen(ssids[i]);
3902 status = writeConfigRid(ai, lock);
3907 status = writeSsidRid(ai, &mySsid, lock);
3911 status = enable_MAC(ai, lock);
3916 rc = readWepKeyRid(ai, &wkr, 1, lock);
3922 rc = readWepKeyRid(ai, &wkr, 0, lock);
3923 }
while(lastindex != wkr.
kindex);
3932 int max_tries = 600000;
3935 OUT4500(ai,
EVACK, EV_CMD);
3942 while (max_tries-- && (IN4500(ai,
EVSTAT) & EV_CMD) == 0) {
3946 if (!
in_atomic() && (max_tries & 255) == 0)
3950 if ( max_tries == -1 ) {
3952 "Max tries exceeded when issuing command");
3953 if (IN4500(ai,
COMMAND) & COMMAND_BUSY)
3965 "cmd:%x status:%x rsp0:%x rsp1:%x rsp2:%x",
3970 if (IN4500(ai,
COMMAND) & COMMAND_BUSY) {
3974 OUT4500(ai,
EVACK, EV_CMD);
3987 OUT4500(ai,
SELECT0+whichbap, rid);
3988 OUT4500(ai,
OFFSET0+whichbap, offset);
3990 int status = IN4500(ai,
OFFSET0+whichbap);
3997 }
else if ( status &
BAP_ERR ) {
4005 if ( !(max_tries--) ) {
4007 "BAP setup error too many retries\n");
4011 OUT4500(ai,
SELECT0+whichbap, rid);
4012 OUT4500(ai,
OFFSET0+whichbap, offset);
4028 *len = IN4500(ai,
AUXDATA)&0xff;
4029 if (offset != 4) OUT4500(ai,
AUXOFF, offset);
4035 int bytelen,
int whichbap)
4043 unsigned long flags;
4046 page = IN4500(ai,
SWS0+whichbap);
4047 offset = IN4500(ai,
SWS2+whichbap);
4048 next = aux_setup(ai, page, offset, &len);
4049 words = (bytelen+1)>>1;
4051 for (i=0; i<words;) {
4053 count = (len>>1) < (words-i) ? (len>>1) : (words-i);
4059 pu16Dst+i, count << 1 );
4062 next = aux_setup(ai, next, 4, &len);
4065 spin_unlock_irqrestore(&ai->
aux_lock, flags);
4072 int bytelen,
int whichbap)
4074 bytelen = (bytelen + 1) & (~1);
4076 insw( ai->
dev->base_addr+
DATA0+whichbap, pu16Dst, bytelen>>1 );
4078 insb( ai->
dev->base_addr+
DATA0+whichbap, pu16Dst, bytelen );
4084 int bytelen,
int whichbap)
4086 bytelen = (bytelen + 1) & (~1);
4089 pu16Src, bytelen>>1 );
4091 outsb( ai->
dev->base_addr+
DATA0+whichbap, pu16Src, bytelen );
4101 memset(&cmd, 0,
sizeof(cmd));
4104 status = issuecommand(ai, &cmd, &rsp);
4105 if (status != 0)
return status;
4106 if ( (rsp.
status & 0x7F00) != 0) {
4107 return (accmd << 8) + (rsp.
rsp0 & 0xFF);
4114 static int PC4500_readrid(
struct airo_info *ai,
u16 rid,
void *
pBuf,
int len,
int lock)
4127 memset(&cmd, 0,
sizeof(cmd));
4128 memset(&rsp, 0,
sizeof(rsp));
4140 rc = issuecommand(ai, &cmd, &rsp);
4157 bap_read(ai, pBuf, 2,
BAP1);
4163 "Rid %x has a length of %d which is too short",
4164 (
int)rid, (
int)len );
4169 rc = bap_read(ai, ((
__le16*)pBuf)+1, len,
BAP1);
4179 static int PC4500_writerid(
struct airo_info *ai,
u16 rid,
4180 const void *pBuf,
int len,
int lock)
4197 "%s: MAC should be disabled (rid=%04x)",
4199 memset(&cmd, 0,
sizeof(cmd));
4200 memset(&rsp, 0,
sizeof(rsp));
4212 if (len < 4 || len > 2047) {
4219 rc = issuecommand(ai, &cmd, &rsp);
4220 if ((rc & 0xff00) != 0) {
4227 if ((rsp.
status & 0x7f00))
4232 if ( (status = PC4500_accessrid(ai, rid,
CMD_ACCESS)) != 0) {
4241 bap_write(ai, pBuf, len,
BAP1);
4243 rc = PC4500_accessrid(ai, rid, 0x100|
CMD_ACCESS);
4253 static u16 transmit_allocate(
struct airo_info *ai,
int lenPayload,
int raw)
4255 unsigned int loop = 3000;
4262 cmd.
parm0 = lenPayload;
4265 if (issuecommand(ai, &cmd, &rsp) !=
SUCCESS) {
4269 if ( (rsp.
status & 0xFF00) != 0) {
4284 OUT4500(ai,
EVACK, EV_ALLOC);
4297 if (bap_setup(ai, txFid, 0x0008,
BAP1) !=
SUCCESS)
4300 bap_write(ai, &txControl,
sizeof(txControl),
BAP1);
4311 static int transmit_802_3_packet(
struct airo_info *ai,
int len,
char *pPacket)
4322 if (len <= ETH_ALEN * 2) {
4326 len -= ETH_ALEN * 2;
4332 miclen =
sizeof(pMic);
4340 bap_write(ai, &payloadLen,
sizeof(payloadLen),
BAP1);
4346 memset( &cmd, 0,
sizeof( cmd ) );
4349 if (issuecommand(ai, &cmd, &rsp) !=
SUCCESS)
return ERROR;
4354 static int transmit_802_11_packet(
struct airo_info *ai,
int len,
char *pPacket)
4360 static u8 tail[(30-10) + 2 + 6] = {[30-10] = 6};
4379 bap_write(ai, &payloadLen,
sizeof(payloadLen),
BAP1);
4381 bap_write(ai, (
__le16 *)pPacket, hdrlen,
BAP1);
4382 bap_write(ai, (
__le16 *)(
tail + (hdrlen - 10)), 38 - hdrlen,
BAP1);
4384 bap_write(ai, (
__le16 *)(pPacket + hdrlen), len - hdrlen,
BAP1);
4386 memset( &cmd, 0,
sizeof( cmd ) );
4389 if (issuecommand(ai, &cmd, &rsp) !=
SUCCESS)
return ERROR;
4400 char __user *buffer,
4405 const char __user *buffer,
4422 .open = proc_statsdelta_open,
4423 .release = proc_close,
4430 .open = proc_stats_open,
4431 .release = proc_close,
4438 .open = proc_status_open,
4439 .release = proc_close,
4446 .write = proc_write,
4447 .open = proc_SSID_open,
4448 .release = proc_close,
4455 .write = proc_write,
4456 .open = proc_BSSList_open,
4457 .release = proc_close,
4464 .write = proc_write,
4465 .open = proc_APList_open,
4466 .release = proc_close,
4473 .write = proc_write,
4474 .open = proc_config_open,
4475 .release = proc_close,
4482 .write = proc_write,
4483 .open = proc_wepkey_open,
4484 .release = proc_close,
4500 static int setup_proc_entry(
struct net_device *dev,
4515 apriv->
proc_entry, &proc_statsdelta_ops, dev);
4517 goto fail_stats_delta;
4518 entry->
uid = proc_kuid;
4519 entry->
gid = proc_kgid;
4526 entry->
uid = proc_kuid;
4527 entry->
gid = proc_kgid;
4534 entry->
uid = proc_kuid;
4535 entry->
gid = proc_kgid;
4542 entry->
uid = proc_kuid;
4543 entry->
gid = proc_kgid;
4550 entry->
uid = proc_kuid;
4551 entry->
gid = proc_kgid;
4558 entry->
uid = proc_kuid;
4559 entry->
gid = proc_kgid;
4566 entry->
uid = proc_kuid;
4567 entry->
gid = proc_kgid;
4574 entry->
uid = proc_kuid;
4575 entry->
gid = proc_kgid;
4599 static int takedown_proc_entry(
struct net_device *dev,
4627 char __user *buffer,
4644 static ssize_t proc_write(
struct file *file,
4645 const char __user *buffer,
4663 static int proc_status_open(
struct inode *
inode,
struct file *file)
4682 readStatusRid(apriv, &status_rid, 1);
4683 readCapabilityRid(apriv, &cap_rid, 1);
4688 mode & 1 ?
"CFG ":
"",
4689 mode & 2 ?
"ACT ":
"",
4690 mode & 0x10 ?
"SYN ":
"",
4691 mode & 0x20 ?
"LNK ":
"",
4692 mode & 0x40 ?
"LEAP ":
"",
4693 mode & 0x80 ?
"PRIV ":
"",
4694 mode & 0x100 ?
"KEY ":
"",
4695 mode & 0x200 ?
"WEP ":
"",
4696 mode & 0x8000 ?
"ERR ":
"");
4698 "Signal Strength: %d\n"
4699 "Signal Quality: %d\n"
4704 "Driver Version: %s\n"
4705 "Device: %s\nManufacturer: %s\nFirmware Version: %s\n"
4706 "Radio type: %x\nCountry: %x\nHardware Version: %x\n"
4707 "Software Version: %x\nSoftware Subversion: %x\n"
4708 "Boot block version: %x\n",
4731 static int proc_stats_rid_open(
struct inode*,
struct file*,
u16);
4732 static int proc_statsdelta_open(
struct inode *inode,
4733 struct file *file ) {
4740 static int proc_stats_open(
struct inode *inode,
struct file *file ) {
4741 return proc_stats_rid_open(inode, file,
RID_STATS);
4744 static int proc_stats_rid_open(
struct inode *inode,
4765 readStatsRid(apriv, &stats, rid, 1);
4769 for(i=0; statsLabels[
i]!=(
char *)-1 && i*4<len; i++) {
4770 if (!statsLabels[i])
continue;
4771 if (j+
strlen(statsLabels[i])+16>4096) {
4773 "Potentially disastrous buffer overflow averted!");
4786 static int get_dec_u16(
char *buffer,
int *
start,
int limit ) {
4789 for (value = 0; *start < limit && buffer[*start] >=
'0' &&
4790 buffer[*
start] <=
'9'; (*start)++) {
4793 value += buffer[*
start] -
'0';
4795 if ( !valid )
return -1;
4799 static int airo_config_commit(
struct net_device *dev,
4803 static inline int sniffing_mode(
struct airo_info *ai)
4809 static void proc_config_on_close(
struct inode *inode,
struct file *file)
4819 readConfigRid(ai, 1);
4825 if ( !
strncmp( line,
"Mode: ", 6 ) ) {
4827 if (sniffing_mode(ai))
4833 if ( line[0] ==
'a' ) {
4837 if ( line[0] ==
'r' ) {
4841 }
else if ( line[0] ==
'y' ) {
4845 }
else if ( line[0] ==
'l' )
4852 else if (!
strncmp(line,
"Radio: ", 7)) {
4861 else if ( !
strncmp( line,
"NodeName: ", 10 ) ) {
4867 for( j = 0; j < 16 && line[
j] !=
'\n'; j++ ) {
4874 else if ( !
strncmp( line,
"PowerMode: ", 11 ) ) {
4876 if ( !
strncmp( line,
"PSPCAM", 6 ) ) {
4879 }
else if ( !
strncmp( line,
"PSP", 3 ) ) {
4886 }
else if ( !
strncmp( line,
"DataRates: ", 11 ) ) {
4887 int v, i = 0,
k = 0;
4891 while((v = get_dec_u16(line, &i, 3))!=-1) {
4897 }
else if ( !
strncmp( line,
"Channel: ", 9 ) ) {
4900 v = get_dec_u16(line, &i, i+3);
4905 }
else if ( !
strncmp( line,
"XmitPower: ", 11 ) ) {
4908 v = get_dec_u16(line, &i, i+3);
4913 }
else if ( !
strncmp( line,
"WEP: ", 5 ) ) {
4927 }
else if ( !
strncmp( line,
"LongRetryLimit: ", 16 ) ) {
4931 v = get_dec_u16(line, &i, 3);
4932 v = (v<0) ? 0 : ((v>255) ? 255 : v);
4935 }
else if ( !
strncmp( line,
"ShortRetryLimit: ", 17 ) ) {
4939 v = get_dec_u16(line, &i, 3);
4940 v = (v<0) ? 0 : ((v>255) ? 255 : v);
4943 }
else if ( !
strncmp( line,
"RTSThreshold: ", 14 ) ) {
4947 v = get_dec_u16(line, &i, 4);
4951 }
else if ( !
strncmp( line,
"TXMSDULifetime: ", 16 ) ) {
4955 v = get_dec_u16(line, &i, 5);
4959 }
else if ( !
strncmp( line,
"RXMSDULifetime: ", 16 ) ) {
4963 v = get_dec_u16(line, &i, 5);
4967 }
else if ( !
strncmp( line,
"TXDiversity: ", 13 ) ) {
4969 (line[13]==
'l') ? 1 :
4970 ((line[13]==
'r')? 2: 3);
4972 }
else if ( !
strncmp( line,
"RXDiversity: ", 13 ) ) {
4974 (line[13]==
'l') ? 1 :
4975 ((line[13]==
'r')? 2: 3);
4977 }
else if ( !
strncmp( line,
"FragThreshold: ", 15 ) ) {
4981 v = get_dec_u16(line, &i, 4);
4986 }
else if (!
strncmp(line,
"Modulation: ", 12)) {
4994 }
else if (!
strncmp(line,
"Preamble: ", 10)) {
5005 while( line[0] && line[0] !=
'\n' ) line++;
5006 if ( line[0] ) line++;
5011 static const char *get_rmode(
__le16 mode)
5021 static int proc_config_open(
struct inode *inode,
struct file *file)
5043 data->
on_close = proc_config_on_close;
5045 readConfigRid(ai, 1);
5053 "DataRates: %d %d %d %d %d %d %d %d\n"
5078 "LongRetryLimit: %d\n"
5079 "ShortRetryLimit: %d\n"
5080 "RTSThreshold: %d\n"
5081 "TXMSDULifetime: %d\n"
5082 "RXMSDULifetime: %d\n"
5085 "FragThreshold: %d\n"
5112 static void proc_SSID_on_close(
struct inode *inode,
struct file *file)
5128 memset(&SSID_rid, 0,
sizeof(SSID_rid));
5130 for (i = 0; i < 3 && p <
end; i++) {
5133 while (*p !=
'\n' && j < 32)
5139 while (*p++ !=
'\n')
5145 writeSsidRid(ai, &SSID_rid, 1);
5149 static void proc_APList_on_close(
struct inode *inode,
struct file *file ) {
5159 memset( &APList_rid, 0,
sizeof(APList_rid) );
5162 for( i = 0; i < 4 && data->
writelen >= (i+1)*6*3; i++ ) {
5164 for( j = 0; j < 6*3 && data->
wbuffer[j+i*6*3]; j++ ) {
5167 APList_rid.
ap[
i][j/3]=
5171 APList_rid.
ap[
i][j/3]|=
5178 writeAPListRid(ai, &APList_rid, 1);
5183 static int do_writerid(
struct airo_info *ai,
u16 rid,
const void *rid_data,
5184 int len,
int dummy ) {
5188 rc = PC4500_writerid(ai, rid, rid_data, len, 1);
5202 rc = readWepKeyRid(ai, &wkr, 1, 1);
5212 rc = readWepKeyRid(ai, &wkr, 0, 1);
5215 }
while (lastindex != wkr.
kindex);
5219 static int get_wep_tx_idx(
struct airo_info *ai)
5225 rc = readWepKeyRid(ai, &wkr, 1, 1);
5232 rc = readWepKeyRid(ai, &wkr, 0, 1);
5235 }
while (lastindex != wkr.
kindex);
5239 static int set_wep_key(
struct airo_info *ai,
u16 index,
const char *key,
5240 u16 keylen,
int perm,
int lock)
5242 static const unsigned char macaddr[
ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
5249 memset(&wkr, 0,
sizeof(wkr));
5256 if (perm) disable_MAC(ai, lock);
5257 rc = writeWepKeyRid(ai, &wkr, perm, lock);
5258 if (perm) enable_MAC(ai, lock);
5262 static int set_wep_tx_idx(
struct airo_info *ai,
u16 index,
int perm,
int lock)
5267 memset(&wkr, 0,
sizeof(wkr));
5274 disable_MAC(ai, lock);
5277 rc = writeWepKeyRid(ai, &wkr, perm, lock);
5280 enable_MAC(ai, lock);
5284 static void proc_wepkey_on_close(
struct inode *inode,
struct file *file ) {
5294 memset(key, 0,
sizeof(key));
5301 index = data->
wbuffer[0] -
'0';
5302 if (data->
wbuffer[1] ==
'\n') {
5303 rc = set_wep_tx_idx(ai, index, 1, 1);
5306 "WEP transmit index to %d: %d.",
5317 for( i = 0; i < 16*3 && data->
wbuffer[i+
j]; i++ ) {
5328 rc = set_wep_key(ai, index, key, i/3, 1, 1);
5331 "%d: %d.", index, rc);
5335 static int proc_wepkey_open(
struct inode *inode,
struct file *file )
5349 memset(&wkr, 0,
sizeof(wkr));
5362 data->
on_close = proc_wepkey_on_close;
5365 strcpy(ptr,
"No wep keys\n");
5366 rc = readWepKeyRid(ai, &wkr, 1, 1);
5370 j +=
sprintf(ptr+j,
"Tx key = %d\n",
5373 j +=
sprintf(ptr+j,
"Key %d set with length = %d\n",
5377 readWepKeyRid(ai, &wkr, 0, 1);
5378 }
while((lastindex != wkr.
kindex) && (j < 180-30));
5384 static int proc_SSID_open(
struct inode *inode,
struct file *file)
5409 data->
on_close = proc_SSID_on_close;
5411 readSsidRid(ai, &SSID_rid);
5413 for (i = 0; i < 3; i++) {
5420 for (j = 0; j < len && SSID_rid.
ssids[
i].
ssid[
j]; j++)
5429 static int proc_APList_open(
struct inode *inode,
struct file *file ) {
5452 data->
on_close = proc_APList_on_close;
5454 readAPListRid(ai, &APList_rid);
5456 for( i = 0; i < 4; i++ ) {
5458 if ( !*(
int*)APList_rid.
ap[i] &&
5459 !*(
int*)&APList_rid.
ap[i][2])
break;
5460 ptr +=
sprintf(ptr,
"%pM\n", APList_rid.
ap[i]);
5462 if (i==0) ptr +=
sprintf(ptr,
"Not using specific APs\n");
5469 static int proc_BSSList_open(
struct inode *inode,
struct file *file ) {
5478 int doLoseSync = -1;
5498 memset(&cmd, 0,
sizeof(cmd));
5502 issuecommand(ai, &cmd, &rsp);
5513 rc = readBSSListRid(ai, doLoseSync, &BSSList_rid);
5515 ptr +=
sprintf(ptr,
"%pM %*s rssi = %d",
5520 ptr +=
sprintf(ptr,
" channel = %d %s %s %s %s\n",
5526 rc = readBSSListRid(ai, 0, &BSSList_rid);
5533 static int proc_close(
struct inode *inode,
struct file *file )
5550 static void timer_func(
struct net_device *dev ) {
5554 readConfigRid(apriv, 0);
5555 disable_MAC(apriv, 0);
5563 set_wep_tx_idx(apriv, apriv->
keyindex, 0, 0);
5569 set_wep_tx_idx(apriv, apriv->
defindex, 0, 0);
5577 writeConfigRid(apriv, 0);
5578 enable_MAC(apriv, 0);
5597 dev = _init_airo_card(pdev->
irq, pdev->
resource[0].start, 0, pdev, &pdev->
dev);
5599 dev = _init_airo_card(pdev->
irq, pdev->
resource[2].start, 0, pdev, &pdev->
dev);
5605 pci_set_drvdata(pdev, dev);
5611 struct net_device *dev = pci_get_drvdata(pdev);
5616 pci_set_drvdata(pdev,
NULL);
5621 struct net_device *dev = pci_get_drvdata(pdev);
5634 readAPListRid(ai, ai->
APList);
5635 readSsidRid(ai, ai->
SSID);
5636 memset(&cmd, 0,
sizeof(cmd));
5644 issuecommand(ai, &cmd, &rsp);
5652 static int airo_pci_resume(
struct pci_dev *pdev)
5654 struct net_device *dev = pci_get_drvdata(pdev);
5660 pci_enable_wake(pdev,
PCI_D0, 0);
5662 if (prev_state !=
PCI_D1) {
5664 mpi_init_descriptors(ai);
5678 writeSsidRid(ai, ai->
SSID, 0);
5683 writeAPListRid(ai, ai->
APList, 0);
5687 writeConfigRid(ai, 0);
5691 netif_wake_queue(dev);
5692 enable_interrupts(ai);
5698 static int __init airo_init_module(
void )
5704 if (!uid_valid(proc_kuid) || !gid_valid(proc_kgid))
5710 airo_entry->
uid = proc_kuid;
5711 airo_entry->
gid = proc_kgid;
5714 for (i = 0; i < 4 &&
io[
i] && irq[
i]; i++) {
5716 "io=0x%x", irq[i],
io[i] );
5723 i = pci_register_driver(&airo_driver);
5738 static void __exit airo_cleanup_module(
void )
5741 while(!list_empty(&airo_devices)) {
5767 return (0x100 - rssi_rid[rssi].rssidBm);
5777 for (i = 0; i < 256; i++)
5778 if (rssi_rid[i].rssidBm == dbm)
5801 quality = 0x20 - sq;
5808 quality = 0xb0 - sq;
5812 #define airo_get_max_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x20 : 0xa0)
5813 #define airo_get_avg_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x10 : 0x50);
5819 static int airo_get_name(
struct net_device *dev,
5824 strcpy(cwrq,
"IEEE 802.11-DS");
5832 static int airo_set_freq(
struct net_device *dev,
5842 int f = fwrq->
m / 100000;
5846 fwrq->
m = ieee80211_freq_to_dsss_chan(f);
5849 if((fwrq->
m > 1000) || (fwrq->
e > 0))
5855 if((channel < 1) || (channel > 14)) {
5860 readConfigRid(local, 1);
5873 static int airo_get_freq(
struct net_device *dev,
5882 readConfigRid(local, 1);
5886 readStatusRid(local, &status_rid, 1);
5889 if((ch > 0) && (ch < 15)) {
5890 fwrq->
m = ieee80211_dsss_chan_to_freq(ch) * 100000;
5904 static int airo_set_essid(
struct net_device *dev,
5913 readSsidRid(local, &SSID_rid);
5916 if (dwrq->
flags == 0) {
5918 memset(&SSID_rid, 0,
sizeof(SSID_rid));
5938 disable_MAC(local, 1);
5939 writeSsidRid(local, &SSID_rid, 1);
5940 enable_MAC(local, 1);
5949 static int airo_get_essid(
struct net_device *dev,
5957 readStatusRid(local, &status_rid, 1);
5977 static int airo_set_wap(
struct net_device *dev,
5989 else if (is_broadcast_ether_addr(awrq->
sa_data) ||
5990 is_zero_ether_addr(awrq->
sa_data)) {
5991 memset(&cmd, 0,
sizeof(cmd));
5995 issuecommand(local, &cmd, &rsp);
5998 memset(&APList_rid, 0,
sizeof(APList_rid));
6001 disable_MAC(local, 1);
6002 writeAPListRid(local, &APList_rid, 1);
6003 enable_MAC(local, 1);
6012 static int airo_get_wap(
struct net_device *dev,
6020 readStatusRid(local, &status_rid, 1);
6033 static int airo_set_nick(
struct net_device *dev,
6044 readConfigRid(local, 1);
6056 static int airo_get_nick(
struct net_device *dev,
6063 readConfigRid(local, 1);
6075 static int airo_set_rate(
struct net_device *dev,
6086 readCapabilityRid(local, &cap_rid, 1);
6089 if((vwrq->
value < 8) && (vwrq->
value >= 0)) {
6095 u8 normvalue = (
u8) (vwrq->
value/500000);
6098 for(i = 0 ; i < 8 ; i++) {
6106 if(vwrq->
value == -1) {
6108 for(i = 0 ; i < 8 ; i++) {
6120 readConfigRid(local, 1);
6122 if(vwrq->
fixed == 0) {
6125 for(i = 0 ; i < 8 ; i++) {
6145 static int airo_get_rate(
struct net_device *dev,
6153 readStatusRid(local, &status_rid, 1);
6157 readConfigRid(local, 1);
6167 static int airo_set_rts(
struct net_device *dev,
6173 int rthr = vwrq->
value;
6180 readConfigRid(local, 1);
6191 static int airo_get_rts(
struct net_device *dev,
6198 readConfigRid(local, 1);
6210 static int airo_set_frag(
struct net_device *dev,
6216 int fthr = vwrq->
value;
6224 readConfigRid(local, 1);
6235 static int airo_get_frag(
struct net_device *dev,
6242 readConfigRid(local, 1);
6254 static int airo_set_mode(
struct net_device *dev,
6262 readConfigRid(local, 1);
6263 if (sniffing_mode(local))
6317 static int airo_get_mode(
struct net_device *dev,
6324 readConfigRid(local, 1);
6343 static inline int valid_index(
struct airo_info *ai,
int index)
6345 return (index >= 0) && (index <= ai->
max_wep_idx);
6352 static int airo_set_encode(
struct net_device *dev,
6365 readConfigRid(local, 1);
6383 current_index = get_wep_tx_idx(local);
6384 if (current_index < 0)
6388 if (!valid_index(local, index))
6389 index = current_index;
6403 rc = set_wep_key(local, index, key.
key, key.
len, perm, 1);
6406 " WEP key at index %d: %d.",
6414 if((index == current_index) && (key.
len > 0) &&
6421 if (valid_index(local, index)) {
6422 rc = set_wep_tx_idx(local, index, perm, 1);
6425 " WEP transmit index to %d: %d.",
6452 static int airo_get_encode(
struct net_device *dev,
6465 readConfigRid(local, 1);
6485 if (!valid_index(local, index)) {
6486 index = get_wep_tx_idx(local);
6490 dwrq->
flags |= index + 1;
6493 wep_key_len = get_wep_key(local, index, &buf[0],
sizeof(buf));
6494 if (wep_key_len < 0) {
6497 dwrq->
length = wep_key_len;
6508 static int airo_set_encodeext(
struct net_device *dev,
6524 readConfigRid(local, 1);
6529 if (!valid_index(local, idx - 1))
6533 idx = get_wep_tx_idx(local);
6545 rc = set_wep_tx_idx(local, idx, perm, 1);
6548 "WEP transmit index to %d: %d.",
6552 set_key = ext->
key_len > 0 ? 1 : 0;
6565 }
else if (ext->
key_len > 0) {
6577 rc = set_wep_tx_idx(local, idx, perm, 1);
6580 "failed to set WEP transmit index to %d: %d.",
6585 rc = set_wep_key(local, idx, key.
key, key.
len, perm, 1);
6588 "failed to set WEP key at index %d: %d.",
6614 static int airo_get_encodeext(
struct net_device *dev,
6622 int idx, max_key_len, wep_key_len;
6628 readConfigRid(local, 1);
6630 max_key_len = encoding->
length -
sizeof(*ext);
6631 if (max_key_len < 0)
6636 if (!valid_index(local, idx - 1))
6640 idx = get_wep_tx_idx(local);
6645 encoding->
flags = idx + 1;
6646 memset(ext, 0,
sizeof(*ext));
6666 wep_key_len = get_wep_key(local, idx, &buf[0],
sizeof(buf));
6667 if (wep_key_len < 0) {
6682 static int airo_set_auth(
struct net_device *dev,
6735 if (param->
value > 0)
6750 static int airo_get_auth(
struct net_device *dev,
6760 switch (currentAuthType) {
6772 switch (currentAuthType) {
6798 static int airo_set_txpow(
struct net_device *dev,
6809 readCapabilityRid(local, &cap_rid, 1);
6822 readConfigRid(local, 1);
6835 static int airo_get_txpow(
struct net_device *dev,
6842 readConfigRid(local, 1);
6855 static int airo_set_retry(
struct net_device *dev,
6866 readConfigRid(local, 1);
6893 static int airo_get_retry(
struct net_device *dev,
6902 readConfigRid(local, 1);
6924 static int airo_get_range(
struct net_device *dev,
6935 readCapabilityRid(local, &cap_rid, 1);
6938 memset(range, 0,
sizeof(*range));
6945 for(i = 0; i < 14; i++) {
6946 range->
freq[
k].i = i + 1;
6947 range->
freq[
k].m = ieee80211_dsss_chan_to_freq(i + 1) * 100000;
6948 range->
freq[k++].e = 1;
6959 range->
max_qual.level = 0x100 - 120;
6960 range->
max_qual.noise = 0x100 - 120;
6967 range->
avg_qual.level = 0x100 - 70;
6970 range->
avg_qual.level = 0x100 - 80;
6972 range->
avg_qual.noise = 0x100 - 85;
6974 for(i = 0 ; i < 8 ; i++) {
7012 range->
max_pmt = 65535 * 1024;
7018 for(i = 0 ; i < 8 ; i++) {
7049 static int airo_set_power(
struct net_device *dev,
7056 readConfigRid(local, 1);
7058 if (sniffing_mode(local))
7079 if (sniffing_mode(local))
7086 if (sniffing_mode(local))
7106 static int airo_get_power(
struct net_device *dev,
7114 readConfigRid(local, 1);
7137 static int airo_set_sens(
struct net_device *dev,
7144 readConfigRid(local, 1);
7156 static int airo_get_sens(
struct net_device *dev,
7163 readConfigRid(local, 1);
7176 static int airo_get_aplist(
struct net_device *dev,
7194 if (readBSSListRid(local, loseSync, &BSSList))
7197 memcpy(address[i].sa_data, BSSList.
bssid, ETH_ALEN);
7201 qual[
i].
level = 0x100 - dBm;
7202 qual[
i].
qual = airo_dbm_to_pct(local->
rssi, dBm);
7207 qual[
i].
level = (dBm + 321) / 2;
7219 readStatusRid(local, &status_rid, 1);
7221 i <
min(IW_MAX_AP, 4) &&
7227 & status_rid.
bssid[
i][5])!=0xff &&
7228 (status_rid.
bssid[i][0]
7229 | status_rid.
bssid[i][1]
7230 | status_rid.
bssid[i][2]
7231 | status_rid.
bssid[i][3]
7232 | status_rid.
bssid[i][4]
7233 | status_rid.
bssid[i][5]);
7235 memcpy(address[i].sa_data,
7236 status_rid.
bssid[i], ETH_ALEN);
7254 static int airo_set_scan(
struct net_device *dev,
7282 memset(&cmd, 0,
sizeof(cmd));
7284 issuecommand(ai, &cmd, &rsp);
7299 static inline char *airo_translate_scan(
struct net_device *dev,
7316 memcpy(iwe.u.ap_addr.sa_data, bss->
bssid, ETH_ALEN);
7317 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
7323 iwe.u.data.length = bss->
ssidLen;
7324 if(iwe.u.data.length > 32)
7325 iwe.u.data.length = 32;
7327 iwe.u.data.flags = 1;
7328 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
7333 capabilities = bss->
cap;
7339 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
7346 iwe.u.freq.m = ieee80211_dsss_chan_to_freq(iwe.u.freq.m) * 100000;
7348 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
7356 iwe.u.qual.level = 0x100 - dBm;
7357 iwe.u.qual.qual = airo_dbm_to_pct(ai->
rssi, dBm);
7362 iwe.u.qual.level = (dBm + 321) / 2;
7363 iwe.u.qual.qual = 0;
7368 iwe.u.qual.noise = ai->
wstats.qual.noise;
7369 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
7378 iwe.u.data.length = 0;
7379 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
7384 current_val = current_ev + iwe_stream_lcp_len(info);
7388 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
7390 for(i = 0 ; i < 8 ; i++) {
7392 if(bss->
rates[i] == 0)
7395 iwe.u.bitrate.value = ((bss->
rates[
i] & 0x7f) * 500000);
7397 current_val = iwe_stream_add_value(info, current_ev,
7398 current_val, end_buf,
7402 if ((current_val - current_ev) > iwe_stream_lcp_len(info))
7403 current_ev = current_val;
7410 iwe.u.data.length =
strlen(buf);
7411 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
7418 unsigned int num_null_ies = 0;
7422 while ((length >= 2) && (num_null_ies < 2)) {
7423 if (2 + ie[1] > length) {
7444 iwe.u.data.length =
min(ie[1] + 2,
7446 current_ev = iwe_stream_add_point(
7455 iwe.u.data.length =
min(ie[1] + 2, 64);
7456 current_ev = iwe_stream_add_point(
7457 info, current_ev, end_buf,
7465 length -= 2 + ie[1];
7476 static int airo_get_scan(
struct net_device *dev,
7484 char *current_ev =
extra;
7495 current_ev = airo_translate_scan(dev, info, current_ev,
7520 static int airo_config_commit(
struct net_device *dev,
7532 disable_MAC(local, 1);
7537 readAPListRid(local, &APList_rid);
7538 readSsidRid(local, &SSID_rid);
7540 setup_card(local, dev->
dev_addr, 1 );
7543 disable_MAC(local, 1);
7544 writeSsidRid(local, &SSID_rid, 1);
7545 writeAPListRid(local, &APList_rid, 1);
7549 writeConfigRid(local, 0);
7550 enable_MAC(local, 0);
7552 airo_set_promisc(local);
7564 static const struct iw_priv_args airo_private_args[] = {
7646 .num_private =
ARRAY_SIZE(airo_private_handler),
7647 .num_private_args =
ARRAY_SIZE(airo_private_args),
7648 .standard = airo_handler,
7649 .private = airo_private_handler,
7650 .private_args = airo_private_args,
7651 .get_wireless_stats = airo_get_wireless_stats,
7714 rc = readrids(dev,&com);
7716 rc = writerids(dev,&com);
7718 rc = flashcard(dev,&com);
7741 static void airo_read_wireless_stats(
struct airo_info *local)
7754 readCapabilityRid(local, &cap_rid, 0);
7755 readStatusRid(local, &status_rid, 0);
7756 readStatsRid(local, &stats_rid,
RID_STATS, 0);
7764 local->
wstats.qual.level =
7765 airo_rssi_to_dbm(local->
rssi,
7768 local->
wstats.qual.qual =
7771 local->
wstats.qual.level =
7773 local->
wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid);
7779 local->
wstats.qual.noise = 0;
7806 airo_read_wireless_stats(local);
7820 unsigned short ridcode;
7821 unsigned char *iobuf;
7833 disable_MAC (ai, 1);
7834 writeConfigRid (ai, 1);
7869 PC4500_readrid(ai,ridcode,iobuf,
RIDSIZE, 1);
7893 unsigned char *iobuf;
7925 if (enable_MAC(ai, 1) != 0)
7985 if((*
writer)(ai, ridcode, iobuf,comp->
len,1)) {
8021 if(comp->
len !=
sizeof(
int))
8028 if(comp->
len !=
sizeof(
int))
8053 #define FLASH_COMMAND 0x7e7e
8061 static int cmdreset(
struct airo_info *ai) {
8085 static int setflashmode (
struct airo_info *ai) {
8112 static int flashpchar(
struct airo_info *ai,
int byte,
int dwelltime) {
8124 while ((IN4500 (ai,
SWS0) & 0x8000) && waittime > 0) {
8137 OUT4500(ai,
SWS0,byte);
8140 echo = IN4500(ai,
SWS1);
8141 }
while (dwelltime >= 0 && echo != byte);
8145 return (echo == byte) ? 0 : -
EIO;
8152 static int flashgchar(
struct airo_info *ai,
int matchbyte,
int dwelltime){
8154 unsigned char rbyte=0;
8157 rchar = IN4500(ai,
SWS1);
8159 if(dwelltime && !(0x8000 & rchar)){
8164 rbyte = 0xff & rchar;
8166 if( (rbyte == matchbyte) && (0x8000 & rchar) ){
8170 if( rbyte == 0x81 || rbyte == 0x82 || rbyte == 0x83 || rbyte == 0x1a || 0xffff == rchar)
8174 }
while(dwelltime > 0);
8183 static int flashputbuf(
struct airo_info *ai){
8193 for(nwords=0;nwords !=
FLASHSIZE / 2;nwords++){
8197 OUT4500(ai,
SWS0,0x8000);
8211 status = mpi_init_descriptors(ai);
8215 status = setup_card(ai, dev->
dev_addr, 1);
8219 ai->
fids[
i] = transmit_allocate