Lines Matching full:ai
1113 static int enable_MAC(struct airo_info *ai, int lock);
1114 static void disable_MAC(struct airo_info *ai, int lock);
1140 static void mpi_receive_802_3(struct airo_info *ai);
1141 static void mpi_receive_802_11(struct airo_info *ai);
1142 static int waitbusy(struct airo_info *ai);
1154 static void micinit(struct airo_info *ai);
1155 static int micsetup(struct airo_info *ai);
1156 static int encapsulate(struct airo_info *ai, etherHead *pPacket, MICBuffer *buffer, int len);
1157 static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
1162 static void airo_networks_free(struct airo_info *ai);
1258 static inline int bap_read(struct airo_info *ai, __le16 *pu16Dst, int bytelen, in bap_read() argument
1261 return ai->bap_read(ai, pu16Dst, bytelen, whichbap); in bap_read()
1269 static int cmdreset(struct airo_info *ai);
1270 static int setflashmode(struct airo_info *ai);
1271 static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime);
1272 static int flashputbuf(struct airo_info *ai);
1273 static int flashrestart(struct airo_info *ai, struct net_device *dev);
1297 static int RxSeqValid(struct airo_info *ai, miccntx *context, int mcast, u32 micSeq);
1304 static int flashpchar(struct airo_info *ai, int byte, int dwelltime);
1331 static void micinit(struct airo_info *ai) in micinit() argument
1335 clear_bit(JOB_MIC, &ai->jobs); in micinit()
1336 PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0); in micinit()
1337 up(&ai->sem); in micinit()
1339 ai->micstats.enabled = (le16_to_cpu(mic_rid.state) & 0x00FF) ? 1 : 0; in micinit()
1340 if (!ai->micstats.enabled) { in micinit()
1344 ai->mod[0].uCtx.valid = 0; in micinit()
1345 ai->mod[0].mCtx.valid = 0; in micinit()
1350 age_mic_context(&ai->mod[0].mCtx, &ai->mod[1].mCtx, in micinit()
1352 ai->tfm); in micinit()
1356 age_mic_context(&ai->mod[0].uCtx, &ai->mod[1].uCtx, in micinit()
1358 ai->tfm); in micinit()
1364 static int micsetup(struct airo_info *ai) in micsetup() argument
1368 if (ai->tfm == NULL) in micsetup()
1369 ai->tfm = crypto_alloc_sync_skcipher("ctr(aes)", 0, 0); in micsetup()
1371 if (IS_ERR(ai->tfm)) { in micsetup()
1372 airo_print_err(ai->dev->name, "failed to load transform for AES"); in micsetup()
1373 ai->tfm = NULL; in micsetup()
1378 memset(&ai->mod[i].mCtx, 0, sizeof(miccntx)); in micsetup()
1379 memset(&ai->mod[i].uCtx, 0, sizeof(miccntx)); in micsetup()
1402 static int encapsulate(struct airo_info *ai, etherHead *frame, MICBuffer *mic, int payLen) in encapsulate() argument
1409 if (test_bit(FLAG_ADHOC, &ai->flags) && (frame->da[0] & 0x1)) in encapsulate()
1410 context = &ai->mod[0].mCtx; in encapsulate()
1412 context = &ai->mod[0].uCtx; in encapsulate()
1458 static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 payLen) in decapsulate() argument
1468 if (!ai->micstats.enabled) { in decapsulate()
1471 ai->micstats.rxMICPlummed++; in decapsulate()
1482 ai->micstats.rxMICPlummed++; in decapsulate()
1493 ai->micstats.rxWrongSequence++; in decapsulate()
1500 context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx; in decapsulate()
1529 if (RxSeqValid(ai, context, mcast, micSEQ) == SUCCESS) { in decapsulate()
1530 ai->micstats.rxSuccess++; in decapsulate()
1539 case NOMICPLUMMED: ai->micstats.rxMICPlummed++; break; in decapsulate()
1540 case SEQUENCE: ai->micstats.rxWrongSequence++; break; in decapsulate()
1541 case INCORRECTMIC: ai->micstats.rxIncorrectMIC++; break; in decapsulate()
1562 static int RxSeqValid(struct airo_info *ai, miccntx *context, int mcast, u32 micSeq) in RxSeqValid() argument
1570 if (test_bit(FLAG_UPDATE_MULTI, &ai->flags)) { in RxSeqValid()
1571 clear_bit (FLAG_UPDATE_MULTI, &ai->flags); in RxSeqValid()
1575 } else if (test_bit(FLAG_UPDATE_UNI, &ai->flags)) { in RxSeqValid()
1576 clear_bit (FLAG_UPDATE_UNI, &ai->flags); in RxSeqValid()
1745 static int readBSSListRid(struct airo_info *ai, int first, in readBSSListRid() argument
1752 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; in readBSSListRid()
1755 if (down_interruptible(&ai->sem)) in readBSSListRid()
1757 ai->list_bss_task = current; in readBSSListRid()
1758 issuecommand(ai, &cmd, &rsp, true); in readBSSListRid()
1759 up(&ai->sem); in readBSSListRid()
1762 ai->list_bss_task = NULL; in readBSSListRid()
1764 return PC4500_readrid(ai, first ? ai->bssListFirst : ai->bssListNext, in readBSSListRid()
1765 list, ai->bssListRidLen, 1); in readBSSListRid()
1768 static int readWepKeyRid(struct airo_info *ai, WepKeyRid *wkr, int temp, int lock) in readWepKeyRid() argument
1770 return PC4500_readrid(ai, temp ? RID_WEP_TEMP : RID_WEP_PERM, in readWepKeyRid()
1774 static int writeWepKeyRid(struct airo_info *ai, WepKeyRid *wkr, int perm, int lock) in writeWepKeyRid() argument
1777 rc = PC4500_writerid(ai, RID_WEP_TEMP, wkr, sizeof(*wkr), lock); in writeWepKeyRid()
1779 airo_print_err(ai->dev->name, "WEP_TEMP set %x", rc); in writeWepKeyRid()
1781 rc = PC4500_writerid(ai, RID_WEP_PERM, wkr, sizeof(*wkr), lock); in writeWepKeyRid()
1783 airo_print_err(ai->dev->name, "WEP_PERM set %x", rc); in writeWepKeyRid()
1788 static int readSsidRid(struct airo_info*ai, SsidRid *ssidr) in readSsidRid() argument
1790 return PC4500_readrid(ai, RID_SSID, ssidr, sizeof(*ssidr), 1); in readSsidRid()
1793 static int writeSsidRid(struct airo_info*ai, SsidRid *pssidr, int lock) in writeSsidRid() argument
1795 return PC4500_writerid(ai, RID_SSID, pssidr, sizeof(*pssidr), lock); in writeSsidRid()
1798 static int readConfigRid(struct airo_info *ai, int lock) in readConfigRid() argument
1803 if (ai->config.len) in readConfigRid()
1806 rc = PC4500_readrid(ai, RID_ACTUALCONFIG, &cfg, sizeof(cfg), lock); in readConfigRid()
1810 ai->config = cfg; in readConfigRid()
1814 static inline void checkThrottle(struct airo_info *ai) in checkThrottle() argument
1818 if (ai->config.authType != AUTH_OPEN && maxencrypt) { in checkThrottle()
1820 if (ai->config.rates[i] > maxencrypt) { in checkThrottle()
1821 ai->config.rates[i] = 0; in checkThrottle()
1827 static int writeConfigRid(struct airo_info *ai, int lock) in writeConfigRid() argument
1831 if (!test_bit (FLAG_COMMIT, &ai->flags)) in writeConfigRid()
1834 clear_bit (FLAG_COMMIT, &ai->flags); in writeConfigRid()
1835 clear_bit (FLAG_RESET, &ai->flags); in writeConfigRid()
1836 checkThrottle(ai); in writeConfigRid()
1837 cfgr = ai->config; in writeConfigRid()
1840 set_bit(FLAG_ADHOC, &ai->flags); in writeConfigRid()
1842 clear_bit(FLAG_ADHOC, &ai->flags); in writeConfigRid()
1844 return PC4500_writerid(ai, RID_CONFIG, &cfgr, sizeof(cfgr), lock); in writeConfigRid()
1847 static int readStatusRid(struct airo_info *ai, StatusRid *statr, int lock) in readStatusRid() argument
1849 return PC4500_readrid(ai, RID_STATUS, statr, sizeof(*statr), lock); in readStatusRid()
1852 static int writeAPListRid(struct airo_info *ai, APListRid *aplr, int lock) in writeAPListRid() argument
1854 return PC4500_writerid(ai, RID_APLIST, aplr, sizeof(*aplr), lock); in writeAPListRid()
1857 static int readCapabilityRid(struct airo_info *ai, CapabilityRid *capr, int lock) in readCapabilityRid() argument
1859 return PC4500_readrid(ai, RID_CAPABILITIES, capr, sizeof(*capr), lock); in readCapabilityRid()
1862 static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock) in readStatsRid() argument
1864 return PC4500_readrid(ai, rid, sr, sizeof(*sr), lock); in readStatsRid()
1867 static void try_auto_wep(struct airo_info *ai) in try_auto_wep() argument
1869 if (auto_wep && !test_bit(FLAG_RADIO_DOWN, &ai->flags)) { in try_auto_wep()
1870 ai->expires = RUN_AT(3*HZ); in try_auto_wep()
1871 wake_up_interruptible(&ai->thr_wait); in try_auto_wep()
1877 struct airo_info *ai = dev->ml_priv; in airo_open() local
1880 if (test_bit(FLAG_FLASHING, &ai->flags)) in airo_open()
1887 if (test_bit(FLAG_COMMIT, &ai->flags)) { in airo_open()
1888 disable_MAC(ai, 1); in airo_open()
1889 writeConfigRid(ai, 1); in airo_open()
1892 if (ai->wifidev != dev) { in airo_open()
1893 clear_bit(JOB_DIE, &ai->jobs); in airo_open()
1894 ai->airo_thread_task = kthread_run(airo_thread, dev, "%s", in airo_open()
1896 if (IS_ERR(ai->airo_thread_task)) in airo_open()
1897 return (int)PTR_ERR(ai->airo_thread_task); in airo_open()
1905 set_bit(JOB_DIE, &ai->jobs); in airo_open()
1906 kthread_stop(ai->airo_thread_task); in airo_open()
1911 clear_bit(FLAG_RADIO_DOWN, &ai->flags); in airo_open()
1912 enable_interrupts(ai); in airo_open()
1914 try_auto_wep(ai); in airo_open()
1916 enable_MAC(ai, 1); in airo_open()
1927 struct airo_info *ai = dev->ml_priv; in mpi_start_xmit() local
1937 npacks = skb_queue_len (&ai->txq); in mpi_start_xmit()
1945 skb_queue_tail (&ai->txq, skb); in mpi_start_xmit()
1949 spin_lock_irqsave(&ai->aux_lock, flags); in mpi_start_xmit()
1950 skb_queue_tail (&ai->txq, skb); in mpi_start_xmit()
1951 pending = test_bit(FLAG_PENDING_XMIT, &ai->flags); in mpi_start_xmit()
1952 spin_unlock_irqrestore(&ai->aux_lock, flags); in mpi_start_xmit()
1956 set_bit(FLAG_PENDING_XMIT, &ai->flags); in mpi_start_xmit()
1975 struct airo_info *ai = dev->ml_priv; in mpi_send_packet() local
1980 if ((skb = skb_dequeue(&ai->txq)) == NULL) { in mpi_send_packet()
1991 ai->txfids[0].tx_desc.offset = 0; in mpi_send_packet()
1992 ai->txfids[0].tx_desc.valid = 1; in mpi_send_packet()
1993 ai->txfids[0].tx_desc.eoc = 1; in mpi_send_packet()
1994 ai->txfids[0].tx_desc.len =len+sizeof(WifiHdr); in mpi_send_packet()
2004 memcpy(ai->txfids[0].virtual_host_addr, in mpi_send_packet()
2007 payloadLen = (__le16 *)(ai->txfids[0].virtual_host_addr + in mpi_send_packet()
2009 sendbuf = ai->txfids[0].virtual_host_addr + in mpi_send_packet()
2016 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && in mpi_send_packet()
2020 if (encapsulate(ai, (etherHead *)buffer, &pMic, len - sizeof(etherHead)) != SUCCESS) in mpi_send_packet()
2024 ai->txfids[0].tx_desc.len += sizeof(pMic); in mpi_send_packet()
2041 memcpy_toio(ai->txfids[0].card_ram_off, in mpi_send_packet()
2042 &ai->txfids[0].tx_desc, sizeof(TxFid)); in mpi_send_packet()
2044 OUT4500(ai, EVACK, 8); in mpi_send_packet()
2050 static void get_tx_error(struct airo_info *ai, s32 fid) in get_tx_error() argument
2055 status = ((WifiCtlHdr *)ai->txfids[0].virtual_host_addr)->ctlhdr.status; in get_tx_error()
2057 if (bap_setup(ai, ai->fids[fid] & 0xffff, 4, BAP0) != SUCCESS) in get_tx_error()
2059 bap_read(ai, &status, 2, BAP0); in get_tx_error()
2062 ai->dev->stats.tx_aborted_errors++; in get_tx_error()
2064 ai->dev->stats.tx_heartbeat_errors++; in get_tx_error()
2068 ai->dev->stats.tx_carrier_errors++; in get_tx_error()
2083 bap_read(ai, (__le16 *) junk, 0x18, BAP0); in get_tx_error()
2097 wireless_send_event(ai->dev, IWEVTXDROP, &wrqu, NULL); in get_tx_error()
2254 struct airo_info *ai = dev->ml_priv; in airo_read_stats() local
2258 clear_bit(JOB_STATS, &ai->jobs); in airo_read_stats()
2259 if (ai->power.event) { in airo_read_stats()
2260 up(&ai->sem); in airo_read_stats()
2263 readStatsRid(ai, &stats_rid, RID_STATS, 0); in airo_read_stats()
2264 up(&ai->sem); in airo_read_stats()
2298 static void airo_set_promisc(struct airo_info *ai, bool may_sleep) in airo_set_promisc() argument
2305 clear_bit(JOB_PROMISC, &ai->jobs); in airo_set_promisc()
2306 cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; in airo_set_promisc()
2307 issuecommand(ai, &cmd, &rsp, may_sleep); in airo_set_promisc()
2308 up(&ai->sem); in airo_set_promisc()
2313 struct airo_info *ai = dev->ml_priv; in airo_set_multicast_list() local
2315 if ((dev->flags ^ ai->flags) & IFF_PROMISC) { in airo_set_multicast_list()
2316 change_bit(FLAG_PROMISC, &ai->flags); in airo_set_multicast_list()
2317 if (down_trylock(&ai->sem) != 0) { in airo_set_multicast_list()
2318 set_bit(JOB_PROMISC, &ai->jobs); in airo_set_multicast_list()
2319 wake_up_interruptible(&ai->thr_wait); in airo_set_multicast_list()
2321 airo_set_promisc(ai, false); in airo_set_multicast_list()
2331 struct airo_info *ai = dev->ml_priv; in airo_set_mac_address() local
2334 readConfigRid(ai, 1); in airo_set_mac_address()
2335 memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); in airo_set_mac_address()
2336 set_bit (FLAG_COMMIT, &ai->flags); in airo_set_mac_address()
2337 disable_MAC(ai, 1); in airo_set_mac_address()
2338 writeConfigRid (ai, 1); in airo_set_mac_address()
2339 enable_MAC(ai, 1); in airo_set_mac_address()
2340 dev_addr_set(ai->dev, addr->sa_data); in airo_set_mac_address()
2341 if (ai->wifidev) in airo_set_mac_address()
2342 dev_addr_set(ai->wifidev, addr->sa_data); in airo_set_mac_address()
2348 static void add_airo_dev(struct airo_info *ai) in add_airo_dev() argument
2352 if (!ai->pci) in add_airo_dev()
2353 list_add_tail(&ai->dev_list, &airo_devices); in add_airo_dev()
2356 static void del_airo_dev(struct airo_info *ai) in del_airo_dev() argument
2358 if (!ai->pci) in del_airo_dev()
2359 list_del(&ai->dev_list); in del_airo_dev()
2364 struct airo_info *ai = dev->ml_priv; in airo_close() local
2368 if (ai->wifidev != dev) { in airo_close()
2375 set_bit(FLAG_RADIO_DOWN, &ai->flags); in airo_close()
2376 disable_MAC(ai, 1); in airo_close()
2378 disable_interrupts(ai); in airo_close()
2382 set_bit(JOB_DIE, &ai->jobs); in airo_close()
2383 kthread_stop(ai->airo_thread_task); in airo_close()
2390 struct airo_info *ai = dev->ml_priv; in stop_airo_card() local
2392 set_bit(FLAG_RADIO_DOWN, &ai->flags); in stop_airo_card()
2393 disable_MAC(ai, 1); in stop_airo_card()
2394 disable_interrupts(ai); in stop_airo_card()
2395 takedown_proc_entry(dev, ai); in stop_airo_card()
2396 if (test_bit(FLAG_REGISTERED, &ai->flags)) { in stop_airo_card()
2398 if (ai->wifidev) { in stop_airo_card()
2399 unregister_netdev(ai->wifidev); in stop_airo_card()
2400 free_netdev(ai->wifidev); in stop_airo_card()
2401 ai->wifidev = NULL; in stop_airo_card()
2403 clear_bit(FLAG_REGISTERED, &ai->flags); in stop_airo_card()
2408 if (test_bit(FLAG_MPI, &ai->flags) && !skb_queue_empty(&ai->txq)) { in stop_airo_card()
2410 for (;(skb = skb_dequeue(&ai->txq));) in stop_airo_card()
2414 airo_networks_free (ai); in stop_airo_card()
2416 kfree(ai->flash); in stop_airo_card()
2417 kfree(ai->rssi); in stop_airo_card()
2418 kfree(ai->SSID); in stop_airo_card()
2422 if (test_bit(FLAG_MPI, &ai->flags)) { in stop_airo_card()
2423 if (ai->pci) in stop_airo_card()
2424 mpi_unmap_card(ai->pci); in stop_airo_card()
2425 if (ai->pcimem) in stop_airo_card()
2426 iounmap(ai->pcimem); in stop_airo_card()
2427 if (ai->pciaux) in stop_airo_card()
2428 iounmap(ai->pciaux); in stop_airo_card()
2429 dma_free_coherent(&ai->pci->dev, PCI_SHARED_LEN, in stop_airo_card()
2430 ai->shared, ai->shared_dma); in stop_airo_card()
2433 crypto_free_sync_skcipher(ai->tfm); in stop_airo_card()
2434 del_airo_dev(ai); in stop_airo_card()
2464 static int mpi_init_descriptors (struct airo_info *ai) in mpi_init_descriptors() argument
2472 netif_stop_queue(ai->dev); in mpi_init_descriptors()
2479 cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); in mpi_init_descriptors()
2481 rc = issuecommand(ai, &cmd, &rsp, true); in mpi_init_descriptors()
2483 airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); in mpi_init_descriptors()
2488 memcpy_toio(ai->rxfids[i].card_ram_off, in mpi_init_descriptors()
2489 &ai->rxfids[i].rx_desc, sizeof(RxFid)); in mpi_init_descriptors()
2499 cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux); in mpi_init_descriptors()
2503 ai->txfids[i].tx_desc.valid = 1; in mpi_init_descriptors()
2504 memcpy_toio(ai->txfids[i].card_ram_off, in mpi_init_descriptors()
2505 &ai->txfids[i].tx_desc, sizeof(TxFid)); in mpi_init_descriptors()
2507 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ in mpi_init_descriptors()
2509 rc = issuecommand(ai, &cmd, &rsp, true); in mpi_init_descriptors()
2511 airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); in mpi_init_descriptors()
2521 cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); in mpi_init_descriptors()
2523 rc = issuecommand(ai, &cmd, &rsp, true); in mpi_init_descriptors()
2525 airo_print_err(ai->dev->name, "Couldn't allocate RID"); in mpi_init_descriptors()
2529 memcpy_toio(ai->config_desc.card_ram_off, in mpi_init_descriptors()
2530 &ai->config_desc.rid_desc, sizeof(Rid)); in mpi_init_descriptors()
2541 static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) in mpi_map_card() argument
2566 ai->pcimem = ioremap(mem_start, mem_len); in mpi_map_card()
2567 if (!ai->pcimem) { in mpi_map_card()
2572 ai->pciaux = ioremap(aux_start, aux_len); in mpi_map_card()
2573 if (!ai->pciaux) { in mpi_map_card()
2580 ai->shared = dma_alloc_coherent(&pci->dev, PCI_SHARED_LEN, in mpi_map_card()
2581 &ai->shared_dma, GFP_KERNEL); in mpi_map_card()
2582 if (!ai->shared) { in mpi_map_card()
2591 busaddroff = ai->shared_dma; in mpi_map_card()
2592 pciaddroff = ai->pciaux + AUX_OFFSET; in mpi_map_card()
2593 vpackoff = ai->shared; in mpi_map_card()
2597 ai->rxfids[i].pending = 0; in mpi_map_card()
2598 ai->rxfids[i].card_ram_off = pciaddroff; in mpi_map_card()
2599 ai->rxfids[i].virtual_host_addr = vpackoff; in mpi_map_card()
2600 ai->rxfids[i].rx_desc.host_addr = busaddroff; in mpi_map_card()
2601 ai->rxfids[i].rx_desc.valid = 1; in mpi_map_card()
2602 ai->rxfids[i].rx_desc.len = PKTSIZE; in mpi_map_card()
2603 ai->rxfids[i].rx_desc.rdy = 0; in mpi_map_card()
2612 ai->txfids[i].card_ram_off = pciaddroff; in mpi_map_card()
2613 ai->txfids[i].virtual_host_addr = vpackoff; in mpi_map_card()
2614 ai->txfids[i].tx_desc.valid = 1; in mpi_map_card()
2615 ai->txfids[i].tx_desc.host_addr = busaddroff; in mpi_map_card()
2616 memcpy(ai->txfids[i].virtual_host_addr, in mpi_map_card()
2623 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ in mpi_map_card()
2626 ai->config_desc.card_ram_off = pciaddroff; in mpi_map_card()
2627 ai->config_desc.virtual_host_addr = vpackoff; in mpi_map_card()
2628 ai->config_desc.rid_desc.host_addr = busaddroff; in mpi_map_card()
2629 ai->ridbus = busaddroff; in mpi_map_card()
2630 ai->config_desc.rid_desc.rid = 0; in mpi_map_card()
2631 ai->config_desc.rid_desc.len = RIDSIZE; in mpi_map_card()
2632 ai->config_desc.rid_desc.valid = 1; in mpi_map_card()
2638 if (mpi_init_descriptors (ai) != SUCCESS) in mpi_map_card()
2643 dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared, in mpi_map_card()
2644 ai->shared_dma); in mpi_map_card()
2646 iounmap(ai->pciaux); in mpi_map_card()
2648 iounmap(ai->pcimem); in mpi_map_card()
2689 static struct net_device *init_wifidev(struct airo_info *ai, in init_wifidev() argument
2713 struct airo_info *ai = dev->ml_priv; in reset_card() local
2715 if (lock && down_interruptible(&ai->sem)) in reset_card()
2717 waitbusy (ai); in reset_card()
2718 OUT4500(ai, COMMAND, CMD_SOFTRESET); in reset_card()
2720 waitbusy (ai); in reset_card()
2723 up(&ai->sem); in reset_card()
2728 static int airo_networks_allocate(struct airo_info *ai) in airo_networks_allocate() argument
2730 if (ai->networks) in airo_networks_allocate()
2733 ai->networks = kcalloc(AIRO_MAX_NETWORK_COUNT, sizeof(BSSListElement), in airo_networks_allocate()
2735 if (!ai->networks) { in airo_networks_allocate()
2743 static void airo_networks_free(struct airo_info *ai) in airo_networks_free() argument
2745 kfree(ai->networks); in airo_networks_free()
2746 ai->networks = NULL; in airo_networks_free()
2749 static void airo_networks_initialize(struct airo_info *ai) in airo_networks_initialize() argument
2753 INIT_LIST_HEAD(&ai->network_free_list); in airo_networks_initialize()
2754 INIT_LIST_HEAD(&ai->network_list); in airo_networks_initialize()
2756 list_add_tail(&ai->networks[i].list, in airo_networks_initialize()
2757 &ai->network_free_list); in airo_networks_initialize()
2788 struct airo_info *ai; in _init_airo_card() local
2793 dev = alloc_netdev(sizeof(*ai), "", NET_NAME_UNKNOWN, ether_setup); in _init_airo_card()
2799 ai = dev->ml_priv = netdev_priv(dev); in _init_airo_card()
2800 ai->wifidev = NULL; in _init_airo_card()
2801 ai->flags = 1 << FLAG_RADIO_DOWN; in _init_airo_card()
2802 ai->jobs = 0; in _init_airo_card()
2803 ai->dev = dev; in _init_airo_card()
2806 set_bit(FLAG_MPI, &ai->flags); in _init_airo_card()
2808 spin_lock_init(&ai->aux_lock); in _init_airo_card()
2809 sema_init(&ai->sem, 1); in _init_airo_card()
2810 ai->config.len = 0; in _init_airo_card()
2811 ai->pci = pci; in _init_airo_card()
2812 init_waitqueue_head (&ai->thr_wait); in _init_airo_card()
2813 ai->tfm = NULL; in _init_airo_card()
2814 add_airo_dev(ai); in _init_airo_card()
2815 ai->APList.len = cpu_to_le16(sizeof(struct APListRid)); in _init_airo_card()
2817 if (airo_networks_allocate (ai)) in _init_airo_card()
2819 airo_networks_initialize (ai); in _init_airo_card()
2821 skb_queue_head_init (&ai->txq); in _init_airo_card()
2824 if (test_bit(FLAG_MPI,&ai->flags)) in _init_airo_card()
2829 ai->wireless_data.spy_data = &ai->spy_data; in _init_airo_card()
2830 dev->wireless_data = &ai->wireless_data; in _init_airo_card()
2849 if (test_bit(FLAG_MPI,&ai->flags)) { in _init_airo_card()
2850 if (mpi_map_card(ai, pci)) { in _init_airo_card()
2857 if (setup_card(ai, dev, 1) != SUCCESS) { in _init_airo_card()
2862 } else if (!test_bit(FLAG_MPI,&ai->flags)) { in _init_airo_card()
2863 ai->bap_read = fast_bap_read; in _init_airo_card()
2864 set_bit(FLAG_FLASHING, &ai->flags); in _init_airo_card()
2873 ai->wifidev = init_wifidev(ai, dev); in _init_airo_card()
2874 if (!ai->wifidev) in _init_airo_card()
2877 rc = readCapabilityRid(ai, &cap_rid, 1); in _init_airo_card()
2883 ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0; in _init_airo_card()
2884 ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0; in _init_airo_card()
2896 airo_print_info(ai->dev->name, "WPA supported."); in _init_airo_card()
2898 set_bit(FLAG_WPA_CAPABLE, &ai->flags); in _init_airo_card()
2899 ai->bssListFirst = RID_WPA_BSSLISTFIRST; in _init_airo_card()
2900 ai->bssListNext = RID_WPA_BSSLISTNEXT; in _init_airo_card()
2901 ai->bssListRidLen = sizeof(BSSListRid); in _init_airo_card()
2903 airo_print_info(ai->dev->name, "WPA unsupported with firmware " in _init_airo_card()
2906 ai->bssListFirst = RID_BSSLISTFIRST; in _init_airo_card()
2907 ai->bssListNext = RID_BSSLISTNEXT; in _init_airo_card()
2908 ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); in _init_airo_card()
2911 set_bit(FLAG_REGISTERED,&ai->flags); in _init_airo_card()
2915 if (probe && !test_bit(FLAG_MPI,&ai->flags)) in _init_airo_card()
2917 ai->fids[i] = transmit_allocate(ai, AIRO_DEF_MTU, i>=MAX_FIDS/2); in _init_airo_card()
2925 unregister_netdev(ai->wifidev); in _init_airo_card()
2926 free_netdev(ai->wifidev); in _init_airo_card()
2930 if (test_bit(FLAG_MPI,&ai->flags) && pci) { in _init_airo_card()
2931 dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared, in _init_airo_card()
2932 ai->shared_dma); in _init_airo_card()
2933 iounmap(ai->pciaux); in _init_airo_card()
2934 iounmap(ai->pcimem); in _init_airo_card()
2935 mpi_unmap_card(ai->pci); in _init_airo_card()
2941 airo_networks_free(ai); in _init_airo_card()
2943 del_airo_dev(ai); in _init_airo_card()
2956 static int waitbusy (struct airo_info *ai) in waitbusy() argument
2959 while ((IN4500(ai, COMMAND) & COMMAND_BUSY) && (delay < 10000)) { in waitbusy()
2962 OUT4500(ai, EVACK, EV_CLEARCOMMANDBUSY); in waitbusy()
2970 struct airo_info *ai = dev->ml_priv; in reset_airo_card() local
2975 if (setup_card(ai, dev, 1) != SUCCESS) { in reset_airo_card()
2981 if (!test_bit(FLAG_MPI,&ai->flags)) in reset_airo_card()
2983 ai->fids[i] = transmit_allocate (ai, AIRO_DEF_MTU, i>=MAX_FIDS/2); in reset_airo_card()
2985 enable_interrupts(ai); in reset_airo_card()
2994 struct airo_info *ai = dev->ml_priv; in airo_send_event() local
2998 clear_bit(JOB_EVENT, &ai->jobs); in airo_send_event()
2999 PC4500_readrid(ai, RID_STATUS, &status_rid, sizeof(status_rid), 0); in airo_send_event()
3000 up(&ai->sem); in airo_send_event()
3010 static void airo_process_scan_results (struct airo_info *ai) in airo_process_scan_results() argument
3019 list_for_each_entry_safe (loop_net, tmp_net, &ai->network_list, list) { in airo_process_scan_results()
3020 list_move_tail (&loop_net->list, &ai->network_free_list); in airo_process_scan_results()
3026 rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0); in airo_process_scan_results()
3036 if (!list_empty(&ai->network_free_list)) { in airo_process_scan_results()
3037 tmp_net = list_entry(ai->network_free_list.next, in airo_process_scan_results()
3039 list_del(ai->network_free_list.next); in airo_process_scan_results()
3044 list_add_tail(&tmp_net->list, &ai->network_list); in airo_process_scan_results()
3049 rc = PC4500_readrid(ai, ai->bssListNext, in airo_process_scan_results()
3050 &bss, ai->bssListRidLen, 0); in airo_process_scan_results()
3055 disable_MAC(ai, 2); in airo_process_scan_results()
3056 writeAPListRid(ai, &ai->APList, 0); in airo_process_scan_results()
3057 enable_MAC(ai, 0); in airo_process_scan_results()
3059 ai->scan_timeout = 0; in airo_process_scan_results()
3060 clear_bit(JOB_SCAN_RESULTS, &ai->jobs); in airo_process_scan_results()
3061 up(&ai->sem); in airo_process_scan_results()
3072 wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL); in airo_process_scan_results()
3078 struct airo_info *ai = dev->ml_priv; in airo_thread() local
3086 if (test_bit(JOB_DIE, &ai->jobs)) in airo_thread()
3089 if (ai->jobs) { in airo_thread()
3090 locked = down_interruptible(&ai->sem); in airo_thread()
3095 add_wait_queue(&ai->thr_wait, &wait); in airo_thread()
3098 if (ai->jobs) in airo_thread()
3100 if (ai->expires || ai->scan_timeout) { in airo_thread()
3101 if (ai->scan_timeout && in airo_thread()
3102 time_after_eq(jiffies, ai->scan_timeout)) { in airo_thread()
3103 set_bit(JOB_SCAN_RESULTS, &ai->jobs); in airo_thread()
3105 } else if (ai->expires && in airo_thread()
3106 time_after_eq(jiffies, ai->expires)) { in airo_thread()
3107 set_bit(JOB_AUTOWEP, &ai->jobs); in airo_thread()
3113 if (!ai->expires || !ai->scan_timeout) { in airo_thread()
3114 wake_at = max(ai->expires, in airo_thread()
3115 ai->scan_timeout); in airo_thread()
3117 wake_at = min(ai->expires, in airo_thread()
3118 ai->scan_timeout); in airo_thread()
3131 remove_wait_queue(&ai->thr_wait, &wait); in airo_thread()
3138 if (test_bit(JOB_DIE, &ai->jobs)) { in airo_thread()
3139 up(&ai->sem); in airo_thread()
3143 if (ai->power.event || test_bit(FLAG_FLASHING, &ai->flags)) { in airo_thread()
3144 up(&ai->sem); in airo_thread()
3148 if (test_bit(JOB_XMIT, &ai->jobs)) in airo_thread()
3150 else if (test_bit(JOB_XMIT11, &ai->jobs)) in airo_thread()
3152 else if (test_bit(JOB_STATS, &ai->jobs)) in airo_thread()
3154 else if (test_bit(JOB_PROMISC, &ai->jobs)) in airo_thread()
3155 airo_set_promisc(ai, true); in airo_thread()
3156 else if (test_bit(JOB_MIC, &ai->jobs)) in airo_thread()
3157 micinit(ai); in airo_thread()
3158 else if (test_bit(JOB_EVENT, &ai->jobs)) in airo_thread()
3160 else if (test_bit(JOB_AUTOWEP, &ai->jobs)) in airo_thread()
3162 else if (test_bit(JOB_SCAN_RESULTS, &ai->jobs)) in airo_thread()
3163 airo_process_scan_results(ai); in airo_thread()
3165 up(&ai->sem); in airo_thread()
3186 static void airo_handle_cisco_mic(struct airo_info *ai) in airo_handle_cisco_mic() argument
3188 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags)) { in airo_handle_cisco_mic()
3189 set_bit(JOB_MIC, &ai->jobs); in airo_handle_cisco_mic()
3190 wake_up_interruptible(&ai->thr_wait); in airo_handle_cisco_mic()
3255 static void airo_handle_link(struct airo_info *ai) in airo_handle_link() argument
3262 status = le16_to_cpu(IN4500(ai, LINKSTAT)); in airo_handle_link()
3263 OUT4500(ai, EVACK, EV_LINK); in airo_handle_link()
3265 if ((status == STAT_FORCELOSS) && (ai->scan_timeout > 0)) in airo_handle_link()
3268 airo_print_status(ai->dev->name, status); in airo_handle_link()
3272 ai->expires = 0; in airo_handle_link()
3273 if (ai->list_bss_task) in airo_handle_link()
3274 wake_up_process(ai->list_bss_task); in airo_handle_link()
3275 set_bit(FLAG_UPDATE_UNI, &ai->flags); in airo_handle_link()
3276 set_bit(FLAG_UPDATE_MULTI, &ai->flags); in airo_handle_link()
3278 set_bit(JOB_EVENT, &ai->jobs); in airo_handle_link()
3279 wake_up_interruptible(&ai->thr_wait); in airo_handle_link()
3281 netif_carrier_on(ai->dev); in airo_handle_link()
3283 if (auto_wep && !ai->expires) { in airo_handle_link()
3284 ai->expires = RUN_AT(3*HZ); in airo_handle_link()
3285 wake_up_interruptible(&ai->thr_wait); in airo_handle_link()
3291 wireless_send_event(ai->dev, SIOCGIWAP, &wrqu, NULL); in airo_handle_link()
3292 netif_carrier_off(ai->dev); in airo_handle_link()
3294 netif_carrier_off(ai->dev); in airo_handle_link()
3298 static void airo_handle_rx(struct airo_info *ai) in airo_handle_rx() argument
3306 if (test_bit(FLAG_MPI, &ai->flags)) { in airo_handle_rx()
3307 if (test_bit(FLAG_802_11, &ai->flags)) in airo_handle_rx()
3308 mpi_receive_802_11(ai); in airo_handle_rx()
3310 mpi_receive_802_3(ai); in airo_handle_rx()
3311 OUT4500(ai, EVACK, EV_RX); in airo_handle_rx()
3315 fid = IN4500(ai, RXFID); in airo_handle_rx()
3318 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3319 bap_setup (ai, fid, 4, BAP0); in airo_handle_rx()
3320 bap_read (ai, (__le16*)&hdr, sizeof(hdr), BAP0); in airo_handle_rx()
3324 if (ai->wifidev == NULL) in airo_handle_rx()
3327 bap_setup(ai, fid, 0x36, BAP0); in airo_handle_rx()
3328 bap_read(ai, &hdr.len, 2, BAP0); in airo_handle_rx()
3333 airo_print_err(ai->dev->name, "Bad size %d", len); in airo_handle_rx()
3339 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3340 bap_read(ai, &fc, sizeof (fc), BAP0); in airo_handle_rx()
3347 ai->dev->stats.rx_dropped++; in airo_handle_rx()
3353 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3355 bap_read(ai, buffer + 1, hdrlen - 2, BAP0); in airo_handle_rx()
3357 bap_read(ai, tmpbuf, 6, BAP0); in airo_handle_rx()
3359 bap_read(ai, &v, sizeof(v), BAP0); in airo_handle_rx()
3363 bap_read(ai, tmpbuf, gap, BAP0); in airo_handle_rx()
3365 airo_print_err(ai->dev->name, "gaplen too " in airo_handle_rx()
3369 bap_read(ai, buffer + hdrlen/2, len, BAP0); in airo_handle_rx()
3373 bap_read(ai, buffer, ETH_ALEN * 2, BAP0); in airo_handle_rx()
3374 if (ai->micstats.enabled) { in airo_handle_rx()
3375 bap_read(ai, (__le16 *) &micbuf, sizeof (micbuf), BAP0); in airo_handle_rx()
3377 bap_setup(ai, fid, 0x44, BAP0); in airo_handle_rx()
3389 bap_read(ai, buffer + ETH_ALEN, len, BAP0); in airo_handle_rx()
3390 if (decapsulate(ai, &micbuf, (etherHead*) buffer, len)) in airo_handle_rx()
3397 if (success && (ai->spy_data.spy_number > 0)) { in airo_handle_rx()
3402 if (!test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3404 bap_setup(ai, fid, 8, BAP0); in airo_handle_rx()
3405 bap_read(ai, (__le16 *) hdr.rssi, 2, BAP0); in airo_handle_rx()
3409 if (ai->rssi) in airo_handle_rx()
3410 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; in airo_handle_rx()
3413 wstats.noise = ai->wstats.qual.noise; in airo_handle_rx()
3418 wireless_spy_update(ai->dev, sa, &wstats); in airo_handle_rx()
3423 OUT4500(ai, EVACK, EV_RX); in airo_handle_rx()
3426 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3429 skb->dev = ai->wifidev; in airo_handle_rx()
3432 skb->protocol = eth_type_trans(skb, ai->dev); in airo_handle_rx()
3439 static void airo_handle_tx(struct airo_info *ai, u16 status) in airo_handle_tx() argument
3444 if (test_bit(FLAG_MPI, &ai->flags)) { in airo_handle_tx()
3448 get_tx_error(ai, -1); in airo_handle_tx()
3450 spin_lock_irqsave(&ai->aux_lock, flags); in airo_handle_tx()
3451 if (!skb_queue_empty(&ai->txq)) { in airo_handle_tx()
3452 spin_unlock_irqrestore(&ai->aux_lock, flags); in airo_handle_tx()
3453 mpi_send_packet(ai->dev); in airo_handle_tx()
3455 clear_bit(FLAG_PENDING_XMIT, &ai->flags); in airo_handle_tx()
3456 spin_unlock_irqrestore(&ai->aux_lock, flags); in airo_handle_tx()
3457 netif_wake_queue(ai->dev); in airo_handle_tx()
3459 OUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC)); in airo_handle_tx()
3463 fid = IN4500(ai, TXCOMPLFID); in airo_handle_tx()
3466 if ((ai->fids[i] & 0xffff) == fid) in airo_handle_tx()
3472 get_tx_error(ai, index); in airo_handle_tx()
3474 OUT4500(ai, EVACK, status & (EV_TX | EV_TXEXC)); in airo_handle_tx()
3477 ai->fids[index] &= 0xffff; in airo_handle_tx()
3479 if (!test_bit(FLAG_PENDING_XMIT, &ai->flags)) in airo_handle_tx()
3480 netif_wake_queue(ai->dev); in airo_handle_tx()
3482 if (!test_bit(FLAG_PENDING_XMIT11, &ai->flags)) in airo_handle_tx()
3483 netif_wake_queue(ai->wifidev); in airo_handle_tx()
3486 OUT4500(ai, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC)); in airo_handle_tx()
3487 airo_print_err(ai->dev->name, "Unallocated FID was used to xmit"); in airo_handle_tx()
3495 struct airo_info *ai = dev->ml_priv; in airo_interrupt() local
3502 status = IN4500(ai, EVSTAT); in airo_interrupt()
3509 OUT4500(ai, EVACK, EV_AWAKE); in airo_interrupt()
3510 OUT4500(ai, EVACK, EV_AWAKE); in airo_interrupt()
3514 savedInterrupts = IN4500(ai, EVINTEN); in airo_interrupt()
3515 OUT4500(ai, EVINTEN, 0); in airo_interrupt()
3519 OUT4500(ai, EVACK, EV_MIC); in airo_interrupt()
3520 airo_handle_cisco_mic(ai); in airo_interrupt()
3525 airo_handle_link(ai); in airo_interrupt()
3530 airo_handle_rx(ai); in airo_interrupt()
3534 airo_handle_tx(ai, status); in airo_interrupt()
3537 airo_print_warn(ai->dev->name, "Got weird status %x", in airo_interrupt()
3543 OUT4500(ai, EVINTEN, savedInterrupts); in airo_interrupt()
3557 static void OUT4500(struct airo_info *ai, u16 reg, u16 val) in OUT4500() argument
3559 if (test_bit(FLAG_MPI,&ai->flags)) in OUT4500()
3562 outw(val, ai->dev->base_addr + reg); in OUT4500()
3564 outb(val & 0xff, ai->dev->base_addr + reg); in OUT4500()
3565 outb(val >> 8, ai->dev->base_addr + reg + 1); in OUT4500()
3569 static u16 IN4500(struct airo_info *ai, u16 reg) in IN4500() argument
3573 if (test_bit(FLAG_MPI,&ai->flags)) in IN4500()
3576 rc = inw(ai->dev->base_addr + reg); in IN4500()
3578 rc = inb(ai->dev->base_addr + reg); in IN4500()
3579 rc += ((int)inb(ai->dev->base_addr + reg + 1)) << 8; in IN4500()
3584 static int enable_MAC(struct airo_info *ai, int lock) in enable_MAC() argument
3596 if (ai->flags & FLAG_RADIO_MASK) return SUCCESS; in enable_MAC()
3598 if (lock && down_interruptible(&ai->sem)) in enable_MAC()
3601 if (!test_bit(FLAG_ENABLED, &ai->flags)) { in enable_MAC()
3604 rc = issuecommand(ai, &cmd, &rsp, true); in enable_MAC()
3606 set_bit(FLAG_ENABLED, &ai->flags); in enable_MAC()
3611 up(&ai->sem); in enable_MAC()
3614 airo_print_err(ai->dev->name, "Cannot enable MAC"); in enable_MAC()
3616 airo_print_err(ai->dev->name, "Bad MAC enable reason=%x, " in enable_MAC()
3623 static void disable_MAC(struct airo_info *ai, int lock) in disable_MAC() argument
3628 if (lock == 1 && down_interruptible(&ai->sem)) in disable_MAC()
3631 if (test_bit(FLAG_ENABLED, &ai->flags)) { in disable_MAC()
3633 netif_carrier_off(ai->dev); in disable_MAC()
3636 issuecommand(ai, &cmd, &rsp, true); in disable_MAC()
3637 clear_bit(FLAG_ENABLED, &ai->flags); in disable_MAC()
3640 up(&ai->sem); in disable_MAC()
3643 static void enable_interrupts(struct airo_info *ai) in enable_interrupts() argument
3646 OUT4500(ai, EVINTEN, STATUS_INTS); in enable_interrupts()
3649 static void disable_interrupts(struct airo_info *ai) in disable_interrupts() argument
3651 OUT4500(ai, EVINTEN, 0); in disable_interrupts()
3654 static void mpi_receive_802_3(struct airo_info *ai) in mpi_receive_802_3() argument
3663 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); in mpi_receive_802_3()
3672 ai->dev->stats.rx_dropped++; in mpi_receive_802_3()
3676 memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2); in mpi_receive_802_3()
3677 if (ai->micstats.enabled) { in mpi_receive_802_3()
3679 ai->rxfids[0].virtual_host_addr + ETH_ALEN * 2, in mpi_receive_802_3()
3690 ai->rxfids[0].virtual_host_addr + ETH_ALEN * 2 + off, in mpi_receive_802_3()
3692 if (decapsulate (ai, &micbuf, (etherHead*)buffer, len - off - ETH_ALEN * 2)) { in mpi_receive_802_3()
3698 if (ai->spy_data.spy_number > 0) { in mpi_receive_802_3()
3707 wireless_spy_update(ai->dev, sa, &wstats); in mpi_receive_802_3()
3712 skb->protocol = eth_type_trans(skb, ai->dev); in mpi_receive_802_3()
3720 memcpy_toio(ai->rxfids[0].card_ram_off, &rxd, sizeof(rxd)); in mpi_receive_802_3()
3724 static void mpi_receive_802_11(struct airo_info *ai) in mpi_receive_802_11() argument
3733 char *ptr = ai->rxfids[0].virtual_host_addr + 4; in mpi_receive_802_11()
3735 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); in mpi_receive_802_11()
3741 if (ai->wifidev == NULL) in mpi_receive_802_11()
3745 airo_print_err(ai->dev->name, "Bad size %d", len); in mpi_receive_802_11()
3756 ai->dev->stats.rx_dropped++; in mpi_receive_802_11()
3770 airo_print_err(ai->dev->name, in mpi_receive_802_11()
3776 if (ai->spy_data.spy_number > 0) { in mpi_receive_802_11()
3782 if (ai->rssi) in mpi_receive_802_11()
3783 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; in mpi_receive_802_11()
3786 wstats.noise = ai->wstats.qual.noise; in mpi_receive_802_11()
3791 wireless_spy_update(ai->dev, sa, &wstats); in mpi_receive_802_11()
3796 skb->dev = ai->wifidev; in mpi_receive_802_11()
3806 memcpy_toio(ai->rxfids[0].card_ram_off, &rxd, sizeof(rxd)); in mpi_receive_802_11()
3820 static int noinline_for_stack airo_readconfig(struct airo_info *ai, in airo_readconfig() argument
3830 kfree(ai->SSID); in airo_readconfig()
3831 ai->SSID = NULL; in airo_readconfig()
3833 status = readConfigRid(ai, lock); in airo_readconfig()
3836 status = readCapabilityRid(ai, &cap_rid, lock); in airo_readconfig()
3839 status = PC4500_readrid(ai, RID_RSSI, &rssi_rid, sizeof(rssi_rid), lock); in airo_readconfig()
3841 if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) in airo_readconfig()
3842 memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ in airo_readconfig()
3845 kfree(ai->rssi); in airo_readconfig()
3846 ai->rssi = NULL; in airo_readconfig()
3848 ai->config.rmode |= RXMODE_NORMALIZED_RSSI; in airo_readconfig()
3850 airo_print_warn(ai->dev->name, "unknown received signal " in airo_readconfig()
3853 ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS; in airo_readconfig()
3854 set_auth_type(ai, AUTH_OPEN); in airo_readconfig()
3855 ai->config.modulation = MOD_CCK; in airo_readconfig()
3859 micsetup(ai) == SUCCESS) { in airo_readconfig()
3860 ai->config.opmode |= MODE_MIC; in airo_readconfig()
3861 set_bit(FLAG_MIC_CAPABLE, &ai->flags); in airo_readconfig()
3865 eth_hw_addr_set(dev, ai->config.macAddr); in airo_readconfig()
3870 memset(ai->config.rates, 0, sizeof(ai->config.rates)); in airo_readconfig()
3872 ai->config.rates[i] = rates[i]; in airo_readconfig()
3875 set_bit (FLAG_COMMIT, &ai->flags); in airo_readconfig()
3881 static u16 setup_card(struct airo_info *ai, struct net_device *dev, int lock) in setup_card() argument
3892 kfree (ai->flash); in setup_card()
3893 ai->flash = NULL; in setup_card()
3898 if (lock && down_interruptible(&ai->sem)) in setup_card()
3900 if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { in setup_card()
3902 up(&ai->sem); in setup_card()
3905 disable_MAC(ai, 0); in setup_card()
3908 if (!test_bit(FLAG_MPI,&ai->flags)) { in setup_card()
3910 if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { in setup_card()
3912 up(&ai->sem); in setup_card()
3913 airo_print_err(ai->dev->name, "Error checking for AUX port"); in setup_card()
3917 ai->bap_read = fast_bap_read; in setup_card()
3918 airo_print_dbg(ai->dev->name, "Doing fast bap_reads"); in setup_card()
3920 ai->bap_read = aux_bap_read; in setup_card()
3921 airo_print_dbg(ai->dev->name, "Doing AUX bap_reads"); in setup_card()
3925 up(&ai->sem); in setup_card()
3926 if (ai->config.len == 0) { in setup_card()
3927 status = airo_readconfig(ai, dev, lock); in setup_card()
3945 status = writeConfigRid(ai, lock); in setup_card()
3950 status = writeSsidRid(ai, &mySsid, lock); in setup_card()
3954 status = enable_MAC(ai, lock); in setup_card()
3959 rc = readWepKeyRid(ai, &wkr, 1, lock); in setup_card()
3963 ai->defindex = wkr.mac[0]; in setup_card()
3965 rc = readWepKeyRid(ai, &wkr, 0, lock); in setup_card()
3968 try_auto_wep(ai); in setup_card()
3973 static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp, in issuecommand() argument
3979 if (IN4500(ai, EVSTAT) & EV_CMD) in issuecommand()
3980 OUT4500(ai, EVACK, EV_CMD); in issuecommand()
3982 OUT4500(ai, PARAM0, pCmd->parm0); in issuecommand()
3983 OUT4500(ai, PARAM1, pCmd->parm1); in issuecommand()
3984 OUT4500(ai, PARAM2, pCmd->parm2); in issuecommand()
3985 OUT4500(ai, COMMAND, pCmd->cmd); in issuecommand()
3987 while (max_tries-- && (IN4500(ai, EVSTAT) & EV_CMD) == 0) { in issuecommand()
3988 if ((IN4500(ai, COMMAND)) == pCmd->cmd) in issuecommand()
3990 OUT4500(ai, COMMAND, pCmd->cmd); in issuecommand()
3996 airo_print_err(ai->dev->name, in issuecommand()
3998 if (IN4500(ai, COMMAND) & COMMAND_BUSY) in issuecommand()
3999 OUT4500(ai, EVACK, EV_CLEARCOMMANDBUSY); in issuecommand()
4004 pRsp->status = IN4500(ai, STATUS); in issuecommand()
4005 pRsp->rsp0 = IN4500(ai, RESP0); in issuecommand()
4006 pRsp->rsp1 = IN4500(ai, RESP1); in issuecommand()
4007 pRsp->rsp2 = IN4500(ai, RESP2); in issuecommand()
4009 airo_print_err(ai->dev->name, in issuecommand()
4015 if (IN4500(ai, COMMAND) & COMMAND_BUSY) { in issuecommand()
4016 OUT4500(ai, EVACK, EV_CLEARCOMMANDBUSY); in issuecommand()
4019 OUT4500(ai, EVACK, EV_CMD); in issuecommand()
4027 static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap) in bap_setup() argument
4032 OUT4500(ai, SELECT0+whichbap, rid); in bap_setup()
4033 OUT4500(ai, OFFSET0+whichbap, offset); in bap_setup()
4035 int status = IN4500(ai, OFFSET0+whichbap); in bap_setup()
4044 airo_print_err(ai->dev->name, "BAP error %x %d", in bap_setup()
4051 airo_print_err(ai->dev->name, in bap_setup()
4056 OUT4500(ai, SELECT0+whichbap, rid); in bap_setup()
4057 OUT4500(ai, OFFSET0+whichbap, offset); in bap_setup()
4065 static u16 aux_setup(struct airo_info *ai, u16 page, in aux_setup() argument
4070 OUT4500(ai, AUXPAGE, page); in aux_setup()
4071 OUT4500(ai, AUXOFF, 0); in aux_setup()
4072 next = IN4500(ai, AUXDATA); in aux_setup()
4073 *len = IN4500(ai, AUXDATA)&0xff; in aux_setup()
4074 if (offset != 4) OUT4500(ai, AUXOFF, offset); in aux_setup()
4079 static int aux_bap_read(struct airo_info *ai, __le16 *pu16Dst, in aux_bap_read() argument
4090 spin_lock_irqsave(&ai->aux_lock, flags); in aux_bap_read()
4091 page = IN4500(ai, SWS0+whichbap); in aux_bap_read()
4092 offset = IN4500(ai, SWS2+whichbap); in aux_bap_read()
4093 next = aux_setup(ai, page, offset, &len); in aux_bap_read()
4100 insw(ai->dev->base_addr+DATA0+whichbap, in aux_bap_read()
4103 insb(ai->dev->base_addr+DATA0+whichbap, in aux_bap_read()
4107 next = aux_setup(ai, next, 4, &len); in aux_bap_read()
4110 spin_unlock_irqrestore(&ai->aux_lock, flags); in aux_bap_read()
4116 static int fast_bap_read(struct airo_info *ai, __le16 *pu16Dst, in fast_bap_read() argument
4121 insw(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1); in fast_bap_read()
4123 insb(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen); in fast_bap_read()
4128 static int bap_write(struct airo_info *ai, const __le16 *pu16Src, in bap_write() argument
4133 outsw(ai->dev->base_addr+DATA0+whichbap, in bap_write()
4136 outsb(ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen); in bap_write()
4140 static int PC4500_accessrid(struct airo_info *ai, u16 rid, u16 accmd) in PC4500_accessrid() argument
4149 status = issuecommand(ai, &cmd, &rsp, true); in PC4500_accessrid()
4159 static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, int lock) in PC4500_readrid() argument
4165 if (down_interruptible(&ai->sem)) in PC4500_readrid()
4168 if (test_bit(FLAG_MPI,&ai->flags)) { in PC4500_readrid()
4174 ai->config_desc.rid_desc.valid = 1; in PC4500_readrid()
4175 ai->config_desc.rid_desc.len = RIDSIZE; in PC4500_readrid()
4176 ai->config_desc.rid_desc.rid = 0; in PC4500_readrid()
4177 ai->config_desc.rid_desc.host_addr = ai->ridbus; in PC4500_readrid()
4182 memcpy_toio(ai->config_desc.card_ram_off, in PC4500_readrid()
4183 &ai->config_desc.rid_desc, sizeof(Rid)); in PC4500_readrid()
4185 rc = issuecommand(ai, &cmd, &rsp, true); in PC4500_readrid()
4190 memcpy(pBuf, ai->config_desc.virtual_host_addr, len); in PC4500_readrid()
4193 if ((status = PC4500_accessrid(ai, rid, CMD_ACCESS))!=SUCCESS) { in PC4500_readrid()
4197 if (bap_setup(ai, rid, 0, BAP1) != SUCCESS) { in PC4500_readrid()
4202 bap_read(ai, pBuf, 2, BAP1); in PC4500_readrid()
4207 airo_print_err(ai->dev->name, in PC4500_readrid()
4214 rc = bap_read(ai, ((__le16*)pBuf)+1, len, BAP1); in PC4500_readrid()
4218 up(&ai->sem); in PC4500_readrid()
4224 static int PC4500_writerid(struct airo_info *ai, u16 rid, in PC4500_writerid() argument
4233 if (down_interruptible(&ai->sem)) in PC4500_writerid()
4236 if (test_bit(FLAG_MPI,&ai->flags)) { in PC4500_writerid()
4240 if (test_bit(FLAG_ENABLED, &ai->flags) && (RID_WEP_TEMP != rid)) in PC4500_writerid()
4241 airo_print_err(ai->dev->name, in PC4500_writerid()
4247 ai->config_desc.rid_desc.valid = 1; in PC4500_writerid()
4248 ai->config_desc.rid_desc.len = *((u16 *)pBuf); in PC4500_writerid()
4249 ai->config_desc.rid_desc.rid = 0; in PC4500_writerid()
4254 memcpy_toio(ai->config_desc.card_ram_off, in PC4500_writerid()
4255 &ai->config_desc.rid_desc, sizeof(Rid)); in PC4500_writerid()
4258 airo_print_err(ai->dev->name, "%s: len=%d", __func__, len); in PC4500_writerid()
4261 memcpy(ai->config_desc.virtual_host_addr, in PC4500_writerid()
4264 rc = issuecommand(ai, &cmd, &rsp, true); in PC4500_writerid()
4266 airo_print_err(ai->dev->name, "%s: Write rid Error %d", in PC4500_writerid()
4268 airo_print_err(ai->dev->name, "%s: Cmd=%04x", in PC4500_writerid()
4277 if ((status = PC4500_accessrid(ai, rid, CMD_ACCESS)) != 0) { in PC4500_writerid()
4282 if (bap_setup(ai, rid, 0, BAP1) != SUCCESS) { in PC4500_writerid()
4286 bap_write(ai, pBuf, len, BAP1); in PC4500_writerid()
4288 rc = PC4500_accessrid(ai, rid, 0x100|CMD_ACCESS); in PC4500_writerid()
4292 up(&ai->sem); in PC4500_writerid()
4298 static u16 transmit_allocate(struct airo_info *ai, int lenPayload, int raw) in transmit_allocate() argument
4308 if (down_interruptible(&ai->sem)) in transmit_allocate()
4310 if (issuecommand(ai, &cmd, &rsp, true) != SUCCESS) { in transmit_allocate()
4321 while (((IN4500(ai, EVSTAT) & EV_ALLOC) == 0) && --loop); in transmit_allocate()
4328 txFid = IN4500(ai, TXALLOCFID); in transmit_allocate()
4329 OUT4500(ai, EVACK, EV_ALLOC); in transmit_allocate()
4342 if (bap_setup(ai, txFid, 0x0008, BAP1) != SUCCESS) in transmit_allocate()
4345 bap_write(ai, &txControl, sizeof(txControl), BAP1); in transmit_allocate()
4348 up(&ai->sem); in transmit_allocate()
4356 static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket, in transmit_802_3_packet() argument
4369 airo_print_warn(ai->dev->name, "Short packet %d", len); in transmit_802_3_packet()
4374 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && in transmit_802_3_packet()
4376 if (encapsulate(ai, (etherHead *)pPacket,&pMic, len) != SUCCESS) in transmit_802_3_packet()
4382 if (bap_setup(ai, txFid, 0x0036, BAP1) != SUCCESS) return ERROR; in transmit_802_3_packet()
4386 bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1); in transmit_802_3_packet()
4387 bap_write(ai, (__le16*)pPacket, sizeof(etherHead), BAP1); in transmit_802_3_packet()
4389 bap_write(ai, (__le16*)&pMic, miclen, BAP1); in transmit_802_3_packet()
4390 bap_write(ai, (__le16*)(pPacket + sizeof(etherHead)), len, BAP1); in transmit_802_3_packet()
4395 if (issuecommand(ai, &cmd, &rsp, may_sleep) != SUCCESS) in transmit_802_3_packet()
4401 static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket, in transmit_802_11_packet() argument
4417 airo_print_warn(ai->dev->name, "Short packet %d", len); in transmit_802_11_packet()
4423 if (bap_setup(ai, txFid, 6, BAP1) != SUCCESS) return ERROR; in transmit_802_11_packet()
4427 bap_write(ai, &payloadLen, sizeof(payloadLen), BAP1); in transmit_802_11_packet()
4428 if (bap_setup(ai, txFid, 0x0014, BAP1) != SUCCESS) return ERROR; in transmit_802_11_packet()
4429 bap_write(ai, (__le16 *)pPacket, hdrlen, BAP1); in transmit_802_11_packet()
4430 bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1); in transmit_802_11_packet()
4432 bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1); in transmit_802_11_packet()
4437 if (issuecommand(ai, &cmd, &rsp, may_sleep) != SUCCESS) in transmit_802_11_packet()
4814 static inline int sniffing_mode(struct airo_info *ai) in sniffing_mode() argument
4816 return (le16_to_cpu(ai->config.rmode) & le16_to_cpu(RXMODE_MASK)) >= in sniffing_mode()
4824 struct airo_info *ai = dev->ml_priv; in proc_config_on_close() local
4829 readConfigRid(ai, 1); in proc_config_on_close()
4830 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4837 if (sniffing_mode(ai)) in proc_config_on_close()
4838 set_bit (FLAG_RESET, &ai->flags); in proc_config_on_close()
4839 ai->config.rmode &= ~RXMODE_FULL_MASK; in proc_config_on_close()
4840 clear_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4841 ai->config.opmode &= ~MODE_CFG_MASK; in proc_config_on_close()
4842 ai->config.scanMode = SCANMODE_ACTIVE; in proc_config_on_close()
4844 ai->config.opmode |= MODE_STA_IBSS; in proc_config_on_close()
4846 ai->config.opmode |= MODE_STA_ESS; in proc_config_on_close()
4848 ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; in proc_config_on_close()
4849 ai->config.scanMode = SCANMODE_PASSIVE; in proc_config_on_close()
4850 set_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4852 ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER; in proc_config_on_close()
4853 ai->config.scanMode = SCANMODE_PASSIVE; in proc_config_on_close()
4854 set_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4856 ai->config.rmode |= RXMODE_LANMON; in proc_config_on_close()
4858 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4865 set_bit (FLAG_RADIO_OFF, &ai->flags); in proc_config_on_close()
4867 clear_bit (FLAG_RADIO_OFF, &ai->flags); in proc_config_on_close()
4875 memset(ai->config.nodeName, 0, 16); in proc_config_on_close()
4878 ai->config.nodeName[j] = line[j]; in proc_config_on_close()
4880 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4887 ai->config.powerSaveMode = POWERSAVE_PSPCAM; in proc_config_on_close()
4888 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4890 ai->config.powerSaveMode = POWERSAVE_PSP; in proc_config_on_close()
4891 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4893 ai->config.powerSaveMode = POWERSAVE_CAM; in proc_config_on_close()
4894 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4902 ai->config.rates[k++] = (u8)v; in proc_config_on_close()
4906 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4912 ai->config.channelSet = cpu_to_le16(v); in proc_config_on_close()
4913 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4920 ai->config.txPower = cpu_to_le16(v); in proc_config_on_close()
4921 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4927 set_auth_type(ai, AUTH_SHAREDKEY); in proc_config_on_close()
4930 set_auth_type(ai, AUTH_ENCRYPT); in proc_config_on_close()
4933 set_auth_type(ai, AUTH_OPEN); in proc_config_on_close()
4936 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4943 ai->config.longRetryLimit = cpu_to_le16(v); in proc_config_on_close()
4944 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4951 ai->config.shortRetryLimit = cpu_to_le16(v); in proc_config_on_close()
4952 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4959 ai->config.rtsThres = cpu_to_le16(v); in proc_config_on_close()
4960 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4967 ai->config.txLifetime = cpu_to_le16(v); in proc_config_on_close()
4968 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4975 ai->config.rxLifetime = cpu_to_le16(v); in proc_config_on_close()
4976 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4978 ai->config.txDiversity = in proc_config_on_close()
4981 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4983 ai->config.rxDiversity = in proc_config_on_close()
4986 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4994 ai->config.fragThresh = cpu_to_le16(v); in proc_config_on_close()
4995 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4999 case 'd': ai->config.modulation = MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5000 case 'c': ai->config.modulation = MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5001 case 'm': ai->config.modulation = MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5002 default: airo_print_warn(ai->dev->name, "Unknown modulation"); in proc_config_on_close()
5007 case 'a': ai->config.preamble = PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5008 case 'l': ai->config.preamble = PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5009 case 's': ai->config.preamble = PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5010 default: airo_print_warn(ai->dev->name, "Unknown preamble"); in proc_config_on_close()
5013 airo_print_warn(ai->dev->name, "Couldn't figure out %s", line); in proc_config_on_close()
5035 struct airo_info *ai = dev->ml_priv; in proc_config_open() local
5054 readConfigRid(ai, 1); in proc_config_open()
5056 mode = ai->config.opmode & MODE_CFG_MASK; in proc_config_open()
5066 mode == MODE_STA_ESS ? get_rmode(ai->config.rmode): in proc_config_open()
5069 test_bit(FLAG_RADIO_OFF, &ai->flags) ? "off" : "on", in proc_config_open()
5070 ai->config.nodeName, in proc_config_open()
5071 ai->config.powerSaveMode == POWERSAVE_CAM ? "CAM" : in proc_config_open()
5072 ai->config.powerSaveMode == POWERSAVE_PSP ? "PSP" : in proc_config_open()
5073 ai->config.powerSaveMode == POWERSAVE_PSPCAM ? "PSPCAM" : in proc_config_open()
5075 (int)ai->config.rates[0], in proc_config_open()
5076 (int)ai->config.rates[1], in proc_config_open()
5077 (int)ai->config.rates[2], in proc_config_open()
5078 (int)ai->config.rates[3], in proc_config_open()
5079 (int)ai->config.rates[4], in proc_config_open()
5080 (int)ai->config.rates[5], in proc_config_open()
5081 (int)ai->config.rates[6], in proc_config_open()
5082 (int)ai->config.rates[7], in proc_config_open()
5083 le16_to_cpu(ai->config.channelSet), in proc_config_open()
5084 le16_to_cpu(ai->config.txPower) in proc_config_open()
5098 le16_to_cpu(ai->config.longRetryLimit), in proc_config_open()
5099 le16_to_cpu(ai->config.shortRetryLimit), in proc_config_open()
5100 le16_to_cpu(ai->config.rtsThres), in proc_config_open()
5101 le16_to_cpu(ai->config.txLifetime), in proc_config_open()
5102 le16_to_cpu(ai->config.rxLifetime), in proc_config_open()
5103 ai->config.txDiversity == 1 ? "left" : in proc_config_open()
5104 ai->config.txDiversity == 2 ? "right" : "both", in proc_config_open()
5105 ai->config.rxDiversity == 1 ? "left" : in proc_config_open()
5106 ai->config.rxDiversity == 2 ? "right" : "both", in proc_config_open()
5107 le16_to_cpu(ai->config.fragThresh), in proc_config_open()
5108 ai->config.authType == AUTH_ENCRYPT ? "encrypt" : in proc_config_open()
5109 ai->config.authType == AUTH_SHAREDKEY ? "shared" : "open", in proc_config_open()
5110 ai->config.modulation == MOD_DEFAULT ? "default" : in proc_config_open()
5111 ai->config.modulation == MOD_CCK ? "cck" : in proc_config_open()
5112 ai->config.modulation == MOD_MOK ? "mok" : "error", in proc_config_open()
5113 ai->config.preamble == PREAMBLE_AUTO ? "auto" : in proc_config_open()
5114 ai->config.preamble == PREAMBLE_LONG ? "long" : in proc_config_open()
5115 ai->config.preamble == PREAMBLE_SHORT ? "short" : "error" in proc_config_open()
5125 struct airo_info *ai = dev->ml_priv; in proc_SSID_on_close() local
5152 disable_MAC(ai, 1); in proc_SSID_on_close()
5153 writeSsidRid(ai, &SSID_rid, 1); in proc_SSID_on_close()
5154 enable_MAC(ai, 1); in proc_SSID_on_close()
5161 struct airo_info *ai = dev->ml_priv; in proc_APList_on_close() local
5162 APListRid *APList_rid = &ai->APList; in proc_APList_on_close()
5173 disable_MAC(ai, 1); in proc_APList_on_close()
5174 writeAPListRid(ai, APList_rid, 1); in proc_APList_on_close()
5175 enable_MAC(ai, 1); in proc_APList_on_close()
5179 static int do_writerid(struct airo_info *ai, u16 rid, const void *rid_data, in do_writerid() argument
5184 disable_MAC(ai, 1); in do_writerid()
5185 rc = PC4500_writerid(ai, rid, rid_data, len, 1); in do_writerid()
5186 enable_MAC(ai, 1); in do_writerid()
5193 static int get_wep_key(struct airo_info *ai, u16 index, char *buf, u16 buflen) in get_wep_key() argument
5199 rc = readWepKeyRid(ai, &wkr, 1, 1); in get_wep_key()
5209 rc = readWepKeyRid(ai, &wkr, 0, 1); in get_wep_key()
5216 static int get_wep_tx_idx(struct airo_info *ai) in get_wep_tx_idx() argument
5222 rc = readWepKeyRid(ai, &wkr, 1, 1); in get_wep_tx_idx()
5229 rc = readWepKeyRid(ai, &wkr, 0, 1); in get_wep_tx_idx()
5236 static int set_wep_key(struct airo_info *ai, u16 index, const u8 *key, in set_wep_key() argument
5253 if (perm) disable_MAC(ai, lock); in set_wep_key()
5254 rc = writeWepKeyRid(ai, &wkr, perm, lock); in set_wep_key()
5255 if (perm) enable_MAC(ai, lock); in set_wep_key()
5259 static int set_wep_tx_idx(struct airo_info *ai, u16 index, int perm, int lock) in set_wep_tx_idx() argument
5270 ai->defindex = (char)index; in set_wep_tx_idx()
5271 disable_MAC(ai, lock); in set_wep_tx_idx()
5274 rc = writeWepKeyRid(ai, &wkr, perm, lock); in set_wep_tx_idx()
5277 enable_MAC(ai, lock); in set_wep_tx_idx()
5285 struct airo_info *ai = dev->ml_priv; in proc_wepkey_on_close() local
5300 rc = set_wep_tx_idx(ai, index, 1, 1); in proc_wepkey_on_close()
5302 airo_print_err(ai->dev->name, "failed to set " in proc_wepkey_on_close()
5310 airo_print_err(ai->dev->name, "WepKey passed invalid key index"); in proc_wepkey_on_close()
5322 airo_print_err(ai->dev->name, "WebKey passed invalid key hex"); in proc_wepkey_on_close()
5335 rc = set_wep_key(ai, index, key, i/3, 1, 1); in proc_wepkey_on_close()
5337 airo_print_err(ai->dev->name, "failed to set WEP key at index " in proc_wepkey_on_close()
5346 struct airo_info *ai = dev->ml_priv; in proc_wepkey_open() local
5372 rc = readWepKeyRid(ai, &wkr, 1, 1); in proc_wepkey_open()
5383 readWepKeyRid(ai, &wkr, 0, 1); in proc_wepkey_open()
5394 struct airo_info *ai = dev->ml_priv; in proc_SSID_open() local
5416 readSsidRid(ai, &SSID_rid); in proc_SSID_open()
5438 struct airo_info *ai = dev->ml_priv; in proc_APList_open() local
5441 APListRid *APList_rid = &ai->APList; in proc_APList_open()
5477 struct airo_info *ai = dev->ml_priv; in proc_BSSList_open() local
5501 if (ai->flags & FLAG_RADIO_MASK) { in proc_BSSList_open()
5508 if (down_interruptible(&ai->sem)) { in proc_BSSList_open()
5513 issuecommand(ai, &cmd, &rsp, true); in proc_BSSList_open()
5514 up(&ai->sem); in proc_BSSList_open()
5524 rc = readBSSListRid(ai, doLoseSync, &BSSList_rid); in proc_BSSList_open()
5537 rc = readBSSListRid(ai, 0, &BSSList_rid); in proc_BSSList_open()
5633 struct airo_info *ai = dev->ml_priv; in airo_pci_suspend() local
5637 if (!ai->SSID) in airo_pci_suspend()
5638 ai->SSID = kmalloc(sizeof(SsidRid), GFP_KERNEL); in airo_pci_suspend()
5639 if (!ai->SSID) in airo_pci_suspend()
5641 readSsidRid(ai, ai->SSID); in airo_pci_suspend()
5644 if (down_interruptible(&ai->sem)) in airo_pci_suspend()
5646 disable_MAC(ai, 0); in airo_pci_suspend()
5648 ai->power = PMSG_SUSPEND; in airo_pci_suspend()
5650 issuecommand(ai, &cmd, &rsp, true); in airo_pci_suspend()
5659 struct airo_info *ai = dev->ml_priv; in airo_pci_resume() local
5666 mpi_init_descriptors(ai); in airo_pci_resume()
5667 setup_card(ai, dev, 0); in airo_pci_resume()
5668 clear_bit(FLAG_RADIO_OFF, &ai->flags); in airo_pci_resume()
5669 clear_bit(FLAG_PENDING_XMIT, &ai->flags); in airo_pci_resume()
5671 OUT4500(ai, EVACK, EV_AWAKEN); in airo_pci_resume()
5672 OUT4500(ai, EVACK, EV_AWAKEN); in airo_pci_resume()
5676 set_bit(FLAG_COMMIT, &ai->flags); in airo_pci_resume()
5677 disable_MAC(ai, 0); in airo_pci_resume()
5679 if (ai->SSID) { in airo_pci_resume()
5680 writeSsidRid(ai, ai->SSID, 0); in airo_pci_resume()
5681 kfree(ai->SSID); in airo_pci_resume()
5682 ai->SSID = NULL; in airo_pci_resume()
5684 writeAPListRid(ai, &ai->APList, 0); in airo_pci_resume()
5685 writeConfigRid(ai, 0); in airo_pci_resume()
5686 enable_MAC(ai, 0); in airo_pci_resume()
5687 ai->power = PMSG_ON; in airo_pci_resume()
5690 enable_interrupts(ai); in airo_pci_resume()
5691 up(&ai->sem); in airo_pci_resume()
5737 struct airo_info *ai; in airo_cleanup_module() local
5739 ai = list_entry(airo_devices.next, struct airo_info, dev_list); in airo_cleanup_module()
5740 airo_print_info(ai->dev->name, "Unregistering..."); in airo_cleanup_module()
5741 stop_airo_card(ai->dev, 1); in airo_cleanup_module()
6358 static inline int valid_index(struct airo_info *ai, int index) in valid_index() argument
6360 return (index >= 0) && (index <= ai->max_wep_idx); in valid_index()
7287 struct airo_info *ai = dev->ml_priv; in airo_set_scan() local
7299 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; in airo_set_scan()
7301 if (down_interruptible(&ai->sem)) in airo_set_scan()
7306 if (ai->scan_timeout > 0) in airo_set_scan()
7312 disable_MAC(ai, 2); in airo_set_scan()
7313 writeAPListRid(ai, &APList_rid_empty, 0); in airo_set_scan()
7314 enable_MAC(ai, 0); in airo_set_scan()
7317 ai->scan_timeout = RUN_AT(3*HZ); in airo_set_scan()
7320 issuecommand(ai, &cmd, &rsp, true); in airo_set_scan()
7324 up(&ai->sem); in airo_set_scan()
7326 wake_up_interruptible(&ai->thr_wait); in airo_set_scan()
7341 struct airo_info *ai = dev->ml_priv; in airo_translate_scan() local
7392 if (ai->rssi) { in airo_translate_scan()
7394 iwe.u.qual.qual = airo_dbm_to_pct(ai->rssi, dBm); in airo_translate_scan()
7405 iwe.u.qual.noise = ai->wstats.qual.noise; in airo_translate_scan()
7454 if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) { in airo_translate_scan()
7519 struct airo_info *ai = dev->ml_priv; in airo_get_scan() local
7525 if (ai->scan_timeout > 0) in airo_get_scan()
7528 if (down_interruptible(&ai->sem)) in airo_get_scan()
7531 list_for_each_entry (net, &ai->network_list, list) { in airo_get_scan()
7550 up(&ai->sem); in airo_get_scan()
7692 struct airo_info *ai = dev->ml_priv; in airo_siocdevprivate() local
7694 if (ai->power.event) in airo_siocdevprivate()
7838 struct airo_info *ai = dev->ml_priv; in readrids() local
7840 if (test_bit(FLAG_FLASHING, &ai->flags)) in readrids()
7847 if (test_bit(FLAG_COMMIT, &ai->flags)) { in readrids()
7848 disable_MAC (ai, 1); in readrids()
7849 writeConfigRid (ai, 1); in readrids()
7850 enable_MAC(ai, 1); in readrids()
7863 if (copy_to_user(comp->data, &ai->micstats, in readrids()
7864 min((int)comp->len, (int)sizeof(ai->micstats)))) in readrids()
7881 PC4500_readrid(ai, ridcode, iobuf, RIDSIZE, 1); in readrids()
7902 struct airo_info *ai = dev->ml_priv; in writerids() local
7912 if (test_bit(FLAG_FLASHING, &ai->flags)) in writerids()
7923 case AIROPCFG: ai->config.len = 0; in writerids()
7924 clear_bit(FLAG_COMMIT, &ai->flags); in writerids()
7938 if (enable_MAC(ai, 1) != 0) in writerids()
7947 disable_MAC(ai, 1); in writerids()
7958 PC4500_readrid(ai, RID_STATSDELTACLEAR, iobuf, RIDSIZE, 1); in writerids()
7960 enabled = ai->micstats.enabled; in writerids()
7961 memset(&ai->micstats, 0, sizeof(ai->micstats)); in writerids()
7962 ai->micstats.enabled = enabled; in writerids()
7989 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags)) in writerids()
7993 set_bit (FLAG_ADHOC, &ai->flags); in writerids()
7995 clear_bit (FLAG_ADHOC, &ai->flags); in writerids()
7998 if ((*writer)(ai, ridcode, iobuf, comp->len, 1)) { in writerids()
8075 static int cmdreset(struct airo_info *ai) in cmdreset() argument
8077 disable_MAC(ai, 1); in cmdreset()
8079 if (!waitbusy (ai)) { in cmdreset()
8080 airo_print_info(ai->dev->name, "Waitbusy hang before RESET"); in cmdreset()
8084 OUT4500(ai, COMMAND, CMD_SOFTRESET); in cmdreset()
8088 if (!waitbusy (ai)) { in cmdreset()
8089 airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET"); in cmdreset()
8100 static int setflashmode (struct airo_info *ai) in setflashmode() argument
8102 set_bit (FLAG_FLASHING, &ai->flags); in setflashmode()
8104 OUT4500(ai, SWS0, FLASH_COMMAND); in setflashmode()
8105 OUT4500(ai, SWS1, FLASH_COMMAND); in setflashmode()
8107 OUT4500(ai, SWS0, FLASH_COMMAND); in setflashmode()
8108 OUT4500(ai, COMMAND, 0x10); in setflashmode()
8110 OUT4500(ai, SWS2, FLASH_COMMAND); in setflashmode()
8111 OUT4500(ai, SWS3, FLASH_COMMAND); in setflashmode()
8112 OUT4500(ai, COMMAND, 0); in setflashmode()
8116 if (!waitbusy(ai)) { in setflashmode()
8117 clear_bit (FLAG_FLASHING, &ai->flags); in setflashmode()
8118 airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode"); in setflashmode()
8128 static int flashpchar(struct airo_info *ai, int byte, int dwelltime) in flashpchar() argument
8141 while ((IN4500 (ai, SWS0) & 0x8000) && waittime > 0) { in flashpchar()
8148 airo_print_info(ai->dev->name, "flash putchar busywait timeout!"); in flashpchar()
8154 OUT4500(ai, SWS0, byte); in flashpchar()
8157 echo = IN4500(ai, SWS1); in flashpchar()
8160 OUT4500(ai, SWS1, 0); in flashpchar()
8169 static int flashgchar(struct airo_info *ai, int matchbyte, int dwelltime) in flashgchar() argument
8175 rchar = IN4500(ai, SWS1); in flashgchar()
8185 OUT4500(ai, SWS1, 0); in flashgchar()
8190 OUT4500(ai, SWS1, 0); in flashgchar()
8201 static int flashputbuf(struct airo_info *ai) in flashputbuf() argument
8206 if (test_bit(FLAG_MPI,&ai->flags)) in flashputbuf()
8207 memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE); in flashputbuf()
8209 OUT4500(ai, AUXPAGE, 0x100); in flashputbuf()
8210 OUT4500(ai, AUXOFF, 0); in flashputbuf()
8213 OUT4500(ai, AUXDATA, ai->flash[nwords] & 0xffff); in flashputbuf()
8216 OUT4500(ai, SWS0, 0x8000); in flashputbuf()
8224 static int flashrestart(struct airo_info *ai, struct net_device *dev) in flashrestart() argument
8229 clear_bit (FLAG_FLASHING, &ai->flags); in flashrestart()
8230 if (test_bit(FLAG_MPI, &ai->flags)) { in flashrestart()
8231 status = mpi_init_descriptors(ai); in flashrestart()
8235 status = setup_card(ai, dev, 1); in flashrestart()
8237 if (!test_bit(FLAG_MPI,&ai->flags)) in flashrestart()
8239 ai->fids[i] = transmit_allocate in flashrestart()
8240 (ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2); in flashrestart()