Lines Matching +full:fiq +full:- +full:index
1 /*** -*- linux-c -*- **********************************************************
5 Copyright 2000-2001 ATMEL Corporation.
6 Copyright 2003-2004 Simon Kelley.
80 over-rides any automatic selection */
100 MODULE_FIRMWARE("atmel_at76c502-wpa.bin");
102 MODULE_FIRMWARE("atmel_at76c502d-wpa.bin");
104 MODULE_FIRMWARE("atmel_at76c502e-wpa.bin");
106 MODULE_FIRMWARE("atmel_at76c502_3com-wpa.bin");
108 MODULE_FIRMWARE("atmel_at76c504-wpa.bin");
110 MODULE_FIRMWARE("atmel_at76c504_2958-wpa.bin");
112 MODULE_FIRMWARE("atmel_at76c504a_2958-wpa.bin");
114 MODULE_FIRMWARE("atmel_at76c506-wpa.bin");
144 #define BSS_SRAM 0x0200 /* AMBA module selection --> SRAM */
145 #define BSS_IRAM 0x0100 /* AMBA module selection --> IRAM */
159 u8 index; member
230 * Host-MAC interface
336 #define REG_DOMAIN_FCC 0x10 /* Channels 1-11 USA */
337 #define REG_DOMAIN_DOC 0x20 /* Channel 1-11 Canada */
338 #define REG_DOMAIN_ETSI 0x30 /* Channel 1-13 Europe (ex Spain/France) */
339 #define REG_DOMAIN_SPAIN 0x31 /* Channel 10-11 Spain */
340 #define REG_DOMAIN_FRANCE 0x32 /* Channel 10-13 France */
342 #define REG_DOMAIN_MKK1 0x41 /* Channel 1-14 Japan(MKK1) */
343 #define REG_DOMAIN_ISRAEL 0x50 /* Channel 3-9 ISRAEL */
597 static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
598 static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index,
600 static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index,
602 static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index,
604 static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index,
617 return priv->host_info_base + offset; in atmel_hi()
622 return priv->host_info.command_pos + offset; in atmel_co()
627 return priv->host_info.rx_desc_pos + (sizeof(struct rx_desc) * desc) + offset; in atmel_rx()
632 return priv->host_info.tx_desc_pos + (sizeof(struct tx_desc) * desc) + offset; in atmel_tx()
637 return inb(dev->base_addr + offset); in atmel_read8()
642 outb(data, dev->base_addr + offset); in atmel_write8()
647 return inw(dev->base_addr + offset); in atmel_read16()
652 outw(data, dev->base_addr + offset); in atmel_write16()
657 atmel_writeAR(priv->dev, pos); in atmel_rmem8()
658 return atmel_read8(priv->dev, DR); in atmel_rmem8()
663 atmel_writeAR(priv->dev, pos); in atmel_wmem8()
664 atmel_write8(priv->dev, DR, data); in atmel_wmem8()
669 atmel_writeAR(priv->dev, pos); in atmel_rmem16()
670 return atmel_read16(priv->dev, DR); in atmel_rmem16()
675 atmel_writeAR(priv->dev, pos); in atmel_wmem16()
676 atmel_write16(priv->dev, DR, data); in atmel_wmem16()
686 atmel_rmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_head)) == TX_DONE && in tx_done_irq()
687 i < priv->host_info.tx_desc_count; in tx_done_irq()
689 u8 status = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_STATUS_OFFSET, priv->tx_desc_head)); in tx_done_irq()
690 u16 msdu_size = atmel_rmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_head)); in tx_done_irq()
691 u8 type = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_PACKET_TYPE_OFFSET, priv->tx_desc_head)); in tx_done_irq()
693 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_head), 0); in tx_done_irq()
695 priv->tx_free_mem += msdu_size; in tx_done_irq()
696 priv->tx_desc_free++; in tx_done_irq()
698 if (priv->tx_buff_head + msdu_size > (priv->host_info.tx_buff_pos + priv->host_info.tx_buff_size)) in tx_done_irq()
699 priv->tx_buff_head = 0; in tx_done_irq()
701 priv->tx_buff_head += msdu_size; in tx_done_irq()
703 if (priv->tx_desc_head < (priv->host_info.tx_desc_count - 1)) in tx_done_irq()
704 priv->tx_desc_head++ ; in tx_done_irq()
706 priv->tx_desc_head = 0; in tx_done_irq()
710 priv->dev->stats.tx_packets++; in tx_done_irq()
712 priv->dev->stats.tx_errors++; in tx_done_irq()
713 netif_wake_queue(priv->dev); in tx_done_irq()
720 u16 bottom_free = priv->host_info.tx_buff_size - priv->tx_buff_tail; in find_tx_buff()
722 if (priv->tx_desc_free == 3 || priv->tx_free_mem < len) in find_tx_buff()
726 return priv->host_info.tx_buff_pos + priv->tx_buff_tail; in find_tx_buff()
728 if (priv->tx_free_mem - bottom_free >= len) { in find_tx_buff()
729 priv->tx_buff_tail = 0; in find_tx_buff()
730 return priv->host_info.tx_buff_pos; in find_tx_buff()
739 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, priv->tx_desc_tail), buff); in tx_update_descriptor()
740 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_tail), len); in tx_update_descriptor()
741 if (!priv->use_wpa) in tx_update_descriptor()
742 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_HOST_LENGTH_OFFSET, priv->tx_desc_tail), len); in tx_update_descriptor()
743 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_PACKET_TYPE_OFFSET, priv->tx_desc_tail), type); in tx_update_descriptor()
744 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_RATE_OFFSET, priv->tx_desc_tail), priv->tx_rate); in tx_update_descriptor()
745 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_RETRY_OFFSET, priv->tx_desc_tail), 0); in tx_update_descriptor()
746 if (priv->use_wpa) { in tx_update_descriptor()
749 cipher_type = priv->group_cipher_suite; in tx_update_descriptor()
755 else if (priv->pairwise_cipher_suite == CIPHER_SUITE_WEP_64 || in tx_update_descriptor()
756 priv->pairwise_cipher_suite == CIPHER_SUITE_WEP_128) { in tx_update_descriptor()
757 cipher_type = priv->pairwise_cipher_suite; in tx_update_descriptor()
764 cipher_type = priv->pairwise_cipher_suite; in tx_update_descriptor()
770 else if (priv->group_cipher_suite == CIPHER_SUITE_WEP_64 || in tx_update_descriptor()
771 priv->group_cipher_suite == CIPHER_SUITE_WEP_128) { in tx_update_descriptor()
772 cipher_type = priv->group_cipher_suite; in tx_update_descriptor()
780 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_TYPE_OFFSET, priv->tx_desc_tail), in tx_update_descriptor()
782 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_LENGTH_OFFSET, priv->tx_desc_tail), in tx_update_descriptor()
785 atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, priv->tx_desc_tail), 0x80000000L); in tx_update_descriptor()
786 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_tail), TX_FIRM_OWN); in tx_update_descriptor()
787 if (priv->tx_desc_previous != priv->tx_desc_tail) in tx_update_descriptor()
788 atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, priv->tx_desc_previous), 0); in tx_update_descriptor()
789 priv->tx_desc_previous = priv->tx_desc_tail; in tx_update_descriptor()
790 if (priv->tx_desc_tail < (priv->host_info.tx_desc_count - 1)) in tx_update_descriptor()
791 priv->tx_desc_tail++; in tx_update_descriptor()
793 priv->tx_desc_tail = 0; in tx_update_descriptor()
794 priv->tx_desc_free--; in tx_update_descriptor()
795 priv->tx_free_mem -= len; in tx_update_descriptor()
803 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; in start_tx()
805 if (priv->card && priv->present_callback && in start_tx()
806 !(*priv->present_callback)(priv->card)) { in start_tx()
807 dev->stats.tx_errors++; in start_tx()
812 if (priv->station_state != STATION_STATE_READY) { in start_tx()
813 dev->stats.tx_errors++; in start_tx()
819 spin_lock_bh(&priv->timerlock); in start_tx()
821 spin_lock_irqsave(&priv->irqlock, flags); in start_tx()
827 initial + 18 (+30-12) */ in start_tx()
830 dev->stats.tx_dropped++; in start_tx()
831 spin_unlock_irqrestore(&priv->irqlock, flags); in start_tx()
832 spin_unlock_bh(&priv->timerlock); in start_tx()
840 if (priv->wep_is_on) in start_tx()
842 if (priv->operating_mode == IW_MODE_ADHOC) { in start_tx()
844 memcpy(&header.addr2, dev->dev_addr, ETH_ALEN); in start_tx()
845 memcpy(&header.addr3, priv->BSSID, ETH_ALEN); in start_tx()
848 memcpy(&header.addr1, priv->CurrentBSSID, ETH_ALEN); in start_tx()
849 memcpy(&header.addr2, dev->dev_addr, ETH_ALEN); in start_tx()
853 if (priv->use_wpa) in start_tx()
860 atmel_copy_to_card(dev, buff + DATA_FRAME_WS_HEADER_SIZE, skb->data + 12, len - 12); in start_tx()
861 priv->tx_buff_tail += len - 12 + DATA_FRAME_WS_HEADER_SIZE; in start_tx()
864 tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA); in start_tx()
865 dev->stats.tx_bytes += len; in start_tx()
867 spin_unlock_irqrestore(&priv->irqlock, flags); in start_tx()
868 spin_unlock_bh(&priv->timerlock); in start_tx()
884 atmel_copy_to_card(priv->dev, buff, (u8 *)header, MGMT_FRAME_BODY_OFFSET); in atmel_transmit_management_frame()
885 atmel_copy_to_card(priv->dev, buff + MGMT_FRAME_BODY_OFFSET, body, body_len); in atmel_transmit_management_frame()
886 priv->tx_buff_tail += len; in atmel_transmit_management_frame()
887 tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT); in atmel_transmit_management_frame()
900 atmel_copy_to_host(priv->dev, mac4, rx_packet_loc + 24, 6); in fast_rx_path()
901 msdu_size -= 6; in fast_rx_path()
903 if (priv->do_rx_crc) { in fast_rx_path()
905 msdu_size -= 4; in fast_rx_path()
909 priv->dev->stats.rx_dropped++; in fast_rx_path()
915 atmel_copy_to_host(priv->dev, skbp + 12, rx_packet_loc + 30, msdu_size); in fast_rx_path()
917 if (priv->do_rx_crc) { in fast_rx_path()
920 atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + 30 + msdu_size, 4); in fast_rx_path()
922 priv->dev->stats.rx_crc_errors++; in fast_rx_path()
928 memcpy(skbp, header->addr1, ETH_ALEN); /* destination address */ in fast_rx_path()
929 if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS) in fast_rx_path()
930 memcpy(&skbp[ETH_ALEN], header->addr3, ETH_ALEN); in fast_rx_path()
932 memcpy(&skbp[ETH_ALEN], header->addr2, ETH_ALEN); /* source address */ in fast_rx_path()
934 skb->protocol = eth_type_trans(skb, priv->dev); in fast_rx_path()
935 skb->ip_summed = CHECKSUM_NONE; in fast_rx_path()
937 priv->dev->stats.rx_bytes += 12 + msdu_size; in fast_rx_path()
938 priv->dev->stats.rx_packets++; in fast_rx_path()
946 int i = msdu_size - 4; in probe_crc()
952 atmel_copy_to_host(priv->dev, (void *)&netcrc, packet_loc + i, 4); in probe_crc()
954 atmel_writeAR(priv->dev, packet_loc); in probe_crc()
955 while (i--) { in probe_crc()
956 u8 octet = atmel_read8(priv->dev, DR); in probe_crc()
972 if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS) in frag_rx_path()
973 memcpy(source, header->addr3, ETH_ALEN); in frag_rx_path()
975 memcpy(source, header->addr2, ETH_ALEN); in frag_rx_path()
979 if (priv->do_rx_crc) in frag_rx_path()
980 msdu_size -= 4; in frag_rx_path()
983 atmel_copy_to_host(priv->dev, mac4, rx_packet_loc, ETH_ALEN); in frag_rx_path()
984 msdu_size -= ETH_ALEN; in frag_rx_path()
987 if (priv->do_rx_crc) in frag_rx_path()
990 priv->frag_seq = seq_no; in frag_rx_path()
991 priv->frag_no = 1; in frag_rx_path()
992 priv->frag_len = msdu_size; in frag_rx_path()
993 memcpy(priv->frag_source, source, ETH_ALEN); in frag_rx_path()
994 memcpy(&priv->rx_buf[ETH_ALEN], source, ETH_ALEN); in frag_rx_path()
995 memcpy(priv->rx_buf, header->addr1, ETH_ALEN); in frag_rx_path()
997 atmel_copy_to_host(priv->dev, &priv->rx_buf[12], rx_packet_loc, msdu_size); in frag_rx_path()
999 if (priv->do_rx_crc) { in frag_rx_path()
1001 crc = crc32_le(crc, &priv->rx_buf[12], msdu_size); in frag_rx_path()
1002 atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); in frag_rx_path()
1004 priv->dev->stats.rx_crc_errors++; in frag_rx_path()
1005 eth_broadcast_addr(priv->frag_source); in frag_rx_path()
1009 } else if (priv->frag_no == frag_no && in frag_rx_path()
1010 priv->frag_seq == seq_no && in frag_rx_path()
1011 memcmp(priv->frag_source, source, ETH_ALEN) == 0) { in frag_rx_path()
1013 atmel_copy_to_host(priv->dev, &priv->rx_buf[12 + priv->frag_len], in frag_rx_path()
1015 if (priv->do_rx_crc) { in frag_rx_path()
1018 &priv->rx_buf[12 + priv->frag_len], in frag_rx_path()
1020 atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); in frag_rx_path()
1022 priv->dev->stats.rx_crc_errors++; in frag_rx_path()
1023 eth_broadcast_addr(priv->frag_source); in frag_rx_path()
1028 priv->frag_len += msdu_size; in frag_rx_path()
1029 priv->frag_no++; in frag_rx_path()
1032 eth_broadcast_addr(priv->frag_source); in frag_rx_path()
1033 if (!(skb = dev_alloc_skb(priv->frag_len + 14))) { in frag_rx_path()
1034 priv->dev->stats.rx_dropped++; in frag_rx_path()
1037 skb_put_data(skb, priv->rx_buf, in frag_rx_path()
1038 priv->frag_len + 12); in frag_rx_path()
1039 skb->protocol = eth_type_trans(skb, priv->dev); in frag_rx_path()
1040 skb->ip_summed = CHECKSUM_NONE; in frag_rx_path()
1042 priv->dev->stats.rx_bytes += priv->frag_len + 12; in frag_rx_path()
1043 priv->dev->stats.rx_packets++; in frag_rx_path()
1047 priv->wstats.discard.fragment++; in frag_rx_path()
1056 …atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID … in rx_done_irq()
1057 i < priv->host_info.rx_desc_count; in rx_done_irq()
1061 u8 status = atmel_rmem8(priv, atmel_rx(priv, RX_DESC_STATUS_OFFSET, priv->rx_desc_head)); in rx_done_irq()
1066 priv->wstats.discard.nwid++; in rx_done_irq()
1068 priv->dev->stats.rx_errors++; in rx_done_irq()
1072 msdu_size = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_SIZE_OFFSET, priv->rx_desc_head)); in rx_done_irq()
1073 rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head)); in rx_done_irq()
1076 priv->dev->stats.rx_errors++; in rx_done_irq()
1081 atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24); in rx_done_irq()
1088 if (priv->probe_crc) { in rx_done_irq()
1089 if (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED)) { in rx_done_irq()
1090 priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size); in rx_done_irq()
1092 priv->do_rx_crc = probe_crc(priv, rx_packet_loc + 24, msdu_size - 24); in rx_done_irq()
1094 if (priv->do_rx_crc) { in rx_done_irq()
1095 if (priv->crc_ok_cnt++ > 5) in rx_done_irq()
1096 priv->probe_crc = 0; in rx_done_irq()
1098 if (priv->crc_ko_cnt++ > 5) in rx_done_irq()
1099 priv->probe_crc = 0; in rx_done_irq()
1104 if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED))) { in rx_done_irq()
1107 msdu_size -= 24; /* header */ in rx_done_irq()
1124 atmel_copy_to_host(priv->dev, (unsigned char *)&priv->rx_buf, rx_packet_loc + 24, msdu_size); in rx_done_irq()
1127 eth_broadcast_addr(priv->frag_source); in rx_done_irq()
1129 if (priv->do_rx_crc) { in rx_done_irq()
1131 msdu_size -= 4; in rx_done_irq()
1132 crc = crc32_le(crc, (unsigned char *)&priv->rx_buf, msdu_size); in rx_done_irq()
1133 if ((crc ^ 0xffffffff) != (*((u32 *)&priv->rx_buf[msdu_size]))) { in rx_done_irq()
1134 priv->dev->stats.rx_crc_errors++; in rx_done_irq()
1140 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_RSSI_OFFSET, priv->rx_desc_head))); in rx_done_irq()
1145 …atmel_wmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head), RX_DESC_FLAG_CONSUMED); in rx_done_irq()
1147 if (priv->rx_desc_head < (priv->host_info.rx_desc_count - 1)) in rx_done_irq()
1148 priv->rx_desc_head++; in rx_done_irq()
1150 priv->rx_desc_head = 0; in rx_done_irq()
1159 int i = -1; in service_interrupt()
1171 if (priv->card && priv->present_callback && in service_interrupt()
1172 !(*priv->present_callback)(priv->card)) in service_interrupt()
1175 /* In this state upper-level code assumes it can mess with in service_interrupt()
1180 if (priv->station_state == STATION_STATE_DOWN) in service_interrupt()
1188 printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name); in service_interrupt()
1197 return i == -1 ? IRQ_NONE : IRQ_HANDLED; in service_interrupt()
1208 printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name); in service_interrupt()
1220 if (priv->operating_mode == IW_MODE_INFRA && in service_interrupt()
1221 priv->station_state == STATION_STATE_READY) { in service_interrupt()
1222 priv->station_is_associated = 0; in service_interrupt()
1228 priv->wstats.discard.misc++; in service_interrupt()
1239 printk(KERN_ALERT "%s: *** FATAL error interrupt ***\n", dev->name); in service_interrupt()
1249 priv->CurrentBSSID, 6); in service_interrupt()
1251 if (priv->use_wpa) in service_interrupt()
1255 printk(KERN_INFO "%s: Generic_irq received.\n", dev->name); in service_interrupt()
1269 priv->wstats.status = priv->station_state; in atmel_get_wireless_stats()
1271 if (priv->operating_mode == IW_MODE_INFRA) { in atmel_get_wireless_stats()
1272 if (priv->station_state != STATION_STATE_READY) { in atmel_get_wireless_stats()
1273 priv->wstats.qual.qual = 0; in atmel_get_wireless_stats()
1274 priv->wstats.qual.level = 0; in atmel_get_wireless_stats()
1275 priv->wstats.qual.updated = (IW_QUAL_QUAL_INVALID in atmel_get_wireless_stats()
1278 priv->wstats.qual.noise = 0; in atmel_get_wireless_stats()
1279 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID; in atmel_get_wireless_stats()
1281 /* Quality levels cannot be determined in ad-hoc mode, in atmel_get_wireless_stats()
1283 priv->wstats.qual.qual = 0; in atmel_get_wireless_stats()
1284 priv->wstats.qual.level = 0; in atmel_get_wireless_stats()
1285 priv->wstats.qual.noise = 0; in atmel_get_wireless_stats()
1286 priv->wstats.qual.updated = IW_QUAL_QUAL_INVALID in atmel_get_wireless_stats()
1289 priv->wstats.miss.beacon = 0; in atmel_get_wireless_stats()
1292 return &priv->wstats; in atmel_get_wireless_stats()
1299 eth_hw_addr_set(dev, addr->sa_data); in atmel_set_mac_address()
1311 del_timer_sync(&priv->management_timer); in atmel_open()
1314 priv->station_state = STATION_STATE_DOWN; in atmel_open()
1316 if (priv->new_SSID_size) { in atmel_open()
1317 memcpy(priv->SSID, priv->new_SSID, priv->new_SSID_size); in atmel_open()
1318 priv->SSID_size = priv->new_SSID_size; in atmel_open()
1319 priv->new_SSID_size = 0; in atmel_open()
1321 priv->BSS_list_entries = 0; in atmel_open()
1323 priv->AuthenticationRequestRetryCnt = 0; in atmel_open()
1324 priv->AssociationRequestRetryCnt = 0; in atmel_open()
1325 priv->ReAssociationRequestRetryCnt = 0; in atmel_open()
1326 priv->CurrentAuthentTransactionSeqNum = 0x0001; in atmel_open()
1327 priv->ExpectedAuthentTransactionSeqNum = 0x0002; in atmel_open()
1329 priv->site_survey_state = SITE_SURVEY_IDLE; in atmel_open()
1330 priv->station_is_associated = 0; in atmel_open()
1336 if (priv->config_reg_domain) { in atmel_open()
1337 priv->reg_domain = priv->config_reg_domain; in atmel_open()
1338 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS, priv->reg_domain); in atmel_open()
1340 priv->reg_domain = atmel_get_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS); in atmel_open()
1342 if (priv->reg_domain == channel_table[i].reg_domain) in atmel_open()
1345 priv->reg_domain = REG_DOMAIN_MKK1; in atmel_open()
1346 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name); in atmel_open()
1350 if ((channel = atmel_validate_channel(priv, priv->channel))) in atmel_open()
1351 priv->channel = channel; in atmel_open()
1356 atmel_set_gcr(priv->dev, GCR_ENINT); /* enable interrupts */ in atmel_open()
1365 if (priv->station_state == STATION_STATE_READY) { in atmel_close()
1372 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); in atmel_close()
1377 if (priv->bus_type == BUS_TYPE_PCCARD) in atmel_close()
1390 if (priv->reg_domain == channel_table[i].reg_domain) { in atmel_validate_channel()
1403 struct atmel_private *priv = m->private; in atmel_proc_show()
1409 if (priv->station_state != STATION_STATE_DOWN) { in atmel_proc_show()
1413 priv->host_info.major_version, in atmel_proc_show()
1414 priv->host_info.minor_version, in atmel_proc_show()
1415 priv->host_info.build_version); in atmel_proc_show()
1417 if (priv->card_type != CARD_TYPE_EEPROM) in atmel_proc_show()
1419 else if (priv->firmware) in atmel_proc_show()
1420 seq_printf(m, "%s loaded by host\n", priv->firmware_id); in atmel_proc_show()
1422 seq_printf(m, "%s loaded by hotplug\n", priv->firmware_id); in atmel_proc_show()
1424 switch (priv->card_type) { in atmel_proc_show()
1440 if (priv->reg_domain == channel_table[i].reg_domain) in atmel_proc_show()
1446 priv->do_rx_crc ? "On" : "Off"); in atmel_proc_show()
1447 seq_printf(m, "WPA-capable firmware:\t%s\n", in atmel_proc_show()
1448 priv->use_wpa ? "Yes" : "No"); in atmel_proc_show()
1451 switch (priv->station_state) { in atmel_proc_show()
1508 if (dev_alloc_name(dev, dev->name) < 0) { in init_atmel_card()
1514 priv->dev = dev; in init_atmel_card()
1515 priv->sys_dev = sys_dev; in init_atmel_card()
1516 priv->present_callback = card_present; in init_atmel_card()
1517 priv->card = card; in init_atmel_card()
1518 priv->firmware = NULL; in init_atmel_card()
1519 priv->firmware_type = fw_type; in init_atmel_card()
1521 strscpy(priv->firmware_id, firmware, sizeof(priv->firmware_id)); in init_atmel_card()
1522 priv->bus_type = card_present ? BUS_TYPE_PCCARD : BUS_TYPE_PCI; in init_atmel_card()
1523 priv->station_state = STATION_STATE_DOWN; in init_atmel_card()
1524 priv->do_rx_crc = 0; in init_atmel_card()
1527 if (priv->bus_type == BUS_TYPE_PCCARD) { in init_atmel_card()
1528 priv->probe_crc = 1; in init_atmel_card()
1529 priv->crc_ok_cnt = priv->crc_ko_cnt = 0; in init_atmel_card()
1531 priv->probe_crc = 0; in init_atmel_card()
1532 priv->last_qual = jiffies; in init_atmel_card()
1533 priv->last_beacon_timestamp = 0; in init_atmel_card()
1534 memset(priv->frag_source, 0xff, sizeof(priv->frag_source)); in init_atmel_card()
1535 eth_zero_addr(priv->BSSID); in init_atmel_card()
1536 priv->CurrentBSSID[0] = 0xFF; /* Initialize to something invalid.... */ in init_atmel_card()
1537 priv->station_was_associated = 0; in init_atmel_card()
1539 priv->last_survey = jiffies; in init_atmel_card()
1540 priv->preamble = LONG_PREAMBLE; in init_atmel_card()
1541 priv->operating_mode = IW_MODE_INFRA; in init_atmel_card()
1542 priv->connect_to_any_BSS = 0; in init_atmel_card()
1543 priv->config_reg_domain = 0; in init_atmel_card()
1544 priv->reg_domain = 0; in init_atmel_card()
1545 priv->tx_rate = 3; in init_atmel_card()
1546 priv->auto_tx_rate = 1; in init_atmel_card()
1547 priv->channel = 4; in init_atmel_card()
1548 priv->power_mode = 0; in init_atmel_card()
1549 priv->SSID[0] = '\0'; in init_atmel_card()
1550 priv->SSID_size = 0; in init_atmel_card()
1551 priv->new_SSID_size = 0; in init_atmel_card()
1552 priv->frag_threshold = 2346; in init_atmel_card()
1553 priv->rts_threshold = 2347; in init_atmel_card()
1554 priv->short_retry = 7; in init_atmel_card()
1555 priv->long_retry = 4; in init_atmel_card()
1557 priv->wep_is_on = 0; in init_atmel_card()
1558 priv->default_key = 0; in init_atmel_card()
1559 priv->encryption_level = 0; in init_atmel_card()
1560 priv->exclude_unencrypted = 0; in init_atmel_card()
1561 priv->group_cipher_suite = priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; in init_atmel_card()
1562 priv->use_wpa = 0; in init_atmel_card()
1563 memset(priv->wep_keys, 0, sizeof(priv->wep_keys)); in init_atmel_card()
1564 memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len)); in init_atmel_card()
1566 priv->default_beacon_period = priv->beacon_period = 100; in init_atmel_card()
1567 priv->listen_interval = 1; in init_atmel_card()
1569 timer_setup(&priv->management_timer, atmel_management_timer, 0); in init_atmel_card()
1570 spin_lock_init(&priv->irqlock); in init_atmel_card()
1571 spin_lock_init(&priv->timerlock); in init_atmel_card()
1573 dev->netdev_ops = &atmel_netdev_ops; in init_atmel_card()
1574 dev->wireless_handlers = &atmel_handler_def; in init_atmel_card()
1575 dev->irq = irq; in init_atmel_card()
1576 dev->base_addr = port; in init_atmel_card()
1578 /* MTU range: 68 - 2312 */ in init_atmel_card()
1579 dev->min_mtu = 68; in init_atmel_card()
1580 dev->max_mtu = MAX_WIRELESS_BODY - ETH_FCS_LEN; in init_atmel_card()
1584 if ((rc = request_irq(dev->irq, service_interrupt, IRQF_SHARED, dev->name, dev))) { in init_atmel_card()
1585 printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc); in init_atmel_card()
1589 if (!request_region(dev->base_addr, 32, in init_atmel_card()
1590 priv->bus_type == BUS_TYPE_PCCARD ? "atmel_cs" : "atmel_pci")) { in init_atmel_card()
1609 dev->name, DRIVER_MAJOR, DRIVER_MINOR, dev->dev_addr); in init_atmel_card()
1614 release_region(dev->base_addr, 32); in init_atmel_card()
1616 free_irq(dev->irq, dev); in init_atmel_card()
1629 if (priv->bus_type == BUS_TYPE_PCCARD) in stop_atmel_card()
1633 del_timer_sync(&priv->management_timer); in stop_atmel_card()
1636 free_irq(dev->irq, dev); in stop_atmel_card()
1637 kfree(priv->firmware); in stop_atmel_card()
1638 release_region(dev->base_addr, 32); in stop_atmel_card()
1652 if (dwrq->flags == 0) { in atmel_set_essid()
1653 priv->connect_to_any_BSS = 1; in atmel_set_essid()
1655 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in atmel_set_essid() local
1657 priv->connect_to_any_BSS = 0; in atmel_set_essid()
1660 if (dwrq->length > MAX_SSID_LENGTH) in atmel_set_essid()
1661 return -E2BIG; in atmel_set_essid()
1662 if (index != 0) in atmel_set_essid()
1663 return -EINVAL; in atmel_set_essid()
1665 memcpy(priv->new_SSID, extra, dwrq->length); in atmel_set_essid()
1666 priv->new_SSID_size = dwrq->length; in atmel_set_essid()
1669 return -EINPROGRESS; in atmel_set_essid()
1680 if (priv->new_SSID_size != 0) { in atmel_get_essid()
1681 memcpy(extra, priv->new_SSID, priv->new_SSID_size); in atmel_get_essid()
1682 dwrq->length = priv->new_SSID_size; in atmel_get_essid()
1684 memcpy(extra, priv->SSID, priv->SSID_size); in atmel_get_essid()
1685 dwrq->length = priv->SSID_size; in atmel_get_essid()
1688 dwrq->flags = !priv->connect_to_any_BSS; /* active */ in atmel_get_essid()
1699 memcpy(awrq->sa_data, priv->CurrentBSSID, ETH_ALEN); in atmel_get_wap()
1700 awrq->sa_family = ARPHRD_ETHER; in atmel_get_wap()
1717 * don't do it. - Jean II */ in atmel_set_encode()
1718 if (dwrq->length > 0) { in atmel_set_encode()
1719 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in atmel_set_encode() local
1720 int current_index = priv->default_key; in atmel_set_encode()
1722 if (dwrq->length > 13) { in atmel_set_encode()
1723 return -EINVAL; in atmel_set_encode()
1725 /* Check the index (none -> use current) */ in atmel_set_encode()
1726 if (index < 0 || index >= 4) in atmel_set_encode()
1727 index = current_index; in atmel_set_encode()
1729 priv->default_key = index; in atmel_set_encode()
1731 if (dwrq->length > 5) in atmel_set_encode()
1732 priv->wep_key_len[index] = 13; in atmel_set_encode()
1734 if (dwrq->length > 0) in atmel_set_encode()
1735 priv->wep_key_len[index] = 5; in atmel_set_encode()
1738 priv->wep_key_len[index] = 0; in atmel_set_encode()
1740 if (!(dwrq->flags & IW_ENCODE_NOKEY)) { in atmel_set_encode()
1742 memset(priv->wep_keys[index], 0, 13); in atmel_set_encode()
1744 memcpy(priv->wep_keys[index], extra, dwrq->length); in atmel_set_encode()
1749 if (index == current_index && in atmel_set_encode()
1750 priv->wep_key_len[index] > 0) { in atmel_set_encode()
1751 priv->wep_is_on = 1; in atmel_set_encode()
1752 priv->exclude_unencrypted = 1; in atmel_set_encode()
1753 if (priv->wep_key_len[index] > 5) { in atmel_set_encode()
1754 priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128; in atmel_set_encode()
1755 priv->encryption_level = 2; in atmel_set_encode()
1757 priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64; in atmel_set_encode()
1758 priv->encryption_level = 1; in atmel_set_encode()
1762 /* Do we want to just set the transmit key index ? */ in atmel_set_encode()
1763 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in atmel_set_encode() local
1764 if (index >= 0 && index < 4) { in atmel_set_encode()
1765 priv->default_key = index; in atmel_set_encode()
1768 if (!(dwrq->flags & IW_ENCODE_MODE)) in atmel_set_encode()
1769 return -EINVAL; in atmel_set_encode()
1772 if (dwrq->flags & IW_ENCODE_DISABLED) { in atmel_set_encode()
1773 priv->wep_is_on = 0; in atmel_set_encode()
1774 priv->encryption_level = 0; in atmel_set_encode()
1775 priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; in atmel_set_encode()
1777 priv->wep_is_on = 1; in atmel_set_encode()
1778 if (priv->wep_key_len[priv->default_key] > 5) { in atmel_set_encode()
1779 priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128; in atmel_set_encode()
1780 priv->encryption_level = 2; in atmel_set_encode()
1782 priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64; in atmel_set_encode()
1783 priv->encryption_level = 1; in atmel_set_encode()
1786 if (dwrq->flags & IW_ENCODE_RESTRICTED) in atmel_set_encode()
1787 priv->exclude_unencrypted = 1; in atmel_set_encode()
1788 if (dwrq->flags & IW_ENCODE_OPEN) in atmel_set_encode()
1789 priv->exclude_unencrypted = 0; in atmel_set_encode()
1791 return -EINPROGRESS; /* Call commit handler */ in atmel_set_encode()
1800 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; in atmel_get_encode() local
1802 if (!priv->wep_is_on) in atmel_get_encode()
1803 dwrq->flags = IW_ENCODE_DISABLED; in atmel_get_encode()
1805 if (priv->exclude_unencrypted) in atmel_get_encode()
1806 dwrq->flags = IW_ENCODE_RESTRICTED; in atmel_get_encode()
1808 dwrq->flags = IW_ENCODE_OPEN; in atmel_get_encode()
1810 /* Which key do we want ? -1 -> tx index */ in atmel_get_encode()
1811 if (index < 0 || index >= 4) in atmel_get_encode()
1812 index = priv->default_key; in atmel_get_encode()
1813 dwrq->flags |= index + 1; in atmel_get_encode()
1815 dwrq->length = priv->wep_key_len[index]; in atmel_get_encode()
1816 if (dwrq->length > 16) { in atmel_get_encode()
1817 dwrq->length = 0; in atmel_get_encode()
1820 memcpy(extra, priv->wep_keys[index], dwrq->length); in atmel_get_encode()
1832 struct iw_point *encoding = &wrqu->encoding; in atmel_set_encodeext()
1834 int idx, key_len, alg = ext->alg, set_key = 1; in atmel_set_encodeext()
1836 /* Determine and validate the key index */ in atmel_set_encodeext()
1837 idx = encoding->flags & IW_ENCODE_INDEX; in atmel_set_encodeext()
1840 return -EINVAL; in atmel_set_encodeext()
1841 idx--; in atmel_set_encodeext()
1843 idx = priv->default_key; in atmel_set_encodeext()
1845 if (encoding->flags & IW_ENCODE_DISABLED) in atmel_set_encodeext()
1848 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { in atmel_set_encodeext()
1849 priv->default_key = idx; in atmel_set_encodeext()
1850 set_key = ext->key_len > 0 ? 1 : 0; in atmel_set_encodeext()
1857 priv->wep_is_on = 0; in atmel_set_encodeext()
1858 priv->encryption_level = 0; in atmel_set_encodeext()
1859 priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; in atmel_set_encodeext()
1862 if (ext->key_len > 5) { in atmel_set_encodeext()
1863 priv->wep_key_len[idx] = 13; in atmel_set_encodeext()
1864 priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128; in atmel_set_encodeext()
1865 priv->encryption_level = 2; in atmel_set_encodeext()
1866 } else if (ext->key_len > 0) { in atmel_set_encodeext()
1867 priv->wep_key_len[idx] = 5; in atmel_set_encodeext()
1868 priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64; in atmel_set_encodeext()
1869 priv->encryption_level = 1; in atmel_set_encodeext()
1871 return -EINVAL; in atmel_set_encodeext()
1873 priv->wep_is_on = 1; in atmel_set_encodeext()
1874 memset(priv->wep_keys[idx], 0, 13); in atmel_set_encodeext()
1875 key_len = min ((int)ext->key_len, priv->wep_key_len[idx]); in atmel_set_encodeext()
1876 memcpy(priv->wep_keys[idx], ext->key, key_len); in atmel_set_encodeext()
1879 return -EINVAL; in atmel_set_encodeext()
1883 return -EINPROGRESS; in atmel_set_encodeext()
1892 struct iw_point *encoding = &wrqu->encoding; in atmel_get_encodeext()
1896 max_key_len = encoding->length - sizeof(*ext); in atmel_get_encodeext()
1898 return -EINVAL; in atmel_get_encodeext()
1900 idx = encoding->flags & IW_ENCODE_INDEX; in atmel_get_encodeext()
1903 return -EINVAL; in atmel_get_encodeext()
1904 idx--; in atmel_get_encodeext()
1906 idx = priv->default_key; in atmel_get_encodeext()
1908 encoding->flags = idx + 1; in atmel_get_encodeext()
1911 if (!priv->wep_is_on) { in atmel_get_encodeext()
1912 ext->alg = IW_ENCODE_ALG_NONE; in atmel_get_encodeext()
1913 ext->key_len = 0; in atmel_get_encodeext()
1914 encoding->flags |= IW_ENCODE_DISABLED; in atmel_get_encodeext()
1916 if (priv->encryption_level > 0) in atmel_get_encodeext()
1917 ext->alg = IW_ENCODE_ALG_WEP; in atmel_get_encodeext()
1919 return -EINVAL; in atmel_get_encodeext()
1921 ext->key_len = priv->wep_key_len[idx]; in atmel_get_encodeext()
1922 memcpy(ext->key, priv->wep_keys[idx], ext->key_len); in atmel_get_encodeext()
1923 encoding->flags |= IW_ENCODE_ENABLED; in atmel_get_encodeext()
1934 struct iw_param *param = &wrqu->param; in atmel_set_auth()
1936 switch (param->flags & IW_AUTH_INDEX) { in atmel_set_auth()
1949 priv->exclude_unencrypted = param->value ? 1 : 0; in atmel_set_auth()
1953 if (param->value & IW_AUTH_ALG_SHARED_KEY) { in atmel_set_auth()
1954 priv->exclude_unencrypted = 1; in atmel_set_auth()
1955 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) { in atmel_set_auth()
1956 priv->exclude_unencrypted = 0; in atmel_set_auth()
1958 return -EINVAL; in atmel_set_auth()
1964 if (param->value > 0) in atmel_set_auth()
1965 return -EOPNOTSUPP; in atmel_set_auth()
1969 return -EOPNOTSUPP; in atmel_set_auth()
1971 return -EINPROGRESS; in atmel_set_auth()
1979 struct iw_param *param = &wrqu->param; in atmel_get_auth()
1981 switch (param->flags & IW_AUTH_INDEX) { in atmel_get_auth()
1983 param->value = priv->exclude_unencrypted; in atmel_get_auth()
1987 if (priv->exclude_unencrypted == 1) in atmel_get_auth()
1988 param->value = IW_AUTH_ALG_SHARED_KEY; in atmel_get_auth()
1990 param->value = IW_AUTH_ALG_OPEN_SYSTEM; in atmel_get_auth()
1994 param->value = 0; in atmel_get_auth()
1998 return -EOPNOTSUPP; in atmel_get_auth()
2009 strcpy(cwrq, "IEEE 802.11-DS"); in atmel_get_name()
2020 if (vwrq->fixed == 0) { in atmel_set_rate()
2021 priv->tx_rate = 3; in atmel_set_rate()
2022 priv->auto_tx_rate = 1; in atmel_set_rate()
2024 priv->auto_tx_rate = 0; in atmel_set_rate()
2027 if ((vwrq->value < 4) && (vwrq->value >= 0)) { in atmel_set_rate()
2028 /* Setting by rate index */ in atmel_set_rate()
2029 priv->tx_rate = vwrq->value; in atmel_set_rate()
2032 switch (vwrq->value) { in atmel_set_rate()
2034 priv->tx_rate = 0; in atmel_set_rate()
2037 priv->tx_rate = 1; in atmel_set_rate()
2040 priv->tx_rate = 2; in atmel_set_rate()
2043 priv->tx_rate = 3; in atmel_set_rate()
2046 return -EINVAL; in atmel_set_rate()
2051 return -EINPROGRESS; in atmel_set_rate()
2062 return -EINVAL; in atmel_set_mode()
2064 priv->operating_mode = *uwrq; in atmel_set_mode()
2065 return -EINPROGRESS; in atmel_set_mode()
2075 *uwrq = priv->operating_mode; in atmel_get_mode()
2086 if (priv->auto_tx_rate) { in atmel_get_rate()
2087 vwrq->fixed = 0; in atmel_get_rate()
2088 vwrq->value = 11000000; in atmel_get_rate()
2090 vwrq->fixed = 1; in atmel_get_rate()
2091 switch (priv->tx_rate) { in atmel_get_rate()
2093 vwrq->value = 1000000; in atmel_get_rate()
2096 vwrq->value = 2000000; in atmel_get_rate()
2099 vwrq->value = 5500000; in atmel_get_rate()
2102 vwrq->value = 11000000; in atmel_get_rate()
2115 priv->power_mode = vwrq->disabled ? 0 : 1; in atmel_set_power()
2116 return -EINPROGRESS; in atmel_set_power()
2125 vwrq->disabled = priv->power_mode ? 0 : 1; in atmel_get_power()
2126 vwrq->flags = IW_POWER_ON; in atmel_get_power()
2137 if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { in atmel_set_retry()
2138 if (vwrq->flags & IW_RETRY_LONG) in atmel_set_retry()
2139 priv->long_retry = vwrq->value; in atmel_set_retry()
2140 else if (vwrq->flags & IW_RETRY_SHORT) in atmel_set_retry()
2141 priv->short_retry = vwrq->value; in atmel_set_retry()
2144 priv->long_retry = vwrq->value; in atmel_set_retry()
2145 priv->short_retry = vwrq->value; in atmel_set_retry()
2147 return -EINPROGRESS; in atmel_set_retry()
2150 return -EINVAL; in atmel_set_retry()
2160 vwrq->disabled = 0; /* Can't be disabled */ in atmel_get_retry()
2163 if (vwrq->flags & IW_RETRY_LONG) { in atmel_get_retry()
2164 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in atmel_get_retry()
2165 vwrq->value = priv->long_retry; in atmel_get_retry()
2167 vwrq->flags = IW_RETRY_LIMIT; in atmel_get_retry()
2168 vwrq->value = priv->short_retry; in atmel_get_retry()
2169 if (priv->long_retry != priv->short_retry) in atmel_get_retry()
2170 vwrq->flags |= IW_RETRY_SHORT; in atmel_get_retry()
2182 int rthr = vwrq->value; in atmel_set_rts()
2184 if (vwrq->disabled) in atmel_set_rts()
2187 return -EINVAL; in atmel_set_rts()
2189 priv->rts_threshold = rthr; in atmel_set_rts()
2191 return -EINPROGRESS; /* Call commit handler */ in atmel_set_rts()
2201 vwrq->value = priv->rts_threshold; in atmel_get_rts()
2202 vwrq->disabled = (vwrq->value >= 2347); in atmel_get_rts()
2203 vwrq->fixed = 1; in atmel_get_rts()
2214 int fthr = vwrq->value; in atmel_set_frag()
2216 if (vwrq->disabled) in atmel_set_frag()
2219 return -EINVAL; in atmel_set_frag()
2221 fthr &= ~0x1; /* Get an even value - is it really needed ??? */ in atmel_set_frag()
2222 priv->frag_threshold = fthr; in atmel_set_frag()
2224 return -EINPROGRESS; /* Call commit handler */ in atmel_set_frag()
2234 vwrq->value = priv->frag_threshold; in atmel_get_frag()
2235 vwrq->disabled = (vwrq->value >= 2346); in atmel_get_frag()
2236 vwrq->fixed = 1; in atmel_get_frag()
2247 int rc = -EINPROGRESS; /* Call commit handler */ in atmel_set_freq()
2250 if (fwrq->e == 1) { in atmel_set_freq()
2251 int f = fwrq->m / 100000; in atmel_set_freq()
2254 fwrq->e = 0; in atmel_set_freq()
2255 fwrq->m = ieee80211_frequency_to_channel(f); in atmel_set_freq()
2258 if (fwrq->m < 0 || fwrq->m > 1000 || fwrq->e > 0) in atmel_set_freq()
2259 rc = -EOPNOTSUPP; in atmel_set_freq()
2261 int channel = fwrq->m; in atmel_set_freq()
2263 priv->channel = channel; in atmel_set_freq()
2265 rc = -EINVAL; in atmel_set_freq()
2278 fwrq->m = priv->channel; in atmel_get_freq()
2279 fwrq->e = 0; in atmel_get_freq()
2298 if (priv->station_state == STATION_STATE_DOWN) in atmel_set_scan()
2299 return -EAGAIN; in atmel_set_scan()
2302 if (time_after(jiffies, priv->last_survey + 20 * HZ)) in atmel_set_scan()
2303 priv->site_survey_state = SITE_SURVEY_IDLE; in atmel_set_scan()
2304 priv->last_survey = jiffies; in atmel_set_scan()
2307 if (priv->site_survey_state == SITE_SURVEY_IN_PROGRESS) in atmel_set_scan()
2308 return -EBUSY; in atmel_set_scan()
2310 del_timer_sync(&priv->management_timer); in atmel_set_scan()
2311 spin_lock_irqsave(&priv->irqlock, flags); in atmel_set_scan()
2313 priv->site_survey_state = SITE_SURVEY_IN_PROGRESS; in atmel_set_scan()
2314 priv->fast_scan = 0; in atmel_set_scan()
2316 spin_unlock_irqrestore(&priv->irqlock, flags); in atmel_set_scan()
2331 if (priv->site_survey_state != SITE_SURVEY_COMPLETED) in atmel_get_scan()
2332 return -EAGAIN; in atmel_get_scan()
2334 for (i = 0; i < priv->BSS_list_entries; i++) { in atmel_get_scan()
2337 memcpy(iwe.u.ap_addr.sa_data, priv->BSSinfo[i].BSSID, ETH_ALEN); in atmel_get_scan()
2342 iwe.u.data.length = priv->BSSinfo[i].SSIDsize; in atmel_get_scan()
2349 &iwe, priv->BSSinfo[i].SSID); in atmel_get_scan()
2352 iwe.u.mode = priv->BSSinfo[i].BSStype; in atmel_get_scan()
2358 iwe.u.freq.m = priv->BSSinfo[i].channel; in atmel_get_scan()
2366 iwe.u.qual.level = priv->BSSinfo[i].RSSI; in atmel_get_scan()
2375 if (priv->BSSinfo[i].UsingWEP) in atmel_get_scan()
2386 dwrq->length = (current_ev - extra); in atmel_get_scan()
2387 dwrq->flags = 0; in atmel_get_scan()
2401 dwrq->length = sizeof(struct iw_range); in atmel_get_range()
2403 range->min_nwid = 0x0000; in atmel_get_range()
2404 range->max_nwid = 0x0000; in atmel_get_range()
2405 range->num_channels = 0; in atmel_get_range()
2407 if (priv->reg_domain == channel_table[j].reg_domain) { in atmel_get_range()
2408 range->num_channels = channel_table[j].max - channel_table[j].min + 1; in atmel_get_range()
2411 if (range->num_channels != 0) { in atmel_get_range()
2413 range->freq[k].i = i; /* List index */ in atmel_get_range()
2415 /* Values in MHz -> * 10^5 * 10 */ in atmel_get_range()
2416 range->freq[k].m = 100000 * in atmel_get_range()
2418 range->freq[k++].e = 1; in atmel_get_range()
2420 range->num_frequency = k; in atmel_get_range()
2423 range->max_qual.qual = 100; in atmel_get_range()
2424 range->max_qual.level = 100; in atmel_get_range()
2425 range->max_qual.noise = 0; in atmel_get_range()
2426 range->max_qual.updated = IW_QUAL_NOISE_INVALID; in atmel_get_range()
2428 range->avg_qual.qual = 50; in atmel_get_range()
2429 range->avg_qual.level = 50; in atmel_get_range()
2430 range->avg_qual.noise = 0; in atmel_get_range()
2431 range->avg_qual.updated = IW_QUAL_NOISE_INVALID; in atmel_get_range()
2433 range->sensitivity = 0; in atmel_get_range()
2435 range->bitrate[0] = 1000000; in atmel_get_range()
2436 range->bitrate[1] = 2000000; in atmel_get_range()
2437 range->bitrate[2] = 5500000; in atmel_get_range()
2438 range->bitrate[3] = 11000000; in atmel_get_range()
2439 range->num_bitrates = 4; in atmel_get_range()
2441 range->min_rts = 0; in atmel_get_range()
2442 range->max_rts = 2347; in atmel_get_range()
2443 range->min_frag = 256; in atmel_get_range()
2444 range->max_frag = 2346; in atmel_get_range()
2446 range->encoding_size[0] = 5; in atmel_get_range()
2447 range->encoding_size[1] = 13; in atmel_get_range()
2448 range->num_encoding_sizes = 2; in atmel_get_range()
2449 range->max_encoding_tokens = 4; in atmel_get_range()
2451 range->pmp_flags = IW_POWER_ON; in atmel_get_range()
2452 range->pmt_flags = IW_POWER_ON; in atmel_get_range()
2453 range->pm_capa = 0; in atmel_get_range()
2455 range->we_version_source = WIRELESS_EXT; in atmel_get_range()
2456 range->we_version_compiled = WIRELESS_EXT; in atmel_get_range()
2457 range->retry_capa = IW_RETRY_LIMIT ; in atmel_get_range()
2458 range->retry_flags = IW_RETRY_LIMIT; in atmel_get_range()
2459 range->r_time_flags = 0; in atmel_get_range()
2460 range->min_retry = 1; in atmel_get_range()
2461 range->max_retry = 65535; in atmel_get_range()
2477 if (awrq->sa_family != ARPHRD_ETHER) in atmel_set_wap()
2478 return -EINVAL; in atmel_set_wap()
2480 if (!memcmp(any, awrq->sa_data, 6) || in atmel_set_wap()
2481 !memcmp(off, awrq->sa_data, 6)) { in atmel_set_wap()
2482 del_timer_sync(&priv->management_timer); in atmel_set_wap()
2483 spin_lock_irqsave(&priv->irqlock, flags); in atmel_set_wap()
2485 spin_unlock_irqrestore(&priv->irqlock, flags); in atmel_set_wap()
2489 for (i = 0; i < priv->BSS_list_entries; i++) { in atmel_set_wap()
2490 if (memcmp(priv->BSSinfo[i].BSSID, awrq->sa_data, 6) == 0) { in atmel_set_wap()
2491 if (!priv->wep_is_on && priv->BSSinfo[i].UsingWEP) { in atmel_set_wap()
2492 return -EINVAL; in atmel_set_wap()
2493 } else if (priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) { in atmel_set_wap()
2494 return -EINVAL; in atmel_set_wap()
2496 del_timer_sync(&priv->management_timer); in atmel_set_wap()
2497 spin_lock_irqsave(&priv->irqlock, flags); in atmel_set_wap()
2499 spin_unlock_irqrestore(&priv->irqlock, flags); in atmel_set_wap()
2505 return -EINVAL; in atmel_set_wap()
2536 (iw_handler) NULL, /* -- hole -- */
2537 (iw_handler) NULL, /* -- hole -- */
2540 (iw_handler) NULL, /* -- hole -- */
2548 (iw_handler) NULL, /* -- hole -- */
2549 (iw_handler) NULL, /* -- hole -- */
2564 (iw_handler) NULL, /* -- hole -- */
2565 (iw_handler) NULL, /* -- hole -- */
2634 wrq->u.param.value = ATMELMAGIC; in atmel_ioctl()
2638 if (copy_from_user(&com, rq->ifr_data, sizeof(com))) { in atmel_ioctl()
2639 rc = -EFAULT; in atmel_ioctl()
2644 rc = -EPERM; in atmel_ioctl()
2654 kfree(priv->firmware); in atmel_ioctl()
2656 priv->firmware = new_firmware; in atmel_ioctl()
2657 priv->firmware_length = com.len; in atmel_ioctl()
2658 strncpy(priv->firmware_id, com.id, 31); in atmel_ioctl()
2659 priv->firmware_id[31] = '\0'; in atmel_ioctl()
2663 if (copy_from_user(domain, rq->ifr_data, REGDOMAINSZ)) { in atmel_ioctl()
2664 rc = -EFAULT; in atmel_ioctl()
2669 rc = -EPERM; in atmel_ioctl()
2674 rc = -EINVAL; in atmel_ioctl()
2677 priv->config_reg_domain = channel_table[i].reg_domain; in atmel_ioctl()
2682 if (rc == 0 && priv->station_state != STATION_STATE_DOWN) in atmel_ioctl()
2687 rc = -EOPNOTSUPP; in atmel_ioctl()
2704 int old_state = priv->station_state; in atmel_enter_state()
2709 priv->station_state = new_state; in atmel_enter_state()
2712 netif_start_queue(priv->dev); in atmel_enter_state()
2713 netif_carrier_on(priv->dev); in atmel_enter_state()
2717 netif_carrier_off(priv->dev); in atmel_enter_state()
2718 if (netif_running(priv->dev)) in atmel_enter_state()
2719 netif_stop_queue(priv->dev); in atmel_enter_state()
2720 priv->last_beacon_timestamp = 0; in atmel_enter_state()
2740 if (priv->fast_scan) { in atmel_scan()
2741 cmd.SSID_size = priv->SSID_size; in atmel_scan()
2742 memcpy(cmd.SSID, priv->SSID, priv->SSID_size); in atmel_scan()
2746 priv->BSS_list_entries = 0; in atmel_scan()
2757 cmd.channel = (priv->channel & 0x7f); in atmel_scan()
2759 cmd.BSS_type = cpu_to_le16(priv->operating_mode == IW_MODE_ADHOC ? in atmel_scan()
2774 u8 BSS_type; /* this is a short in a scan command - weird */ in join()
2781 cmd.SSID_size = priv->SSID_size; in join()
2782 memcpy(cmd.SSID, priv->SSID, priv->SSID_size); in join()
2783 memcpy(cmd.BSSID, priv->CurrentBSSID, ETH_ALEN); in join()
2784 cmd.channel = (priv->channel & 0x7f); in join()
2802 cmd.SSID_size = priv->SSID_size; in start()
2803 memcpy(cmd.SSID, priv->SSID, priv->SSID_size); in start()
2804 memcpy(cmd.BSSID, priv->BSSID, ETH_ALEN); in start()
2806 cmd.channel = (priv->channel & 0x7f); in start()
2818 if (priv->preamble != new) { in handle_beacon_probe()
2819 priv->preamble = new; in handle_beacon_probe()
2824 if (priv->channel != channel) { in handle_beacon_probe()
2825 priv->channel = channel; in handle_beacon_probe()
2831 priv->station_is_associated = 0; in handle_beacon_probe()
2834 if (priv->operating_mode == IW_MODE_INFRA) in handle_beacon_probe()
2850 memcpy(header.addr1, priv->CurrentBSSID, ETH_ALEN); in send_authentication_request()
2851 memcpy(header.addr2, priv->dev->dev_addr, ETH_ALEN); in send_authentication_request()
2852 memcpy(header.addr3, priv->CurrentBSSID, ETH_ALEN); in send_authentication_request()
2854 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1) in send_authentication_request()
2861 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum); in send_authentication_request()
2862 priv->ExpectedAuthentTransactionSeqNum = priv->CurrentAuthentTransactionSeqNum+1; in send_authentication_request()
2863 priv->CurrentAuthentTransactionSeqNum += 2; in send_authentication_request()
2897 memcpy(header.addr1, priv->CurrentBSSID, ETH_ALEN); in send_association_request()
2898 memcpy(header.addr2, priv->dev->dev_addr, ETH_ALEN); in send_association_request()
2899 memcpy(header.addr3, priv->CurrentBSSID, ETH_ALEN); in send_association_request()
2902 if (priv->wep_is_on) in send_association_request()
2904 if (priv->preamble == SHORT_PREAMBLE) in send_association_request()
2907 body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period); in send_association_request()
2909 /* current AP address - only in reassoc frame */ in send_association_request()
2911 memcpy(body.ap, priv->CurrentBSSID, ETH_ALEN); in send_association_request()
2913 bodysize = 18 + priv->SSID_size; in send_association_request()
2916 bodysize = 12 + priv->SSID_size; in send_association_request()
2920 ssid_el_p[1] = priv->SSID_size; in send_association_request()
2921 memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size); in send_association_request()
2922 ssid_el_p[2 + priv->SSID_size] = WLAN_EID_SUPP_RATES; in send_association_request()
2923 ssid_el_p[3 + priv->SSID_size] = 4; /* len of supported rates */ in send_association_request()
2924 memcpy(ssid_el_p + 4 + priv->SSID_size, atmel_basic_rates, 4); in send_association_request()
2932 if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS) in is_frame_from_current_bss()
2933 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0; in is_frame_from_current_bss()
2935 return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0; in is_frame_from_current_bss()
2941 int max_rssi = -128; in retrieve_bss()
2942 int max_index = -1; in retrieve_bss()
2944 if (priv->BSS_list_entries == 0) in retrieve_bss()
2945 return -1; in retrieve_bss()
2947 if (priv->connect_to_any_BSS) { in retrieve_bss()
2948 /* Select a BSS with the max-RSSI but of the same type and of in retrieve_bss()
2952 priv->current_BSS = 0; in retrieve_bss()
2953 for (i = 0; i < priv->BSS_list_entries; i++) { in retrieve_bss()
2954 if (priv->operating_mode == priv->BSSinfo[i].BSStype && in retrieve_bss()
2955 ((!priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) || in retrieve_bss()
2956 (priv->wep_is_on && priv->BSSinfo[i].UsingWEP)) && in retrieve_bss()
2957 !(priv->BSSinfo[i].channel & 0x80)) { in retrieve_bss()
2958 max_rssi = priv->BSSinfo[i].RSSI; in retrieve_bss()
2959 priv->current_BSS = max_index = i; in retrieve_bss()
2965 for (i = 0; i < priv->BSS_list_entries; i++) { in retrieve_bss()
2966 if (priv->SSID_size == priv->BSSinfo[i].SSIDsize && in retrieve_bss()
2967 memcmp(priv->SSID, priv->BSSinfo[i].SSID, priv->SSID_size) == 0 && in retrieve_bss()
2968 priv->operating_mode == priv->BSSinfo[i].BSStype && in retrieve_bss()
2969 atmel_validate_channel(priv, priv->BSSinfo[i].channel) == 0) { in retrieve_bss()
2970 if (priv->BSSinfo[i].RSSI >= max_rssi) { in retrieve_bss()
2971 max_rssi = priv->BSSinfo[i].RSSI; in retrieve_bss()
2984 u8 *bss = capability & WLAN_CAPABILITY_ESS ? header->addr2 : header->addr3; in store_bss_info()
2985 int i, index; in store_bss_info() local
2987 for (index = -1, i = 0; i < priv->BSS_list_entries; i++) in store_bss_info()
2988 if (memcmp(bss, priv->BSSinfo[i].BSSID, ETH_ALEN) == 0) in store_bss_info()
2989 index = i; in store_bss_info()
2995 if (index == -1) { in store_bss_info()
2996 if (priv->BSS_list_entries == MAX_BSS_ENTRIES) in store_bss_info()
2998 index = priv->BSS_list_entries++; in store_bss_info()
2999 memcpy(priv->BSSinfo[index].BSSID, bss, ETH_ALEN); in store_bss_info()
3000 priv->BSSinfo[index].RSSI = rssi; in store_bss_info()
3002 if (rssi > priv->BSSinfo[index].RSSI) in store_bss_info()
3003 priv->BSSinfo[index].RSSI = rssi; in store_bss_info()
3008 priv->BSSinfo[index].channel = channel; in store_bss_info()
3009 priv->BSSinfo[index].beacon_period = beacon_period; in store_bss_info()
3010 priv->BSSinfo[index].UsingWEP = capability & WLAN_CAPABILITY_PRIVACY; in store_bss_info()
3011 memcpy(priv->BSSinfo[index].SSID, ssid, ssid_len); in store_bss_info()
3012 priv->BSSinfo[index].SSIDsize = ssid_len; in store_bss_info()
3015 priv->BSSinfo[index].BSStype = IW_MODE_ADHOC; in store_bss_info()
3017 priv->BSSinfo[index].BSStype = IW_MODE_INFRA; in store_bss_info()
3019 priv->BSSinfo[index].preamble = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ? in store_bss_info()
3025 struct auth_body *auth = (struct auth_body *)priv->rx_buf; in authenticate()
3026 u16 status = le16_to_cpu(auth->status); in authenticate()
3027 u16 trans_seq_no = le16_to_cpu(auth->trans_seq); in authenticate()
3028 u16 system = le16_to_cpu(auth->alg); in authenticate()
3030 if (status == WLAN_STATUS_SUCCESS && !priv->wep_is_on) { in authenticate()
3032 if (priv->station_was_associated) { in authenticate()
3043 if (status == WLAN_STATUS_SUCCESS && priv->wep_is_on) { in authenticate()
3046 if (trans_seq_no != priv->ExpectedAuthentTransactionSeqNum) in authenticate()
3055 auth->el_id == WLAN_EID_CHALLENGE) { in authenticate()
3056 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len); in authenticate()
3064 if (priv->station_was_associated) { in authenticate()
3081 priv->CurrentAuthentTransactionSeqNum = 0x001; in authenticate()
3082 priv->exclude_unencrypted = 1; in authenticate()
3086 && priv->wep_is_on) { in authenticate()
3087 priv->CurrentAuthentTransactionSeqNum = 0x001; in authenticate()
3088 priv->exclude_unencrypted = 0; in authenticate()
3091 } else if (priv->connect_to_any_BSS) { in authenticate()
3094 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; in authenticate()
3096 if ((bss_index = retrieve_bss(priv)) != -1) { in authenticate()
3103 priv->AuthenticationRequestRetryCnt = 0; in authenticate()
3105 priv->station_is_associated = 0; in authenticate()
3117 } *ass_resp = (struct ass_resp_format *)priv->rx_buf; in associate()
3119 u16 status = le16_to_cpu(ass_resp->status); in associate()
3120 u16 ass_id = le16_to_cpu(ass_resp->ass_id); in associate()
3121 u16 rates_len = ass_resp->length > 4 ? 4 : ass_resp->length; in associate()
3130 priv->AssociationRequestRetryCnt = 0; in associate()
3132 priv->ReAssociationRequestRetryCnt = 0; in associate()
3137 PHY_MIB_RATE_SET_POS, ass_resp->rates, rates_len); in associate()
3138 if (priv->power_mode == 0) { in associate()
3139 priv->listen_interval = 1; in associate()
3145 priv->listen_interval = 2; in associate()
3152 priv->station_is_associated = 1; in associate()
3153 priv->station_was_associated = 1; in associate()
3159 memcpy(wrqu.ap_addr.sa_data, priv->CurrentBSSID, ETH_ALEN); in associate()
3161 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); in associate()
3169 priv->AssociationRequestRetryCnt < MAX_ASSOCIATION_RETRIES) { in associate()
3170 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); in associate()
3171 priv->AssociationRequestRetryCnt++; in associate()
3179 priv->ReAssociationRequestRetryCnt < MAX_ASSOCIATION_RETRIES) { in associate()
3180 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); in associate()
3181 priv->ReAssociationRequestRetryCnt++; in associate()
3187 priv->station_is_associated = 0; in associate()
3189 if (priv->connect_to_any_BSS) { in associate()
3191 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; in associate()
3193 if ((bss_index = retrieve_bss(priv)) != -1) in associate()
3200 struct bss_info *bss = &priv->BSSinfo[bss_index]; in atmel_join_bss()
3202 memcpy(priv->CurrentBSSID, bss->BSSID, ETH_ALEN); in atmel_join_bss()
3203 memcpy(priv->SSID, bss->SSID, priv->SSID_size = bss->SSIDsize); in atmel_join_bss()
3206 if (priv->use_wpa) in atmel_join_bss()
3211 if (bss->BSStype == IW_MODE_ADHOC && in atmel_join_bss()
3212 priv->operating_mode != IW_MODE_ADHOC && in atmel_join_bss()
3213 priv->power_mode) { in atmel_join_bss()
3214 priv->power_mode = 0; in atmel_join_bss()
3215 priv->listen_interval = 1; in atmel_join_bss()
3222 priv->operating_mode = bss->BSStype; in atmel_join_bss()
3223 priv->channel = bss->channel & 0x7f; in atmel_join_bss()
3224 priv->beacon_period = bss->beacon_period; in atmel_join_bss()
3226 if (priv->preamble != bss->preamble) { in atmel_join_bss()
3227 priv->preamble = bss->preamble; in atmel_join_bss()
3229 LOCAL_MIB_PREAMBLE_TYPE, bss->preamble); in atmel_join_bss()
3232 if (!priv->wep_is_on && bss->UsingWEP) { in atmel_join_bss()
3234 priv->station_is_associated = 0; in atmel_join_bss()
3238 if (priv->wep_is_on && !bss->UsingWEP) { in atmel_join_bss()
3240 priv->station_is_associated = 0; in atmel_join_bss()
3246 if (priv->operating_mode == IW_MODE_INFRA) in atmel_join_bss()
3256 if (!priv->connect_to_any_BSS) { in restart_search()
3259 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; in restart_search()
3261 if ((bss_index = retrieve_bss(priv)) != -1) in restart_search()
3270 u8 old = priv->wstats.qual.level; in smooth_rssi()
3271 u8 max_rssi = 42; /* 502-rmfd-revd max by experiment, default for now */ in smooth_rssi()
3273 switch (priv->firmware_type) { in smooth_rssi()
3275 max_rssi = 63; /* 502-rmfd-reve max by experiment */ in smooth_rssi()
3283 priv->wstats.qual.level = (rssi + old) / 2 + 1; in smooth_rssi()
3285 priv->wstats.qual.level = (rssi + old) / 2; in smooth_rssi()
3286 priv->wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; in smooth_rssi()
3287 priv->wstats.qual.updated &= ~IW_QUAL_LEVEL_INVALID; in smooth_rssi()
3292 unsigned long time_diff = (jiffies - priv->last_qual) / HZ; in atmel_smooth_qual()
3293 while (time_diff--) { in atmel_smooth_qual()
3294 priv->last_qual += HZ; in atmel_smooth_qual()
3295 priv->wstats.qual.qual = priv->wstats.qual.qual / 2; in atmel_smooth_qual()
3296 priv->wstats.qual.qual += in atmel_smooth_qual()
3297 priv->beacons_this_sec * priv->beacon_period * (priv->wstats.qual.level + 100) / 4000; in atmel_smooth_qual()
3298 priv->beacons_this_sec = 0; in atmel_smooth_qual()
3300 priv->wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; in atmel_smooth_qual()
3301 priv->wstats.qual.updated &= ~IW_QUAL_QUAL_INVALID; in atmel_smooth_qual()
3311 subtype = le16_to_cpu(header->frame_control) & IEEE80211_FCTL_STYPE; in atmel_management_frame()
3316 /* beacon frame has multiple variable-length fields - in atmel_management_frame()
3332 } *beacon = (struct beacon_format *)priv->rx_buf; in atmel_management_frame()
3335 u64 timestamp = le64_to_cpu(beacon->timestamp); in atmel_management_frame()
3336 u16 beacon_interval = le16_to_cpu(beacon->interval); in atmel_management_frame()
3337 u16 capability = le16_to_cpu(beacon->capability); in atmel_management_frame()
3338 u8 *beaconp = priv->rx_buf; in atmel_management_frame()
3339 ssid_length = beacon->ssid_length; in atmel_management_frame()
3343 rates_length = beaconp[beacon->ssid_length + 15]; in atmel_management_frame()
3350 if (priv->station_state == STATION_STATE_READY) { in atmel_management_frame()
3353 priv->beacons_this_sec++; in atmel_management_frame()
3355 if (priv->last_beacon_timestamp) { in atmel_management_frame()
3356 /* Note truncate this to 32 bits - kernel can't divide a long */ in atmel_management_frame()
3357 u32 beacon_delay = timestamp - priv->last_beacon_timestamp; in atmel_management_frame()
3360 priv->wstats.miss.beacon += beacons - 1; in atmel_management_frame()
3362 priv->last_beacon_timestamp = timestamp; in atmel_management_frame()
3367 if (priv->station_state == STATION_STATE_SCANNING) in atmel_management_frame()
3371 &beacon->rates_el_id, in atmel_management_frame()
3378 if (priv->station_state == STATION_STATE_AUTHENTICATING) in atmel_management_frame()
3386 if (priv->station_state == STATION_STATE_ASSOCIATING || in atmel_management_frame()
3387 priv->station_state == STATION_STATE_REASSOCIATING) in atmel_management_frame()
3393 if (priv->station_is_associated && in atmel_management_frame()
3394 priv->operating_mode == IW_MODE_INFRA && in atmel_management_frame()
3396 priv->station_was_associated = 0; in atmel_management_frame()
3397 priv->station_is_associated = 0; in atmel_management_frame()
3406 if (priv->operating_mode == IW_MODE_INFRA && in atmel_management_frame()
3408 priv->station_was_associated = 0; in atmel_management_frame()
3425 if (priv->card && priv->present_callback && in atmel_management_timer()
3426 !(*priv->present_callback)(priv->card)) in atmel_management_timer()
3429 spin_lock_irqsave(&priv->irqlock, flags); in atmel_management_timer()
3431 switch (priv->station_state) { in atmel_management_timer()
3434 if (priv->AuthenticationRequestRetryCnt >= MAX_AUTHENTICATION_RETRIES) { in atmel_management_timer()
3436 priv->station_is_associated = 0; in atmel_management_timer()
3437 priv->AuthenticationRequestRetryCnt = 0; in atmel_management_timer()
3441 priv->AuthenticationRequestRetryCnt++; in atmel_management_timer()
3442 priv->CurrentAuthentTransactionSeqNum = 0x0001; in atmel_management_timer()
3443 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); in atmel_management_timer()
3444 if (priv->wep_is_on && priv->exclude_unencrypted) in atmel_management_timer()
3451 if (priv->AssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { in atmel_management_timer()
3453 priv->station_is_associated = 0; in atmel_management_timer()
3454 priv->AssociationRequestRetryCnt = 0; in atmel_management_timer()
3457 priv->AssociationRequestRetryCnt++; in atmel_management_timer()
3458 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); in atmel_management_timer()
3464 if (priv->ReAssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { in atmel_management_timer()
3466 priv->station_is_associated = 0; in atmel_management_timer()
3467 priv->ReAssociationRequestRetryCnt = 0; in atmel_management_timer()
3470 priv->ReAssociationRequestRetryCnt++; in atmel_management_timer()
3471 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); in atmel_management_timer()
3480 spin_unlock_irqrestore(&priv->irqlock, flags); in atmel_management_timer()
3497 priv->station_was_associated = priv->station_is_associated; in atmel_command_irq()
3499 (u8 *)priv->CurrentBSSID, 6); in atmel_command_irq()
3505 fast_scan = priv->fast_scan; in atmel_command_irq()
3506 priv->fast_scan = 0; in atmel_command_irq()
3513 if (bss_index != -1) { in atmel_command_irq()
3515 } else if (priv->operating_mode == IW_MODE_ADHOC && in atmel_command_irq()
3516 priv->SSID_size != 0) { in atmel_command_irq()
3519 priv->fast_scan = !fast_scan; in atmel_command_irq()
3523 priv->site_survey_state = SITE_SURVEY_COMPLETED; in atmel_command_irq()
3527 wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); in atmel_command_irq()
3533 priv->fast_scan = 0; in atmel_command_irq()
3538 priv->site_survey_state = SITE_SURVEY_COMPLETED; in atmel_command_irq()
3539 if (priv->station_is_associated) { in atmel_command_irq()
3543 wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); in atmel_command_irq()
3551 if (priv->operating_mode == IW_MODE_ADHOC) { in atmel_command_irq()
3552 priv->station_was_associated = priv->station_is_associated; in atmel_command_irq()
3556 priv->AuthenticationRequestRetryCnt = 0; in atmel_command_irq()
3559 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); in atmel_command_irq()
3560 priv->CurrentAuthentTransactionSeqNum = 0x0001; in atmel_command_irq()
3561 if (priv->wep_is_on && priv->exclude_unencrypted) in atmel_command_irq()
3574 struct host_info_struct *iface = &priv->host_info; in atmel_wakeup_firmware()
3578 if (priv->card_type == CARD_TYPE_SPI_FLASH) in atmel_wakeup_firmware()
3579 atmel_set_gcr(priv->dev, GCR_REMAP); in atmel_wakeup_firmware()
3581 /* wake up on-board processor */ in atmel_wakeup_firmware()
3582 atmel_clear_gcr(priv->dev, 0x0040); in atmel_wakeup_firmware()
3583 atmel_write16(priv->dev, BSR, BSS_SRAM); in atmel_wakeup_firmware()
3585 if (priv->card_type == CARD_TYPE_SPI_FLASH) in atmel_wakeup_firmware()
3589 for (i = LOOP_RETRY_LIMIT; i; i--) { in atmel_wakeup_firmware()
3590 mr1 = atmel_read16(priv->dev, MR1); in atmel_wakeup_firmware()
3591 mr3 = atmel_read16(priv->dev, MR3); in atmel_wakeup_firmware()
3596 priv->bus_type == BUS_TYPE_PCCARD) in atmel_wakeup_firmware()
3601 printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name); in atmel_wakeup_firmware()
3602 return -EIO; in atmel_wakeup_firmware()
3605 if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) { in atmel_wakeup_firmware()
3606 printk(KERN_ALERT "%s: card missing.\n", priv->dev->name); in atmel_wakeup_firmware()
3607 return -ENODEV; in atmel_wakeup_firmware()
3617 for (i = LOOP_RETRY_LIMIT; i; i--) { in atmel_wakeup_firmware()
3618 mr1 = atmel_read16(priv->dev, MR1); in atmel_wakeup_firmware()
3619 mr3 = atmel_read16(priv->dev, MR3); in atmel_wakeup_firmware()
3624 priv->bus_type == BUS_TYPE_PCCARD) in atmel_wakeup_firmware()
3630 priv->dev->name); in atmel_wakeup_firmware()
3631 return -EIO; in atmel_wakeup_firmware()
3636 !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) { in atmel_wakeup_firmware()
3637 printk(KERN_ALERT "%s: MAC failed MR3 self-test.\n", priv->dev->name); in atmel_wakeup_firmware()
3638 return -EIO; in atmel_wakeup_firmware()
3641 !(atmel_read16(priv->dev, MR1) & MAC_INIT_OK)) { in atmel_wakeup_firmware()
3642 printk(KERN_ALERT "%s: MAC failed MR1 self-test.\n", priv->dev->name); in atmel_wakeup_firmware()
3643 return -EIO; in atmel_wakeup_firmware()
3646 atmel_copy_to_host(priv->dev, (unsigned char *)iface, in atmel_wakeup_firmware()
3647 priv->host_info_base, sizeof(*iface)); in atmel_wakeup_firmware()
3649 iface->tx_buff_pos = le16_to_cpu(iface->tx_buff_pos); in atmel_wakeup_firmware()
3650 iface->tx_buff_size = le16_to_cpu(iface->tx_buff_size); in atmel_wakeup_firmware()
3651 iface->tx_desc_pos = le16_to_cpu(iface->tx_desc_pos); in atmel_wakeup_firmware()
3652 iface->tx_desc_count = le16_to_cpu(iface->tx_desc_count); in atmel_wakeup_firmware()
3653 iface->rx_buff_pos = le16_to_cpu(iface->rx_buff_pos); in atmel_wakeup_firmware()
3654 iface->rx_buff_size = le16_to_cpu(iface->rx_buff_size); in atmel_wakeup_firmware()
3655 iface->rx_desc_pos = le16_to_cpu(iface->rx_desc_pos); in atmel_wakeup_firmware()
3656 iface->rx_desc_count = le16_to_cpu(iface->rx_desc_count); in atmel_wakeup_firmware()
3657 iface->build_version = le16_to_cpu(iface->build_version); in atmel_wakeup_firmware()
3658 iface->command_pos = le16_to_cpu(iface->command_pos); in atmel_wakeup_firmware()
3659 iface->major_version = le16_to_cpu(iface->major_version); in atmel_wakeup_firmware()
3660 iface->minor_version = le16_to_cpu(iface->minor_version); in atmel_wakeup_firmware()
3661 iface->func_ctrl = le16_to_cpu(iface->func_ctrl); in atmel_wakeup_firmware()
3662 iface->mac_status = le16_to_cpu(iface->mac_status); in atmel_wakeup_firmware()
3675 if (priv->bus_type == BUS_TYPE_PCCARD) in probe_atmel_card()
3685 priv->card_type = CARD_TYPE_EEPROM; in probe_atmel_card()
3689 atmel_clear_gcr(priv->dev, 0x0040); in probe_atmel_card()
3691 for (i = LOOP_RETRY_LIMIT; i; i--) in probe_atmel_card()
3695 printk(KERN_ALERT "%s: MAC failed to boot MAC address reader.\n", dev->name); in probe_atmel_card()
3702 if (priv->bus_type == BUS_TYPE_PCCARD) in probe_atmel_card()
3709 priv->card_type = CARD_TYPE_PARALLEL_FLASH; in probe_atmel_card()
3718 priv->card_type = CARD_TYPE_SPI_FLASH; in probe_atmel_card()
3725 if (priv->bus_type == BUS_TYPE_PCCARD) in probe_atmel_card()
3733 if (dev->dev_addr[0] == 0xFF) { in probe_atmel_card()
3737 printk(KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n", dev->name); in probe_atmel_card()
3746 This routine is for the pre-WPA firmware: later firmware has
3765 mib.wep_is_on = priv->wep_is_on; in build_wep_mib()
3766 if (priv->wep_is_on) { in build_wep_mib()
3767 if (priv->wep_key_len[priv->default_key] > 5) in build_wep_mib()
3775 mib.default_key = priv->default_key; in build_wep_mib()
3776 mib.exclude_unencrypted = priv->exclude_unencrypted; in build_wep_mib()
3779 memcpy(mib.wep_keys[i], priv->wep_keys[i], 13); in build_wep_mib()
3806 mib.wep_is_on = priv->wep_is_on; in build_wpa_mib()
3807 mib.exclude_unencrypted = priv->exclude_unencrypted; in build_wpa_mib()
3808 memcpy(mib.receiver_address, priv->CurrentBSSID, ETH_ALEN); in build_wpa_mib()
3813 if (priv->wep_is_on) { in build_wpa_mib()
3821 if (priv->wep_key_len[i] > 0) { in build_wpa_mib()
3822 memcpy(mib.cipher_default_key_value[i], priv->wep_keys[i], MAX_ENCRYPTION_KEY_SIZE); in build_wpa_mib()
3823 if (i == priv->default_key) { in build_wpa_mib()
3825 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 7; in build_wpa_mib()
3826 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->pairwise_cipher_suite; in build_wpa_mib()
3829 priv->group_cipher_suite = priv->pairwise_cipher_suite; in build_wpa_mib()
3830 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 1; in build_wpa_mib()
3831 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->group_cipher_suite; in build_wpa_mib()
3852 can be altered on the fly, but many (WEP, infrastructure or ad-hoc) in reset_atmel_card()
3857 hardware-specific fields in the atmel_private structure, in reset_atmel_card()
3863 int old_state = priv->station_state; in reset_atmel_card()
3870 "-wpa", in reset_atmel_card()
3876 if (priv->bus_type == BUS_TYPE_PCCARD) in reset_atmel_card()
3877 atmel_write16(priv->dev, GCR, 0x0060); in reset_atmel_card()
3880 atmel_write16(priv->dev, GCR, 0x0040); in reset_atmel_card()
3882 if (priv->card_type == CARD_TYPE_EEPROM) { in reset_atmel_card()
3886 int len = priv->firmware_length; in reset_atmel_card()
3887 if (!(fw = priv->firmware)) { in reset_atmel_card()
3888 if (priv->firmware_type == ATMEL_FW_TYPE_NONE) { in reset_atmel_card()
3889 if (strlen(priv->firmware_id) == 0) { in reset_atmel_card()
3892 dev->name); in reset_atmel_card()
3895 dev->name); in reset_atmel_card()
3896 strcpy(priv->firmware_id, "atmel_at76c502.bin"); in reset_atmel_card()
3898 err = request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev); in reset_atmel_card()
3902 dev->name, priv->firmware_id); in reset_atmel_card()
3910 while (fw_table[fw_index].fw_type != priv->firmware_type in reset_atmel_card()
3918 snprintf(priv->firmware_id, 32, "%s%s.%s", fw_table[fw_index].fw_file, in reset_atmel_card()
3920 priv->firmware_id[31] = '\0'; in reset_atmel_card()
3921 if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) == 0) { in reset_atmel_card()
3930 dev->name, priv->firmware_id); in reset_atmel_card()
3931 priv->firmware_id[0] = '\0'; in reset_atmel_card()
3932 return -ENOENT; in reset_atmel_card()
3936 fw = fw_entry->data; in reset_atmel_card()
3937 len = fw_entry->size; in reset_atmel_card()
3941 atmel_write16(priv->dev, BSR, BSS_IRAM); in reset_atmel_card()
3942 atmel_copy_to_card(priv->dev, 0, fw, len); in reset_atmel_card()
3943 atmel_set_gcr(priv->dev, GCR_REMAP); in reset_atmel_card()
3946 atmel_set_gcr(priv->dev, GCR_REMAP); in reset_atmel_card()
3947 atmel_write16(priv->dev, BSR, BSS_IRAM); in reset_atmel_card()
3948 atmel_copy_to_card(priv->dev, 0, fw, 0x6000); in reset_atmel_card()
3949 atmel_write16(priv->dev, BSR, 0x2ff); in reset_atmel_card()
3950 atmel_copy_to_card(priv->dev, 0x8000, &fw[0x6000], len - 0x6000); in reset_atmel_card()
3962 The pre-wpa 3com firmware reports major version 5, in reset_atmel_card()
3964 the 3com broken-ness filter. */ in reset_atmel_card()
3965 priv->use_wpa = (priv->host_info.major_version == 4); in reset_atmel_card()
3966 priv->radio_on_broken = (priv->host_info.major_version == 5); in reset_atmel_card()
3977 priv->tx_desc_free = priv->host_info.tx_desc_count; in reset_atmel_card()
3978 priv->tx_desc_head = 0; in reset_atmel_card()
3979 priv->tx_desc_tail = 0; in reset_atmel_card()
3980 priv->tx_desc_previous = 0; in reset_atmel_card()
3981 priv->tx_free_mem = priv->host_info.tx_buff_size; in reset_atmel_card()
3982 priv->tx_buff_head = 0; in reset_atmel_card()
3983 priv->tx_buff_tail = 0; in reset_atmel_card()
3990 priv->rx_desc_head = 0; in reset_atmel_card()
3996 if (!priv->radio_on_broken) { in reset_atmel_card()
4000 dev->name); in reset_atmel_card()
4001 return -EIO; in reset_atmel_card()
4006 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_AUTO_TX_RATE_POS, priv->auto_tx_rate); in reset_atmel_card()
4008 atmel_set_mib16(priv, Mac_Mib_Type, MAC_MIB_RTS_THRESHOLD_POS, priv->rts_threshold); in reset_atmel_card()
4009 atmel_set_mib16(priv, Mac_Mib_Type, MAC_MIB_FRAG_THRESHOLD_POS, priv->frag_threshold); in reset_atmel_card()
4010 atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_SHORT_RETRY_POS, priv->short_retry); in reset_atmel_card()
4011 atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_LONG_RETRY_POS, priv->long_retry); in reset_atmel_card()
4012 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, priv->preamble); in reset_atmel_card()
4014 priv->dev->dev_addr, 6); in reset_atmel_card()
4017 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_BEACON_PER_POS, priv->default_beacon_period); in reset_atmel_card()
4019 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_PRIVACY_POS, priv->wep_is_on); in reset_atmel_card()
4020 if (priv->use_wpa) in reset_atmel_card()
4032 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); in reset_atmel_card()
4042 atmel_copy_to_card(priv->dev, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET), in atmel_send_command()
4056 for (i = 5000; i; i--) { in atmel_send_command_wait()
4065 printk(KERN_ALERT "%s: failed to contact MAC.\n", priv->dev->name); in atmel_send_command_wait()
4075 static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index) in atmel_get_mib8() argument
4080 m.index = index; in atmel_get_mib8()
4086 static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, u8 data) in atmel_set_mib8() argument
4091 m.index = index; in atmel_set_mib8()
4097 static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, in atmel_set_mib16() argument
4103 m.index = index; in atmel_set_mib16()
4110 static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, in atmel_set_mib() argument
4116 m.index = index; in atmel_set_mib()
4119 printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name); in atmel_set_mib()
4125 static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, in atmel_get_mib() argument
4131 m.index = index; in atmel_get_mib()
4134 printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name); in atmel_get_mib()
4137 atmel_copy_to_host(priv->dev, data, in atmel_get_mib()
4144 outw(data, dev->base_addr + AR); in atmel_writeAR()
4146 for (i = 0; data != inw(dev->base_addr + AR) && i < 10; i++) in atmel_writeAR()
4147 outw(data, dev->base_addr + AR); in atmel_writeAR()
4157 src++; len--; in atmel_copy_to_card()
4159 for (i = len; i > 1 ; i -= 2) { in atmel_copy_to_card()
4175 dest++; len--; in atmel_copy_to_host()
4177 for (i = len; i > 1 ; i -= 2) { in atmel_copy_to_host()
4188 outw(inw(dev->base_addr + GCR) | mask, dev->base_addr + GCR); in atmel_set_gcr()
4193 outw(inw(dev->base_addr + GCR) & ~mask, dev->base_addr + GCR); in atmel_clear_gcr()
4200 for (i = 5000; i; i--) { in atmel_lock_mac()
4212 if (!j--) in atmel_lock_mac()
4222 atmel_writeAR(priv->dev, pos); in atmel_wmem32()
4223 atmel_write16(priv->dev, DR, data); /* card is little-endian */ in atmel_wmem32()
4224 atmel_write16(priv->dev, DR, data >> 16); in atmel_wmem32()
4265 .set CPSR_INITIAL, 0xD3 /* IRQ/FIQ disabled, ARM mode, Supervisor state */
4266 .set CPSR_USER, 0xD1 /* IRQ/FIQ disabled, ARM mode, USER state */
4274 .set SP_TDRE, 2 /* status register bit -- TDR empty */
4275 .set SP_RDRF, 1 /* status register bit -- RDR full */
4505 …ldr r0, [r4, #SP_RDR] /* what's this byte? It's the byte read while writing the TDR -- nonsense, …