136 #include <linux/compiler.h>
137 #include <linux/errno.h>
138 #include <linux/if_arp.h>
139 #include <linux/in6.h>
140 #include <linux/in.h>
141 #include <linux/ip.h>
142 #include <linux/kernel.h>
144 #include <linux/module.h>
145 #include <linux/netdevice.h>
146 #include <linux/ethtool.h>
147 #include <linux/pci.h>
151 #include <asm/uaccess.h>
153 #include <linux/fs.h>
155 #include <linux/slab.h>
158 #include <linux/tcp.h>
159 #include <linux/types.h>
160 #include <linux/time.h>
163 #include <linux/ctype.h>
171 #define IPW2100_VERSION "git-1.2.2"
173 #define DRV_NAME "ipw2100"
174 #define DRV_VERSION IPW2100_VERSION
175 #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2100 Network Driver"
176 #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
181 #ifdef CONFIG_IPW2100_DEBUG
182 #define IPW2100_RX_DEBUG
190 static int debug = 0;
191 static int network_mode = 0;
193 static int associate = 0;
214 #ifdef CONFIG_IPW2100_DEBUG
215 #define IPW_DEBUG(level, message...) \
217 if (ipw2100_debug_level & (level)) { \
218 printk(KERN_DEBUG "ipw2100: %c %s ", \
219 in_interrupt() ? 'I' : 'U', __func__); \
224 #define IPW_DEBUG(level, message...) do {} while (0)
227 #ifdef CONFIG_IPW2100_DEBUG
228 static const char *command_types[] = {
239 "AUTHENTICATION_TYPE",
242 "INTERNATIONAL_MODE",
257 "CLEAR_ALL_MULTICAST",
278 "AP_OR_STATION_TABLE",
287 "HOST_PRE_POWER_DOWN",
290 "CARD_DISABLE_PHY_OFF",
293 "SET_STATION_STAT_BITS",
294 "CLEAR_STATIONS_STAT_BITS",
296 "SET_SECURITY_INFORMATION",
297 "DISASSOCIATION_BSSID",
302 static const long ipw2100_frequencies[] = {
303 2412, 2417, 2422, 2427,
304 2432, 2437, 2442, 2447,
305 2452, 2457, 2462, 2467,
309 #define FREQ_COUNT ARRAY_SIZE(ipw2100_frequencies)
318 #define RATE_COUNT ARRAY_SIZE(ipw2100_bg_rates)
456 aligned_addr = addr & (~0x3);
457 dif_len = addr - aligned_addr;
462 for (i = dif_len; i < 4; i++, buf++)
463 write_register_byte(dev,
473 aligned_len = len & (~0x3);
474 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
478 dif_len = len - aligned_len;
480 for (i = 0; i < dif_len; i++, buf++)
494 aligned_addr = addr & (~0x3);
495 dif_len = addr - aligned_addr;
500 for (i = dif_len; i < 4; i++, buf++)
501 read_register_byte(dev,
511 aligned_len = len & (~0x3);
512 for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4)
516 dif_len = len - aligned_len;
518 for (i = 0; i < dif_len; i++, buf++)
522 static bool ipw2100_hw_is_adapter_in_system(
struct net_device *dev)
543 "before they have been loaded.\n");
552 ": ordinal buffer length too small, need %zd\n",
560 read_nic_dword(priv->
net_dev, addr, val);
582 field_len = *((
u16 *) & field_info);
585 field_count = *(((
u16 *) & field_info) + 1);
588 total_length = field_len * field_count;
589 if (total_length > *len) {
599 read_nic_memory(priv->
net_dev, addr, total_length, val);
605 "in table 2\n", ord);
626 write_nic_dword(priv->
net_dev, addr, *val);
640 static char *snprint_line(
char *buf,
size_t count,
646 out =
snprintf(buf, count,
"%08X", ofs);
648 for (l = 0, i = 0; i < 2; i++) {
649 out +=
snprintf(buf + out, count - out,
" ");
650 for (j = 0; j < 8 && l < len; j++, l++)
651 out +=
snprintf(buf + out, count - out,
"%02X ",
654 out +=
snprintf(buf + out, count - out,
" ");
657 out +=
snprintf(buf + out, count - out,
" ");
658 for (l = 0, i = 0; i < 2; i++) {
659 out +=
snprintf(buf + out, count - out,
" ");
660 for (j = 0; j < 8 && l < len; j++, l++) {
661 c = data[(i * 8 +
j)];
665 out +=
snprintf(buf + out, count - out,
"%c", c);
669 out +=
snprintf(buf + out, count - out,
" ");
675 static void printk_buf(
int level,
const u8 * data,
u32 len)
679 if (!(ipw2100_debug_level & level))
684 snprint_line(line,
sizeof(line), &data[ofs],
685 min(len, 16
U), ofs));
687 len -=
min(len, 16
U);
691 #define MAX_RESET_BACKOFF 10
710 netif_stop_queue(priv->
net_dev);
728 #define HOST_COMPLETE_TIMEOUT (2 * HZ)
729 static int ipw2100_hw_send_command(
struct ipw2100_priv *priv,
747 (
"Attempt to send command while hardware in fatal error condition.\n");
754 (
"Attempt to send command while hardware is not running.\n");
761 (
"Attempt to send command while another command is pending.\n");
788 sizeof(packet->
info.
c_struct.cmd->host_command_params_reg));
796 ipw2100_tx_send_commands(priv);
797 ipw2100_tx_send_data(priv);
799 spin_unlock_irqrestore(&priv->
low_lock, flags);
817 priv->
status &= ~STATUS_CMD_ACTIVE;
818 schedule_reset(priv);
838 spin_unlock_irqrestore(&priv->
low_lock, flags);
852 u32 val1 = 0x76543210;
853 u32 val2 = 0xFEDCBA98;
858 read_register(priv->
net_dev, address, &data1);
864 for (address = 0; address < 5; address++) {
874 if (val1 == data1 && val2 == data2)
890 #define IPW_CARD_DISABLE_COMPLETE_WAIT 100 // 100 milli
910 if ((card_state == state) ||
924 IPW_DEBUG_INFO(
"ipw2100_wait_for_card_state to %s state timed out\n",
925 state ?
"DISABLED" :
"ENABLED");
934 static int sw_reset_and_clock(
struct ipw2100_priv *priv)
944 for (i = 0; i < 1000; i++) {
962 for (i = 0; i < 10000; i++) {
993 static int ipw2100_download_firmware(
struct ipw2100_priv *priv)
1005 "fatal error %d. Interface must be brought down.\n",
1010 if (!ipw2100_firmware.version) {
1011 err = ipw2100_get_firmware(priv, &ipw2100_firmware);
1020 err = ipw2100_get_firmware(priv, &ipw2100_firmware);
1031 err = sw_reset_and_clock(priv);
1038 err = ipw2100_verify(priv);
1046 write_nic_dword(priv->
net_dev,
1053 err = ipw2100_ucode_download(priv, &ipw2100_firmware);
1061 write_nic_dword(priv->
net_dev,
1065 err = sw_reset_and_clock(priv);
1068 ": %s: sw_reset_and_clock failed: %d\n",
1074 err = ipw2100_fw_download(priv, &ipw2100_firmware);
1089 ipw2100_release_firmware(priv, &ipw2100_firmware);
1095 write_nic_dword(priv->
net_dev, address, 0);
1098 write_nic_dword(priv->
net_dev, address, 0);
1101 write_nic_dword(priv->
net_dev, address, 0);
1104 write_nic_dword(priv->
net_dev, address, 0);
1107 write_nic_dword(priv->
net_dev, address, 0);
1112 ipw2100_release_firmware(priv, &ipw2100_firmware);
1116 static inline void ipw2100_enable_interrupts(
struct ipw2100_priv *priv)
1124 static inline void ipw2100_disable_interrupts(
struct ipw2100_priv *priv)
1132 static void ipw2100_initialize_ordinals(
struct ipw2100_priv *priv)
1154 static inline void ipw2100_hw_set_gpio(
struct ipw2100_priv *priv)
1168 #define MAX_RF_KILL_CHECKS 5
1169 #define RF_KILL_CHECK_DELAY 40
1171 unsigned short value = 0;
1182 udelay(RF_KILL_CHECK_DELAY);
1195 return (value == 0);
1198 static int ipw2100_get_hw_features(
struct ipw2100_priv *priv)
1207 if (ipw2100_get_ordinal
1219 read_nic_dword(priv->
net_dev, addr + 0xFC, &val);
1230 read_nic_dword(priv->
net_dev, addr + 0x20, &val);
1231 if (!((val >> 24) & 0x01))
1246 static int ipw2100_start_adapter(
struct ipw2100_priv *priv)
1261 if (ipw2100_download_firmware(priv)) {
1263 ": %s: Failed to power on the adapter.\n",
1270 ipw2100_queues_initialize(priv);
1272 ipw2100_hw_set_gpio(priv);
1281 IPW_DEBUG_FW(
"Waiting for f/w initialization to complete...\n");
1293 IPW2100_INTA_FW_INIT_DONE);
1315 if (inta & inta_mask)
1319 i ?
"SUCCESS" :
"FAILED");
1323 ": %s: Firmware did not initialize.\n",
1346 static inline void ipw2100_reset_fatalerror(
struct ipw2100_priv *priv)
1357 static int ipw2100_power_cycle_adapter(
struct ipw2100_priv *priv)
1364 ipw2100_hw_set_gpio(priv);
1385 (
"exit - waited too long for master assert stop\n");
1393 ipw2100_reset_fatalerror(priv);
1410 static int ipw2100_hw_phy_off(
struct ipw2100_priv *priv)
1413 #define HW_PHY_OFF_LOOP_DELAY (HZ / 5000)
1417 .host_command_sequence = 0,
1418 .host_command_length = 0,
1426 err = ipw2100_hw_send_command(priv, &cmd);
1430 for (i = 0; i < 2500; i++) {
1444 static int ipw2100_enable_adapter(
struct ipw2100_priv *priv)
1448 .host_command_sequence = 0,
1449 .host_command_length = 0
1460 if (rf_kill_active(priv)) {
1461 IPW_DEBUG_HC(
"Command aborted due to RF kill active.\n");
1465 err = ipw2100_hw_send_command(priv, &cmd);
1488 static int ipw2100_hw_stop_adapter(
struct ipw2100_priv *priv)
1490 #define HW_POWER_DOWN_DELAY (msecs_to_jiffies(100))
1494 .host_command_sequence = 0,
1495 .host_command_length = 0,
1511 ipw2100_enable_adapter(priv);
1513 err = ipw2100_hw_phy_off(priv);
1516 ": Error disabling radio %d\n", err);
1540 err = ipw2100_hw_send_command(priv, &cmd);
1543 "%s: Power down command failed: Error %d\n",
1555 ipw2100_hw_set_gpio(priv);
1570 for (i = 5; i > 0; i--) {
1582 ": %s: Could now power down adapter.\n",
1594 static int ipw2100_disable_adapter(
struct ipw2100_priv *priv)
1598 .host_command_sequence = 0,
1599 .host_command_length = 0
1618 err = ipw2100_hw_send_command(priv, &cmd);
1621 ": exit - failed to send CARD_DISABLE command\n");
1628 ": exit - card failed to change to DISABLED\n");
1639 static int ipw2100_set_scan_options(
struct ipw2100_priv *priv)
1643 .host_command_sequence = 0,
1644 .host_command_length = 8
1663 err = ipw2100_hw_send_command(priv, &cmd);
1671 static int ipw2100_start_scan(
struct ipw2100_priv *priv)
1675 .host_command_sequence = 0,
1676 .host_command_length = 4
1703 err = ipw2100_hw_send_command(priv, &cmd);
1712 static const struct libipw_geo ipw_geos[] = {
1716 .bg = {{2412, 1}, {2417, 2}, {2422, 3},
1717 {2427, 4}, {2432, 5}, {2437, 6},
1718 {2442, 7}, {2447, 8}, {2452, 9},
1719 {2457, 10}, {2462, 11}, {2467, 12},
1720 {2472, 13}, {2484, 14}},
1724 static int ipw2100_up(
struct ipw2100_priv *priv,
int deferred)
1726 unsigned long flags;
1729 u32 ord_len =
sizeof(lock);
1740 "switch\n", priv->
net_dev->name);
1751 ipw2100_disable_interrupts(priv);
1754 ipw2100_reset_fatalerror(priv);
1755 spin_unlock_irqrestore(&priv->
low_lock, flags);
1760 if (ipw2100_power_cycle_adapter(priv)) {
1762 ": %s: Could not cycle adapter.\n",
1771 if (ipw2100_start_adapter(priv)) {
1773 ": %s: Failed to start the firmware.\n",
1779 ipw2100_initialize_ordinals(priv);
1782 if (ipw2100_get_hw_features(priv)) {
1784 ": %s: Failed to determine HW features.\n",
1800 ": %s: Failed to clear ordinal lock.\n",
1808 if (rf_kill_active(priv)) {
1822 ipw2100_enable_interrupts(priv);
1826 if (ipw2100_adapter_setup(priv)) {
1835 if (ipw2100_enable_adapter(priv)) {
1837 "%s: failed in call to enable adapter.\n",
1839 ipw2100_hw_stop_adapter(priv);
1845 ipw2100_set_scan_options(priv);
1846 ipw2100_start_scan(priv);
1855 unsigned long flags;
1881 ipw2100_enable_interrupts(priv);
1882 spin_unlock_irqrestore(&priv->
low_lock, flags);
1884 if (ipw2100_hw_stop_adapter(priv))
1892 ipw2100_disable_interrupts(priv);
1893 spin_unlock_irqrestore(&priv->
low_lock, flags);
1903 netif_stop_queue(priv->
net_dev);
1906 static int ipw2100_wdev_init(
struct net_device *dev)
1948 bg_band->
bitrates = ipw2100_bg_rates;
1954 wdev->
wiphy->cipher_suites = ipw_cipher_suites;
1967 unsigned long flags;
1984 spin_unlock_irqrestore(&priv->
low_lock, flags);
1995 ipw2100_up(priv, 0);
2003 #define MAC_ASSOCIATION_READ_DELAY (HZ)
2005 unsigned int len, essid_len;
2056 txratename =
"1Mbps";
2059 txratename =
"2Mbsp";
2062 txratename =
"5.5Mbps";
2065 txratename =
"11Mbps";
2069 txratename =
"unknown rate";
2073 IPW_DEBUG_INFO(
"%s: Associated with '%s' at %s, channel %d (BSSID=%pM)\n",
2075 txratename, chan, bssid);
2091 static int ipw2100_set_essid(
struct ipw2100_priv *priv,
char *essid,
2092 int length,
int batch_mode)
2097 .host_command_sequence = 0,
2098 .host_command_length = ssid_len
2109 err = ipw2100_disable_adapter(priv);
2120 bogus[i] = 0x18 + i;
2127 err = ipw2100_hw_send_command(priv, &cmd);
2135 if (ipw2100_enable_adapter(priv))
2142 static void isr_indicate_association_lost(
struct ipw2100_priv *priv,
u32 status)
2147 "disassociated: '%s' %pM\n",
2162 netif_stop_queue(priv->
net_dev);
2173 static void isr_indicate_rf_kill(
struct ipw2100_priv *priv,
u32 status)
2187 static void send_scan_event(
void *data)
2192 wrqu.
data.length = 0;
2193 wrqu.
data.flags = 0;
2197 static void ipw2100_scan_event_later(
struct work_struct *work)
2200 scan_event_later.work));
2203 static void ipw2100_scan_event_now(
struct work_struct *work)
2213 priv->
ieee->scans++;
2228 #ifdef CONFIG_IPW2100_DEBUG
2229 #define IPW2100_HANDLER(v, f) { v, f, # v }
2236 #define IPW2100_HANDLER(v, f) { v, f }
2243 static void isr_indicate_scanning(
struct ipw2100_priv *priv,
u32 status)
2265 static void isr_status_change(
struct ipw2100_priv *priv,
int status)
2273 "no scan request. Restarting firmware.\n");
2276 schedule_reset(priv);
2279 for (i = 0; status_handlers[
i].
status != -1; i++) {
2280 if (status == status_handlers[i].status) {
2282 status_handlers[i].
name);
2283 if (status_handlers[i].
cb)
2284 status_handlers[
i].
cb(priv, status);
2293 static void isr_rx_complete_command(
struct ipw2100_priv *priv,
2296 #ifdef CONFIG_IPW2100_DEBUG
2314 #ifdef CONFIG_IPW2100_DEBUG
2315 static const char *frame_types[] = {
2316 "COMMAND_STATUS_VAL",
2317 "STATUS_CHANGE_VAL",
2320 "HOST_NOTIFICATION_VAL"
2324 static int ipw2100_alloc_skb(
struct ipw2100_priv *priv,
2341 #define SEARCH_ERROR 0xffffffff
2342 #define SEARCH_FAIL 0xfffffffe
2343 #define SEARCH_SUCCESS 0xfffffff0
2344 #define SEARCH_DISCARD 0
2345 #define SEARCH_SNAPSHOT 1
2347 #define SNAPSHOT_ADDR(ofs) (priv->snapshot[((ofs) >> 12) & 0xff] + ((ofs) & 0xfff))
2348 static void ipw2100_snapshot_free(
struct ipw2100_priv *priv)
2353 for (i = 0; i < 0x30; i++)
2358 #ifdef IPW2100_DEBUG_C3
2359 static int ipw2100_snapshot_alloc(
struct ipw2100_priv *priv)
2364 for (i = 0; i < 0x30; i++) {
2368 "buffer %d\n", priv->
net_dev->name, i);
2380 size_t len,
int mode)
2389 if (!ipw2100_snapshot_alloc(priv))
2393 for (ret =
SEARCH_FAIL, i = 0; i < 0x30000; i += 4) {
2394 read_nic_dword(priv->
net_dev, i, &tmp);
2399 for (j = 0; j < 4; j++) {
2408 if ((s - in_buf) == len)
2409 ret = (i + j) - len + 1;
2433 #ifdef IPW2100_RX_DEBUG
2437 static void ipw2100_corruption_detected(
struct ipw2100_priv *priv,
int i)
2439 #ifdef IPW2100_DEBUG_C3
2448 #ifdef IPW2100_DEBUG_C3
2461 match = ipw2100_match_buf(priv, (
u8 *) status,
2466 "offset 0x%06X, length %d:\n",
2471 "Firmware.\n", priv->
net_dev->name);
2478 priv->
net_dev->stats.rx_errors++;
2479 schedule_reset(priv);
2496 dev->
stats.rx_errors++;
2500 if (
unlikely(!netif_running(dev))) {
2501 dev->
stats.rx_errors++;
2502 priv->
wstats.discard.misc++;
2510 priv->
wstats.discard.misc++;
2514 pci_unmap_single(priv->
pci_dev,
2520 #ifdef IPW2100_RX_DEBUG
2523 skb_copy_from_linear_data(packet->
skb, packet_data,
2529 #ifdef IPW2100_RX_DEBUG
2534 dev->
stats.rx_errors++;
2542 if (
unlikely(ipw2100_alloc_skb(priv, packet))) {
2544 "%s: Unable to allocate SKB onto RBD ring - disabling "
2545 "adapter.\n", dev->
name);
2554 #ifdef CONFIG_IPW2100_MONITOR
2556 static void isr_rx_monitor(
struct ipw2100_priv *priv,
int i,
2574 sizeof(
struct ipw_rt_hdr))) {
2579 skb_tailroom(packet->
skb));
2580 dev->
stats.rx_errors++;
2584 if (
unlikely(!netif_running(dev))) {
2585 dev->
stats.rx_errors++;
2586 priv->
wstats.discard.misc++;
2594 dev->
stats.rx_errors++;
2600 memmove(packet->
skb->data +
sizeof(
struct ipw_rt_hdr),
2603 ipw_rt = (
struct ipw_rt_hdr *) packet->
skb->data;
2606 ipw_rt->rt_hdr.it_pad = 0;
2607 ipw_rt->rt_hdr.it_len =
cpu_to_le16(
sizeof(
struct ipw_rt_hdr));
2616 dev->
stats.rx_errors++;
2624 if (
unlikely(ipw2100_alloc_skb(priv, packet))) {
2626 "%s: Unable to allocate SKB onto RBD ring - disabling "
2627 "adapter.\n", dev->
name);
2638 static int ipw2100_corruption_check(
struct ipw2100_priv *priv,
int i)
2644 switch (frame_type) {
2653 #ifdef CONFIG_IPW2100_MONITOR
2694 static void __ipw2100_rx_process(
struct ipw2100_priv *priv)
2728 if (
unlikely(ipw2100_corruption_check(priv, i))) {
2729 ipw2100_corruption_detected(priv, i);
2736 stats.
len = sq->
drv[
i].frame_size;
2739 if (stats.
rssi != 0)
2744 priv->
net_dev->name, frame_types[frame_type],
2747 switch (frame_type) {
2759 #ifdef CONFIG_IPW2100_MONITOR
2761 isr_rx_monitor(priv, i, &stats);
2777 isr_rx(priv, i, &stats);
2786 rxq->
drv[
i].status.info.field = 0;
2839 static int __ipw2100_tx_process(
struct ipw2100_priv *priv)
2845 int descriptors_used;
2847 u32 r,
w, frag_num = 0;
2858 switch (packet->
type) {
2861 descriptors_used = 1;
2869 e = txq->
oldest + frag_num;
2913 if (!((r <= w && (e < r || e >= w)) || (e < r && e >= w))) {
2914 IPW_DEBUG_TX(
"exit - no processed packets ready to release.\n");
2921 #ifdef CONFIG_IPW2100_DEBUG
2927 txq->
drv[i].host_addr, txq->
drv[i].buf_length);
2942 switch (packet->
type) {
2944 if (txq->
drv[txq->
oldest].status.info.fields.txType != 0)
2946 "Expecting DATA TBD but pulled "
2947 "something else: ids %d=%d.\n",
2951 for (i = 0; i < frag_num; i++) {
2958 pci_unmap_single(priv->
pci_dev,
2972 netif_wake_queue(priv->
net_dev);
2981 if (txq->
drv[txq->
oldest].status.info.fields.txType != 1)
2983 "Expecting COMMAND TBD but pulled "
2984 "something else: ids %d=%d.\n",
2987 #ifdef CONFIG_IPW2100_DEBUG
3009 IPW_DEBUG_TX(
"packet latency (send to process) %ld jiffies\n",
3015 static inline void __ipw2100_tx_complete(
struct ipw2100_priv *priv)
3019 while (__ipw2100_tx_process(priv) && i < 200)
3024 "%s: Driver is running slow (%d iters).\n",
3029 static void ipw2100_tx_send_commands(
struct ipw2100_priv *priv)
3084 if (txq->
next != next) {
3098 static void ipw2100_tx_send_data(
struct ipw2100_priv *priv)
3104 int next = txq->
next;
3124 "Increase fragmentation level.\n",
3180 #ifdef CONFIG_IPW2100_DEBUG
3186 for (i = 0; i < packet->
info.
d_struct.txb->nr_frags; i++) {
3212 pci_dma_sync_single_for_device(priv->
pci_dev,
3228 if (txq->
next != next) {
3237 static void ipw2100_irq_tasklet(
struct ipw2100_priv *priv)
3240 unsigned long flags;
3244 ipw2100_disable_interrupts(priv);
3262 ": Fatal interrupt. Scheduling firmware restart.\n");
3264 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_FATAL_ERROR);
3275 schedule_reset(priv);
3280 ": ***** PARITY ERROR INTERRUPT !!!!\n");
3282 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_PARITY_ERROR);
3290 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_RX_TRANSFER);
3292 __ipw2100_rx_process(priv);
3293 __ipw2100_tx_complete(priv);
3301 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_TX_TRANSFER);
3303 __ipw2100_tx_complete(priv);
3304 ipw2100_tx_send_commands(priv);
3305 ipw2100_tx_send_data(priv);
3311 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_TX_COMPLETE);
3313 __ipw2100_tx_complete(priv);
3319 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_EVENT_INTERRUPT);
3322 if (inta & IPW2100_INTA_FW_INIT_DONE) {
3327 if (tmp & (IPW2100_INTA_FATAL_ERROR |
3328 IPW2100_INTA_PARITY_ERROR)) {
3330 IPW2100_INTA_FATAL_ERROR |
3331 IPW2100_INTA_PARITY_ERROR);
3334 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_FW_INIT_DONE);
3340 write_register(dev,
IPW_REG_INTA, IPW2100_INTA_STATUS_CHANGE);
3347 IPW2100_INTA_SLAVE_MODE_HOST_COMMAND_DONE);
3351 ipw2100_enable_interrupts(priv);
3353 spin_unlock_irqrestore(&priv->
low_lock, flags);
3361 u32 inta, inta_mask;
3380 if (inta == 0xFFFFFFFF) {
3388 if (!(inta & inta_mask)) {
3397 ipw2100_disable_interrupts(priv);
3414 unsigned long flags;
3420 priv->
net_dev->stats.tx_carrier_errors++;
3421 netif_stop_queue(dev);
3444 ipw2100_tx_send_data(priv);
3446 spin_unlock_irqrestore(&priv->
low_lock, flags);
3450 netif_stop_queue(dev);
3451 spin_unlock_irqrestore(&priv->
low_lock, flags);
3455 static int ipw2100_msg_allocate(
struct ipw2100_priv *priv)
3472 "%s: PCI alloc failed for msg "
3473 "buffers.\n", priv->
net_dev->name);
3486 if (i == IPW_COMMAND_POOL_SIZE)
3489 for (j = 0; j <
i; j++) {
3503 static int ipw2100_msg_initialize(
struct ipw2100_priv *priv)
3517 static void ipw2100_msg_free(
struct ipw2100_priv *priv)
3544 for (i = 0; i < 16; i++) {
3545 out +=
sprintf(out,
"[%08X] ", i * 16);
3546 for (j = 0; j < 16; j += 4) {
3547 pci_read_config_dword(pci_dev, i * 16 + j, &val);
3548 out +=
sprintf(out,
"%08X ", val);
3585 #define IPW2100_REG(x) { IPW_ ##x, #x }
3586 static const struct {
3594 #define IPW2100_NIC(x, s) { x, #x, s }
3595 static const struct {
3602 #define IPW2100_ORD(x, d) { IPW_ORD_ ##x, #x, d }
3603 static const struct {
3608 IPW2100_ORD(STAT_TX_HOST_REQUESTS,
"requested Host Tx's (MSDU)"),
3610 "successful Host Tx's (MSDU)"),
3612 "successful Directed Tx's (MSDU)"),
3614 "successful Directed Tx's (MSDU) @ 1MB"),
3616 "successful Directed Tx's (MSDU) @ 2MB"),
3618 "successful Directed Tx's (MSDU) @ 5_5MB"),
3620 "successful Directed Tx's (MSDU) @ 11MB"),
3622 "successful Non_Directed Tx's (MSDU) @ 1MB"),
3624 "successful Non_Directed Tx's (MSDU) @ 2MB"),
3626 "successful Non_Directed Tx's (MSDU) @ 5.5MB"),
3628 "successful Non_Directed Tx's (MSDU) @ 11MB"),
3629 IPW2100_ORD(STAT_NULL_DATA,
"successful NULL data Tx's"),
3633 IPW2100_ORD(STAT_TX_ASSN,
"successful Association Tx's"),
3635 "successful Association response Tx's"),
3637 "successful Reassociation Tx's"),
3639 "successful Reassociation response Tx's"),
3641 "probes successfully transmitted"),
3643 "probe responses successfully transmitted"),
3647 "successful Disassociation TX"),
3648 IPW2100_ORD(STAT_TX_AUTH,
"successful Authentication Tx"),
3650 "successful Deauthentication TX"),
3652 "Total successful Tx data bytes"),
3654 IPW2100_ORD(STAT_TX_RETRY1,
"Tx retries at 1MBPS"),
3655 IPW2100_ORD(STAT_TX_RETRY2,
"Tx retries at 2MBPS"),
3656 IPW2100_ORD(STAT_TX_RETRY5_5,
"Tx retries at 5.5MBPS"),
3657 IPW2100_ORD(STAT_TX_RETRY11,
"Tx retries at 11MBPS"),
3660 "times max tries in a hop failed"),
3662 "times disassociation failed"),
3663 IPW2100_ORD(STAT_TX_ERR_CTS,
"missed/bad CTS frames"),
3664 IPW2100_ORD(STAT_TX_ERR_ACK,
"tx err due to acks"),
3665 IPW2100_ORD(STAT_RX_HOST,
"packets passed to host"),
3666 IPW2100_ORD(STAT_RX_DIR_DATA,
"directed packets"),
3667 IPW2100_ORD(STAT_RX_DIR_DATA1,
"directed packets at 1MB"),
3668 IPW2100_ORD(STAT_RX_DIR_DATA2,
"directed packets at 2MB"),
3670 "directed packets at 5.5MB"),
3671 IPW2100_ORD(STAT_RX_DIR_DATA11,
"directed packets at 11MB"),
3672 IPW2100_ORD(STAT_RX_NODIR_DATA,
"nondirected packets"),
3674 "nondirected packets at 1MB"),
3676 "nondirected packets at 2MB"),
3678 "nondirected packets at 5.5MB"),
3680 "nondirected packets at 11MB"),
3686 IPW2100_ORD(STAT_RX_CFEND_ACK,
"Rx CF End + CF Ack"),
3688 IPW2100_ORD(STAT_RX_ASSN_RESP,
"Association response Rx's"),
3689 IPW2100_ORD(STAT_RX_REASSN,
"Reassociation Rx's"),
3691 "Reassociation response Rx's"),
3693 IPW2100_ORD(STAT_RX_PROBE_RESP,
"probe response Rx's"),
3696 IPW2100_ORD(STAT_RX_DISASSN,
"disassociation Rx"),
3698 IPW2100_ORD(STAT_RX_DEAUTH,
"deauthentication Rx"),
3700 "Total rx data bytes received"),
3701 IPW2100_ORD(STAT_RX_ERR_CRC,
"packets with Rx CRC error"),
3702 IPW2100_ORD(STAT_RX_ERR_CRC1,
"Rx CRC errors at 1MB"),
3703 IPW2100_ORD(STAT_RX_ERR_CRC2,
"Rx CRC errors at 2MB"),
3704 IPW2100_ORD(STAT_RX_ERR_CRC5_5,
"Rx CRC errors at 5.5MB"),
3705 IPW2100_ORD(STAT_RX_ERR_CRC11,
"Rx CRC errors at 11MB"),
3707 "duplicate rx packets at 1MB"),
3709 "duplicate rx packets at 2MB"),
3711 "duplicate rx packets at 5.5MB"),
3713 "duplicate rx packets at 11MB"),
3714 IPW2100_ORD(STAT_RX_DUPLICATE,
"duplicate rx packets"),
3715 IPW2100_ORD(PERS_DB_LOCK,
"locking fw permanent db"),
3716 IPW2100_ORD(PERS_DB_SIZE,
"size of fw permanent db"),
3717 IPW2100_ORD(PERS_DB_ADDR,
"address of fw permanent db"),
3719 "rx frames with invalid protocol"),
3722 "rx frames rejected due to no buffer"),
3724 "rx frames dropped due to missing fragment"),
3726 "rx frames dropped due to non-sequential fragment"),
3728 "rx frames dropped due to unmatched 1st frame"),
3730 "rx frames dropped due to uncompleted frame"),
3732 "ICV errors during decryption"),
3733 IPW2100_ORD(STAT_PSP_SUSPENSION,
"times adapter suspended"),
3734 IPW2100_ORD(STAT_PSP_BCN_TIMEOUT,
"beacon timeout"),
3736 "poll response timeouts"),
3738 "timeouts waiting for last {broad,multi}cast pkt"),
3739 IPW2100_ORD(STAT_PSP_RX_DTIMS,
"PSP DTIMs received"),
3740 IPW2100_ORD(STAT_PSP_RX_TIMS,
"PSP TIMs received"),
3741 IPW2100_ORD(STAT_PSP_STATION_ID,
"PSP Station ID"),
3742 IPW2100_ORD(LAST_ASSN_TIME,
"RTC time of last association"),
3744 "current calculation of % missed beacons"),
3746 "current calculation of % missed tx retries"),
3748 "0 if not associated, else pointer to AP table entry"),
3750 "AP's decsribed in the AP table"),
3751 IPW2100_ORD(AP_LIST_PTR,
"Ptr to list of available APs"),
3753 IPW2100_ORD(STAT_ASSN_FAIL,
"association failures"),
3755 "failures due to response fail"),
3759 "times roaming was inhibited due to activity"),
3761 "RSSI of associated AP at time of association"),
3763 "reassociation: no probe response or TX on hop"),
3765 "reassociation: poor tx/rx quality"),
3767 "reassociation: tx/rx quality (excessive AP load"),
3769 "reassociation: AP RSSI level"),
3771 "reassociations due to load leveling"),
3774 "times authentication response failed"),
3776 "entries in association table"),
3778 IPW2100_ORD(POWER_MGMT_MODE,
"Power mode - 0=CAM, 1=PSP"),
3780 "IEEE country code as recv'd from beacon"),
3782 "channels supported by country"),
3786 "TRUE if antenna diversity is disabled"),
3787 IPW2100_ORD(DTIM_PERIOD,
"beacon intervals between DTIMs"),
3789 "current radio freq lower digits - channel ID"),
3796 IPW2100_ORD(NIC_HIGHEST_RATE,
"NIC highest tx rate"),
3797 IPW2100_ORD(AP_HIGHEST_RATE,
"AP highest tx rate"),
3799 "Management frame capability field"),
3801 IPW2100_ORD(RADIO_TYPE,
"Adapter card platform type"),
3803 "Min packet length for RTS handshaking"),
3806 "protocol frag threshold"),
3808 "EEPROM offset in SRAM"),
3810 "EEPROM size in SRAM"),
3813 "EEPROM IBSS 11b channel set"),
3817 IPW2100_ORD(NIC_MANF_DATE_TIME,
"MANF Date/Time STAMP"),
3829 out +=
sprintf(out,
"%30s [Address ] : Hex\n",
"Register");
3832 read_register(dev,
hw_data[i].addr, &val);
3833 out +=
sprintf(out,
"%30s [%08X] : %08X\n",
3850 out +=
sprintf(out,
"%30s [Address ] : Hex\n",
"NIC entry");
3857 switch (nic_data[i].
size) {
3859 read_nic_byte(dev, nic_data[i].addr, &tmp8);
3860 out +=
sprintf(out,
"%30s [%08X] : %02X\n",
3861 nic_data[i].
name, nic_data[i].addr,
3865 read_nic_word(dev, nic_data[i].addr, &tmp16);
3866 out +=
sprintf(out,
"%30s [%08X] : %04X\n",
3867 nic_data[i].
name, nic_data[i].addr,
3871 read_nic_dword(dev, nic_data[i].addr, &tmp32);
3872 out +=
sprintf(out,
"%30s [%08X] : %08X\n",
3873 nic_data[i].
name, nic_data[i].addr,
3888 static unsigned long loop = 0;
3894 if (loop >= 0x30000)
3898 while (len <
PAGE_SIZE - 128 && loop < 0x30000) {
3901 for (i = 0; i < 4; i++)
3905 for (i = 0; i < 4; i++)
3906 read_nic_dword(dev, loop + i * 4, &buffer[i]);
3914 ((
u8 *) buffer)[0x0],
3915 ((
u8 *) buffer)[0x1],
3916 ((
u8 *) buffer)[0x2],
3917 ((
u8 *) buffer)[0x3],
3918 ((
u8 *) buffer)[0x4],
3919 ((
u8 *) buffer)[0x5],
3920 ((
u8 *) buffer)[0x6],
3921 ((
u8 *) buffer)[0x7],
3922 ((
u8 *) buffer)[0x8],
3923 ((
u8 *) buffer)[0x9],
3924 ((
u8 *) buffer)[0xa],
3925 ((
u8 *) buffer)[0
xb],
3926 ((
u8 *) buffer)[0
xc],
3927 ((
u8 *) buffer)[0xd],
3928 ((
u8 *) buffer)[0
xe],
3929 ((
u8 *) buffer)[0xf]);
3931 len +=
sprintf(buf + len,
"%s\n",
3932 snprint_line(line,
sizeof(line),
3933 (
u8 *) buffer, 16, loop));
3941 const char *buf,
size_t count)
3945 const char *p =
buf;
3958 }
else if (p[0] ==
'0' || (count >= 2 &&
tolower(p[0]) ==
'o' &&
3964 }
else if (
tolower(p[0]) ==
'r') {
3966 ipw2100_snapshot_free(priv);
3970 "reset = clear memory snapshot\n", dev->
name);
3984 static int loop = 0;
3994 val_len =
sizeof(
u32);
3996 if (ipw2100_get_ordinal(priv, ord_data[loop].
index, &val,
3998 len +=
sprintf(buf + len,
"[0x%02X] = ERROR %s\n",
3999 ord_data[loop].index,
4000 ord_data[loop].
desc);
4002 len +=
sprintf(buf + len,
"[0x%02X] = 0x%08X %s\n",
4003 ord_data[loop].index, val,
4004 ord_data[loop].desc);
4019 out +=
sprintf(out,
"interrupts: %d {tx: %d, rx: %d, other: %d}\n",
4023 out +=
sprintf(out,
"firmware hangs: %d\n", priv->
hangs);
4024 #ifdef CONFIG_IPW2100_DEBUG
4025 out +=
sprintf(out,
"packet mismatch image: %s\n",
4038 if (mode == priv->
ieee->iw_mode)
4041 err = ipw2100_disable_adapter(priv);
4055 #ifdef CONFIG_IPW2100_MONITOR
4068 ipw2100_firmware.version = 0;
4073 schedule_reset(priv);
4084 #define DUMP_VAR(x,y) len += sprintf(buf + len, # x ": %" y "\n", priv-> x)
4087 len +=
sprintf(buf + len,
"connected: %lu\n",
4090 len +=
sprintf(buf + len,
"not connected\n");
4098 sprintf(buf + len,
"last_rtc: %lu\n",
4146 memset(essid, 0,
sizeof(essid));
4147 memset(bssid, 0,
sizeof(bssid));
4155 length =
sizeof(
bssid);
4162 length =
sizeof(
u32);
4168 out +=
sprintf(out,
"ESSID: %s\n", essid);
4169 out +=
sprintf(out,
"BSSID: %pM\n", bssid);
4170 out +=
sprintf(out,
"Channel: %d\n", chan);
4177 #ifdef CONFIG_IPW2100_DEBUG
4180 return sprintf(buf,
"0x%08X\n", ipw2100_debug_level);
4184 const char *buf,
size_t count)
4186 char *p = (
char *)buf;
4189 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
4191 if (p[0] ==
'x' || p[0] ==
'X')
4199 ipw2100_debug_level =
val;
4225 out +=
sprintf(out,
"%d. 0x%08X\n", i,
4227 IPW2100_ERROR_QUEUE]);
4238 schedule_reset(priv);
4249 return sprintf(buf,
"%d\n", priv->
ieee->scan_age);
4253 const char *buf,
size_t count)
4257 char buffer[] =
"00000000";
4259 (
sizeof(
buffer) - 1) > count ? count :
sizeof(
buffer) - 1;
4270 if (p[1] ==
'x' || p[1] ==
'X' || p[0] ==
'x' || p[0] ==
'X') {
4272 if (p[0] ==
'x' || p[0] ==
'X')
4299 (rf_kill_active(priv) ? 0x2 : 0x0);
4300 return sprintf(buf,
"%i\n", val);
4303 static int ipw_radio_kill_sw(
struct ipw2100_priv *priv,
int disable_radio)
4305 if ((disable_radio ? 1 : 0) ==
4310 disable_radio ?
"OFF" :
"ON");
4314 if (disable_radio) {
4319 if (rf_kill_active(priv)) {
4321 "disabled by HW switch\n");
4327 schedule_reset(priv);
4335 const char *buf,
size_t count)
4338 ipw_radio_kill_sw(priv, buf[0] ==
'1');
4344 static struct attribute *ipw2100_sysfs_entries[] = {
4345 &dev_attr_hardware.attr,
4346 &dev_attr_registers.attr,
4347 &dev_attr_ordinals.attr,
4349 &dev_attr_stats.attr,
4350 &dev_attr_internals.attr,
4351 &dev_attr_bssinfo.attr,
4352 &dev_attr_memory.attr,
4353 &dev_attr_scan_age.attr,
4354 &dev_attr_fatal_error.attr,
4355 &dev_attr_rf_kill.attr,
4357 &dev_attr_status.attr,
4358 &dev_attr_capability.attr,
4363 .attrs = ipw2100_sysfs_entries,
4388 static void status_queue_free(
struct ipw2100_priv *priv)
4402 static int bd_queue_allocate(
struct ipw2100_priv *priv,
4414 (
"can't allocate shared memory for buffer descriptors\n");
4439 static void bd_queue_initialize(
struct ipw2100_priv *priv,
4456 static void ipw2100_kill_works(
struct ipw2100_priv *priv)
4469 static int ipw2100_tx_allocate(
struct ipw2100_priv *priv)
4489 ": %s: alloc failed form tx buffers.\n",
4491 bd_queue_free(priv, &priv->
tx_queue);
4501 ": %s: PCI alloc failed for tx " "buffers.\n",
4514 if (i == TX_PENDED_QUEUE_LENGTH)
4517 for (j = 0; j <
i; j++) {
4531 static void ipw2100_tx_initialize(
struct ipw2100_priv *priv)
4571 bd_queue_initialize(priv, &priv->
tx_queue,
4587 bd_queue_free(priv, &priv->
tx_queue);
4613 static int ipw2100_rx_allocate(
struct ipw2100_priv *priv)
4628 bd_queue_free(priv, &priv->
rx_queue);
4641 bd_queue_free(priv, &priv->
rx_queue);
4643 status_queue_free(priv);
4651 err = ipw2100_alloc_skb(priv, packet);
4663 if (i == RX_QUEUE_LENGTH)
4666 for (j = 0; j <
i; j++) {
4676 bd_queue_free(priv, &priv->
rx_queue);
4678 status_queue_free(priv);
4683 static void ipw2100_rx_initialize(
struct ipw2100_priv *priv)
4694 bd_queue_initialize(priv, &priv->
rx_queue,
4713 bd_queue_free(priv, &priv->
rx_queue);
4714 status_queue_free(priv);
4721 pci_unmap_single(priv->
pci_dev,
4735 static int ipw2100_read_mac_address(
struct ipw2100_priv *priv)
4760 static int ipw2100_set_mac_address(
struct ipw2100_priv *priv,
int batch_mode)
4764 .host_command_sequence = 0,
4780 err = ipw2100_hw_send_command(priv, &cmd);
4791 .host_command_sequence = 0,
4792 .host_command_length =
sizeof(
u32)
4796 switch (port_type) {
4806 port_type ==
IPW_IBSS ?
"Ad-Hoc" :
"Managed");
4809 err = ipw2100_disable_adapter(priv);
4812 ": %s: Could not disable adapter %d\n",
4819 err = ipw2100_hw_send_command(priv, &cmd);
4822 ipw2100_enable_adapter(priv);
4832 .host_command_sequence = 0,
4833 .host_command_length =
sizeof(
u32)
4845 if ((channel != 0) &&
4850 err = ipw2100_disable_adapter(priv);
4855 err = ipw2100_hw_send_command(priv, &cmd);
4869 err = ipw2100_enable_adapter(priv);
4877 static int ipw2100_system_config(
struct ipw2100_priv *priv,
int batch_mode)
4881 .host_command_sequence = 0,
4882 .host_command_length = 12,
4884 u32 ibss_mask, len =
sizeof(
u32);
4890 err = ipw2100_disable_adapter(priv);
4904 err = ipw2100_get_ordinal(priv,
4916 err = ipw2100_hw_send_command(priv, &cmd);
4922 #if !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
4927 ipw2100_hw_send_command(priv, &cmd);
4930 err = ipw2100_enable_adapter(priv);
4943 .host_command_sequence = 0,
4944 .host_command_length = 4
4951 err = ipw2100_disable_adapter(priv);
4957 ipw2100_hw_send_command(priv, &cmd);
4961 ipw2100_hw_send_command(priv, &cmd);
4965 ipw2100_hw_send_command(priv, &cmd);
4968 err = ipw2100_enable_adapter(priv);
4978 static int ipw2100_set_power_mode(
struct ipw2100_priv *priv,
int power_level)
4982 .host_command_sequence = 0,
4983 .host_command_length = 4
4989 err = ipw2100_hw_send_command(priv, &cmd);
4998 #ifdef IPW2100_TX_POWER
4999 if (priv->port_type == IBSS && priv->adhoc_power != DFTL_IBSS_TX_POWER) {
5004 err = ipw2100_hw_send_command(priv, &cmd);
5017 .host_command_sequence = 0,
5018 .host_command_length = 4
5027 err = ipw2100_hw_send_command(priv, &cmd);
5037 int ipw2100_set_fragmentation_threshold(
struct ipw2100_priv *priv,
5038 u32 threshold,
int batch_mode)
5042 .host_command_sequence = 0,
5043 .host_command_length = 4,
5044 .host_command_parameters[0] = 0,
5049 err = ipw2100_disable_adapter(priv);
5065 err = ipw2100_hw_send_command(priv, &cmd);
5068 ipw2100_enable_adapter(priv);
5081 .host_command_sequence = 0,
5082 .host_command_length = 4
5088 err = ipw2100_hw_send_command(priv, &cmd);
5097 static int ipw2100_set_long_retry(
struct ipw2100_priv *priv,
u32 retry)
5101 .host_command_sequence = 0,
5102 .host_command_length = 4
5108 err = ipw2100_hw_send_command(priv, &cmd);
5117 static int ipw2100_set_mandatory_bssid(
struct ipw2100_priv *priv,
u8 * bssid,
5122 .host_command_sequence = 0,
5127 #ifdef CONFIG_IPW2100_DEBUG
5138 err = ipw2100_disable_adapter(priv);
5143 err = ipw2100_hw_send_command(priv, &cmd);
5146 ipw2100_enable_adapter(priv);
5151 static int ipw2100_disassociate_bssid(
struct ipw2100_priv *priv)
5155 .host_command_sequence = 0,
5170 err = ipw2100_hw_send_command(priv, &cmd);
5185 .host_command_sequence = 0,
5193 err = ipw2100_disable_adapter(priv);
5201 err = ipw2100_hw_send_command(priv, &cmd);
5204 if (ipw2100_enable_adapter(priv))
5219 static int ipw2100_set_security_information(
struct ipw2100_priv *priv,
5222 int unicast_using_group,
5227 .host_command_sequence = 0,
5233 memset(security, 0,
sizeof(*security));
5242 switch (security_level) {
5266 (
"SET_SECURITY_INFORMATION: auth:%d cipher:0x%02X (level %d)\n",
5272 err = ipw2100_disable_adapter(priv);
5277 err = ipw2100_hw_send_command(priv, &cmd);
5280 ipw2100_enable_adapter(priv);
5289 .host_command_sequence = 0,
5290 .host_command_length = 4
5302 err = ipw2100_hw_send_command(priv, &cmd);
5309 static int ipw2100_set_ibss_beacon_interval(
struct ipw2100_priv *priv,
5314 .host_command_sequence = 0,
5315 .host_command_length = 4
5325 err = ipw2100_disable_adapter(priv);
5330 ipw2100_hw_send_command(priv, &cmd);
5333 err = ipw2100_enable_adapter(priv);
5344 static void ipw2100_queues_initialize(
struct ipw2100_priv *priv)
5346 ipw2100_tx_initialize(priv);
5347 ipw2100_rx_initialize(priv);
5348 ipw2100_msg_initialize(priv);
5351 static void ipw2100_queues_free(
struct ipw2100_priv *priv)
5353 ipw2100_tx_free(priv);
5354 ipw2100_rx_free(priv);
5355 ipw2100_msg_free(priv);
5358 static int ipw2100_queues_allocate(
struct ipw2100_priv *priv)
5360 if (ipw2100_tx_allocate(priv) ||
5361 ipw2100_rx_allocate(priv) || ipw2100_msg_allocate(priv))
5367 ipw2100_tx_free(priv);
5368 ipw2100_rx_free(priv);
5369 ipw2100_msg_free(priv);
5373 #define IPW_PRIVACY_CAPABLE 0x0008
5375 static int ipw2100_set_wep_flags(
struct ipw2100_priv *priv,
u32 flags,
5380 .host_command_sequence = 0,
5381 .host_command_length = 4
5390 err = ipw2100_disable_adapter(priv);
5393 ": %s: Could not disable adapter %d\n",
5400 err = ipw2100_hw_send_command(priv, &cmd);
5403 ipw2100_enable_adapter(priv);
5415 #define WEP_FMT_64 "%02X%02X%02X%02X-%02X"
5416 #define WEP_FMT_128 "%02X%02X%02X%02X-%02X%02X%02X%02X-%02X%02X%02X"
5417 #define WEP_STR_64(x) x[0],x[1],x[2],x[3],x[4]
5418 #define WEP_STR_128(x) x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10]
5436 int idx,
char *
key,
int len,
int batch_mode)
5438 int keylen = len ? (len <= 5 ? 5 : 13) : 0;
5441 .host_command_sequence = 0,
5447 IPW_DEBUG_HC(
"WEP_KEY_INFO: index = %d, len = %d/%d\n",
5455 wep_key->
len = keylen;
5459 memset(wep_key->
key + len, 0, keylen - len);
5466 else if (keylen == 5)
5477 err = ipw2100_disable_adapter(priv);
5481 ": %s: Could not disable adapter %d\n",
5488 err = ipw2100_hw_send_command(priv, &cmd);
5491 int err2 = ipw2100_enable_adapter(priv);
5498 static int ipw2100_set_key_index(
struct ipw2100_priv *priv,
5499 int idx,
int batch_mode)
5503 .host_command_sequence = 0,
5504 .host_command_length = 4,
5505 .host_command_parameters = {idx},
5511 if (idx < 0 || idx > 3)
5515 err = ipw2100_disable_adapter(priv);
5518 ": %s: Could not disable adapter %d\n",
5525 err = ipw2100_hw_send_command(priv, &cmd);
5528 ipw2100_enable_adapter(priv);
5533 static int ipw2100_configure_security(
struct ipw2100_priv *priv,
int batch_mode)
5541 err = ipw2100_disable_adapter(priv);
5546 if (!priv->
ieee->sec.enabled) {
5561 sec_level = priv->
ieee->sec.level;
5565 use_group = priv->
ieee->sec.unicast_uses_group;
5568 ipw2100_set_security_information(priv, auth_mode, sec_level,
5575 if (priv->
ieee->sec.enabled) {
5576 for (i = 0; i < 4; i++) {
5577 if (!(priv->
ieee->sec.flags & (1 << i))) {
5579 priv->
ieee->sec.key_sizes[
i] = 0;
5581 err = ipw2100_set_key(priv, i,
5582 priv->
ieee->sec.keys[i],
5590 ipw2100_set_key_index(priv, priv->
ieee->crypt_info.tx_keyidx, 1);
5596 ipw2100_set_wep_flags(priv,
5606 ipw2100_enable_adapter(priv);
5611 static void ipw2100_security_work(
struct work_struct *work)
5621 ipw2100_configure_security(priv, 0);
5624 static void shim__set_security(
struct net_device *dev,
5628 int i, force_update = 0;
5634 for (i = 0; i < 4; i++) {
5635 if (sec->
flags & (1 << i)) {
5638 priv->
ieee->sec.flags &= ~(1 <<
i);
5643 priv->
ieee->sec.flags |= (1 <<
i);
5646 priv->
ieee->sec.flags &= ~(1 <<
i);
5685 priv->
ieee->sec.flags & (1 << 8) ?
'1' :
'0',
5686 priv->
ieee->sec.flags & (1 << 7) ?
'1' :
'0',
5687 priv->
ieee->sec.flags & (1 << 6) ?
'1' :
'0',
5688 priv->
ieee->sec.flags & (1 << 5) ?
'1' :
'0',
5689 priv->
ieee->sec.flags & (1 << 4) ?
'1' :
'0',
5690 priv->
ieee->sec.flags & (1 << 3) ?
'1' :
'0',
5691 priv->
ieee->sec.flags & (1 << 2) ?
'1' :
'0',
5692 priv->
ieee->sec.flags & (1 << 1) ?
'1' :
'0',
5693 priv->
ieee->sec.flags & (1 << 0) ?
'1' :
'0');
5701 ipw2100_configure_security(priv, 0);
5706 static int ipw2100_adapter_setup(
struct ipw2100_priv *priv)
5714 err = ipw2100_disable_adapter(priv);
5717 #ifdef CONFIG_IPW2100_MONITOR
5719 err = ipw2100_set_channel(priv, priv->
channel, batch_mode);
5729 err = ipw2100_read_mac_address(priv);
5733 err = ipw2100_set_mac_address(priv, batch_mode);
5737 err = ipw2100_set_port_type(priv, priv->
ieee->iw_mode, batch_mode);
5742 err = ipw2100_set_channel(priv, priv->
channel, batch_mode);
5747 err = ipw2100_system_config(priv, batch_mode);
5751 err = ipw2100_set_tx_rates(priv, priv->
tx_rates, batch_mode);
5765 bssid = priv->
bssid;
5768 err = ipw2100_set_mandatory_bssid(priv, bssid, batch_mode);
5776 err = ipw2100_set_essid(priv,
NULL, 0, batch_mode);
5780 err = ipw2100_configure_security(priv, batch_mode);
5786 ipw2100_set_ibss_beacon_interval(priv,
5792 err = ipw2100_set_tx_power(priv, priv->
tx_power);
5818 static int ipw2100_set_address(
struct net_device *dev,
void *p)
5824 if (!is_valid_ether_addr(addr->
sa_data))
5832 err = ipw2100_set_mac_address(priv, 0);
5838 ipw2100_reset_adapter(&priv->
reset_work.work);
5846 static int ipw2100_open(
struct net_device *dev)
5849 unsigned long flags;
5855 netif_start_queue(dev);
5857 spin_unlock_irqrestore(&priv->
low_lock, flags);
5862 static int ipw2100_close(
struct net_device *dev)
5865 unsigned long flags;
5875 netif_stop_queue(dev);
5891 spin_unlock_irqrestore(&priv->
low_lock, flags);
5901 static void ipw2100_tx_timeout(
struct net_device *dev)
5905 dev->
stats.tx_errors++;
5907 #ifdef CONFIG_IPW2100_MONITOR
5912 IPW_DEBUG_INFO(
"%s: TX timed out. Scheduling firmware restart.\n",
5914 schedule_reset(priv);
5917 static int ipw2100_wpa_enable(
struct ipw2100_priv *priv,
int value)
5925 static int ipw2100_wpa_set_auth_algs(
struct ipw2100_priv *priv,
int value)
5955 char *wpa_ie,
int wpa_ie_len)
5967 ipw2100_wpa_enable(priv, 1);
5968 ipw2100_set_wpa_ie(priv, &frame, 0);
5971 static void ipw_ethtool_get_drvinfo(
struct net_device *dev,
5975 char fw_ver[64], ucode_ver[64];
5980 ipw2100_get_fwversion(priv, fw_ver,
sizeof(fw_ver));
5981 ipw2100_get_ucodeversion(priv, ucode_ver,
sizeof(ucode_ver));
5996 static const struct ethtool_ops ipw2100_ethtool_ops = {
5997 .
get_link = ipw2100_ethtool_get_link,
5998 .get_drvinfo = ipw_ethtool_get_drvinfo,
6001 static void ipw2100_hang_check(
struct work_struct *work)
6005 unsigned long flags;
6033 schedule_reset(priv);
6041 spin_unlock_irqrestore(&priv->
low_lock, flags);
6044 static void ipw2100_rf_kill(
struct work_struct *work)
6048 unsigned long flags;
6052 if (rf_kill_active(priv)) {
6065 schedule_reset(priv);
6071 spin_unlock_irqrestore(&priv->
low_lock, flags);
6074 static void ipw2100_irq_tasklet(
struct ipw2100_priv *priv);
6078 .ndo_stop = ipw2100_close,
6081 .ndo_tx_timeout = ipw2100_tx_timeout,
6082 .ndo_set_mac_address = ipw2100_set_address,
6088 static struct net_device *ipw2100_alloc_device(
struct pci_dev *pci_dev,
6097 priv = libipw_priv(dev);
6098 priv->
ieee = netdev_priv(dev);
6103 priv->
ieee->hard_start_xmit = ipw2100_tx;
6104 priv->
ieee->set_security = shim__set_security;
6106 priv->
ieee->perfect_rssi = -20;
6107 priv->
ieee->worst_rssi = -85;
6111 dev->wireless_handlers = &ipw2100_wx_handler_def;
6129 #ifdef CONFIG_IPW2100_MONITOR
6130 priv->
config |= CFG_CRC_CHECK;
6132 priv->
ieee->wpa_enabled = 0;
6133 priv->
ieee->drop_unencrypted = 0;
6134 priv->
ieee->privacy_invoked = 0;
6135 priv->
ieee->ieee802_1x = 1;
6138 switch (network_mode) {
6142 #ifdef CONFIG_IPW2100_MONITOR
6205 ipw2100_irq_tasklet, (
unsigned long)priv);
6208 priv->stop_rf_kill = 1;
6209 priv->stop_hang_check = 1;
6214 static int ipw2100_pci_init_one(
struct pci_dev *pci_dev,
6232 ioaddr = pci_iomap(pci_dev, 0, 0);
6235 "Error calling ioremap_nocache.\n");
6241 dev = ipw2100_alloc_device(pci_dev, ioaddr);
6244 "Error calling ipw2100_alloc_device.\n");
6253 "Error calling pci_enable_device.\n");
6257 priv = libipw_priv(dev);
6260 pci_set_drvdata(pci_dev, priv);
6265 "Error calling pci_set_dma_mask.\n");
6273 "Error calling pci_request_regions.\n");
6280 pci_read_config_dword(pci_dev, 0x40, &val);
6281 if ((val & 0x0000ff00) != 0)
6282 pci_write_config_dword(pci_dev, 0x40, val & 0xffff00ff);
6286 if (!ipw2100_hw_is_adapter_in_system(dev)) {
6288 "Device not found via register read.\n");
6297 ipw2100_disable_interrupts(priv);
6300 if (ipw2100_queues_allocate(priv)) {
6302 "Error calling ipw2100_queues_allocate.\n");
6306 ipw2100_queues_initialize(priv);
6312 "Error calling request_irq: %d.\n", pci_dev->
irq);
6320 ": Detected Intel PRO/Wireless 2100 Network Connection\n");
6322 err = ipw2100_up(priv, 1);
6326 err = ipw2100_wdev_init(dev);
6339 "Error calling register_netdev.\n");
6357 if (ipw2100_enable_adapter(priv)) {
6359 ": %s: failed in call to enable adapter.\n",
6361 ipw2100_hw_stop_adapter(priv);
6367 ipw2100_set_scan_options(priv);
6368 ipw2100_start_scan(priv);
6383 if (registered >= 2)
6391 ipw2100_hw_stop_adapter(priv);
6393 ipw2100_disable_interrupts(priv);
6398 ipw2100_kill_works(priv);
6401 ipw2100_queues_free(priv);
6403 &ipw2100_attribute_group);
6406 pci_set_drvdata(pci_dev,
NULL);
6416 static void __devexit ipw2100_pci_remove_one(
struct pci_dev *pci_dev)
6428 if (ipw2100_firmware.version)
6429 ipw2100_release_firmware(priv, &ipw2100_firmware);
6444 ipw2100_kill_works(priv);
6446 ipw2100_queues_free(priv);
6449 ipw2100_snapshot_free(priv);
6494 static int ipw2100_resume(
struct pci_dev *pci_dev)
6524 pci_read_config_dword(pci_dev, 0x40, &val);
6525 if ((val & 0x0000ff00) != 0)
6526 pci_write_config_dword(pci_dev, 0x40, val & 0xffff00ff);
6536 ipw2100_up(priv, 0);
6544 static void ipw2100_shutdown(
struct pci_dev *pci_dev)
6554 #define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x }
6608 static struct pci_driver ipw2100_pci_driver = {
6610 .id_table = ipw2100_pci_id_table,
6611 .probe = ipw2100_pci_init_one,
6614 .suspend = ipw2100_suspend,
6615 .resume = ipw2100_resume,
6617 .shutdown = ipw2100_shutdown,
6629 static int __init ipw2100_init(
void)
6639 ret = pci_register_driver(&ipw2100_pci_driver);
6643 #ifdef CONFIG_IPW2100_DEBUG
6644 ipw2100_debug_level =
debug;
6646 &driver_attr_debug_level);
6656 static void __exit ipw2100_exit(
void)
6659 #ifdef CONFIG_IPW2100_DEBUG
6661 &driver_attr_debug_level);
6670 static int ipw2100_wx_get_name(
struct net_device *dev,
6688 static int ipw2100_wx_set_freq(
struct net_device *dev,
6707 if ((fwrq->
m >= (
int)2.412e8 && fwrq->
m <= (
int)2.487e8)) {
6708 int f = fwrq->
m / 100000;
6712 (f != ipw2100_frequencies[c]))
6721 if (fwrq->
e > 0 || fwrq->
m > 1000) {
6726 err = ipw2100_set_channel(priv, fwrq->
m, 0);
6734 static int ipw2100_wx_get_freq(
struct net_device *dev,
6759 static int ipw2100_wx_set_mode(
struct net_device *dev,
6768 if (wrqu->
mode == priv->
ieee->iw_mode)
6777 switch (wrqu->
mode) {
6778 #ifdef CONFIG_IPW2100_MONITOR
6798 static int ipw2100_wx_get_mode(
struct net_device *dev,
6814 #define POWER_MODES 5
6833 static int ipw2100_wx_get_range(
struct net_device *dev,
6846 wrqu->
data.length =
sizeof(*range);
6847 memset(range, 0,
sizeof(*range));
6885 range->
min_pmp = period_duration[0];
6888 range->
max_pmt = timeout_duration[0];
6936 range->
freq[
val].m = ipw2100_frequencies[
i] * 100000;
6958 static int ipw2100_wx_set_wap(
struct net_device *dev,
6975 if (is_broadcast_ether_addr(wrqu->
ap_addr.sa_data) ||
6976 is_zero_ether_addr(wrqu->
ap_addr.sa_data)) {
6980 err = ipw2100_set_mandatory_bssid(priv,
NULL, 0);
6987 err = ipw2100_set_mandatory_bssid(priv, wrqu->
ap_addr.sa_data, 0);
6996 static int ipw2100_wx_get_wap(
struct net_device *dev,
7018 static int ipw2100_wx_set_essid(
struct net_device *dev,
7034 if (wrqu->
essid.flags && wrqu->
essid.length) {
7035 length = wrqu->
essid.length;
7042 err = ipw2100_set_essid(priv,
NULL, 0, 0);
7062 err = ipw2100_set_essid(priv, essid, length, 0);
7069 static int ipw2100_wx_get_essid(
struct net_device *dev,
7087 wrqu->
essid.flags = 1;
7090 wrqu->
essid.length = 0;
7091 wrqu->
essid.flags = 0;
7097 static int ipw2100_wx_set_nick(
struct net_device *dev,
7110 wrqu->
data.length =
min((
size_t) wrqu->
data.length,
sizeof(priv->
nick));
7119 static int ipw2100_wx_get_nick(
struct net_device *dev,
7131 wrqu->
data.flags = 1;
7138 static int ipw2100_wx_set_rate(
struct net_device *dev,
7155 if (target_rate == 1000000 ||
7156 (!wrqu->
bitrate.fixed && target_rate > 1000000))
7158 if (target_rate == 2000000 ||
7159 (!wrqu->
bitrate.fixed && target_rate > 2000000))
7161 if (target_rate == 5500000 ||
7162 (!wrqu->
bitrate.fixed && target_rate > 5500000))
7164 if (target_rate == 11000000 ||
7165 (!wrqu->
bitrate.fixed && target_rate > 11000000))
7170 err = ipw2100_set_tx_rates(priv, rate, 0);
7178 static int ipw2100_wx_get_rate(
struct net_device *dev,
7184 unsigned int len =
sizeof(
val);
7206 switch (val & TX_RATE_MASK) {
7208 wrqu->
bitrate.value = 1000000;
7211 wrqu->
bitrate.value = 2000000;
7214 wrqu->
bitrate.value = 5500000;
7217 wrqu->
bitrate.value = 11000000;
7230 static int ipw2100_wx_set_rts(
struct net_device *dev,
7238 if (wrqu->
rts.fixed == 0)
7247 if (wrqu->
rts.disabled)
7250 if (wrqu->
rts.value < 1 || wrqu->
rts.value > 2304) {
7254 value = wrqu->
rts.value;
7257 err = ipw2100_set_rts_threshold(priv, value);
7265 static int ipw2100_wx_get_rts(
struct net_device *dev,
7276 wrqu->
rts.fixed = 1;
7286 static int ipw2100_wx_set_txpow(
struct net_device *dev,
7293 if (ipw_radio_kill_sw(priv, wrqu->
txpower.disabled))
7318 err = ipw2100_set_tx_power(priv, value);
7327 static int ipw2100_wx_get_txpow(
struct net_device *dev,
7354 static int ipw2100_wx_set_frag(
struct net_device *dev,
7364 if (!wrqu->
frag.fixed)
7367 if (wrqu->
frag.disabled) {
7375 priv->
ieee->fts = wrqu->
frag.value & ~0x1;
7384 static int ipw2100_wx_get_frag(
struct net_device *dev,
7394 wrqu->
frag.fixed = 0;
7402 static int ipw2100_wx_set_retry(
struct net_device *dev,
7422 err = ipw2100_set_short_retry(priv, wrqu->
retry.value);
7429 err = ipw2100_set_long_retry(priv, wrqu->
retry.value);
7435 err = ipw2100_set_short_retry(priv, wrqu->
retry.value);
7437 err = ipw2100_set_long_retry(priv, wrqu->
retry.value);
7446 static int ipw2100_wx_get_retry(
struct net_device *dev,
7456 wrqu->
retry.disabled = 0;
7478 static int ipw2100_wx_set_scan(
struct net_device *dev,
7494 if (ipw2100_set_scan_options(priv) || ipw2100_start_scan(priv)) {
7506 static int ipw2100_wx_get_scan(
struct net_device *dev,
7521 static int ipw2100_wx_set_encode(
struct net_device *dev,
7533 static int ipw2100_wx_get_encode(
struct net_device *dev,
7545 static int ipw2100_wx_set_power(
struct net_device *dev,
7558 if (wrqu->
power.disabled) {
7590 static int ipw2100_wx_get_power(
struct net_device *dev,
7601 wrqu->
power.disabled = 1;
7603 wrqu->
power.disabled = 0;
7604 wrqu->
power.flags = 0;
7617 static int ipw2100_wx_set_genie(
struct net_device *dev,
7630 (wrqu->
data.length && extra ==
NULL))
7633 if (wrqu->
data.length) {
7653 static int ipw2100_wx_get_genie(
struct net_device *dev,
7661 wrqu->
data.length = 0;
7675 static int ipw2100_wx_set_auth(
struct net_device *dev,
7683 unsigned long flags;
7697 crypt = priv->
ieee->crypt_info.crypt[priv->
ieee->crypt_info.tx_keyidx];
7698 if (!crypt || !crypt->
ops->set_flags || !crypt->
ops->get_flags)
7701 flags = crypt->
ops->get_flags(crypt->
priv);
7708 crypt->
ops->set_flags(flags, crypt->
priv);
7726 .enabled = param->
value,
7728 priv->
ieee->drop_unencrypted = param->
value;
7732 if (!param->
value) {
7739 if (priv->
ieee->set_security)
7740 priv->
ieee->set_security(priv->
ieee->dev, &sec);
7745 ret = ipw2100_wpa_set_auth_algs(priv, param->
value);
7749 ret = ipw2100_wpa_enable(priv, param->
value);
7768 static int ipw2100_wx_get_auth(
struct net_device *dev,
7790 crypt = priv->
ieee->crypt_info.crypt[priv->
ieee->crypt_info.tx_keyidx];
7791 if (!crypt || !crypt->
ops->get_flags) {
7793 "crypt not set!\n");
7807 param->
value = priv->
ieee->sec.auth_mode;
7830 static int ipw2100_wx_set_encodeext(
struct net_device *dev,
7839 static int ipw2100_wx_get_encodeext(
struct net_device *dev,
7848 static int ipw2100_wx_set_mlme(
struct net_device *dev,
7858 switch (mlme->
cmd) {
7864 ipw2100_disassociate_bssid(priv);
7878 #ifdef CONFIG_IPW2100_MONITOR
7879 static int ipw2100_wx_set_promisc(
struct net_device *dev,
7884 int *
parms = (
int *)extra;
7885 int enable = (parms[0] > 0);
7896 err = ipw2100_set_channel(priv, parms[1], 0);
7903 err = ipw2100_switch_mode(priv, priv->
last_mode);
7910 static int ipw2100_wx_reset(
struct net_device *dev,
7916 schedule_reset(priv);
7922 static int ipw2100_wx_set_powermode(
struct net_device *dev,
7927 int err = 0, mode = *(
int *)extra;
7939 err = ipw2100_set_power_mode(priv, mode);
7945 #define MAX_POWER_STRING 80
7946 static int ipw2100_wx_get_powermode(
struct net_device *dev,
7960 "Power save level: %d (Off)", level);
7965 "Power save level: %d (None)", level);
7969 "Power save level: %d (Auto)", level);
7972 timeout = timeout_duration[level - 1] / 1000;
7973 period = period_duration[level - 1] / 1000;
7975 "Power save level: %d "
7976 "(Timeout %dms, Period %dms)",
7977 level, timeout, period);
7986 static int ipw2100_wx_set_preamble(
struct net_device *dev,
7991 int err, mode = *(
int *)extra;
8008 err = ipw2100_system_config(priv, 0);
8015 static int ipw2100_wx_get_preamble(
struct net_device *dev,
8033 #ifdef CONFIG_IPW2100_MONITOR
8034 static int ipw2100_wx_set_crc_check(
struct net_device *dev,
8039 int err, mode = *(
int *)extra;
8048 priv->
config |= CFG_CRC_CHECK;
8050 priv->
config &= ~CFG_CRC_CHECK;
8062 static int ipw2100_wx_get_crc_check(
struct net_device *dev,
8072 if (priv->
config & CFG_CRC_CHECK)
8119 #define IPW2100_PRIV_SET_MONITOR SIOCIWFIRSTPRIV
8120 #define IPW2100_PRIV_RESET SIOCIWFIRSTPRIV+1
8121 #define IPW2100_PRIV_SET_POWER SIOCIWFIRSTPRIV+2
8122 #define IPW2100_PRIV_GET_POWER SIOCIWFIRSTPRIV+3
8123 #define IPW2100_PRIV_SET_LONGPREAMBLE SIOCIWFIRSTPRIV+4
8124 #define IPW2100_PRIV_GET_LONGPREAMBLE SIOCIWFIRSTPRIV+5
8125 #define IPW2100_PRIV_SET_CRC_CHECK SIOCIWFIRSTPRIV+6
8126 #define IPW2100_PRIV_GET_CRC_CHECK SIOCIWFIRSTPRIV+7
8128 static const struct iw_priv_args ipw2100_private_args[] = {
8130 #ifdef CONFIG_IPW2100_MONITOR
8152 #ifdef CONFIG_IPW2100_MONITOR
8162 static iw_handler ipw2100_private_handler[] = {
8163 #ifdef CONFIG_IPW2100_MONITOR
8164 ipw2100_wx_set_promisc,
8170 ipw2100_wx_set_powermode,
8171 ipw2100_wx_get_powermode,
8172 ipw2100_wx_set_preamble,
8173 ipw2100_wx_get_preamble,
8174 #ifdef CONFIG_IPW2100_MONITOR
8175 ipw2100_wx_set_crc_check,
8176 ipw2100_wx_get_crc_check,
8205 u32 rssi, tx_retries, missed_beacons, tx_failures;
8206 u32 ord_len =
sizeof(
u32);
8219 wstats->
miss.beacon = 0;
8221 wstats->
qual.qual = 0;
8222 wstats->
qual.level = 0;
8223 wstats->
qual.noise = 0;
8224 wstats->
qual.updated = 7;
8231 &missed_beacons, &ord_len))
8232 goto fail_get_ordinal;
8236 wstats->
qual.qual = 0;
8237 wstats->
qual.level = 0;
8241 goto fail_get_ordinal;
8244 rssi_qual = rssi * POOR / 10;
8246 rssi_qual = (rssi - 10) * (FAIR - POOR) / 5 + POOR;
8248 rssi_qual = (rssi - 15) * (
GOOD - FAIR) / 5 + FAIR;
8250 rssi_qual = (rssi - 20) * (VERY_GOOD -
GOOD) /
8253 rssi_qual = (rssi - 30) * (
PERFECT - VERY_GOOD) /
8257 &tx_retries, &ord_len))
8258 goto fail_get_ordinal;
8260 if (tx_retries > 75)
8261 tx_qual = (90 - tx_retries) * POOR / 15;
8262 else if (tx_retries > 70)
8263 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
8264 else if (tx_retries > 65)
8265 tx_qual = (70 - tx_retries) * (
GOOD - FAIR) / 5 + FAIR;
8266 else if (tx_retries > 50)
8267 tx_qual = (65 - tx_retries) * (VERY_GOOD -
GOOD) /
8270 tx_qual = (50 - tx_retries) *
8271 (
PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
8273 if (missed_beacons > 50)
8274 beacon_qual = (60 - missed_beacons) * POOR / 10;
8275 else if (missed_beacons > 40)
8276 beacon_qual = (50 - missed_beacons) * (FAIR - POOR) /
8278 else if (missed_beacons > 32)
8279 beacon_qual = (40 - missed_beacons) * (
GOOD - FAIR) /
8281 else if (missed_beacons > 20)
8282 beacon_qual = (32 - missed_beacons) *
8285 beacon_qual = (20 - missed_beacons) *
8286 (
PERFECT - VERY_GOOD) / 20 + VERY_GOOD;
8288 quality =
min(tx_qual, rssi_qual);
8289 quality =
min(beacon_qual, quality);
8291 #ifdef CONFIG_IPW2100_DEBUG
8292 if (beacon_qual == quality)
8294 else if (tx_qual == quality)
8296 else if (quality != 100)
8302 wstats->
qual.qual = quality;
8306 wstats->
qual.noise = 0;
8307 wstats->
qual.updated = 7;
8311 wstats->
miss.beacon = missed_beacons;
8314 &tx_failures, &ord_len))
8315 goto fail_get_ordinal;
8316 wstats->
discard.retries = tx_failures;
8327 .standard = ipw2100_wx_handlers,
8328 .num_standard =
ARRAY_SIZE(ipw2100_wx_handlers),
8329 .num_private =
ARRAY_SIZE(ipw2100_private_handler),
8330 .num_private_args =
ARRAY_SIZE(ipw2100_private_args),
8331 .private = (
iw_handler *) ipw2100_private_handler,
8332 .private_args = (
struct iw_priv_args *)ipw2100_private_args,
8333 .get_wireless_stats = ipw2100_wx_wireless_stats,
8336 static void ipw2100_wx_event_work(
struct work_struct *work)
8358 &priv->
bssid, &len)) {
8368 netif_wake_queue(priv->
net_dev);
8380 ipw2100_set_essid(priv,
NULL, 0, 0);
8387 #define IPW2100_FW_MAJOR_VERSION 1
8388 #define IPW2100_FW_MINOR_VERSION 3
8390 #define IPW2100_FW_MINOR(x) ((x & 0xff) >> 8)
8391 #define IPW2100_FW_MAJOR(x) (x & 0xff)
8393 #define IPW2100_FW_VERSION ((IPW2100_FW_MINOR_VERSION << 8) | \
8394 IPW2100_FW_MAJOR_VERSION)
8396 #define IPW2100_FW_PREFIX "ipw2100-" __stringify(IPW2100_FW_MAJOR_VERSION) \
8397 "." __stringify(IPW2100_FW_MINOR_VERSION)
8399 #define IPW2100_FW_NAME(x) IPW2100_FW_PREFIX "" x ".fw"
8422 static int ipw2100_mod_firmware_load(
struct ipw2100_fw *
fw)
8429 "(detected version id of %u). "
8430 "See Documentation/networking/README.ipw2100\n",
8444 static int ipw2100_get_firmware(
struct ipw2100_priv *priv,
8453 switch (priv->
ieee->iw_mode) {
8457 #ifdef CONFIG_IPW2100_MONITOR
8472 "%s: Firmware '%s' not available or load failed.\n",
8473 priv->
net_dev->name, fw_name);
8479 ipw2100_mod_firmware_load(fw);
8485 #ifdef CONFIG_IPW2100_MONITOR
8490 static void ipw2100_release_firmware(
struct ipw2100_priv *priv,
8498 static int ipw2100_get_fwversion(
struct ipw2100_priv *priv,
char *buf,
8511 for (i = 0; i < len; i++)
8517 static int ipw2100_get_ucodeversion(
struct ipw2100_priv *priv,
char *buf,
8525 return snprintf(buf, max,
"%08X", ver);
8544 const unsigned char *firmware_data = fw->
fw.data;
8545 unsigned int firmware_data_left = fw->
fw.size;
8547 while (firmware_data_left > 0) {
8548 addr = *(
u32 *) (firmware_data);
8550 firmware_data_left -= 4;
8552 len = *(
u16 *) (firmware_data);
8554 firmware_data_left -= 2;
8558 "Invalid firmware run-length of %d bytes\n",
8563 write_nic_memory(priv->
net_dev, addr, len, firmware_data);
8564 firmware_data += len;
8565 firmware_data_left -= len;
8588 static int ipw2100_ucode_download(
struct ipw2100_priv *priv,
8592 const unsigned char *microcode_data = fw->
uc.data;
8593 unsigned int microcode_data_left = fw->
uc.size;
8607 write_nic_byte(dev, 0x210014, 0x72);
8609 write_nic_byte(dev, 0x210014, 0x72);
8613 write_nic_byte(dev, 0x210000, 0x40);
8615 write_nic_byte(dev, 0x210000, 0x0);
8617 write_nic_byte(dev, 0x210000, 0x40);
8622 while (microcode_data_left > 0) {
8623 write_nic_byte(dev, 0x210010, *microcode_data++);
8624 write_nic_byte(dev, 0x210010, *microcode_data++);
8625 microcode_data_left -= 2;
8629 write_nic_byte(dev, 0x210000, 0x0);
8634 write_nic_byte(dev, 0x210000, 0x0);
8636 write_nic_byte(dev, 0x210000, 0x80);
8646 write_nic_byte(dev, 0x210014, 0x72);
8648 write_nic_byte(dev, 0x210014, 0x72);
8653 write_nic_byte(dev, 0x210000, 0x00);
8655 write_nic_byte(dev, 0x210000, 0x80);
8659 for (i = 0; i < 10; i++) {
8663 read_nic_byte(dev, 0x210000, &data);
8675 for (i = 0; i < 30; i++) {
8678 j < (sizeof(struct symbol_alive_response) >> 1); j++)
8679 read_nic_word(dev, 0x210004, ((
u16 *) & response) +
j);
8688 ": %s: No response from Symbol - hw not alive\n",