2008-12-02 20:13:11

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 0/11] iwlwifi driver updates

This series contains a few cleanups and fixes. The fixes address the
following problems:
- failure of HW crypto in 3945 (patch 3)
- 3945 rate scaling (patch 7)
- significant delay when bringing interface down (patch 8)
- A band association in passive channels (patch 11)

The series also contains a new feature that enables support of older
firmware versions (patches 9 and 10).

[PATCH 01/11] iwlwifi: move host command check function into separate file
[PATCH 02/11] iwlwifi: fix printk size format error
[PATCH 03/11] iwl3945: Select correct sta ID from find_station()
[PATCH 04/11] iwlwifi: move disable/enable interrupts to iwl-core.c
[PATCH 05/11] iwlwifi: move channels sysfs to debugfs
[PATCH 06/11] iwl3945: add debugfs support
[PATCH 07/11] iwl3945: Fix iwl3945 rate scaling.
[PATCH 08/11] iwlwifi: fix DMA channel number in iwl_txq_ctx_stop
[PATCH 09/11] iwlwifi: store ucode version number
[PATCH 10/11] iwlwifi: rely on API version read from firmware
[PATCH 11/11] iwl3945 : Fix a-band association for passive channels


Thank you

Reinette


2008-12-02 20:13:14

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 05/11] iwlwifi: move channels sysfs to debugfs

From: Winkler, Tomas <[email protected]>

This patch moves channels info display from sysfs to debugfs.
This shows channel information as stored in NIC EEPROM. This
is useful in debugging CRDA or iwl goes setting so it belongs
rather to debugfs then to sysfs.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-agn.c | 63 -----------------------
drivers/net/wireless/iwlwifi/iwl-debug.h | 1 +
drivers/net/wireless/iwlwifi/iwl-debugfs.c | 76 ++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 63 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 9e1d57f..4bdd33b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3591,68 +3591,6 @@ static ssize_t show_power_level(struct device *d,
static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level,
store_power_level);

-static ssize_t show_channels(struct device *d,
- struct device_attribute *attr, char *buf)
-{
-
- struct iwl_priv *priv = dev_get_drvdata(d);
- struct ieee80211_channel *channels = NULL;
- const struct ieee80211_supported_band *supp_band = NULL;
- int len = 0, i;
- int count = 0;
-
- if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
- return -EAGAIN;
-
- supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
- channels = supp_band->channels;
- count = supp_band->n_channels;
-
- len += sprintf(&buf[len],
- "Displaying %d channels in 2.4GHz band "
- "(802.11bg):\n", count);
-
- for (i = 0; i < count; i++)
- len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n",
- ieee80211_frequency_to_channel(
- channels[i].center_freq),
- channels[i].max_power,
- channels[i].flags & IEEE80211_CHAN_RADAR ?
- " (IEEE 802.11h required)" : "",
- (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
- || (channels[i].flags &
- IEEE80211_CHAN_RADAR)) ? "" :
- ", IBSS",
- channels[i].flags &
- IEEE80211_CHAN_PASSIVE_SCAN ?
- "passive only" : "active/passive");
-
- supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
- channels = supp_band->channels;
- count = supp_band->n_channels;
-
- len += sprintf(&buf[len], "Displaying %d channels in 5.2GHz band "
- "(802.11a):\n", count);
-
- for (i = 0; i < count; i++)
- len += sprintf(&buf[len], "%d: %ddBm: BSS%s%s, %s.\n",
- ieee80211_frequency_to_channel(
- channels[i].center_freq),
- channels[i].max_power,
- channels[i].flags & IEEE80211_CHAN_RADAR ?
- " (IEEE 802.11h required)" : "",
- ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
- || (channels[i].flags &
- IEEE80211_CHAN_RADAR)) ? "" :
- ", IBSS",
- channels[i].flags &
- IEEE80211_CHAN_PASSIVE_SCAN ?
- "passive only" : "active/passive");
-
- return len;
-}
-
-static DEVICE_ATTR(channels, S_IRUSR, show_channels, NULL);

static ssize_t show_statistics(struct device *d,
struct device_attribute *attr, char *buf)
@@ -3752,7 +3690,6 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
}

static struct attribute *iwl_sysfs_entries[] = {
- &dev_attr_channels.attr,
&dev_attr_flags.attr,
&dev_attr_filter_flags.attr,
&dev_attr_power_level.attr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 0e79a6a..a115dc6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -60,6 +60,7 @@ struct iwl_debugfs {
struct dentry *file_rx_statistics;
struct dentry *file_tx_statistics;
struct dentry *file_log_event;
+ struct dentry *file_channels;
} dbgfs_data_files;
struct dir_rf_files {
struct dentry *file_disable_sensitivity;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 5346ed5..84053d8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -350,12 +350,86 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
return count;
}

+
+
+static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+ struct ieee80211_channel *channels = NULL;
+ const struct ieee80211_supported_band *supp_band = NULL;
+ int pos = 0, i, bufsz = PAGE_SIZE;
+ char *buf;
+ ssize_t ret;
+
+ if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
+ return -EAGAIN;
+
+ buf = kzalloc(bufsz, GFP_KERNEL);
+ if (!buf) {
+ IWL_ERROR("Can not allocate Buffer\n");
+ return -ENOMEM;
+ }
+
+ supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
+ channels = supp_band->channels;
+
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "Displaying %d channels in 2.4GHz band 802.11bg):\n",
+ supp_band->n_channels);
+
+ for (i = 0; i < supp_band->n_channels; i++)
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "%d: %ddBm: BSS%s%s, %s.\n",
+ ieee80211_frequency_to_channel(
+ channels[i].center_freq),
+ channels[i].max_power,
+ channels[i].flags & IEEE80211_CHAN_RADAR ?
+ " (IEEE 802.11h required)" : "",
+ (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
+ || (channels[i].flags &
+ IEEE80211_CHAN_RADAR)) ? "" :
+ ", IBSS",
+ channels[i].flags &
+ IEEE80211_CHAN_PASSIVE_SCAN ?
+ "passive only" : "active/passive");
+
+ supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
+ channels = supp_band->channels;
+
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "Displaying %d channels in 5.2GHz band (802.11a)\n",
+ supp_band->n_channels);
+
+ for (i = 0; i < supp_band->n_channels; i++)
+ pos += scnprintf(buf + pos, bufsz - pos,
+ "%d: %ddBm: BSS%s%s, %s.\n",
+ ieee80211_frequency_to_channel(
+ channels[i].center_freq),
+ channels[i].max_power,
+ channels[i].flags & IEEE80211_CHAN_RADAR ?
+ " (IEEE 802.11h required)" : "",
+ ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
+ || (channels[i].flags &
+ IEEE80211_CHAN_RADAR)) ? "" :
+ ", IBSS",
+ channels[i].flags &
+ IEEE80211_CHAN_PASSIVE_SCAN ?
+ "passive only" : "active/passive");
+
+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+ kfree(buf);
+ return ret;
+}
+
+
DEBUGFS_READ_WRITE_FILE_OPS(sram);
DEBUGFS_WRITE_FILE_OPS(log_event);
DEBUGFS_READ_FILE_OPS(eeprom);
DEBUGFS_READ_FILE_OPS(stations);
DEBUGFS_READ_FILE_OPS(rx_statistics);
DEBUGFS_READ_FILE_OPS(tx_statistics);
+DEBUGFS_READ_FILE_OPS(channels);

/*
* Create the debugfs files and directories
@@ -389,6 +463,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
DEBUGFS_ADD_FILE(stations, data);
DEBUGFS_ADD_FILE(rx_statistics, data);
DEBUGFS_ADD_FILE(tx_statistics, data);
+ DEBUGFS_ADD_FILE(channels, data);
DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
&priv->disable_chain_noise_cal);
@@ -417,6 +492,7 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv)
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
+ DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
DEBUGFS_REMOVE(priv->dbgfs->dir_data);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
--
1.5.4.3


2008-12-03 17:57:23

by Reinette Chatre

[permalink] [raw]
Subject: Re: [ipw3945-devel] [PATCH 11/11] iwl3945 : Fix a-band association for passive channels

On Wed, 2008-12-03 at 08:49 -0800, Helmut Schaa wrote:
> Hi,
>
> Am Dienstag, 2. Dezember 2008 schrieb Reinette Chatre:
> > 2) This fix will only work with uCode version 15.28.2.8 and above.
>
> Where can I find the ucode version 15.28.2.8? I could only find
> 15.28.1.8 at [1].
>

Sorry - I removed the firmware when our initial release [1] was not
received very well. I initially planned to make it available when these
patches are accepted ... but I might as well do it now.


> [1] http://www.intellinuxwireless.org/?n=downloads&f=ucodes_3945


The firmware is now available from here.

Reinette


[1] http://marc.info/?l=linux-wireless&m=122461362432337&w=2




2008-12-02 20:13:13

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 03/11] iwl3945: Select correct sta ID from find_station()

From: Samuel Ortiz <[email protected]>

The find_station routine needs to look at the IWL_AP_ID entry if we're a STA.
Currently, it only looks for STA entries which causes HW crypto to fail.

Signed-off-by: Samuel Ortiz <[email protected]>
Acked-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index fb5d295..96824e8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -809,13 +809,20 @@ int iwl3945_hw_txq_free_tfd(struct iwl3945_priv *priv, struct iwl3945_tx_queue *

u8 iwl3945_hw_find_station(struct iwl3945_priv *priv, const u8 *addr)
{
- int i;
+ int i, start = IWL_AP_ID;
int ret = IWL_INVALID_STATION;
unsigned long flags;
DECLARE_MAC_BUF(mac);

+ if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
+ (priv->iw_mode == NL80211_IFTYPE_AP))
+ start = IWL_STA_ID;
+
+ if (is_broadcast_ether_addr(addr))
+ return priv->hw_setting.bcast_sta_id;
+
spin_lock_irqsave(&priv->sta_lock, flags);
- for (i = IWL_STA_ID; i < priv->hw_setting.max_stations; i++)
+ for (i = start; i < priv->hw_setting.max_stations; i++)
if ((priv->stations[i].used) &&
(!compare_ether_addr
(priv->stations[i].sta.sta.addr, addr))) {
--
1.5.4.3


2008-12-02 20:13:13

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 04/11] iwlwifi: move disable/enable interrupts to iwl-core.c

From: Winkler, Tomas <[email protected]>

This patch moves iwl_enable_interrupts and iwl_disable_interrupts
functions to iwl-core.c

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-agn.c | 22 ----------------------
drivers/net/wireless/iwlwifi/iwl-core.c | 25 +++++++++++++++++++++++++
drivers/net/wireless/iwlwifi/iwl-core.h | 6 ++++++
3 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index de1ec54..9e1d57f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1259,13 +1259,6 @@ static void iwl_print_rx_config_cmd(struct iwl_priv *priv)
}
#endif

-static void iwl_enable_interrupts(struct iwl_priv *priv)
-{
- IWL_DEBUG_ISR("Enabling interrupts\n");
- set_bit(STATUS_INT_ENABLED, &priv->status);
- iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
-}
-
/* call this function to flush any scheduled tasklet */
static inline void iwl_synchronize_irq(struct iwl_priv *priv)
{
@@ -1274,21 +1267,6 @@ static inline void iwl_synchronize_irq(struct iwl_priv *priv)
tasklet_kill(&priv->irq_tasklet);
}

