Lines Matching +full:pci +full:- +full:host +full:- +full:cam +full:- +full:generic

47 #include <linux/pci.h>
73 MODULE_DEVICE_TABLE(pci, card_ids);
93 /* Include Wireless Extension definition and check version - Jean II */
146 "LostSync-MaxRetry",
147 "LostSync-MissedBeacons",
148 "LostSync-ArlExceeded",
149 "LostSync-Deauth",
150 "LostSync-Disassoced",
151 "LostSync-TsfTiming",
203 "LostSync-HostReq",
213 (char*)-1 };
252 "Direct support for ISA/PCI/MPI cards and support for PCMCIA when used with airo_cs.");
261 …"If non-zero, the driver will keep looping through the authentication options until an association…
266 …"If non-zero, the driver will switch into a mode that seems to work better for older cards with so…
275 MODULE_PARM_DESC(adhoc, "If non-zero, the card will start in adhoc mode.");
295 #define ERROR -1
296 #define NO_PACKET -2
500 * Rids and endian-ness: The Rids will always be in cpu endian, since
501 * this all the patches from the big-endian guys end up doing that.
562 #define RXMODE_LANMON cpu_to_le16(5) /* lan style monitor -- data packets only */
581 /*---------- Scanning/Associating ----------*/
606 /*---------- Power save operation ----------*/
617 /*---------- Ap/Ibss config items ----------*/
626 /*---------- Radio configuration ----------*/
644 /*---------- Aironet Extensions ----------*/
650 /*---------- Aironet Extensions ----------*/
863 #define TXCTL_NORELEASE (1<<5) /* on completion returns to host */
869 /* Warning : SIOCDEVPRIVATE may disapear during 2.5.X - Jean II */
881 * is usually a problem. - Jean II */
937 unsigned char __user *data; // d-data
970 emmh32_context seed; // Context - the seed
1015 * Host receive descriptor
1021 char *virtual_host_addr; /* virtual address of host receive
1027 * Host transmit descriptor
1033 char *virtual_host_addr; /* virtual address of host receive
1039 * Host RID descriptor
1045 char *virtual_host_addr; /* virtual address of host receive
1097 #define MIN_KEY_SIZE 5 // 40 bits RC4 - WEP
1100 u8 key[16]; /* 40-bit and 104-bit keys */
1137 static void mpi_unmap_card(struct pci_dev *pci);
1166 /* Note, we can have MAX_FIDS outstanding. FIDs are 16-bits, so we
1185 #define FLAG_PROMISC 8 /* IFF_PROMISC 0x100 - include/linux/if.h */
1233 struct pci_dev *pci; member
1248 /* WPA-related stuff */
1261 return ai->bap_read(ai, pu16Dst, bytelen, whichbap); in bap_read()
1290 #define AIRO_FLASH(dev) (((struct airo_info *)dev->ml_priv)->flash)
1312 if (cur->valid && (memcmp(cur->key, key, key_len) == 0)) in age_mic_context()
1319 memcpy(cur->key, key, key_len); in age_mic_context()
1320 cur->window = 33; /* Window always points to the middle */ in age_mic_context()
1321 cur->rx = 0; /* Rx Sequence numbers */ in age_mic_context()
1322 cur->tx = 0; /* Tx sequence numbers */ in age_mic_context()
1323 cur->valid = 1; /* Key is now valid */ in age_mic_context()
1326 emmh32_setseed(&cur->seed, key, key_len, tfm); in age_mic_context()
1329 /* micinit - Initialize mic seed */
1335 clear_bit(JOB_MIC, &ai->jobs); 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()
1362 /* micsetup - Get ready for business */
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()
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()
1414 if (!context->valid) in encapsulate()
1417 mic->typelen = htons(payLen + 16); //Length of Mic'd packet in encapsulate()
1419 memcpy(&mic->u.snap, micsnap, sizeof(micsnap)); // Add Snap in encapsulate()
1422 mic->seq = htonl(context->tx); in encapsulate()
1423 context->tx += 2; in encapsulate()
1425 emmh32_init(&context->seed); // Mic the packet in encapsulate()
1426 emmh32_update(&context->seed, frame->da, ETH_ALEN * 2); // DA, SA in encapsulate()
1427 emmh32_update(&context->seed, (u8*)&mic->typelen, 10); // Type/Length and Snap in encapsulate()
1428 emmh32_update(&context->seed, (u8*)&mic->seq, sizeof(mic->seq)); //SEQ in encapsulate()
1429 emmh32_update(&context->seed, (u8*)(frame + 1), payLen); //payload in encapsulate()
1430 emmh32_final(&context->seed, (u8*)&mic->mic); in encapsulate()
1433 mic->typelen = 0; //Let NIC know it could be an oversized packet in encapsulate()
1451 * Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE
1455 *---------------------------------------------------------------------------
1468 if (!ai->micstats.enabled) { in decapsulate()
1471 ai->micstats.rxMICPlummed++; in decapsulate()
1477 if (ntohs(mic->typelen) == 0x888E) in decapsulate()
1480 if (memcmp (mic->u.snap, micsnap, sizeof(micsnap)) != 0) { in decapsulate()
1482 ai->micstats.rxMICPlummed++; in decapsulate()
1486 micSEQ = ntohl(mic->seq); //store SEQ as CPU order in decapsulate()
1493 ai->micstats.rxWrongSequence++; in decapsulate()
1498 int mcast = eth->da[0] & 1; in decapsulate()
1500 context = mcast ? &ai->mod[i].mCtx : &ai->mod[i].uCtx; in decapsulate()
1503 if (!context->valid) { in decapsulate()
1510 if (!mic->typelen) in decapsulate()
1511 mic->typelen = htons(payLen + sizeof(MICBuffer) - 2); in decapsulate()
1513 emmh32_init(&context->seed); in decapsulate()
1514 emmh32_update(&context->seed, eth->da, ETH_ALEN*2); in decapsulate()
1515 emmh32_update(&context->seed, (u8 *)&mic->typelen, sizeof(mic->typelen)+sizeof(mic->u.snap)); in decapsulate()
1516 emmh32_update(&context->seed, (u8 *)&mic->seq, sizeof(mic->seq)); in decapsulate()
1517 emmh32_update(&context->seed, (u8 *)(eth + 1), payLen); in decapsulate()
1519 emmh32_final(&context->seed, digest); in decapsulate()
1521 if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match 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()
1552 * Inputs: miccntx - mic context to check seq against
1553 * micSeq - the Mic seq number
1559 *---------------------------------------------------------------------------
1566 //Allow for the ap being rebooted - if it is then use the next in RxSeqValid()
1567 //sequence number of the current sequence number - might go backwards in RxSeqValid()
1570 if (test_bit(FLAG_UPDATE_MULTI, &ai->flags)) { in RxSeqValid()
1571 clear_bit (FLAG_UPDATE_MULTI, &ai->flags); in RxSeqValid()
1572 context->window = (micSeq > 33) ? micSeq : 33; in RxSeqValid()
1573 context->rx = 0; // Reset rx in RxSeqValid()
1575 } else if (test_bit(FLAG_UPDATE_UNI, &ai->flags)) { in RxSeqValid()
1576 clear_bit (FLAG_UPDATE_UNI, &ai->flags); in RxSeqValid()
1577 context->window = (micSeq > 33) ? micSeq : 33; // Move window in RxSeqValid()
1578 context->rx = 0; // Reset rx in RxSeqValid()
1582 seq = micSeq - (context->window - 33); in RxSeqValid()
1598 if (!(context->rx & index)) { in RxSeqValid()
1601 context->rx |= index; in RxSeqValid()
1615 if (micSeq > context->window) { in MoveWindow()
1616 shift = (micSeq - context->window) >> 1; in MoveWindow()
1620 context->rx >>= shift; in MoveWindow()
1622 context->rx = 0; in MoveWindow()
1624 context->window = micSeq; //Move window in MoveWindow()
1634 context->accum += (u64)(val) * be32_to_cpu(context->coeff[coeff_position++]);
1640 /* take the keying material, expand if necessary, truncate at 16-bytes */ in emmh32_setseed()
1641 /* run through AES counter mode to generate context->coeff[] */ in emmh32_setseed()
1650 memset(context->coeff, 0, sizeof(context->coeff)); in emmh32_setseed()
1651 sg_init_one(&sg, context->coeff, sizeof(context->coeff)); in emmh32_setseed()
1655 skcipher_request_set_crypt(req, &sg, &sg, sizeof(context->coeff), iv); in emmh32_setseed()
1665 context->accum = 0; in emmh32_init()
1666 context->position = 0; in emmh32_init()
1676 coeff_position = context->position >> 2; in emmh32_update()
1678 /* deal with partial 32-bit word left over from last update */ in emmh32_update()
1679 byte_position = context->position & 3; in emmh32_update()
1684 context->part.d8[byte_position++] = *pOctets++; in emmh32_update()
1685 context->position++; in emmh32_update()
1686 len--; in emmh32_update()
1688 MIC_ACCUM(ntohl(context->part.d32)); in emmh32_update()
1691 /* deal with full 32-bit words */ in emmh32_update()
1694 context->position += 4; in emmh32_update()
1696 len -= 4; in emmh32_update()
1699 /* deal with partial 32-bit word that will be left over from this update */ in emmh32_update()
1702 context->part.d8[byte_position++] = *pOctets++; in emmh32_update()
1703 context->position++; in emmh32_update()
1704 len--; in emmh32_update()
1720 coeff_position = context->position >> 2; in emmh32_final()
1722 /* deal with partial 32-bit word left over from last update */ in emmh32_final()
1723 byte_position = context->position & 3; in emmh32_final()
1726 val = ntohl(context->part.d32); in emmh32_final()
1730 /* reduce the accumulated u64 to a 32-bit MIC */ in emmh32_final()
1731 sum = context->accum; in emmh32_final()
1732 stmp = (sum & 0xffffffffLL) - ((sum >> 32) * 15); in emmh32_final()
1733 utmp = (stmp & 0xffffffffLL) - ((stmp >> 32) * 15); in emmh32_final()
1736 sum -= 15; in emmh32_final()
1752 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; in readBSSListRid()
1755 if (down_interruptible(&ai->sem)) in readBSSListRid()
1756 return -ERESTARTSYS; in readBSSListRid()
1757 ai->list_bss_task = current; 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()
1779 airo_print_err(ai->dev->name, "WEP_TEMP set %x", rc); in writeWepKeyRid()
1783 airo_print_err(ai->dev->name, "WEP_PERM set %x", rc); in writeWepKeyRid()
1803 if (ai->config.len) in readConfigRid()
1810 ai->config = cfg; in readConfigRid()
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()
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()
1837 cfgr = ai->config; in writeConfigRid()
1840 set_bit(FLAG_ADHOC, &ai->flags); in writeConfigRid()
1842 clear_bit(FLAG_ADHOC, &ai->flags); in writeConfigRid()
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()
1880 if (test_bit(FLAG_FLASHING, &ai->flags)) in airo_open()
1881 return -EIO; in airo_open()
1885 * is open (to pipeline changes and speed-up card setup). If in airo_open()
1886 * those changes are not yet committed, do it now - Jean II */ in airo_open()
1887 if (test_bit(FLAG_COMMIT, &ai->flags)) { 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()
1895 dev->name); 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()
1899 rc = request_irq(dev->irq, airo_interrupt, IRQF_SHARED, in airo_open()
1900 dev->name, dev); in airo_open()
1902 airo_print_err(dev->name, in airo_open()
1904 dev->irq, rc); 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()
1927 struct airo_info *ai = dev->ml_priv; in mpi_start_xmit()
1930 airo_print_err(dev->name, "%s: skb == NULL!",__func__); in mpi_start_xmit()
1934 dev->stats.tx_dropped++; in mpi_start_xmit()
1937 npacks = skb_queue_len (&ai->txq); in mpi_start_xmit()
1939 if (npacks >= MAXTXQ - 1) { in mpi_start_xmit()
1942 dev->stats.tx_fifo_errors++; 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()
1980 if ((skb = skb_dequeue(&ai->txq)) == NULL) { in mpi_send_packet()
1981 airo_print_err(dev->name, in mpi_send_packet()
1988 len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; in mpi_send_packet()
1989 buffer = skb->data; 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()
1997 * Magic, the cards firmware needs a length count (2 bytes) in the host buffer in mpi_send_packet()
1999 * is immediately after it. ------------------------------------------------ in mpi_send_packet()
2001 * ------------------------------------------------ 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()
2023 *payloadLen = cpu_to_le16(len-sizeof(etherHead)+sizeof(pMic)); in mpi_send_packet()
2024 ai->txfids[0].tx_desc.len += sizeof(pMic); in mpi_send_packet()
2031 memcpy (sendbuf, buffer, len - sizeof(etherHead)); in mpi_send_packet()
2033 *payloadLen = cpu_to_le16(len - sizeof(etherHead)); 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()
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()
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()
2074 * Other errors means that *we* screwed up. - Jean II */ in get_tx_error()
2082 * need to go to 0x18 and read 6 bytes - Jean II */ in get_tx_error()
2088 * In Ad-Hoc mode, it will be the node address. in get_tx_error()
2092 * - Jean II */ in get_tx_error()
2097 wireless_send_event(ai->dev, IWEVTXDROP, &wrqu, NULL); in get_tx_error()
2105 struct airo_info *priv = dev->ml_priv; in airo_end_xmit()
2106 struct sk_buff *skb = priv->xmit.skb; in airo_end_xmit()
2107 int fid = priv->xmit.fid; in airo_end_xmit()
2108 u32 *fids = priv->fids; in airo_end_xmit()
2110 clear_bit(JOB_XMIT, &priv->jobs); in airo_end_xmit()
2111 clear_bit(FLAG_PENDING_XMIT, &priv->flags); in airo_end_xmit()
2112 status = transmit_802_3_packet (priv, fids[fid], skb->data); in airo_end_xmit()
2113 up(&priv->sem); in airo_end_xmit()
2118 for (; i < MAX_FIDS / 2 && (priv->fids[i] & 0xffff0000); i++); in airo_end_xmit()
2120 priv->fids[fid] &= 0xffff; in airo_end_xmit()
2121 dev->stats.tx_window_errors++; in airo_end_xmit()
2133 struct airo_info *priv = dev->ml_priv; in airo_start_xmit()
2134 u32 *fids = priv->fids; in airo_start_xmit()
2137 airo_print_err(dev->name, "%s: skb == NULL!", __func__); in airo_start_xmit()
2141 dev->stats.tx_dropped++; in airo_start_xmit()
2153 dev->stats.tx_fifo_errors++; in airo_start_xmit()
2158 len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; in airo_start_xmit()
2161 priv->xmit.skb = skb; in airo_start_xmit()
2162 priv->xmit.fid = i; in airo_start_xmit()
2163 if (down_trylock(&priv->sem) != 0) { in airo_start_xmit()
2164 set_bit(FLAG_PENDING_XMIT, &priv->flags); in airo_start_xmit()
2166 set_bit(JOB_XMIT, &priv->jobs); in airo_start_xmit()
2167 wake_up_interruptible(&priv->thr_wait); in airo_start_xmit()
2177 struct airo_info *priv = dev->ml_priv; in airo_end_xmit11()
2178 struct sk_buff *skb = priv->xmit11.skb; in airo_end_xmit11()
2179 int fid = priv->xmit11.fid; in airo_end_xmit11()
2180 u32 *fids = priv->fids; in airo_end_xmit11()
2182 clear_bit(JOB_XMIT11, &priv->jobs); in airo_end_xmit11()
2183 clear_bit(FLAG_PENDING_XMIT11, &priv->flags); in airo_end_xmit11()
2184 status = transmit_802_11_packet (priv, fids[fid], skb->data); in airo_end_xmit11()
2185 up(&priv->sem); in airo_end_xmit11()
2190 for (; i < MAX_FIDS && (priv->fids[i] & 0xffff0000); i++); in airo_end_xmit11()
2192 priv->fids[fid] &= 0xffff; in airo_end_xmit11()
2193 dev->stats.tx_window_errors++; in airo_end_xmit11()
2205 struct airo_info *priv = dev->ml_priv; in airo_start_xmit11()
2206 u32 *fids = priv->fids; in airo_start_xmit11()
2208 if (test_bit(FLAG_MPI, &priv->flags)) { in airo_start_xmit11()
2216 airo_print_err(dev->name, "%s: skb == NULL!", __func__); in airo_start_xmit11()
2220 dev->stats.tx_dropped++; in airo_start_xmit11()
2232 dev->stats.tx_fifo_errors++; in airo_start_xmit11()
2237 len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; in airo_start_xmit11()
2240 priv->xmit11.skb = skb; in airo_start_xmit11()
2241 priv->xmit11.fid = i; in airo_start_xmit11()
2242 if (down_trylock(&priv->sem) != 0) { in airo_start_xmit11()
2243 set_bit(FLAG_PENDING_XMIT11, &priv->flags); in airo_start_xmit11()
2245 set_bit(JOB_XMIT11, &priv->jobs); in airo_start_xmit11()
2246 wake_up_interruptible(&priv->thr_wait); in airo_start_xmit11()
2254 struct airo_info *ai = dev->ml_priv; in airo_read_stats()
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()
2264 up(&ai->sem); in airo_read_stats()
2266 dev->stats.rx_packets = le32_to_cpu(vals[43]) + le32_to_cpu(vals[44]) + in airo_read_stats()
2268 dev->stats.tx_packets = le32_to_cpu(vals[39]) + le32_to_cpu(vals[40]) + in airo_read_stats()
2270 dev->stats.rx_bytes = le32_to_cpu(vals[92]); in airo_read_stats()
2271 dev->stats.tx_bytes = le32_to_cpu(vals[91]); in airo_read_stats()
2272 dev->stats.rx_errors = le32_to_cpu(vals[0]) + le32_to_cpu(vals[2]) + in airo_read_stats()
2274 dev->stats.tx_errors = le32_to_cpu(vals[42]) + in airo_read_stats()
2275 dev->stats.tx_fifo_errors; in airo_read_stats()
2276 dev->stats.multicast = le32_to_cpu(vals[43]); in airo_read_stats()
2277 dev->stats.collisions = le32_to_cpu(vals[89]); in airo_read_stats()
2280 dev->stats.rx_length_errors = le32_to_cpu(vals[3]); in airo_read_stats()
2281 dev->stats.rx_crc_errors = le32_to_cpu(vals[4]); in airo_read_stats()
2282 dev->stats.rx_frame_errors = le32_to_cpu(vals[2]); in airo_read_stats()
2283 dev->stats.rx_fifo_errors = le32_to_cpu(vals[0]); in airo_read_stats()
2288 struct airo_info *local = dev->ml_priv; in airo_get_stats()
2290 if (!test_bit(JOB_STATS, &local->jobs)) { in airo_get_stats()
2292 if (down_trylock(&local->sem) != 0) { in airo_get_stats()
2293 set_bit(JOB_STATS, &local->jobs); in airo_get_stats()
2294 wake_up_interruptible(&local->thr_wait); in airo_get_stats()
2299 return &dev->stats; in airo_get_stats()
2309 clear_bit(JOB_PROMISC, &ai->jobs); in airo_set_promisc()
2310 cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; in airo_set_promisc()
2312 up(&ai->sem); in airo_set_promisc()
2317 struct airo_info *ai = dev->ml_priv; in airo_set_multicast_list()
2319 if ((dev->flags ^ ai->flags) & IFF_PROMISC) { in airo_set_multicast_list()
2320 change_bit(FLAG_PROMISC, &ai->flags); in airo_set_multicast_list()
2321 if (down_trylock(&ai->sem) != 0) { in airo_set_multicast_list()
2322 set_bit(JOB_PROMISC, &ai->jobs); in airo_set_multicast_list()
2323 wake_up_interruptible(&ai->thr_wait); in airo_set_multicast_list()
2328 if ((dev->flags&IFF_ALLMULTI) || !netdev_mc_empty(dev)) { in airo_set_multicast_list()
2335 struct airo_info *ai = dev->ml_priv; in airo_set_mac_address()
2339 memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); in airo_set_mac_address()
2340 set_bit (FLAG_COMMIT, &ai->flags); in airo_set_mac_address()
2344 memcpy (ai->dev->dev_addr, addr->sa_data, dev->addr_len); in airo_set_mac_address()
2345 if (ai->wifidev) in airo_set_mac_address()
2346 memcpy (ai->wifidev->dev_addr, addr->sa_data, dev->addr_len); in airo_set_mac_address()
2354 /* Upper layers already keep track of PCI devices, in add_airo_dev()
2355 * so we only need to remember our non-PCI cards. */ in add_airo_dev()
2356 if (!ai->pci) in add_airo_dev()
2357 list_add_tail(&ai->dev_list, &airo_devices); in add_airo_dev()
2362 if (!ai->pci) in del_airo_dev()
2363 list_del(&ai->dev_list); in del_airo_dev()
2368 struct airo_info *ai = dev->ml_priv; in airo_close()
2372 if (ai->wifidev != dev) { in airo_close()
2379 set_bit(FLAG_RADIO_DOWN, &ai->flags); in airo_close()
2384 free_irq(dev->irq, dev); in airo_close()
2386 set_bit(JOB_DIE, &ai->jobs); in airo_close()
2387 kthread_stop(ai->airo_thread_task); in airo_close()
2394 struct airo_info *ai = dev->ml_priv; in stop_airo_card()
2396 set_bit(FLAG_RADIO_DOWN, &ai->flags); in stop_airo_card()
2400 if (test_bit(FLAG_REGISTERED, &ai->flags)) { in stop_airo_card()
2402 if (ai->wifidev) { in stop_airo_card()
2403 unregister_netdev(ai->wifidev); in stop_airo_card()
2404 free_netdev(ai->wifidev); in stop_airo_card()
2405 ai->wifidev = NULL; in stop_airo_card()
2407 clear_bit(FLAG_REGISTERED, &ai->flags); in stop_airo_card()
2412 if (test_bit(FLAG_MPI, &ai->flags) && !skb_queue_empty(&ai->txq)) { in stop_airo_card()
2414 for (;(skb = skb_dequeue(&ai->txq));) in stop_airo_card()
2420 kfree(ai->flash); in stop_airo_card()
2421 kfree(ai->rssi); in stop_airo_card()
2422 kfree(ai->SSID); in stop_airo_card()
2424 /* PCMCIA frees this stuff, so only for PCI and ISA */ in stop_airo_card()
2425 release_region(dev->base_addr, 64); in stop_airo_card()
2426 if (test_bit(FLAG_MPI, &ai->flags)) { in stop_airo_card()
2427 if (ai->pci) in stop_airo_card()
2428 mpi_unmap_card(ai->pci); in stop_airo_card()
2429 if (ai->pcimem) in stop_airo_card()
2430 iounmap(ai->pcimem); in stop_airo_card()
2431 if (ai->pciaux) in stop_airo_card()
2432 iounmap(ai->pciaux); in stop_airo_card()
2433 dma_free_coherent(&ai->pci->dev, PCI_SHARED_LEN, in stop_airo_card()
2434 ai->shared, ai->shared_dma); in stop_airo_card()
2437 crypto_free_sync_skcipher(ai->tfm); in stop_airo_card()
2450 static void mpi_unmap_card(struct pci_dev *pci) in mpi_unmap_card() argument
2452 unsigned long mem_start = pci_resource_start(pci, 1); in mpi_unmap_card()
2453 unsigned long mem_len = pci_resource_len(pci, 1); in mpi_unmap_card()
2454 unsigned long aux_start = pci_resource_start(pci, 2); in mpi_unmap_card()
2476 netif_stop_queue(ai->dev); in mpi_init_descriptors()
2483 cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); in mpi_init_descriptors()
2487 airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); in mpi_init_descriptors()
2492 memcpy_toio(ai->rxfids[i].card_ram_off, in mpi_init_descriptors()
2493 &ai->rxfids[i].rx_desc, sizeof(RxFid)); in mpi_init_descriptors()
2503 cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux); in mpi_init_descriptors()
2507 ai->txfids[i].tx_desc.valid = 1; in mpi_init_descriptors()
2508 memcpy_toio(ai->txfids[i].card_ram_off, in mpi_init_descriptors()
2509 &ai->txfids[i].tx_desc, sizeof(TxFid)); in mpi_init_descriptors()
2511 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ in mpi_init_descriptors()
2515 airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); in mpi_init_descriptors()
2525 cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); in mpi_init_descriptors()
2529 airo_print_err(ai->dev->name, "Couldn't allocate RID"); in mpi_init_descriptors()
2533 memcpy_toio(ai->config_desc.card_ram_off, in mpi_init_descriptors()
2534 &ai->config_desc.rid_desc, sizeof(Rid)); in mpi_init_descriptors()
2542 * 2) Map PCI memory for issuing commands.
2545 static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) in mpi_map_card() argument
2548 int rc = -1; in mpi_map_card()
2554 mem_start = pci_resource_start(pci, 1); in mpi_map_card()
2555 mem_len = pci_resource_len(pci, 1); in mpi_map_card()
2556 aux_start = pci_resource_start(pci, 2); in mpi_map_card()
2570 ai->pcimem = ioremap(mem_start, mem_len); in mpi_map_card()
2571 if (!ai->pcimem) { in mpi_map_card()
2576 ai->pciaux = ioremap(aux_start, aux_len); in mpi_map_card()
2577 if (!ai->pciaux) { in mpi_map_card()
2584 ai->shared = dma_alloc_coherent(&pci->dev, PCI_SHARED_LEN, in mpi_map_card()
2585 &ai->shared_dma, GFP_KERNEL); in mpi_map_card()
2586 if (!ai->shared) { in mpi_map_card()
2595 busaddroff = ai->shared_dma; in mpi_map_card()
2596 pciaddroff = ai->pciaux + AUX_OFFSET; in mpi_map_card()
2597 vpackoff = ai->shared; in mpi_map_card()
2601 ai->rxfids[i].pending = 0; in mpi_map_card()
2602 ai->rxfids[i].card_ram_off = pciaddroff; in mpi_map_card()
2603 ai->rxfids[i].virtual_host_addr = vpackoff; in mpi_map_card()
2604 ai->rxfids[i].rx_desc.host_addr = busaddroff; in mpi_map_card()
2605 ai->rxfids[i].rx_desc.valid = 1; in mpi_map_card()
2606 ai->rxfids[i].rx_desc.len = PKTSIZE; in mpi_map_card()
2607 ai->rxfids[i].rx_desc.rdy = 0; in mpi_map_card()
2616 ai->txfids[i].card_ram_off = pciaddroff; in mpi_map_card()
2617 ai->txfids[i].virtual_host_addr = vpackoff; in mpi_map_card()
2618 ai->txfids[i].tx_desc.valid = 1; in mpi_map_card()
2619 ai->txfids[i].tx_desc.host_addr = busaddroff; in mpi_map_card()
2620 memcpy(ai->txfids[i].virtual_host_addr, in mpi_map_card()
2627 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ in mpi_map_card()
2630 ai->config_desc.card_ram_off = pciaddroff; in mpi_map_card()
2631 ai->config_desc.virtual_host_addr = vpackoff; in mpi_map_card()
2632 ai->config_desc.rid_desc.host_addr = busaddroff; in mpi_map_card()
2633 ai->ridbus = busaddroff; in mpi_map_card()
2634 ai->config_desc.rid_desc.rid = 0; in mpi_map_card()
2635 ai->config_desc.rid_desc.len = RIDSIZE; in mpi_map_card()
2636 ai->config_desc.rid_desc.valid = 1; in mpi_map_card()
2647 dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared, in mpi_map_card()
2648 ai->shared_dma); in mpi_map_card()
2650 iounmap(ai->pciaux); in mpi_map_card()
2652 iounmap(ai->pcimem); in mpi_map_card()
2676 dev->netdev_ops = &airo11_netdev_ops; in wifi_setup()
2677 dev->header_ops = &airo_header_ops; in wifi_setup()
2678 dev->wireless_handlers = &airo_handler_def; in wifi_setup()
2680 dev->type = ARPHRD_IEEE80211; in wifi_setup()
2681 dev->hard_header_len = ETH_HLEN; in wifi_setup()
2682 dev->mtu = AIRO_DEF_MTU; in wifi_setup()
2683 dev->min_mtu = 68; in wifi_setup()
2684 dev->max_mtu = MIC_MSGLEN_MAX; in wifi_setup()
2685 dev->addr_len = ETH_ALEN; in wifi_setup()
2686 dev->tx_queue_len = 100; in wifi_setup()
2688 eth_broadcast_addr(dev->broadcast); in wifi_setup()
2690 dev->flags = IFF_BROADCAST|IFF_MULTICAST; in wifi_setup()
2701 dev->ml_priv = ethdev->ml_priv; in init_wifidev()
2702 dev->irq = ethdev->irq; in init_wifidev()
2703 dev->base_addr = ethdev->base_addr; in init_wifidev()
2704 dev->wireless_data = ethdev->wireless_data; in init_wifidev()
2705 SET_NETDEV_DEV(dev, ethdev->dev.parent); in init_wifidev()
2717 struct airo_info *ai = dev->ml_priv; in reset_card()
2719 if (lock && down_interruptible(&ai->sem)) in reset_card()
2720 return -1; in reset_card()
2727 up(&ai->sem); in reset_card()
2734 if (ai->networks) in airo_networks_allocate()
2737 ai->networks = kcalloc(AIRO_MAX_NETWORK_COUNT, sizeof(BSSListElement), in airo_networks_allocate()
2739 if (!ai->networks) { in airo_networks_allocate()
2741 return -ENOMEM; in airo_networks_allocate()
2749 kfree(ai->networks); in airo_networks_free()
2750 ai->networks = NULL; in airo_networks_free()
2757 INIT_LIST_HEAD(&ai->network_free_list); in airo_networks_initialize()
2758 INIT_LIST_HEAD(&ai->network_list); in airo_networks_initialize()
2760 list_add_tail(&ai->networks[i].list, in airo_networks_initialize()
2761 &ai->network_free_list); in airo_networks_initialize()
2788 int is_pcmcia, struct pci_dev *pci, in _init_airo_card() argument
2803 ai = dev->ml_priv = netdev_priv(dev); in _init_airo_card()
2804 ai->wifidev = NULL; in _init_airo_card()
2805 ai->flags = 1 << FLAG_RADIO_DOWN; in _init_airo_card()
2806 ai->jobs = 0; in _init_airo_card()
2807 ai->dev = dev; in _init_airo_card()
2808 if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { in _init_airo_card()
2810 set_bit(FLAG_MPI, &ai->flags); in _init_airo_card()
2812 spin_lock_init(&ai->aux_lock); in _init_airo_card()
2813 sema_init(&ai->sem, 1); in _init_airo_card()
2814 ai->config.len = 0; in _init_airo_card()
2815 ai->pci = pci; in _init_airo_card()
2816 init_waitqueue_head (&ai->thr_wait); in _init_airo_card()
2817 ai->tfm = NULL; in _init_airo_card()
2819 ai->APList.len = cpu_to_le16(sizeof(struct APListRid)); in _init_airo_card()
2825 skb_queue_head_init (&ai->txq); in _init_airo_card()
2827 /* The Airo-specific entries in the device structure. */ in _init_airo_card()
2828 if (test_bit(FLAG_MPI,&ai->flags)) in _init_airo_card()
2829 dev->netdev_ops = &mpi_netdev_ops; in _init_airo_card()
2831 dev->netdev_ops = &airo_netdev_ops; in _init_airo_card()
2832 dev->wireless_handlers = &airo_handler_def; in _init_airo_card()
2833 ai->wireless_data.spy_data = &ai->spy_data; in _init_airo_card()
2834 dev->wireless_data = &ai->wireless_data; in _init_airo_card()
2835 dev->irq = irq; in _init_airo_card()
2836 dev->base_addr = port; in _init_airo_card()
2837 dev->priv_flags &= ~IFF_TX_SKB_SHARING; in _init_airo_card()
2838 dev->max_mtu = MIC_MSGLEN_MAX; in _init_airo_card()
2846 if (!request_region(dev->base_addr, 64, DRV_NAME)) { in _init_airo_card()
2847 rc = -EBUSY; in _init_airo_card()
2848 airo_print_err(dev->name, "Couldn't request region"); in _init_airo_card()
2853 if (test_bit(FLAG_MPI,&ai->flags)) { in _init_airo_card()
2854 if (mpi_map_card(ai, pci)) { in _init_airo_card()
2861 if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) { in _init_airo_card()
2862 airo_print_err(dev->name, "MAC could not be enabled"); in _init_airo_card()
2863 rc = -EIO; in _init_airo_card()
2866 } else if (!test_bit(FLAG_MPI,&ai->flags)) { in _init_airo_card()
2867 ai->bap_read = fast_bap_read; in _init_airo_card()
2868 set_bit(FLAG_FLASHING, &ai->flags); in _init_airo_card()
2871 strcpy(dev->name, "eth%d"); in _init_airo_card()
2874 airo_print_err(dev->name, "Couldn't register_netdev"); in _init_airo_card()
2877 ai->wifidev = init_wifidev(ai, dev); in _init_airo_card()
2878 if (!ai->wifidev) in _init_airo_card()
2883 rc = -EIO; in _init_airo_card()
2887 ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0; in _init_airo_card()
2888 ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0; in _init_airo_card()
2890 airo_print_info(dev->name, "Firmware version %x.%x.%02d", in _init_airo_card()
2900 airo_print_info(ai->dev->name, "WPA supported."); in _init_airo_card()
2902 set_bit(FLAG_WPA_CAPABLE, &ai->flags); in _init_airo_card()
2903 ai->bssListFirst = RID_WPA_BSSLISTFIRST; in _init_airo_card()
2904 ai->bssListNext = RID_WPA_BSSLISTNEXT; in _init_airo_card()
2905 ai->bssListRidLen = sizeof(BSSListRid); in _init_airo_card()
2907 airo_print_info(ai->dev->name, "WPA unsupported with firmware " in _init_airo_card()
2910 ai->bssListFirst = RID_BSSLISTFIRST; in _init_airo_card()
2911 ai->bssListNext = RID_BSSLISTNEXT; in _init_airo_card()
2912 ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); in _init_airo_card()
2915 set_bit(FLAG_REGISTERED,&ai->flags); in _init_airo_card()
2916 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr); in _init_airo_card()
2919 if (probe && !test_bit(FLAG_MPI,&ai->flags)) in _init_airo_card()
2921 ai->fids[i] = transmit_allocate(ai, AIRO_DEF_MTU, i>=MAX_FIDS/2); in _init_airo_card()
2923 if (setup_proc_entry(dev, dev->ml_priv) < 0) in _init_airo_card()
2929 unregister_netdev(ai->wifidev); in _init_airo_card()
2930 free_netdev(ai->wifidev); in _init_airo_card()
2934 if (test_bit(FLAG_MPI,&ai->flags) && pci) { in _init_airo_card()
2935 dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared, in _init_airo_card()
2936 ai->shared_dma); in _init_airo_card()
2937 iounmap(ai->pciaux); in _init_airo_card()
2938 iounmap(ai->pcimem); in _init_airo_card()
2939 mpi_unmap_card(ai->pci); in _init_airo_card()
2943 release_region(dev->base_addr, 64); in _init_airo_card()
2974 struct airo_info *ai = dev->ml_priv; in reset_airo_card()
2977 return -1; in reset_airo_card()
2979 if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) { in reset_airo_card()
2980 airo_print_err(dev->name, "MAC could not be enabled"); in reset_airo_card()
2981 return -1; in reset_airo_card()
2983 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr); in reset_airo_card()
2985 if (!test_bit(FLAG_MPI,&ai->flags)) in reset_airo_card()
2987 ai->fids[i] = transmit_allocate (ai, AIRO_DEF_MTU, i>=MAX_FIDS/2); in reset_airo_card()
2998 struct airo_info *ai = dev->ml_priv; in airo_send_event()
3002 clear_bit(JOB_EVENT, &ai->jobs); in airo_send_event()
3004 up(&ai->sem); in airo_send_event()
3023 list_for_each_entry_safe (loop_net, tmp_net, &ai->network_list, list) { in airo_process_scan_results()
3024 list_move_tail (&loop_net->list, &ai->network_free_list); in airo_process_scan_results()
3025 /* Don't blow away ->list, just BSS data */ in airo_process_scan_results()
3026 memset (loop_net, 0, sizeof (loop_net->bss)); in airo_process_scan_results()
3030 rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0); in airo_process_scan_results()
3040 if (!list_empty(&ai->network_free_list)) { in airo_process_scan_results()
3041 tmp_net = list_entry(ai->network_free_list.next, in airo_process_scan_results()
3043 list_del(ai->network_free_list.next); in airo_process_scan_results()
3047 memcpy(tmp_net, &bss, sizeof(tmp_net->bss)); in airo_process_scan_results()
3048 list_add_tail(&tmp_net->list, &ai->network_list); in airo_process_scan_results()
3053 rc = PC4500_readrid(ai, ai->bssListNext, in airo_process_scan_results()
3054 &bss, ai->bssListRidLen, 0); in airo_process_scan_results()
3060 writeAPListRid(ai, &ai->APList, 0); in airo_process_scan_results()
3063 ai->scan_timeout = 0; in airo_process_scan_results()
3064 clear_bit(JOB_SCAN_RESULTS, &ai->jobs); in airo_process_scan_results()
3065 up(&ai->sem); in airo_process_scan_results()
3073 * extract the data - Jean II */ in airo_process_scan_results()
3076 wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL); in airo_process_scan_results()
3082 struct airo_info *ai = dev->ml_priv; in airo_thread()
3090 if (test_bit(JOB_DIE, &ai->jobs)) in airo_thread()
3093 if (ai->jobs) { in airo_thread()
3094 locked = down_interruptible(&ai->sem); in airo_thread()
3099 add_wait_queue(&ai->thr_wait, &wait); in airo_thread()
3102 if (ai->jobs) in airo_thread()
3104 if (ai->expires || ai->scan_timeout) { in airo_thread()
3105 if (ai->scan_timeout && in airo_thread()
3106 time_after_eq(jiffies, ai->scan_timeout)) { in airo_thread()
3107 set_bit(JOB_SCAN_RESULTS, &ai->jobs); in airo_thread()
3109 } else if (ai->expires && in airo_thread()
3110 time_after_eq(jiffies, ai->expires)) { in airo_thread()
3111 set_bit(JOB_AUTOWEP, &ai->jobs); in airo_thread()
3117 if (!ai->expires || !ai->scan_timeout) { in airo_thread()
3118 wake_at = max(ai->expires, in airo_thread()
3119 ai->scan_timeout); in airo_thread()
3121 wake_at = min(ai->expires, in airo_thread()
3122 ai->scan_timeout); in airo_thread()
3124 schedule_timeout(wake_at - jiffies); in airo_thread()
3135 remove_wait_queue(&ai->thr_wait, &wait); in airo_thread()
3142 if (test_bit(JOB_DIE, &ai->jobs)) { in airo_thread()
3143 up(&ai->sem); in airo_thread()
3147 if (ai->power.event || test_bit(FLAG_FLASHING, &ai->flags)) { in airo_thread()
3148 up(&ai->sem); in airo_thread()
3152 if (test_bit(JOB_XMIT, &ai->jobs)) in airo_thread()
3154 else if (test_bit(JOB_XMIT11, &ai->jobs)) in airo_thread()
3156 else if (test_bit(JOB_STATS, &ai->jobs)) in airo_thread()
3158 else if (test_bit(JOB_WSTATS, &ai->jobs)) in airo_thread()
3160 else if (test_bit(JOB_PROMISC, &ai->jobs)) in airo_thread()
3162 else if (test_bit(JOB_MIC, &ai->jobs)) in airo_thread()
3164 else if (test_bit(JOB_EVENT, &ai->jobs)) in airo_thread()
3166 else if (test_bit(JOB_AUTOWEP, &ai->jobs)) in airo_thread()
3168 else if (test_bit(JOB_SCAN_RESULTS, &ai->jobs)) in airo_thread()
3171 up(&ai->sem); in airo_thread()
3183 return 10; /* one-address control packet */ in header_len()
3184 return 16; /* two-address control packet */ in header_len()
3194 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags)) { in airo_handle_cisco_mic()
3195 set_bit(JOB_MIC, &ai->jobs); in airo_handle_cisco_mic()
3196 wake_up_interruptible(&ai->thr_wait); in airo_handle_cisco_mic()
3201 #define STAT_NOBEACON 0x8000 /* Loss of sync - missed beacons */
3202 #define STAT_MAXRETRIES 0x8001 /* Loss of sync - max retries */
3203 #define STAT_MAXARL 0x8002 /* Loss of sync - average retry level exceeded*/
3204 #define STAT_FORCELOSS 0x8003 /* Loss of sync - host request */
3205 #define STAT_TSFSYNC 0x8004 /* Loss of sync - TSF synchronization */
3271 if ((status == STAT_FORCELOSS) && (ai->scan_timeout > 0)) in airo_handle_link()
3274 airo_print_status(ai->dev->name, status); in airo_handle_link()
3278 ai->expires = 0; in airo_handle_link()
3279 if (ai->list_bss_task) in airo_handle_link()
3280 wake_up_process(ai->list_bss_task); in airo_handle_link()
3281 set_bit(FLAG_UPDATE_UNI, &ai->flags); in airo_handle_link()
3282 set_bit(FLAG_UPDATE_MULTI, &ai->flags); in airo_handle_link()
3284 if (down_trylock(&ai->sem) != 0) { in airo_handle_link()
3285 set_bit(JOB_EVENT, &ai->jobs); in airo_handle_link()
3286 wake_up_interruptible(&ai->thr_wait); in airo_handle_link()
3288 airo_send_event(ai->dev); in airo_handle_link()
3289 netif_carrier_on(ai->dev); in airo_handle_link()
3291 if (auto_wep && !ai->expires) { in airo_handle_link()
3292 ai->expires = RUN_AT(3*HZ); in airo_handle_link()
3293 wake_up_interruptible(&ai->thr_wait); in airo_handle_link()
3299 wireless_send_event(ai->dev, SIOCGIWAP, &wrqu, NULL); in airo_handle_link()
3300 netif_carrier_off(ai->dev); in airo_handle_link()
3302 netif_carrier_off(ai->dev); in airo_handle_link()
3314 if (test_bit(FLAG_MPI, &ai->flags)) { in airo_handle_rx()
3315 if (test_bit(FLAG_802_11, &ai->flags)) in airo_handle_rx()
3326 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3332 if (ai->wifidev == NULL) in airo_handle_rx()
3341 airo_print_err(ai->dev->name, "Bad size %d", len); in airo_handle_rx()
3347 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3355 ai->dev->stats.rx_dropped++; in airo_handle_rx()
3361 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3363 bap_read(ai, buffer + 1, hdrlen - 2, BAP0); in airo_handle_rx()
3373 airo_print_err(ai->dev->name, "gaplen too " in airo_handle_rx()
3382 if (ai->micstats.enabled) { in airo_handle_rx()
3392 len -= sizeof(micbuf); in airo_handle_rx()
3405 if (success && (ai->spy_data.spy_number > 0)) { in airo_handle_rx()
3410 if (!test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3417 if (ai->rssi) in airo_handle_rx()
3418 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; in airo_handle_rx()
3421 wstats.noise = ai->wstats.qual.noise; in airo_handle_rx()
3426 wireless_spy_update(ai->dev, sa, &wstats); in airo_handle_rx()
3434 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3436 skb->pkt_type = PACKET_OTHERHOST; in airo_handle_rx()
3437 skb->dev = ai->wifidev; in airo_handle_rx()
3438 skb->protocol = htons(ETH_P_802_2); in airo_handle_rx()
3440 skb->protocol = eth_type_trans(skb, ai->dev); in airo_handle_rx()
3441 skb->ip_summed = CHECKSUM_NONE; in airo_handle_rx()
3449 int i, index = -1; in airo_handle_tx()
3452 if (test_bit(FLAG_MPI, &ai->flags)) { in airo_handle_tx()
3456 get_tx_error(ai, -1); in airo_handle_tx()
3458 spin_lock_irqsave(&ai->aux_lock, flags); in airo_handle_tx()
3459 if (!skb_queue_empty(&ai->txq)) { in airo_handle_tx()
3460 spin_unlock_irqrestore(&ai->aux_lock, flags); in airo_handle_tx()
3461 mpi_send_packet(ai->dev); in airo_handle_tx()
3463 clear_bit(FLAG_PENDING_XMIT, &ai->flags); in airo_handle_tx()
3464 spin_unlock_irqrestore(&ai->aux_lock, flags); in airo_handle_tx()
3465 netif_wake_queue(ai->dev); in airo_handle_tx()
3474 if ((ai->fids[i] & 0xffff) == fid) in airo_handle_tx()
3478 if (index != -1) { in airo_handle_tx()
3485 ai->fids[index] &= 0xffff; in airo_handle_tx()
3487 if (!test_bit(FLAG_PENDING_XMIT, &ai->flags)) in airo_handle_tx()
3488 netif_wake_queue(ai->dev); in airo_handle_tx()
3490 if (!test_bit(FLAG_PENDING_XMIT11, &ai->flags)) in airo_handle_tx()
3491 netif_wake_queue(ai->wifidev); in airo_handle_tx()
3495 airo_print_err(ai->dev->name, "Unallocated FID was used to xmit"); in airo_handle_tx()
3503 struct airo_info *ai = dev->ml_priv; in airo_interrupt()
3545 airo_print_warn(ai->dev->name, "Got weird status %x", in airo_interrupt()
3567 if (test_bit(FLAG_MPI,&ai->flags)) in OUT4500()
3570 outw(val, ai->dev->base_addr + reg); in OUT4500()
3572 outb(val & 0xff, ai->dev->base_addr + reg); in OUT4500()
3573 outb(val >> 8, ai->dev->base_addr + reg + 1); in OUT4500()
3581 if (test_bit(FLAG_MPI,&ai->flags)) in IN4500()
3584 rc = inw(ai->dev->base_addr + reg); in IN4500()
3586 rc = inb(ai->dev->base_addr + reg); in IN4500()
3587 rc += ((int)inb(ai->dev->base_addr + reg + 1)) << 8; in IN4500()
3603 * "cheaper" - Jean II */ in enable_MAC()
3604 if (ai->flags & FLAG_RADIO_MASK) return SUCCESS; in enable_MAC()
3606 if (lock && down_interruptible(&ai->sem)) in enable_MAC()
3607 return -ERESTARTSYS; in enable_MAC()
3609 if (!test_bit(FLAG_ENABLED, &ai->flags)) { in enable_MAC()
3614 set_bit(FLAG_ENABLED, &ai->flags); in enable_MAC()
3619 up(&ai->sem); in enable_MAC()
3622 airo_print_err(ai->dev->name, "Cannot enable MAC"); in enable_MAC()
3624 airo_print_err(ai->dev->name, "Bad MAC enable reason=%x, " in enable_MAC()
3636 if (lock == 1 && down_interruptible(&ai->sem)) in disable_MAC()
3639 if (test_bit(FLAG_ENABLED, &ai->flags)) { in disable_MAC()
3641 netif_carrier_off(ai->dev); in disable_MAC()
3645 clear_bit(FLAG_ENABLED, &ai->flags); in disable_MAC()
3648 up(&ai->sem); in disable_MAC()
3671 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); in mpi_receive_802_3()
3680 ai->dev->stats.rx_dropped++; in mpi_receive_802_3()
3684 memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2); in mpi_receive_802_3()
3685 if (ai->micstats.enabled) { in mpi_receive_802_3()
3687 ai->rxfids[0].virtual_host_addr + ETH_ALEN * 2, in mpi_receive_802_3()
3694 skb_trim (skb, len - off); in mpi_receive_802_3()
3698 ai->rxfids[0].virtual_host_addr + ETH_ALEN * 2 + off, in mpi_receive_802_3()
3699 len - ETH_ALEN * 2 - off); in mpi_receive_802_3()
3700 if (decapsulate (ai, &micbuf, (etherHead*)buffer, len - off - ETH_ALEN * 2)) { in mpi_receive_802_3()
3706 if (ai->spy_data.spy_number > 0) { in mpi_receive_802_3()
3715 wireless_spy_update(ai->dev, sa, &wstats); in mpi_receive_802_3()
3719 skb->ip_summed = CHECKSUM_NONE; in mpi_receive_802_3()
3720 skb->protocol = eth_type_trans(skb, ai->dev); in mpi_receive_802_3()
3728 memcpy_toio(ai->rxfids[0].card_ram_off, &rxd, sizeof(rxd)); in mpi_receive_802_3()
3741 char *ptr = ai->rxfids[0].virtual_host_addr + 4; in mpi_receive_802_11()
3743 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); in mpi_receive_802_11()
3749 if (ai->wifidev == NULL) in mpi_receive_802_11()
3753 airo_print_err(ai->dev->name, "Bad size %d", len); in mpi_receive_802_11()
3764 ai->dev->stats.rx_dropped++; in mpi_receive_802_11()
3778 airo_print_err(ai->dev->name, in mpi_receive_802_11()
3784 if (ai->spy_data.spy_number > 0) { in mpi_receive_802_11()
3790 if (ai->rssi) in mpi_receive_802_11()
3791 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; in mpi_receive_802_11()
3794 wstats.noise = ai->wstats.qual.noise; in mpi_receive_802_11()
3799 wireless_spy_update(ai->dev, sa, &wstats); in mpi_receive_802_11()
3803 skb->pkt_type = PACKET_OTHERHOST; in mpi_receive_802_11()
3804 skb->dev = ai->wifidev; in mpi_receive_802_11()
3805 skb->protocol = htons(ETH_P_802_2); in mpi_receive_802_11()
3806 skb->ip_summed = CHECKSUM_NONE; in mpi_receive_802_11()
3814 memcpy_toio(ai->rxfids[0].card_ram_off, &rxd, sizeof(rxd)); in mpi_receive_802_11()
3820 local->config.authType = auth_type; in set_auth_type()
3825 local->last_auth = auth_type; in set_auth_type()
3839 kfree (ai->flash); in setup_card()
3840 ai->flash = NULL; in setup_card()
3845 if (lock && down_interruptible(&ai->sem)) in setup_card()
3849 up(&ai->sem); in setup_card()
3855 if (!test_bit(FLAG_MPI,&ai->flags)) { in setup_card()
3859 up(&ai->sem); in setup_card()
3860 airo_print_err(ai->dev->name, "Error checking for AUX port"); in setup_card()
3864 ai->bap_read = fast_bap_read; in setup_card()
3865 airo_print_dbg(ai->dev->name, "Doing fast bap_reads"); in setup_card()
3867 ai->bap_read = aux_bap_read; in setup_card()
3868 airo_print_dbg(ai->dev->name, "Doing AUX bap_reads"); in setup_card()
3872 up(&ai->sem); in setup_card()
3873 if (ai->config.len == 0) { in setup_card()
3878 kfree(ai->SSID); in setup_card()
3879 ai->SSID = NULL; in setup_card()
3889 if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) in setup_card()
3890 memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ in setup_card()
3893 kfree(ai->rssi); in setup_card()
3894 ai->rssi = NULL; in setup_card()
3896 ai->config.rmode |= RXMODE_NORMALIZED_RSSI; in setup_card()
3898 airo_print_warn(ai->dev->name, "unknown received signal " in setup_card()
3901 ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS; in setup_card()
3903 ai->config.modulation = MOD_CCK; in setup_card()
3908 ai->config.opmode |= MODE_MIC; in setup_card()
3909 set_bit(FLAG_MIC_CAPABLE, &ai->flags); in setup_card()
3914 mac[i] = ai->config.macAddr[i]; in setup_card()
3920 memset(ai->config.rates, 0, sizeof(ai->config.rates)); in setup_card()
3922 ai->config.rates[i] = rates[i]; in setup_card()
3925 set_bit (FLAG_COMMIT, &ai->flags); in setup_card()
3959 ai->defindex = wkr.mac[0]; in setup_card()
3977 OUT4500(ai, PARAM0, pCmd->parm0); in issuecommand()
3978 OUT4500(ai, PARAM1, pCmd->parm1); in issuecommand()
3979 OUT4500(ai, PARAM2, pCmd->parm2); in issuecommand()
3980 OUT4500(ai, COMMAND, pCmd->cmd); in issuecommand()
3982 while (max_tries-- && (IN4500(ai, EVSTAT) & EV_CMD) == 0) { in issuecommand()
3983 if ((IN4500(ai, COMMAND)) == pCmd->cmd) in issuecommand()
3985 OUT4500(ai, COMMAND, pCmd->cmd); in issuecommand()
3990 if (max_tries == -1) { in issuecommand()
3991 airo_print_err(ai->dev->name, in issuecommand()
3999 pRsp->status = IN4500(ai, STATUS); in issuecommand()
4000 pRsp->rsp0 = IN4500(ai, RESP0); in issuecommand()
4001 pRsp->rsp1 = IN4500(ai, RESP1); in issuecommand()
4002 pRsp->rsp2 = IN4500(ai, RESP2); in issuecommand()
4003 if ((pRsp->status & 0xff00)!=0 && pCmd->cmd != CMD_SOFTRESET) in issuecommand()
4004 airo_print_err(ai->dev->name, in issuecommand()
4006 pCmd->cmd, pRsp->status, pRsp->rsp0, pRsp->rsp1, in issuecommand()
4007 pRsp->rsp2); in issuecommand()
4034 if (timeout--) { in bap_setup()
4039 airo_print_err(ai->dev->name, "BAP error %x %d", in bap_setup()
4045 if (!(max_tries--)) { in bap_setup()
4046 airo_print_err(ai->dev->name, in bap_setup()
4050 // -- PC4500 missed it, try again in bap_setup()
4085 spin_lock_irqsave(&ai->aux_lock, flags); in aux_bap_read()
4093 count = (len>>1) < (words-i) ? (len>>1) : (words-i); in aux_bap_read()
4095 insw(ai->dev->base_addr+DATA0+whichbap, in aux_bap_read()
4098 insb(ai->dev->base_addr+DATA0+whichbap, in aux_bap_read()
4105 spin_unlock_irqrestore(&ai->aux_lock, flags); in aux_bap_read()
4116 insw(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1); in fast_bap_read()
4118 insb(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen); in fast_bap_read()
4128 outsw(ai->dev->base_addr+DATA0+whichbap, in bap_write()
4131 outsb(ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen); in bap_write()
4160 if (down_interruptible(&ai->sem)) in PC4500_readrid()
4163 if (test_bit(FLAG_MPI,&ai->flags)) { in PC4500_readrid()
4169 ai->config_desc.rid_desc.valid = 1; in PC4500_readrid()
4170 ai->config_desc.rid_desc.len = RIDSIZE; in PC4500_readrid()
4171 ai->config_desc.rid_desc.rid = 0; in PC4500_readrid()
4172 ai->config_desc.rid_desc.host_addr = ai->ridbus; in PC4500_readrid()
4177 memcpy_toio(ai->config_desc.card_ram_off, in PC4500_readrid()
4178 &ai->config_desc.rid_desc, sizeof(Rid)); in PC4500_readrid()
4185 memcpy(pBuf, ai->config_desc.virtual_host_addr, len); in PC4500_readrid()
4199 len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2; in PC4500_readrid()
4202 airo_print_err(ai->dev->name, in PC4500_readrid()
4213 up(&ai->sem); in PC4500_readrid()
4228 if (down_interruptible(&ai->sem)) in PC4500_writerid()
4231 if (test_bit(FLAG_MPI,&ai->flags)) { in PC4500_writerid()
4235 if (test_bit(FLAG_ENABLED, &ai->flags) && (RID_WEP_TEMP != rid)) in PC4500_writerid()
4236 airo_print_err(ai->dev->name, in PC4500_writerid()
4242 ai->config_desc.rid_desc.valid = 1; in PC4500_writerid()
4243 ai->config_desc.rid_desc.len = *((u16 *)pBuf); in PC4500_writerid()
4244 ai->config_desc.rid_desc.rid = 0; in PC4500_writerid()
4249 memcpy_toio(ai->config_desc.card_ram_off, in PC4500_writerid()
4250 &ai->config_desc.rid_desc, sizeof(Rid)); in PC4500_writerid()
4253 airo_print_err(ai->dev->name, "%s: len=%d", __func__, len); in PC4500_writerid()
4254 rc = -1; in PC4500_writerid()
4256 memcpy(ai->config_desc.virtual_host_addr, in PC4500_writerid()
4261 airo_print_err(ai->dev->name, "%s: Write rid Error %d", in PC4500_writerid()
4263 airo_print_err(ai->dev->name, "%s: Cmd=%04x", in PC4500_writerid()
4271 // --- first access so that we can write the rid data in PC4500_writerid()
4276 // --- now write the rid data in PC4500_writerid()
4282 // ---now commit the rid data in PC4500_writerid()
4287 up(&ai->sem); in PC4500_writerid()
4303 if (down_interruptible(&ai->sem)) in transmit_allocate()
4316 while (((IN4500(ai, EVSTAT) & EV_ALLOC) == 0) && --loop); in transmit_allocate()
4343 up(&ai->sem); in transmit_allocate()
4363 airo_print_warn(ai->dev->name, "Short packet %d", len); in transmit_802_3_packet()
4366 len -= ETH_ALEN * 2; in transmit_802_3_packet()
4368 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && in transmit_802_3_packet()
4374 // packet is destination[6], source[6], payload[len-12] in transmit_802_3_packet()
4400 static u8 tail[(30-10) + 2 + 6] = {[30-10] = 6}; in transmit_802_11_packet()
4409 airo_print_warn(ai->dev->name, "Short packet %d", len); in transmit_802_11_packet()
4418 payloadLen = cpu_to_le16(len-hdrlen); in transmit_802_11_packet()
4422 bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1); in transmit_802_11_packet()
4424 bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1); in transmit_802_11_packet()
4538 strcpy(apriv->proc_name, dev->name); in setup_proc_entry()
4539 apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm, in setup_proc_entry()
4541 if (!apriv->proc_entry) in setup_proc_entry()
4542 return -ENOMEM; in setup_proc_entry()
4543 proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid); in setup_proc_entry()
4547 apriv->proc_entry, &proc_statsdelta_ops, dev); in setup_proc_entry()
4554 apriv->proc_entry, &proc_stats_ops, dev); in setup_proc_entry()
4561 apriv->proc_entry, &proc_status_ops, dev); in setup_proc_entry()
4568 apriv->proc_entry, &proc_config_ops, dev); in setup_proc_entry()
4575 apriv->proc_entry, &proc_SSID_ops, dev); in setup_proc_entry()
4582 apriv->proc_entry, &proc_APList_ops, dev); in setup_proc_entry()
4589 apriv->proc_entry, &proc_BSSList_ops, dev); in setup_proc_entry()
4596 apriv->proc_entry, &proc_wepkey_ops, dev); in setup_proc_entry()
4603 remove_proc_subtree(apriv->proc_name, airo_entry); in setup_proc_entry()
4604 return -ENOMEM; in setup_proc_entry()
4610 remove_proc_subtree(apriv->proc_name, airo_entry); in takedown_proc_entry()
4623 * The read routine is generic, it relies on the preallocated rbuffer
4631 struct proc_data *priv = file->private_data; in proc_read()
4633 if (!priv->rbuffer) in proc_read()
4634 return -EINVAL; in proc_read()
4636 return simple_read_from_buffer(buffer, len, offset, priv->rbuffer, in proc_read()
4637 priv->readlen); in proc_read()
4641 * The write routine is generic, it fills in a preallocated rbuffer
4650 struct proc_data *priv = file->private_data; in proc_write()
4652 if (!priv->wbuffer) in proc_write()
4653 return -EINVAL; in proc_write()
4655 ret = simple_write_to_buffer(priv->wbuffer, priv->maxwritelen, offset, in proc_write()
4658 priv->writelen = max_t(int, priv->writelen, *offset); in proc_write()
4667 struct airo_info *apriv = dev->ml_priv; in proc_status_open()
4673 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_status_open()
4674 return -ENOMEM; in proc_status_open()
4675 data = file->private_data; in proc_status_open()
4676 if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) { in proc_status_open()
4677 kfree (file->private_data); in proc_status_open()
4678 return -ENOMEM; in proc_status_open()
4686 i = sprintf(data->rbuffer, "Status: %s%s%s%s%s%s%s%s%s\n", in proc_status_open()
4696 sprintf(data->rbuffer+i, "Mode: %x\n" in proc_status_open()
4699 "SSID: %-.*s\n" in proc_status_open()
4700 "AP: %-.16s\n" in proc_status_open()
4726 data->readlen = strlen(data->rbuffer); in proc_status_open()
4734 if (file->f_mode&FMODE_WRITE) { in proc_statsdelta_open()
4751 struct airo_info *apriv = dev->ml_priv; in proc_stats_rid_open()
4757 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_stats_rid_open()
4758 return -ENOMEM; in proc_stats_rid_open()
4759 data = file->private_data; in proc_stats_rid_open()
4760 if ((data->rbuffer = kmalloc(4096, GFP_KERNEL)) == NULL) { in proc_stats_rid_open()
4761 kfree (file->private_data); in proc_stats_rid_open()
4762 return -ENOMEM; in proc_stats_rid_open()
4769 for (i = 0; statsLabels[i]!=(char *)-1 && i*4<len; i++) { in proc_stats_rid_open()
4772 airo_print_warn(apriv->dev->name, in proc_stats_rid_open()
4776 j+=sprintf(data->rbuffer+j, "%s: %u\n", statsLabels[i], in proc_stats_rid_open()
4780 airo_print_warn(apriv->dev->name, "Got a short rid"); in proc_stats_rid_open()
4782 data->readlen = j; in proc_stats_rid_open()
4794 value += buffer[*start] - '0'; in get_dec_u16()
4796 if (!valid) return -1; in get_dec_u16()
4806 return (le16_to_cpu(ai->config.rmode) & le16_to_cpu(RXMODE_MASK)) >= in sniffing_mode()
4812 struct proc_data *data = file->private_data; in proc_config_on_close()
4814 struct airo_info *ai = dev->ml_priv; in proc_config_on_close()
4817 if (!data->writelen) return; in proc_config_on_close()
4820 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4822 line = data->wbuffer; in proc_config_on_close()
4828 set_bit (FLAG_RESET, &ai->flags); in proc_config_on_close()
4829 ai->config.rmode &= ~RXMODE_FULL_MASK; in proc_config_on_close()
4830 clear_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4831 ai->config.opmode &= ~MODE_CFG_MASK; in proc_config_on_close()
4832 ai->config.scanMode = SCANMODE_ACTIVE; in proc_config_on_close()
4834 ai->config.opmode |= MODE_STA_IBSS; in proc_config_on_close()
4836 ai->config.opmode |= MODE_STA_ESS; in proc_config_on_close()
4838 ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; in proc_config_on_close()
4839 ai->config.scanMode = SCANMODE_PASSIVE; in proc_config_on_close()
4840 set_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4842 ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER; in proc_config_on_close()
4843 ai->config.scanMode = SCANMODE_PASSIVE; in proc_config_on_close()
4844 set_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4846 ai->config.rmode |= RXMODE_LANMON; in proc_config_on_close()
4848 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4855 set_bit (FLAG_RADIO_OFF, &ai->flags); in proc_config_on_close()
4857 clear_bit (FLAG_RADIO_OFF, &ai->flags); in proc_config_on_close()
4865 memset(ai->config.nodeName, 0, 16); in proc_config_on_close()
4868 ai->config.nodeName[j] = line[j]; in proc_config_on_close()
4870 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4877 ai->config.powerSaveMode = POWERSAVE_PSPCAM; in proc_config_on_close()
4878 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4880 ai->config.powerSaveMode = POWERSAVE_PSP; in proc_config_on_close()
4881 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4883 ai->config.powerSaveMode = POWERSAVE_CAM; in proc_config_on_close()
4884 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4891 while ((v = get_dec_u16(line, &i, 3))!=-1) { in proc_config_on_close()
4892 ai->config.rates[k++] = (u8)v; in proc_config_on_close()
4896 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4901 if (v != -1) { in proc_config_on_close()
4902 ai->config.channelSet = cpu_to_le16(v); in proc_config_on_close()
4903 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4909 if (v != -1) { in proc_config_on_close()
4910 ai->config.txPower = cpu_to_le16(v); in proc_config_on_close()
4911 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4926 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4933 ai->config.longRetryLimit = cpu_to_le16(v); in proc_config_on_close()
4934 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4941 ai->config.shortRetryLimit = cpu_to_le16(v); in proc_config_on_close()
4942 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4949 ai->config.rtsThres = cpu_to_le16(v); in proc_config_on_close()
4950 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4957 ai->config.txLifetime = cpu_to_le16(v); in proc_config_on_close()
4958 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4965 ai->config.rxLifetime = cpu_to_le16(v); in proc_config_on_close()
4966 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4968 ai->config.txDiversity = in proc_config_on_close()
4971 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4973 ai->config.rxDiversity = in proc_config_on_close()
4976 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4984 ai->config.fragThresh = cpu_to_le16(v); in proc_config_on_close()
4985 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4989 case 'd': ai->config.modulation = MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
4990 case 'c': ai->config.modulation = MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
4991 case 'm': ai->config.modulation = MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
4992 default: airo_print_warn(ai->dev->name, "Unknown modulation"); in proc_config_on_close()
4997 case 'a': ai->config.preamble = PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
4998 case 'l': ai->config.preamble = PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
4999 case 's': ai->config.preamble = PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5000 default: airo_print_warn(ai->dev->name, "Unknown preamble"); in proc_config_on_close()
5003 airo_print_warn(ai->dev->name, "Couldn't figure out %s", line); in proc_config_on_close()
5025 struct airo_info *ai = dev->ml_priv; in proc_config_open()
5029 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_config_open()
5030 return -ENOMEM; in proc_config_open()
5031 data = file->private_data; in proc_config_open()
5032 if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) { in proc_config_open()
5033 kfree (file->private_data); in proc_config_open()
5034 return -ENOMEM; in proc_config_open()
5036 if ((data->wbuffer = kzalloc(2048, GFP_KERNEL)) == NULL) { in proc_config_open()
5037 kfree (data->rbuffer); in proc_config_open()
5038 kfree (file->private_data); in proc_config_open()
5039 return -ENOMEM; in proc_config_open()
5041 data->maxwritelen = 2048; in proc_config_open()
5042 data->on_close = proc_config_on_close; in proc_config_open()
5046 mode = ai->config.opmode & MODE_CFG_MASK; in proc_config_open()
5047 i = sprintf(data->rbuffer, in proc_config_open()
5050 "NodeName: %-16s\n" in proc_config_open()
5056 mode == MODE_STA_ESS ? get_rmode(ai->config.rmode): in proc_config_open()
5059 test_bit(FLAG_RADIO_OFF, &ai->flags) ? "off" : "on", in proc_config_open()
5060 ai->config.nodeName, in proc_config_open()
5061 ai->config.powerSaveMode == POWERSAVE_CAM ? "CAM" : in proc_config_open()
5062 ai->config.powerSaveMode == POWERSAVE_PSP ? "PSP" : in proc_config_open()
5063 ai->config.powerSaveMode == POWERSAVE_PSPCAM ? "PSPCAM" : in proc_config_open()
5065 (int)ai->config.rates[0], in proc_config_open()
5066 (int)ai->config.rates[1], in proc_config_open()
5067 (int)ai->config.rates[2], in proc_config_open()
5068 (int)ai->config.rates[3], in proc_config_open()
5069 (int)ai->config.rates[4], in proc_config_open()
5070 (int)ai->config.rates[5], in proc_config_open()
5071 (int)ai->config.rates[6], in proc_config_open()
5072 (int)ai->config.rates[7], in proc_config_open()
5073 le16_to_cpu(ai->config.channelSet), in proc_config_open()
5074 le16_to_cpu(ai->config.txPower) in proc_config_open()
5076 sprintf(data->rbuffer + i, in proc_config_open()
5088 le16_to_cpu(ai->config.longRetryLimit), in proc_config_open()
5089 le16_to_cpu(ai->config.shortRetryLimit), in proc_config_open()
5090 le16_to_cpu(ai->config.rtsThres), in proc_config_open()
5091 le16_to_cpu(ai->config.txLifetime), in proc_config_open()
5092 le16_to_cpu(ai->config.rxLifetime), in proc_config_open()
5093 ai->config.txDiversity == 1 ? "left" : in proc_config_open()
5094 ai->config.txDiversity == 2 ? "right" : "both", in proc_config_open()
5095 ai->config.rxDiversity == 1 ? "left" : in proc_config_open()
5096 ai->config.rxDiversity == 2 ? "right" : "both", in proc_config_open()
5097 le16_to_cpu(ai->config.fragThresh), in proc_config_open()
5098 ai->config.authType == AUTH_ENCRYPT ? "encrypt" : in proc_config_open()
5099 ai->config.authType == AUTH_SHAREDKEY ? "shared" : "open", in proc_config_open()
5100 ai->config.modulation == MOD_DEFAULT ? "default" : in proc_config_open()
5101 ai->config.modulation == MOD_CCK ? "cck" : in proc_config_open()
5102 ai->config.modulation == MOD_MOK ? "mok" : "error", in proc_config_open()
5103 ai->config.preamble == PREAMBLE_AUTO ? "auto" : in proc_config_open()
5104 ai->config.preamble == PREAMBLE_LONG ? "long" : in proc_config_open()
5105 ai->config.preamble == PREAMBLE_SHORT ? "short" : "error" in proc_config_open()
5107 data->readlen = strlen(data->rbuffer); in proc_config_open()
5113 struct proc_data *data = file->private_data; in proc_SSID_on_close()
5115 struct airo_info *ai = dev->ml_priv; in proc_SSID_on_close()
5118 char *p = data->wbuffer; in proc_SSID_on_close()
5119 char *end = p + data->writelen; in proc_SSID_on_close()
5121 if (!data->writelen) in proc_SSID_on_close()
5149 struct proc_data *data = file->private_data; in proc_APList_on_close()
5151 struct airo_info *ai = dev->ml_priv; in proc_APList_on_close()
5152 APListRid *APList_rid = &ai->APList; in proc_APList_on_close()
5155 if (!data->writelen) return; in proc_APList_on_close()
5158 APList_rid->len = cpu_to_le16(sizeof(*APList_rid)); in proc_APList_on_close()
5160 for (i = 0; i < 4 && data->writelen >= (i + 1) * 6 * 3; i++) in proc_APList_on_close()
5161 mac_pton(data->wbuffer + i * 6 * 3, APList_rid->ap[i]); in proc_APList_on_close()
5180 /* Returns the WEP key at the specified index, or -1 if that key does
5191 return -1; in get_wep_key()
5201 return -1; in get_wep_key()
5203 return -1; in get_wep_key()
5214 return -1; in get_wep_tx_idx()
5221 return -1; in get_wep_tx_idx()
5223 return -1; in get_wep_tx_idx()
5234 return -1; in set_wep_key()
5260 ai->defindex = (char)index; in set_wep_tx_idx()
5275 struct airo_info *ai = dev->ml_priv; in proc_wepkey_on_close()
5283 data = file->private_data; in proc_wepkey_on_close()
5284 if (!data->writelen) return; in proc_wepkey_on_close()
5286 if (data->wbuffer[0] >= '0' && data->wbuffer[0] <= '3' && in proc_wepkey_on_close()
5287 (data->wbuffer[1] == ' ' || data->wbuffer[1] == '\n')) { in proc_wepkey_on_close()
5288 index = data->wbuffer[0] - '0'; in proc_wepkey_on_close()
5289 if (data->wbuffer[1] == '\n') { in proc_wepkey_on_close()
5292 airo_print_err(ai->dev->name, "failed to set " in proc_wepkey_on_close()
5300 airo_print_err(ai->dev->name, "WepKey passed invalid key index"); in proc_wepkey_on_close()
5304 for (i = 0; i < 16*3 && data->wbuffer[i+j]; i++) { in proc_wepkey_on_close()
5307 key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4; in proc_wepkey_on_close()
5310 key[i/3] |= hex_to_bin(data->wbuffer[i+j]); in proc_wepkey_on_close()
5317 airo_print_err(ai->dev->name, "failed to set WEP key at index " in proc_wepkey_on_close()
5326 struct airo_info *ai = dev->ml_priv; in proc_wepkey_open()
5333 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_wepkey_open()
5334 return -ENOMEM; in proc_wepkey_open()
5336 data = file->private_data; in proc_wepkey_open()
5337 if ((data->rbuffer = kzalloc(180, GFP_KERNEL)) == NULL) { in proc_wepkey_open()
5338 kfree (file->private_data); in proc_wepkey_open()
5339 return -ENOMEM; in proc_wepkey_open()
5341 data->writelen = 0; in proc_wepkey_open()
5342 data->maxwritelen = 80; in proc_wepkey_open()
5343 if ((data->wbuffer = kzalloc(80, GFP_KERNEL)) == NULL) { in proc_wepkey_open()
5344 kfree (data->rbuffer); in proc_wepkey_open()
5345 kfree (file->private_data); in proc_wepkey_open()
5346 return -ENOMEM; in proc_wepkey_open()
5348 data->on_close = proc_wepkey_on_close; in proc_wepkey_open()
5350 ptr = data->rbuffer; in proc_wepkey_open()
5364 } while ((lastindex != wkr.kindex) && (j < 180-30)); in proc_wepkey_open()
5366 data->readlen = strlen(data->rbuffer); in proc_wepkey_open()
5374 struct airo_info *ai = dev->ml_priv; in proc_SSID_open()
5379 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_SSID_open()
5380 return -ENOMEM; in proc_SSID_open()
5381 data = file->private_data; in proc_SSID_open()
5382 if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) { in proc_SSID_open()
5383 kfree (file->private_data); in proc_SSID_open()
5384 return -ENOMEM; in proc_SSID_open()
5386 data->writelen = 0; in proc_SSID_open()
5387 data->maxwritelen = 33*3; in proc_SSID_open()
5389 if ((data->wbuffer = kzalloc(33*3 + 1, GFP_KERNEL)) == NULL) { in proc_SSID_open()
5390 kfree (data->rbuffer); in proc_SSID_open()
5391 kfree (file->private_data); in proc_SSID_open()
5392 return -ENOMEM; in proc_SSID_open()
5394 data->on_close = proc_SSID_on_close; in proc_SSID_open()
5397 ptr = data->rbuffer; in proc_SSID_open()
5410 data->readlen = strlen(data->rbuffer); in proc_SSID_open()
5418 struct airo_info *ai = dev->ml_priv; in proc_APList_open()
5421 APListRid *APList_rid = &ai->APList; in proc_APList_open()
5423 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_APList_open()
5424 return -ENOMEM; in proc_APList_open()
5425 data = file->private_data; in proc_APList_open()
5426 if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) { in proc_APList_open()
5427 kfree (file->private_data); in proc_APList_open()
5428 return -ENOMEM; in proc_APList_open()
5430 data->writelen = 0; in proc_APList_open()
5431 data->maxwritelen = 4*6*3; in proc_APList_open()
5432 if ((data->wbuffer = kzalloc(data->maxwritelen, GFP_KERNEL)) == NULL) { in proc_APList_open()
5433 kfree (data->rbuffer); in proc_APList_open()
5434 kfree (file->private_data); in proc_APList_open()
5435 return -ENOMEM; in proc_APList_open()
5437 data->on_close = proc_APList_on_close; in proc_APList_open()
5439 ptr = data->rbuffer; in proc_APList_open()
5442 if (!*(int*)APList_rid->ap[i] && in proc_APList_open()
5443 !*(int*)&APList_rid->ap[i][2]) break; in proc_APList_open()
5444 ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]); in proc_APList_open()
5449 data->readlen = strlen(data->rbuffer); in proc_APList_open()
5457 struct airo_info *ai = dev->ml_priv; in proc_BSSList_open()
5462 int doLoseSync = -1; in proc_BSSList_open()
5464 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_BSSList_open()
5465 return -ENOMEM; in proc_BSSList_open()
5466 data = file->private_data; in proc_BSSList_open()
5467 if ((data->rbuffer = kmalloc(1024, GFP_KERNEL)) == NULL) { in proc_BSSList_open()
5468 kfree (file->private_data); in proc_BSSList_open()
5469 return -ENOMEM; in proc_BSSList_open()
5471 data->writelen = 0; in proc_BSSList_open()
5472 data->maxwritelen = 0; in proc_BSSList_open()
5473 data->wbuffer = NULL; in proc_BSSList_open()
5474 data->on_close = NULL; in proc_BSSList_open()
5476 if (file->f_mode & FMODE_WRITE) { in proc_BSSList_open()
5477 if (!(file->f_mode & FMODE_READ)) { in proc_BSSList_open()
5481 if (ai->flags & FLAG_RADIO_MASK) { in proc_BSSList_open()
5482 kfree(data->rbuffer); in proc_BSSList_open()
5483 kfree(file->private_data); in proc_BSSList_open()
5484 return -ENETDOWN; in proc_BSSList_open()
5488 if (down_interruptible(&ai->sem)) { in proc_BSSList_open()
5489 kfree(data->rbuffer); in proc_BSSList_open()
5490 kfree(file->private_data); in proc_BSSList_open()
5491 return -ERESTARTSYS; in proc_BSSList_open()
5494 up(&ai->sem); in proc_BSSList_open()
5495 data->readlen = 0; in proc_BSSList_open()
5500 ptr = data->rbuffer; in proc_BSSList_open()
5520 data->readlen = strlen(data->rbuffer); in proc_BSSList_open()
5526 struct proc_data *data = file->private_data; in proc_close()
5528 if (data->on_close != NULL) in proc_close()
5529 data->on_close(inode, file); in proc_close()
5530 kfree(data->rbuffer); in proc_close()
5531 kfree(data->wbuffer); in proc_close()
5543 struct airo_info *apriv = dev->ml_priv; in timer_func()
5548 switch(apriv->config.authType) { in timer_func()
5551 apriv->config.authType = AUTH_OPEN; in timer_func()
5554 if (apriv->keyindex < auto_wep) { in timer_func()
5555 set_wep_tx_idx(apriv, apriv->keyindex, 0, 0); in timer_func()
5556 apriv->config.authType = AUTH_SHAREDKEY; in timer_func()
5557 apriv->keyindex++; in timer_func()
5560 apriv->keyindex = 0; in timer_func()
5561 set_wep_tx_idx(apriv, apriv->defindex, 0, 0); in timer_func()
5562 apriv->config.authType = AUTH_ENCRYPT; in timer_func()
5566 apriv->config.authType = AUTH_SHAREDKEY; in timer_func()
5568 set_bit (FLAG_COMMIT, &apriv->flags); in timer_func()
5571 up(&apriv->sem); in timer_func()
5574 clear_bit(JOB_AUTOWEP, &apriv->jobs); in timer_func()
5575 apriv->expires = RUN_AT(HZ*3); in timer_func()
5585 return -ENODEV; in airo_pci_probe()
5588 if (pdev->device == 0x5000 || pdev->device == 0xa504) in airo_pci_probe()
5589 dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev); in airo_pci_probe()
5591 dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev); in airo_pci_probe()
5594 return -ENODEV; in airo_pci_probe()
5605 airo_print_info(dev->name, "Unregistering..."); in airo_pci_remove()
5613 struct airo_info *ai = dev->ml_priv; in airo_pci_suspend()
5617 if (!ai->SSID) in airo_pci_suspend()
5618 ai->SSID = kmalloc(sizeof(SsidRid), GFP_KERNEL); in airo_pci_suspend()
5619 if (!ai->SSID) in airo_pci_suspend()
5620 return -ENOMEM; in airo_pci_suspend()
5621 readSsidRid(ai, ai->SSID); in airo_pci_suspend()
5624 if (down_interruptible(&ai->sem)) in airo_pci_suspend()
5625 return -EAGAIN; in airo_pci_suspend()
5628 ai->power = PMSG_SUSPEND; in airo_pci_suspend()
5639 struct airo_info *ai = dev->ml_priv; in airo_pci_resume()
5640 pci_power_t prev_state = to_pci_dev(dev_d)->current_state; in airo_pci_resume()
5647 setup_card(ai, dev->dev_addr, 0); in airo_pci_resume()
5648 clear_bit(FLAG_RADIO_OFF, &ai->flags); in airo_pci_resume()
5649 clear_bit(FLAG_PENDING_XMIT, &ai->flags); in airo_pci_resume()
5656 set_bit(FLAG_COMMIT, &ai->flags); in airo_pci_resume()
5659 if (ai->SSID) { in airo_pci_resume()
5660 writeSsidRid(ai, ai->SSID, 0); in airo_pci_resume()
5661 kfree(ai->SSID); in airo_pci_resume()
5662 ai->SSID = NULL; in airo_pci_resume()
5664 writeAPListRid(ai, &ai->APList, 0); in airo_pci_resume()
5667 ai->power = PMSG_ON; in airo_pci_resume()
5671 up(&ai->sem); in airo_pci_resume()
5683 return -EINVAL; in airo_init_module()
5699 airo_print_info("", "Probing for PCI adapters"); in airo_init_module()
5701 airo_print_info("", "Finished probing for PCI adapters"); in airo_init_module()
5720 airo_print_info(ai->dev->name, "Unregistering..."); in airo_cleanup_module()
5721 stop_airo_card(ai->dev, 1); in airo_cleanup_module()
5731 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 17 November 00
5733 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 26 March 02
5736 * would not work at all... - Jean II
5744 return (0x100 - rssi_rid[rssi].rssidBm); in airo_rssi_to_dbm()
5767 if ((status_rid->mode & cpu_to_le16(0x3f)) != cpu_to_le16(0x3f)) in airo_get_quality()
5770 if (!(cap_rid->hardCap & cpu_to_le16(8))) in airo_get_quality()
5773 sq = le16_to_cpu(status_rid->signalQuality); in airo_get_quality()
5774 if (memcmp(cap_rid->prodName, "350", 3)) in airo_get_quality()
5778 quality = 0x20 - sq; in airo_get_quality()
5785 quality = 0xb0 - sq; in airo_get_quality()
5789 #define airo_get_max_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x20 : 0xa0)
5790 #define airo_get_avg_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x10 : 0x50);
5792 /*------------------------------------------------------------------*/
5801 strcpy(cwrq, "IEEE 802.11-DS"); in airo_get_name()
5805 /*------------------------------------------------------------------*/
5814 struct airo_info *local = dev->ml_priv; in airo_set_freq()
5815 int rc = -EINPROGRESS; /* Call commit handler */ in airo_set_freq()
5818 if (fwrq->e == 1) { in airo_set_freq()
5819 int f = fwrq->m / 100000; in airo_set_freq()
5822 fwrq->e = 0; in airo_set_freq()
5823 fwrq->m = ieee80211_frequency_to_channel(f); in airo_set_freq()
5826 if (fwrq->m < 0 || fwrq->m > 1000 || fwrq->e > 0) in airo_set_freq()
5827 rc = -EOPNOTSUPP; in airo_set_freq()
5829 int channel = fwrq->m; in airo_set_freq()
5833 airo_print_dbg(dev->name, "New channel value of %d is invalid!", in airo_set_freq()
5834 fwrq->m); in airo_set_freq()
5835 rc = -EINVAL; in airo_set_freq()
5839 local->config.channelSet = cpu_to_le16(channel); in airo_set_freq()
5840 set_bit (FLAG_COMMIT, &local->flags); in airo_set_freq()
5846 /*------------------------------------------------------------------*/
5855 struct airo_info *local = dev->ml_priv; in airo_get_freq()
5860 if ((local->config.opmode & MODE_CFG_MASK) == MODE_STA_ESS) in airo_get_freq()
5861 status_rid.channel = local->config.channelSet; in airo_get_freq()
5867 fwrq->m = 100000 * in airo_get_freq()
5869 fwrq->e = 1; in airo_get_freq()
5871 fwrq->m = ch; in airo_get_freq()
5872 fwrq->e = 0; in airo_get_freq()
5878 /*------------------------------------------------------------------*/
5887 struct airo_info *local = dev->ml_priv; in airo_set_essid()
5894 if (dwrq->flags == 0) { in airo_set_essid()
5898 unsigned index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_set_essid()
5901 if (dwrq->length > IW_ESSID_MAX_SIZE) in airo_set_essid()
5902 return -E2BIG ; in airo_set_essid()
5906 return -EINVAL; in airo_set_essid()
5911 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length); in airo_set_essid()
5912 SSID_rid.ssids[index].len = cpu_to_le16(dwrq->length); in airo_set_essid()
5923 /*------------------------------------------------------------------*/
5932 struct airo_info *local = dev->ml_priv; in airo_get_essid()
5937 /* Note : if dwrq->flags != 0, we should in airo_get_essid()
5945 dwrq->length = le16_to_cpu(status_rid.SSIDlen); in airo_get_essid()
5946 dwrq->flags = 1; /* active */ in airo_get_essid()
5951 /*------------------------------------------------------------------*/
5960 struct airo_info *local = dev->ml_priv; in airo_set_wap()
5963 APListRid *APList_rid = &local->APList; in airo_set_wap()
5965 if (awrq->sa_family != ARPHRD_ETHER) in airo_set_wap()
5966 return -EINVAL; in airo_set_wap()
5967 else if (is_broadcast_ether_addr(awrq->sa_data) || in airo_set_wap()
5968 is_zero_ether_addr(awrq->sa_data)) { in airo_set_wap()
5971 if (down_interruptible(&local->sem)) in airo_set_wap()
5972 return -ERESTARTSYS; in airo_set_wap()
5974 up(&local->sem); in airo_set_wap()
5977 APList_rid->len = cpu_to_le16(sizeof(*APList_rid)); in airo_set_wap()
5978 memcpy(APList_rid->ap[0], awrq->sa_data, ETH_ALEN); in airo_set_wap()
5986 /*------------------------------------------------------------------*/
5995 struct airo_info *local = dev->ml_priv; in airo_get_wap()
6001 memcpy(awrq->sa_data, status_rid.bssid[0], ETH_ALEN); in airo_get_wap()
6002 awrq->sa_family = ARPHRD_ETHER; in airo_get_wap()
6007 /*------------------------------------------------------------------*/
6016 struct airo_info *local = dev->ml_priv; in airo_set_nick()
6019 if (dwrq->length > 16) { in airo_set_nick()
6020 return -E2BIG; in airo_set_nick()
6023 memset(local->config.nodeName, 0, sizeof(local->config.nodeName)); in airo_set_nick()
6024 memcpy(local->config.nodeName, extra, dwrq->length); in airo_set_nick()
6025 set_bit (FLAG_COMMIT, &local->flags); in airo_set_nick()
6027 return -EINPROGRESS; /* Call commit handler */ in airo_set_nick()
6030 /*------------------------------------------------------------------*/
6039 struct airo_info *local = dev->ml_priv; in airo_get_nick()
6042 strncpy(extra, local->config.nodeName, 16); in airo_get_nick()
6044 dwrq->length = strlen(extra); in airo_get_nick()
6049 /*------------------------------------------------------------------*/
6051 * Wireless Handler : set Bit-Rate
6058 struct airo_info *local = dev->ml_priv; in airo_set_rate()
6067 if ((vwrq->value < 8) && (vwrq->value >= 0)) { in airo_set_rate()
6070 brate = cap_rid.supportedRates[vwrq->value]; in airo_set_rate()
6073 u8 normvalue = (u8) (vwrq->value/500000); in airo_set_rate()
6083 /* -1 designed the max rate (mostly auto mode) */ in airo_set_rate()
6084 if (vwrq->value == -1) { in airo_set_rate()
6091 brate = cap_rid.supportedRates[i - 1]; in airo_set_rate()
6095 return -EINVAL; in airo_set_rate()
6100 if (vwrq->fixed == 0) { in airo_set_rate()
6102 memset(local->config.rates, 0, 8); in airo_set_rate()
6104 local->config.rates[i] = cap_rid.supportedRates[i]; in airo_set_rate()
6105 if (local->config.rates[i] == brate) in airo_set_rate()
6111 memset(local->config.rates, 0, 8); in airo_set_rate()
6112 local->config.rates[0] = brate; in airo_set_rate()
6114 set_bit (FLAG_COMMIT, &local->flags); in airo_set_rate()
6116 return -EINPROGRESS; /* Call commit handler */ in airo_set_rate()
6119 /*------------------------------------------------------------------*/
6121 * Wireless Handler : get Bit-Rate
6128 struct airo_info *local = dev->ml_priv; in airo_get_rate()
6133 vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000; in airo_get_rate()
6136 vwrq->fixed = (local->config.rates[1] == 0); in airo_get_rate()
6141 /*------------------------------------------------------------------*/
6150 struct airo_info *local = dev->ml_priv; in airo_set_rts()
6151 int rthr = vwrq->value; in airo_set_rts()
6153 if (vwrq->disabled) in airo_set_rts()
6156 return -EINVAL; in airo_set_rts()
6159 local->config.rtsThres = cpu_to_le16(rthr); in airo_set_rts()
6160 set_bit (FLAG_COMMIT, &local->flags); in airo_set_rts()
6162 return -EINPROGRESS; /* Call commit handler */ in airo_set_rts()
6165 /*------------------------------------------------------------------*/
6174 struct airo_info *local = dev->ml_priv; in airo_get_rts()
6177 vwrq->value = le16_to_cpu(local->config.rtsThres); in airo_get_rts()
6178 vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU); in airo_get_rts()
6179 vwrq->fixed = 1; in airo_get_rts()
6184 /*------------------------------------------------------------------*/
6193 struct airo_info *local = dev->ml_priv; in airo_set_frag()
6194 int fthr = vwrq->value; in airo_set_frag()
6196 if (vwrq->disabled) in airo_set_frag()
6199 return -EINVAL; in airo_set_frag()
6201 fthr &= ~0x1; /* Get an even value - is it really needed ??? */ in airo_set_frag()
6203 local->config.fragThresh = cpu_to_le16(fthr); in airo_set_frag()
6204 set_bit (FLAG_COMMIT, &local->flags); in airo_set_frag()
6206 return -EINPROGRESS; /* Call commit handler */ in airo_set_frag()
6209 /*------------------------------------------------------------------*/
6218 struct airo_info *local = dev->ml_priv; in airo_get_frag()
6221 vwrq->value = le16_to_cpu(local->config.fragThresh); in airo_get_frag()
6222 vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU); in airo_get_frag()
6223 vwrq->fixed = 1; in airo_get_frag()
6228 /*------------------------------------------------------------------*/
6237 struct airo_info *local = dev->ml_priv; in airo_set_mode()
6246 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6247 local->config.opmode |= MODE_STA_IBSS; in airo_set_mode()
6248 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6249 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6250 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6253 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6254 local->config.opmode |= MODE_STA_ESS; in airo_set_mode()
6255 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6256 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6257 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6260 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6261 local->config.opmode |= MODE_AP; in airo_set_mode()
6262 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6263 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6264 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6267 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6268 local->config.opmode |= MODE_AP_RPTR; in airo_set_mode()
6269 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6270 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6271 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6274 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6275 local->config.opmode |= MODE_STA_ESS; in airo_set_mode()
6276 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6277 local->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; in airo_set_mode()
6278 local->config.scanMode = SCANMODE_PASSIVE; in airo_set_mode()
6279 set_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6282 return -EINVAL; in airo_set_mode()
6285 set_bit (FLAG_RESET, &local->flags); in airo_set_mode()
6286 set_bit (FLAG_COMMIT, &local->flags); in airo_set_mode()
6288 return -EINPROGRESS; /* Call commit handler */ in airo_set_mode()
6291 /*------------------------------------------------------------------*/
6300 struct airo_info *local = dev->ml_priv; in airo_get_mode()
6303 /* If not managed, assume it's ad-hoc */ in airo_get_mode()
6304 switch (local->config.opmode & MODE_CFG_MASK) { in airo_get_mode()
6323 return (index >= 0) && (index <= ai->max_wep_idx); in valid_index()
6326 /*------------------------------------------------------------------*/
6335 struct airo_info *local = dev->ml_priv; in airo_set_encode()
6336 int perm = (dwrq->flags & IW_ENCODE_TEMP ? 0 : 1); in airo_set_encode()
6337 __le16 currentAuthType = local->config.authType; in airo_set_encode()
6340 if (!local->wep_capable) in airo_set_encode()
6341 return -EOPNOTSUPP; in airo_set_encode()
6350 * don't do it. - Jean II */ in airo_set_encode()
6351 if (dwrq->length > 0) { in airo_set_encode()
6353 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_set_encode()
6357 if (dwrq->length > MAX_KEY_SIZE) { in airo_set_encode()
6358 return -EINVAL; in airo_set_encode()
6365 /* Check the index (none -> use current) */ in airo_set_encode()
6370 if (dwrq->length > MIN_KEY_SIZE) in airo_set_encode()
6375 if (!(dwrq->flags & IW_ENCODE_NOKEY)) { in airo_set_encode()
6379 memcpy(key.key, extra, dwrq->length); in airo_set_encode()
6383 airo_print_err(local->dev->name, "failed to set" in airo_set_encode()
6393 (local->config.authType == AUTH_OPEN)) in airo_set_encode()
6397 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_set_encode()
6401 airo_print_err(local->dev->name, "failed to set" in airo_set_encode()
6408 if (!(dwrq->flags & IW_ENCODE_MODE)) in airo_set_encode()
6409 return -EINVAL; in airo_set_encode()
6413 if (dwrq->flags & IW_ENCODE_DISABLED) in airo_set_encode()
6415 if (dwrq->flags & IW_ENCODE_RESTRICTED) in airo_set_encode()
6417 if (dwrq->flags & IW_ENCODE_OPEN) in airo_set_encode()
6420 if (local->config.authType != currentAuthType) in airo_set_encode()
6421 set_bit (FLAG_COMMIT, &local->flags); in airo_set_encode()
6422 return -EINPROGRESS; /* Call commit handler */ in airo_set_encode()
6425 /*------------------------------------------------------------------*/
6434 struct airo_info *local = dev->ml_priv; in airo_get_encode()
6435 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_get_encode()
6439 if (!local->wep_capable) in airo_get_encode()
6440 return -EOPNOTSUPP; in airo_get_encode()
6445 switch(local->config.authType) { in airo_get_encode()
6447 dwrq->flags = IW_ENCODE_OPEN; in airo_get_encode()
6450 dwrq->flags = IW_ENCODE_RESTRICTED; in airo_get_encode()
6454 dwrq->flags = IW_ENCODE_DISABLED; in airo_get_encode()
6458 dwrq->flags |= IW_ENCODE_NOKEY; in airo_get_encode()
6461 /* Which key do we want ? -1 -> tx index */ in airo_get_encode()
6467 dwrq->flags |= index + 1; in airo_get_encode()
6472 dwrq->length = 0; in airo_get_encode()
6474 dwrq->length = wep_key_len; in airo_get_encode()
6475 memcpy(extra, buf, dwrq->length); in airo_get_encode()
6481 /*------------------------------------------------------------------*/
6490 struct airo_info *local = dev->ml_priv; in airo_set_encodeext()
6491 struct iw_point *encoding = &wrqu->encoding; in airo_set_encodeext()
6493 int perm = (encoding->flags & IW_ENCODE_TEMP ? 0 : 1); in airo_set_encodeext()
6494 __le16 currentAuthType = local->config.authType; in airo_set_encodeext()
6495 int idx, key_len, alg = ext->alg, set_key = 1, rc; in airo_set_encodeext()
6498 if (!local->wep_capable) in airo_set_encodeext()
6499 return -EOPNOTSUPP; in airo_set_encodeext()
6504 idx = encoding->flags & IW_ENCODE_INDEX; in airo_set_encodeext()
6506 if (!valid_index(local, idx - 1)) in airo_set_encodeext()
6507 return -EINVAL; in airo_set_encodeext()
6508 idx--; in airo_set_encodeext()
6515 if (encoding->flags & IW_ENCODE_DISABLED) in airo_set_encodeext()
6518 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { in airo_set_encodeext()
6524 airo_print_err(local->dev->name, "failed to set " in airo_set_encodeext()
6529 set_key = ext->key_len > 0 ? 1 : 0; in airo_set_encodeext()
6540 if (ext->key_len > MIN_KEY_SIZE) { in airo_set_encodeext()
6542 } else if (ext->key_len > 0) { in airo_set_encodeext()
6545 return -EINVAL; in airo_set_encodeext()
6547 key_len = min (ext->key_len, key.len); in airo_set_encodeext()
6548 memcpy(key.key, ext->key, key_len); in airo_set_encodeext()
6551 return -EINVAL; in airo_set_encodeext()
6556 airo_print_err(local->dev->name, in airo_set_encodeext()
6564 airo_print_err(local->dev->name, in airo_set_encodeext()
6573 if (encoding->flags & IW_ENCODE_DISABLED) in airo_set_encodeext()
6575 if (encoding->flags & IW_ENCODE_RESTRICTED) in airo_set_encodeext()
6577 if (encoding->flags & IW_ENCODE_OPEN) in airo_set_encodeext()
6580 if (local->config.authType != currentAuthType) in airo_set_encodeext()
6581 set_bit (FLAG_COMMIT, &local->flags); in airo_set_encodeext()
6583 return -EINPROGRESS; in airo_set_encodeext()
6587 /*------------------------------------------------------------------*/
6596 struct airo_info *local = dev->ml_priv; in airo_get_encodeext()
6597 struct iw_point *encoding = &wrqu->encoding; in airo_get_encodeext()
6602 if (!local->wep_capable) in airo_get_encodeext()
6603 return -EOPNOTSUPP; in airo_get_encodeext()
6607 max_key_len = encoding->length - sizeof(*ext); in airo_get_encodeext()
6609 return -EINVAL; in airo_get_encodeext()
6611 idx = encoding->flags & IW_ENCODE_INDEX; in airo_get_encodeext()
6613 if (!valid_index(local, idx - 1)) in airo_get_encodeext()
6614 return -EINVAL; in airo_get_encodeext()
6615 idx--; in airo_get_encodeext()
6622 encoding->flags = idx + 1; in airo_get_encodeext()
6626 switch(local->config.authType) { in airo_get_encodeext()
6628 encoding->flags = IW_ENCODE_ALG_WEP | IW_ENCODE_ENABLED; in airo_get_encodeext()
6631 encoding->flags = IW_ENCODE_ALG_WEP | IW_ENCODE_ENABLED; in airo_get_encodeext()
6635 encoding->flags = IW_ENCODE_ALG_NONE | IW_ENCODE_DISABLED; in airo_get_encodeext()
6639 encoding->flags |= IW_ENCODE_NOKEY; in airo_get_encodeext()
6645 ext->key_len = 0; in airo_get_encodeext()
6647 ext->key_len = wep_key_len; in airo_get_encodeext()
6648 memcpy(extra, buf, ext->key_len); in airo_get_encodeext()
6655 /*------------------------------------------------------------------*/
6663 struct airo_info *local = dev->ml_priv; in airo_set_auth()
6664 struct iw_param *param = &wrqu->param; in airo_set_auth()
6665 __le16 currentAuthType = local->config.authType; in airo_set_auth()
6667 switch (param->flags & IW_AUTH_INDEX) { in airo_set_auth()
6680 if (param->value) { in airo_set_auth()
6689 if (local->config.authType != currentAuthType) in airo_set_auth()
6690 set_bit (FLAG_COMMIT, &local->flags); in airo_set_auth()
6694 if (param->value & IW_AUTH_ALG_SHARED_KEY) { in airo_set_auth()
6696 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) { in airo_set_auth()
6698 * unencrypted mode was requested - so use the in airo_set_auth()
6701 set_auth_type(local, local->last_auth); in airo_set_auth()
6703 return -EINVAL; in airo_set_auth()
6706 if (local->config.authType != currentAuthType) in airo_set_auth()
6707 set_bit (FLAG_COMMIT, &local->flags); in airo_set_auth()
6713 if (param->value > 0) in airo_set_auth()
6714 return -EOPNOTSUPP; in airo_set_auth()
6718 return -EOPNOTSUPP; in airo_set_auth()
6720 return -EINPROGRESS; in airo_set_auth()
6724 /*------------------------------------------------------------------*/
6732 struct airo_info *local = dev->ml_priv; in airo_get_auth()
6733 struct iw_param *param = &wrqu->param; in airo_get_auth()
6734 __le16 currentAuthType = local->config.authType; in airo_get_auth()
6736 switch (param->flags & IW_AUTH_INDEX) { in airo_get_auth()
6741 param->value = 1; in airo_get_auth()
6744 param->value = 0; in airo_get_auth()
6752 param->value = IW_AUTH_ALG_SHARED_KEY; in airo_get_auth()
6756 param->value = IW_AUTH_ALG_OPEN_SYSTEM; in airo_get_auth()
6762 param->value = 0; in airo_get_auth()
6766 return -EOPNOTSUPP; in airo_get_auth()
6772 /*------------------------------------------------------------------*/
6774 * Wireless Handler : set Tx-Power
6781 struct airo_info *local = dev->ml_priv; in airo_set_txpow()
6784 int rc = -EINVAL; in airo_set_txpow()
6785 __le16 v = cpu_to_le16(vwrq->value); in airo_set_txpow()
6789 if (vwrq->disabled) { in airo_set_txpow()
6790 set_bit (FLAG_RADIO_OFF, &local->flags); in airo_set_txpow()
6791 set_bit (FLAG_COMMIT, &local->flags); in airo_set_txpow()
6792 return -EINPROGRESS; /* Call commit handler */ in airo_set_txpow()
6794 if (vwrq->flags != IW_TXPOW_MWATT) { in airo_set_txpow()
6795 return -EINVAL; in airo_set_txpow()
6797 clear_bit (FLAG_RADIO_OFF, &local->flags); in airo_set_txpow()
6801 local->config.txPower = v; in airo_set_txpow()
6802 set_bit (FLAG_COMMIT, &local->flags); in airo_set_txpow()
6803 rc = -EINPROGRESS; /* Call commit handler */ in airo_set_txpow()
6809 /*------------------------------------------------------------------*/
6811 * Wireless Handler : get Tx-Power
6818 struct airo_info *local = dev->ml_priv; in airo_get_txpow()
6821 vwrq->value = le16_to_cpu(local->config.txPower); in airo_get_txpow()
6822 vwrq->fixed = 1; /* No power control */ in airo_get_txpow()
6823 vwrq->disabled = test_bit(FLAG_RADIO_OFF, &local->flags); in airo_get_txpow()
6824 vwrq->flags = IW_TXPOW_MWATT; in airo_get_txpow()
6829 /*------------------------------------------------------------------*/
6838 struct airo_info *local = dev->ml_priv; in airo_set_retry()
6839 int rc = -EINVAL; in airo_set_retry()
6841 if (vwrq->disabled) { in airo_set_retry()
6842 return -EINVAL; in airo_set_retry()
6845 if (vwrq->flags & IW_RETRY_LIMIT) { in airo_set_retry()
6846 __le16 v = cpu_to_le16(vwrq->value); in airo_set_retry()
6847 if (vwrq->flags & IW_RETRY_LONG) in airo_set_retry()
6848 local->config.longRetryLimit = v; in airo_set_retry()
6849 else if (vwrq->flags & IW_RETRY_SHORT) in airo_set_retry()
6850 local->config.shortRetryLimit = v; in airo_set_retry()
6853 local->config.longRetryLimit = v; in airo_set_retry()
6854 local->config.shortRetryLimit = v; in airo_set_retry()
6856 set_bit (FLAG_COMMIT, &local->flags); in airo_set_retry()
6857 rc = -EINPROGRESS; /* Call commit handler */ in airo_set_retry()
6859 if (vwrq->flags & IW_RETRY_LIFETIME) { in airo_set_retry()
6860 local->config.txLifetime = cpu_to_le16(vwrq->value / 1024); in airo_set_retry()
6861 set_bit (FLAG_COMMIT, &local->flags); in airo_set_retry()
6862 rc = -EINPROGRESS; /* Call commit handler */ in airo_set_retry()
6867 /*------------------------------------------------------------------*/
6876 struct airo_info *local = dev->ml_priv; in airo_get_retry()
6878 vwrq->disabled = 0; /* Can't be disabled */ in airo_get_retry()
6882 if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { in airo_get_retry()
6883 vwrq->flags = IW_RETRY_LIFETIME; in airo_get_retry()
6884 vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024; in airo_get_retry()
6885 } else if ((vwrq->flags & IW_RETRY_LONG)) { in airo_get_retry()
6886 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in airo_get_retry()
6887 vwrq->value = le16_to_cpu(local->config.longRetryLimit); in airo_get_retry()
6889 vwrq->flags = IW_RETRY_LIMIT; in airo_get_retry()
6890 vwrq->value = le16_to_cpu(local->config.shortRetryLimit); in airo_get_retry()
6891 if (local->config.shortRetryLimit != local->config.longRetryLimit) in airo_get_retry()
6892 vwrq->flags |= IW_RETRY_SHORT; in airo_get_retry()
6898 /*------------------------------------------------------------------*/
6907 struct airo_info *local = dev->ml_priv; in airo_get_range()
6915 dwrq->length = sizeof(struct iw_range); in airo_get_range()
6917 range->min_nwid = 0x0000; in airo_get_range()
6918 range->max_nwid = 0x0000; in airo_get_range()
6919 range->num_channels = 14; in airo_get_range()
6924 range->freq[k].i = i + 1; /* List index */ in airo_get_range()
6925 range->freq[k].m = 100000 * in airo_get_range()
6927 range->freq[k++].e = 1; /* Values in MHz -> * 10^5 * 10 */ in airo_get_range()
6929 range->num_frequency = k; in airo_get_range()
6931 range->sensitivity = 65535; in airo_get_range()
6934 if (local->rssi) in airo_get_range()
6935 range->max_qual.qual = 100; /* % */ in airo_get_range()
6937 range->max_qual.qual = airo_get_max_quality(&cap_rid); in airo_get_range()
6938 range->max_qual.level = 0x100 - 120; /* -120 dBm */ in airo_get_range()
6939 range->max_qual.noise = 0x100 - 120; /* -120 dBm */ in airo_get_range()
6941 /* Experimental measurements - boundary 11/5.5 Mb/s */ in airo_get_range()
6942 /* Note : with or without the (local->rssi), results in airo_get_range()
6943 * are somewhat different. - Jean II */ in airo_get_range()
6944 if (local->rssi) { in airo_get_range()
6945 range->avg_qual.qual = 50; /* % */ in airo_get_range()
6946 range->avg_qual.level = 0x100 - 70; /* -70 dBm */ in airo_get_range()
6948 range->avg_qual.qual = airo_get_avg_quality(&cap_rid); in airo_get_range()
6949 range->avg_qual.level = 0x100 - 80; /* -80 dBm */ in airo_get_range()
6951 range->avg_qual.noise = 0x100 - 85; /* -85 dBm */ in airo_get_range()
6954 range->bitrate[i] = cap_rid.supportedRates[i] * 500000; in airo_get_range()
6955 if (range->bitrate[i] == 0) in airo_get_range()
6958 range->num_bitrates = i; in airo_get_range()
6964 range->throughput = 5000 * 1000; in airo_get_range()
6966 range->throughput = 1500 * 1000; in airo_get_range()
6968 range->min_rts = 0; in airo_get_range()
6969 range->max_rts = AIRO_DEF_MTU; in airo_get_range()
6970 range->min_frag = 256; in airo_get_range()
6971 range->max_frag = AIRO_DEF_MTU; in airo_get_range()
6975 range->encoding_size[0] = 5; in airo_get_range()
6978 range->encoding_size[1] = 13; in airo_get_range()
6979 range->num_encoding_sizes = 2; in airo_get_range()
6981 range->num_encoding_sizes = 1; in airo_get_range()
6982 range->max_encoding_tokens = in airo_get_range()
6985 range->num_encoding_sizes = 0; in airo_get_range()
6986 range->max_encoding_tokens = 0; in airo_get_range()
6988 range->min_pmp = 0; in airo_get_range()
6989 range->max_pmp = 5000000; /* 5 secs */ in airo_get_range()
6990 range->min_pmt = 0; in airo_get_range()
6991 range->max_pmt = 65535 * 1024; /* ??? */ in airo_get_range()
6992 range->pmp_flags = IW_POWER_PERIOD; in airo_get_range()
6993 range->pmt_flags = IW_POWER_TIMEOUT; in airo_get_range()
6994 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; in airo_get_range()
6996 /* Transmit Power - values are in mW */ in airo_get_range()
6998 range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]); in airo_get_range()
6999 if (range->txpower[i] == 0) in airo_get_range()
7002 range->num_txpower = i; in airo_get_range()
7003 range->txpower_capa = IW_TXPOW_MWATT; in airo_get_range()
7004 range->we_version_source = 19; in airo_get_range()
7005 range->we_version_compiled = WIRELESS_EXT; in airo_get_range()
7006 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; in airo_get_range()
7007 range->retry_flags = IW_RETRY_LIMIT; in airo_get_range()
7008 range->r_time_flags = IW_RETRY_LIFETIME; in airo_get_range()
7009 range->min_retry = 1; in airo_get_range()
7010 range->max_retry = 65535; in airo_get_range()
7011 range->min_r_time = 1024; in airo_get_range()
7012 range->max_r_time = 65535 * 1024; in airo_get_range()
7015 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | in airo_get_range()
7019 range->event_capa[1] = IW_EVENT_CAPA_K_1; in airo_get_range()
7020 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVTXDROP); in airo_get_range()
7024 /*------------------------------------------------------------------*/
7033 struct airo_info *local = dev->ml_priv; in airo_set_power()
7036 if (vwrq->disabled) { in airo_set_power()
7038 return -EINVAL; in airo_set_power()
7039 local->config.powerSaveMode = POWERSAVE_CAM; in airo_set_power()
7040 local->config.rmode &= ~RXMODE_MASK; in airo_set_power()
7041 local->config.rmode |= RXMODE_BC_MC_ADDR; in airo_set_power()
7042 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7043 return -EINPROGRESS; /* Call commit handler */ in airo_set_power()
7045 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { in airo_set_power()
7046 local->config.fastListenDelay = cpu_to_le16((vwrq->value + 500) / 1024); in airo_set_power()
7047 local->config.powerSaveMode = POWERSAVE_PSPCAM; in airo_set_power()
7048 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7049 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { in airo_set_power()
7050 local->config.fastListenInterval = in airo_set_power()
7051 local->config.listenInterval = in airo_set_power()
7052 cpu_to_le16((vwrq->value + 500) / 1024); in airo_set_power()
7053 local->config.powerSaveMode = POWERSAVE_PSPCAM; in airo_set_power()
7054 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7056 switch (vwrq->flags & IW_POWER_MODE) { in airo_set_power()
7059 return -EINVAL; in airo_set_power()
7060 local->config.rmode &= ~RXMODE_MASK; in airo_set_power()
7061 local->config.rmode |= RXMODE_ADDR; in airo_set_power()
7062 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7066 return -EINVAL; in airo_set_power()
7067 local->config.rmode &= ~RXMODE_MASK; in airo_set_power()
7068 local->config.rmode |= RXMODE_BC_MC_ADDR; in airo_set_power()
7069 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7071 /* This is broken, fixme ;-) */ in airo_set_power()
7074 return -EINVAL; in airo_set_power()
7076 // Note : we may want to factor local->need_commit here in airo_set_power()
7078 return -EINPROGRESS; /* Call commit handler */ in airo_set_power()
7081 /*------------------------------------------------------------------*/
7090 struct airo_info *local = dev->ml_priv; in airo_get_power()
7094 mode = local->config.powerSaveMode; in airo_get_power()
7095 if ((vwrq->disabled = (mode == POWERSAVE_CAM))) in airo_get_power()
7097 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { in airo_get_power()
7098 vwrq->value = le16_to_cpu(local->config.fastListenDelay) * 1024; in airo_get_power()
7099 vwrq->flags = IW_POWER_TIMEOUT; in airo_get_power()
7101 vwrq->value = le16_to_cpu(local->config.fastListenInterval) * 1024; in airo_get_power()
7102 vwrq->flags = IW_POWER_PERIOD; in airo_get_power()
7104 if ((local->config.rmode & RXMODE_MASK) == RXMODE_ADDR) in airo_get_power()
7105 vwrq->flags |= IW_POWER_UNICAST_R; in airo_get_power()
7107 vwrq->flags |= IW_POWER_ALL_R; in airo_get_power()
7112 /*------------------------------------------------------------------*/
7121 struct airo_info *local = dev->ml_priv; in airo_set_sens()
7124 local->config.rssiThreshold = in airo_set_sens()
7125 cpu_to_le16(vwrq->disabled ? RSSI_DEFAULT : vwrq->value); in airo_set_sens()
7126 set_bit (FLAG_COMMIT, &local->flags); in airo_set_sens()
7128 return -EINPROGRESS; /* Call commit handler */ in airo_set_sens()
7131 /*------------------------------------------------------------------*/
7140 struct airo_info *local = dev->ml_priv; in airo_get_sens()
7143 vwrq->value = le16_to_cpu(local->config.rssiThreshold); in airo_get_sens()
7144 vwrq->disabled = (vwrq->value == 0); in airo_get_sens()
7145 vwrq->fixed = 1; in airo_get_sens()
7150 /*------------------------------------------------------------------*/
7160 struct airo_info *local = dev->ml_priv; in airo_get_aplist()
7165 int loseSync = capable(CAP_NET_ADMIN) ? 1: -1; in airo_get_aplist()
7169 return -ENOMEM; in airo_get_aplist()
7179 if (local->rssi) { in airo_get_aplist()
7180 qual[i].level = 0x100 - dBm; in airo_get_aplist()
7181 qual[i].qual = airo_dbm_to_pct(local->rssi, dBm); in airo_get_aplist()
7192 qual[i].noise = local->wstats.qual.noise; in airo_get_aplist()
7219 dwrq->flags = 1; /* Should be define'd */ in airo_get_aplist()
7223 dwrq->length = i; in airo_get_aplist()
7229 /*------------------------------------------------------------------*/
7238 struct airo_info *ai = dev->ml_priv; in airo_set_scan()
7250 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; in airo_set_scan()
7252 if (down_interruptible(&ai->sem)) in airo_set_scan()
7253 return -ERESTARTSYS; in airo_set_scan()
7257 if (ai->scan_timeout > 0) in airo_set_scan()
7268 ai->scan_timeout = RUN_AT(3*HZ); in airo_set_scan()
7275 up(&ai->sem); in airo_set_scan()
7277 wake_up_interruptible(&ai->thr_wait); in airo_set_scan()
7281 /*------------------------------------------------------------------*/
7284 * format that the Wireless Tools will understand - Jean II
7292 struct airo_info *ai = dev->ml_priv; in airo_translate_scan()
7303 memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); in airo_translate_scan()
7310 iwe.u.data.length = bss->ssidLen; in airo_translate_scan()
7316 &iwe, bss->ssid); in airo_translate_scan()
7320 capabilities = bss->cap; in airo_translate_scan()
7332 iwe.u.freq.m = le16_to_cpu(bss->dsChannel); in airo_translate_scan()
7339 dBm = le16_to_cpu(bss->dBm); in airo_translate_scan()
7343 if (ai->rssi) { in airo_translate_scan()
7344 iwe.u.qual.level = 0x100 - dBm; in airo_translate_scan()
7345 iwe.u.qual.qual = airo_dbm_to_pct(ai->rssi, dBm); in airo_translate_scan()
7356 iwe.u.qual.noise = ai->wstats.qual.noise; in airo_translate_scan()
7368 &iwe, bss->ssid); in airo_translate_scan()
7371 * more of magic - Jean II */ in airo_translate_scan()
7380 if (bss->rates[i] == 0) in airo_translate_scan()
7383 iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000); in airo_translate_scan()
7390 if ((current_val - current_ev) > iwe_stream_lcp_len(info)) in airo_translate_scan()
7397 sprintf(buf, "bcn_int=%d", bss->beaconInterval); in airo_translate_scan()
7405 if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) { in airo_translate_scan()
7407 u16 length = sizeof (bss->extra.iep); in airo_translate_scan()
7408 u8 *ie = (void *)&bss->extra.iep; in airo_translate_scan()
7418 /* Two zero-length SSID elements in airo_translate_scan()
7431 /* 64 is an arbitrary cut-off */ in airo_translate_scan()
7442 /* 64 is an arbitrary cut-off */ in airo_translate_scan()
7453 length -= 2 + ie[1]; in airo_translate_scan()
7460 /*------------------------------------------------------------------*/
7469 struct airo_info *ai = dev->ml_priv; in airo_get_scan()
7474 /* If a scan is in-progress, return -EAGAIN */ in airo_get_scan()
7475 if (ai->scan_timeout > 0) in airo_get_scan()
7476 return -EAGAIN; in airo_get_scan()
7478 if (down_interruptible(&ai->sem)) in airo_get_scan()
7479 return -EAGAIN; in airo_get_scan()
7481 list_for_each_entry (net, &ai->network_list, list) { in airo_get_scan()
7484 extra + dwrq->length, in airo_get_scan()
7485 &net->bss); in airo_get_scan()
7488 if ((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { in airo_get_scan()
7490 err = -E2BIG; in airo_get_scan()
7496 dwrq->length = (current_ev - extra); in airo_get_scan()
7497 dwrq->flags = 0; /* todo */ in airo_get_scan()
7500 up(&ai->sem); in airo_get_scan()
7504 /*------------------------------------------------------------------*/
7513 struct airo_info *local = dev->ml_priv; in airo_config_commit()
7515 if (!test_bit (FLAG_COMMIT, &local->flags)) in airo_config_commit()
7521 if (test_bit (FLAG_RESET, &local->flags)) { in airo_config_commit()
7525 if (test_bit(FLAG_MPI,&local->flags)) in airo_config_commit()
7526 setup_card(local, dev->dev_addr, 1); in airo_config_commit()
7531 writeAPListRid(local, &local->APList, 1); in airo_config_commit()
7533 if (down_interruptible(&local->sem)) in airo_config_commit()
7534 return -ERESTARTSYS; in airo_config_commit()
7537 if (test_bit (FLAG_RESET, &local->flags)) in airo_config_commit()
7540 up(&local->sem); in airo_config_commit()
7545 /*------------------------------------------------------------------*/
7582 (iw_handler) NULL, /* -- hole -- */
7590 (iw_handler) NULL, /* -- hole -- */
7591 (iw_handler) NULL, /* -- hole -- */
7606 (iw_handler) NULL, /* -- hole -- */
7607 (iw_handler) NULL, /* -- hole -- */
7656 struct airo_info *ai = dev->ml_priv; in airo_ioctl()
7658 if (ai->power.event) in airo_ioctl()
7670 if (copy_from_user(&com, rq->ifr_data, sizeof(com))) in airo_ioctl()
7671 rc = -EFAULT; in airo_ioctl()
7673 rc = -EFAULT; in airo_ioctl()
7686 if (copy_from_user(&com, rq->ifr_data, sizeof(com))) { in airo_ioctl()
7687 rc = -EFAULT; in airo_ioctl()
7695 rc = -EFAULT; in airo_ioctl()
7706 rc = -EINVAL; /* Bad command in ioctl */ in airo_ioctl()
7713 rc = -EOPNOTSUPP; in airo_ioctl()
7723 * o Check if work in Ad-Hoc mode (otherwise, use SPY, as in wvlan_cs)
7735 clear_bit(JOB_WSTATS, &local->jobs); in airo_read_wireless_stats()
7736 if (local->power.event) { in airo_read_wireless_stats()
7737 up(&local->sem); in airo_read_wireless_stats()
7743 up(&local->sem); in airo_read_wireless_stats()
7746 local->wstats.status = le16_to_cpu(status_rid.mode); in airo_read_wireless_stats()
7749 if (local->rssi) { in airo_read_wireless_stats()
7750 local->wstats.qual.level = in airo_read_wireless_stats()
7751 airo_rssi_to_dbm(local->rssi, in airo_read_wireless_stats()
7754 local->wstats.qual.qual = in airo_read_wireless_stats()
7757 local->wstats.qual.level = in airo_read_wireless_stats()
7759 local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid); in airo_read_wireless_stats()
7762 local->wstats.qual.noise = 0x100 - status_rid.noisedBm; in airo_read_wireless_stats()
7763 local->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; in airo_read_wireless_stats()
7765 local->wstats.qual.noise = 0; in airo_read_wireless_stats()
7766 …local->wstats.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID … in airo_read_wireless_stats()
7771 local->wstats.discard.nwid = le32_to_cpu(vals[56]) + in airo_read_wireless_stats()
7774 local->wstats.discard.code = le32_to_cpu(vals[6]);/* RxWepErr */ in airo_read_wireless_stats()
7775 local->wstats.discard.fragment = le32_to_cpu(vals[30]); in airo_read_wireless_stats()
7776 local->wstats.discard.retries = le32_to_cpu(vals[10]); in airo_read_wireless_stats()
7777 local->wstats.discard.misc = le32_to_cpu(vals[1]) + in airo_read_wireless_stats()
7779 local->wstats.miss.beacon = le32_to_cpu(vals[34]); in airo_read_wireless_stats()
7784 struct airo_info *local = dev->ml_priv; in airo_get_wireless_stats()
7786 if (!test_bit(JOB_WSTATS, &local->jobs)) { in airo_get_wireless_stats()
7788 if (down_trylock(&local->sem) != 0) { in airo_get_wireless_stats()
7789 set_bit(JOB_WSTATS, &local->jobs); in airo_get_wireless_stats()
7790 wake_up_interruptible(&local->thr_wait); in airo_get_wireless_stats()
7795 return &local->wstats; in airo_get_wireless_stats()
7801 * feed to the radio's host interface. Things can be added/deleted
7810 struct airo_info *ai = dev->ml_priv; in readrids()
7812 if (test_bit(FLAG_FLASHING, &ai->flags)) in readrids()
7813 return -EIO; in readrids()
7815 switch(comp->command) in readrids()
7819 if (test_bit(FLAG_COMMIT, &ai->flags)) { in readrids()
7835 if (copy_to_user(comp->data, &ai->micstats, in readrids()
7836 min((int)comp->len, (int)sizeof(ai->micstats)))) in readrids()
7837 return -EFAULT; in readrids()
7839 case AIRORRID: ridcode = comp->ridnum; break; in readrids()
7841 return -EINVAL; in readrids()
7845 /* Only super-user can read WEP keys */ in readrids()
7847 return -EPERM; in readrids()
7851 return -ENOMEM; in readrids()
7858 len = comp->len; in readrids()
7860 if (copy_to_user(comp->data, iobuf, min(len, (int)RIDSIZE))) { in readrids()
7862 return -EFAULT; in readrids()
7874 struct airo_info *ai = dev->ml_priv; in writerids()
7880 /* Only super-user can write RIDs */ in writerids()
7882 return -EPERM; in writerids()
7884 if (test_bit(FLAG_FLASHING, &ai->flags)) in writerids()
7885 return -EIO; in writerids()
7890 switch(comp->command) in writerids()
7895 case AIROPCFG: ai->config.len = 0; in writerids()
7896 clear_bit(FLAG_COMMIT, &ai->flags); in writerids()
7911 return -EIO; in writerids()
7928 return -ENOMEM; in writerids()
7932 enabled = ai->micstats.enabled; in writerids()
7933 memset(&ai->micstats, 0, sizeof(ai->micstats)); in writerids()
7934 ai->micstats.enabled = enabled; in writerids()
7936 if (copy_to_user(comp->data, iobuf, in writerids()
7937 min((int)comp->len, (int)RIDSIZE))) { in writerids()
7939 return -EFAULT; in writerids()
7945 return -EOPNOTSUPP; /* Blarg! */ in writerids()
7947 if (comp->len > RIDSIZE) in writerids()
7948 return -EINVAL; in writerids()
7951 return -ENOMEM; in writerids()
7953 if (copy_from_user(iobuf, comp->data, comp->len)) { in writerids()
7955 return -EFAULT; in writerids()
7958 if (comp->command == AIROPCFG) { in writerids()
7961 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags)) in writerids()
7962 cfg->opmode |= MODE_MIC; in writerids()
7964 if ((cfg->opmode & MODE_CFG_MASK) == MODE_STA_IBSS) in writerids()
7965 set_bit (FLAG_ADHOC, &ai->flags); in writerids()
7967 clear_bit (FLAG_ADHOC, &ai->flags); in writerids()
7970 if ((*writer)(ai, ridcode, iobuf, comp->len, 1)) { in writerids()
7972 return -EIO; in writerids()
7991 /* Only super-user can modify flash */ in flashcard()
7993 return -EPERM; in flashcard()
7995 switch(comp->command) in flashcard()
7998 return cmdreset((struct airo_info *)dev->ml_priv); in flashcard()
8003 return -ENOMEM; in flashcard()
8004 return setflashmode((struct airo_info *)dev->ml_priv); in flashcard()
8007 if (comp->len != sizeof(int)) in flashcard()
8008 return -EINVAL; in flashcard()
8009 if (copy_from_user(&z, comp->data, comp->len)) in flashcard()
8010 return -EFAULT; in flashcard()
8011 return flashgchar((struct airo_info *)dev->ml_priv, z, 8000); in flashcard()
8014 if (comp->len != sizeof(int)) in flashcard()
8015 return -EINVAL; in flashcard()
8016 if (copy_from_user(&z, comp->data, comp->len)) in flashcard()
8017 return -EFAULT; in flashcard()
8018 return flashpchar((struct airo_info *)dev->ml_priv, z, 8000); in flashcard()
8022 return -ENOMEM; in flashcard()
8023 if (comp->len > FLASHSIZE) in flashcard()
8024 return -EINVAL; in flashcard()
8025 if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len)) in flashcard()
8026 return -EFAULT; in flashcard()
8028 flashputbuf((struct airo_info *)dev->ml_priv); in flashcard()
8032 if (flashrestart((struct airo_info *)dev->ml_priv, dev)) in flashcard()
8033 return -EIO; in flashcard()
8036 return -EINVAL; in flashcard()
8052 airo_print_info(ai->dev->name, "Waitbusy hang before RESET"); in cmdreset()
8053 return -EBUSY; in cmdreset()
8061 airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET"); in cmdreset()
8062 return -EBUSY; in cmdreset()
8074 set_bit (FLAG_FLASHING, &ai->flags); in setflashmode()
8089 clear_bit (FLAG_FLASHING, &ai->flags); in setflashmode()
8090 airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode"); in setflashmode()
8091 return -EIO; in setflashmode()
8115 waittime -= 50; in flashpchar()
8120 airo_print_info(ai->dev->name, "flash putchar busywait timeout!"); in flashpchar()
8121 return -EBUSY; in flashpchar()
8128 dwelltime -= 50; in flashpchar()
8134 return (echo == byte) ? 0 : -EIO; in flashpchar()
8150 dwelltime -= 10; in flashgchar()
8165 return -EIO; in flashgchar()
8178 if (test_bit(FLAG_MPI,&ai->flags)) in flashputbuf()
8179 memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE); in flashputbuf()
8185 OUT4500(ai, AUXDATA, ai->flash[nwords] & 0xffff); in flashputbuf()
8201 clear_bit (FLAG_FLASHING, &ai->flags); in flashrestart()
8202 if (test_bit(FLAG_MPI, &ai->flags)) { in flashrestart()
8207 status = setup_card(ai, dev->dev_addr, 1); in flashrestart()
8209 if (!test_bit(FLAG_MPI,&ai->flags)) in flashrestart()
8211 ai->fids[i] = transmit_allocate in flashrestart()