WorkStruct: make allyesconfig
[safe/jmp/linux-2.6] / drivers / net / wireless / ipw2200.c
index 1173044..587a091 100644 (file)
 #include "ipw2200.h"
 #include <linux/version.h>
 
-#define IPW2200_VERSION "git-1.1.1"
+
+#ifndef KBUILD_EXTMOD
+#define VK "k"
+#else
+#define VK
+#endif
+
+#ifdef CONFIG_IPW2200_DEBUG
+#define VD "d"
+#else
+#define VD
+#endif
+
+#ifdef CONFIG_IPW2200_MONITOR
+#define VM "m"
+#else
+#define VM
+#endif
+
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+#define VP "p"
+#else
+#define VP
+#endif
+
+#ifdef CONFIG_IPW2200_RADIOTAP
+#define VR "r"
+#else
+#define VR
+#endif
+
+#ifdef CONFIG_IPW2200_QOS
+#define VQ "q"
+#else
+#define VQ
+#endif
+
+#define IPW2200_VERSION "1.1.4" VK VD VM VP VR VQ
 #define DRV_DESCRIPTION        "Intel(R) PRO/Wireless 2200/2915 Network Driver"
 #define DRV_COPYRIGHT  "Copyright(c) 2003-2006 Intel Corporation"
 #define DRV_VERSION     IPW2200_VERSION
@@ -46,9 +83,7 @@ MODULE_AUTHOR(DRV_COPYRIGHT);
 MODULE_LICENSE("GPL");
 
 static int cmdlog = 0;
-#ifdef CONFIG_IPW2200_DEBUG
 static int debug = 0;
-#endif
 static int channel = 0;
 static int mode = 0;
 
@@ -65,7 +100,12 @@ static const char ipw_modes[] = {
 };
 static int antenna = CFG_SYS_ANTENNA_BOTH;
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+static int rtap_iface = 0;     /* def: 0 -- do not create rtap interface */
+#endif
+
+
+#ifdef CONFIG_IPW2200_QOS
 static int qos_enable = 0;
 static int qos_burst_enable = 0;
 static int qos_no_ack_mask = 0;
@@ -129,7 +169,7 @@ static int ipw_send_qos_params_command(struct ipw_priv *priv, struct ieee80211_q
                                       *qos_param);
 static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element
                                     *qos_param);
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
 static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev);
 static void ipw_remove_current_network(struct ipw_priv *priv);
@@ -147,9 +187,9 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *);
 static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *);
 static void ipw_rx_queue_replenish(void *);
 static int ipw_up(struct ipw_priv *);
-static void ipw_bg_up(void *);
+static void ipw_bg_up(struct work_struct *work);
 static void ipw_down(struct ipw_priv *);
-static void ipw_bg_down(void *);
+static void ipw_bg_down(struct work_struct *work);
 static int ipw_config(struct ipw_priv *);
 static int init_supported_rates(struct ipw_priv *priv,
                                struct ipw_supported_rates *prates);
@@ -491,7 +531,7 @@ static inline void ipw_clear_bit(struct ipw_priv *priv, u32 reg, u32 mask)
        ipw_write32(priv, reg, ipw_read32(priv, reg) & ~mask);
 }
 
-static inline void ipw_enable_interrupts(struct ipw_priv *priv)
+static inline void __ipw_enable_interrupts(struct ipw_priv *priv)
 {
        if (priv->status & STATUS_INT_ENABLED)
                return;
@@ -499,7 +539,7 @@ static inline void ipw_enable_interrupts(struct ipw_priv *priv)
        ipw_write32(priv, IPW_INTA_MASK_R, IPW_INTA_MASK_ALL);
 }
 
-static inline void ipw_disable_interrupts(struct ipw_priv *priv)
+static inline void __ipw_disable_interrupts(struct ipw_priv *priv)
 {
        if (!(priv->status & STATUS_INT_ENABLED))
                return;
@@ -507,7 +547,24 @@ static inline void ipw_disable_interrupts(struct ipw_priv *priv)
        ipw_write32(priv, IPW_INTA_MASK_R, ~IPW_INTA_MASK_ALL);
 }
 
-#ifdef CONFIG_IPW2200_DEBUG
+static inline void ipw_enable_interrupts(struct ipw_priv *priv)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->irq_lock, flags);
+       __ipw_enable_interrupts(priv);
+       spin_unlock_irqrestore(&priv->irq_lock, flags);
+}
+
+static inline void ipw_disable_interrupts(struct ipw_priv *priv)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&priv->irq_lock, flags);
+       __ipw_disable_interrupts(priv);
+       spin_unlock_irqrestore(&priv->irq_lock, flags);
+}
+
 static char *ipw_error_desc(u32 val)
 {
        switch (val) {
@@ -574,7 +631,6 @@ static void ipw_dump_error_log(struct ipw_priv *priv,
                          error->log[i].time,
                          error->log[i].data, error->log[i].event);
 }
-#endif
 
 static inline int ipw_is_init(struct ipw_priv *priv)
 {
@@ -806,11 +862,12 @@ static void ipw_led_link_on(struct ipw_priv *priv)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static void ipw_bg_led_link_on(void *data)
+static void ipw_bg_led_link_on(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, led_link_on.work);
        mutex_lock(&priv->mutex);
-       ipw_led_link_on(data);
+       ipw_led_link_on(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -850,11 +907,12 @@ static void ipw_led_link_off(struct ipw_priv *priv)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static void ipw_bg_led_link_off(void *data)
+static void ipw_bg_led_link_off(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, led_link_off.work);
        mutex_lock(&priv->mutex);
-       ipw_led_link_off(data);
+       ipw_led_link_off(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -929,11 +987,12 @@ static void ipw_led_activity_off(struct ipw_priv *priv)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static void ipw_bg_led_activity_off(void *data)
+static void ipw_bg_led_activity_off(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, led_act_off.work);
        mutex_lock(&priv->mutex);
-       ipw_led_activity_off(data);
+       ipw_led_activity_off(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -1169,12 +1228,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
        return error;
 }
 
-static void ipw_free_error_log(struct ipw_fw_error *error)
-{
-       if (error)
-               kfree(error);
-}
-
 static ssize_t show_event_log(struct device *d,
                              struct device_attribute *attr, char *buf)
 {
@@ -1236,10 +1289,9 @@ static ssize_t clear_error(struct device *d,
                           const char *buf, size_t count)
 {
        struct ipw_priv *priv = dev_get_drvdata(d);
-       if (priv->error) {
-               ipw_free_error_log(priv->error);
-               priv->error = NULL;
-       }
+
+       kfree(priv->error);
+       priv->error = NULL;
        return count;
 }
 
@@ -1272,6 +1324,105 @@ static ssize_t show_cmd_log(struct device *d,
 
 static DEVICE_ATTR(cmd_log, S_IRUGO, show_cmd_log, NULL);
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+static void ipw_prom_free(struct ipw_priv *priv);
+static int ipw_prom_alloc(struct ipw_priv *priv);
+static ssize_t store_rtap_iface(struct device *d,
+                        struct device_attribute *attr,
+                        const char *buf, size_t count)
+{
+       struct ipw_priv *priv = dev_get_drvdata(d);
+       int rc = 0;
+
+       if (count < 1)
+               return -EINVAL;
+
+       switch (buf[0]) {
+       case '0':
+               if (!rtap_iface)
+                       return count;
+
+               if (netif_running(priv->prom_net_dev)) {
+                       IPW_WARNING("Interface is up.  Cannot unregister.\n");
+                       return count;
+               }
+
+               ipw_prom_free(priv);
+               rtap_iface = 0;
+               break;
+
+       case '1':
+               if (rtap_iface)
+                       return count;
+
+               rc = ipw_prom_alloc(priv);
+               if (!rc)
+                       rtap_iface = 1;
+               break;
+
+       default:
+               return -EINVAL;
+       }
+
+       if (rc) {
+               IPW_ERROR("Failed to register promiscuous network "
+                         "device (error %d).\n", rc);
+       }
+
+       return count;
+}
+
+static ssize_t show_rtap_iface(struct device *d,
+                       struct device_attribute *attr,
+                       char *buf)
+{
+       struct ipw_priv *priv = dev_get_drvdata(d);
+       if (rtap_iface)
+               return sprintf(buf, "%s", priv->prom_net_dev->name);
+       else {
+               buf[0] = '-';
+               buf[1] = '1';
+               buf[2] = '\0';
+               return 3;
+       }
+}
+
+static DEVICE_ATTR(rtap_iface, S_IWUSR | S_IRUSR, show_rtap_iface,
+                  store_rtap_iface);
+
+static ssize_t store_rtap_filter(struct device *d,
+                        struct device_attribute *attr,
+                        const char *buf, size_t count)
+{
+       struct ipw_priv *priv = dev_get_drvdata(d);
+
+       if (!priv->prom_priv) {
+               IPW_ERROR("Attempting to set filter without "
+                         "rtap_iface enabled.\n");
+               return -EPERM;
+       }
+
+       priv->prom_priv->filter = simple_strtol(buf, NULL, 0);
+
+       IPW_DEBUG_INFO("Setting rtap filter to " BIT_FMT16 "\n",
+                      BIT_ARG16(priv->prom_priv->filter));
+
+       return count;
+}
+
+static ssize_t show_rtap_filter(struct device *d,
+                       struct device_attribute *attr,
+                       char *buf)
+{
+       struct ipw_priv *priv = dev_get_drvdata(d);
+       return sprintf(buf, "0x%04X",
+                      priv->prom_priv ? priv->prom_priv->filter : 0);
+}
+
+static DEVICE_ATTR(rtap_filter, S_IWUSR | S_IRUSR, show_rtap_filter,
+                  store_rtap_filter);
+#endif
+
 static ssize_t show_scan_age(struct device *d, struct device_attribute *attr,
                             char *buf)
 {
@@ -1283,9 +1434,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
                              const char *buf, size_t count)
 {
        struct ipw_priv *priv = dev_get_drvdata(d);
-#ifdef CONFIG_IPW2200_DEBUG
        struct net_device *dev = priv->net_dev;
-#endif
        char buffer[] = "00000000";
        unsigned long len =
            (sizeof(buffer) - 1) > count ? count : sizeof(buffer) - 1;
@@ -1715,7 +1864,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
        unsigned long flags;
        int rc = 0;
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->irq_lock, flags);
 
        inta = ipw_read32(priv, IPW_INTA_RW);
        inta_mask = ipw_read32(priv, IPW_INTA_MASK_R);
@@ -1724,6 +1873,10 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
        /* Add any cached INTA values that need to be handled */
        inta |= priv->isr_inta;
 
+       spin_unlock_irqrestore(&priv->irq_lock, flags);
+
+       spin_lock_irqsave(&priv->lock, flags);
+
        /* handle all the justifications for the interrupt */
        if (inta & IPW_INTA_BIT_RX_TRANSFER) {
                ipw_rx(priv);
@@ -1802,15 +1955,12 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
                IPW_WARNING("Firmware error detected.  Restarting.\n");
                if (priv->error) {
                        IPW_DEBUG_FW("Sysfs 'error' log already exists.\n");
-#ifdef CONFIG_IPW2200_DEBUG
                        if (ipw_debug_level & IPW_DL_FW_ERRORS) {
                                struct ipw_fw_error *error =
                                    ipw_alloc_error_log(priv);
                                ipw_dump_error_log(priv, error);
-                               if (error)
-                                       ipw_free_error_log(error);
+                               kfree(error);
                        }
-#endif
                } else {
                        priv->error = ipw_alloc_error_log(priv);
                        if (priv->error)
@@ -1818,10 +1968,8 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
                        else
                                IPW_DEBUG_FW("Error allocating sysfs 'error' "
                                             "log.\n");
-#ifdef CONFIG_IPW2200_DEBUG
                        if (ipw_debug_level & IPW_DL_FW_ERRORS)
                                ipw_dump_error_log(priv, priv->error);
-#endif
                }
 
                /* XXX: If hardware encryption is for WPA/WPA2,
@@ -1852,10 +2000,10 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
                IPW_ERROR("Unhandled INTA bits 0x%08x\n", inta & ~handled);
        }
 
+       spin_unlock_irqrestore(&priv->lock, flags);
+
        /* enable all interrupts */
        ipw_enable_interrupts(priv);
-
-       spin_unlock_irqrestore(&priv->lock, flags);
 }
 
 #define IPW_CMD(x) case IPW_CMD_ ## x : return #x
@@ -2028,16 +2176,11 @@ static int ipw_send_host_complete(struct ipw_priv *priv)
        return ipw_send_cmd_simple(priv, IPW_CMD_HOST_COMPLETE);
 }
 
-static int ipw_send_system_config(struct ipw_priv *priv,
-                                 struct ipw_sys_config *config)
+static int ipw_send_system_config(struct ipw_priv *priv)
 {
-       if (!priv || !config) {
-               IPW_ERROR("Invalid args\n");
-               return -1;
-       }
-
-       return ipw_send_cmd_pdu(priv, IPW_CMD_SYSTEM_CONFIG, sizeof(*config),
-                               config);
+       return ipw_send_cmd_pdu(priv, IPW_CMD_SYSTEM_CONFIG,
+                               sizeof(priv->sys_config),
+                               &priv->sys_config);
 }
 
 static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len)
@@ -2088,11 +2231,12 @@ static void ipw_adapter_restart(void *adapter)
        }
 }
 
-static void ipw_bg_adapter_restart(void *data)
+static void ipw_bg_adapter_restart(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, adapter_restart);
        mutex_lock(&priv->mutex);
-       ipw_adapter_restart(data);
+       ipw_adapter_restart(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -2109,11 +2253,12 @@ static void ipw_scan_check(void *data)
        }
 }
 
-static void ipw_bg_scan_check(void *data)
+static void ipw_bg_scan_check(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, scan_check.work);
        mutex_lock(&priv->mutex);
-       ipw_scan_check(data);
+       ipw_scan_check(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -2137,7 +2282,7 @@ static int ipw_send_scan_abort(struct ipw_priv *priv)
 static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens)
 {
        struct ipw_sensitivity_calib calib = {
-               .beacon_rssi_raw = sens,
+               .beacon_rssi_raw = cpu_to_le16(sens),
        };
 
        return ipw_send_cmd_pdu(priv, IPW_CMD_SENSITIVITY_CALIB, sizeof(calib),
@@ -2203,6 +2348,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off)
                return -1;
        }
 
+       phy_off = cpu_to_le32(phy_off);
        return ipw_send_cmd_pdu(priv, IPW_CMD_CARD_DISABLE, sizeof(phy_off),
                                &phy_off);
 }