-static inline void iwl_disable_interrupts(struct iwl_priv *priv)
-{
- clear_bit(STATUS_INT_ENABLED, &priv->status);
-
- /* disable interrupts from uCode/NIC to host */
- iwl_write32(priv, CSR_INT_MASK, 0x00000000);
-
- /* acknowledge/clear/reset any interrupts still pending
- * from uCode or flow handler (Rx/Tx DMA) */
- iwl_write32(priv, CSR_INT, 0xffffffff);
- iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff);
- IWL_DEBUG_ISR("Disabled interrupts\n");
-}
-
-
/**
* iwl_irq_handle_error - called for HW or SW error interrupt from card
*/
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 6aa332b..78d1ba7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -962,6 +962,30 @@ void iwl_uninit_drv(struct iwl_priv *priv)
}
EXPORT_SYMBOL(iwl_uninit_drv);

+
+void iwl_disable_interrupts(struct iwl_priv *priv)
+{
+ clear_bit(STATUS_INT_ENABLED, &priv->status);
+
+ /* disable interrupts from uCode/NIC to host */
+ iwl_write32(priv, CSR_INT_MASK, 0x00000000);
+
+ /* acknowledge/clear/reset any interrupts still pending
+ * from uCode or flow handler (Rx/Tx DMA) */
+ iwl_write32(priv, CSR_INT, 0xffffffff);
+ iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff);
+ IWL_DEBUG_ISR("Disabled interrupts\n");
+}
+EXPORT_SYMBOL(iwl_disable_interrupts);
+
+void iwl_enable_interrupts(struct iwl_priv *priv)
+{
+ IWL_DEBUG_ISR("Enabling interrupts\n");
+ set_bit(STATUS_INT_ENABLED, &priv->status);
+ iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
+}
+EXPORT_SYMBOL(iwl_enable_interrupts);
+
int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags)
{
u32 stat_flags = 0;
@@ -1337,6 +1361,7 @@ void iwl_rf_kill_ct_config(struct iwl_priv *priv)
}
EXPORT_SYMBOL(iwl_rf_kill_ct_config);

+
/*
* CARD_STATE_CMD
*
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 82bf263..f68883b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -313,6 +313,12 @@ int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len,
int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);

/*****************************************************
+ * PCI *
+ *****************************************************/
+void iwl_disable_interrupts(struct iwl_priv *priv);
+void iwl_enable_interrupts(struct iwl_priv *priv);
+
+/*****************************************************
* Error Handling Debugging
******************************************************/
void iwl_dump_nic_error_log(struct iwl_priv *priv);
--
1.5.4.3


2008-12-02 20:13:16

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 10/11] iwlwifi: rely on API version read from firmware

This adds the infrastructure to support older firmware APIs.
The API version number is stored as part of the filename, we first try to
load the most recent firmware and progressively try lower versions.
The API version is also read from the firmware self and stored as part
of the iwl_priv structure. Only firmware that is supported by driver will
be loaded. The version number read from firmware is compared
to supported versions in the driver not the API version used as part of
filename.

An example using this new infrastrucure:
if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
Driver interacts with Firmware API version >= 2.
} else {
Driver interacts with Firmware API version 1.
}

Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945-core.h | 26 ++++++++++-
drivers/net/wireless/iwlwifi/iwl-3945.c | 8 ++-
drivers/net/wireless/iwlwifi/iwl-3945.h | 14 ++++--
drivers/net/wireless/iwlwifi/iwl-4965.c | 21 +++++---
drivers/net/wireless/iwlwifi/iwl-5000.c | 46 ++++++++++++++-----
drivers/net/wireless/iwlwifi/iwl-agn.c | 62 ++++++++++++++++++++-----
drivers/net/wireless/iwlwifi/iwl-core.h | 32 ++++++++++++-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 64 ++++++++++++++++++++------
8 files changed, 217 insertions(+), 56 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-core.h b/drivers/net/wireless/iwlwifi/iwl-3945-core.h
index bc12f97..edac6c6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-core.h
@@ -71,9 +71,33 @@
#define IWL_SKU_G 0x1
#define IWL_SKU_A 0x2

+/**
+ * struct iwl_3945_cfg
+ * @fw_name_pre: Firmware filename prefix. The api version and extension
+ * (.ucode) will be added to filename before loading from disk. The
+ * filename is constructed as fw_name_pre<api>.ucode.
+ * @ucode_api_max: Highest version of uCode API supported by driver.
+ * @ucode_api_min: Lowest version of uCode API supported by driver.
+ *
+ * We enable the driver to be backward compatible wrt API version. The
+ * driver specifies which APIs it supports (with @ucode_api_max being the
+ * highest and @ucode_api_min the lowest). Firmware will only be loaded if
+ * it has a supported API version. The firmware's API version will be
+ * stored in @iwl_priv, enabling the driver to make runtime changes based
+ * on firmware version used.
+ *
+ * For example,
+ * if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
+ * Driver interacts with Firmware API version >= 2.
+ * } else {
+ * Driver interacts with Firmware API version 1.
+ * }
+ */
struct iwl_3945_cfg {
const char *name;
- const char *fw_name;
+ const char *fw_name_pre;
+ const unsigned int ucode_api_max;
+ const unsigned int ucode_api_min;
unsigned int sku;
};

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index d422600..6602729 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2509,13 +2509,17 @@ void iwl3945_hw_cancel_deferred_work(struct iwl3945_priv *priv)

static struct iwl_3945_cfg iwl3945_bg_cfg = {
.name = "3945BG",
- .fw_name = "iwlwifi-3945" IWL3945_UCODE_API ".ucode",
+ .fw_name_pre = IWL3945_FW_PRE,
+ .ucode_api_max = IWL3945_UCODE_API_MAX,
+ .ucode_api_min = IWL3945_UCODE_API_MIN,
.sku = IWL_SKU_G,
};

static struct iwl_3945_cfg iwl3945_abg_cfg = {
.name = "3945ABG",
- .fw_name = "iwlwifi-3945" IWL3945_UCODE_API ".ucode",
+ .fw_name_pre = IWL3945_FW_PRE,
+ .ucode_api_max = IWL3945_UCODE_API_MAX,
+ .ucode_api_min = IWL3945_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G,
};

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 972c454..d6502b4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -50,11 +50,15 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
#include "iwl-3945-debug.h"
#include "iwl-3945-led.h"

-/* Change firmware file name, using "-" and incrementing number,
- * *only* when uCode interface or architecture changes so that it
- * is not compatible with earlier drivers.
- * This number will also appear in << 8 position of 1st dword of uCode file */
-#define IWL3945_UCODE_API "-1"
+/* Highest firmware API version supported */
+#define IWL3945_UCODE_API_MAX 1
+
+/* Lowest firmware API version supported */
+#define IWL3945_UCODE_API_MIN 1
+
+#define IWL3945_FW_PRE "iwlwifi-3945-"
+#define _IWL3945_MODULE_FIRMWARE(api) IWL3945_FW_PRE #api ".ucode"
+#define IWL3945_MODULE_FIRMWARE(api) _IWL3945_MODULE_FIRMWARE(api)

