]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/iwlwifi/iwl4965-base.c
iwlwifi: fix bug to show hidden APs during scan
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / iwlwifi / iwl4965-base.c
index af95626a611229739bf78c2fc6d42f05af1e81c5..0b7335181719da86a8356f8e321903fefc90cf05 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
+ * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
  *
  * Portions of this file are derived from the ipw3945 project, as well
  * as portions of the ieee80211 subsystem header files.
@@ -45,6 +45,7 @@
 
 #include <asm/div64.h>
 
+#include "iwl-eeprom.h"
 #include "iwl-core.h"
 #include "iwl-4965.h"
 #include "iwl-helpers.h"
@@ -194,25 +195,6 @@ int iwl4965_queue_space(const struct iwl4965_queue *q)
        return s;
 }
 
-/**
- * iwl4965_queue_inc_wrap - increment queue index, wrap back to beginning
- * @index -- current index
- * @n_bd -- total number of entries in queue (must be power of 2)
- */
-static inline int iwl4965_queue_inc_wrap(int index, int n_bd)
-{
-       return ++index & (n_bd - 1);
-}
-
-/**
- * iwl4965_queue_dec_wrap - decrement queue index, wrap back to end
- * @index -- current index
- * @n_bd -- total number of entries in queue (must be power of 2)
- */
-static inline int iwl4965_queue_dec_wrap(int index, int n_bd)
-{
-       return --index & (n_bd - 1);
-}
 
 static inline int x2_queue_used(const struct iwl4965_queue *q, int i)
 {
@@ -241,8 +223,8 @@ static int iwl4965_queue_init(struct iwl4965_priv *priv, struct iwl4965_queue *q
        q->n_window = slots_num;
        q->id = id;
 
-       /* count must be power-of-two size, otherwise iwl4965_queue_inc_wrap
-        * and iwl4965_queue_dec_wrap are broken. */
+       /* count must be power-of-two size, otherwise iwl_queue_inc_wrap
+        * and iwl_queue_dec_wrap are broken. */
        BUG_ON(!is_power_of_2(count));
 
        /* slots_num must be power-of-two size, otherwise
@@ -342,7 +324,7 @@ int iwl4965_tx_queue_init(struct iwl4965_priv *priv,
        txq->need_update = 0;
 
        /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
-        * iwl4965_queue_inc_wrap and iwl4965_queue_dec_wrap are broken. */
+        * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
        BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
 
        /* Initialize queue's high/low-water marks, and head/tail indexes */
@@ -373,7 +355,7 @@ void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *t
 
        /* first, empty all BD's */
        for (; q->write_ptr != q->read_ptr;
-            q->read_ptr = iwl4965_queue_inc_wrap(q->read_ptr, q->n_bd))
+            q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
                iwl4965_hw_txq_free_tfd(priv, txq);
 
        len = sizeof(struct iwl4965_cmd) * q->n_window;
@@ -714,7 +696,7 @@ static int iwl4965_enqueue_hcmd(struct iwl4965_priv *priv, struct iwl4965_host_c
        ret = iwl4965_tx_queue_update_wr_ptr(priv, txq, 0);
 
        /* Increment and update queue's write index */
-       q->write_ptr = iwl4965_queue_inc_wrap(q->write_ptr, q->n_bd);
+       q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
        iwl4965_tx_queue_update_write_ptr(priv, txq);
 
        spin_unlock_irqrestore(&priv->hcmd_lock, flags);
@@ -1579,85 +1561,6 @@ static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv)
        return rc;
 }
 
-/******************************************************************************
- *
- * EEPROM related functions
- *
- ******************************************************************************/
-
-static void get_eeprom_mac(struct iwl4965_priv *priv, u8 *mac)
-{
-       memcpy(mac, priv->eeprom.mac_address, 6);
-}
-
-static inline void iwl4965_eeprom_release_semaphore(struct iwl4965_priv *priv)
-{
-       iwl4965_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
-               CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
-}
-
-/**
- * iwl4965_eeprom_init - read EEPROM contents
- *
- * Load the EEPROM contents from adapter into priv->eeprom
- *
- * NOTE:  This routine uses the non-debug IO access functions.
- */
-int iwl4965_eeprom_init(struct iwl4965_priv *priv)
-{
-       u16 *e = (u16 *)&priv->eeprom;
-       u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP);
-       u32 r;
-       int sz = sizeof(priv->eeprom);
-       int rc;
-       int i;
-       u16 addr;
-
-       /* The EEPROM structure has several padding buffers within it
-        * and when adding new EEPROM maps is subject to programmer errors
-        * which may be very difficult to identify without explicitly
-        * checking the resulting size of the eeprom map. */
-       BUILD_BUG_ON(sizeof(priv->eeprom) != IWL_EEPROM_IMAGE_SIZE);
-
-       if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) {
-               IWL_ERROR("EEPROM not found, EEPROM_GP=0x%08x", gp);
-               return -ENOENT;
-       }
-
-       /* Make sure driver (instead of uCode) is allowed to read EEPROM */
-       rc = iwl4965_eeprom_acquire_semaphore(priv);
-       if (rc < 0) {
-               IWL_ERROR("Failed to acquire EEPROM semaphore.\n");
-               return -ENOENT;
-       }
-
-       /* eeprom is an array of 16bit values */
-       for (addr = 0; addr < sz; addr += sizeof(u16)) {
-               _iwl4965_write32(priv, CSR_EEPROM_REG, addr << 1);
-               _iwl4965_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
-
-               for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT;
-                                       i += IWL_EEPROM_ACCESS_DELAY) {
-                       r = _iwl4965_read_direct32(priv, CSR_EEPROM_REG);
-                       if (r & CSR_EEPROM_REG_READ_VALID_MSK)
-                               break;
-                       udelay(IWL_EEPROM_ACCESS_DELAY);
-               }
-
-               if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) {
-                       IWL_ERROR("Time out reading EEPROM[%d]", addr);
-                       rc = -ETIMEDOUT;
-                       goto done;
-               }
-               e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
-       }
-       rc = 0;
-
-done:
-       iwl4965_eeprom_release_semaphore(priv);
-       return rc;
-}
-
 /******************************************************************************
  *
  * Misc. internal state and helper functions
@@ -2897,7 +2800,7 @@ static int iwl4965_tx_skb(struct iwl4965_priv *priv,
        iwl4965_tx_queue_update_wr_ptr(priv, txq, len);
 
        /* Tell device the write index *just past* this latest filled TFD */