@@ -2264,7 +2410,7 @@ static int ipw_set_tx_power(struct ipw_priv *priv)
 static int ipw_send_rts_threshold(struct ipw_priv *priv, u16 rts)
 {
        struct ipw_rts_threshold rts_threshold = {
-               .rts_threshold = rts,
+               .rts_threshold = cpu_to_le16(rts),
        };
 
        if (!priv) {
@@ -2279,7 +2425,7 @@ static int ipw_send_rts_threshold(struct ipw_priv *priv, u16 rts)
 static int ipw_send_frag_threshold(struct ipw_priv *priv, u16 frag)
 {
        struct ipw_frag_threshold frag_threshold = {
-               .frag_threshold = frag,
+               .frag_threshold = cpu_to_le16(frag),
        };
 
        if (!priv) {
@@ -2314,6 +2460,7 @@ static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode)
                break;
        }
 
+       param = cpu_to_le32(mode);
        return ipw_send_cmd_pdu(priv, IPW_CMD_POWER_MODE, sizeof(param),
                                &param);
 }
@@ -2517,7 +2664,7 @@ static void ipw_fw_dma_abort(struct ipw_priv *priv)
 
        IPW_DEBUG_FW(">> :\n");
 
-       //set the Stop and Abort bit
+       /* set the Stop and Abort bit */
        control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_STOP_AND_ABORT;
        ipw_write_reg32(priv, IPW_DMA_I_DMA_CONTROL, control);
        priv->sram_desc.last_cb_index = 0;
@@ -2852,8 +2999,6 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
        if (rc < 0)
                return rc;
 
-//      spin_lock_irqsave(&priv->lock, flags);
-
        for (addr = IPW_SHARED_LOWER_BOUND;
             addr < IPW_REGISTER_DOMAIN1_END; addr += 4) {
                ipw_write32(priv, addr, 0);
@@ -2947,8 +3092,6 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
           firmware have problem getting alive resp. */
        ipw_write_reg8(priv, IPW_BASEBAND_CONTROL_STATUS, 0);
 
-//      spin_unlock_irqrestore(&priv->lock, flags);
-
        return rc;
 }
 
@@ -3693,18 +3836,30 @@ static int ipw_disassociate(void *data)
        return 1;
 }
 
-static void ipw_bg_disassociate(void *data)
+static void ipw_bg_disassociate(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, disassociate);
        mutex_lock(&priv->mutex);
-       ipw_disassociate(data);
+       ipw_disassociate(priv);
        mutex_unlock(&priv->mutex);
 }
 
-static void ipw_system_config(void *data)
+static void ipw_system_config(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
-       ipw_send_system_config(priv, &priv->sys_config);
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, system_config);
+
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
+               priv->sys_config.accept_all_data_frames = 1;
+               priv->sys_config.accept_non_directed_frames = 1;
+               priv->sys_config.accept_all_mgmt_bcpr = 1;
+               priv->sys_config.accept_all_mgmt_frames = 1;
+       }
+#endif
+
+       ipw_send_system_config(priv);
 }
 
 struct ipw_status_code {
@@ -3759,7 +3914,6 @@ static const struct ipw_status_code ipw_status_codes[] = {
        {0x2E, "Cipher suite is rejected per security policy"},
 };
 
-#ifdef CONFIG_IPW2200_DEBUG
 static const char *ipw_get_status_code(u16 status)
 {
        int i;
@@ -3768,7 +3922,6 @@ static const char *ipw_get_status_code(u16 status)
                        return ipw_status_codes[i].reason;
        return "Unknown status value.";
 }
-#endif
 
 static void inline average_init(struct average *avg)
 {
@@ -4062,11 +4215,12 @@ static void ipw_gather_stats(struct ipw_priv *priv)
                           IPW_STATS_INTERVAL);
 }
 
-static void ipw_bg_gather_stats(void *data)
+static void ipw_bg_gather_stats(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, gather_stats.work);
        mutex_lock(&priv->mutex);