/* Default noise level to report when noise measurement is not available.
* This may be because we're:
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 93d3df8..87c7bb0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -48,12 +48,15 @@
static int iwl4965_send_tx_power(struct iwl_priv *priv);
static int iwl4965_hw_get_temperature(const struct iwl_priv *priv);

-/* Change firmware file name, using "-" and incrementing number,
- * *only* when uCode interface or architecture changes so that it
- * is not compatible with earlier drivers.
- * This number will also appear in << 8 position of 1st dword of uCode file */
-#define IWL4965_UCODE_API "-2"
-#define IWL4965_MODULE_FIRMWARE "iwlwifi-4965" IWL4965_UCODE_API ".ucode"
+/* Highest firmware API version supported */
+#define IWL4965_UCODE_API_MAX 2
+
+/* Lowest firmware API version supported */
+#define IWL4965_UCODE_API_MIN 2
+
+#define IWL4965_FW_PRE "iwlwifi-4965-"
+#define _IWL4965_MODULE_FIRMWARE(api) IWL4965_FW_PRE #api ".ucode"
+#define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api)


/* module parameters */
@@ -2336,7 +2339,9 @@ static struct iwl_ops iwl4965_ops = {

struct iwl_cfg iwl4965_agn_cfg = {
.name = "4965AGN",
- .fw_name = IWL4965_MODULE_FIRMWARE,
+ .fw_name_pre = IWL4965_FW_PRE,
+ .ucode_api_max = IWL4965_UCODE_API_MAX,
+ .ucode_api_min = IWL4965_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
.eeprom_size = IWL4965_EEPROM_IMG_SIZE,
.eeprom_ver = EEPROM_4965_EEPROM_VERSION,
@@ -2346,7 +2351,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
};

/* Module firmware */
-MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE);
+MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE(IWL4965_UCODE_API_MAX));

module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index f7a8df8..438e4bd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -44,11 +44,21 @@
#include "iwl-helpers.h"
#include "iwl-5000-hw.h"

-#define IWL5000_UCODE_API "-1"
-#define IWL5150_UCODE_API "-1"
+/* Highest firmware API version supported */
+#define IWL5000_UCODE_API_MAX 1
+#define IWL5150_UCODE_API_MAX 1

-#define IWL5000_MODULE_FIRMWARE "iwlwifi-5000" IWL5000_UCODE_API ".ucode"
-#define IWL5150_MODULE_FIRMWARE "iwlwifi-5150" IWL5150_UCODE_API ".ucode"
+/* Lowest firmware API version supported */
+#define IWL5000_UCODE_API_MIN 1
+#define IWL5150_UCODE_API_MIN 1
+
+#define IWL5000_FW_PRE "iwlwifi-5000-"
+#define _IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE #api ".ucode"
+#define IWL5000_MODULE_FIRMWARE(api) _IWL5000_MODULE_FIRMWARE(api)
+
+#define IWL5150_FW_PRE "iwlwifi-5150-"
+#define _IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE #api ".ucode"
+#define IWL5150_MODULE_FIRMWARE(api) _IWL5150_MODULE_FIRMWARE(api)

