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) {