-       ipw_gather_stats(data);
+       ipw_gather_stats(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -4122,8 +4276,8 @@ static void ipw_handle_missed_beacon(struct ipw_priv *priv,
                if (!(priv->status & STATUS_ROAMING)) {
                        priv->status |= STATUS_ROAMING;
                        if (!(priv->status & STATUS_SCANNING))
-                               queue_work(priv->workqueue,
-                                          &priv->request_scan);
+                               queue_delayed_work(priv->workqueue,
+                                                  &priv->request_scan, 0);
                }
                return;
        }
@@ -4196,7 +4350,7 @@ static void ipw_rx_notification(struct ipw_priv *priv,
                                        queue_work(priv->workqueue,
                                                   &priv->system_config);
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
 #define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \
                         le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_ctl))
                                        if ((priv->status & STATUS_AUTH) &&
@@ -4238,7 +4392,6 @@ static void ipw_rx_notification(struct ipw_priv *priv,
                                        if (priv->
                                            status & (STATUS_ASSOCIATED |
                                                      STATUS_AUTH)) {
-#ifdef CONFIG_IPW2200_DEBUG
                                                struct notif_authenticate *auth
                                                    = &notif->u.auth;
                                                IPW_DEBUG(IPW_DL_NOTIF |
@@ -4256,7 +4409,6 @@ static void ipw_rx_notification(struct ipw_priv *priv,
                                                          ipw_get_status_code
                                                          (ntohs
                                                           (auth->status)));
-#endif
 
                                                priv->status &=
                                                    ~(STATUS_ASSOCIATING |
@@ -4463,8 +4615,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
 #ifdef CONFIG_IPW2200_MONITOR
                        if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
                                priv->status |= STATUS_SCAN_FORCED;
-                               queue_work(priv->workqueue,
-                                          &priv->request_scan);
+                               queue_delayed_work(priv->workqueue,
+                                                  &priv->request_scan, 0);
                                break;
                        }
                        priv->status &= ~STATUS_SCAN_FORCED;
@@ -4487,8 +4639,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
                                        /* Don't schedule if we aborted the scan */
                                        priv->status &= ~STATUS_ROAMING;
                        } else if (priv->status & STATUS_SCAN_PENDING)
-                               queue_work(priv->workqueue,
-                                          &priv->request_scan);
+                               queue_delayed_work(priv->workqueue,
+                                                  &priv->request_scan, 0);
                        else if (priv->config & CFG_BACKGROUND_SCAN
                                 && priv->status & STATUS_ASSOCIATED)
                                queue_delayed_work(priv->workqueue,
@@ -4899,7 +5051,6 @@ static void ipw_rx_queue_replenish(void *data)
                }
                list_del(element);
 
-               rxb->rxb = (struct ipw_rx_buffer *)rxb->skb->data;
                rxb->dma_addr =
                    pci_map_single(priv->pci_dev, rxb->skb->data,
                                   IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
@@ -4912,11 +5063,12 @@ static void ipw_rx_queue_replenish(void *data)
        ipw_rx_queue_restock(priv);
 }
 
-static void ipw_bg_rx_queue_replenish(void *data)
+static void ipw_bg_rx_queue_replenish(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, rx_replenish);
        mutex_lock(&priv->mutex);
-       ipw_rx_queue_replenish(data);
+       ipw_rx_queue_replenish(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -5346,9 +5498,10 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
        return 1;
 }
 
-static void ipw_merge_adhoc_network(void *data)
+static void ipw_merge_adhoc_network(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, merge_networks);
        struct ieee80211_network *network = NULL;
        struct ipw_network_match match = {
                .network = priv->assoc_network
@@ -5678,8 +5831,8 @@ static void ipw_send_tgi_tx_key(struct ipw_priv *priv, int type, int index)
        key.station_index = 0;  /* always 0 for BSS */
        key.flags = 0;
        /* 0 for new key; previous value of counter (after fatal error) */
-       key.tx_counter[0] = 0;
-       key.tx_counter[1] = 0;
+       key.tx_counter[0] = cpu_to_le32(0);
+       key.tx_counter[1] = cpu_to_le32(0);
 
        ipw_send_cmd_pdu(priv, IPW_CMD_TGI_TX_KEY, sizeof(key), &key);
 }
@@ -5805,15 +5958,15 @@ static void ipw_adhoc_check(void *data)
                           priv->assoc_request.beacon_interval);
 }
 
-static void ipw_bg_adhoc_check(void *data)
+static void ipw_bg_adhoc_check(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, adhoc_check.work);
        mutex_lock(&priv->mutex);
-       ipw_adhoc_check(data);
+       ipw_adhoc_check(priv);
        mutex_unlock(&priv->mutex);
 }
 
-#ifdef CONFIG_IPW2200_DEBUG
 static void ipw_debug_config(struct ipw_priv *priv)
 {
        IPW_DEBUG_INFO("Scan completed, no valid APs matched "
@@ -5838,9 +5991,6 @@ static void ipw_debug_config(struct ipw_priv *priv)
                IPW_DEBUG_INFO("PRIVACY off\n");
        IPW_DEBUG_INFO("RATE MASK: 0x%08X\n", priv->rates_mask);
 }
-#else
-#define ipw_debug_config(x) do {} while (0)
-#endif
 
 static void ipw_set_fixed_rate(struct ipw_priv *priv, int mode)
 {
@@ -6028,7 +6178,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
        }
 }
 
-static int ipw_request_scan(struct ipw_priv *priv)
+static int ipw_request_scan_helper(struct ipw_priv *priv, int type)
 {
        struct ipw_scan_request_ext scan;
        int err = 0, scan_type;
@@ -6059,19 +6209,29 @@ static int ipw_request_scan(struct ipw_priv *priv)
        }
 
        memset(&scan, 0, sizeof(scan));
+       scan.full_scan_index = cpu_to_le32(ieee80211_get_scans(priv->ieee));
 
-       if (priv->config & CFG_SPEED_SCAN)
+       if (type == IW_SCAN_TYPE_PASSIVE) {
+               IPW_DEBUG_WX("use passive scanning\n");
+               scan_type = IPW_SCAN_PASSIVE_FULL_DWELL_SCAN;
+               scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] =
+                       cpu_to_le16(120);
+               ipw_add_scan_channels(priv, &scan, scan_type);
+               goto send_request;
+       }
+
+       /* Use active scan by default. */
+       if (priv->config & CFG_SPEED_SCAN)
                scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_SCAN] =
-                   cpu_to_le16(30);
+                       cpu_to_le16(30);
        else
                scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_SCAN] =
-                   cpu_to_le16(20);
+                       cpu_to_le16(20);
 
        scan.dwell_time[IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN] =
-           cpu_to_le16(20);
-       scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] = cpu_to_le16(120);
+               cpu_to_le16(20);
 
-       scan.full_scan_index = cpu_to_le32(ieee80211_get_scans(priv->ieee));
+       scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] = cpu_to_le16(120);
 
 #ifdef CONFIG_IPW2200_MONITOR
        if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
@@ -6108,7 +6268,7 @@ static int ipw_request_scan(struct ipw_priv *priv)
                 *
                 * TODO: Move SPEED SCAN support to all modes and bands */
                scan.dwell_time[IPW_SCAN_PASSIVE_FULL_DWELL_SCAN] =
