Lines Matching +full:mic +full:- +full:offset

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 };
260 …"If non-zero, the driver will keep looping through the authentication options until an association…
265 …"If non-zero, the driver will switch into a mode that seems to work better for older cards with so…
274 MODULE_PARM_DESC(adhoc, "If non-zero, the card will start in adhoc mode.");
294 #define ERROR -1
295 #define NO_PACKET -2
398 /* Offset into aux memory for descriptors */
499 * Rids and endian-ness: The Rids will always be in cpu endian, since
500 * this all the patches from the big-endian guys end up doing that.
554 #define MODE_MIC cpu_to_le16(1<<15) /* enable MIC */
561 #define RXMODE_LANMON cpu_to_le16(5) /* lan style monitor -- data packets only */
580 /*---------- Scanning/Associating ----------*/
605 /*---------- Power save operation ----------*/
616 /*---------- Ap/Ibss config items ----------*/
625 /*---------- Radio configuration ----------*/
643 /*---------- Aironet Extensions ----------*/
649 /*---------- Aironet Extensions ----------*/
846 __be32 mic; member
868 /* Warning : SIOCDEVPRIVATE may disapear during 2.5.X - Jean II */
880 * is usually a problem. - Jean II */
936 unsigned char __user *data; // d-data
949 u8 enabled; // MIC enabled or not
951 u32 rxIncorrectMIC; // pkts dropped due to incorrect MIC comparison
952 u32 rxNotMICed; // pkts dropped due to not being MIC'd
953 u32 rxMICPlummed; // pkts dropped due to not having a MIC plummed
960 u64 accum; // accumulated mic, reduced to u32 in final()
961 int position; // current position (byte offset) in message
969 emmh32_context seed; // Context - the seed
990 unsigned int offset: 15; member
1017 unsigned char __iomem *card_ram_off; /* offset into card memory of the
1029 unsigned char __iomem *card_ram_off; /* offset into card memory of the
1041 unsigned char __iomem *card_ram_off; /* offset into card memory of the
1096 #define MIN_KEY_SIZE 5 // 40 bits RC4 - WEP
1099 u8 key[16]; /* 40-bit and 104-bit keys */
1119 static int bap_setup(struct airo_info*, u16 rid, u16 offset, int whichbap);
1157 static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket, u16 payLen);
1167 /* Note, we can have MAX_FIDS outstanding. FIDs are 16-bits, so we
1181 #define FLAG_ADHOC 3 /* Needed by MIC */
1186 #define FLAG_PROMISC 8 /* IFF_PROMISC 0x100 - include/linux/if.h */
1224 /* MIC stuff */
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)
1293 * MIC ROUTINES *
1309 /* If the current MIC context is valid and its key is the same as in age_mic_context()
1310 * the MIC register, there's nothing to do. in age_mic_context()
1312 if (cur->valid && (memcmp(cur->key, key, key_len) == 0)) in age_mic_context()
1315 /* Age current mic Context */ 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()
1325 /* Give key to mic seed */ 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()
1341 /* So next time we have a valid key and mic is enabled, we will 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()
1387 * Description: Mic a packet
1392 * PacketTxLen will be updated with the mic'd packets size.
1395 * be big enough to hold the largets mic message possible.
1402 static int encapsulate(struct airo_info *ai, etherHead *frame, MICBuffer *mic, int payLen) in encapsulate() argument
1409 if (test_bit(FLAG_ADHOC, &ai->flags) && (frame->da[0] & 0x1)) in encapsulate()
1410 context = &ai->mod[0].mCtx; in encapsulate()
1412 context = &ai->mod[0].uCtx; in encapsulate()
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()
1446 * Description: Decapsulates a MIC'd packet and returns the 802.3 packet
1447 * (removes the MIC stuff) if packet is a valid packet.
1451 * Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE
1455 *---------------------------------------------------------------------------
1458 static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *eth, u16 payLen) in decapsulate() argument
1466 // Check if the packet is a Mic'd packet in decapsulate()
1468 if (!ai->micstats.enabled) { in decapsulate()
1469 //No Mic set or Mic OFF but we received a MIC'd packet. 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()
1481 // Mic enabled but packet isn't Mic'd in decapsulate()
1482 ai->micstats.rxMICPlummed++; in decapsulate()
1486 micSEQ = ntohl(mic->seq); //store SEQ as CPU order in decapsulate()
1488 //At this point we a have a mic'd packet and mic is enabled in decapsulate()
1489 //Now do the mic error checking. 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()
1518 //Calculate MIC in decapsulate()
1519 emmh32_final(&context->seed, digest); in decapsulate()
1521 if (memcmp(digest, &mic->mic, 4)) { //Make sure the mics match in decapsulate()
1522 //Invalid Mic 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()
1632 /* mic accumulate */
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()
1661 /* prepare for calculation of a new mic */
1664 /* prepare for new mic calculation */ in emmh32_init()
1665 context->accum = 0; in emmh32_init()
1666 context->position = 0; in emmh32_init()
1669 /* add some bytes to the mic calculation */
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()
1711 /* calculate the mic */
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()
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()
2081 * another bap_setup(). We are at offset 0x6 and 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, may_sleep); 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, may_sleep); 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()
2291 set_bit(JOB_STATS, &local->jobs); in airo_get_stats()
2292 wake_up_interruptible(&local->thr_wait); in airo_get_stats()
2295 return &dev->stats; in airo_get_stats()
2305 clear_bit(JOB_PROMISC, &ai->jobs); in airo_set_promisc()
2306 cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; in airo_set_promisc()
2308 up(&ai->sem); in airo_set_promisc()
2313 struct airo_info *ai = dev->ml_priv; in airo_set_multicast_list()
2315 if ((dev->flags ^ ai->flags) & IFF_PROMISC) { in airo_set_multicast_list()
2316 change_bit(FLAG_PROMISC, &ai->flags); in airo_set_multicast_list()
2317 if (down_trylock(&ai->sem) != 0) { in airo_set_multicast_list()
2318 set_bit(JOB_PROMISC, &ai->jobs); in airo_set_multicast_list()
2319 wake_up_interruptible(&ai->thr_wait); in airo_set_multicast_list()
2324 if ((dev->flags&IFF_ALLMULTI) || !netdev_mc_empty(dev)) { in airo_set_multicast_list()
2331 struct airo_info *ai = dev->ml_priv; in airo_set_mac_address()
2335 memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); in airo_set_mac_address()
2336 set_bit (FLAG_COMMIT, &ai->flags); in airo_set_mac_address()
2340 dev_addr_set(ai->dev, addr->sa_data); in airo_set_mac_address()
2341 if (ai->wifidev) in airo_set_mac_address()
2342 dev_addr_set(ai->wifidev, addr->sa_data); in airo_set_mac_address()
2351 * so we only need to remember our non-PCI cards. */ in add_airo_dev()
2352 if (!ai->pci) in add_airo_dev()
2353 list_add_tail(&ai->dev_list, &airo_devices); in add_airo_dev()
2358 if (!ai->pci) in del_airo_dev()
2359 list_del(&ai->dev_list); in del_airo_dev()
2364 struct airo_info *ai = dev->ml_priv; in airo_close()
2368 if (ai->wifidev != dev) { in airo_close()
2375 set_bit(FLAG_RADIO_DOWN, &ai->flags); in airo_close()
2380 free_irq(dev->irq, dev); in airo_close()
2382 set_bit(JOB_DIE, &ai->jobs); in airo_close()
2383 kthread_stop(ai->airo_thread_task); in airo_close()
2390 struct airo_info *ai = dev->ml_priv; in stop_airo_card()
2392 set_bit(FLAG_RADIO_DOWN, &ai->flags); in stop_airo_card()
2396 if (test_bit(FLAG_REGISTERED, &ai->flags)) { in stop_airo_card()
2398 if (ai->wifidev) { in stop_airo_card()
2399 unregister_netdev(ai->wifidev); in stop_airo_card()
2400 free_netdev(ai->wifidev); in stop_airo_card()
2401 ai->wifidev = NULL; in stop_airo_card()
2403 clear_bit(FLAG_REGISTERED, &ai->flags); in stop_airo_card()
2408 if (test_bit(FLAG_MPI, &ai->flags) && !skb_queue_empty(&ai->txq)) { in stop_airo_card()
2410 for (;(skb = skb_dequeue(&ai->txq));) in stop_airo_card()
2416 kfree(ai->flash); in stop_airo_card()
2417 kfree(ai->rssi); in stop_airo_card()
2418 kfree(ai->SSID); in stop_airo_card()
2421 release_region(dev->base_addr, 64); in stop_airo_card()
2422 if (test_bit(FLAG_MPI, &ai->flags)) { in stop_airo_card()
2423 if (ai->pci) in stop_airo_card()
2424 mpi_unmap_card(ai->pci); in stop_airo_card()
2425 if (ai->pcimem) in stop_airo_card()
2426 iounmap(ai->pcimem); in stop_airo_card()
2427 if (ai->pciaux) in stop_airo_card()
2428 iounmap(ai->pciaux); in stop_airo_card()
2429 dma_free_coherent(&ai->pci->dev, PCI_SHARED_LEN, in stop_airo_card()
2430 ai->shared, ai->shared_dma); in stop_airo_card()
2433 crypto_free_sync_skcipher(ai->tfm); in stop_airo_card()
2472 netif_stop_queue(ai->dev); in mpi_init_descriptors()
2479 cmd.parm1 = (ai->rxfids[0].card_ram_off - ai->pciaux); in mpi_init_descriptors()
2483 airo_print_err(ai->dev->name, "Couldn't allocate RX FID"); in mpi_init_descriptors()
2488 memcpy_toio(ai->rxfids[i].card_ram_off, in mpi_init_descriptors()
2489 &ai->rxfids[i].rx_desc, sizeof(RxFid)); in mpi_init_descriptors()
2499 cmd.parm1 = (ai->txfids[0].card_ram_off - ai->pciaux); in mpi_init_descriptors()
2503 ai->txfids[i].tx_desc.valid = 1; in mpi_init_descriptors()
2504 memcpy_toio(ai->txfids[i].card_ram_off, in mpi_init_descriptors()
2505 &ai->txfids[i].tx_desc, sizeof(TxFid)); in mpi_init_descriptors()
2507 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ in mpi_init_descriptors()
2511 airo_print_err(ai->dev->name, "Couldn't allocate TX FID"); in mpi_init_descriptors()
2521 cmd.parm1 = (ai->config_desc.card_ram_off - ai->pciaux); in mpi_init_descriptors()
2525 airo_print_err(ai->dev->name, "Couldn't allocate RID"); in mpi_init_descriptors()
2529 memcpy_toio(ai->config_desc.card_ram_off, in mpi_init_descriptors()
2530 &ai->config_desc.rid_desc, sizeof(Rid)); in mpi_init_descriptors()
2544 int rc = -1; in mpi_map_card()
2566 ai->pcimem = ioremap(mem_start, mem_len); in mpi_map_card()
2567 if (!ai->pcimem) { in mpi_map_card()
2572 ai->pciaux = ioremap(aux_start, aux_len); in mpi_map_card()
2573 if (!ai->pciaux) { in mpi_map_card()
2580 ai->shared = dma_alloc_coherent(&pci->dev, PCI_SHARED_LEN, in mpi_map_card()
2581 &ai->shared_dma, GFP_KERNEL); in mpi_map_card()
2582 if (!ai->shared) { in mpi_map_card()
2591 busaddroff = ai->shared_dma; in mpi_map_card()
2592 pciaddroff = ai->pciaux + AUX_OFFSET; in mpi_map_card()
2593 vpackoff = ai->shared; in mpi_map_card()
2597 ai->rxfids[i].pending = 0; in mpi_map_card()
2598 ai->rxfids[i].card_ram_off = pciaddroff; in mpi_map_card()
2599 ai->rxfids[i].virtual_host_addr = vpackoff; in mpi_map_card()
2600 ai->rxfids[i].rx_desc.host_addr = busaddroff; in mpi_map_card()
2601 ai->rxfids[i].rx_desc.valid = 1; in mpi_map_card()
2602 ai->rxfids[i].rx_desc.len = PKTSIZE; in mpi_map_card()
2603 ai->rxfids[i].rx_desc.rdy = 0; in mpi_map_card()
2612 ai->txfids[i].card_ram_off = pciaddroff; in mpi_map_card()
2613 ai->txfids[i].virtual_host_addr = vpackoff; in mpi_map_card()
2614 ai->txfids[i].tx_desc.valid = 1; in mpi_map_card()
2615 ai->txfids[i].tx_desc.host_addr = busaddroff; in mpi_map_card()
2616 memcpy(ai->txfids[i].virtual_host_addr, in mpi_map_card()
2623 ai->txfids[i-1].tx_desc.eoc = 1; /* Last descriptor has EOC set */ in mpi_map_card()
2626 ai->config_desc.card_ram_off = pciaddroff; in mpi_map_card()
2627 ai->config_desc.virtual_host_addr = vpackoff; in mpi_map_card()
2628 ai->config_desc.rid_desc.host_addr = busaddroff; in mpi_map_card()
2629 ai->ridbus = busaddroff; in mpi_map_card()
2630 ai->config_desc.rid_desc.rid = 0; in mpi_map_card()
2631 ai->config_desc.rid_desc.len = RIDSIZE; in mpi_map_card()
2632 ai->config_desc.rid_desc.valid = 1; in mpi_map_card()
2643 dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared, in mpi_map_card()
2644 ai->shared_dma); in mpi_map_card()
2646 iounmap(ai->pciaux); in mpi_map_card()
2648 iounmap(ai->pcimem); in mpi_map_card()
2672 dev->netdev_ops = &airo11_netdev_ops; in wifi_setup()
2673 dev->header_ops = &airo_header_ops; in wifi_setup()
2674 dev->wireless_handlers = &airo_handler_def; in wifi_setup()
2676 dev->type = ARPHRD_IEEE80211; in wifi_setup()
2677 dev->hard_header_len = ETH_HLEN; in wifi_setup()
2678 dev->mtu = AIRO_DEF_MTU; in wifi_setup()
2679 dev->min_mtu = 68; in wifi_setup()
2680 dev->max_mtu = MIC_MSGLEN_MAX; in wifi_setup()
2681 dev->addr_len = ETH_ALEN; in wifi_setup()
2682 dev->tx_queue_len = 100; in wifi_setup()
2684 eth_broadcast_addr(dev->broadcast); in wifi_setup()
2686 dev->flags = IFF_BROADCAST|IFF_MULTICAST; in wifi_setup()
2697 dev->ml_priv = ethdev->ml_priv; in init_wifidev()
2698 dev->irq = ethdev->irq; in init_wifidev()
2699 dev->base_addr = ethdev->base_addr; in init_wifidev()
2700 dev->wireless_data = ethdev->wireless_data; in init_wifidev()
2701 SET_NETDEV_DEV(dev, ethdev->dev.parent); in init_wifidev()
2713 struct airo_info *ai = dev->ml_priv; in reset_card()
2715 if (lock && down_interruptible(&ai->sem)) in reset_card()
2716 return -1; in reset_card()
2723 up(&ai->sem); in reset_card()
2730 if (ai->networks) in airo_networks_allocate()
2733 ai->networks = kcalloc(AIRO_MAX_NETWORK_COUNT, sizeof(BSSListElement), in airo_networks_allocate()
2735 if (!ai->networks) { in airo_networks_allocate()
2737 return -ENOMEM; in airo_networks_allocate()
2745 kfree(ai->networks); in airo_networks_free()
2746 ai->networks = NULL; in airo_networks_free()
2753 INIT_LIST_HEAD(&ai->network_free_list); in airo_networks_initialize()
2754 INIT_LIST_HEAD(&ai->network_list); in airo_networks_initialize()
2756 list_add_tail(&ai->networks[i].list, in airo_networks_initialize()
2757 &ai->network_free_list); in airo_networks_initialize()
2799 ai = dev->ml_priv = netdev_priv(dev); in _init_airo_card()
2800 ai->wifidev = NULL; in _init_airo_card()
2801 ai->flags = 1 << FLAG_RADIO_DOWN; in _init_airo_card()
2802 ai->jobs = 0; in _init_airo_card()
2803 ai->dev = dev; in _init_airo_card()
2804 if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { in _init_airo_card()
2806 set_bit(FLAG_MPI, &ai->flags); in _init_airo_card()
2808 spin_lock_init(&ai->aux_lock); in _init_airo_card()
2809 sema_init(&ai->sem, 1); in _init_airo_card()
2810 ai->config.len = 0; in _init_airo_card()
2811 ai->pci = pci; in _init_airo_card()
2812 init_waitqueue_head (&ai->thr_wait); in _init_airo_card()
2813 ai->tfm = NULL; in _init_airo_card()
2815 ai->APList.len = cpu_to_le16(sizeof(struct APListRid)); in _init_airo_card()
2821 skb_queue_head_init (&ai->txq); in _init_airo_card()
2823 /* The Airo-specific entries in the device structure. */ in _init_airo_card()
2824 if (test_bit(FLAG_MPI,&ai->flags)) in _init_airo_card()
2825 dev->netdev_ops = &mpi_netdev_ops; in _init_airo_card()
2827 dev->netdev_ops = &airo_netdev_ops; in _init_airo_card()
2828 dev->wireless_handlers = &airo_handler_def; in _init_airo_card()
2829 ai->wireless_data.spy_data = &ai->spy_data; in _init_airo_card()
2830 dev->wireless_data = &ai->wireless_data; in _init_airo_card()
2831 dev->irq = irq; in _init_airo_card()
2832 dev->base_addr = port; in _init_airo_card()
2833 dev->priv_flags &= ~IFF_TX_SKB_SHARING; in _init_airo_card()
2834 dev->max_mtu = MIC_MSGLEN_MAX; in _init_airo_card()
2842 if (!request_region(dev->base_addr, 64, DRV_NAME)) { in _init_airo_card()
2843 rc = -EBUSY; in _init_airo_card()
2844 airo_print_err(dev->name, "Couldn't request region"); in _init_airo_card()
2849 if (test_bit(FLAG_MPI,&ai->flags)) { in _init_airo_card()
2858 airo_print_err(dev->name, "MAC could not be enabled"); in _init_airo_card()
2859 rc = -EIO; in _init_airo_card()
2862 } else if (!test_bit(FLAG_MPI,&ai->flags)) { in _init_airo_card()
2863 ai->bap_read = fast_bap_read; in _init_airo_card()
2864 set_bit(FLAG_FLASHING, &ai->flags); in _init_airo_card()
2867 strcpy(dev->name, "eth%d"); in _init_airo_card()
2870 airo_print_err(dev->name, "Couldn't register_netdev"); in _init_airo_card()
2873 ai->wifidev = init_wifidev(ai, dev); in _init_airo_card()
2874 if (!ai->wifidev) in _init_airo_card()
2879 rc = -EIO; in _init_airo_card()
2883 ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0; in _init_airo_card()
2884 ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0; in _init_airo_card()
2886 airo_print_info(dev->name, "Firmware version %x.%x.%02d", in _init_airo_card()
2896 airo_print_info(ai->dev->name, "WPA supported."); in _init_airo_card()
2898 set_bit(FLAG_WPA_CAPABLE, &ai->flags); in _init_airo_card()
2899 ai->bssListFirst = RID_WPA_BSSLISTFIRST; in _init_airo_card()
2900 ai->bssListNext = RID_WPA_BSSLISTNEXT; in _init_airo_card()
2901 ai->bssListRidLen = sizeof(BSSListRid); in _init_airo_card()
2903 airo_print_info(ai->dev->name, "WPA unsupported with firmware " in _init_airo_card()
2906 ai->bssListFirst = RID_BSSLISTFIRST; in _init_airo_card()
2907 ai->bssListNext = RID_BSSLISTNEXT; in _init_airo_card()
2908 ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); in _init_airo_card()
2911 set_bit(FLAG_REGISTERED,&ai->flags); in _init_airo_card()
2912 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr); in _init_airo_card()
2915 if (probe && !test_bit(FLAG_MPI,&ai->flags)) in _init_airo_card()
2917 ai->fids[i] = transmit_allocate(ai, AIRO_DEF_MTU, i>=MAX_FIDS/2); in _init_airo_card()
2919 if (setup_proc_entry(dev, dev->ml_priv) < 0) in _init_airo_card()
2925 unregister_netdev(ai->wifidev); in _init_airo_card()
2926 free_netdev(ai->wifidev); in _init_airo_card()
2930 if (test_bit(FLAG_MPI,&ai->flags) && pci) { in _init_airo_card()
2931 dma_free_coherent(&pci->dev, PCI_SHARED_LEN, ai->shared, in _init_airo_card()
2932 ai->shared_dma); in _init_airo_card()
2933 iounmap(ai->pciaux); in _init_airo_card()
2934 iounmap(ai->pcimem); in _init_airo_card()
2935 mpi_unmap_card(ai->pci); in _init_airo_card()
2939 release_region(dev->base_addr, 64); in _init_airo_card()
2970 struct airo_info *ai = dev->ml_priv; in reset_airo_card()
2973 return -1; in reset_airo_card()
2976 airo_print_err(dev->name, "MAC could not be enabled"); in reset_airo_card()
2977 return -1; in reset_airo_card()
2979 airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr); in reset_airo_card()
2981 if (!test_bit(FLAG_MPI,&ai->flags)) in reset_airo_card()
2983 ai->fids[i] = transmit_allocate (ai, AIRO_DEF_MTU, i>=MAX_FIDS/2); in reset_airo_card()
2994 struct airo_info *ai = dev->ml_priv; in airo_send_event()
2998 clear_bit(JOB_EVENT, &ai->jobs); in airo_send_event()
3000 up(&ai->sem); in airo_send_event()
3019 list_for_each_entry_safe (loop_net, tmp_net, &ai->network_list, list) { in airo_process_scan_results()
3020 list_move_tail (&loop_net->list, &ai->network_free_list); in airo_process_scan_results()
3021 /* Don't blow away ->list, just BSS data */ in airo_process_scan_results()
3022 memset (loop_net, 0, sizeof (loop_net->bss)); in airo_process_scan_results()
3026 rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0); in airo_process_scan_results()
3036 if (!list_empty(&ai->network_free_list)) { in airo_process_scan_results()
3037 tmp_net = list_entry(ai->network_free_list.next, in airo_process_scan_results()
3039 list_del(ai->network_free_list.next); in airo_process_scan_results()
3043 memcpy(tmp_net, &bss, sizeof(tmp_net->bss)); in airo_process_scan_results()
3044 list_add_tail(&tmp_net->list, &ai->network_list); in airo_process_scan_results()
3049 rc = PC4500_readrid(ai, ai->bssListNext, in airo_process_scan_results()
3050 &bss, ai->bssListRidLen, 0); in airo_process_scan_results()
3056 writeAPListRid(ai, &ai->APList, 0); in airo_process_scan_results()
3059 ai->scan_timeout = 0; in airo_process_scan_results()
3060 clear_bit(JOB_SCAN_RESULTS, &ai->jobs); in airo_process_scan_results()
3061 up(&ai->sem); in airo_process_scan_results()
3069 * extract the data - Jean II */ in airo_process_scan_results()
3072 wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL); in airo_process_scan_results()
3078 struct airo_info *ai = dev->ml_priv; in airo_thread()
3086 if (test_bit(JOB_DIE, &ai->jobs)) in airo_thread()
3089 if (ai->jobs) { in airo_thread()
3090 locked = down_interruptible(&ai->sem); in airo_thread()
3095 add_wait_queue(&ai->thr_wait, &wait); in airo_thread()
3098 if (ai->jobs) in airo_thread()
3100 if (ai->expires || ai->scan_timeout) { in airo_thread()
3101 if (ai->scan_timeout && in airo_thread()
3102 time_after_eq(jiffies, ai->scan_timeout)) { in airo_thread()
3103 set_bit(JOB_SCAN_RESULTS, &ai->jobs); in airo_thread()
3105 } else if (ai->expires && in airo_thread()
3106 time_after_eq(jiffies, ai->expires)) { in airo_thread()
3107 set_bit(JOB_AUTOWEP, &ai->jobs); in airo_thread()
3113 if (!ai->expires || !ai->scan_timeout) { in airo_thread()
3114 wake_at = max(ai->expires, in airo_thread()
3115 ai->scan_timeout); in airo_thread()
3117 wake_at = min(ai->expires, in airo_thread()
3118 ai->scan_timeout); in airo_thread()
3120 schedule_timeout(wake_at - jiffies); in airo_thread()
3131 remove_wait_queue(&ai->thr_wait, &wait); in airo_thread()
3138 if (test_bit(JOB_DIE, &ai->jobs)) { in airo_thread()
3139 up(&ai->sem); in airo_thread()
3143 if (ai->power.event || test_bit(FLAG_FLASHING, &ai->flags)) { in airo_thread()
3144 up(&ai->sem); in airo_thread()
3148 if (test_bit(JOB_XMIT, &ai->jobs)) in airo_thread()
3150 else if (test_bit(JOB_XMIT11, &ai->jobs)) in airo_thread()
3152 else if (test_bit(JOB_STATS, &ai->jobs)) in airo_thread()
3154 else if (test_bit(JOB_PROMISC, &ai->jobs)) in airo_thread()
3156 else if (test_bit(JOB_MIC, &ai->jobs)) in airo_thread()
3158 else if (test_bit(JOB_EVENT, &ai->jobs)) in airo_thread()
3160 else if (test_bit(JOB_AUTOWEP, &ai->jobs)) in airo_thread()
3162 else if (test_bit(JOB_SCAN_RESULTS, &ai->jobs)) in airo_thread()
3165 up(&ai->sem); in airo_thread()
3177 return 10; /* one-address control packet */ in header_len()
3178 return 16; /* two-address control packet */ in header_len()
3188 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags)) { in airo_handle_cisco_mic()
3189 set_bit(JOB_MIC, &ai->jobs); in airo_handle_cisco_mic()
3190 wake_up_interruptible(&ai->thr_wait); in airo_handle_cisco_mic()
3195 #define STAT_NOBEACON 0x8000 /* Loss of sync - missed beacons */
3196 #define STAT_MAXRETRIES 0x8001 /* Loss of sync - max retries */
3197 #define STAT_MAXARL 0x8002 /* Loss of sync - average retry level exceeded*/
3198 #define STAT_FORCELOSS 0x8003 /* Loss of sync - host request */
3199 #define STAT_TSFSYNC 0x8004 /* Loss of sync - TSF synchronization */
3265 if ((status == STAT_FORCELOSS) && (ai->scan_timeout > 0)) in airo_handle_link()
3268 airo_print_status(ai->dev->name, status); in airo_handle_link()
3272 ai->expires = 0; in airo_handle_link()
3273 if (ai->list_bss_task) in airo_handle_link()
3274 wake_up_process(ai->list_bss_task); in airo_handle_link()
3275 set_bit(FLAG_UPDATE_UNI, &ai->flags); in airo_handle_link()
3276 set_bit(FLAG_UPDATE_MULTI, &ai->flags); in airo_handle_link()
3278 set_bit(JOB_EVENT, &ai->jobs); in airo_handle_link()
3279 wake_up_interruptible(&ai->thr_wait); in airo_handle_link()
3281 netif_carrier_on(ai->dev); in airo_handle_link()
3283 if (auto_wep && !ai->expires) { in airo_handle_link()
3284 ai->expires = RUN_AT(3*HZ); in airo_handle_link()
3285 wake_up_interruptible(&ai->thr_wait); in airo_handle_link()
3291 wireless_send_event(ai->dev, SIOCGIWAP, &wrqu, NULL); in airo_handle_link()
3292 netif_carrier_off(ai->dev); in airo_handle_link()
3294 netif_carrier_off(ai->dev); in airo_handle_link()
3306 if (test_bit(FLAG_MPI, &ai->flags)) { in airo_handle_rx()
3307 if (test_bit(FLAG_802_11, &ai->flags)) in airo_handle_rx()
3318 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3324 if (ai->wifidev == NULL) in airo_handle_rx()
3333 airo_print_err(ai->dev->name, "Bad size %d", len); in airo_handle_rx()
3339 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3347 ai->dev->stats.rx_dropped++; in airo_handle_rx()
3353 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3355 bap_read(ai, buffer + 1, hdrlen - 2, BAP0); in airo_handle_rx()
3365 airo_print_err(ai->dev->name, "gaplen too " in airo_handle_rx()
3374 if (ai->micstats.enabled) { in airo_handle_rx()
3384 len -= sizeof(micbuf); in airo_handle_rx()
3397 if (success && (ai->spy_data.spy_number > 0)) { in airo_handle_rx()
3402 if (!test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3409 if (ai->rssi) in airo_handle_rx()
3410 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; in airo_handle_rx()
3413 wstats.noise = ai->wstats.qual.noise; in airo_handle_rx()
3418 wireless_spy_update(ai->dev, sa, &wstats); in airo_handle_rx()
3426 if (test_bit(FLAG_802_11, &ai->flags)) { in airo_handle_rx()
3428 skb->pkt_type = PACKET_OTHERHOST; in airo_handle_rx()
3429 skb->dev = ai->wifidev; in airo_handle_rx()
3430 skb->protocol = htons(ETH_P_802_2); in airo_handle_rx()
3432 skb->protocol = eth_type_trans(skb, ai->dev); in airo_handle_rx()
3433 skb->ip_summed = CHECKSUM_NONE; in airo_handle_rx()
3441 int i, index = -1; in airo_handle_tx()
3444 if (test_bit(FLAG_MPI, &ai->flags)) { in airo_handle_tx()
3448 get_tx_error(ai, -1); in airo_handle_tx()
3450 spin_lock_irqsave(&ai->aux_lock, flags); in airo_handle_tx()
3451 if (!skb_queue_empty(&ai->txq)) { in airo_handle_tx()
3452 spin_unlock_irqrestore(&ai->aux_lock, flags); in airo_handle_tx()
3453 mpi_send_packet(ai->dev); in airo_handle_tx()
3455 clear_bit(FLAG_PENDING_XMIT, &ai->flags); in airo_handle_tx()
3456 spin_unlock_irqrestore(&ai->aux_lock, flags); in airo_handle_tx()
3457 netif_wake_queue(ai->dev); in airo_handle_tx()
3466 if ((ai->fids[i] & 0xffff) == fid) in airo_handle_tx()
3470 if (index != -1) { in airo_handle_tx()
3477 ai->fids[index] &= 0xffff; in airo_handle_tx()
3479 if (!test_bit(FLAG_PENDING_XMIT, &ai->flags)) in airo_handle_tx()
3480 netif_wake_queue(ai->dev); in airo_handle_tx()
3482 if (!test_bit(FLAG_PENDING_XMIT11, &ai->flags)) in airo_handle_tx()
3483 netif_wake_queue(ai->wifidev); in airo_handle_tx()
3487 airo_print_err(ai->dev->name, "Unallocated FID was used to xmit"); in airo_handle_tx()
3495 struct airo_info *ai = dev->ml_priv; in airo_interrupt()
3537 airo_print_warn(ai->dev->name, "Got weird status %x", in airo_interrupt()
3559 if (test_bit(FLAG_MPI,&ai->flags)) in OUT4500()
3562 outw(val, ai->dev->base_addr + reg); in OUT4500()
3564 outb(val & 0xff, ai->dev->base_addr + reg); in OUT4500()
3565 outb(val >> 8, ai->dev->base_addr + reg + 1); in OUT4500()
3573 if (test_bit(FLAG_MPI,&ai->flags)) in IN4500()
3576 rc = inw(ai->dev->base_addr + reg); in IN4500()
3578 rc = inb(ai->dev->base_addr + reg); in IN4500()
3579 rc += ((int)inb(ai->dev->base_addr + reg + 1)) << 8; in IN4500()
3595 * "cheaper" - Jean II */ in enable_MAC()
3596 if (ai->flags & FLAG_RADIO_MASK) return SUCCESS; in enable_MAC()
3598 if (lock && down_interruptible(&ai->sem)) in enable_MAC()
3599 return -ERESTARTSYS; in enable_MAC()
3601 if (!test_bit(FLAG_ENABLED, &ai->flags)) { in enable_MAC()
3606 set_bit(FLAG_ENABLED, &ai->flags); in enable_MAC()
3611 up(&ai->sem); in enable_MAC()
3614 airo_print_err(ai->dev->name, "Cannot enable MAC"); in enable_MAC()
3616 airo_print_err(ai->dev->name, "Bad MAC enable reason=%x, " in enable_MAC()
3617 "rid=%x, offset=%d", rsp.rsp0, rsp.rsp1, rsp.rsp2); in enable_MAC()
3628 if (lock == 1 && down_interruptible(&ai->sem)) in disable_MAC()
3631 if (test_bit(FLAG_ENABLED, &ai->flags)) { in disable_MAC()
3633 netif_carrier_off(ai->dev); in disable_MAC()
3637 clear_bit(FLAG_ENABLED, &ai->flags); in disable_MAC()
3640 up(&ai->sem); in disable_MAC()
3663 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); in mpi_receive_802_3()
3672 ai->dev->stats.rx_dropped++; in mpi_receive_802_3()
3676 memcpy(buffer, ai->rxfids[0].virtual_host_addr, ETH_ALEN * 2); in mpi_receive_802_3()
3677 if (ai->micstats.enabled) { in mpi_receive_802_3()
3679 ai->rxfids[0].virtual_host_addr + ETH_ALEN * 2, in mpi_receive_802_3()
3686 skb_trim (skb, len - off); in mpi_receive_802_3()
3690 ai->rxfids[0].virtual_host_addr + ETH_ALEN * 2 + off, in mpi_receive_802_3()
3691 len - ETH_ALEN * 2 - off); in mpi_receive_802_3()
3692 if (decapsulate (ai, &micbuf, (etherHead*)buffer, len - off - ETH_ALEN * 2)) { in mpi_receive_802_3()
3698 if (ai->spy_data.spy_number > 0) { in mpi_receive_802_3()
3707 wireless_spy_update(ai->dev, sa, &wstats); in mpi_receive_802_3()
3711 skb->ip_summed = CHECKSUM_NONE; in mpi_receive_802_3()
3712 skb->protocol = eth_type_trans(skb, ai->dev); in mpi_receive_802_3()
3720 memcpy_toio(ai->rxfids[0].card_ram_off, &rxd, sizeof(rxd)); in mpi_receive_802_3()
3733 char *ptr = ai->rxfids[0].virtual_host_addr + 4; in mpi_receive_802_11()
3735 memcpy_fromio(&rxd, ai->rxfids[0].card_ram_off, sizeof(rxd)); in mpi_receive_802_11()
3741 if (ai->wifidev == NULL) in mpi_receive_802_11()
3745 airo_print_err(ai->dev->name, "Bad size %d", len); in mpi_receive_802_11()
3756 ai->dev->stats.rx_dropped++; in mpi_receive_802_11()
3770 airo_print_err(ai->dev->name, in mpi_receive_802_11()
3776 if (ai->spy_data.spy_number > 0) { in mpi_receive_802_11()
3782 if (ai->rssi) in mpi_receive_802_11()
3783 wstats.level = 0x100 - ai->rssi[hdr.rssi[1]].rssidBm; in mpi_receive_802_11()
3786 wstats.noise = ai->wstats.qual.noise; in mpi_receive_802_11()
3791 wireless_spy_update(ai->dev, sa, &wstats); in mpi_receive_802_11()
3795 skb->pkt_type = PACKET_OTHERHOST; in mpi_receive_802_11()
3796 skb->dev = ai->wifidev; in mpi_receive_802_11()
3797 skb->protocol = htons(ETH_P_802_2); in mpi_receive_802_11()
3798 skb->ip_summed = CHECKSUM_NONE; in mpi_receive_802_11()
3806 memcpy_toio(ai->rxfids[0].card_ram_off, &rxd, sizeof(rxd)); in mpi_receive_802_11()
3812 local->config.authType = auth_type; in set_auth_type()
3817 local->last_auth = auth_type; in set_auth_type()
3830 kfree(ai->SSID); in airo_readconfig()
3831 ai->SSID = NULL; in airo_readconfig()
3841 if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) in airo_readconfig()
3842 memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ in airo_readconfig()
3845 kfree(ai->rssi); in airo_readconfig()
3846 ai->rssi = NULL; in airo_readconfig()
3848 ai->config.rmode |= RXMODE_NORMALIZED_RSSI; in airo_readconfig()
3850 airo_print_warn(ai->dev->name, "unknown received signal " in airo_readconfig()
3853 ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS; in airo_readconfig()
3855 ai->config.modulation = MOD_CCK; in airo_readconfig()
3860 ai->config.opmode |= MODE_MIC; in airo_readconfig()
3861 set_bit(FLAG_MIC_CAPABLE, &ai->flags); in airo_readconfig()
3865 eth_hw_addr_set(dev, ai->config.macAddr); in airo_readconfig()
3870 memset(ai->config.rates, 0, sizeof(ai->config.rates)); in airo_readconfig()
3872 ai->config.rates[i] = rates[i]; in airo_readconfig()
3875 set_bit (FLAG_COMMIT, &ai->flags); in airo_readconfig()
3892 kfree (ai->flash); in setup_card()
3893 ai->flash = NULL; in setup_card()
3898 if (lock && down_interruptible(&ai->sem)) in setup_card()
3902 up(&ai->sem); in setup_card()
3908 if (!test_bit(FLAG_MPI,&ai->flags)) { in setup_card()
3912 up(&ai->sem); in setup_card()
3913 airo_print_err(ai->dev->name, "Error checking for AUX port"); in setup_card()
3917 ai->bap_read = fast_bap_read; in setup_card()
3918 airo_print_dbg(ai->dev->name, "Doing fast bap_reads"); in setup_card()
3920 ai->bap_read = aux_bap_read; in setup_card()
3921 airo_print_dbg(ai->dev->name, "Doing AUX bap_reads"); in setup_card()
3925 up(&ai->sem); in setup_card()
3926 if (ai->config.len == 0) { in setup_card()
3963 ai->defindex = wkr.mac[0]; in setup_card()
3982 OUT4500(ai, PARAM0, pCmd->parm0); in issuecommand()
3983 OUT4500(ai, PARAM1, pCmd->parm1); in issuecommand()
3984 OUT4500(ai, PARAM2, pCmd->parm2); in issuecommand()
3985 OUT4500(ai, COMMAND, pCmd->cmd); in issuecommand()
3987 while (max_tries-- && (IN4500(ai, EVSTAT) & EV_CMD) == 0) { in issuecommand()
3988 if ((IN4500(ai, COMMAND)) == pCmd->cmd) in issuecommand()
3990 OUT4500(ai, COMMAND, pCmd->cmd); in issuecommand()
3995 if (max_tries == -1) { in issuecommand()
3996 airo_print_err(ai->dev->name, in issuecommand()
4004 pRsp->status = IN4500(ai, STATUS); in issuecommand()
4005 pRsp->rsp0 = IN4500(ai, RESP0); in issuecommand()
4006 pRsp->rsp1 = IN4500(ai, RESP1); in issuecommand()
4007 pRsp->rsp2 = IN4500(ai, RESP2); in issuecommand()
4008 if ((pRsp->status & 0xff00)!=0 && pCmd->cmd != CMD_SOFTRESET) in issuecommand()
4009 airo_print_err(ai->dev->name, in issuecommand()
4011 pCmd->cmd, pRsp->status, pRsp->rsp0, pRsp->rsp1, in issuecommand()
4012 pRsp->rsp2); in issuecommand()
4027 static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap) in bap_setup() argument
4033 OUT4500(ai, OFFSET0+whichbap, offset); in bap_setup()
4039 if (timeout--) { in bap_setup()
4043 /* invalid rid or offset */ in bap_setup()
4044 airo_print_err(ai->dev->name, "BAP error %x %d", in bap_setup()
4050 if (!(max_tries--)) { in bap_setup()
4051 airo_print_err(ai->dev->name, in bap_setup()
4055 // -- PC4500 missed it, try again in bap_setup()
4057 OUT4500(ai, OFFSET0+whichbap, offset); in bap_setup()
4066 u16 offset, u16 *len) in aux_setup() argument
4074 if (offset != 4) OUT4500(ai, AUXOFF, offset); in aux_setup()
4084 u16 offset; in aux_bap_read() local
4090 spin_lock_irqsave(&ai->aux_lock, flags); in aux_bap_read()
4092 offset = IN4500(ai, SWS2+whichbap); in aux_bap_read()
4093 next = aux_setup(ai, page, offset, &len); in aux_bap_read()
4098 count = (len>>1) < (words-i) ? (len>>1) : (words-i); in aux_bap_read()
4100 insw(ai->dev->base_addr+DATA0+whichbap, in aux_bap_read()
4103 insb(ai->dev->base_addr+DATA0+whichbap, in aux_bap_read()
4110 spin_unlock_irqrestore(&ai->aux_lock, flags); in aux_bap_read()
4121 insw(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen>>1); in fast_bap_read()
4123 insb(ai->dev->base_addr+DATA0+whichbap, pu16Dst, bytelen); in fast_bap_read()
4133 outsw(ai->dev->base_addr+DATA0+whichbap, in bap_write()
4136 outsb(ai->dev->base_addr+DATA0+whichbap, pu16Src, bytelen); in bap_write()
4165 if (down_interruptible(&ai->sem)) in PC4500_readrid()
4168 if (test_bit(FLAG_MPI,&ai->flags)) { in PC4500_readrid()
4174 ai->config_desc.rid_desc.valid = 1; in PC4500_readrid()
4175 ai->config_desc.rid_desc.len = RIDSIZE; in PC4500_readrid()
4176 ai->config_desc.rid_desc.rid = 0; in PC4500_readrid()
4177 ai->config_desc.rid_desc.host_addr = ai->ridbus; in PC4500_readrid()
4182 memcpy_toio(ai->config_desc.card_ram_off, in PC4500_readrid()
4183 &ai->config_desc.rid_desc, sizeof(Rid)); in PC4500_readrid()
4190 memcpy(pBuf, ai->config_desc.virtual_host_addr, len); in PC4500_readrid()
4204 len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2; in PC4500_readrid()
4207 airo_print_err(ai->dev->name, in PC4500_readrid()
4218 up(&ai->sem); in PC4500_readrid()
4233 if (down_interruptible(&ai->sem)) in PC4500_writerid()
4236 if (test_bit(FLAG_MPI,&ai->flags)) { in PC4500_writerid()
4240 if (test_bit(FLAG_ENABLED, &ai->flags) && (RID_WEP_TEMP != rid)) in PC4500_writerid()
4241 airo_print_err(ai->dev->name, in PC4500_writerid()
4247 ai->config_desc.rid_desc.valid = 1; in PC4500_writerid()
4248 ai->config_desc.rid_desc.len = *((u16 *)pBuf); in PC4500_writerid()
4249 ai->config_desc.rid_desc.rid = 0; in PC4500_writerid()
4254 memcpy_toio(ai->config_desc.card_ram_off, in PC4500_writerid()
4255 &ai->config_desc.rid_desc, sizeof(Rid)); in PC4500_writerid()
4258 airo_print_err(ai->dev->name, "%s: len=%d", __func__, len); in PC4500_writerid()
4259 rc = -1; in PC4500_writerid()
4261 memcpy(ai->config_desc.virtual_host_addr, in PC4500_writerid()
4266 airo_print_err(ai->dev->name, "%s: Write rid Error %d", in PC4500_writerid()
4268 airo_print_err(ai->dev->name, "%s: Cmd=%04x", in PC4500_writerid()
4276 // --- first access so that we can write the rid data in PC4500_writerid()
4281 // --- now write the rid data in PC4500_writerid()
4287 // ---now commit the rid data in PC4500_writerid()
4292 up(&ai->sem); in PC4500_writerid()
4308 if (down_interruptible(&ai->sem)) in transmit_allocate()
4321 while (((IN4500(ai, EVSTAT) & EV_ALLOC) == 0) && --loop); in transmit_allocate()
4348 up(&ai->sem); in transmit_allocate()
4369 airo_print_warn(ai->dev->name, "Short packet %d", len); in transmit_802_3_packet()
4372 len -= ETH_ALEN * 2; in transmit_802_3_packet()
4374 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags) && ai->micstats.enabled && in transmit_802_3_packet()
4380 // packet is destination[6], source[6], payload[len-12] in transmit_802_3_packet()
4408 static u8 tail[(30-10) + 2 + 6] = {[30-10] = 6}; in transmit_802_11_packet()
4417 airo_print_warn(ai->dev->name, "Short packet %d", len); in transmit_802_11_packet()
4426 payloadLen = cpu_to_le16(len-hdrlen); in transmit_802_11_packet()
4430 bap_write(ai, (__le16 *)(tail + (hdrlen - 10)), 38 - hdrlen, BAP1); in transmit_802_11_packet()
4432 bap_write(ai, (__le16 *)(pPacket + hdrlen), len - hdrlen, BAP1); in transmit_802_11_packet()
4451 loff_t *offset);
4456 loff_t *offset);
4547 strcpy(apriv->proc_name, dev->name); in setup_proc_entry()
4548 apriv->proc_entry = proc_mkdir_mode(apriv->proc_name, airo_perm, in setup_proc_entry()
4550 if (!apriv->proc_entry) in setup_proc_entry()
4551 return -ENOMEM; in setup_proc_entry()
4552 proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid); in setup_proc_entry()
4556 apriv->proc_entry, &proc_statsdelta_ops, dev); in setup_proc_entry()
4563 apriv->proc_entry, &proc_stats_ops, dev); in setup_proc_entry()
4570 apriv->proc_entry, &proc_status_ops, dev); in setup_proc_entry()
4577 apriv->proc_entry, &proc_config_ops, dev); in setup_proc_entry()
4584 apriv->proc_entry, &proc_SSID_ops, dev); in setup_proc_entry()
4591 apriv->proc_entry, &proc_APList_ops, dev); in setup_proc_entry()
4598 apriv->proc_entry, &proc_BSSList_ops, dev); in setup_proc_entry()
4605 apriv->proc_entry, &proc_wepkey_ops, dev); in setup_proc_entry()
4612 remove_proc_subtree(apriv->proc_name, airo_entry); in setup_proc_entry()
4613 return -ENOMEM; in setup_proc_entry()
4619 remove_proc_subtree(apriv->proc_name, airo_entry); in takedown_proc_entry()
4638 loff_t *offset) in proc_read() argument
4640 struct proc_data *priv = file->private_data; in proc_read()
4642 if (!priv->rbuffer) in proc_read()
4643 return -EINVAL; in proc_read()
4645 return simple_read_from_buffer(buffer, len, offset, priv->rbuffer, in proc_read()
4646 priv->readlen); in proc_read()
4656 loff_t *offset) in proc_write() argument
4659 struct proc_data *priv = file->private_data; in proc_write()
4661 if (!priv->wbuffer) in proc_write()
4662 return -EINVAL; in proc_write()
4664 ret = simple_write_to_buffer(priv->wbuffer, priv->maxwritelen, offset, in proc_write()
4667 priv->writelen = max_t(int, priv->writelen, *offset); in proc_write()
4676 struct airo_info *apriv = dev->ml_priv; in proc_status_open()
4682 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_status_open()
4683 return -ENOMEM; in proc_status_open()
4684 data = file->private_data; in proc_status_open()
4685 if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) { in proc_status_open()
4686 kfree (file->private_data); in proc_status_open()
4687 return -ENOMEM; in proc_status_open()
4695 i = sprintf(data->rbuffer, "Status: %s%s%s%s%s%s%s%s%s\n", in proc_status_open()
4705 sprintf(data->rbuffer+i, "Mode: %x\n" in proc_status_open()
4708 "SSID: %-.*s\n" in proc_status_open()
4709 "AP: %-.16s\n" in proc_status_open()
4735 data->readlen = strlen(data->rbuffer); in proc_status_open()
4743 if (file->f_mode&FMODE_WRITE) { in proc_statsdelta_open()
4760 struct airo_info *apriv = dev->ml_priv; in proc_stats_rid_open()
4766 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_stats_rid_open()
4767 return -ENOMEM; in proc_stats_rid_open()
4768 data = file->private_data; in proc_stats_rid_open()
4769 if ((data->rbuffer = kmalloc(4096, GFP_KERNEL)) == NULL) { in proc_stats_rid_open()
4770 kfree (file->private_data); in proc_stats_rid_open()
4771 return -ENOMEM; in proc_stats_rid_open()
4778 for (i = 0; statsLabels[i]!=(char *)-1 && i*4<len; i++) { in proc_stats_rid_open()
4781 airo_print_warn(apriv->dev->name, in proc_stats_rid_open()
4785 j+=sprintf(data->rbuffer+j, "%s: %u\n", statsLabels[i], in proc_stats_rid_open()
4789 airo_print_warn(apriv->dev->name, "Got a short rid"); in proc_stats_rid_open()
4791 data->readlen = j; in proc_stats_rid_open()
4803 value += buffer[*start] - '0'; in get_dec_u16()
4805 if (!valid) return -1; in get_dec_u16()
4815 return (le16_to_cpu(ai->config.rmode) & le16_to_cpu(RXMODE_MASK)) >= in sniffing_mode()
4821 struct proc_data *data = file->private_data; in proc_config_on_close()
4823 struct airo_info *ai = dev->ml_priv; in proc_config_on_close()
4826 if (!data->writelen) return; in proc_config_on_close()
4829 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4831 line = data->wbuffer; in proc_config_on_close()
4837 set_bit (FLAG_RESET, &ai->flags); in proc_config_on_close()
4838 ai->config.rmode &= ~RXMODE_FULL_MASK; in proc_config_on_close()
4839 clear_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4840 ai->config.opmode &= ~MODE_CFG_MASK; in proc_config_on_close()
4841 ai->config.scanMode = SCANMODE_ACTIVE; in proc_config_on_close()
4843 ai->config.opmode |= MODE_STA_IBSS; in proc_config_on_close()
4845 ai->config.opmode |= MODE_STA_ESS; in proc_config_on_close()
4847 ai->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; in proc_config_on_close()
4848 ai->config.scanMode = SCANMODE_PASSIVE; in proc_config_on_close()
4849 set_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4851 ai->config.rmode |= RXMODE_RFMON_ANYBSS | RXMODE_DISABLE_802_3_HEADER; in proc_config_on_close()
4852 ai->config.scanMode = SCANMODE_PASSIVE; in proc_config_on_close()
4853 set_bit (FLAG_802_11, &ai->flags); in proc_config_on_close()
4855 ai->config.rmode |= RXMODE_LANMON; in proc_config_on_close()
4857 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4864 set_bit (FLAG_RADIO_OFF, &ai->flags); in proc_config_on_close()
4866 clear_bit (FLAG_RADIO_OFF, &ai->flags); in proc_config_on_close()
4874 memset(ai->config.nodeName, 0, 16); in proc_config_on_close()
4877 ai->config.nodeName[j] = line[j]; in proc_config_on_close()
4879 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4886 ai->config.powerSaveMode = POWERSAVE_PSPCAM; in proc_config_on_close()
4887 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4889 ai->config.powerSaveMode = POWERSAVE_PSP; in proc_config_on_close()
4890 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4892 ai->config.powerSaveMode = POWERSAVE_CAM; in proc_config_on_close()
4893 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4900 while ((v = get_dec_u16(line, &i, 3))!=-1) { in proc_config_on_close()
4901 ai->config.rates[k++] = (u8)v; in proc_config_on_close()
4905 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4910 if (v != -1) { in proc_config_on_close()
4911 ai->config.channelSet = cpu_to_le16(v); in proc_config_on_close()
4912 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4918 if (v != -1) { in proc_config_on_close()
4919 ai->config.txPower = cpu_to_le16(v); in proc_config_on_close()
4920 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4935 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4942 ai->config.longRetryLimit = cpu_to_le16(v); in proc_config_on_close()
4943 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4950 ai->config.shortRetryLimit = cpu_to_le16(v); in proc_config_on_close()
4951 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4958 ai->config.rtsThres = cpu_to_le16(v); in proc_config_on_close()
4959 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4966 ai->config.txLifetime = cpu_to_le16(v); in proc_config_on_close()
4967 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4974 ai->config.rxLifetime = cpu_to_le16(v); in proc_config_on_close()
4975 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4977 ai->config.txDiversity = in proc_config_on_close()
4980 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4982 ai->config.rxDiversity = in proc_config_on_close()
4985 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4993 ai->config.fragThresh = cpu_to_le16(v); in proc_config_on_close()
4994 set_bit (FLAG_COMMIT, &ai->flags); in proc_config_on_close()
4998 case 'd': ai->config.modulation = MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
4999 case 'c': ai->config.modulation = MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5000 case 'm': ai->config.modulation = MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5001 default: airo_print_warn(ai->dev->name, "Unknown modulation"); in proc_config_on_close()
5006 case 'a': ai->config.preamble = PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5007 case 'l': ai->config.preamble = PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5008 case 's': ai->config.preamble = PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break; in proc_config_on_close()
5009 default: airo_print_warn(ai->dev->name, "Unknown preamble"); in proc_config_on_close()
5012 airo_print_warn(ai->dev->name, "Couldn't figure out %s", line); in proc_config_on_close()
5034 struct airo_info *ai = dev->ml_priv; in proc_config_open()
5038 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_config_open()
5039 return -ENOMEM; in proc_config_open()
5040 data = file->private_data; in proc_config_open()
5041 if ((data->rbuffer = kmalloc(2048, GFP_KERNEL)) == NULL) { in proc_config_open()
5042 kfree (file->private_data); in proc_config_open()
5043 return -ENOMEM; in proc_config_open()
5045 if ((data->wbuffer = kzalloc(2048, GFP_KERNEL)) == NULL) { in proc_config_open()
5046 kfree (data->rbuffer); in proc_config_open()
5047 kfree (file->private_data); in proc_config_open()
5048 return -ENOMEM; in proc_config_open()
5050 data->maxwritelen = 2048; in proc_config_open()
5051 data->on_close = proc_config_on_close; in proc_config_open()
5055 mode = ai->config.opmode & MODE_CFG_MASK; in proc_config_open()
5056 i = sprintf(data->rbuffer, in proc_config_open()
5059 "NodeName: %-16s\n" in proc_config_open()
5065 mode == MODE_STA_ESS ? get_rmode(ai->config.rmode): in proc_config_open()
5068 test_bit(FLAG_RADIO_OFF, &ai->flags) ? "off" : "on", in proc_config_open()
5069 ai->config.nodeName, in proc_config_open()
5070 ai->config.powerSaveMode == POWERSAVE_CAM ? "CAM" : in proc_config_open()
5071 ai->config.powerSaveMode == POWERSAVE_PSP ? "PSP" : in proc_config_open()
5072 ai->config.powerSaveMode == POWERSAVE_PSPCAM ? "PSPCAM" : in proc_config_open()
5074 (int)ai->config.rates[0], in proc_config_open()
5075 (int)ai->config.rates[1], in proc_config_open()
5076 (int)ai->config.rates[2], in proc_config_open()
5077 (int)ai->config.rates[3], in proc_config_open()
5078 (int)ai->config.rates[4], in proc_config_open()
5079 (int)ai->config.rates[5], in proc_config_open()
5080 (int)ai->config.rates[6], in proc_config_open()
5081 (int)ai->config.rates[7], in proc_config_open()
5082 le16_to_cpu(ai->config.channelSet), in proc_config_open()
5083 le16_to_cpu(ai->config.txPower) in proc_config_open()
5085 sprintf(data->rbuffer + i, in proc_config_open()
5097 le16_to_cpu(ai->config.longRetryLimit), in proc_config_open()
5098 le16_to_cpu(ai->config.shortRetryLimit), in proc_config_open()
5099 le16_to_cpu(ai->config.rtsThres), in proc_config_open()
5100 le16_to_cpu(ai->config.txLifetime), in proc_config_open()
5101 le16_to_cpu(ai->config.rxLifetime), in proc_config_open()
5102 ai->config.txDiversity == 1 ? "left" : in proc_config_open()
5103 ai->config.txDiversity == 2 ? "right" : "both", in proc_config_open()
5104 ai->config.rxDiversity == 1 ? "left" : in proc_config_open()
5105 ai->config.rxDiversity == 2 ? "right" : "both", in proc_config_open()
5106 le16_to_cpu(ai->config.fragThresh), in proc_config_open()
5107 ai->config.authType == AUTH_ENCRYPT ? "encrypt" : in proc_config_open()
5108 ai->config.authType == AUTH_SHAREDKEY ? "shared" : "open", in proc_config_open()
5109 ai->config.modulation == MOD_DEFAULT ? "default" : in proc_config_open()
5110 ai->config.modulation == MOD_CCK ? "cck" : in proc_config_open()
5111 ai->config.modulation == MOD_MOK ? "mok" : "error", in proc_config_open()
5112 ai->config.preamble == PREAMBLE_AUTO ? "auto" : in proc_config_open()
5113 ai->config.preamble == PREAMBLE_LONG ? "long" : in proc_config_open()
5114 ai->config.preamble == PREAMBLE_SHORT ? "short" : "error" in proc_config_open()
5116 data->readlen = strlen(data->rbuffer); in proc_config_open()
5122 struct proc_data *data = file->private_data; in proc_SSID_on_close()
5124 struct airo_info *ai = dev->ml_priv; in proc_SSID_on_close()
5127 char *p = data->wbuffer; in proc_SSID_on_close()
5128 char *end = p + data->writelen; in proc_SSID_on_close()
5130 if (!data->writelen) in proc_SSID_on_close()
5158 struct proc_data *data = file->private_data; in proc_APList_on_close()
5160 struct airo_info *ai = dev->ml_priv; in proc_APList_on_close()
5161 APListRid *APList_rid = &ai->APList; in proc_APList_on_close()
5164 if (!data->writelen) return; in proc_APList_on_close()
5167 APList_rid->len = cpu_to_le16(sizeof(*APList_rid)); in proc_APList_on_close()
5169 for (i = 0; i < 4 && data->writelen >= (i + 1) * 6 * 3; i++) in proc_APList_on_close()
5170 mac_pton(data->wbuffer + i * 6 * 3, APList_rid->ap[i]); in proc_APList_on_close()
5189 /* Returns the WEP key at the specified index, or -1 if that key does
5200 return -1; in get_wep_key()
5210 return -1; in get_wep_key()
5212 return -1; in get_wep_key()
5223 return -1; in get_wep_tx_idx()
5230 return -1; in get_wep_tx_idx()
5232 return -1; in get_wep_tx_idx()
5243 return -1; in set_wep_key()
5269 ai->defindex = (char)index; in set_wep_tx_idx()
5284 struct airo_info *ai = dev->ml_priv; in proc_wepkey_on_close()
5292 data = file->private_data; in proc_wepkey_on_close()
5293 if (!data->writelen) return; in proc_wepkey_on_close()
5295 if (data->wbuffer[0] >= '0' && data->wbuffer[0] <= '3' && in proc_wepkey_on_close()
5296 (data->wbuffer[1] == ' ' || data->wbuffer[1] == '\n')) { in proc_wepkey_on_close()
5297 index = data->wbuffer[0] - '0'; in proc_wepkey_on_close()
5298 if (data->wbuffer[1] == '\n') { in proc_wepkey_on_close()
5301 airo_print_err(ai->dev->name, "failed to set " in proc_wepkey_on_close()
5309 airo_print_err(ai->dev->name, "WepKey passed invalid key index"); in proc_wepkey_on_close()
5313 for (i = 0; i < 16*3 && data->wbuffer[i+j]; i++) { in proc_wepkey_on_close()
5319 val = hex_to_bin(data->wbuffer[i+j]); in proc_wepkey_on_close()
5321 airo_print_err(ai->dev->name, "WebKey passed invalid key hex"); in proc_wepkey_on_close()
5336 airo_print_err(ai->dev->name, "failed to set WEP key at index " in proc_wepkey_on_close()
5345 struct airo_info *ai = dev->ml_priv; in proc_wepkey_open()
5352 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_wepkey_open()
5353 return -ENOMEM; in proc_wepkey_open()
5355 data = file->private_data; in proc_wepkey_open()
5356 if ((data->rbuffer = kzalloc(180, GFP_KERNEL)) == NULL) { in proc_wepkey_open()
5357 kfree (file->private_data); in proc_wepkey_open()
5358 return -ENOMEM; in proc_wepkey_open()
5360 data->writelen = 0; in proc_wepkey_open()
5361 data->maxwritelen = 80; in proc_wepkey_open()
5362 if ((data->wbuffer = kzalloc(80, GFP_KERNEL)) == NULL) { in proc_wepkey_open()
5363 kfree (data->rbuffer); in proc_wepkey_open()
5364 kfree (file->private_data); in proc_wepkey_open()
5365 return -ENOMEM; in proc_wepkey_open()
5367 data->on_close = proc_wepkey_on_close; in proc_wepkey_open()
5369 ptr = data->rbuffer; in proc_wepkey_open()
5383 } while ((lastindex != wkr.kindex) && (j < 180-30)); in proc_wepkey_open()
5385 data->readlen = strlen(data->rbuffer); in proc_wepkey_open()
5393 struct airo_info *ai = dev->ml_priv; in proc_SSID_open()
5398 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_SSID_open()
5399 return -ENOMEM; in proc_SSID_open()
5400 data = file->private_data; in proc_SSID_open()
5401 if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) { in proc_SSID_open()
5402 kfree (file->private_data); in proc_SSID_open()
5403 return -ENOMEM; in proc_SSID_open()
5405 data->writelen = 0; in proc_SSID_open()
5406 data->maxwritelen = 33*3; in proc_SSID_open()
5408 if ((data->wbuffer = kzalloc(33*3 + 1, GFP_KERNEL)) == NULL) { in proc_SSID_open()
5409 kfree (data->rbuffer); in proc_SSID_open()
5410 kfree (file->private_data); in proc_SSID_open()
5411 return -ENOMEM; in proc_SSID_open()
5413 data->on_close = proc_SSID_on_close; in proc_SSID_open()
5416 ptr = data->rbuffer; in proc_SSID_open()
5429 data->readlen = strlen(data->rbuffer); in proc_SSID_open()
5437 struct airo_info *ai = dev->ml_priv; in proc_APList_open()
5440 APListRid *APList_rid = &ai->APList; in proc_APList_open()
5442 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_APList_open()
5443 return -ENOMEM; in proc_APList_open()
5444 data = file->private_data; in proc_APList_open()
5445 if ((data->rbuffer = kmalloc(104, GFP_KERNEL)) == NULL) { in proc_APList_open()
5446 kfree (file->private_data); in proc_APList_open()
5447 return -ENOMEM; in proc_APList_open()
5449 data->writelen = 0; in proc_APList_open()
5450 data->maxwritelen = 4*6*3; in proc_APList_open()
5451 if ((data->wbuffer = kzalloc(data->maxwritelen, GFP_KERNEL)) == NULL) { in proc_APList_open()
5452 kfree (data->rbuffer); in proc_APList_open()
5453 kfree (file->private_data); in proc_APList_open()
5454 return -ENOMEM; in proc_APList_open()
5456 data->on_close = proc_APList_on_close; in proc_APList_open()
5458 ptr = data->rbuffer; in proc_APList_open()
5461 if (!*(int*)APList_rid->ap[i] && in proc_APList_open()
5462 !*(int*)&APList_rid->ap[i][2]) break; in proc_APList_open()
5463 ptr += sprintf(ptr, "%pM\n", APList_rid->ap[i]); in proc_APList_open()
5468 data->readlen = strlen(data->rbuffer); in proc_APList_open()
5476 struct airo_info *ai = dev->ml_priv; in proc_BSSList_open()
5481 int doLoseSync = -1; in proc_BSSList_open()
5483 if ((file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL)) == NULL) in proc_BSSList_open()
5484 return -ENOMEM; in proc_BSSList_open()
5485 data = file->private_data; in proc_BSSList_open()
5486 if ((data->rbuffer = kmalloc(1024, GFP_KERNEL)) == NULL) { in proc_BSSList_open()
5487 kfree (file->private_data); in proc_BSSList_open()
5488 return -ENOMEM; in proc_BSSList_open()
5490 data->writelen = 0; in proc_BSSList_open()
5491 data->maxwritelen = 0; in proc_BSSList_open()
5492 data->wbuffer = NULL; in proc_BSSList_open()
5493 data->on_close = NULL; in proc_BSSList_open()
5495 if (file->f_mode & FMODE_WRITE) { in proc_BSSList_open()
5496 if (!(file->f_mode & FMODE_READ)) { in proc_BSSList_open()
5500 if (ai->flags & FLAG_RADIO_MASK) { in proc_BSSList_open()
5501 kfree(data->rbuffer); in proc_BSSList_open()
5502 kfree(file->private_data); in proc_BSSList_open()
5503 return -ENETDOWN; in proc_BSSList_open()
5507 if (down_interruptible(&ai->sem)) { in proc_BSSList_open()
5508 kfree(data->rbuffer); in proc_BSSList_open()
5509 kfree(file->private_data); in proc_BSSList_open()
5510 return -ERESTARTSYS; in proc_BSSList_open()
5513 up(&ai->sem); in proc_BSSList_open()
5514 data->readlen = 0; in proc_BSSList_open()
5519 ptr = data->rbuffer; in proc_BSSList_open()
5539 data->readlen = strlen(data->rbuffer); in proc_BSSList_open()
5545 struct proc_data *data = file->private_data; in proc_close()
5547 if (data->on_close != NULL) in proc_close()
5548 data->on_close(inode, file); in proc_close()
5549 kfree(data->rbuffer); in proc_close()
5550 kfree(data->wbuffer); in proc_close()
5562 struct airo_info *apriv = dev->ml_priv; in timer_func()
5567 switch(apriv->config.authType) { in timer_func()
5570 apriv->config.authType = AUTH_OPEN; in timer_func()
5573 if (apriv->keyindex < auto_wep) { in timer_func()
5574 set_wep_tx_idx(apriv, apriv->keyindex, 0, 0); in timer_func()
5575 apriv->config.authType = AUTH_SHAREDKEY; in timer_func()
5576 apriv->keyindex++; in timer_func()
5579 apriv->keyindex = 0; in timer_func()
5580 set_wep_tx_idx(apriv, apriv->defindex, 0, 0); in timer_func()
5581 apriv->config.authType = AUTH_ENCRYPT; in timer_func()
5585 apriv->config.authType = AUTH_SHAREDKEY; in timer_func()
5587 set_bit (FLAG_COMMIT, &apriv->flags); in timer_func()
5590 up(&apriv->sem); in timer_func()
5593 clear_bit(JOB_AUTOWEP, &apriv->jobs); in timer_func()
5594 apriv->expires = RUN_AT(HZ*3); in timer_func()
5604 return -ENODEV; in airo_pci_probe()
5607 if (pdev->device == 0x5000 || pdev->device == 0xa504) in airo_pci_probe()
5608 dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev); in airo_pci_probe()
5610 dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev); in airo_pci_probe()
5613 return -ENODEV; in airo_pci_probe()
5624 airo_print_info(dev->name, "Unregistering..."); in airo_pci_remove()
5632 struct airo_info *ai = dev->ml_priv; in airo_pci_suspend()
5636 if (!ai->SSID) in airo_pci_suspend()
5637 ai->SSID = kmalloc(sizeof(SsidRid), GFP_KERNEL); in airo_pci_suspend()
5638 if (!ai->SSID) in airo_pci_suspend()
5639 return -ENOMEM; in airo_pci_suspend()
5640 readSsidRid(ai, ai->SSID); in airo_pci_suspend()
5643 if (down_interruptible(&ai->sem)) in airo_pci_suspend()
5644 return -EAGAIN; in airo_pci_suspend()
5647 ai->power = PMSG_SUSPEND; in airo_pci_suspend()
5658 struct airo_info *ai = dev->ml_priv; in airo_pci_resume()
5659 pci_power_t prev_state = to_pci_dev(dev_d)->current_state; in airo_pci_resume()
5667 clear_bit(FLAG_RADIO_OFF, &ai->flags); in airo_pci_resume()
5668 clear_bit(FLAG_PENDING_XMIT, &ai->flags); in airo_pci_resume()
5675 set_bit(FLAG_COMMIT, &ai->flags); in airo_pci_resume()
5678 if (ai->SSID) { in airo_pci_resume()
5679 writeSsidRid(ai, ai->SSID, 0); in airo_pci_resume()
5680 kfree(ai->SSID); in airo_pci_resume()
5681 ai->SSID = NULL; in airo_pci_resume()
5683 writeAPListRid(ai, &ai->APList, 0); in airo_pci_resume()
5686 ai->power = PMSG_ON; in airo_pci_resume()
5690 up(&ai->sem); in airo_pci_resume()
5702 return -EINVAL; in airo_init_module()
5739 airo_print_info(ai->dev->name, "Unregistering..."); in airo_cleanup_module()
5740 stop_airo_card(ai->dev, 1); in airo_cleanup_module()
5750 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 17 November 00
5752 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 26 March 02
5755 * would not work at all... - Jean II
5763 return (0x100 - rssi_rid[rssi].rssidBm); in airo_rssi_to_dbm()
5786 if ((status_rid->mode & cpu_to_le16(0x3f)) != cpu_to_le16(0x3f)) in airo_get_quality()
5789 if (!(cap_rid->hardCap & cpu_to_le16(8))) in airo_get_quality()
5792 sq = le16_to_cpu(status_rid->signalQuality); in airo_get_quality()
5793 if (memcmp(cap_rid->prodName, "350", 3)) in airo_get_quality()
5797 quality = 0x20 - sq; in airo_get_quality()
5804 quality = 0xb0 - sq; in airo_get_quality()
5808 #define airo_get_max_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x20 : 0xa0)
5809 #define airo_get_avg_quality(cap_rid) (memcmp((cap_rid)->prodName, "350", 3) ? 0x10 : 0x50)
5811 /*------------------------------------------------------------------*/
5820 strcpy(cwrq, "IEEE 802.11-DS"); in airo_get_name()
5824 /*------------------------------------------------------------------*/
5833 struct airo_info *local = dev->ml_priv; in airo_set_freq()
5834 int rc = -EINPROGRESS; /* Call commit handler */ in airo_set_freq()
5837 if (fwrq->e == 1) { in airo_set_freq()
5838 int f = fwrq->m / 100000; in airo_set_freq()
5841 fwrq->e = 0; in airo_set_freq()
5842 fwrq->m = ieee80211_frequency_to_channel(f); in airo_set_freq()
5845 if (fwrq->m < 0 || fwrq->m > 1000 || fwrq->e > 0) in airo_set_freq()
5846 rc = -EOPNOTSUPP; in airo_set_freq()
5848 int channel = fwrq->m; in airo_set_freq()
5852 airo_print_dbg(dev->name, "New channel value of %d is invalid!", in airo_set_freq()
5853 fwrq->m); in airo_set_freq()
5854 rc = -EINVAL; in airo_set_freq()
5858 local->config.channelSet = cpu_to_le16(channel); in airo_set_freq()
5859 set_bit (FLAG_COMMIT, &local->flags); in airo_set_freq()
5865 /*------------------------------------------------------------------*/
5874 struct airo_info *local = dev->ml_priv; in airo_get_freq()
5879 if ((local->config.opmode & MODE_CFG_MASK) == MODE_STA_ESS) in airo_get_freq()
5880 status_rid.channel = local->config.channelSet; in airo_get_freq()
5886 fwrq->m = 100000 * in airo_get_freq()
5888 fwrq->e = 1; in airo_get_freq()
5890 fwrq->m = ch; in airo_get_freq()
5891 fwrq->e = 0; in airo_get_freq()
5897 /*------------------------------------------------------------------*/
5906 struct airo_info *local = dev->ml_priv; in airo_set_essid()
5913 if (dwrq->flags == 0) { in airo_set_essid()
5917 unsigned index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_set_essid()
5920 if (dwrq->length > IW_ESSID_MAX_SIZE) in airo_set_essid()
5921 return -E2BIG ; in airo_set_essid()
5925 return -EINVAL; in airo_set_essid()
5930 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length); in airo_set_essid()
5931 SSID_rid.ssids[index].len = cpu_to_le16(dwrq->length); in airo_set_essid()
5942 /*------------------------------------------------------------------*/
5951 struct airo_info *local = dev->ml_priv; in airo_get_essid()
5956 /* Note : if dwrq->flags != 0, we should in airo_get_essid()
5964 dwrq->length = le16_to_cpu(status_rid.SSIDlen); in airo_get_essid()
5965 dwrq->flags = 1; /* active */ in airo_get_essid()
5970 /*------------------------------------------------------------------*/
5979 struct airo_info *local = dev->ml_priv; in airo_set_wap()
5982 APListRid *APList_rid = &local->APList; in airo_set_wap()
5984 if (awrq->sa_family != ARPHRD_ETHER) in airo_set_wap()
5985 return -EINVAL; in airo_set_wap()
5986 else if (is_broadcast_ether_addr(awrq->sa_data) || in airo_set_wap()
5987 is_zero_ether_addr(awrq->sa_data)) { in airo_set_wap()
5990 if (down_interruptible(&local->sem)) in airo_set_wap()
5991 return -ERESTARTSYS; in airo_set_wap()
5993 up(&local->sem); in airo_set_wap()
5996 APList_rid->len = cpu_to_le16(sizeof(*APList_rid)); in airo_set_wap()
5997 memcpy(APList_rid->ap[0], awrq->sa_data, ETH_ALEN); in airo_set_wap()
6005 /*------------------------------------------------------------------*/
6014 struct airo_info *local = dev->ml_priv; in airo_get_wap()
6020 memcpy(awrq->sa_data, status_rid.bssid[0], ETH_ALEN); in airo_get_wap()
6021 awrq->sa_family = ARPHRD_ETHER; in airo_get_wap()
6026 /*------------------------------------------------------------------*/
6035 struct airo_info *local = dev->ml_priv; in airo_set_nick()
6038 if (dwrq->length > 16) { in airo_set_nick()
6039 return -E2BIG; in airo_set_nick()
6042 memset(local->config.nodeName, 0, sizeof(local->config.nodeName)); in airo_set_nick()
6043 memcpy(local->config.nodeName, extra, dwrq->length); in airo_set_nick()
6044 set_bit (FLAG_COMMIT, &local->flags); in airo_set_nick()
6046 return -EINPROGRESS; /* Call commit handler */ in airo_set_nick()
6049 /*------------------------------------------------------------------*/
6058 struct airo_info *local = dev->ml_priv; in airo_get_nick()
6061 strncpy(extra, local->config.nodeName, 16); in airo_get_nick()
6063 dwrq->length = strlen(extra); in airo_get_nick()
6068 /*------------------------------------------------------------------*/
6070 * Wireless Handler : set Bit-Rate
6077 struct airo_info *local = dev->ml_priv; in airo_set_rate()
6086 if ((vwrq->value < 8) && (vwrq->value >= 0)) { in airo_set_rate()
6089 brate = cap_rid.supportedRates[vwrq->value]; in airo_set_rate()
6092 u8 normvalue = (u8) (vwrq->value/500000); in airo_set_rate()
6102 /* -1 designed the max rate (mostly auto mode) */ in airo_set_rate()
6103 if (vwrq->value == -1) { in airo_set_rate()
6110 brate = cap_rid.supportedRates[i - 1]; in airo_set_rate()
6114 return -EINVAL; in airo_set_rate()
6119 if (vwrq->fixed == 0) { in airo_set_rate()
6121 memset(local->config.rates, 0, 8); in airo_set_rate()
6123 local->config.rates[i] = cap_rid.supportedRates[i]; in airo_set_rate()
6124 if (local->config.rates[i] == brate) in airo_set_rate()
6130 memset(local->config.rates, 0, 8); in airo_set_rate()
6131 local->config.rates[0] = brate; in airo_set_rate()
6133 set_bit (FLAG_COMMIT, &local->flags); in airo_set_rate()
6135 return -EINPROGRESS; /* Call commit handler */ in airo_set_rate()
6138 /*------------------------------------------------------------------*/
6140 * Wireless Handler : get Bit-Rate
6147 struct airo_info *local = dev->ml_priv; in airo_get_rate()
6152 vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000; in airo_get_rate()
6155 vwrq->fixed = (local->config.rates[1] == 0); in airo_get_rate()
6160 /*------------------------------------------------------------------*/
6169 struct airo_info *local = dev->ml_priv; in airo_set_rts()
6170 int rthr = vwrq->value; in airo_set_rts()
6172 if (vwrq->disabled) in airo_set_rts()
6175 return -EINVAL; in airo_set_rts()
6178 local->config.rtsThres = cpu_to_le16(rthr); in airo_set_rts()
6179 set_bit (FLAG_COMMIT, &local->flags); in airo_set_rts()
6181 return -EINPROGRESS; /* Call commit handler */ in airo_set_rts()
6184 /*------------------------------------------------------------------*/
6193 struct airo_info *local = dev->ml_priv; in airo_get_rts()
6196 vwrq->value = le16_to_cpu(local->config.rtsThres); in airo_get_rts()
6197 vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU); in airo_get_rts()
6198 vwrq->fixed = 1; in airo_get_rts()
6203 /*------------------------------------------------------------------*/
6212 struct airo_info *local = dev->ml_priv; in airo_set_frag()
6213 int fthr = vwrq->value; in airo_set_frag()
6215 if (vwrq->disabled) in airo_set_frag()
6218 return -EINVAL; in airo_set_frag()
6220 fthr &= ~0x1; /* Get an even value - is it really needed ??? */ in airo_set_frag()
6222 local->config.fragThresh = cpu_to_le16(fthr); in airo_set_frag()
6223 set_bit (FLAG_COMMIT, &local->flags); in airo_set_frag()
6225 return -EINPROGRESS; /* Call commit handler */ in airo_set_frag()
6228 /*------------------------------------------------------------------*/
6237 struct airo_info *local = dev->ml_priv; in airo_get_frag()
6240 vwrq->value = le16_to_cpu(local->config.fragThresh); in airo_get_frag()
6241 vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU); in airo_get_frag()
6242 vwrq->fixed = 1; in airo_get_frag()
6247 /*------------------------------------------------------------------*/
6256 struct airo_info *local = dev->ml_priv; in airo_set_mode()
6265 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6266 local->config.opmode |= MODE_STA_IBSS; in airo_set_mode()
6267 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6268 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6269 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6272 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6273 local->config.opmode |= MODE_STA_ESS; in airo_set_mode()
6274 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6275 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6276 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6279 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6280 local->config.opmode |= MODE_AP; in airo_set_mode()
6281 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6282 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6283 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6286 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6287 local->config.opmode |= MODE_AP_RPTR; in airo_set_mode()
6288 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6289 local->config.scanMode = SCANMODE_ACTIVE; in airo_set_mode()
6290 clear_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6293 local->config.opmode &= ~MODE_CFG_MASK; in airo_set_mode()
6294 local->config.opmode |= MODE_STA_ESS; in airo_set_mode()
6295 local->config.rmode &= ~RXMODE_FULL_MASK; in airo_set_mode()
6296 local->config.rmode |= RXMODE_RFMON | RXMODE_DISABLE_802_3_HEADER; in airo_set_mode()
6297 local->config.scanMode = SCANMODE_PASSIVE; in airo_set_mode()
6298 set_bit (FLAG_802_11, &local->flags); in airo_set_mode()
6301 return -EINVAL; in airo_set_mode()
6304 set_bit (FLAG_RESET, &local->flags); in airo_set_mode()
6305 set_bit (FLAG_COMMIT, &local->flags); in airo_set_mode()
6307 return -EINPROGRESS; /* Call commit handler */ in airo_set_mode()
6310 /*------------------------------------------------------------------*/
6319 struct airo_info *local = dev->ml_priv; in airo_get_mode()
6322 /* If not managed, assume it's ad-hoc */ in airo_get_mode()
6323 switch (local->config.opmode & MODE_CFG_MASK) { in airo_get_mode()
6342 return (index >= 0) && (index <= ai->max_wep_idx); in valid_index()
6345 /*------------------------------------------------------------------*/
6354 struct airo_info *local = dev->ml_priv; in airo_set_encode()
6355 int perm = (dwrq->flags & IW_ENCODE_TEMP ? 0 : 1); in airo_set_encode()
6356 __le16 currentAuthType = local->config.authType; in airo_set_encode()
6359 if (!local->wep_capable) in airo_set_encode()
6360 return -EOPNOTSUPP; in airo_set_encode()
6369 * don't do it. - Jean II */ in airo_set_encode()
6370 if (dwrq->length > 0) { in airo_set_encode()
6372 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_set_encode()
6376 if (dwrq->length > MAX_KEY_SIZE) { in airo_set_encode()
6377 return -EINVAL; in airo_set_encode()
6384 /* Check the index (none -> use current) */ in airo_set_encode()
6389 if (dwrq->length > MIN_KEY_SIZE) in airo_set_encode()
6394 if (!(dwrq->flags & IW_ENCODE_NOKEY)) { in airo_set_encode()
6398 memcpy(key.key, extra, dwrq->length); in airo_set_encode()
6402 airo_print_err(local->dev->name, "failed to set" in airo_set_encode()
6412 (local->config.authType == AUTH_OPEN)) in airo_set_encode()
6416 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_set_encode()
6420 airo_print_err(local->dev->name, "failed to set" in airo_set_encode()
6427 if (!(dwrq->flags & IW_ENCODE_MODE)) in airo_set_encode()
6428 return -EINVAL; in airo_set_encode()
6432 if (dwrq->flags & IW_ENCODE_DISABLED) in airo_set_encode()
6434 if (dwrq->flags & IW_ENCODE_RESTRICTED) in airo_set_encode()
6436 if (dwrq->flags & IW_ENCODE_OPEN) in airo_set_encode()
6439 if (local->config.authType != currentAuthType) in airo_set_encode()
6440 set_bit (FLAG_COMMIT, &local->flags); in airo_set_encode()
6441 return -EINPROGRESS; /* Call commit handler */ in airo_set_encode()
6444 /*------------------------------------------------------------------*/
6453 struct airo_info *local = dev->ml_priv; in airo_get_encode()
6454 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in airo_get_encode()
6458 if (!local->wep_capable) in airo_get_encode()
6459 return -EOPNOTSUPP; in airo_get_encode()
6464 switch(local->config.authType) { in airo_get_encode()
6466 dwrq->flags = IW_ENCODE_OPEN; in airo_get_encode()
6469 dwrq->flags = IW_ENCODE_RESTRICTED; in airo_get_encode()
6473 dwrq->flags = IW_ENCODE_DISABLED; in airo_get_encode()
6477 dwrq->flags |= IW_ENCODE_NOKEY; in airo_get_encode()
6480 /* Which key do we want ? -1 -> tx index */ in airo_get_encode()
6486 dwrq->flags |= index + 1; in airo_get_encode()
6491 dwrq->length = 0; in airo_get_encode()
6493 dwrq->length = wep_key_len; in airo_get_encode()
6494 memcpy(extra, buf, dwrq->length); in airo_get_encode()
6500 /*------------------------------------------------------------------*/
6509 struct airo_info *local = dev->ml_priv; in airo_set_encodeext()
6510 struct iw_point *encoding = &wrqu->encoding; in airo_set_encodeext()
6512 int perm = (encoding->flags & IW_ENCODE_TEMP ? 0 : 1); in airo_set_encodeext()
6513 __le16 currentAuthType = local->config.authType; in airo_set_encodeext()
6514 int idx, key_len, alg = ext->alg, set_key = 1, rc; in airo_set_encodeext()
6517 if (!local->wep_capable) in airo_set_encodeext()
6518 return -EOPNOTSUPP; in airo_set_encodeext()
6523 idx = encoding->flags & IW_ENCODE_INDEX; in airo_set_encodeext()
6525 if (!valid_index(local, idx - 1)) in airo_set_encodeext()
6526 return -EINVAL; in airo_set_encodeext()
6527 idx--; in airo_set_encodeext()
6534 if (encoding->flags & IW_ENCODE_DISABLED) in airo_set_encodeext()
6537 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { in airo_set_encodeext()
6543 airo_print_err(local->dev->name, "failed to set " in airo_set_encodeext()
6548 set_key = ext->key_len > 0 ? 1 : 0; in airo_set_encodeext()
6559 if (ext->key_len > MIN_KEY_SIZE) { in airo_set_encodeext()
6561 } else if (ext->key_len > 0) { in airo_set_encodeext()
6564 return -EINVAL; in airo_set_encodeext()
6566 key_len = min (ext->key_len, key.len); in airo_set_encodeext()
6567 memcpy(key.key, ext->key, key_len); in airo_set_encodeext()
6570 return -EINVAL; in airo_set_encodeext()
6575 airo_print_err(local->dev->name, in airo_set_encodeext()
6583 airo_print_err(local->dev->name, in airo_set_encodeext()
6592 if (encoding->flags & IW_ENCODE_DISABLED) in airo_set_encodeext()
6594 if (encoding->flags & IW_ENCODE_RESTRICTED) in airo_set_encodeext()
6596 if (encoding->flags & IW_ENCODE_OPEN) in airo_set_encodeext()
6599 if (local->config.authType != currentAuthType) in airo_set_encodeext()
6600 set_bit (FLAG_COMMIT, &local->flags); in airo_set_encodeext()
6602 return -EINPROGRESS; in airo_set_encodeext()
6606 /*------------------------------------------------------------------*/
6615 struct airo_info *local = dev->ml_priv; in airo_get_encodeext()
6616 struct iw_point *encoding = &wrqu->encoding; in airo_get_encodeext()
6621 if (!local->wep_capable) in airo_get_encodeext()
6622 return -EOPNOTSUPP; in airo_get_encodeext()
6626 max_key_len = encoding->length - sizeof(*ext); in airo_get_encodeext()
6628 return -EINVAL; in airo_get_encodeext()
6630 idx = encoding->flags & IW_ENCODE_INDEX; in airo_get_encodeext()
6632 if (!valid_index(local, idx - 1)) in airo_get_encodeext()
6633 return -EINVAL; in airo_get_encodeext()
6634 idx--; in airo_get_encodeext()
6641 encoding->flags = idx + 1; in airo_get_encodeext()
6645 switch(local->config.authType) { in airo_get_encodeext()
6647 encoding->flags = IW_ENCODE_ALG_WEP | IW_ENCODE_ENABLED; in airo_get_encodeext()
6650 encoding->flags = IW_ENCODE_ALG_WEP | IW_ENCODE_ENABLED; in airo_get_encodeext()
6654 encoding->flags = IW_ENCODE_ALG_NONE | IW_ENCODE_DISABLED; in airo_get_encodeext()
6658 encoding->flags |= IW_ENCODE_NOKEY; in airo_get_encodeext()
6664 ext->key_len = 0; in airo_get_encodeext()
6666 ext->key_len = wep_key_len; in airo_get_encodeext()
6667 memcpy(extra, buf, ext->key_len); in airo_get_encodeext()
6674 /*------------------------------------------------------------------*/
6682 struct airo_info *local = dev->ml_priv; in airo_set_auth()
6683 struct iw_param *param = &wrqu->param; in airo_set_auth()
6684 __le16 currentAuthType = local->config.authType; in airo_set_auth()
6686 switch (param->flags & IW_AUTH_INDEX) { in airo_set_auth()
6699 if (param->value) { in airo_set_auth()
6708 if (local->config.authType != currentAuthType) in airo_set_auth()
6709 set_bit (FLAG_COMMIT, &local->flags); in airo_set_auth()
6713 if (param->value & IW_AUTH_ALG_SHARED_KEY) { in airo_set_auth()
6715 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) { in airo_set_auth()
6717 * unencrypted mode was requested - so use the in airo_set_auth()
6720 set_auth_type(local, local->last_auth); in airo_set_auth()
6722 return -EINVAL; in airo_set_auth()
6725 if (local->config.authType != currentAuthType) in airo_set_auth()
6726 set_bit (FLAG_COMMIT, &local->flags); in airo_set_auth()
6732 if (param->value > 0) in airo_set_auth()
6733 return -EOPNOTSUPP; in airo_set_auth()
6737 return -EOPNOTSUPP; in airo_set_auth()
6739 return -EINPROGRESS; in airo_set_auth()
6743 /*------------------------------------------------------------------*/
6751 struct airo_info *local = dev->ml_priv; in airo_get_auth()
6752 struct iw_param *param = &wrqu->param; in airo_get_auth()
6753 __le16 currentAuthType = local->config.authType; in airo_get_auth()
6755 switch (param->flags & IW_AUTH_INDEX) { in airo_get_auth()
6760 param->value = 1; in airo_get_auth()
6763 param->value = 0; in airo_get_auth()
6771 param->value = IW_AUTH_ALG_SHARED_KEY; in airo_get_auth()
6775 param->value = IW_AUTH_ALG_OPEN_SYSTEM; in airo_get_auth()
6781 param->value = 0; in airo_get_auth()
6785 return -EOPNOTSUPP; in airo_get_auth()
6791 /*------------------------------------------------------------------*/
6793 * Wireless Handler : set Tx-Power
6800 struct airo_info *local = dev->ml_priv; in airo_set_txpow()
6803 int rc = -EINVAL; in airo_set_txpow()
6804 __le16 v = cpu_to_le16(vwrq->value); in airo_set_txpow()
6808 if (vwrq->disabled) { in airo_set_txpow()
6809 set_bit (FLAG_RADIO_OFF, &local->flags); in airo_set_txpow()
6810 set_bit (FLAG_COMMIT, &local->flags); in airo_set_txpow()
6811 return -EINPROGRESS; /* Call commit handler */ in airo_set_txpow()
6813 if (vwrq->flags != IW_TXPOW_MWATT) { in airo_set_txpow()
6814 return -EINVAL; in airo_set_txpow()
6816 clear_bit (FLAG_RADIO_OFF, &local->flags); in airo_set_txpow()
6820 local->config.txPower = v; in airo_set_txpow()
6821 set_bit (FLAG_COMMIT, &local->flags); in airo_set_txpow()
6822 rc = -EINPROGRESS; /* Call commit handler */ in airo_set_txpow()
6828 /*------------------------------------------------------------------*/
6830 * Wireless Handler : get Tx-Power
6837 struct airo_info *local = dev->ml_priv; in airo_get_txpow()
6840 vwrq->value = le16_to_cpu(local->config.txPower); in airo_get_txpow()
6841 vwrq->fixed = 1; /* No power control */ in airo_get_txpow()
6842 vwrq->disabled = test_bit(FLAG_RADIO_OFF, &local->flags); in airo_get_txpow()
6843 vwrq->flags = IW_TXPOW_MWATT; in airo_get_txpow()
6848 /*------------------------------------------------------------------*/
6857 struct airo_info *local = dev->ml_priv; in airo_set_retry()
6858 int rc = -EINVAL; in airo_set_retry()
6860 if (vwrq->disabled) { in airo_set_retry()
6861 return -EINVAL; in airo_set_retry()
6864 if (vwrq->flags & IW_RETRY_LIMIT) { in airo_set_retry()
6865 __le16 v = cpu_to_le16(vwrq->value); in airo_set_retry()
6866 if (vwrq->flags & IW_RETRY_LONG) in airo_set_retry()
6867 local->config.longRetryLimit = v; in airo_set_retry()
6868 else if (vwrq->flags & IW_RETRY_SHORT) in airo_set_retry()
6869 local->config.shortRetryLimit = v; in airo_set_retry()
6872 local->config.longRetryLimit = v; in airo_set_retry()
6873 local->config.shortRetryLimit = v; in airo_set_retry()
6875 set_bit (FLAG_COMMIT, &local->flags); in airo_set_retry()
6876 rc = -EINPROGRESS; /* Call commit handler */ in airo_set_retry()
6878 if (vwrq->flags & IW_RETRY_LIFETIME) { in airo_set_retry()
6879 local->config.txLifetime = cpu_to_le16(vwrq->value / 1024); in airo_set_retry()
6880 set_bit (FLAG_COMMIT, &local->flags); in airo_set_retry()
6881 rc = -EINPROGRESS; /* Call commit handler */ in airo_set_retry()
6886 /*------------------------------------------------------------------*/
6895 struct airo_info *local = dev->ml_priv; in airo_get_retry()
6897 vwrq->disabled = 0; /* Can't be disabled */ in airo_get_retry()
6901 if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { in airo_get_retry()
6902 vwrq->flags = IW_RETRY_LIFETIME; in airo_get_retry()
6903 vwrq->value = le16_to_cpu(local->config.txLifetime) * 1024; in airo_get_retry()
6904 } else if ((vwrq->flags & IW_RETRY_LONG)) { in airo_get_retry()
6905 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in airo_get_retry()
6906 vwrq->value = le16_to_cpu(local->config.longRetryLimit); in airo_get_retry()
6908 vwrq->flags = IW_RETRY_LIMIT; in airo_get_retry()
6909 vwrq->value = le16_to_cpu(local->config.shortRetryLimit); in airo_get_retry()
6910 if (local->config.shortRetryLimit != local->config.longRetryLimit) in airo_get_retry()
6911 vwrq->flags |= IW_RETRY_SHORT; in airo_get_retry()
6917 /*------------------------------------------------------------------*/
6926 struct airo_info *local = dev->ml_priv; in airo_get_range()
6934 dwrq->length = sizeof(struct iw_range); in airo_get_range()
6936 range->min_nwid = 0x0000; in airo_get_range()
6937 range->max_nwid = 0x0000; in airo_get_range()
6938 range->num_channels = 14; in airo_get_range()
6943 range->freq[k].i = i + 1; /* List index */ in airo_get_range()
6944 range->freq[k].m = 100000 * in airo_get_range()
6946 range->freq[k++].e = 1; /* Values in MHz -> * 10^5 * 10 */ in airo_get_range()
6948 range->num_frequency = k; in airo_get_range()
6950 range->sensitivity = 65535; in airo_get_range()
6953 if (local->rssi) in airo_get_range()
6954 range->max_qual.qual = 100; /* % */ in airo_get_range()
6956 range->max_qual.qual = airo_get_max_quality(&cap_rid); in airo_get_range()
6957 range->max_qual.level = 0x100 - 120; /* -120 dBm */ in airo_get_range()
6958 range->max_qual.noise = 0x100 - 120; /* -120 dBm */ in airo_get_range()
6960 /* Experimental measurements - boundary 11/5.5 Mb/s */ in airo_get_range()
6961 /* Note : with or without the (local->rssi), results in airo_get_range()
6962 * are somewhat different. - Jean II */ in airo_get_range()
6963 if (local->rssi) { in airo_get_range()
6964 range->avg_qual.qual = 50; /* % */ in airo_get_range()
6965 range->avg_qual.level = 0x100 - 70; /* -70 dBm */ in airo_get_range()
6967 range->avg_qual.qual = airo_get_avg_quality(&cap_rid); in airo_get_range()
6968 range->avg_qual.level = 0x100 - 80; /* -80 dBm */ in airo_get_range()
6970 range->avg_qual.noise = 0x100 - 85; /* -85 dBm */ in airo_get_range()
6973 range->bitrate[i] = cap_rid.supportedRates[i] * 500000; in airo_get_range()
6974 if (range->bitrate[i] == 0) in airo_get_range()
6977 range->num_bitrates = i; in airo_get_range()
6983 range->throughput = 5000 * 1000; in airo_get_range()
6985 range->throughput = 1500 * 1000; in airo_get_range()
6987 range->min_rts = 0; in airo_get_range()
6988 range->max_rts = AIRO_DEF_MTU; in airo_get_range()
6989 range->min_frag = 256; in airo_get_range()
6990 range->max_frag = AIRO_DEF_MTU; in airo_get_range()
6994 range->encoding_size[0] = 5; in airo_get_range()
6997 range->encoding_size[1] = 13; in airo_get_range()
6998 range->num_encoding_sizes = 2; in airo_get_range()
7000 range->num_encoding_sizes = 1; in airo_get_range()
7001 range->max_encoding_tokens = in airo_get_range()
7004 range->num_encoding_sizes = 0; in airo_get_range()
7005 range->max_encoding_tokens = 0; in airo_get_range()
7007 range->min_pmp = 0; in airo_get_range()
7008 range->max_pmp = 5000000; /* 5 secs */ in airo_get_range()
7009 range->min_pmt = 0; in airo_get_range()
7010 range->max_pmt = 65535 * 1024; /* ??? */ in airo_get_range()
7011 range->pmp_flags = IW_POWER_PERIOD; in airo_get_range()
7012 range->pmt_flags = IW_POWER_TIMEOUT; in airo_get_range()
7013 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R; in airo_get_range()
7015 /* Transmit Power - values are in mW */ in airo_get_range()
7017 range->txpower[i] = le16_to_cpu(cap_rid.txPowerLevels[i]); in airo_get_range()
7018 if (range->txpower[i] == 0) in airo_get_range()
7021 range->num_txpower = i; in airo_get_range()
7022 range->txpower_capa = IW_TXPOW_MWATT; in airo_get_range()
7023 range->we_version_source = 19; in airo_get_range()
7024 range->we_version_compiled = WIRELESS_EXT; in airo_get_range()
7025 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; in airo_get_range()
7026 range->retry_flags = IW_RETRY_LIMIT; in airo_get_range()
7027 range->r_time_flags = IW_RETRY_LIFETIME; in airo_get_range()
7028 range->min_retry = 1; in airo_get_range()
7029 range->max_retry = 65535; in airo_get_range()
7030 range->min_r_time = 1024; in airo_get_range()
7031 range->max_r_time = 65535 * 1024; in airo_get_range()
7034 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | in airo_get_range()
7038 range->event_capa[1] = IW_EVENT_CAPA_K_1; in airo_get_range()
7039 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVTXDROP); in airo_get_range()
7043 /*------------------------------------------------------------------*/
7052 struct airo_info *local = dev->ml_priv; in airo_set_power()
7055 if (vwrq->disabled) { in airo_set_power()
7057 return -EINVAL; in airo_set_power()
7058 local->config.powerSaveMode = POWERSAVE_CAM; in airo_set_power()
7059 local->config.rmode &= ~RXMODE_MASK; in airo_set_power()
7060 local->config.rmode |= RXMODE_BC_MC_ADDR; in airo_set_power()
7061 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7062 return -EINPROGRESS; /* Call commit handler */ in airo_set_power()
7064 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { in airo_set_power()
7065 local->config.fastListenDelay = cpu_to_le16((vwrq->value + 500) / 1024); in airo_set_power()
7066 local->config.powerSaveMode = POWERSAVE_PSPCAM; in airo_set_power()
7067 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7068 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) { in airo_set_power()
7069 local->config.fastListenInterval = in airo_set_power()
7070 local->config.listenInterval = in airo_set_power()
7071 cpu_to_le16((vwrq->value + 500) / 1024); in airo_set_power()
7072 local->config.powerSaveMode = POWERSAVE_PSPCAM; in airo_set_power()
7073 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7075 switch (vwrq->flags & IW_POWER_MODE) { in airo_set_power()
7078 return -EINVAL; in airo_set_power()
7079 local->config.rmode &= ~RXMODE_MASK; in airo_set_power()
7080 local->config.rmode |= RXMODE_ADDR; in airo_set_power()
7081 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7085 return -EINVAL; in airo_set_power()
7086 local->config.rmode &= ~RXMODE_MASK; in airo_set_power()
7087 local->config.rmode |= RXMODE_BC_MC_ADDR; in airo_set_power()
7088 set_bit (FLAG_COMMIT, &local->flags); in airo_set_power()
7091 /* This is broken, fixme ;-) */ in airo_set_power()
7094 return -EINVAL; in airo_set_power()
7096 // Note : we may want to factor local->need_commit here in airo_set_power()
7098 return -EINPROGRESS; /* Call commit handler */ in airo_set_power()
7101 /*------------------------------------------------------------------*/
7110 struct airo_info *local = dev->ml_priv; in airo_get_power()
7114 mode = local->config.powerSaveMode; in airo_get_power()
7115 if ((vwrq->disabled = (mode == POWERSAVE_CAM))) in airo_get_power()
7117 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { in airo_get_power()
7118 vwrq->value = le16_to_cpu(local->config.fastListenDelay) * 1024; in airo_get_power()
7119 vwrq->flags = IW_POWER_TIMEOUT; in airo_get_power()
7121 vwrq->value = le16_to_cpu(local->config.fastListenInterval) * 1024; in airo_get_power()
7122 vwrq->flags = IW_POWER_PERIOD; in airo_get_power()
7124 if ((local->config.rmode & RXMODE_MASK) == RXMODE_ADDR) in airo_get_power()
7125 vwrq->flags |= IW_POWER_UNICAST_R; in airo_get_power()
7127 vwrq->flags |= IW_POWER_ALL_R; in airo_get_power()
7132 /*------------------------------------------------------------------*/
7141 struct airo_info *local = dev->ml_priv; in airo_set_sens()
7144 local->config.rssiThreshold = in airo_set_sens()
7145 cpu_to_le16(vwrq->disabled ? RSSI_DEFAULT : vwrq->value); in airo_set_sens()
7146 set_bit (FLAG_COMMIT, &local->flags); in airo_set_sens()
7148 return -EINPROGRESS; /* Call commit handler */ in airo_set_sens()
7151 /*------------------------------------------------------------------*/
7160 struct airo_info *local = dev->ml_priv; in airo_get_sens()
7163 vwrq->value = le16_to_cpu(local->config.rssiThreshold); in airo_get_sens()
7164 vwrq->disabled = (vwrq->value == 0); in airo_get_sens()
7165 vwrq->fixed = 1; in airo_get_sens()
7170 /*------------------------------------------------------------------*/
7180 struct airo_info *local = dev->ml_priv; in airo_get_aplist()
7185 int loseSync = capable(CAP_NET_ADMIN) ? 1: -1; in airo_get_aplist()
7189 return -ENOMEM; in airo_get_aplist()
7199 if (local->rssi) { in airo_get_aplist()
7200 qual[i].level = 0x100 - dBm; in airo_get_aplist()
7201 qual[i].qual = airo_dbm_to_pct(local->rssi, dBm); in airo_get_aplist()
7212 qual[i].noise = local->wstats.qual.noise; in airo_get_aplist()
7239 dwrq->flags = 1; /* Should be define'd */ in airo_get_aplist()
7243 dwrq->length = i; in airo_get_aplist()
7249 /*------------------------------------------------------------------*/
7258 struct airo_info *ai = dev->ml_priv; in airo_set_scan()
7270 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; in airo_set_scan()
7272 if (down_interruptible(&ai->sem)) in airo_set_scan()
7273 return -ERESTARTSYS; in airo_set_scan()
7277 if (ai->scan_timeout > 0) in airo_set_scan()
7288 ai->scan_timeout = RUN_AT(3*HZ); in airo_set_scan()
7295 up(&ai->sem); in airo_set_scan()
7297 wake_up_interruptible(&ai->thr_wait); in airo_set_scan()
7301 /*------------------------------------------------------------------*/
7304 * format that the Wireless Tools will understand - Jean II
7312 struct airo_info *ai = dev->ml_priv; in airo_translate_scan()
7323 memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); in airo_translate_scan()
7330 iwe.u.data.length = bss->ssidLen; in airo_translate_scan()
7336 &iwe, bss->ssid); in airo_translate_scan()
7340 capabilities = bss->cap; in airo_translate_scan()
7352 iwe.u.freq.m = le16_to_cpu(bss->dsChannel); in airo_translate_scan()
7359 dBm = le16_to_cpu(bss->dBm); in airo_translate_scan()
7363 if (ai->rssi) { in airo_translate_scan()
7364 iwe.u.qual.level = 0x100 - dBm; in airo_translate_scan()
7365 iwe.u.qual.qual = airo_dbm_to_pct(ai->rssi, dBm); in airo_translate_scan()
7376 iwe.u.qual.noise = ai->wstats.qual.noise; in airo_translate_scan()
7388 &iwe, bss->ssid); in airo_translate_scan()
7391 * more of magic - Jean II */ in airo_translate_scan()
7400 if (bss->rates[i] == 0) in airo_translate_scan()
7403 iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000); in airo_translate_scan()
7410 if ((current_val - current_ev) > iwe_stream_lcp_len(info)) in airo_translate_scan()
7417 sprintf(buf, "bcn_int=%d", bss->beaconInterval); in airo_translate_scan()
7425 if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) { in airo_translate_scan()
7427 u16 length = sizeof (bss->extra.iep); in airo_translate_scan()
7428 u8 *ie = (void *)&bss->extra.iep; in airo_translate_scan()
7438 /* Two zero-length SSID elements in airo_translate_scan()
7451 /* 64 is an arbitrary cut-off */ in airo_translate_scan()
7462 /* 64 is an arbitrary cut-off */ in airo_translate_scan()
7473 length -= 2 + ie[1]; in airo_translate_scan()
7480 /*------------------------------------------------------------------*/
7489 struct airo_info *ai = dev->ml_priv; in airo_get_scan()
7494 /* If a scan is in-progress, return -EAGAIN */ in airo_get_scan()
7495 if (ai->scan_timeout > 0) in airo_get_scan()
7496 return -EAGAIN; in airo_get_scan()
7498 if (down_interruptible(&ai->sem)) in airo_get_scan()
7499 return -EAGAIN; in airo_get_scan()
7501 list_for_each_entry (net, &ai->network_list, list) { in airo_get_scan()
7504 extra + dwrq->length, in airo_get_scan()
7505 &net->bss); in airo_get_scan()
7508 if ((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { in airo_get_scan()
7510 err = -E2BIG; in airo_get_scan()
7516 dwrq->length = (current_ev - extra); in airo_get_scan()
7517 dwrq->flags = 0; /* todo */ in airo_get_scan()
7520 up(&ai->sem); in airo_get_scan()
7524 /*------------------------------------------------------------------*/
7533 struct airo_info *local = dev->ml_priv; in airo_config_commit()
7535 if (!test_bit (FLAG_COMMIT, &local->flags)) in airo_config_commit()
7541 if (test_bit (FLAG_RESET, &local->flags)) { in airo_config_commit()
7545 if (test_bit(FLAG_MPI,&local->flags)) in airo_config_commit()
7551 writeAPListRid(local, &local->APList, 1); in airo_config_commit()
7553 if (down_interruptible(&local->sem)) in airo_config_commit()
7554 return -ERESTARTSYS; in airo_config_commit()
7557 if (test_bit (FLAG_RESET, &local->flags)) in airo_config_commit()
7560 up(&local->sem); in airo_config_commit()
7565 /*------------------------------------------------------------------*/
7602 (iw_handler) NULL, /* -- hole -- */
7610 (iw_handler) NULL, /* -- hole -- */
7611 (iw_handler) NULL, /* -- hole -- */
7626 (iw_handler) NULL, /* -- hole -- */
7627 (iw_handler) NULL, /* -- hole -- */
7677 struct airo_info *ai = dev->ml_priv; in airo_siocdevprivate()
7679 if (ai->power.event) in airo_siocdevprivate()
7692 rc = -EFAULT; in airo_siocdevprivate()
7694 rc = -EFAULT; in airo_siocdevprivate()
7708 rc = -EFAULT; in airo_siocdevprivate()
7716 rc = -EFAULT; in airo_siocdevprivate()
7727 rc = -EINVAL; /* Bad command in ioctl */ in airo_siocdevprivate()
7734 rc = -EOPNOTSUPP; in airo_siocdevprivate()
7744 * o Check if work in Ad-Hoc mode (otherwise, use SPY, as in wvlan_cs)
7756 if (local->power.event) in airo_read_wireless_stats()
7764 local->wstats.status = le16_to_cpu(status_rid.mode); in airo_read_wireless_stats()
7767 if (local->rssi) { in airo_read_wireless_stats()
7768 local->wstats.qual.level = in airo_read_wireless_stats()
7769 airo_rssi_to_dbm(local->rssi, in airo_read_wireless_stats()
7772 local->wstats.qual.qual = in airo_read_wireless_stats()
7775 local->wstats.qual.level = in airo_read_wireless_stats()
7777 local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid); in airo_read_wireless_stats()
7780 local->wstats.qual.noise = 0x100 - status_rid.noisedBm; in airo_read_wireless_stats()
7781 local->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; in airo_read_wireless_stats()
7783 local->wstats.qual.noise = 0; in airo_read_wireless_stats()
7784 …local->wstats.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID … in airo_read_wireless_stats()
7789 local->wstats.discard.nwid = le32_to_cpu(vals[56]) + in airo_read_wireless_stats()
7792 local->wstats.discard.code = le32_to_cpu(vals[6]);/* RxWepErr */ in airo_read_wireless_stats()
7793 local->wstats.discard.fragment = le32_to_cpu(vals[30]); in airo_read_wireless_stats()
7794 local->wstats.discard.retries = le32_to_cpu(vals[10]); in airo_read_wireless_stats()
7795 local->wstats.discard.misc = le32_to_cpu(vals[1]) + in airo_read_wireless_stats()
7797 local->wstats.miss.beacon = le32_to_cpu(vals[34]); in airo_read_wireless_stats()
7802 struct airo_info *local = dev->ml_priv; in airo_get_wireless_stats()
7804 if (!down_interruptible(&local->sem)) { in airo_get_wireless_stats()
7806 up(&local->sem); in airo_get_wireless_stats()
7808 return &local->wstats; in airo_get_wireless_stats()
7823 struct airo_info *ai = dev->ml_priv; in readrids()
7825 if (test_bit(FLAG_FLASHING, &ai->flags)) in readrids()
7826 return -EIO; in readrids()
7828 switch(comp->command) in readrids()
7832 if (test_bit(FLAG_COMMIT, &ai->flags)) { in readrids()
7848 if (copy_to_user(comp->data, &ai->micstats, in readrids()
7849 min((int)comp->len, (int)sizeof(ai->micstats)))) in readrids()
7850 return -EFAULT; in readrids()
7852 case AIRORRID: ridcode = comp->ridnum; break; in readrids()
7854 return -EINVAL; in readrids()
7858 /* Only super-user can read WEP keys */ in readrids()
7860 return -EPERM; in readrids()
7864 return -ENOMEM; in readrids()
7871 len = comp->len; in readrids()
7873 if (copy_to_user(comp->data, iobuf, min(len, (int)RIDSIZE))) { in readrids()
7875 return -EFAULT; in readrids()
7887 struct airo_info *ai = dev->ml_priv; in writerids()
7893 /* Only super-user can write RIDs */ in writerids()
7895 return -EPERM; in writerids()
7897 if (test_bit(FLAG_FLASHING, &ai->flags)) in writerids()
7898 return -EIO; in writerids()
7903 switch(comp->command) in writerids()
7908 case AIROPCFG: ai->config.len = 0; in writerids()
7909 clear_bit(FLAG_COMMIT, &ai->flags); in writerids()
7924 return -EIO; in writerids()
7941 return -ENOMEM; in writerids()
7945 enabled = ai->micstats.enabled; in writerids()
7946 memset(&ai->micstats, 0, sizeof(ai->micstats)); in writerids()
7947 ai->micstats.enabled = enabled; in writerids()
7949 if (copy_to_user(comp->data, iobuf, in writerids()
7950 min((int)comp->len, (int)RIDSIZE))) { in writerids()
7952 return -EFAULT; in writerids()
7958 return -EOPNOTSUPP; /* Blarg! */ in writerids()
7960 if (comp->len > RIDSIZE) in writerids()
7961 return -EINVAL; in writerids()
7964 return -ENOMEM; in writerids()
7966 if (copy_from_user(iobuf, comp->data, comp->len)) { in writerids()
7968 return -EFAULT; in writerids()
7971 if (comp->command == AIROPCFG) { in writerids()
7974 if (test_bit(FLAG_MIC_CAPABLE, &ai->flags)) in writerids()
7975 cfg->opmode |= MODE_MIC; in writerids()
7977 if ((cfg->opmode & MODE_CFG_MASK) == MODE_STA_IBSS) in writerids()
7978 set_bit (FLAG_ADHOC, &ai->flags); in writerids()
7980 clear_bit (FLAG_ADHOC, &ai->flags); in writerids()
7983 if ((*writer)(ai, ridcode, iobuf, comp->len, 1)) { in writerids()
7985 return -EIO; in writerids()
8004 /* Only super-user can modify flash */ in flashcard()
8006 return -EPERM; in flashcard()
8008 switch(comp->command) in flashcard()
8011 return cmdreset((struct airo_info *)dev->ml_priv); in flashcard()
8016 return -ENOMEM; in flashcard()
8017 return setflashmode((struct airo_info *)dev->ml_priv); in flashcard()
8020 if (comp->len != sizeof(int)) in flashcard()
8021 return -EINVAL; in flashcard()
8022 if (copy_from_user(&z, comp->data, comp->len)) in flashcard()
8023 return -EFAULT; in flashcard()
8024 return flashgchar((struct airo_info *)dev->ml_priv, z, 8000); in flashcard()
8027 if (comp->len != sizeof(int)) in flashcard()
8028 return -EINVAL; in flashcard()
8029 if (copy_from_user(&z, comp->data, comp->len)) in flashcard()
8030 return -EFAULT; in flashcard()
8031 return flashpchar((struct airo_info *)dev->ml_priv, z, 8000); in flashcard()
8035 return -ENOMEM; in flashcard()
8036 if (comp->len > FLASHSIZE) in flashcard()
8037 return -EINVAL; in flashcard()
8038 if (copy_from_user(AIRO_FLASH(dev), comp->data, comp->len)) in flashcard()
8039 return -EFAULT; in flashcard()
8041 flashputbuf((struct airo_info *)dev->ml_priv); in flashcard()
8045 if (flashrestart((struct airo_info *)dev->ml_priv, dev)) in flashcard()
8046 return -EIO; in flashcard()
8049 return -EINVAL; in flashcard()
8065 airo_print_info(ai->dev->name, "Waitbusy hang before RESET"); in cmdreset()
8066 return -EBUSY; in cmdreset()
8074 airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET"); in cmdreset()
8075 return -EBUSY; in cmdreset()
8087 set_bit (FLAG_FLASHING, &ai->flags); in setflashmode()
8102 clear_bit (FLAG_FLASHING, &ai->flags); in setflashmode()
8103 airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode"); in setflashmode()
8104 return -EIO; in setflashmode()
8128 waittime -= 50; in flashpchar()
8133 airo_print_info(ai->dev->name, "flash putchar busywait timeout!"); in flashpchar()
8134 return -EBUSY; in flashpchar()
8141 dwelltime -= 50; in flashpchar()
8147 return (echo == byte) ? 0 : -EIO; in flashpchar()
8163 dwelltime -= 10; in flashgchar()
8178 return -EIO; in flashgchar()
8191 if (test_bit(FLAG_MPI,&ai->flags)) in flashputbuf()
8192 memcpy_toio(ai->pciaux + 0x8000, ai->flash, FLASHSIZE); in flashputbuf()
8198 OUT4500(ai, AUXDATA, ai->flash[nwords] & 0xffff); in flashputbuf()
8214 clear_bit (FLAG_FLASHING, &ai->flags); in flashrestart()
8215 if (test_bit(FLAG_MPI, &ai->flags)) { in flashrestart()
8222 if (!test_bit(FLAG_MPI,&ai->flags)) in flashrestart()
8224 ai->fids[i] = transmit_allocate in flashrestart()