-       q->write_ptr = iwl4965_queue_inc_wrap(q->write_ptr, q->n_bd);
+       q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
        rc = iwl4965_tx_queue_update_write_ptr(priv, txq);
        spin_unlock_irqrestore(&priv->lock, flags);
 
@@ -3291,9 +3194,9 @@ int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index)
                return 0;
        }
 
-       for (index = iwl4965_queue_inc_wrap(index, q->n_bd);
+       for (index = iwl_queue_inc_wrap(index, q->n_bd);
                q->read_ptr != index;
-               q->read_ptr = iwl4965_queue_inc_wrap(q->read_ptr, q->n_bd)) {
+               q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
                if (txq_id != IWL_CMD_QUEUE_NUM) {
                        iwl4965_txstatus_to_ieee(priv,
                                        &(txq->txb[txq->q.read_ptr]));
@@ -3538,7 +3441,7 @@ static void iwl4965_rx_reply_tx(struct iwl4965_priv *priv,
 
                if (txq->q.read_ptr != (scd_ssn & 0xff)) {
                        int freed;
-                       index = iwl4965_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
+                       index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
                        IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn "
                                           "%d index %d\n", scd_ssn , index);
                        freed = iwl4965_tx_queue_reclaim(priv, txq_id, index);
@@ -5547,8 +5450,9 @@ static void iwl4965_init_hw_rates(struct iwl4965_priv *priv,
                        /*
                         * If CCK != 1M then set short preamble rate flag.
                         */
-                       rates[i].flags |= (iwl4965_rates[i].plcp == 10) ?
-                               0 : IEEE80211_RATE_SHORT_PREAMBLE;
+                       rates[i].flags |=
+                               (iwl4965_rates[i].plcp == IWL_RATE_1M_PLCP) ?
+                                       0 : IEEE80211_RATE_SHORT_PREAMBLE;
                }
        }
 }
@@ -6840,18 +6744,23 @@ static void iwl4965_bg_request_scan(struct work_struct *data)
        if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR)
                scan->filter_flags = RXON_FILTER_PROMISC_MSK;
 
-       if (direct_mask)
+       if (direct_mask) {
                IWL_DEBUG_SCAN
                    ("Initiating direct scan for %s.\n",
                     iwl4965_escape_essid(priv->essid, priv->essid_len));
-       else
+               scan->channel_count =
+                       iwl4965_get_channels_for_scan(
+                               priv, band, 1, /* active */
+                               direct_mask,
+                               (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+       } else {
                IWL_DEBUG_SCAN("Initiating indirect scan.\n");
-
-       scan->channel_count =
-               iwl4965_get_channels_for_scan(
-                       priv, band, 1, /* active */
-                       direct_mask,
-                       (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+               scan->channel_count =
+                       iwl4965_get_channels_for_scan(
+                               priv, band, 0, /* passive */
+                               direct_mask,
+                               (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
+       }
 
        cmd.len += le16_to_cpu(scan->tx_cmd.len) +
            scan->channel_count * sizeof(struct iwl4965_scan_channel);
@@ -8784,13 +8693,13 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
                goto out_remove_sysfs;
         }
        /* Read the EEPROM */
-       err = iwl4965_eeprom_init(priv);
+       err = iwl_eeprom_init(priv);
        if (err) {
                IWL_ERROR("Unable to init EEPROM\n");
                goto out_remove_sysfs;
        }
        /* MAC Address location in EEPROM same for 3945/4965 */
-       get_eeprom_mac(priv, priv->mac_addr);
+       iwl_eeprom_get_mac(priv, priv->mac_addr);
        IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
        SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);