-                   cpu_to_le16(2000);
+                       cpu_to_le16(2000);
        } else {
 #endif                         /* CONFIG_IPW2200_MONITOR */
                /* If we are roaming, then make this a directed scan for the
@@ -6134,6 +6294,7 @@ static int ipw_request_scan(struct ipw_priv *priv)
        }
 #endif
 
+send_request:
        err = ipw_send_scan_request_ext(priv, &scan);
        if (err) {
                IPW_DEBUG_HC("Sending scan command failed: %08X\n", err);
@@ -6144,16 +6305,31 @@ static int ipw_request_scan(struct ipw_priv *priv)
        priv->status &= ~STATUS_SCAN_PENDING;
        queue_delayed_work(priv->workqueue, &priv->scan_check,
                           IPW_SCAN_CHECK_WATCHDOG);
-      done:
+done:
        mutex_unlock(&priv->mutex);
        return err;
 }
 
-static void ipw_bg_abort_scan(void *data)
+static void ipw_request_passive_scan(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, request_passive_scan);
+       ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE);
+}
+
+static void ipw_request_scan(struct work_struct *work)
+{
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, request_scan.work);
+       ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE);
+}
+
+static void ipw_bg_abort_scan(struct work_struct *work)
+{
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, abort_scan);
        mutex_lock(&priv->mutex);
-       ipw_abort_scan(data);
+       ipw_abort_scan(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -6198,8 +6374,6 @@ static void ipw_wpa_assoc_frame(struct ipw_priv *priv, char *wpa_ie,
 {
        /* make sure WPA is enabled */
        ipw_wpa_enable(priv, 1);
-
-       ipw_disassociate(priv);
 }
 
 static int ipw_set_rsn_capa(struct ipw_priv *priv,
@@ -6229,13 +6403,6 @@ static int ipw_wx_set_genie(struct net_device *dev,
            (wrqu->data.length && extra == NULL))
                return -EINVAL;
 
-       //mutex_lock(&priv->mutex);
-
-       //if (!ieee->wpa_enabled) {
-       //      err = -EOPNOTSUPP;
-       //      goto out;
-       //}
-
        if (wrqu->data.length) {
                buf = kmalloc(wrqu->data.length, GFP_KERNEL);
                if (buf == NULL) {
@@ -6255,7 +6422,6 @@ static int ipw_wx_set_genie(struct net_device *dev,
 
        ipw_wpa_assoc_frame(priv, ieee->wpa_ie, ieee->wpa_ie_len);
       out:
-       //mutex_unlock(&priv->mutex);
        return err;
 }
 
@@ -6268,13 +6434,6 @@ static int ipw_wx_get_genie(struct net_device *dev,
        struct ieee80211_device *ieee = priv->ieee;
        int err = 0;
 
-       //mutex_lock(&priv->mutex);
-
-       //if (!ieee->wpa_enabled) {
-       //      err = -EOPNOTSUPP;
-       //      goto out;
-       //}
-
        if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
                wrqu->data.length = 0;
                goto out;
@@ -6289,7 +6448,6 @@ static int ipw_wx_get_genie(struct net_device *dev,
        memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len);
 
       out:
-       //mutex_unlock(&priv->mutex);
        return err;
 }
 
@@ -6393,13 +6551,13 @@ static int ipw_wx_set_auth(struct net_device *dev,
 
        case IW_AUTH_WPA_ENABLED:
                ret = ipw_wpa_enable(priv, param->value);
+               ipw_disassociate(priv);
                break;
 
        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
                ieee->ieee802_1x = param->value;
                break;
 
-               //case IW_AUTH_ROAMING_CONTROL:
        case IW_AUTH_PRIVACY_INVOKED:
                ieee->privacy_invoked = param->value;
                break;
@@ -6521,7 +6679,7 @@ static int ipw_wx_set_mlme(struct net_device *dev,
 
        switch (mlme->cmd) {
        case IW_MLME_DEAUTH:
-               // silently ignore
+               /* silently ignore */
                break;
 
        case IW_MLME_DISASSOC:
@@ -6534,7 +6692,7 @@ static int ipw_wx_set_mlme(struct net_device *dev,
        return 0;
 }
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
 
 /* QoS */
 /*
@@ -6652,7 +6810,7 @@ static int ipw_qos_activate(struct ipw_priv *priv,
                burst_duration = ipw_qos_get_burst_duration(priv);
                for (i = 0; i < QOS_QUEUE_NUM; i++)
                        qos_parameters[QOS_PARAM_SET_ACTIVE].tx_op_limit[i] =
-                           (u16) burst_duration;
+                           (u16)burst_duration;
        } else if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
                if (type == IEEE_B) {
                        IPW_DEBUG_QOS("QoS activate IBSS nework mode %d\n",
@@ -6684,11 +6842,20 @@ static int ipw_qos_activate(struct ipw_priv *priv,
                        burst_duration = ipw_qos_get_burst_duration(priv);
                        for (i = 0; i < QOS_QUEUE_NUM; i++)
                                qos_parameters[QOS_PARAM_SET_ACTIVE].
-                                   tx_op_limit[i] = (u16) burst_duration;
+                                   tx_op_limit[i] = (u16)burst_duration;
                }
        }
 
        IPW_DEBUG_QOS("QoS sending IPW_CMD_QOS_PARAMETERS\n");
+       for (i = 0; i < 3; i++) {
+               int j;
+               for (j = 0; j < QOS_QUEUE_NUM; j++) {
+                       qos_parameters[i].cw_min[j] = cpu_to_le16(qos_parameters[i].cw_min[j]);
+                       qos_parameters[i].cw_max[j] = cpu_to_le16(qos_parameters[i].cw_max[j]);
+                       qos_parameters[i].tx_op_limit[j] = cpu_to_le16(qos_parameters[i].tx_op_limit[j]);
+               }
+       }
+
        err = ipw_send_qos_params_command(priv,
                                          (struct ieee80211_qos_parameters *)
                                          &(qos_parameters[0]));
@@ -6927,7 +7094,7 @@ static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
 
        if (priv->qos_data.qos_no_ack_mask & (1UL << tx_queue_id)) {
                tfd->tx_flags &= ~DCT_FLAG_ACK_REQD;
-               tfd->tfd.tfd_26.mchdr.qos_ctrl |= CTRL_QOS_NO_ACK;
+               tfd->tfd.tfd_26.mchdr.qos_ctrl |= cpu_to_le16(CTRL_QOS_NO_ACK);
        }
        return 0;
 }
@@ -6935,9 +7102,10 @@ static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
 /*
 * background support to run QoS activate functionality
 */
-static void ipw_bg_qos_activate(void *data)
+static void ipw_bg_qos_activate(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, qos_activate);
 
        if (priv == NULL)
                return;
@@ -6999,7 +7167,7 @@ static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos
                                qos_param);
 }
 
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
 static int ipw_associate_network(struct ipw_priv *priv,
                                 struct ieee80211_network *network,
@@ -7138,7 +7306,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
        else
                priv->sys_config.answer_broadcast_ssid_probe = 0;
 
-       err = ipw_send_system_config(priv, &priv->sys_config);
+       err = ipw_send_system_config(priv);
        if (err) {
                IPW_DEBUG_HC("Attempt to send sys config command failed.\n");
                return err;
@@ -7163,7 +7331,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
 
        priv->assoc_network = network;
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        ipw_qos_association(priv, network);
 #endif
 
@@ -7245,11 +7413,12 @@ static void ipw_roam(void *data)
        priv->status &= ~STATUS_ROAMING;
 }
 
-static void ipw_bg_roam(void *data)
+static void ipw_bg_roam(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, roam);
        mutex_lock(&priv->mutex);
-       ipw_roam(data);
+       ipw_roam(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -7330,8 +7499,8 @@ static int ipw_associate(void *data)
                                                   &priv->request_scan,
                                                   SCAN_INTERVAL);
                        else
-                               queue_work(priv->workqueue,
-                                          &priv->request_scan);
+                               queue_delayed_work(priv->workqueue,
+                                                  &priv->request_scan, 0);
                }
 
                return 0;
@@ -7342,11 +7511,12 @@ static int ipw_associate(void *data)
        return 1;
 }
 
-static void ipw_bg_associate(void *data)
+static void ipw_bg_associate(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, associate);
        mutex_lock(&priv->mutex);
-       ipw_associate(data);
+       ipw_associate(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -7437,7 +7607,7 @@ static void ipw_handle_data_packet(struct ipw_priv *priv,
        }
 }
 
-#ifdef CONFIG_IEEE80211_RADIOTAP
+#ifdef CONFIG_IPW2200_RADIOTAP
 static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
                                           struct ipw_rx_mem_buffer *rxb,
                                           struct ieee80211_rx_stats *stats)
@@ -7454,15 +7624,7 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
        /* Magic struct that slots into the radiotap header -- no reason
         * to build this manually element by element, we can write it much
         * more efficiently than we can parse it. ORDER MATTERS HERE */
-       struct ipw_rt_hdr {
-               struct ieee80211_radiotap_header rt_hdr;
-               u8 rt_flags;    /* radiotap packet flags */
-               u8 rt_rate;     /* rate in 500kb/s */
-               u16 rt_channel; /* channel in mhz */
-               u16 rt_chbitmask;       /* channel bitfield */
-               s8 rt_dbmsignal;        /* signal in dbM, kluged to signed */
-               u8 rt_antenna;  /* antenna number */
-       } *ipw_rt;
+       struct ipw_rt_hdr *ipw_rt;
 
        short len = le16_to_cpu(pkt->u.frame.length);
 
@@ -7519,10 +7681,12 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
             (1 << IEEE80211_RADIOTAP_RATE) |
             (1 << IEEE80211_RADIOTAP_CHANNEL) |
             (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
+            (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |
             (1 << IEEE80211_RADIOTAP_ANTENNA));
 
        /* Zero the flags, we'll add to them as we go */
        ipw_rt->rt_flags = 0;
+       ipw_rt->rt_tsf = 0ULL;
 
        /* Convert signal to DBM */
        ipw_rt->rt_dbmsignal = antsignal;
@@ -7604,6 +7768,214 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
 }
 #endif
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+#define ieee80211_is_probe_response(fc) \
+   ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && \
+    (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP )
+
+#define ieee80211_is_management(fc) \
+   ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)
+
+#define ieee80211_is_control(fc) \
+   ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL)
+
+#define ieee80211_is_data(fc) \
+   ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
+
+#define ieee80211_is_assoc_request(fc) \
+   ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ)
+
+#define ieee80211_is_reassoc_request(fc) \
+   ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ)
+
+static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
+                                     struct ipw_rx_mem_buffer *rxb,
+                                     struct ieee80211_rx_stats *stats)
+{
+       struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
+       struct ipw_rx_frame *frame = &pkt->u.frame;
+       struct ipw_rt_hdr *ipw_rt;
+
+       /* First cache any information we need before we overwrite
+        * the information provided in the skb from the hardware */
+       struct ieee80211_hdr *hdr;
+       u16 channel = frame->received_channel;
+       u8 phy_flags = frame->antennaAndPhy;
+       s8 signal = frame->rssi_dbm - IPW_RSSI_TO_DBM;
+       s8 noise = frame->noise;
+       u8 rate = frame->rate;
+       short len = le16_to_cpu(pkt->u.frame.length);
+       struct sk_buff *skb;
+       int hdr_only = 0;
+       u16 filter = priv->prom_priv->filter;
+
+       /* If the filter is set to not include Rx frames then return */
+       if (filter & IPW_PROM_NO_RX)
+               return;
+
+       /* We received data from the HW, so stop the watchdog */
+       priv->prom_net_dev->trans_start = jiffies;
+
+       if (unlikely((len + IPW_RX_FRAME_SIZE) > skb_tailroom(rxb->skb))) {
+               priv->prom_priv->ieee->stats.rx_errors++;
+               IPW_DEBUG_DROP("Corruption detected! Oh no!\n");
+               return;
+       }
+
+       /* We only process data packets if the interface is open */
+       if (unlikely(!netif_running(priv->prom_net_dev))) {
+               priv->prom_priv->ieee->stats.rx_dropped++;
+               IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
+               return;
+       }
+
+       /* Libpcap 0.9.3+ can handle variable length radiotap, so we'll use
+        * that now */
+       if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) {
+               /* FIXME: Should alloc bigger skb instead */
+               priv->prom_priv->ieee->stats.rx_dropped++;
+               IPW_DEBUG_DROP("Dropping too large packet in monitor\n");
+               return;
+       }
+
+       hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE;
+       if (ieee80211_is_management(le16_to_cpu(hdr->frame_ctl))) {
+               if (filter & IPW_PROM_NO_MGMT)
+                       return;
+               if (filter & IPW_PROM_MGMT_HEADER_ONLY)
+                       hdr_only = 1;
+       } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_ctl))) {
+               if (filter & IPW_PROM_NO_CTL)
+                       return;
+               if (filter & IPW_PROM_CTL_HEADER_ONLY)
+                       hdr_only = 1;
+       } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_ctl))) {
+               if (filter & IPW_PROM_NO_DATA)
+                       return;
+               if (filter & IPW_PROM_DATA_HEADER_ONLY)
+                       hdr_only = 1;
+       }
+
+       /* Copy the SKB since this is for the promiscuous side */
+       skb = skb_copy(rxb->skb, GFP_ATOMIC);
+       if (skb == NULL) {
+               IPW_ERROR("skb_clone failed for promiscuous copy.\n");
+               return;
+       }
+
+       /* copy the frame data to write after where the radiotap header goes */
+       ipw_rt = (void *)skb->data;
+
+       if (hdr_only)
+               len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+
+       memcpy(ipw_rt->payload, hdr, len);
+
+       /* Zero the radiotap static buffer  ...  We only need to zero the bytes
+        * NOT part of our real header, saves a little time.
+        *
+        * No longer necessary since we fill in all our data.  Purge before
+        * merging patch officially.
+        * memset(rxb->skb->data + sizeof(struct ipw_rt_hdr), 0,
+        *        IEEE80211_RADIOTAP_HDRLEN - sizeof(struct ipw_rt_hdr));
+        */
+
+       ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
+       ipw_rt->rt_hdr.it_pad = 0;      /* always good to zero */
+       ipw_rt->rt_hdr.it_len = sizeof(*ipw_rt);        /* total header+data */
+
+       /* Set the size of the skb to the size of the frame */
+       skb_put(skb, ipw_rt->rt_hdr.it_len + len);
+
+       /* Big bitfield of all the fields we provide in radiotap */
+       ipw_rt->rt_hdr.it_present =
+           ((1 << IEEE80211_RADIOTAP_FLAGS) |
+            (1 << IEEE80211_RADIOTAP_RATE) |
+            (1 << IEEE80211_RADIOTAP_CHANNEL) |
+            (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
+            (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |
+            (1 << IEEE80211_RADIOTAP_ANTENNA));
+
+       /* Zero the flags, we'll add to them as we go */
+       ipw_rt->rt_flags = 0;
+       ipw_rt->rt_tsf = 0ULL;
+
+       /* Convert to DBM */
+       ipw_rt->rt_dbmsignal = signal;
+       ipw_rt->rt_dbmnoise = noise;
+
+       /* Convert the channel data and set the flags */
+       ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(channel));
+       if (channel > 14) {     /* 802.11a */
+               ipw_rt->rt_chbitmask =
+                   cpu_to_le16((IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ));
+       } else if (phy_flags & (1 << 5)) {      /* 802.11b */
+               ipw_rt->rt_chbitmask =
+                   cpu_to_le16((IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ));
+       } else {                /* 802.11g */
+               ipw_rt->rt_chbitmask =
+                   (IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ);
+       }
+
+       /* set the rate in multiples of 500k/s */
+       switch (rate) {
+       case IPW_TX_RATE_1MB:
+               ipw_rt->rt_rate = 2;
+               break;
+       case IPW_TX_RATE_2MB:
+               ipw_rt->rt_rate = 4;
+               break;
+       case IPW_TX_RATE_5MB:
+               ipw_rt->rt_rate = 10;
+               break;
+       case IPW_TX_RATE_6MB:
+               ipw_rt->rt_rate = 12;
+               break;
+       case IPW_TX_RATE_9MB:
+               ipw_rt->rt_rate = 18;
+               break;
+       case IPW_TX_RATE_11MB:
+               ipw_rt->rt_rate = 22;
+               break;
+       case IPW_TX_RATE_12MB:
+               ipw_rt->rt_rate = 24;
+               break;
+       case IPW_TX_RATE_18MB:
+               ipw_rt->rt_rate = 36;
+               break;
+       case IPW_TX_RATE_24MB:
+               ipw_rt->rt_rate = 48;
+               break;
+       case IPW_TX_RATE_36MB:
+               ipw_rt->rt_rate = 72;
+               break;
+       case IPW_TX_RATE_48MB:
+               ipw_rt->rt_rate = 96;
+               break;
+       case IPW_TX_RATE_54MB:
+               ipw_rt->rt_rate = 108;
+               break;
+       default:
+               ipw_rt->rt_rate = 0;
+               break;
+       }
+
+       /* antenna number */
+       ipw_rt->rt_antenna = (phy_flags & 3);
+
+       /* set the preamble flag if we have it */
+       if (phy_flags & (1 << 6))
+               ipw_rt->rt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
+
+       IPW_DEBUG_RX("Rx packet of %d bytes.\n", skb->len);
+
+       if (!ieee80211_rx(priv->prom_priv->ieee, skb, stats)) {
+               priv->prom_priv->ieee->stats.rx_errors++;
+               dev_kfree_skb_any(skb);
+       }
+}
+#endif
+
 static int is_network_packet(struct ipw_priv *priv,
                                    struct ieee80211_hdr_4addr *header)
 {
@@ -7799,8 +8171,7 @@ static void ipw_rx(struct ipw_priv *priv)
                switch (pkt->header.message_type) {
                case RX_FRAME_TYPE:     /* 802.11 frame */  {
                                struct ieee80211_rx_stats stats = {
-                                       .rssi =
-                                           le16_to_cpu(pkt->u.frame.rssi_dbm) -
+                                       .rssi = pkt->u.frame.rssi_dbm -
                                            IPW_RSSI_TO_DBM,
                                        .signal =
                                            le16_to_cpu(pkt->u.frame.rssi_dbm) -
@@ -7830,15 +8201,21 @@ static void ipw_rx(struct ipw_priv *priv)
 
                                priv->rx_packets++;
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       if (priv->prom_net_dev && netif_running(priv->prom_net_dev))
+               ipw_handle_promiscuous_rx(priv, rxb, &stats);
+#endif
+
 #ifdef CONFIG_IPW2200_MONITOR
                                if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
-#ifdef CONFIG_IEEE80211_RADIOTAP
-                                       ipw_handle_data_packet_monitor(priv,
-                                                                      rxb,
-                                                                      &stats);
+#ifdef CONFIG_IPW2200_RADIOTAP
+
+                ipw_handle_data_packet_monitor(priv,
+                                              rxb,
+                                              &stats);
 #else
-                                       ipw_handle_data_packet(priv, rxb,
-                                                              &stats);
+               ipw_handle_data_packet(priv, rxb,
+                                      &stats);
 #endif
                                        break;
                                }
@@ -8004,10 +8381,10 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
                IPW_DEBUG_INFO("Bind to static channel %d\n", channel);
                /* TODO: Validate that provided channel is in range */
        }
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        ipw_qos_init(priv, qos_enable, qos_burst_enable,
                     burst_duration_CCK, burst_duration_OFDM);
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
        switch (mode) {
        case 1:
@@ -8018,7 +8395,7 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
 #ifdef CONFIG_IPW2200_MONITOR
        case 2:
                priv->ieee->iw_mode = IW_MODE_MONITOR;
-#ifdef CONFIG_IEEE80211_RADIOTAP
+#ifdef CONFIG_IPW2200_RADIOTAP
                priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
 #else
                priv->net_dev->type = ARPHRD_IEEE80211;
@@ -8229,9 +8606,26 @@ static int ipw_wx_get_freq(struct net_device *dev,
         * configured CHANNEL then return that; otherwise return ANY */
        mutex_lock(&priv->mutex);
        if (priv->config & CFG_STATIC_CHANNEL ||
-           priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED))
-               wrqu->freq.m = priv->channel;
-       else
+           priv->status & (STATUS_ASSOCIATING | STATUS_ASSOCIATED)) {
+               int i;
+
+               i = ieee80211_channel_to_index(priv->ieee, priv->channel);
+               BUG_ON(i == -1);
+               wrqu->freq.e = 1;
+
+               switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) {
+               case IEEE80211_52GHZ_BAND:
+                       wrqu->freq.m = priv->ieee->geo.a[i].freq * 100000;
+                       break;
+
+               case IEEE80211_24GHZ_BAND:
+                       wrqu->freq.m = priv->ieee->geo.bg[i].freq * 100000;
+                       break;
+
+               default:
+                       BUG();
+               }
+       } else
                wrqu->freq.m = 0;
 
        mutex_unlock(&priv->mutex);
@@ -8273,7 +8667,7 @@ static int ipw_wx_set_mode(struct net_device *dev,
                priv->net_dev->type = ARPHRD_ETHER;
 
        if (wrqu->mode == IW_MODE_MONITOR)
-#ifdef CONFIG_IEEE80211_RADIOTAP
+#ifdef CONFIG_IPW2200_RADIOTAP
                priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
 #else
                priv->net_dev->type = ARPHRD_IEEE80211;
@@ -8487,42 +8881,36 @@ static int ipw_wx_set_essid(struct net_device *dev,
                            union iwreq_data *wrqu, char *extra)
 {
        struct ipw_priv *priv = ieee80211_priv(dev);
-       char *essid = "";       /* ANY */
-       int length = 0;
-       mutex_lock(&priv->mutex);
-       if (wrqu->essid.flags && wrqu->essid.length) {
-               length = wrqu->essid.length - 1;
-               essid = extra;
-       }
-       if (length == 0) {
-               IPW_DEBUG_WX("Setting ESSID to ANY\n");
-               if ((priv->config & CFG_STATIC_ESSID) &&
-                   !(priv->status & (STATUS_ASSOCIATED |
-                                     STATUS_ASSOCIATING))) {
-                       IPW_DEBUG_ASSOC("Attempting to associate with new "
-                                       "parameters.\n");
-                       priv->config &= ~CFG_STATIC_ESSID;
-                       ipw_associate(priv);
-               }
-               mutex_unlock(&priv->mutex);
-               return 0;
-       }
+        int length;
+
+        mutex_lock(&priv->mutex);
 
-       length = min(length, IW_ESSID_MAX_SIZE);
+        if (!wrqu->essid.flags)
+        {
+                IPW_DEBUG_WX("Setting ESSID to ANY\n");
+                ipw_disassociate(priv);
+                priv->config &= ~CFG_STATIC_ESSID;
+                ipw_associate(priv);
+                mutex_unlock(&priv->mutex);
+                return 0;
+        }
+
+       length = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
 
        priv->config |= CFG_STATIC_ESSID;
 
-       if (priv->essid_len == length && !memcmp(priv->essid, extra, length)) {
+       if (priv->essid_len == length && !memcmp(priv->essid, extra, length)
+           && (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) {
                IPW_DEBUG_WX("ESSID set to current ESSID.\n");
                mutex_unlock(&priv->mutex);
                return 0;
        }
 
-       IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(essid, length),
+       IPW_DEBUG_WX("Setting ESSID: '%s' (%d)\n", escape_essid(extra, length),
                     length);
 
        priv->essid_len = length;
-       memcpy(priv->essid, essid, priv->essid_len);
+       memcpy(priv->essid, extra, priv->essid_len);
 
        /* Network configuration changed -- force [re]association */
        IPW_DEBUG_ASSOC("[re]association triggered due to ESSID change.\n");
@@ -8584,7 +8972,7 @@ static int ipw_wx_get_nick(struct net_device *dev,
        struct ipw_priv *priv = ieee80211_priv(dev);
        IPW_DEBUG_WX("Getting nick\n");
        mutex_lock(&priv->mutex);
-       wrqu->data.length = strlen(priv->nick) + 1;
+       wrqu->data.length = strlen(priv->nick);
        memcpy(extra, priv->nick, wrqu->data.length);
        wrqu->data.flags = 1;   /* active */
        mutex_unlock(&priv->mutex);
@@ -8903,13 +9291,13 @@ static int ipw_wx_set_retry(struct net_device *dev,
        if (!(wrqu->retry.flags & IW_RETRY_LIMIT))
                return 0;
 
-       if (wrqu->retry.value < 0 || wrqu->retry.value > 255)
+       if (wrqu->retry.value < 0 || wrqu->retry.value >= 255)
                return -EINVAL;
 
        mutex_lock(&priv->mutex);
-       if (wrqu->retry.flags & IW_RETRY_MIN)
+       if (wrqu->retry.flags & IW_RETRY_SHORT)
                priv->short_retry_limit = (u8) wrqu->retry.value;
-       else if (wrqu->retry.flags & IW_RETRY_MAX)
+       else if (wrqu->retry.flags & IW_RETRY_LONG)
                priv->long_retry_limit = (u8) wrqu->retry.value;
        else {
                priv->short_retry_limit = (u8) wrqu->retry.value;
@@ -8938,11 +9326,11 @@ static int ipw_wx_get_retry(struct net_device *dev,
                return -EINVAL;
        }
 
-       if (wrqu->retry.flags & IW_RETRY_MAX) {
-               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+       if (wrqu->retry.flags & IW_RETRY_LONG) {
+               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
                wrqu->retry.value = priv->long_retry_limit;
-       } else if (wrqu->retry.flags & IW_RETRY_MIN) {
-               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
+       } else if (wrqu->retry.flags & IW_RETRY_SHORT) {
+               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
                wrqu->retry.value = priv->short_retry_limit;
        } else {
                wrqu->retry.flags = IW_RETRY_LIMIT;
@@ -9026,20 +9414,24 @@ static int ipw_wx_set_scan(struct net_device *dev,
                           union iwreq_data *wrqu, char *extra)
 {
        struct ipw_priv *priv = ieee80211_priv(dev);
-       struct iw_scan_req *req = NULL;
-       if (wrqu->data.length
-           && wrqu->data.length == sizeof(struct iw_scan_req)) {
-               req = (struct iw_scan_req *)extra;
+       struct iw_scan_req *req = (struct iw_scan_req *)extra;
+
+       if (wrqu->data.length == sizeof(struct iw_scan_req)) {
                if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                        ipw_request_direct_scan(priv, req->essid,
                                                req->essid_len);
                        return 0;
                }
+               if (req->scan_type == IW_SCAN_TYPE_PASSIVE) {
+                       queue_work(priv->workqueue,
+                                  &priv->request_passive_scan);
+                       return 0;
+               }
        }
 
        IPW_DEBUG_WX("Start scan\n");
 
-       queue_work(priv->workqueue, &priv->request_scan);
+       queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
 
        return 0;
 }
@@ -9375,7 +9767,7 @@ static int ipw_wx_set_monitor(struct net_device *dev,
        IPW_DEBUG_WX("SET MONITOR: %d %d\n", enable, parms[1]);
        if (enable) {
                if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
-#ifdef CONFIG_IEEE80211_RADIOTAP
+#ifdef CONFIG_IPW2200_RADIOTAP
                        priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
 #else
                        priv->net_dev->type = ARPHRD_IEEE80211;
@@ -9396,7 +9788,7 @@ static int ipw_wx_set_monitor(struct net_device *dev,
        return 0;
 }
 
-#endif                         // CONFIG_IPW2200_MONITOR
+#endif                         /* CONFIG_IPW2200_MONITOR */
 
 static int ipw_wx_reset(struct net_device *dev,
                        struct iw_request_info *info,
@@ -9639,7 +10031,7 @@ static  void init_sys_config(struct ipw_sys_config *sys_config)
        sys_config->dot11g_auto_detection = 0;
        sys_config->enable_cts_to_self = 0;
        sys_config->bt_coexist_collision_thr = 0;
-       sys_config->pass_noise_stats_to_host = 1;       //1 -- fix for 256
+       sys_config->pass_noise_stats_to_host = 1;       /* 1 -- fix for 256 */
        sys_config->silence_threshold = 0x1e;
 }
 
@@ -9677,7 +10069,7 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
            txb->fragments[0]->data;
        int i = 0;
        struct tfd_frame *tfd;
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        int tx_id = ipw_get_tx_queue_number(priv, pri);
        struct clx2_tx_queue *txq = &priv->txq[tx_id];
 #else
@@ -9743,7 +10135,7 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
                switch (priv->ieee->sec.level) {
                case SEC_LEVEL_3:
                        tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |=
-                           IEEE80211_FCTL_PROTECTED;
+                           cpu_to_le16(IEEE80211_FCTL_PROTECTED);
                        /* XXX: ACK flag must be set for CCMP even if it
                         * is a multicast/broadcast packet, because CCMP
                         * group communication encrypted by GTK is
@@ -9758,14 +10150,14 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
                        break;
                case SEC_LEVEL_2:
                        tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |=
-                           IEEE80211_FCTL_PROTECTED;
+                           cpu_to_le16(IEEE80211_FCTL_PROTECTED);
                        tfd->u.data.tx_flags &= ~DCT_FLAG_NO_WEP;
                        tfd->u.data.tx_flags_ext |= DCT_FLAG_EXT_SECURITY_TKIP;
                        tfd->u.data.key_index = DCT_WEP_INDEX_USE_IMMEDIATE;
                        break;
                case SEC_LEVEL_1:
                        tfd->u.data.tfd.tfd_24.mchdr.frame_ctl |=
-                           IEEE80211_FCTL_PROTECTED;
+                           cpu_to_le16(IEEE80211_FCTL_PROTECTED);
                        tfd->u.data.key_index = priv->ieee->tx_keyidx;
                        if (priv->ieee->sec.key_sizes[priv->ieee->tx_keyidx] <=
                            40)
@@ -9784,10 +10176,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
                /* No hardware encryption */
                tfd->u.data.tx_flags |= DCT_FLAG_NO_WEP;
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        if (fc & IEEE80211_STYPE_QOS_DATA)
                ipw_qos_set_tx_queue_command(priv, pri, &(tfd->u.data));
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
        /* payload */
        tfd->u.data.num_chunks = cpu_to_le32(min((u8) (NUM_TFD_CHUNKS - 2),
@@ -9867,12 +10259,12 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
 static int ipw_net_is_queue_full(struct net_device *dev, int pri)
 {
        struct ipw_priv *priv = ieee80211_priv(dev);
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        int tx_id = ipw_get_tx_queue_number(priv, pri);
        struct clx2_tx_queue *txq = &priv->txq[tx_id];
 #else
        struct clx2_tx_queue *txq = &priv->txq[0];
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
        if (ipw_queue_space(&txq->q) < txq->q.high_mark)
                return 1;
@@ -9880,6 +10272,88 @@ static int ipw_net_is_queue_full(struct net_device *dev, int pri)
        return 0;
 }
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
+                                     struct ieee80211_txb *txb)
+{
+       struct ieee80211_rx_stats dummystats;
+       struct ieee80211_hdr *hdr;
+       u8 n;
+       u16 filter = priv->prom_priv->filter;
+       int hdr_only = 0;
+
+       if (filter & IPW_PROM_NO_TX)
+               return;
+
+       memset(&dummystats, 0, sizeof(dummystats));
+
+       /* Filtering of fragment chains is done agains the first fragment */
+       hdr = (void *)txb->fragments[0]->data;
+       if (ieee80211_is_management(le16_to_cpu(hdr->frame_ctl))) {
+               if (filter & IPW_PROM_NO_MGMT)
+                       return;
+               if (filter & IPW_PROM_MGMT_HEADER_ONLY)
+                       hdr_only = 1;
+       } else if (ieee80211_is_control(le16_to_cpu(hdr->frame_ctl))) {
+               if (filter & IPW_PROM_NO_CTL)
+                       return;
+               if (filter & IPW_PROM_CTL_HEADER_ONLY)
+                       hdr_only = 1;
+       } else if (ieee80211_is_data(le16_to_cpu(hdr->frame_ctl))) {
+               if (filter & IPW_PROM_NO_DATA)
+                       return;
+               if (filter & IPW_PROM_DATA_HEADER_ONLY)
+                       hdr_only = 1;
+       }
+
+       for(n=0; n<txb->nr_frags; ++n) {
+               struct sk_buff *src = txb->fragments[n];
+               struct sk_buff *dst;
+               struct ieee80211_radiotap_header *rt_hdr;
+               int len;
+
+               if (hdr_only) {
+                       hdr = (void *)src->data;
+                       len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
+               } else
+                       len = src->len;
+
+               dst = alloc_skb(
+                       len + IEEE80211_RADIOTAP_HDRLEN, GFP_ATOMIC);
+               if (!dst) continue;
+
+               rt_hdr = (void *)skb_put(dst, sizeof(*rt_hdr));
+
+               rt_hdr->it_version = PKTHDR_RADIOTAP_VERSION;
+               rt_hdr->it_pad = 0;
+               rt_hdr->it_present = 0; /* after all, it's just an idea */
+               rt_hdr->it_present |=  (1 << IEEE80211_RADIOTAP_CHANNEL);
+
+               *(u16*)skb_put(dst, sizeof(u16)) = cpu_to_le16(
+                       ieee80211chan2mhz(priv->channel));
+               if (priv->channel > 14)         /* 802.11a */
+                       *(u16*)skb_put(dst, sizeof(u16)) =
+                               cpu_to_le16(IEEE80211_CHAN_OFDM |
+                                            IEEE80211_CHAN_5GHZ);
+               else if (priv->ieee->mode == IEEE_B) /* 802.11b */
+                       *(u16*)skb_put(dst, sizeof(u16)) =
+                               cpu_to_le16(IEEE80211_CHAN_CCK |
+                                            IEEE80211_CHAN_2GHZ);
+               else            /* 802.11g */
+                       *(u16*)skb_put(dst, sizeof(u16)) =
+                               cpu_to_le16(IEEE80211_CHAN_OFDM |
+                                IEEE80211_CHAN_2GHZ);
+
+               rt_hdr->it_len = dst->len;
+
+               memcpy(skb_put(dst, len), src->data, len);
+
+               if (!ieee80211_rx(priv->prom_priv->ieee, dst, &dummystats))
+                       dev_kfree_skb_any(dst);
+       }
+}
+#endif
+
 static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
                                   struct net_device *dev, int pri)
 {
@@ -9897,6 +10371,11 @@ static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
                goto fail_unlock;
        }
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       if (rtap_iface && netif_running(priv->prom_net_dev))
+               ipw_handle_promiscuous_tx(priv, txb);
+#endif
+
        ret = ipw_tx_skb(priv, txb, pri);
        if (ret == NETDEV_TX_OK)
                __ipw_led_activity_on(priv);
@@ -10001,7 +10480,7 @@ static int ipw_ethtool_set_eeprom(struct net_device *dev,
        return 0;
 }
 
-static struct ethtool_ops ipw_ethtool_ops = {
+static const struct ethtool_ops ipw_ethtool_ops = {
        .get_link = ipw_ethtool_get_link,
        .get_drvinfo = ipw_ethtool_get_drvinfo,
        .get_eeprom_len = ipw_ethtool_get_eeprom_len,
@@ -10009,7 +10488,7 @@ static struct ethtool_ops ipw_ethtool_ops = {
        .set_eeprom = ipw_ethtool_set_eeprom,
 };
 
-static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t ipw_isr(int irq, void *data)
 {
        struct ipw_priv *priv = data;
        u32 inta, inta_mask;
@@ -10017,7 +10496,7 @@ static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
        if (!priv)
                return IRQ_NONE;
 
-       spin_lock(&priv->lock);
+       spin_lock(&priv->irq_lock);
 
        if (!(priv->status & STATUS_INT_ENABLED)) {
                /* Shared IRQ */
@@ -10039,7 +10518,7 @@ static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
        }
 
        /* tell the device to stop sending interrupts */
-       ipw_disable_interrupts(priv);
+       __ipw_disable_interrupts(priv);
 
        /* ack current interrupts */
        inta &= (IPW_INTA_MASK_ALL & inta_mask);
@@ -10050,11 +10529,11 @@ static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs)
 
        tasklet_schedule(&priv->irq_tasklet);
 
-       spin_unlock(&priv->lock);
+       spin_unlock(&priv->irq_lock);
 
        return IRQ_HANDLED;
       none:
-       spin_unlock(&priv->lock);
+       spin_unlock(&priv->irq_lock);
        return IRQ_NONE;
 }
 
@@ -10089,11 +10568,12 @@ static void ipw_rf_kill(void *adapter)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static void ipw_bg_rf_kill(void *data)
+static void ipw_bg_rf_kill(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, rf_kill.work);
        mutex_lock(&priv->mutex);
-       ipw_rf_kill(data);
+       ipw_rf_kill(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -10124,11 +10604,12 @@ static void ipw_link_up(struct ipw_priv *priv)
                queue_delayed_work(priv->workqueue, &priv->request_scan, HZ);
 }
 
-static void ipw_bg_link_up(void *data)
+static void ipw_bg_link_up(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, link_up);
        mutex_lock(&priv->mutex);
-       ipw_link_up(data);
+       ipw_link_up(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -10148,15 +10629,16 @@ static void ipw_link_down(struct ipw_priv *priv)
 
        if (!(priv->status & STATUS_EXIT_PENDING)) {
                /* Queue up another scan... */
-               queue_work(priv->workqueue, &priv->request_scan);
+               queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
        }
 }
 
-static void ipw_bg_link_down(void *data)
+static void ipw_bg_link_down(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, link_down);
        mutex_lock(&priv->mutex);
-       ipw_link_down(data);
+       ipw_link_down(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -10168,37 +10650,31 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
        init_waitqueue_head(&priv->wait_command_queue);
        init_waitqueue_head(&priv->wait_state);
 
-       INIT_WORK(&priv->adhoc_check, ipw_bg_adhoc_check, priv);
-       INIT_WORK(&priv->associate, ipw_bg_associate, priv);
-       INIT_WORK(&priv->disassociate, ipw_bg_disassociate, priv);
-       INIT_WORK(&priv->system_config, ipw_system_config, priv);
-       INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish, priv);
-       INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart, priv);
-       INIT_WORK(&priv->rf_kill, ipw_bg_rf_kill, priv);
-       INIT_WORK(&priv->up, (void (*)(void *))ipw_bg_up, priv);
-       INIT_WORK(&priv->down, (void (*)(void *))ipw_bg_down, priv);
-       INIT_WORK(&priv->request_scan,
-                 (void (*)(void *))ipw_request_scan, priv);
-       INIT_WORK(&priv->gather_stats,
-                 (void (*)(void *))ipw_bg_gather_stats, priv);
-       INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_bg_abort_scan, priv);
-       INIT_WORK(&priv->roam, ipw_bg_roam, priv);
-       INIT_WORK(&priv->scan_check, ipw_bg_scan_check, priv);
-       INIT_WORK(&priv->link_up, (void (*)(void *))ipw_bg_link_up, priv);
-       INIT_WORK(&priv->link_down, (void (*)(void *))ipw_bg_link_down, priv);
-       INIT_WORK(&priv->led_link_on, (void (*)(void *))ipw_bg_led_link_on,
-                 priv);
-       INIT_WORK(&priv->led_link_off, (void (*)(void *))ipw_bg_led_link_off,
-                 priv);
-       INIT_WORK(&priv->led_act_off, (void (*)(void *))ipw_bg_led_activity_off,
-                 priv);
-       INIT_WORK(&priv->merge_networks,
-                 (void (*)(void *))ipw_merge_adhoc_network, priv);
-
-#ifdef CONFIG_IPW_QOS
-       INIT_WORK(&priv->qos_activate, (void (*)(void *))ipw_bg_qos_activate,
-                 priv);
-#endif                         /* CONFIG_IPW_QOS */
+       INIT_DELAYED_WORK(&priv->adhoc_check, ipw_bg_adhoc_check);
+       INIT_WORK(&priv->associate, ipw_bg_associate);
+       INIT_WORK(&priv->disassociate, ipw_bg_disassociate);
+       INIT_WORK(&priv->system_config, ipw_system_config);
+       INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish);
+       INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart);
+       INIT_DELAYED_WORK(&priv->rf_kill, ipw_bg_rf_kill);
+       INIT_WORK(&priv->up, ipw_bg_up);
+       INIT_WORK(&priv->down, ipw_bg_down);
+       INIT_DELAYED_WORK(&priv->request_scan, ipw_request_scan);
+       INIT_WORK(&priv->request_passive_scan, ipw_request_passive_scan);
+       INIT_DELAYED_WORK(&priv->gather_stats, ipw_bg_gather_stats);
+       INIT_WORK(&priv->abort_scan, ipw_bg_abort_scan);
+       INIT_WORK(&priv->roam, ipw_bg_roam);
+       INIT_DELAYED_WORK(&priv->scan_check, ipw_bg_scan_check);
+       INIT_WORK(&priv->link_up, ipw_bg_link_up);
+       INIT_WORK(&priv->link_down, ipw_bg_link_down);
+       INIT_DELAYED_WORK(&priv->led_link_on, ipw_bg_led_link_on);
+       INIT_DELAYED_WORK(&priv->led_link_off, ipw_bg_led_link_off);
+       INIT_DELAYED_WORK(&priv->led_act_off, ipw_bg_led_activity_off);
+       INIT_WORK(&priv->merge_networks, ipw_merge_adhoc_network);
+
+#ifdef CONFIG_IPW2200_QOS
+       INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate);
+#endif                         /* CONFIG_IPW2200_QOS */
 
        tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
                     ipw_irq_tasklet, (unsigned long)priv);
@@ -10344,12 +10820,21 @@ static int ipw_config(struct ipw_priv *priv)
                            |= CFG_BT_COEXISTENCE_OOB;
        }
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
+               priv->sys_config.accept_all_data_frames = 1;
+               priv->sys_config.accept_non_directed_frames = 1;
+               priv->sys_config.accept_all_mgmt_bcpr = 1;
+               priv->sys_config.accept_all_mgmt_frames = 1;
+       }
+#endif
+
        if (priv->ieee->iw_mode == IW_MODE_ADHOC)
                priv->sys_config.answer_broadcast_ssid_probe = 1;
        else
                priv->sys_config.answer_broadcast_ssid_probe = 0;
 
-       if (ipw_send_system_config(priv, &priv->sys_config))
+       if (ipw_send_system_config(priv))
                goto error;
 
        init_supported_rates(priv, &priv->rates);
@@ -10361,10 +10846,10 @@ static int ipw_config(struct ipw_priv *priv)
                if (ipw_send_rts_threshold(priv, priv->rts_threshold))
                        goto error;
        }
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        IPW_DEBUG_QOS("QoS: call ipw_qos_activate\n");
        ipw_qos_activate(priv, NULL);
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
        if (ipw_set_random_seed(priv))
                goto error;
@@ -10721,7 +11206,8 @@ static int ipw_up(struct ipw_priv *priv)
 
                        /* If configure to try and auto-associate, kick
                         * off a scan. */
-                       queue_work(priv->workqueue, &priv->request_scan);
+                       queue_delayed_work(priv->workqueue,
+                                          &priv->request_scan, 0);
 
                        return 0;
                }
@@ -10742,11 +11228,12 @@ static int ipw_up(struct ipw_priv *priv)
        return -EIO;
 }
 
-static void ipw_bg_up(void *data)
+static void ipw_bg_up(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, up);
        mutex_lock(&priv->mutex);
-       ipw_up(data);
+       ipw_up(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -10813,11 +11300,12 @@ static void ipw_down(struct ipw_priv *priv)
        ipw_led_radio_off(priv);
 }
 
-static void ipw_bg_down(void *data)
+static void ipw_bg_down(struct work_struct *work)
 {
-       struct ipw_priv *priv = data;
+       struct ipw_priv *priv =
+               container_of(work, struct ipw_priv, down);
        mutex_lock(&priv->mutex);
-       ipw_down(data);
+       ipw_down(priv);
        mutex_unlock(&priv->mutex);
 }
 
@@ -10887,6 +11375,10 @@ static struct attribute *ipw_sysfs_entries[] = {
        &dev_attr_led.attr,
        &dev_attr_speed_scan.attr,
        &dev_attr_net_stats.attr,
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       &dev_attr_rtap_iface.attr,
+       &dev_attr_rtap_filter.attr,
+#endif
        NULL
 };
 
@@ -10895,6 +11387,109 @@ static struct attribute_group ipw_attribute_group = {
        .attrs = ipw_sysfs_entries,
 };
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+static int ipw_prom_open(struct net_device *dev)
+{
+       struct ipw_prom_priv *prom_priv = ieee80211_priv(dev);
+       struct ipw_priv *priv = prom_priv->priv;
+
+       IPW_DEBUG_INFO("prom dev->open\n");
+       netif_carrier_off(dev);
+       netif_stop_queue(dev);
+
+       if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
+               priv->sys_config.accept_all_data_frames = 1;
+               priv->sys_config.accept_non_directed_frames = 1;
+               priv->sys_config.accept_all_mgmt_bcpr = 1;
+               priv->sys_config.accept_all_mgmt_frames = 1;
+
+               ipw_send_system_config(priv);
+       }
+
+       return 0;
+}
+
+static int ipw_prom_stop(struct net_device *dev)
+{
+       struct ipw_prom_priv *prom_priv = ieee80211_priv(dev);
+       struct ipw_priv *priv = prom_priv->priv;
+
+       IPW_DEBUG_INFO("prom dev->stop\n");
+
+       if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
+               priv->sys_config.accept_all_data_frames = 0;
+               priv->sys_config.accept_non_directed_frames = 0;
+               priv->sys_config.accept_all_mgmt_bcpr = 0;
+               priv->sys_config.accept_all_mgmt_frames = 0;
+
+               ipw_send_system_config(priv);
+       }
+
+       return 0;
+}
+
+static int ipw_prom_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+       IPW_DEBUG_INFO("prom dev->xmit\n");
+       netif_stop_queue(dev);
+       return -EOPNOTSUPP;
+}
+
+static struct net_device_stats *ipw_prom_get_stats(struct net_device *dev)
+{
+       struct ipw_prom_priv *prom_priv = ieee80211_priv(dev);
+       return &prom_priv->ieee->stats;
+}
+
+static int ipw_prom_alloc(struct ipw_priv *priv)
+{
+       int rc = 0;
+
+       if (priv->prom_net_dev)
+               return -EPERM;
+
+       priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv));
+       if (priv->prom_net_dev == NULL)
+               return -ENOMEM;
+
+       priv->prom_priv = ieee80211_priv(priv->prom_net_dev);
+       priv->prom_priv->ieee = netdev_priv(priv->prom_net_dev);
+       priv->prom_priv->priv = priv;
+
+       strcpy(priv->prom_net_dev->name, "rtap%d");
+
+       priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
+       priv->prom_net_dev->open = ipw_prom_open;
+       priv->prom_net_dev->stop = ipw_prom_stop;
+       priv->prom_net_dev->get_stats = ipw_prom_get_stats;
+       priv->prom_net_dev->hard_start_xmit = ipw_prom_hard_start_xmit;
+
+       priv->prom_priv->ieee->iw_mode = IW_MODE_MONITOR;
+
+       rc = register_netdev(priv->prom_net_dev);
+       if (rc) {
+               free_ieee80211(priv->prom_net_dev);
+               priv->prom_net_dev = NULL;
+               return rc;
+       }
+
+       return 0;
+}
+
+static void ipw_prom_free(struct ipw_priv *priv)
+{
+       if (!priv->prom_net_dev)
+               return;
+
+       unregister_netdev(priv->prom_net_dev);
+       free_ieee80211(priv->prom_net_dev);
+
+       priv->prom_net_dev = NULL;
+}
+
+#endif
+
+
 static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        int err = 0;