static const u16 iwl5000_default_queue_to_tx_fifo[] = {
IWL_TX_FIFO_AC3,
@@ -1532,7 +1542,9 @@ static struct iwl_mod_params iwl50_mod_params = {

struct iwl_cfg iwl5300_agn_cfg = {
.name = "5300AGN",
- .fw_name = IWL5000_MODULE_FIRMWARE,
+ .fw_name_pre = IWL5000_FW_PRE,
+ .ucode_api_max = IWL5000_UCODE_API_MAX,
+ .ucode_api_min = IWL5000_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
.ops = &iwl5000_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1543,7 +1555,9 @@ struct iwl_cfg iwl5300_agn_cfg = {

struct iwl_cfg iwl5100_bg_cfg = {
.name = "5100BG",
- .fw_name = IWL5000_MODULE_FIRMWARE,
+ .fw_name_pre = IWL5000_FW_PRE,
+ .ucode_api_max = IWL5000_UCODE_API_MAX,
+ .ucode_api_min = IWL5000_UCODE_API_MIN,
.sku = IWL_SKU_G,
.ops = &iwl5000_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1554,7 +1568,9 @@ struct iwl_cfg iwl5100_bg_cfg = {

struct iwl_cfg iwl5100_abg_cfg = {
.name = "5100ABG",
- .fw_name = IWL5000_MODULE_FIRMWARE,
+ .fw_name_pre = IWL5000_FW_PRE,
+ .ucode_api_max = IWL5000_UCODE_API_MAX,
+ .ucode_api_min = IWL5000_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G,
.ops = &iwl5000_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1565,7 +1581,9 @@ struct iwl_cfg iwl5100_abg_cfg = {

struct iwl_cfg iwl5100_agn_cfg = {
.name = "5100AGN",
- .fw_name = IWL5000_MODULE_FIRMWARE,
+ .fw_name_pre = IWL5000_FW_PRE,
+ .ucode_api_max = IWL5000_UCODE_API_MAX,
+ .ucode_api_min = IWL5000_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
.ops = &iwl5000_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1576,7 +1594,9 @@ struct iwl_cfg iwl5100_agn_cfg = {

struct iwl_cfg iwl5350_agn_cfg = {
.name = "5350AGN",
- .fw_name = IWL5000_MODULE_FIRMWARE,
+ .fw_name_pre = IWL5000_FW_PRE,
+ .ucode_api_max = IWL5000_UCODE_API_MAX,
+ .ucode_api_min = IWL5000_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
.ops = &iwl5000_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1587,7 +1607,9 @@ struct iwl_cfg iwl5350_agn_cfg = {

struct iwl_cfg iwl5150_agn_cfg = {
.name = "5150AGN",
- .fw_name = IWL5150_MODULE_FIRMWARE,
+ .fw_name_pre = IWL5150_FW_PRE,
+ .ucode_api_max = IWL5150_UCODE_API_MAX,
+ .ucode_api_min = IWL5150_UCODE_API_MIN,
.sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
.ops = &iwl5000_ops,
.eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
@@ -1596,8 +1618,8 @@ struct iwl_cfg iwl5150_agn_cfg = {
.mod_params = &iwl50_mod_params,
};

-MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
-MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE);
+MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));

module_param_named(disable50, iwl50_mod_params.disable, int, 0444);
MODULE_PARM_DESC(disable50,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index c906260..fc4e7e4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1574,24 +1574,40 @@ static void iwl_nic_start(struct iwl_priv *priv)
static int iwl_read_ucode(struct iwl_priv *priv)
{
struct iwl_ucode *ucode;
- int ret;
+ int ret = -EINVAL, index;
const struct firmware *ucode_raw;
- const char *name = priv->cfg->fw_name;
+ const char *name_pre = priv->cfg->fw_name_pre;
+ const unsigned int api_max = priv->cfg->ucode_api_max;
+ const unsigned int api_min = priv->cfg->ucode_api_min;
+ char buf[25];
u8 *src;
size_t len;
- u32 inst_size, data_size, init_size, init_data_size, boot_size;
+ u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size;

/* Ask kernel firmware_class module to get the boot firmware off disk.
* request_firmware() is synchronous, file is in memory on return. */
- ret = request_firmware(&ucode_raw, name, &priv->pci_dev->dev);
- if (ret < 0) {
- IWL_ERROR("%s firmware file req failed: Reason %d\n",
- name, ret);
- goto error;
+ for (index = api_max; index >= api_min; index--) {
+ sprintf(buf, "%s%d%s", name_pre, index, ".ucode");
+ ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev);
+ if (ret < 0) {
+ IWL_ERROR("%s firmware file req failed: Reason %d\n",
+ buf, ret);
+ if (ret == -ENOENT)
+ continue;
+ else
+ goto error;
+ } else {
+ if (index < api_max)
+ IWL_ERROR("Loaded firmware %s, which is deprecated. Please use API v%u instead.\n",
+ buf, api_max);
+ IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n",
+ buf, ucode_raw->size);
+ break;
+ }
}

- IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n",
- name, ucode_raw->size);
+ if (ret < 0)
+ goto error;

/* Make sure that we got at least our header! */
if (ucode_raw->size < sizeof(*ucode)) {
@@ -1604,19 +1620,39 @@ static int iwl_read_ucode(struct iwl_priv *priv)
ucode = (void *)ucode_raw->data;

priv->ucode_ver = le32_to_cpu(ucode->ver);
+ api_ver = IWL_UCODE_API(priv->ucode_ver);
inst_size = le32_to_cpu(ucode->inst_size);
data_size = le32_to_cpu(ucode->data_size);
init_size = le32_to_cpu(ucode->init_size);
init_data_size = le32_to_cpu(ucode->init_data_size);
boot_size = le32_to_cpu(ucode->boot_size);

- IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
- priv->ucode_ver);
- IWL_DEBUG_INFO("f/w package hdr ucode version = %u.%u.%u.%u\n",
+ /* api_ver should match the api version forming part of the
+ * firmware filename ... but we don't check for that and only rely
+ * on the API version read from firware header from here on forward */
+
+ if (api_ver < api_min || api_ver > api_max) {
+ IWL_ERROR("Driver unable to support your firmware API. "
+ "Driver supports v%u, firmware is v%u.\n",
+ api_max, api_ver);
+ priv->ucode_ver = 0;
+ ret = -EINVAL;
+ goto err_release;
+ }
+ if (api_ver != api_max)
+ IWL_ERROR("Firmware has old API version. Expected v%u, "
+ "got v%u. New firmware can be obtained "
+ "from http://www.intellinuxwireless.org.\n",
+ api_max, api_ver);
+
+ printk(KERN_INFO DRV_NAME " loaded firmware version %u.%u.%u.%u\n",
IWL_UCODE_MAJOR(priv->ucode_ver),
IWL_UCODE_MINOR(priv->ucode_ver),
IWL_UCODE_API(priv->ucode_ver),
IWL_UCODE_SERIAL(priv->ucode_ver));
+
+ IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
+ priv->ucode_ver);
IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n",
inst_size);
IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index f68883b..81ddca0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -164,9 +164,39 @@ struct iwl_mod_params {
int restart_fw; /* def: 1 = restart firmware */
};

+/**
+ * struct iwl_cfg
+ * @fw_name_pre: Firmware filename prefix. The api version and extension
+ * (.ucode) will be added to filename before loading from disk. The
+ * filename is constructed as fw_name_pre<api>.ucode.
+ * @ucode_api_max: Highest version of uCode API supported by driver.
+ * @ucode_api_min: Lowest version of uCode API supported by driver.
+ *
+ * We enable the driver to be backward compatible wrt API version. The
+ * driver specifies which APIs it supports (with @ucode_api_max being the
+ * highest and @ucode_api_min the lowest). Firmware will only be loaded if
+ * it has a supported API version. The firmware's API version will be
+ * stored in @iwl_priv, enabling the driver to make runtime changes based
+ * on firmware version used.
+ *
+ * For example,
+ * if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
+ * Driver interacts with Firmware API version >= 2.
+ * } else {
+ * Driver interacts with Firmware API version 1.
+ * }
+ *
+ * The ideal usage of this infrastructure is to treat a new ucode API
+ * release as a new hardware revision. That is, through utilizing the
+ * iwl_hcmd_utils_ops etc. we accommodate different command structures
+ * and flows between hardware versions (4965/5000) as well as their API
+ * versions.
+ */
struct iwl_cfg {
const char *name;
- const char *fw_name;
+ const char *fw_name_pre;
+ const unsigned int ucode_api_max;
+ const unsigned int ucode_api_min;
unsigned int sku;
int eeprom_size;
u16 eeprom_ver;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index c003814..8e14607 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -5335,25 +5335,41 @@ static void iwl3945_nic_start(struct iwl3945_priv *priv)
static int iwl3945_read_ucode(struct iwl3945_priv *priv)
{
struct iwl3945_ucode *ucode;
- int ret = 0;
+ int ret = -EINVAL, index;
const struct firmware *ucode_raw;
/* firmware file name contains uCode/driver compatibility version */
- const char *name = priv->cfg->fw_name;
+ const char *name_pre = priv->cfg->fw_name_pre;
+ const unsigned int api_max = priv->cfg->ucode_api_max;
+ const unsigned int api_min = priv->cfg->ucode_api_min;
+ char buf[25];
u8 *src;
size_t len;
- u32 inst_size, data_size, init_size, init_data_size, boot_size;
+ u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size;

/* Ask kernel firmware_class module to get the boot firmware off disk.
* request_firmware() is synchronous, file is in memory on return. */
- ret = request_firmware(&ucode_raw, name, &priv->pci_dev->dev);
- if (ret < 0) {
- IWL_ERROR("%s firmware file req failed: Reason %d\n",
- name, ret);
- goto error;
+ for (index = api_max; index >= api_min; index--) {
+ sprintf(buf, "%s%u%s", name_pre, index, ".ucode");
+ ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev);
+ if (ret < 0) {
+ IWL_ERROR("%s firmware file req failed: Reason %d\n",
+ buf, ret);
+ if (ret == -ENOENT)
+ continue;
+ else
+ goto error;
+ } else {
+ if (index < api_max)
+ IWL_ERROR("Loaded firmware %s, which is deprecated. Please use API v%u instead.\n",
+ buf, api_max);
+ IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n",
+ buf, ucode_raw->size);
+ break;
+ }
}

- IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n",
- name, ucode_raw->size);
+ if (ret < 0)
+ goto error;

/* Make sure that we got at least our header! */
if (ucode_raw->size < sizeof(*ucode)) {
@@ -5366,25 +5382,45 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
ucode = (void *)ucode_raw->data;

priv->ucode_ver = le32_to_cpu(ucode->ver);
+ api_ver = IWL_UCODE_API(priv->ucode_ver);
inst_size = le32_to_cpu(ucode->inst_size);
data_size = le32_to_cpu(ucode->data_size);
init_size = le32_to_cpu(ucode->init_size);
init_data_size = le32_to_cpu(ucode->init_data_size);
boot_size = le32_to_cpu(ucode->boot_size);

- IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
- priv->ucode_ver);
- IWL_DEBUG_INFO("f/w package hdr ucode version = %u.%u.%u.%u\n",
+ /* api_ver should match the api version forming part of the
+ * firmware filename ... but we don't check for that and only rely
+ * on the API version read from firware header from here on forward */
+
+ if (api_ver < api_min || api_ver > api_max) {
+ IWL_ERROR("Driver unable to support your firmware API. "
+ "Driver supports v%u, firmware is v%u.\n",
+ api_max, api_ver);
+ priv->ucode_ver = 0;
+ ret = -EINVAL;
+ goto err_release;
+ }
+ if (api_ver != api_max)
+ IWL_ERROR("Firmware has old API version. Expected %u, "
+ "got %u. New firmware can be obtained "
+ "from http://www.intellinuxwireless.org.\n",
+ api_max, api_ver);
+
+ printk(KERN_INFO DRV_NAME " loaded firmware version %u.%u.%u.%u\n",
IWL_UCODE_MAJOR(priv->ucode_ver),
IWL_UCODE_MINOR(priv->ucode_ver),
IWL_UCODE_API(priv->ucode_ver),
IWL_UCODE_SERIAL(priv->ucode_ver));
+ IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
+ priv->ucode_ver);
IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", inst_size);
IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", data_size);
IWL_DEBUG_INFO("f/w package hdr init inst size = %u\n", init_size);
IWL_DEBUG_INFO("f/w package hdr init data size = %u\n", init_data_size);
IWL_DEBUG_INFO("f/w package hdr boot inst size = %u\n", boot_size);

+
/* Verify size of file vs. image size info in file's header */
if (ucode_raw->size < sizeof(*ucode) +
inst_size + data_size + init_size +
@@ -8352,7 +8388,7 @@ static void __exit iwl3945_exit(void)
iwl3945_rate_control_unregister();
}

-MODULE_FIRMWARE("iwlwifi-3945" IWL3945_UCODE_API ".ucode");
+MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX));

module_param_named(antenna, iwl3945_param_antenna, int, 0444);
MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
--
1.5.4.3


2008-12-02 21:51:17

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 10/11] iwlwifi: rely on API version read from firmware

Hi Reinette,

> > > This adds the infrastructure to support older firmware APIs.
> > > The API version number is stored as part of the filename, we first try to
> > > load the most recent firmware and progressively try lower versions.
> > > The API version is also read from the firmware self and stored as part
> > > of the iwl_priv structure. Only firmware that is supported by driver will
> > > be loaded. The version number read from firmware is compared
> > > to supported versions in the driver not the API version used as part of
> > > filename.
> >
> > thanks for doing this. This can really help smooth upgrade path in case
> > the firmware API changes.
> >
> > > -MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
> > > -MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE);
> > > +MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
> > > +MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
> >
> > So we don't have clear semantics on how MODULE_FIRMWARE should be used.
> > The current way is that it list all potential firmware versions. So in
> > cases it support API -1 and -2, then it has to list both. And not only
> > the latest.
>
> Even though the driver supports older firmware we really want the user
> to use the latest firmware. The driver will also print a clear error if
> the user is using API -1 and the latest available is -2. For this reason
> we do want to make clear through MODULE_FIRMWARE which firmware the
> driver would like to work with: the latest.

as I said, we never clearly defined the semantics of MODULE_FIRMWARE for
these cases. The only problem that I see is that some initrd tools are
actually using MODULE_FIRMWARE to figure which files need to be included
for the builtin kernel drivers. So on a system with old firmware only,
it will not include these.

Maybe we need to extend MODULE_FIRMWARE. Maybe something like
MODULE_ALTERNATE_FIRMWARE or some extra flags.

> > Personally I think we should not create too many macros here and just
> > list all the firmware files manually.
>
> Having one spot to change when a new API is supported makes the code
> less error prone.

I agree on that, but it doesn't make it easier to read through the
source code.

Regards

Marcel



2008-12-02 20:13:12

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 02/11] iwlwifi: fix printk size format error

From: Zhu Yi <[email protected]>

The patch fixes a printk size format error.

Signed-off-by: Zhu Yi <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 4f45894..de1ec54 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1539,7 +1539,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
/* Hardware disappeared. It might have already raised
* an interrupt */
- IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta);
+ IWL_WARNING("HARDWARE GONE?? INTA == 0x%08x\n", inta);
goto unplugged;
}

diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 7902339..074b43c 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -4450,7 +4450,7 @@ static irqreturn_t iwl3945_isr(int irq, void *data)

if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
/* Hardware disappeared */
- IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta);
+ IWL_WARNING("HARDWARE GONE?? INTA == 0x%08x\n", inta);
goto unplugged;
}

--
1.5.4.3


2008-12-02 20:13:14

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 06/11] iwl3945: add debugfs support

From: Abbas, Mohamed <[email protected]>

Add debugfs support to 3945 driver to display rs info.

