2007-07-26 03:29:03

by Zhu Yi

[permalink] [raw]
Subject: [PATCH] iwlwifi: provide frequency to radiotap monitor not channel index

From: Andy Green <[email protected]>

iwlwifi wrongly provides the channel index to the radiotap header
on Monitor mode. This results in tcpdump showing "6MHz" for example.

This patch arranges to send the frequency in MHz instead eg, 2437MHz

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

diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c
index a1ebc2a..8671891 100644
--- a/drivers/net/wireless/iwl-base.c
+++ b/drivers/net/wireless/iwl-base.c
@@ -3120,7 +3120,6 @@ void iwl_handle_data_packet_monitor(struct iwl_priv *priv,
* the information provided in the skb from the hardware */
s8 signal = stats->ssi;
s8 noise = 0;
- u16 channel = stats->channel;
int rate = stats->rate;
u64 tsf = stats->mactime;

@@ -3162,8 +3161,8 @@ void iwl_handle_data_packet_monitor(struct iwl_priv *priv,
iwl_rt->rt_dbmsignal = signal;
iwl_rt->rt_dbmnoise = noise;

- /* Convert the channel data and set the flags */
- iwl_rt->rt_channel = cpu_to_le16(channel);
+ /* Convert the channel frequency and set the flags */
+ iwl_rt->rt_channelMHz = cpu_to_le16(stats->freq);
if (!(phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK)) {
iwl_rt->rt_chbitmask =
cpu_to_le16((IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ));
diff --git a/drivers/net/wireless/iwlwifi.h b/drivers/net/wireless/iwlwifi.h
index a86fc48..58e3ea6 100644
--- a/drivers/net/wireless/iwlwifi.h
+++ b/drivers/net/wireless/iwlwifi.h
@@ -104,7 +104,7 @@ struct iwl_rt_rx_hdr {
__le64 rt_tsf; /* TSF */
u8 rt_flags; /* radiotap packet flags */
u8 rt_rate; /* rate in 500kb/s */
- __le16 rt_channel; /* channel in mHz */
+ __le16 rt_channelMHz; /* channel in MHz */
__le16 rt_chbitmask; /* channel bitfield */
s8 rt_dbmsignal; /* signal in dBm, kluged to signed */
s8 rt_dbmnoise;
--
1.5.2


2007-07-26 03:29:04

by Zhu Yi

[permalink] [raw]
Subject: [PATCH] iwlwifi: cleanup tx queue allocation

From: Tomas Winkler <[email protected]>

The following patch cleans up tx queue allocation. Change txq bd
from u8* to struct iwl_tdf_frame. This allows kill
txq->q.element_size and do strong type changing. Most importantly
in increasing number of slots from 64 to 256 for TX queues. This is
crucial for good TX performance in HT aggregation.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Zhu Yi <[email protected]>
---
drivers/net/wireless/iwl-3945.c | 15 +++++++--------
drivers/net/wireless/iwl-4965.c | 6 +++---
drivers/net/wireless/iwl-base.c | 31 +++++++++++++++----------------
drivers/net/wireless/iwl-hw.h | 2 +-
drivers/net/wireless/iwlwifi.h | 3 +--
5 files changed, 27 insertions(+), 30 deletions(-)

diff --git a/drivers/net/wireless/iwl-3945.c b/drivers/net/wireless/iwl-3945.c
index 6683778..eb8226a 100644
--- a/drivers/net/wireless/iwl-3945.c
+++ b/drivers/net/wireless/iwl-3945.c
@@ -842,7 +842,7 @@ static int iwl3945_tx_reset(struct iwl_priv *priv)
static int iwl3945_txq_ctx_reset(struct iwl_priv *priv)
{
int rc;
- int i, num_slots;
+ int txq_id, slots_num;

iwl_hw_txq_ctx_free(priv);

@@ -852,13 +852,14 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv)
goto error;

/* Tx queue(s) */
- for (i = 0; i < TFD_QUEUE_MAX; i++) {
- num_slots =
- (i == IWL_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS :
+ for (txq_id = 0; txq_id < TFD_QUEUE_MAX; txq_id++) {
+ slots_num =
+ (txq_id == IWL_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS :
TFD_TX_CMD_SLOTS;
- rc = iwl_tx_queue_init(priv, &priv->txq[i], num_slots, i);
+ rc = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num,
+ txq_id);
if (rc) {
- IWL_ERROR("Tx %d queue init failed\n", i);
+ IWL_ERROR("Tx %d queue init failed\n", txq_id);
goto error;
}
}
@@ -2109,8 +2110,6 @@ int iwl_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq)

shared_data->tx_base_ptr[txq_id] = (u32) txq->q.dma_addr;

- txq->q.element_size = sizeof(struct iwl_tfd_frame);
-
spin_lock_irqsave(&priv->lock, flags);
rc = iwl_grab_restricted_access(priv);
if (rc) {
diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c
index 3f1a339..03e3708 100644
--- a/drivers/net/wireless/iwl-4965.c
+++ b/drivers/net/wireless/iwl-4965.c
@@ -366,7 +366,7 @@ static void iwl4965_kw_free(struct iwl_priv *priv)
static int iwl4965_txq_ctx_reset(struct iwl_priv *priv)
{
int rc = 0;
- int txq_id, num_slots;
+ int txq_id, slots_num;
unsigned long flags;

iwl4965_kw_free(priv);
@@ -401,9 +401,9 @@ static int iwl4965_txq_ctx_reset(struct iwl_priv *priv)

/* Tx queue(s) */
for (txq_id = 0; txq_id < priv->hw_setting.max_queue_number; txq_id++) {
- num_slots = (txq_id == IWL_CMD_QUEUE_NUM) ?
+ slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ?
TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
- rc = iwl_tx_queue_init(priv, &priv->txq[txq_id], num_slots,
+ rc = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num,
txq_id);
if (rc) {
IWL_ERROR("Tx %d queue init failed\n", txq_id);
diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c
index 1437f66..82470f1 100644
--- a/drivers/net/wireless/iwl-base.c
+++ b/drivers/net/wireless/iwl-base.c
@@ -179,10 +179,10 @@ static inline u8 get_next_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
}

static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
- int count, int size, u32 id)
+ int count, int slots_num, u32 id)
{
q->n_bd = count;
- q->n_window = size;
+ q->n_window = slots_num;
q->id = id;

q->low_mark = q->n_window / 4;
@@ -199,7 +199,7 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
}

static int iwl_tx_queue_alloc(struct iwl_priv *priv,
- struct iwl_tx_queue *txq, int count, u32 id)
+ struct iwl_tx_queue *txq, u32 id)
{
struct pci_dev *dev = priv->pci_dev;

@@ -215,13 +215,12 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
txq->txb = NULL;

txq->bd = pci_alloc_consistent(dev,
- sizeof(struct iwl_tfd_frame) * TFD_QUEUE_SIZE_MAX,
+ sizeof(txq->bd[0]) * TFD_QUEUE_SIZE_MAX,
&txq->q.dma_addr);

- txq->q.element_size = sizeof(struct iwl_tfd_frame);
if (!txq->bd) {
IWL_ERROR("pci_alloc_consistent(%zd) failed\n",
- sizeof(txq->bd[0]) * count);
+ sizeof(txq->bd[0]) * TFD_QUEUE_SIZE_MAX);
goto error;
}
txq->q.id = id;
@@ -238,7 +237,7 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
}

int iwl_tx_queue_init(struct iwl_priv *priv,
- struct iwl_tx_queue *txq, int count, u32 txq_id)
+ struct iwl_tx_queue *txq, int slots_num, u32 txq_id)
{
struct pci_dev *dev = priv->pci_dev;
int len;
@@ -247,14 +246,14 @@ int iwl_tx_queue_init(struct iwl_priv *priv,
/* alocate command space + one big command for scan since scan
* command is very huge the system will not have two scan at the
* same time */
- len = sizeof(struct iwl_cmd) * count;
+ len = sizeof(struct iwl_cmd) * slots_num;
if (txq_id == IWL_CMD_QUEUE_NUM);
len += IWL_MAX_SCAN_SIZE;
txq->cmd = pci_alloc_consistent(dev, len, &txq->dma_addr_cmd);
if (!txq->cmd)
return -ENOMEM;

- rc = iwl_tx_queue_alloc(priv, txq, count, txq_id);
+ rc = iwl_tx_queue_alloc(priv, txq, txq_id);
if (rc) {
pci_free_consistent(dev, len, txq->cmd, txq->dma_addr_cmd);

@@ -262,7 +261,7 @@ int iwl_tx_queue_init(struct iwl_priv *priv,
}

txq->need_update = 0;
- iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, count, txq_id);
+ iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
iwl_hw_tx_queue_init(priv, txq);

return 0;
@@ -551,7 +550,7 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
{
struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
struct iwl_queue *q = &txq->q;
- u8 *tfd;
+ struct iwl_tfd_frame *tfd;
u32 *control_flags;
struct iwl_cmd *out_cmd;
u32 idx = 0;
@@ -573,8 +572,8 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
IWL_ERROR("No space for Tx\n");
return -ENOSPC;
}
- tfd = &txq->bd[q->first_empty * q->element_size];
- memset(tfd, 0, q->element_size);
+ tfd = &txq->bd[q->first_empty];
+ memset(tfd, 0, sizeof(*tfd));

control_flags = (u32 *) tfd;

@@ -2754,7 +2753,7 @@ static int iwl_tx_skb(struct iwl_priv *priv,
struct sk_buff *skb, struct ieee80211_tx_control *ctl)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
- u8 *tfd;
+ struct iwl_tfd_frame *tfd;
u32 *control_flags;
int txq_id = ctl->queue;
struct iwl_tx_queue *txq = NULL;
@@ -2845,8 +2844,8 @@ static int iwl_tx_skb(struct iwl_priv *priv,
q = &txq->q;

spin_lock_irqsave(&priv->lock, flags);
- tfd = (u8 *) (&txq->bd[q->first_empty * q->element_size]);
- memset(tfd, 0, q->element_size);
+ tfd = &txq->bd[q->first_empty];
+ memset(tfd, 0, sizeof(*tfd));
control_flags = (u32 *) tfd;
idx = get_next_cmd_index(q, q->first_empty, 0);

diff --git a/drivers/net/wireless/iwl-hw.h b/drivers/net/wireless/iwl-hw.h
index 4b3cd37..3f7e5bd 100644
--- a/drivers/net/wireless/iwl-hw.h
+++ b/drivers/net/wireless/iwl-hw.h
@@ -1231,7 +1231,7 @@ struct statistics {
#define TFD_CTL_PAD_SET(n) (n<<28)
#define TFD_CTL_PAD_GET(ctl) (ctl>>28)

-#define TFD_TX_CMD_SLOTS 64
+#define TFD_TX_CMD_SLOTS 256
#define TFD_CMD_SLOTS 32

#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
diff --git a/drivers/net/wireless/iwlwifi.h b/drivers/net/wireless/iwlwifi.h
index 58e3ea6..d0403d0 100644
--- a/drivers/net/wireless/iwlwifi.h
+++ b/drivers/net/wireless/iwlwifi.h
@@ -134,7 +134,6 @@ struct iwl_queue {
dma_addr_t dma_addr; /* physical addr for BD's */
int n_window; /* safe queue window */
u32 id;
- u32 element_size;
int low_mark; /* low watermark, resume queue if free
* space more than this */
int high_mark; /* high watermark, stop queue if free
@@ -157,7 +156,7 @@ struct iwl_tx_info {
*/
struct iwl_tx_queue {
struct iwl_queue q;
- u8 *bd;
+ struct iwl_tfd_frame *bd;
struct iwl_cmd *cmd;
dma_addr_t dma_addr_cmd;
struct iwl_tx_info *txb;
--
1.5.2

2007-07-26 07:15:35

by Andy Green

[permalink] [raw]
Subject: Re: [PATCH] iwlwifi: provide frequency to radiotap monitor not channel index

Somebody in the thread at some point said:

> From: Andy Green <[email protected]>
>
> iwlwifi wrongly provides the channel index to the radiotap header
> on Monitor mode. This results in tcpdump showing "6MHz" for example.
>
> This patch arranges to send the frequency in MHz instead eg, 2437MHz
>
> Signed-off-by: Andy Green <[email protected]>
> Signed-off-by: Zhu Yi <[email protected]>

Thanks.

-Andy

2007-07-26 03:29:00

by Zhu Yi

[permalink] [raw]
Subject: [PATCH] iwlwifi: Calculate and report noise level while associated

From: Cahill, Ben M <[email protected]>

The patch fixed the "Noise level" info from iwconfig disappeared
after association bug.

Signed-off-by: Cahill, Ben M <[email protected]>
Signed-off-by: Zhu Yi <[email protected]>
---
drivers/net/wireless/iwl-4965.c | 90 +++++++++++++++++++++++++++------------
drivers/net/wireless/iwl-4965.h | 2 +-
drivers/net/wireless/iwl-base.c | 2 +-
drivers/net/wireless/iwl-priv.h | 6 +--
4 files changed, 67 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c
index caefb2c..9991956 100644
--- a/drivers/net/wireless/iwl-4965.c
+++ b/drivers/net/wireless/iwl-4965.c
@@ -3459,6 +3459,43 @@ static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv)
return 1;
}

+/* Calculate noise level, based on measurements during network silence just
+ * before arriving beacon. This measurement can be done only if we know
+ * exactly when to expect beacons, therefore only when we're associated. */
+static void iwl4965_rx_calc_noise(struct iwl_priv *priv)
+{
+ struct statistics_rx_non_phy *rx_info
+ = &(priv->statistics.rx.general);
+ int num_active_rx = 0;
+ int total_silence = 0;
+ int bcn_silence_a = rx_info->beacon_silence_rssi_a & IN_BAND_FILTER;
+ int bcn_silence_b = rx_info->beacon_silence_rssi_b & IN_BAND_FILTER;
+ int bcn_silence_c = rx_info->beacon_silence_rssi_c & IN_BAND_FILTER;
+
+ if (bcn_silence_a) {
+ total_silence += bcn_silence_a;
+ num_active_rx++;
+ }
+ if (bcn_silence_b) {
+ total_silence += bcn_silence_b;
+ num_active_rx++;
+ }
+ if (bcn_silence_c) {
+ total_silence += bcn_silence_c;
+ num_active_rx++;
+ }
+
+ /* Average among active antennas */
+ if (num_active_rx)
+ priv->last_rx_noise = (total_silence / num_active_rx) - 107;
+ else
+ priv->last_rx_noise = -127;
+
+ IWL_DEBUG_CALIB("inband silence a %u, b %u, c %u, dBm %d\n",
+ bcn_silence_a, bcn_silence_b, bcn_silence_c,
+ priv->last_rx_noise);
+}
+
void iwl_hw_rx_statistics(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
{
struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
@@ -3485,11 +3522,14 @@ void iwl_hw_rx_statistics(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
mod_timer(&priv->statistics_periodic, jiffies +
msecs_to_jiffies(REG_RECALIB_PERIOD * 1000));

-#ifdef CONFIG_IWLWIFI_SENSITIVITY
if (unlikely(!(priv->status & STATUS_SCANNING)) &&
- (pkt->hdr.cmd == STATISTICS_NOTIFICATION))
+ (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) {
+ iwl4965_rx_calc_noise(priv);
+#ifdef CONFIG_IWLWIFI_SENSITIVITY
queue_work(priv->workqueue, &priv->sensitivity_work);
#endif
+ }
+
/* If the hardware hasn't reported a change in
* temperature then don't bother computing a
* calibrated temperature value */
@@ -3828,46 +3868,42 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv,
/* Find max signal strength (dBm) among 3 antenna/receiver chains */
stats.ssi = iwl4965_calc_rssi(rx_start);

- IWL_DEBUG_RX("Rssi %d, TSF %llu\n", stats.ssi,
- le64_to_cpu(rx_start->timestamp));
-
- /* Sensitivity algo, if used (only while associated, not scanning),
- * calculates signal-to-noise ratio in dB. Use this if available,
- * else calculate signal quality using only the signal strength. */
- if (priv->last_rx_snr && iwl_is_associated(priv) &&
- !(priv->status & STATUS_SCANNING)) {
- /* TODO: Find better noise level reference, use
- * in iwl_calc_sig_qual() */
- stats.noise = stats.ssi - priv->last_rx_snr;
- stats.signal = iwl_calc_sig_qual(stats.ssi, 0);
+ /* Meaningful noise values are available only from beacon statistics,
+ * which are gathered only when associated, and indicate noise
+ * only for the associated network channel ...
+ * Ignore these noise values while scanning (other channels) */
+ if (iwl_is_associated(priv) && !(priv->status & STATUS_SCANNING)) {
+ stats.noise = priv->last_rx_noise;
+ stats.signal = iwl_calc_sig_qual(stats.ssi, stats.noise);
} else {
+ stats.noise = -127;
stats.signal = iwl_calc_sig_qual(stats.ssi, 0);
+ }

- /* Reset noise values if not associated or snr not available. */
- /* Set default noise value to -127 ... this works better than
- * 0 when averaging frames with/without noise info;
- * measured dBm values are always negative ... using a
- * negative value as the default keeps all averages
- * within an s8's (used in some apps) range of negative
- * values. */
- priv->last_rx_snr = 0;
+ /* Reset beacon noise level if not associated.
+ * Use default noise value of -127 ... this works better than
+ * 0 when averaging frames with/without noise info;
+ * measured dBm values are always negative ... using a
+ * negative value as the default keeps all averages within
+ * an s8's (used in some apps) range of negative values. */
+ if (!iwl_is_associated(priv))
priv->last_rx_noise = -127;
- stats.noise = -127;
- }
- IWL_DEBUG_STATS("Rssi %d noise %d qual %d snr db %d\n", stats.ssi,
- stats.noise, stats.signal, priv->last_rx_snr);

#ifdef CONFIG_IWLWIFI_DEBUG
/* TODO: Parts of iwl_report_frame are broken for 4965 */
if (iwl_debug_level & (IWL_DL_RX))
/* Set "1" to report good data frames in groups of 100 */
iwl_report_frame(priv, pkt, header, 1);
+
+ if (iwl_debug_level & (IWL_DL_RX | IWL_DL_STATS))
+ IWL_DEBUG_RX("Rssi %d, noise %d, qual %d, TSF %lu\n",
+ stats.ssi, stats.noise, stats.signal,
+ (long unsigned int)le64_to_cpu(rx_start->timestamp));
#endif

network_packet = iwl_is_network_packet(priv, header);
if (network_packet) {
priv->last_rx_rssi = stats.ssi;
- priv->last_rx_noise = stats.noise;
priv->last_beacon_time = priv->ucode_beacon_time;
priv->last_tsf = le64_to_cpu(rx_start->timestamp);
}
diff --git a/drivers/net/wireless/iwl-4965.h b/drivers/net/wireless/iwl-4965.h
index a2452e9..816df54 100644
--- a/drivers/net/wireless/iwl-4965.h
+++ b/drivers/net/wireless/iwl-4965.h
@@ -197,7 +197,6 @@ struct iwl_lq_mngr {
/* Sensitivity and chain noise calibration */
#define INITIALIZATION_VALUE 0xFFFF
#define CAL_NUM_OF_BEACONS 20
-#define IN_BAND_FILTER 0xFF
#define MAXIMUM_ALLOWED_PATHLOSS 15

/* Param table within SENSITIVITY_CMD */
@@ -257,6 +256,7 @@ struct iwl_lq_mngr {
#define CHAIN_C 2
#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
#define ALL_BAND_FILTER 0xFF00
+#define IN_BAND_FILTER 0xFF
#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF

enum iwl_false_alarm_state {
diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c
index 8671891..7f8f2ac 100644
--- a/drivers/net/wireless/iwl-base.c
+++ b/drivers/net/wireless/iwl-base.c
@@ -3655,7 +3655,7 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv,
__le16 *qc = ieee80211_get_qos_ctrl(hdr);

if(qc == NULL) {
- IWL_ERROR("BUG_ON qc is null!!!!");
+ IWL_ERROR("BUG_ON qc is null!!!!\n");
return;
}

diff --git a/drivers/net/wireless/iwl-priv.h b/drivers/net/wireless/iwl-priv.h
index 0a0f4bc..9de898d 100644
--- a/drivers/net/wireless/iwl-priv.h
+++ b/drivers/net/wireless/iwl-priv.h
@@ -182,10 +182,8 @@ struct iwl_priv {
u32 status;
u32 config;

- int quality;
- int last_rx_rssi;
- int last_rx_noise;
- int last_rx_snr;
+ int last_rx_rssi; /* From Rx packet statisitics */
+ int last_rx_noise; /* From beacon statistics */

struct iwl_power_mgr power_data;

--
1.5.2

2007-07-26 03:29:03

by Zhu Yi

[permalink] [raw]
Subject: [PATCH] iwlwifi: modify station fix

From: Tomas Winkler <[email protected]>

This patch fixes bit mask for modify station parameters.
Using assignment (=) instead of adding (|). The later caused
bringing parameters from previous command to the current and
eventaully caused uCode error.

Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Zhu Yi <[email protected]>
---
drivers/net/wireless/iwl-4965.c | 10 +++++-----
drivers/net/wireless/iwl-base.c | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c
index 9991956..3f1a339 100644
--- a/drivers/net/wireless/iwl-4965.c
+++ b/drivers/net/wireless/iwl-4965.c
@@ -3759,7 +3759,7 @@ static void iwl4965_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK;
priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
priv->stations[sta_id].sta.sta.modify_mask = 0;
- priv->stations[sta_id].sta.mode |= STA_CONTROL_MODIFY_MSK;
+ priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
spin_unlock_irqrestore(&priv->sta_lock, lock_flags);
/* assuming we are in rx flow and the lock is already locked */
iwl_send_add_station(priv, &priv->stations[sta_id].sta,
@@ -4097,9 +4097,9 @@ static void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id,
unsigned long lock_flags;

spin_lock_irqsave(&priv->sta_lock, lock_flags);
- priv->stations[sta_id].sta.sta.modify_mask |= STA_MODIFY_TID_DISABLE_TX;
+ priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX;
priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le32(~(1 << tid));
- priv->stations[sta_id].sta.mode |= STA_CONTROL_MODIFY_MSK;
+ priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
spin_unlock_irqrestore(&priv->sta_lock, lock_flags);
iwl_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
}
@@ -4556,7 +4556,7 @@ static void iwl4965_sta_modify_add_ba_tid(struct iwl_priv *priv,
priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK;
priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid;
priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn);
- priv->stations[sta_id].sta.mode |= STA_CONTROL_MODIFY_MSK;
+ priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
spin_unlock_irqrestore(&priv->sta_lock, lock_flags);
iwl_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
}
@@ -4570,7 +4570,7 @@ static void iwl4965_sta_modify_del_ba_tid(struct iwl_priv *priv,
priv->stations[sta_id].sta.station_flags_msk = 0;
priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK;
priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid;
- priv->stations[sta_id].sta.mode |= STA_CONTROL_MODIFY_MSK;
+ priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
spin_unlock_irqrestore(&priv->sta_lock, lock_flags);
iwl_send_add_station(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
}
diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c
index 7f8f2ac..1437f66 100644
--- a/drivers/net/wireless/iwl-base.c
+++ b/drivers/net/wireless/iwl-base.c
@@ -1405,8 +1405,8 @@ static int iwl_update_sta_key_info(struct iwl_priv *priv,
memcpy(priv->stations[sta_id].sta.key.key, keyconf->key,
keyconf->keylen);
priv->stations[sta_id].sta.key.key_flags = key_flags;
- priv->stations[sta_id].sta.sta.modify_mask |= STA_MODIFY_KEY_MASK;
- priv->stations[sta_id].sta.mode |= STA_CONTROL_MODIFY_MSK;
+ priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
+ priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;

spin_unlock_irqrestore(&priv->sta_lock, flags);

--
1.5.2

2007-07-26 03:29:04

by Zhu Yi

[permalink] [raw]
Subject: [PATCH] iwlwifi: rxon filter_flags endianity fix

From: Tomas Winkler <[email protected]>

This patch fixes endianty issues in rxon.filter_flags.
It also discards usage of iwl_check_bits in some cases.
The result is the same but the semantic is not.

Signed-off-by: Gregory Greenman <[email protected]>
Signed-off-by: Tomas Winkler <[email protected]>
Signed-off-by: Zhu Yi <[email protected]>
---
drivers/net/wireless/iwl-base.c | 12 +++----
drivers/net/wireless/iwl-hw.h | 74 ++++++++++++++++++--------------------
2 files changed, 40 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c
index 82470f1..3d19a1a 100644
--- a/drivers/net/wireless/iwl-base.c
+++ b/drivers/net/wireless/iwl-base.c
@@ -984,15 +984,13 @@ static int iwl_full_rxon_required(struct iwl_priv *priv)
* flag transitions are allowed using RXON_ASSOC */

/* Check if we are not switching bands */
- if (iwl_check_bits(priv->staging_rxon.flags, RXON_FLG_BAND_24G_MSK) !=
- iwl_check_bits(priv->active_rxon.flags, RXON_FLG_BAND_24G_MSK))
+ if ((priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) !=
+ (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK))
return 1;

/* Check if we are switching association toggle */
- if (iwl_check_bits(priv->staging_rxon.filter_flags,
- RXON_FILTER_ASSOC_MSK) !=
- iwl_check_bits(priv->active_rxon.filter_flags,
- RXON_FILTER_ASSOC_MSK))
+ if ((priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) !=
+ (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK))
return 1;

return 0;
@@ -1154,7 +1152,7 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
"* bssid = " MAC_FMT "\n",
((priv->staging_rxon.filter_flags &
RXON_FILTER_ASSOC_MSK) ? "" : "out"),
- priv->staging_rxon.channel,
+ le16_to_cpu(priv->staging_rxon.channel),
MAC_ARG(priv->staging_rxon.bssid_addr));

/* Apply the new configuration */
diff --git a/drivers/net/wireless/iwl-hw.h b/drivers/net/wireless/iwl-hw.h
index 3f7e5bd..58afbf7 100644
--- a/drivers/net/wireless/iwl-hw.h
+++ b/drivers/net/wireless/iwl-hw.h
@@ -193,47 +193,43 @@ enum {
};

/* rx_config flags */
-enum {
- /* band & modulation selection */
- RXON_FLG_BAND_24G_MSK = (1 << 0),
- RXON_FLG_CCK_MSK = (1 << 1),
- /* auto detection enable */
- RXON_FLG_AUTO_DETECT_MSK = (1 << 2),
- /* TGg protection when tx */
- RXON_FLG_TGG_PROTECT_MSK = (1 << 3),
- /* cck short slot & preamble */
- RXON_FLG_SHORT_SLOT_MSK = (1 << 4),
- RXON_FLG_SHORT_PREAMBLE_MSK = (1 << 5),
- /* antenna selection */
- RXON_FLG_DIS_DIV_MSK = (1 << 7),
- RXON_FLG_ANT_SEL_MSK = 0x0f00,
- RXON_FLG_ANT_A_MSK = (1 << 8),
- RXON_FLG_ANT_B_MSK = (1 << 9),
- /* radar detection enable */
- RXON_FLG_RADAR_DETECT_MSK = (1 << 12),
- RXON_FLG_TGJ_NARROW_BAND_MSK = (1 << 13),
- /* rx response to host with 8-byte TSF
- * (according to ON_AIR deassertion) */
- RXON_FLG_TSF2HOST_MSK = (1 << 15)
-};
+/* band & modulation selection */
+#define RXON_FLG_BAND_24G_MSK __constant_cpu_to_le32(1 << 0)
+#define RXON_FLG_CCK_MSK __constant_cpu_to_le32(1 << 1)
+/* auto detection enable */
+#define RXON_FLG_AUTO_DETECT_MSK __constant_cpu_to_le32(1 << 2)
+/* TGg protection when tx */
+#define RXON_FLG_TGG_PROTECT_MSK __constant_cpu_to_le32(1 << 3)
+/* cck short slot & preamble */
+#define RXON_FLG_SHORT_SLOT_MSK __constant_cpu_to_le32(1 << 4)
+#define RXON_FLG_SHORT_PREAMBLE_MSK __constant_cpu_to_le32(1 << 5)
+/* antenna selection */
+#define RXON_FLG_DIS_DIV_MSK __constant_cpu_to_le32(1 << 7)
+#define RXON_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0x0f00)
+#define RXON_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8)
+#define RXON_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9)
+/* radar detection enable */
+#define RXON_FLG_RADAR_DETECT_MSK __constant_cpu_to_le32(1 << 12)
+#define RXON_FLG_TGJ_NARROW_BAND_MSK __constant_cpu_to_le32(1 << 13)
+/* rx response to host with 8-byte TSF
+* (according to ON_AIR deassertion) */
+#define RXON_FLG_TSF2HOST_MSK __constant_cpu_to_le32(1 << 15)

/* rx_config filter flags */
-enum {
- /* accept all data frames */
- RXON_FILTER_PROMISC_MSK = (1 << 0),
- /* pass control & management to host */
- RXON_FILTER_CTL2HOST_MSK = (1 << 1),
- /* accept multi-cast */
- RXON_FILTER_ACCEPT_GRP_MSK = (1 << 2),
- /* don't decrypt uni-cast frames */
- RXON_FILTER_DIS_DECRYPT_MSK = (1 << 3),
- /* don't decrypt multi-cast frames */
- RXON_FILTER_DIS_GRP_DECRYPT_MSK = (1 << 4),
- /* STA is associated */
- RXON_FILTER_ASSOC_MSK = (1 << 5),
- /* transfer to host non bssid beacons in associated state */
- RXON_FILTER_BCON_AWARE_MSK = (1 << 6)
-};
+/* accept all data frames */
+#define RXON_FILTER_PROMISC_MSK __constant_cpu_to_le32(1 << 0)
+/* pass control & management to host */
+#define RXON_FILTER_CTL2HOST_MSK __constant_cpu_to_le32(1 << 1)
+/* accept multi-cast */
+#define RXON_FILTER_ACCEPT_GRP_MSK __constant_cpu_to_le32(1 << 2)
+/* don't decrypt uni-cast frames */
+#define RXON_FILTER_DIS_DECRYPT_MSK __constant_cpu_to_le32(1 << 3)
+/* don't decrypt multi-cast frames */
+#define RXON_FILTER_DIS_GRP_DECRYPT_MSK __constant_cpu_to_le32(1 << 4)
+/* STA is associated */
+#define RXON_FILTER_ASSOC_MSK __constant_cpu_to_le32(1 << 5)
+/* transfer to host non bssid beacons in associated state */
+#define RXON_FILTER_BCON_AWARE_MSK __constant_cpu_to_le32(1 << 6)

/*
* RXON-Timings Command & Response
--
1.5.2