@@ -10915,9 +11510,8 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        priv->net_dev = net_dev;
        priv->pci_dev = pdev;
-#ifdef CONFIG_IPW2200_DEBUG
        ipw_debug_level = debug;
-#endif
+       spin_lock_init(&priv->irq_lock);
        spin_lock_init(&priv->lock);
        for (i = 0; i < IPW_IBSS_MAC_HASH_SIZE; i++)
                INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
@@ -10971,7 +11565,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        ipw_sw_reset(priv, 1);
 
-       err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, priv);
+       err = request_irq(pdev->irq, ipw_isr, IRQF_SHARED, DRV_NAME, priv);
        if (err) {
                IPW_ERROR("Error allocating IRQ %d\n", pdev->irq);
                goto out_destroy_workqueue;
@@ -10986,12 +11580,12 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        priv->ieee->set_security = shim__set_security;
        priv->ieee->is_queue_full = ipw_net_is_queue_full;
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_QOS
        priv->ieee->is_qos_active = ipw_is_qos_active;
        priv->ieee->handle_probe_response = ipw_handle_beacon;
        priv->ieee->handle_beacon = ipw_handle_probe_response;
        priv->ieee->handle_assoc_response = ipw_handle_assoc_response;
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
        priv->ieee->perfect_rssi = -20;
        priv->ieee->worst_rssi = -85;
@@ -11025,6 +11619,18 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto out_remove_sysfs;
        }
 
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       if (rtap_iface) {
+               err = ipw_prom_alloc(priv);
+               if (err) {
+                       IPW_ERROR("Failed to register promiscuous network "
+                                 "device (error %d).\n", err);
+                       unregister_netdev(priv->net_dev);
+                       goto out_remove_sysfs;
+               }
+       }
+#endif
+
        printk(KERN_INFO DRV_NAME ": Detected geography %s (%d 802.11bg "
               "channels, %d 802.11a channels)\n",
               priv->ieee->geo.name, priv->ieee->geo.bg_channels,
@@ -11099,10 +11705,12 @@ static void ipw_pci_remove(struct pci_dev *pdev)
                }
        }
 