Signed-off-by: Mohamed Abbas <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 62 ++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index e0ea2fe..e5f4b71 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -63,6 +63,9 @@ struct iwl3945_rs_sta {
u8 ibss_sta_added;
struct timer_list rate_scale_flush;
struct iwl3945_rate_scale_data win[IWL_RATE_COUNT];
+#ifdef CONFIG_MAC80211_DEBUGFS
+ struct dentry *rs_sta_dbgfs_stats_table_file;
+#endif

/* used to be in sta_info */
int last_txrate_idx;
@@ -773,6 +776,60 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
IWL_DEBUG_RATE("leave: %d\n", index);
}

+#ifdef CONFIG_MAC80211_DEBUGFS
+static int iwl3945_open_file_generic(struct inode *inode, struct file *file)
+{
+ file->private_data = inode->i_private;
+ return 0;
+}
+
+static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ char buff[1024];
+ int desc = 0;
+ int j;
+ struct iwl3945_rs_sta *lq_sta = file->private_data;
+
+ desc += sprintf(buff + desc, "tx packets=%d last rate index=%d\n"
+ "rate=0x%X flush time %d\n",
+ lq_sta->tx_packets,
+ lq_sta->last_txrate_idx,
+ lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time));
+ for (j = 0; j < IWL_RATE_COUNT; j++) {
+ desc += sprintf(buff+desc,
+ "counter=%d success=%d %%=%d\n",
+ lq_sta->win[j].counter,
+ lq_sta->win[j].success_counter,
+ lq_sta->win[j].success_ratio);
+ }
+ return simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+}
+
+static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
+ .read = iwl3945_sta_dbgfs_stats_table_read,
+ .open = iwl3945_open_file_generic,
+};
+
+static void iwl3945_add_debugfs(void *priv, void *priv_sta,
+ struct dentry *dir)
+{
+ struct iwl3945_rs_sta *lq_sta = priv_sta;
+
+ lq_sta->rs_sta_dbgfs_stats_table_file =
+ debugfs_create_file("rate_stats_table", 0600, dir,
+ lq_sta, &rs_sta_dbgfs_stats_table_ops);
+
+}
+
+static void iwl3945_remove_debugfs(void *priv, void *priv_sta)
+{
+ struct iwl3945_rs_sta *lq_sta = priv_sta;
+ debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file);
+}
+#endif
+
static struct rate_control_ops rs_ops = {
.module = NULL,
.name = RS_NAME,
@@ -783,6 +840,11 @@ static struct rate_control_ops rs_ops = {
.free = rs_free,
.alloc_sta = rs_alloc_sta,
.free_sta = rs_free_sta,
+#ifdef CONFIG_MAC80211_DEBUGFS
+ .add_sta_debugfs = iwl3945_add_debugfs,
+ .remove_sta_debugfs = iwl3945_remove_debugfs,
+#endif
+
};

void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
--
1.5.4.3


2008-12-03 16:49:41

by Helmut Schaa

[permalink] [raw]
Subject: Re: [ipw3945-devel] [PATCH 11/11] iwl3945 : Fix a-band association for passive channels

Hi,

Am Dienstag, 2. Dezember 2008 schrieb Reinette Chatre:
> 2) This fix will only work with uCode version 15.28.2.8 and above.

Where can I find the ucode version 15.28.2.8? I could only find
15.28.1.8 at [1].

Thanks,
Helmut

[1] http://www.intellinuxwireless.org/?n=downloads&f=ucodes_3945

2008-12-02 20:13:12

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 01/11] iwlwifi: move host command check function into separate file

From: Winkler, Tomas <[email protected]>

This patch moves iwl_check_rxon_cmd into iwl-agn-hcmd-check.c
This function compiled out in none debugging or non development
mode and more. We haven't decided which one yet hence preserving the
current 'always compile' state.
More functions will be added to the file namely for checking TX and LQ
commands.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/Makefile | 2 +-
drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c | 108 +++++++++++++++++++++
drivers/net/wireless/iwlwifi/iwl-agn.c | 75 +--------------
drivers/net/wireless/iwlwifi/iwl-commands.h | 2 +
drivers/net/wireless/iwlwifi/iwl-dev.h | 5 -
5 files changed, 112 insertions(+), 80 deletions(-)
create mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c

diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 8b45b30..0be9e6b 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -8,7 +8,7 @@ iwlcore-$(CONFIG_IWLWIFI_RFKILL) += iwl-rfkill.o
iwlcore-$(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) += iwl-spectrum.o

obj-$(CONFIG_IWLAGN) += iwlagn.o
-iwlagn-objs := iwl-agn.o iwl-agn-rs.o
+iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-hcmd-check.o

iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c
new file mode 100644
index 0000000..c50494a
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c
@@ -0,0 +1,108 @@
+/******************************************************************************
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2008 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ * Tomas Winkler <[email protected]>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *****************************************************************************/
+
+#include <linux/kernel.h>
+#include <net/mac80211.h>
+#include "iwl-dev.h"
+#include "iwl-debug.h"
+#include "iwl-commands.h"
+
+
+/**
+ * iwl_check_rxon_cmd - validate RXON structure is valid
+ *
+ * NOTE: This is really only useful during development and can eventually
+ * be #ifdef'd out once the driver is stable and folks aren't actively
+ * making changes
+ */
+int iwl_agn_check_rxon_cmd(struct iwl_rxon_cmd *rxon)
+{
+ int error = 0;
+ int counter = 1;
+
+ if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
+ error |= le32_to_cpu(rxon->flags &
+ (RXON_FLG_TGJ_NARROW_BAND_MSK |
+ RXON_FLG_RADAR_DETECT_MSK));
+ if (error)
+ IWL_WARNING("check 24G fields %d | %d\n",
+ counter++, error);
+ } else {
+ error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
+ 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
+ if (error)
+ IWL_WARNING("check 52 fields %d | %d\n",
+ counter++, error);
+ error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
+ if (error)
+ IWL_WARNING("check 52 CCK %d | %d\n",
+ counter++, error);
+ }
+ error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
+ if (error)
+ IWL_WARNING("check mac addr %d | %d\n", counter++, error);
+
+ /* make sure basic rates 6Mbps and 1Mbps are supported */
+ error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
+ ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
+ if (error)
+ IWL_WARNING("check basic rate %d | %d\n", counter++, error);
+
+ error |= (le16_to_cpu(rxon->assoc_id) > 2007);
+ if (error)
+ IWL_WARNING("check assoc id %d | %d\n", counter++, error);
+
+ error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
+ == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
+ if (error)
+ IWL_WARNING("check CCK and short slot %d | %d\n",
+ counter++, error);
+
+ error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
+ == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
+ if (error)
+ IWL_WARNING("check CCK & auto detect %d | %d\n",
+ counter++, error);
+
+ error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
+ RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
+ if (error)
+ IWL_WARNING("check TGG and auto detect %d | %d\n",
+ counter++, error);
+
+ if (error)
+ IWL_WARNING("Tuning to channel %d\n",
+ le16_to_cpu(rxon->channel));
+
+ if (error) {
+ IWL_ERROR("Not a valid iwl4965_rxon_assoc_cmd field values\n");
+ return -1;
+ }
+ return 0;
+}
+
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 5ddc86d..4f45894 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -108,79 +108,6 @@ static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
}

/**
- * iwl_check_rxon_cmd - validate RXON structure is valid
- *
- * NOTE: This is really only useful during development and can eventually
- * be #ifdef'd out once the driver is stable and folks aren't actively
- * making changes
- */
-static int iwl_check_rxon_cmd(struct iwl_rxon_cmd *rxon)
-{
- int error = 0;
- int counter = 1;
-
- if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
- error |= le32_to_cpu(rxon->flags &
- (RXON_FLG_TGJ_NARROW_BAND_MSK |
- RXON_FLG_RADAR_DETECT_MSK));
- if (error)
- IWL_WARNING("check 24G fields %d | %d\n",
- counter++, error);
- } else {
- error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
- 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
- if (error)
- IWL_WARNING("check 52 fields %d | %d\n",
- counter++, error);
- error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
- if (error)
- IWL_WARNING("check 52 CCK %d | %d\n",
- counter++, error);
- }
- error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
- if (error)
- IWL_WARNING("check mac addr %d | %d\n", counter++, error);
-
- /* make sure basic rates 6Mbps and 1Mbps are supported */
- error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
- ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
- if (error)
- IWL_WARNING("check basic rate %d | %d\n", counter++, error);
-
- error |= (le16_to_cpu(rxon->assoc_id) > 2007);
- if (error)
- IWL_WARNING("check assoc id %d | %d\n", counter++, error);
-
- error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
- == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
- if (error)
- IWL_WARNING("check CCK and short slot %d | %d\n",
- counter++, error);
-
- error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
- == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
- if (error)
- IWL_WARNING("check CCK & auto detect %d | %d\n",
- counter++, error);
-
- error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
- RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
- if (error)
- IWL_WARNING("check TGG and auto detect %d | %d\n",
- counter++, error);
-
- if (error)
- IWL_WARNING("Tuning to channel %d\n",
- le16_to_cpu(rxon->channel));
-
- if (error) {
- IWL_ERROR("Not a valid iwl_rxon_assoc_cmd field values\n");
- return -1;
- }
- return 0;
-}
-
-/**
* iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
* @priv: staging_rxon is compared to active_rxon
*
@@ -253,7 +180,7 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
* 5000, but will not damage 4965 */
priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN;