-       if (priv->error) {
-               ipw_free_error_log(priv->error);
-               priv->error = NULL;
-       }
+       kfree(priv->error);
+       priv->error = NULL;
+
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+       ipw_prom_free(priv);
+#endif
 
        free_irq(pdev->irq, priv);
        iounmap(priv->hw_base);
@@ -11167,6 +11775,16 @@ static int ipw_pci_resume(struct pci_dev *pdev)
 }
 #endif
 
+static void ipw_pci_shutdown(struct pci_dev *pdev)
+{
+       struct ipw_priv *priv = pci_get_drvdata(pdev);
+
+       /* Take down the device; powers it off, etc. */
+       ipw_down(priv);
+
+       pci_disable_device(pdev);
+}
+
 /* driver initialization stuff */
 static struct pci_driver ipw_driver = {
        .name = DRV_NAME,
@@ -11177,6 +11795,7 @@ static struct pci_driver ipw_driver = {
        .suspend = ipw_pci_suspend,
        .resume = ipw_pci_resume,
 #endif
+       .shutdown = ipw_pci_shutdown,
 };
 
 static int __init ipw_init(void)
@@ -11186,7 +11805,7 @@ static int __init ipw_init(void)
        printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION ", " DRV_VERSION "\n");
        printk(KERN_INFO DRV_NAME ": " DRV_COPYRIGHT "\n");
 
-       ret = pci_module_init(&ipw_driver);
+       ret = pci_register_driver(&ipw_driver);
        if (ret) {
                IPW_ERROR("Unable to initialize PCI module\n");
                return ret;
@@ -11220,15 +11839,18 @@ MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)");
 module_param(led, int, 0444);
 MODULE_PARM_DESC(led, "enable led control on some systems (default 0 off)\n");
 
-#ifdef CONFIG_IPW2200_DEBUG
 module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "debug output mask");
-#endif
 
 module_param(channel, int, 0444);
 MODULE_PARM_DESC(channel, "channel to limit associate to (default 0 [ANY])");
 
-#ifdef CONFIG_IPW_QOS
+#ifdef CONFIG_IPW2200_PROMISCUOUS
+module_param(rtap_iface, int, 0444);
+MODULE_PARM_DESC(rtap_iface, "create the rtap interface (1 - create, default 0)");
+#endif
+
+#ifdef CONFIG_IPW2200_QOS
 module_param(qos_enable, int, 0444);
 MODULE_PARM_DESC(qos_enable, "enable all QoS functionalitis");
 
@@ -11243,7 +11865,7 @@ MODULE_PARM_DESC(burst_duration_CCK, "set CCK burst value");
 
 module_param(burst_duration_OFDM, int, 0444);
 MODULE_PARM_DESC(burst_duration_OFDM, "set OFDM burst value");
-#endif                         /* CONFIG_IPW_QOS */
+#endif                         /* CONFIG_IPW2200_QOS */
 
 #ifdef CONFIG_IPW2200_MONITOR
 module_param(mode, int, 0444);