- ret = iwl_check_rxon_cmd(&priv->staging_rxon);
+ ret = iwl_agn_check_rxon_cmd(&priv->staging_rxon);
if (ret) {
IWL_ERROR("Invalid RXON configuration. Not committing.\n");
return -EINVAL;
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 7761504..d6196b9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -3064,4 +3064,6 @@ struct iwl_rx_packet {

#define IWL_RX_FRAME_SIZE (4 + sizeof(struct iwl4965_rx_frame))

+int iwl_agn_check_rxon_cmd(struct iwl_rxon_cmd *rxon);
+
#endif /* __iwl_commands_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index b2ce29c..846b8b0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1086,9 +1086,4 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch)
return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
}

-extern const struct iwl_channel_info *iwl_get_channel_info(
- const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
-
-/* Requires full declaration of iwl_priv before including */
-
#endif /* __iwl_dev_h__ */
--
1.5.4.3


2008-12-02 20:13:14

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 07/11] iwl3945: Fix iwl3945 rate scaling.

From: Abbas, Mohamed <[email protected]>

3945 rate scaling was broken in recent tree. This patch fix the following:
1- Get TX response info and update rates window.
2- Rate scaling selection.
3- Flush window timer.

Signed-off-by: Mohamed Abbas <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 83 ++++++++++++++++-----------
drivers/net/wireless/iwlwifi/iwl-3945.c | 26 +-------
2 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index e5f4b71..06d97b1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -117,9 +117,11 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = {
};

#define IWL_RATE_MAX_WINDOW 62
-#define IWL_RATE_FLUSH (3*HZ/10)
+#define IWL_RATE_FLUSH (3*HZ)
#define IWL_RATE_WIN_FLUSH (HZ/2)
#define IWL_RATE_HIGH_TH 11520
+#define IWL_SUCCESS_UP_TH 8960
+#define IWL_SUCCESS_DOWN_TH 10880
#define IWL_RATE_MIN_FAILURE_TH 8
#define IWL_RATE_MIN_SUCCESS_TH 8
#define IWL_RATE_DECREASE_TH 1920
@@ -206,6 +208,7 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)

#define IWL_RATE_FLUSH_MAX 5000 /* msec */
#define IWL_RATE_FLUSH_MIN 50 /* msec */
+#define IWL_AVERAGE_PACKETS 1500

static void iwl3945_bg_rate_scale_flush(unsigned long data)
{
@@ -220,8 +223,6 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)

spin_lock_irqsave(&rs_sta->lock, flags);

- rs_sta->flush_pending = 0;
-
/* Number of packets Rx'd since last time this timer ran */
packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1;

@@ -230,7 +231,6 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
if (unflushed) {
duration =
jiffies_to_msecs(jiffies - rs_sta->last_partial_flush);
-/* duration = jiffies_to_msecs(rs_sta->flush_time); */

IWL_DEBUG_RATE("Tx'd %d packets in %dms\n",
packet_count, duration);
@@ -242,9 +242,11 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
pps = 0;

if (pps) {
- duration = IWL_RATE_FLUSH_MAX / pps;
+ duration = (IWL_AVERAGE_PACKETS * 1000) / pps;
if (duration < IWL_RATE_FLUSH_MIN)
duration = IWL_RATE_FLUSH_MIN;
+ else if (duration > IWL_RATE_FLUSH_MAX)
+ duration = IWL_RATE_FLUSH_MAX;
} else
duration = IWL_RATE_FLUSH_MAX;

@@ -257,8 +259,10 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
rs_sta->flush_time);

rs_sta->last_partial_flush = jiffies;
+ } else {
+ rs_sta->flush_time = IWL_RATE_FLUSH;
+ rs_sta->flush_pending = 0;
}
-
/* If there weren't any unflushed entries, we don't schedule the timer
* to run again */

@@ -278,17 +282,18 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
*/
static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
struct iwl3945_rate_scale_data *window,
- int success, int retries)
+ int success, int retries, int index)
{
unsigned long flags;
+ s32 fail_count;

if (!retries) {
IWL_DEBUG_RATE("leave: retries == 0 -- should be at least 1\n");
return;
}

+ spin_lock_irqsave(&rs_sta->lock, flags);
while (retries--) {
- spin_lock_irqsave(&rs_sta->lock, flags);

/* If we have filled up the window then subtract one from the
* success counter if the high-bit is counting toward
@@ -316,8 +321,18 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
/* Tag this window as having been updated */
window->stamp = jiffies;

- spin_unlock_irqrestore(&rs_sta->lock, flags);
}
+
+ fail_count = window->counter - window->success_counter;
+ if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) ||
+ (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH))
+ window->average_tpt = ((window->success_ratio *
+ rs_sta->expected_tpt[index] + 64) / 128);
+ else
+ window->average_tpt = IWL_INV_TPT;
+
+ spin_unlock_irqrestore(&rs_sta->lock, flags);
+
}

static void rs_rate_init(void *priv, struct ieee80211_supported_band *sband,
@@ -429,19 +444,16 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
struct ieee80211_sta *sta, void *priv_sta,
struct sk_buff *skb)
{
- u8 retries = 0, current_count;
+ s8 retries = 0, current_count;
int scale_rate_index, first_index, last_index;
unsigned long flags;
struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
struct iwl3945_rs_sta *rs_sta = priv_sta;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- int i;

IWL_DEBUG_RATE("enter\n");

- for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
- retries += info->status.rates[i].count;
- retries--;
+ retries = info->status.rates[0].count;

first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
@@ -469,9 +481,9 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
* at which the frame was finally transmitted (or failed if no
* ACK)
*/
- while (retries > 0) {
- if (retries < priv->retry_rate) {
- current_count = retries;
+ while (retries > 1) {
+ if ((retries - 1) < priv->retry_rate) {
+ current_count = (retries - 1);
last_index = scale_rate_index;
} else {
current_count = priv->retry_rate;
@@ -483,15 +495,13 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
* as was used for it (per current_count) */
iwl3945_collect_tx_data(rs_sta,
&rs_sta->win[scale_rate_index],
- 0, current_count);
+ 0, current_count, scale_rate_index);
IWL_DEBUG_RATE("Update rate %d for %d retries.\n",
scale_rate_index, current_count);

retries -= current_count;

- if (retries)
- scale_rate_index =
- iwl3945_rs_next_rate(priv, scale_rate_index);
+ scale_rate_index = last_index;
}


@@ -502,7 +512,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
"success" : "failure");
iwl3945_collect_tx_data(rs_sta,
&rs_sta->win[last_index],
- info->flags & IEEE80211_TX_STAT_ACK, 1);
+ info->flags & IEEE80211_TX_STAT_ACK, 1, last_index);

/* We updated the rate scale window -- if its been more than
* flush_time since the last run, schedule the flush
@@ -510,9 +520,10 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
spin_lock_irqsave(&rs_sta->lock, flags);

if (!rs_sta->flush_pending &&
- time_after(jiffies, rs_sta->last_partial_flush +
+ time_after(jiffies, rs_sta->last_flush +
rs_sta->flush_time)) {

+ rs_sta->last_partial_flush = jiffies;
rs_sta->flush_pending = 1;
mod_timer(&rs_sta->rate_scale_flush,
jiffies + rs_sta->flush_time);
@@ -661,8 +672,13 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,

spin_lock_irqsave(&rs_sta->lock, flags);

+ /* for recent assoc, choose best rate regarding
+ * to rssi value
+ */
if (rs_sta->start_rate != IWL_RATE_INVALID) {
- index = rs_sta->start_rate;
+ if (rs_sta->start_rate < index &&
+ (rate_mask & (1 << rs_sta->start_rate)))
+ index = rs_sta->start_rate;
rs_sta->start_rate = IWL_RATE_INVALID;
}

@@ -672,7 +688,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,

if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) &&
(window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) {
- window->average_tpt = IWL_INV_TPT;
spin_unlock_irqrestore(&rs_sta->lock, flags);

IWL_DEBUG_RATE("Invalid average_tpt on rate %d: "
@@ -686,8 +701,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,

}

- window->average_tpt = ((window->success_ratio *
- rs_sta->expected_tpt[index] + 64) / 128);
current_tpt = window->average_tpt;

high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask,
@@ -735,13 +748,15 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
}
}

- if ((window->success_ratio > IWL_RATE_HIGH_TH) ||
- (current_tpt > window->average_tpt)) {
- IWL_DEBUG_RATE("No action -- success_ratio [%d] > HIGH_TH or "
- "current_tpt [%d] > average_tpt [%d]\n",
- window->success_ratio,
- current_tpt, window->average_tpt);
- scale_action = 0;
+ if (scale_action == -1) {
+ if (window->success_ratio > IWL_SUCCESS_DOWN_TH)
+ scale_action = 0;
+ } else if (scale_action == 1) {
+ if (window->success_ratio < IWL_SUCCESS_UP_TH) {
+ IWL_DEBUG_RATE("No action -- success_ratio [%d] < "
+ "SUCCESS UP\n", window->success_ratio);
+ scale_action = 0;
+ }
}

switch (scale_action) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 96824e8..d422600 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -337,7 +337,7 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
u32 status = le32_to_cpu(tx_resp->status);
int rate_idx;
- int fail, i;
+ int fail;

if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) {
IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
@@ -356,27 +356,9 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv,
rate_idx -= IWL_FIRST_OFDM_RATE;

fail = tx_resp->failure_frame;
- for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
- int next = iwl3945_rs_next_rate(priv, rate_idx);

- info->status.rates[i].idx = rate_idx;
-
- /*
- * Put remaining into the last count as best approximation
- * of saying exactly what the hardware would have done...
- */
- if ((rate_idx == next) || (i == IEEE80211_TX_MAX_RATES - 1)) {
- info->status.rates[i].count = fail;
- break;
- }
-
- info->status.rates[i].count = priv->retry_rate;
- fail -= priv->retry_rate;
- rate_idx = next;
- if (fail <= 0)
- break;
- }
- info->status.rates[i].count++; /* add final attempt */
+ info->status.rates[0].idx = rate_idx;
+ info->status.rates[0].count = fail + 1; /* add final attempt */

/* tx_status->rts_retry_count = tx_resp->failure_rts; */
info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ?
--
1.5.4.3


2008-12-02 21:19:27

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 10/11] iwlwifi: rely on API version read from firmware

Hi Reinette,

> This adds the infrastructure to support older firmware APIs.
> The API version number is stored as part of the filename, we first try to
> load the most recent firmware and progressively try lower versions.
> The API version is also read from the firmware self and stored as part
> of the iwl_priv structure. Only firmware that is supported by driver will
> be loaded. The version number read from firmware is compared
> to supported versions in the driver not the API version used as part of
> filename.

thanks for doing this. This can really help smooth upgrade path in case
the firmware API changes.

> -MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
> -MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE);
> +MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
> +MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));

So we don't have clear semantics on how MODULE_FIRMWARE should be used.
The current way is that it list all potential firmware versions. So in
cases it support API -1 and -2, then it has to list both. And not only
the latest.

Personally I think we should not create too many macros here and just
list all the firmware files manually.

Regards

Marcel



2008-12-04 07:24:03

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 07/11] iwl3945: Fix iwl3945 rate scaling.

Reinette Chatre <[email protected]> writes:

> From: Abbas, Mohamed <[email protected]>
>
> 3945 rate scaling was broken in recent tree. This patch fix the following:
> 1- Get TX response info and update rates window.
> 2- Rate scaling selection.
> 3- Flush window timer.
>
> Signed-off-by: Mohamed Abbas <[email protected]>
> Signed-off-by: Reinette Chatre <[email protected]>

I just updated to latest wireless-testing (commit e81dc4db9) and it
contains this patch. Now rate control is working and iwconfig shows 54
Mbit/s rate when I'm close to AP. Thanks for fixing this.

--
Kalle Valo

2008-12-02 20:13:15

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 08/11] iwlwifi: fix DMA channel number in iwl_txq_ctx_stop

From: Zhu Yi <[email protected]>

The patch fixes the misuse of DMA channel number by Tx queue number in
iwl_tx_ctx_stop().

The problem was originally reported by Wu Fengguang who complains
iwlagn driver takes too long time when issuing `ifconfig wlan0 down`.
The patch now decreases the interface bring down time from 2 seconds
to 0.8 second.

This fixes bugs:
http://bugzilla.kernel.org/show_bug.cgi?id=11956
http://www.intellinuxwireless.org/bugzilla/show_bug.cgi?id=1790

Signed-off-by: Zhu Yi <[email protected]>
Tested-by: Fengguang Wu <[email protected]>
Acked-by: Tomas Winkler <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-4965.c | 1 +
drivers/net/wireless/iwlwifi/iwl-5000.c | 1 +
drivers/net/wireless/iwlwifi/iwl-dev.h | 4 +++-
drivers/net/wireless/iwlwifi/iwl-tx.c | 11 +++++------
4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index f90c9e9..93d3df8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -816,6 +816,7 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
}

priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
+ priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM;
priv->hw_params.scd_bc_tbls_size =
IWL49_NUM_QUEUES * sizeof(struct iwl4965_scd_bc_tbl);
priv->hw_params.max_stations = IWL4965_STATION_COUNT;
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index b6c57cb..f7a8df8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -827,6 +827,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
}

priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
+ priv->hw_params.dma_chnl_num = FH50_TCSR_CHNL_NUM;
priv->hw_params.scd_bc_tbls_size =
IWL50_NUM_QUEUES * sizeof(struct iwl5000_scd_bc_tbl);
priv->hw_params.max_stations = IWL5000_STATION_COUNT;
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 846b8b0..5f6805b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -508,6 +508,7 @@ struct iwl_sensitivity_ranges {
/**
* struct iwl_hw_params
* @max_txq_num: Max # Tx queues supported
+ * @dma_chnl_num: Number of Tx DMA/FIFO channels
* @scd_bc_tbls_size: size of scheduler byte count tables
* @tx/rx_chains_num: Number of TX/RX chains
* @valid_tx/rx_ant: usable antennas
@@ -525,7 +526,8 @@ struct iwl_sensitivity_ranges {
* @struct iwl_sensitivity_ranges: range of sensitivity values
*/
struct iwl_hw_params {
- u16 max_txq_num;
+ u8 max_txq_num;
+ u8 dma_chnl_num;
u16 scd_bc_tbls_size;
u8 tx_chains_num;
u8 rx_chains_num;
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 9e638c2..6614e67 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -611,7 +611,7 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
*/
void iwl_txq_ctx_stop(struct iwl_priv *priv)
{
- int txq_id;
+ int ch;
unsigned long flags;

/* Turn off all Tx DMA fifos */
@@ -624,12 +624,11 @@ void iwl_txq_ctx_stop(struct iwl_priv *priv)
priv->cfg->ops->lib->txq_set_sched(priv, 0);

/* Stop each Tx DMA channel, and wait for it to be idle */
- for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
- iwl_write_direct32(priv,
- FH_TCSR_CHNL_TX_CONFIG_REG(txq_id), 0x0);
+ for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) {
+ iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0);
iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG,
- FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE
- (txq_id), 200);
+ FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch),
+ 200);
}
iwl_release_nic_access(priv);
spin_unlock_irqrestore(&priv->lock, flags);
--
1.5.4.3


2008-12-02 20:13:15

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 09/11] iwlwifi: store ucode version number

From: Chatre, Reinette <[email protected]>

We store the ucode version number as part of
iwl_priv/iwl3945_priv. This enables us to determine
if particular ucode has support for features in order
to have driver support more than one ucode API.

Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945-commands.h | 6 ++++++
drivers/net/wireless/iwlwifi/iwl-3945.h | 4 +++-
drivers/net/wireless/iwlwifi/iwl-agn.c | 12 +++++++++---
drivers/net/wireless/iwlwifi/iwl-commands.h | 6 ++++++
drivers/net/wireless/iwlwifi/iwl-dev.h | 4 +++-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 12 +++++++++---
6 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
index 8772d9d..1bec123 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-commands.h
@@ -69,6 +69,12 @@
#ifndef __iwl_3945_commands_h__
#define __iwl_3945_commands_h__

+/* uCode version contains 4 values: Major/Minor/API/Serial */
+#define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24)
+#define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16)
+#define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
+#define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF)
+
enum {
REPLY_ALIVE = 0x1,
REPLY_ERROR = 0x2,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 2a924c1..972c454 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -505,7 +505,7 @@ struct fw_desc {

/* uCode file layout */
struct iwl3945_ucode {
- __le32 ver; /* major/minor/subminor */
+ __le32 ver; /* major/minor/API/serial */
__le32 inst_size; /* bytes of runtime instructions */
__le32 data_size; /* bytes of runtime data */
__le32 init_size; /* bytes of initialization instructions */
@@ -762,6 +762,8 @@ struct iwl3945_priv {
void __iomem *hw_base;

/* uCode images, save to reload in case of failure */
+ u32 ucode_ver; /* ucode version, copy of
+ iwl3945_ucode.ver */
struct fw_desc ucode_code; /* runtime inst */
struct fw_desc ucode_data; /* runtime data original */
struct fw_desc ucode_data_backup; /* runtime data save/restore */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 4bdd33b..c906260 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1579,7 +1579,7 @@ static int iwl_read_ucode(struct iwl_priv *priv)
const char *name = priv->cfg->fw_name;
u8 *src;
size_t len;
- u32 ver, inst_size, data_size, init_size, init_data_size, boot_size;
+ u32 inst_size, data_size, init_size, init_data_size, boot_size;

/* Ask kernel firmware_class module to get the boot firmware off disk.
* request_firmware() is synchronous, file is in memory on return. */
@@ -1603,14 +1603,20 @@ static int iwl_read_ucode(struct iwl_priv *priv)
/* Data from ucode file: header followed by uCode images */
ucode = (void *)ucode_raw->data;

- ver = le32_to_cpu(ucode->ver);
+ priv->ucode_ver = le32_to_cpu(ucode->ver);
inst_size = le32_to_cpu(ucode->inst_size);
data_size = le32_to_cpu(ucode->data_size);
init_size = le32_to_cpu(ucode->init_size);
init_data_size = le32_to_cpu(ucode->init_data_size);
boot_size = le32_to_cpu(ucode->boot_size);

- IWL_DEBUG_INFO("f/w package hdr ucode version = 0x%x\n", ver);
+ IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
+ priv->ucode_ver);
+ IWL_DEBUG_INFO("f/w package hdr ucode version = %u.%u.%u.%u\n",
+ IWL_UCODE_MAJOR(priv->ucode_ver),
+ IWL_UCODE_MINOR(priv->ucode_ver),
+ IWL_UCODE_API(priv->ucode_ver),
+ IWL_UCODE_SERIAL(priv->ucode_ver));
IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n",
inst_size);
IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index d6196b9..0db151b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -69,6 +69,12 @@
#ifndef __iwl_commands_h__
#define __iwl_commands_h__

+/* uCode version contains 4 values: Major/Minor/API/Serial */
+#define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24)
+#define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16)
+#define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8)
+#define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF)
+
enum {
REPLY_ALIVE = 0x1,
REPLY_ERROR = 0x2,
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 5f6805b..a19fbb5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -462,7 +462,7 @@ struct fw_desc {

/* uCode file layout */
struct iwl_ucode {
- __le32 ver; /* major/minor/subminor */
+ __le32 ver; /* major/minor/API/serial */
__le32 inst_size; /* bytes of runtime instructions */
__le32 data_size; /* bytes of runtime data */
__le32 init_size; /* bytes of initialization instructions */
@@ -843,6 +843,8 @@ struct iwl_priv {
u8 rev_id;

/* uCode images, save to reload in case of failure */
+ u32 ucode_ver; /* version of ucode, copy of
+ iwl_ucode.ver */
struct fw_desc ucode_code; /* runtime inst */
struct fw_desc ucode_data; /* runtime data original */
struct fw_desc ucode_data_backup; /* runtime data save/restore */
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 074b43c..c003814 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -5341,7 +5341,7 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
const char *name = priv->cfg->fw_name;
u8 *src;
size_t len;
- u32 ver, inst_size, data_size, init_size, init_data_size, boot_size;
+ u32 inst_size, data_size, init_size, init_data_size, boot_size;

/* Ask kernel firmware_class module to get the boot firmware off disk.
* request_firmware() is synchronous, file is in memory on return. */
@@ -5365,14 +5365,20 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
/* Data from ucode file: header followed by uCode images */
ucode = (void *)ucode_raw->data;

- ver = le32_to_cpu(ucode->ver);
+ priv->ucode_ver = le32_to_cpu(ucode->ver);
inst_size = le32_to_cpu(ucode->inst_size);
data_size = le32_to_cpu(ucode->data_size);
init_size = le32_to_cpu(ucode->init_size);
init_data_size = le32_to_cpu(ucode->init_data_size);
boot_size = le32_to_cpu(ucode->boot_size);

- IWL_DEBUG_INFO("f/w package hdr ucode version = 0x%x\n", ver);
+ IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n",
+ priv->ucode_ver);
+ IWL_DEBUG_INFO("f/w package hdr ucode version = %u.%u.%u.%u\n",
+ IWL_UCODE_MAJOR(priv->ucode_ver),
+ IWL_UCODE_MINOR(priv->ucode_ver),
+ IWL_UCODE_API(priv->ucode_ver),
+ IWL_UCODE_SERIAL(priv->ucode_ver));
IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", inst_size);
IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", data_size);
IWL_DEBUG_INFO("f/w package hdr init inst size = %u\n", init_size);
--
1.5.4.3


2008-12-02 20:13:17

by Reinette Chatre

[permalink] [raw]
Subject: [PATCH 11/11] iwl3945 : Fix a-band association for passive channels

From: Abhijeet Kolekar <[email protected]>

Patch does following things
1) This patch fixes the a-band association for passive channels with new
uCode feature that it allows direct scan on passive channels after
auto-switch from passive to active. This enables sending of direct probes
on passive channels, as long as some traffic is detected on that channel.
This improves the scanning for hidden SSIDs in A-band,which is all
passive channels.

This patch fixes the bug no 1748.

http://www.intellinuxwireless.org/bugzilla/show_bug.cgi?id=1748

2) This fix will only work with uCode version 15.28.2.8 and above.
Prior versions of uCode would work only if we heard the traffic within
active dwell time, which is much shorter than passive dwell time and
is shorter than typical beacon periods. This patch also provids full
active dwell time even if we hear traffic late in passive dwell.

3) uCode API version is incremented to 2.

Signed-off-by: Abhijeet Kolekar <[email protected]>
Signed-off-by: Zhu Yi <[email protected]>
Acked-by: Ben Cahill <[email protected]>
Signed-off-by: Reinette Chatre <[email protected]>
---
drivers/net/wireless/iwlwifi/iwl-3945.h | 2 +-
drivers/net/wireless/iwlwifi/iwl3945-base.c | 30 ++++++++++++++++++++------
2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index d6502b4..5c2c15e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -51,7 +51,7 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
#include "iwl-3945-led.h"

/* Highest firmware API version supported */
-#define IWL3945_UCODE_API_MAX 1
+#define IWL3945_UCODE_API_MAX 2

/* Lowest firmware API version supported */
#define IWL3945_UCODE_API_MIN 1
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 8e14607..e9e30cb 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -4824,17 +4824,33 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
continue;
}

+ scan_ch->active_dwell = cpu_to_le16(active_dwell);
+ scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
+ /* If passive , set up for auto-switch
+ * and use long active_dwell time.
+ */
if (!is_active || is_channel_passive(ch_info) ||
- (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
+ (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
scan_ch->type = 0; /* passive */
- else
+ if (IWL_UCODE_API(priv->ucode_ver) == 1)
+ scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1);
+ } else {
scan_ch->type = 1; /* active */
+ }

- if ((scan_ch->type & 1) && n_probes)
- scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
-
- scan_ch->active_dwell = cpu_to_le16(active_dwell);
- scan_ch->passive_dwell = cpu_to_le16(passive_dwell);
+ /* Set direct probe bits. These may be used both for active
+ * scan channels (probes gets sent right away),
+ * or for passive channels (probes get se sent only after
+ * hearing clear Rx packet).*/
+ if (IWL_UCODE_API(priv->ucode_ver) >= 2) {
+ if (n_probes)
+ scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
+ } else {
+ /* uCode v1 does not allow setting direct probe bits on
+ * passive channel. */
+ if ((scan_ch->type & 1) && n_probes)
+ scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes);
+ }

/* Set txpower levels to defaults */
scan_ch->tpc.dsp_atten = 110;
--
1.5.4.3


2008-12-02 21:44:08

by Reinette Chatre

[permalink] [raw]
Subject: Re: [PATCH 10/11] iwlwifi: rely on API version read from firmware

On Tue, 2008-12-02 at 13:19 -0800, Marcel Holtmann wrote:
> Hi Reinette,
>
> > This adds the infrastructure to support older firmware APIs.
> > The API version number is stored as part of the filename, we first try to
> > load the most recent firmware and progressively try lower versions.
> > The API version is also read from the firmware self and stored as part
> > of the iwl_priv structure. Only firmware that is supported by driver will
> > be loaded. The version number read from firmware is compared
> > to supported versions in the driver not the API version used as part of
> > filename.
>
> thanks for doing this. This can really help smooth upgrade path in case
> the firmware API changes.
>
> > -MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
> > -MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE);
> > +MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
> > +MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
>
> So we don't have clear semantics on how MODULE_FIRMWARE should be used.
> The current way is that it list all potential firmware versions. So in
> cases it support API -1 and -2, then it has to list both. And not only
> the latest.

Even though the driver supports older firmware we really want the user
to use the latest firmware. The driver will also print a clear error if
the user is using API -1 and the latest available is -2. For this reason
we do want to make clear through MODULE_FIRMWARE which firmware the
driver would like to work with: the latest.

> Personally I think we should not create too many macros here and just
> list all the firmware files manually.

Having one spot to change when a new API is supported makes the code
less error prone.

Reinette


2008-12-02 22:50:14

by Reinette Chatre

[permalink] [raw]
Subject: Re: [PATCH 10/11] iwlwifi: rely on API version read from firmware

On Tue, 2008-12-02 at 13:51 -0800, Marcel Holtmann wrote:
> Hi Reinette,
>
> > > > This adds the infrastructure to support older firmware APIs.
> > > > The API version number is stored as part of the filename, we first try to
> > > > load the most recent firmware and progressively try lower versions.
> > > > The API version is also read from the firmware self and stored as part
> > > > of the iwl_priv structure. Only firmware that is supported by driver will
> > > > be loaded. The version number read from firmware is compared
> > > > to supported versions in the driver not the API version used as part of
> > > > filename.
> > >
> > > thanks for doing this. This can really help smooth upgrade path in case
> > > the firmware API changes.
> > >
> > > > -MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE);
> > > > -MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE);
> > > > +MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
> > > > +MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
> > >
> > > So we don't have clear semantics on how MODULE_FIRMWARE should be used.
> > > The current way is that it list all potential firmware versions. So in
> > > cases it support API -1 and -2, then it has to list both. And not only
> > > the latest.
> >
> > Even though the driver supports older firmware we really want the user
> > to use the latest firmware. The driver will also print a clear error if
> > the user is using API -1 and the latest available is -2. For this reason
> > we do want to make clear through MODULE_FIRMWARE which firmware the
> > driver would like to work with: the latest.
>
> as I said, we never clearly defined the semantics of MODULE_FIRMWARE for
> these cases. The only problem that I see is that some initrd tools are
> actually using MODULE_FIRMWARE to figure which files need to be included
> for the builtin kernel drivers. So on a system with old firmware only,
> it will not include these.

This seems to fit in with the other suggestion you had to add a big
warning to modules_install when MODULE_FIRMWARE is not present on the
filesystem. We want users to have a working wireless system at the time
they find out they need new firmware. So, if initrd figures out it needs
new firmware the user can just go and download it at that time.

>
> Maybe we need to extend MODULE_FIRMWARE. Maybe something like
> MODULE_ALTERNATE_FIRMWARE or some extra flags.

I don't think this is necessary.

Reinette