* [PATCH 1/7] iwlwifi: add IWLWIFI_HT Kconfig option [not found] <11858505963374-git-send-email-yi.zhu@intel.com> @ 2007-07-31 2:56 ` Zhu Yi 2007-07-31 2:56 ` [PATCH 2/7] iwlwifi: fix rate setting in beacon command Zhu Yi 0 siblings, 1 reply; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Zhu Yi Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/Kconfig | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index afb0871..daa7c9e 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -768,6 +768,15 @@ config IWLWIFI_DEBUG as the debug information can assist others in helping you resolve any problems you may encounter. +config IWLWIFI_HT + bool "Enable 802.11n HT features in iwlwifi drivers" + depends on EXPERIMENTAL + depends on IWLWIFI && MAC80211_HT + default n + ---help--- + This option enables IEEE 802.11n High Throughput features + for the iwlwifi drivers. + config IWL4965 tristate "Intel Wireless WiFi 4965AGN" depends on m && IWLWIFI && EXPERIMENTAL -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/7] iwlwifi: fix rate setting in beacon command 2007-07-31 2:56 ` [PATCH 1/7] iwlwifi: add IWLWIFI_HT Kconfig option Zhu Yi @ 2007-07-31 2:56 ` Zhu Yi 2007-07-31 2:56 ` [PATCH 3/7] iwlwifi: Endianity fix for TX host command Zhu Yi 0 siblings, 1 reply; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Tomas Winkler, Zhu Yi From: Tomas Winkler <tomas.winkler@intel.com> This patch fixed rate setting in beacon command. It removes invalid <= comparsion on unsinged values. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/iwl-3945.c | 2 +- drivers/net/wireless/iwl-4965.c | 11 ++++++----- drivers/net/wireless/iwl-base.c | 6 +++--- drivers/net/wireless/iwlwifi.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/iwl-3945.c b/drivers/net/wireless/iwl-3945.c index 8a534e1..b71e987 100644 --- a/drivers/net/wireless/iwl-3945.c +++ b/drivers/net/wireless/iwl-3945.c @@ -2231,7 +2231,7 @@ int iwl_hw_set_hw_setting(struct iwl_priv *priv) } int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl_frame *frame, u16 rate) + struct iwl_frame *frame, u8 rate) { struct iwl_tx_beacon_cmd *tx_beacon_cmd; int frame_size; diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c index cc2dd49..9f4d83a 100644 --- a/drivers/net/wireless/iwl-4965.c +++ b/drivers/net/wireless/iwl-4965.c @@ -2718,14 +2718,11 @@ int iwl_hw_get_temperature(struct iwl_priv *priv) } int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl_frame *frame, u16 rate) + struct iwl_frame *frame, u8 rate) { struct iwl_tx_beacon_cmd *tx_beacon_cmd; int frame_size; - if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP)) - rate |= RATE_MCS_CCK_MSK; - tx_beacon_cmd = &frame->u.beacon; memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); @@ -2739,7 +2736,11 @@ int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, tx_beacon_cmd->tx.len = frame_size; - tx_beacon_cmd->tx.rate.rate_n_flags = rate; + if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP)) + tx_beacon_cmd->tx.rate.rate_n_flags = rate|RATE_MCS_CCK_MSK; + else + tx_beacon_cmd->tx.rate.rate_n_flags = rate; + tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK); return (sizeof(*tx_beacon_cmd) + frame_size); diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c index 6e77a51..574d01c 100644 --- a/drivers/net/wireless/iwl-base.c +++ b/drivers/net/wireless/iwl-base.c @@ -1487,7 +1487,7 @@ static int iwl_send_beacon_cmd(struct iwl_priv *priv) { struct iwl_frame *frame; int frame_size, rc; - u16 rate; + u8 rate; frame = iwl_get_free_frame(priv); @@ -1500,11 +1500,11 @@ static int iwl_send_beacon_cmd(struct iwl_priv *priv) if (!(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)) { rate = iwl_rate_get_lowest_plcp(priv->active_rate_basic & 0xFF0); - if (rate <= 0) + if (rate == IWL_INVALID_RATE) rate = IWL_RATE_6M_PLCP; } else { rate = iwl_rate_get_lowest_plcp(priv->active_rate_basic & 0xF); - if (rate <= 0) + if (rate == IWL_INVALID_RATE) rate = IWL_RATE_1M_PLCP; } diff --git a/drivers/net/wireless/iwlwifi.h b/drivers/net/wireless/iwlwifi.h index 6941031..dff6f6f 100644 --- a/drivers/net/wireless/iwlwifi.h +++ b/drivers/net/wireless/iwlwifi.h @@ -692,7 +692,7 @@ extern int iwl_tx_queue_free_tfd(struct iwl_priv *priv, extern int iwl_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq); extern int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl_frame *frame, u16 rate); + struct iwl_frame *frame, u8 rate); extern int iwl_hw_get_rx_read(struct iwl_priv *priv); extern void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv, struct iwl_cmd *cmd, -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/7] iwlwifi: Endianity fix for TX host command 2007-07-31 2:56 ` [PATCH 2/7] iwlwifi: fix rate setting in beacon command Zhu Yi @ 2007-07-31 2:56 ` Zhu Yi 2007-07-31 2:56 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Zhu Yi 0 siblings, 1 reply; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Tomas Winkler, Zhu Yi From: Tomas Winkler <tomas.winkler@intel.com> This patch fixes endnianity issues in TX host command. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/iwl-3945-hw.h | 10 ++++++++++ drivers/net/wireless/iwl-4965-hw.h | 10 +++++++++- drivers/net/wireless/iwl-4965.c | 26 ++++++++++++++------------ drivers/net/wireless/iwl-base.c | 10 ++++++---- drivers/net/wireless/iwl-commands.h | 2 +- drivers/net/wireless/iwl-hw.h | 10 +++++----- 6 files changed, 45 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/iwl-3945-hw.h b/drivers/net/wireless/iwl-3945-hw.h index b127450..81c7263 100644 --- a/drivers/net/wireless/iwl-3945-hw.h +++ b/drivers/net/wireless/iwl-3945-hw.h @@ -87,4 +87,14 @@ struct iwl_tfd_frame { u8 reserved[28]; } __attribute__ ((packed)); +static inline u8 iwl_hw_get_rate(__le16 rate_n_flags) +{ + return le16_to_cpu(rate_n_flags) & 0xFF; +} + +static inline u16 iwl_hw_get_rate_n_flags(__le16 rate_n_flags) +{ + return le16_to_cpu(rate_n_flags); +} + #endif diff --git a/drivers/net/wireless/iwl-4965-hw.h b/drivers/net/wireless/iwl-4965-hw.h index 5dec78b..61229c8 100644 --- a/drivers/net/wireless/iwl-4965-hw.h +++ b/drivers/net/wireless/iwl-4965-hw.h @@ -768,10 +768,18 @@ struct iwl4965_rx_mpdu_res_start { __le16 reserved; } __attribute__ ((packed)); -static inline u8 iwl4965_get_rate(__le32 rate_n_flags) +static inline u8 iwl_hw_get_rate(__le32 rate_n_flags) { return le32_to_cpu(rate_n_flags) & 0xFF; } +static inline u16 iwl_hw_get_rate_n_flags(__le32 rate_n_flags) +{ + return le32_to_cpu(rate_n_flags) & 0xFFFF; +} +static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u16 flags) +{ + return cpu_to_le32(flags|rate); +} #if 0 union iwl_dram_scratch_union { diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c index 9f4d83a..19591a6 100644 --- a/drivers/net/wireless/iwl-4965.c +++ b/drivers/net/wireless/iwl-4965.c @@ -2660,7 +2660,7 @@ void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv, struct ieee80211_hdr *hdr, int sta_id, int is_hcca) { - int rate = ctrl->tx_rate; + u8 rate; u8 rts_retry_limit = 0; u8 data_retry_limit = 0; u32 tx_flags; @@ -2700,7 +2700,7 @@ void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv, cmd->cmd.tx.rts_retry_limit = rts_retry_limit; cmd->cmd.tx.data_retry_limit = data_retry_limit; - cmd->cmd.tx.rate.s.rate = rate; + cmd->cmd.tx.rate_n_flags = iwl_hw_set_rate_n_flags(rate, 0); cmd->cmd.tx.tx_flags = tx_flags; } @@ -2737,9 +2737,11 @@ int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, tx_beacon_cmd->tx.len = frame_size; if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP)) - tx_beacon_cmd->tx.rate.rate_n_flags = rate|RATE_MCS_CCK_MSK; + tx_beacon_cmd->tx.rate_n_flags = + iwl_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK); else - tx_beacon_cmd->tx.rate.rate_n_flags = rate; + tx_beacon_cmd->tx.rate_n_flags = + iwl_hw_set_rate_n_flags(rate, 0); tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK); @@ -3249,6 +3251,7 @@ int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd, u8 unicast = 0; u8 is_data = 1; u16 fc; + u16 rate_flags; int rate_index = min(ctrl->tx_rate & 0xffff, IWL_RATE_COUNT - 1); #ifdef CONFIG_IWLWIFI_HT #ifdef CONFIG_IWLWIFI_HT_AGG @@ -3290,29 +3293,28 @@ int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd, /* Hard coded to start at the highest retry fallback position * until the 4965 specific rate control algorithm is tied in */ tx->initial_rate_index = LINK_QUAL_MAX_RETRY_NUM - 1; - tx->rate.s.rate = iwl_rates[rate_index].plcp; /* Alternate between antenna A and B for successive frames */ if (priv->use_ant_b_for_management_frame) { priv->use_ant_b_for_management_frame = 0; - tx->rate.rate_n_flags |= RATE_MCS_ANT_B_MSK; - tx->rate.rate_n_flags &= ~RATE_MCS_ANT_A_MSK; + rate_flags = RATE_MCS_ANT_B_MSK; } else { priv->use_ant_b_for_management_frame = 1; - tx->rate.rate_n_flags |= RATE_MCS_ANT_A_MSK; - tx->rate.rate_n_flags &= ~RATE_MCS_ANT_B_MSK; + rate_flags = RATE_MCS_ANT_A_MSK; } if (!unicast || !is_data ) { if ((rate_index >= IWL_FIRST_CCK_RATE) && (rate_index <= IWL_LAST_CCK_RATE)) - tx->rate.rate_n_flags |= RATE_MCS_CCK_MSK; - + rate_flags |= RATE_MCS_CCK_MSK; } else { tx->initial_rate_index = 0; tx->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; } + tx->rate_n_flags = iwl_hw_set_rate_n_flags(iwl_rates[rate_index].plcp, + rate_flags); + if (ieee80211_is_probe_request(fc)) tx->tx_flags |= TX_CMD_FLG_TSF_MSK; else if (ieee80211_is_back_request(fc)) @@ -3825,7 +3827,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv, (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? MODE_IEEE80211G : MODE_IEEE80211A, .antenna = 0, - .rate = iwl4965_get_rate(rx_start->rate_n_flags), + .rate = iwl_hw_get_rate(rx_start->rate_n_flags), .flag = le16_to_cpu(rx_start->phy_flags), #ifdef CONFIG_IWLWIFI_HT_AGG .ordered = 0 diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c index 574d01c..a2560d3 100644 --- a/drivers/net/wireless/iwl-base.c +++ b/drivers/net/wireless/iwl-base.c @@ -7087,8 +7087,9 @@ static void iwl_bg_request_scan(struct work_struct *data) #if IWL == 3945 scan->tx_cmd.rate = IWL_RATE_1M_PLCP; #elif IWL == 4965 - scan->tx_cmd.rate.s.rate = IWL_RATE_1M_PLCP; - scan->tx_cmd.rate.s.flags = 0x80 | 0x2; + scan->tx_cmd.rate_n_flags = + iwl_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, + RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); #endif scan->good_CRC_th = 0; phymode = MODE_IEEE80211G; @@ -7098,8 +7099,9 @@ static void iwl_bg_request_scan(struct work_struct *data) #if IWL == 3945 scan->tx_cmd.rate = IWL_RATE_6M_PLCP; #elif IWL == 4965 - scan->tx_cmd.rate.s.rate = IWL_RATE_6M_PLCP; - scan->tx_cmd.rate.s.flags = 0x80; + scan->tx_cmd.rate_n_flags = + iwl_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, + RATE_MCS_ANT_B_MSK); #endif scan->good_CRC_th = IWL_GOOD_CRC_TH; phymode = MODE_IEEE80211A; diff --git a/drivers/net/wireless/iwl-commands.h b/drivers/net/wireless/iwl-commands.h index e3f2977..0faf9c0 100644 --- a/drivers/net/wireless/iwl-commands.h +++ b/drivers/net/wireless/iwl-commands.h @@ -245,7 +245,7 @@ struct iwl_tx_cmd { u8 tid_tspec; #elif IWL == 4965 struct iwl_dram_scratch scratch; - struct iwl_rate rate; + __le32 rate_n_flags; u8 sta_id; #endif u8 sec_ctl; diff --git a/drivers/net/wireless/iwl-hw.h b/drivers/net/wireless/iwl-hw.h index e73cf88..25a4728 100644 --- a/drivers/net/wireless/iwl-hw.h +++ b/drivers/net/wireless/iwl-hw.h @@ -322,11 +322,11 @@ enum { * 10 B active, A inactive * 11 Both active */ -#define RATE_MCS_ANT_A_POS 14 -#define RATE_MCS_ANT_B_POS 15 -#define RATE_MCS_ANT_A_MSK __constant_cpu_to_le16(0x4000) -#define RATE_MCS_ANT_B_MSK __constant_cpu_to_le16(0x8000) -#define RATE_MCS_ANT_AB_MSK __constant_cpu_to_le16(0xc000) +#define RATE_MCS_ANT_A_POS 14 +#define RATE_MCS_ANT_B_POS 15 +#define RATE_MCS_ANT_A_MSK 0x4000 +#define RATE_MCS_ANT_B_MSK 0x8000 +#define RATE_MCS_ANT_AB_MSK 0xc000 /* * WEP/CKIP group key command -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/7] iwlwifi: Endainity fix for rx configuration 2007-07-31 2:56 ` [PATCH 3/7] iwlwifi: Endianity fix for TX host command Zhu Yi @ 2007-07-31 2:56 ` Zhu Yi 2007-07-31 2:56 ` [PATCH 5/7] iwlwifi: Endianity fixes for 3945 Zhu Yi 2007-07-31 9:48 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Michael Buesch 0 siblings, 2 replies; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Tomas Winkler, Gregory Greenman, Zhu Yi From: Tomas Winkler <tomas.winkler@intel.com> This patch fixes endianity issues in rx configuration related code. Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/iwl-4965.c | 26 ++++--- drivers/net/wireless/iwl-base.c | 148 +++++++++++++++++++++------------------ drivers/net/wireless/iwl-hw.h | 10 ++-- 3 files changed, 101 insertions(+), 83 deletions(-) diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c index 19591a6..786c5d0 100644 --- a/drivers/net/wireless/iwl-4965.c +++ b/drivers/net/wireless/iwl-4965.c @@ -3615,8 +3615,8 @@ static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data, hdr = (void *)(pkt->u.raw + sizeof(struct iwl4965_rx_mpdu_res_start)); - rx_end = (u32 *) (((u8 *) hdr) + amsdu->byte_count); len = amsdu->byte_count; + rx_end = (u32 *) (((u8 *) hdr) + len); rx_start->byte_count = len; } if (len > 2342 || len < 16) { @@ -4130,21 +4130,25 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, { int i, sh, ack; + u16 ba_seq_ctl = le16_to_cpu(ba_resp->ba_seq_ctl); u32 bitmap0, bitmap1; + u32 resp_bitmap0 = le32_to_cpu(ba_resp->ba_bitmap0); + u32 resp_bitmap1 = le32_to_cpu(ba_resp->ba_bitmap1); + if (unlikely(!agg->wait_for_ba)) { IWL_ERROR("Received BA when not expected\n"); return -EINVAL; } agg->wait_for_ba = 0; IWL_DEBUG_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->ba_seq_ctl); - sh = agg->start_idx - SEQ_TO_INDEX(ba_resp->ba_seq_ctl>>4); + sh = agg->start_idx - SEQ_TO_INDEX(ba_seq_ctl>>4); if (sh < 0) /* tbw something is wrong with indeces */ sh += 0x100; /* don't use 64 bits for now */ - bitmap0 = ba_resp->ba_bitmap0 >> sh; - bitmap1 = ba_resp->ba_bitmap1 >> sh; - bitmap0 |= (ba_resp->ba_bitmap1 & ((1<<sh)|((1<<sh)-1))) << (32 - sh); + bitmap0 = resp_bitmap0 >> sh; + bitmap1 = resp_bitmap1 >> sh; + bitmap0 |= (resp_bitmap1 & ((1<<sh)|((1<<sh)-1))) << (32 - sh); if (agg->frame_count > (64 - sh)) { IWL_DEBUG_TX_REPLY("more frames than bitmap size"); @@ -4184,15 +4188,17 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, int index; struct iwl_tx_queue *txq = NULL; struct iwl_ht_agg *agg; + u16 ba_resp_scd_flow = le16_to_cpu(ba_resp->scd_flow); + u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); - if (ba_resp->scd_flow >= ARRAY_SIZE(priv->txq)) { + if (ba_resp_scd_flow >= ARRAY_SIZE(priv->txq)) { IWL_ERROR("BUG_ON scd_flow is bigger than number of queues"); return; } - txq = &priv->txq[ba_resp->scd_flow]; + txq = &priv->txq[ba_resp_scd_flow]; agg = &priv->stations[ba_resp->sta_id].tid[ba_resp->tid].agg; - index = iwl_queue_dec_wrap(ba_resp->scd_ssn & 0xff, txq->q.n_bd); + index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); /* TODO: Need to get this copy more sefely - now good for debug */ /* @@ -4216,8 +4222,8 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, */ iwl4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); /* releases all the TFDs until the SSN */ - if (txq->q.last_used != (ba_resp->scd_ssn & 0xff)) - iwl_tx_queue_reclaim(priv, ba_resp ->scd_flow, index); + if (txq->q.last_used != (ba_resp_scd_ssn & 0xff)) + iwl_tx_queue_reclaim(priv, ba_resp_scd_flow, index); } diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c index a2560d3..b7854b5 100644 --- a/drivers/net/wireless/iwl-base.c +++ b/drivers/net/wireless/iwl-base.c @@ -843,7 +843,7 @@ static int iwl_rxon_add_station(struct iwl_priv *priv, * NOTE: Does not commit to the hardware; it sets appropriate bit fields * in the staging RXON flag structure based on the phymode */ -static int iwl_set_rxon_channel(struct iwl_priv *priv, u8 phymode, u8 channel) +static int iwl_set_rxon_channel(struct iwl_priv *priv, u8 phymode, u16 channel) { if (!iwl_get_channel_info(priv, phymode, channel)) { IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", @@ -851,11 +851,11 @@ static int iwl_set_rxon_channel(struct iwl_priv *priv, u8 phymode, u8 channel) return -EINVAL; } - if ((priv->staging_rxon.channel == channel) && + if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && (priv->phymode == phymode)) return 0; - priv->staging_rxon.channel = channel; + priv->staging_rxon.channel = cpu_to_le16(channel); if ((phymode == MODE_IEEE80211A) || (phymode == MODE_ATHEROS_TURBO)) priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; @@ -882,18 +882,19 @@ static int iwl_check_rxon_cmd(struct iwl_rxon_cmd *rxon) int counter = 1; if (rxon->flags & RXON_FLG_BAND_24G_MSK) { - error |= (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK); - error |= (rxon->flags & RXON_FLG_RADAR_DETECT_MSK); + error |= + le32_to_cpu(rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK); + error |= le32_to_cpu(rxon->flags & 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) != - RXON_FLG_SHORT_SLOT_MSK); + RXON_FLG_SHORT_SLOT_MSK); if (error) IWL_WARNING("check 52 fields %d | %d\n", counter++, error); - error |= (rxon->flags & RXON_FLG_CCK_MSK); + error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK); if (error) IWL_WARNING("check 52 CCK %d | %d\n", counter++, error); @@ -905,11 +906,11 @@ static int iwl_check_rxon_cmd(struct iwl_rxon_cmd *rxon) /* 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)); + ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0)); if (error) IWL_WARNING("check basic rate %d | %d\n", counter++, error); - error |= (rxon->assoc_id > 2007); + error |= (le16_to_cpu(rxon->assoc_id) > 2007); if (error) IWL_WARNING("check assoc id %d | %d\n", counter++, error); @@ -2334,19 +2335,19 @@ static void iwl_sequence_reset(struct iwl_priv *priv) #else #define MAX_UCODE_BEACON_INTERVAL 1024 #endif -#define INTEL_CONN_LISTEN_INTERVAL 0xA +#define INTEL_CONN_LISTEN_INTERVAL __constant_cpu_to_le16(0xA) -static u16 iwl_adjust_beacon_interval(u16 beacon_val) +static __le16 iwl_adjust_beacon_interval(u16 beacon_val) { u16 new_val = 0; u16 beacon_factor = 0; beacon_factor = - (beacon_val + - MAX_UCODE_BEACON_INTERVAL) / MAX_UCODE_BEACON_INTERVAL; + (beacon_val + MAX_UCODE_BEACON_INTERVAL) + / MAX_UCODE_BEACON_INTERVAL; new_val = beacon_val / beacon_factor; - return new_val; + return cpu_to_le16(new_val); } static void iwl_setup_rxon_timing(struct iwl_priv *priv) @@ -2360,8 +2361,8 @@ static void iwl_setup_rxon_timing(struct iwl_priv *priv) conf = ieee80211_get_hw_conf(priv->hw); spin_lock_irqsave(&priv->lock, flags); - priv->rxon_timing.timestamp.dw[1] = priv->timestamp1; - priv->rxon_timing.timestamp.dw[0] = priv->timestamp0; + priv->rxon_timing.timestamp.dw[1] = cpu_to_le32(priv->timestamp1); + priv->rxon_timing.timestamp.dw[0] = cpu_to_le32(priv->timestamp0); priv->rxon_timing.listen_interval = INTEL_CONN_LISTEN_INTERVAL; @@ -2373,13 +2374,14 @@ static void iwl_setup_rxon_timing(struct iwl_priv *priv) if (priv->iw_mode == IEEE80211_IF_TYPE_STA) { if (beacon_int == 0) { - priv->rxon_timing.beacon_interval = 100; - priv->rxon_timing.beacon_init_val = 102400; + priv->rxon_timing.beacon_interval = cpu_to_le16(100); + priv->rxon_timing.beacon_init_val = cpu_to_le32(102400); } else { - priv->rxon_timing.beacon_interval = beacon_int; + priv->rxon_timing.beacon_interval = + cpu_to_le16(beacon_int); priv->rxon_timing.beacon_interval = iwl_adjust_beacon_interval( - priv->rxon_timing.beacon_interval); + le16_to_cpu(priv->rxon_timing.beacon_interval)); } priv->rxon_timing.atim_window = 0; @@ -2391,15 +2393,17 @@ static void iwl_setup_rxon_timing(struct iwl_priv *priv) priv->rxon_timing.atim_window = 0; } - interval_tm_unit = (priv->rxon_timing.beacon_interval * 1024); + interval_tm_unit = + (le16_to_cpu(priv->rxon_timing.beacon_interval) * 1024); result = do_div(tsf, interval_tm_unit); priv->rxon_timing.beacon_init_val = - (u32) ((u64) interval_tm_unit - result); + cpu_to_le32((u32) ((u64) interval_tm_unit - result)); IWL_DEBUG_ASSOC ("beacon interval %d beacon timer %d beacon tim %d\n", - priv->rxon_timing.beacon_interval, - priv->rxon_timing.beacon_init_val, priv->rxon_timing.atim_window); + le16_to_cpu(priv->rxon_timing.beacon_interval), + le32_to_cpu(priv->rxon_timing.beacon_init_val), + le16_to_cpu(priv->rxon_timing.atim_window)); } static int iwl_scan_initiate(struct iwl_priv *priv) @@ -2515,7 +2519,7 @@ static void iwl_connection_init_rx_config(struct iwl_priv *priv) #endif ch_info = iwl_get_channel_info(priv, priv->phymode, - priv->staging_rxon.channel); + le16_to_cpu(priv->staging_rxon.channel)); if (!ch_info) ch_info = &priv->channel_info[0]; @@ -2528,7 +2532,7 @@ static void iwl_connection_init_rx_config(struct iwl_priv *priv) !(is_channel_ibss(ch_info))) ch_info = &priv->channel_info[0]; - priv->staging_rxon.channel = ch_info->channel; + priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); if (is_channel_a_band(ch_info)) priv->phymode = MODE_IEEE80211A; else @@ -2560,12 +2564,12 @@ static int iwl_set_mode(struct iwl_priv *priv, int mode) const struct iwl_channel_info *ch_info; ch_info = iwl_get_channel_info(priv, - priv->phymode, - priv->staging_rxon.channel); + priv->phymode, + le16_to_cpu(priv->staging_rxon.channel)); if (!ch_info || !is_channel_ibss(ch_info)) { IWL_ERROR("channel %d not IBSS channel\n", - priv->staging_rxon.channel); + le16_to_cpu(priv->staging_rxon.channel)); return -EINVAL; } } @@ -3139,6 +3143,7 @@ void iwl_handle_data_packet_monitor(struct iwl_priv *priv, s8 noise = 0; int rate = stats->rate; u64 tsf = stats->mactime; + __le16 phy_flags_hw = cpu_to_le16(phy_flags); /* We received data from the HW, so stop the watchdog */ if (len > IWL_RX_BUF_SIZE - sizeof(*iwl_rt)) { @@ -3180,16 +3185,15 @@ void iwl_handle_data_packet_monitor(struct iwl_priv *priv, /* 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)) { + if (!(phy_flags_hw & RX_RES_PHY_FLAGS_BAND_24_MSK)) iwl_rt->rt_chbitmask = cpu_to_le16((IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ)); - } else if (phy_flags & RX_RES_PHY_FLAGS_MOD_CCK_MSK) { + else if (phy_flags_hw & RX_RES_PHY_FLAGS_MOD_CCK_MSK) iwl_rt->rt_chbitmask = cpu_to_le16((IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ)); - } else { /* 802.11g */ + else /* 802.11g */ iwl_rt->rt_chbitmask = cpu_to_le16((IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ)); - } rate = iwl_rate_index_from_plcp(rate); if (rate == -1) @@ -3198,10 +3202,11 @@ void iwl_handle_data_packet_monitor(struct iwl_priv *priv, iwl_rt->rt_rate = iwl_rates[rate].ieee; /* antenna number */ - iwl_rt->rt_antenna = (phy_flags & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; + iwl_rt->rt_antenna = + le16_to_cpu(phy_flags_hw & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; /* set the preamble flag if we have it */ - if (phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) + if (phy_flags_hw & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) iwl_rt->rt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; IWL_DEBUG_RX("Rx packet of %d bytes.\n", rxb->skb->len); @@ -3315,7 +3320,7 @@ static u32 iwl_usecs_to_beacons(u32 usec, u32 beacon_interval) * the same as HW timer counter counting down */ -static u32 iwl_add_beacon_time(u32 base, u32 addon, u32 beacon_interval) +static __le32 iwl_add_beacon_time(u32 base, u32 addon, u32 beacon_interval) { u32 base_low = base & BEACON_TIME_MASK_LOW; u32 addon_low = addon & BEACON_TIME_MASK_LOW; @@ -3331,7 +3336,7 @@ static u32 iwl_add_beacon_time(u32 base, u32 addon, u32 beacon_interval) } else res += (1 << 24); - return res; + return cpu_to_le32(res); } static int iwl_get_measurement(struct iwl_priv *priv, @@ -3345,32 +3350,35 @@ static int iwl_get_measurement(struct iwl_priv *priv, .data = (void *)&spectrum, .meta.flags = CMD_WANT_SKB, }; - u32 add_time = params->start_time; + u32 add_time = le64_to_cpu(params->start_time); int rc; + int spectrum_resp_status; + int duration = le16_to_cpu(params->duration); if (iwl_is_associated(priv)) add_time = - iwl_usecs_to_beacons(params->start_time - priv->last_tsf, - priv->rxon_timing.beacon_interval); + iwl_usecs_to_beacons( + le64_to_cpu(params->start_time) - priv->last_tsf, + le16_to_cpu(priv->rxon_timing.beacon_interval)); memset(&spectrum, 0, sizeof(spectrum)); - spectrum.channel_count = cpu_to_le32(1); + spectrum.channel_count = cpu_to_le16(1); spectrum.flags = RXON_FLG_TSF2HOST_MSK | RXON_FLG_ANT_A_MSK | RXON_FLG_DIS_DIV_MSK; spectrum.filter_flags = MEASUREMENT_FILTER_FLAG; cmd.len = sizeof(spectrum); - spectrum.len = cmd.len - sizeof(spectrum.len); + spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); if (iwl_is_associated(priv)) spectrum.start_time = iwl_add_beacon_time(priv->last_beacon_time, - add_time, - priv->rxon_timing.beacon_interval); + add_time, + le16_to_cpu(priv->rxon_timing.beacon_interval)); else spectrum.start_time = params->start_time; - spectrum.channels[0].duration = params->duration * TIME_UNIT; + spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); spectrum.channels[0].channel = params->channel; spectrum.channels[0].type = type; if (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK) @@ -3387,7 +3395,8 @@ static int iwl_get_measurement(struct iwl_priv *priv, rc = -EIO; } - switch (res->u.spectrum.status) { + spectrum_resp_status = le16_to_cpu(res->u.spectrum.status); + switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (res->u.spectrum.id != 0xff) { IWL_DEBUG_INFO @@ -3799,13 +3808,13 @@ static void iwl_rx_reply_error(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) { struct iwl_rx_packet *pkt = (void *)rxb->skb->data; - u32 err_type = pkt->u.err_resp.error_type; - u8 cmd_id = pkt->u.err_resp.cmd_id; - u16 seq = pkt->u.err_resp.bad_cmd_seq_num; - u32 ser = pkt->u.err_resp.error_info; IWL_ERROR("Error Reply type 0x%08X cmd %s (0x%02X) " - "seq 0x%04X ser 0x%08X\n", - err_type, get_cmd_string(cmd_id), cmd_id, seq, ser); + "seq 0x%04X ser 0x%08X\n", + le32_to_cpu(pkt->u.err_resp.error_type), + get_cmd_string(pkt->u.err_resp.cmd_id), + pkt->u.err_resp.cmd_id, + le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), + le32_to_cpu(pkt->u.err_resp.error_info)); return; } @@ -3817,8 +3826,9 @@ static void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon; struct iwl_csa_notification *csa = &(pkt->u.csa_notif); IWL_DEBUG_11H("CSA notif: channel %d, status %d\n", - csa->channel, csa->status); - rxon->channel = priv->staging_rxon.channel = cpu_to_le16(csa->channel); + le16_to_cpu(csa->channel), le32_to_cpu(csa->status)); + rxon->channel = csa->channel; + priv->staging_rxon.channel = csa->channel; } static void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, @@ -3872,11 +3882,12 @@ static void iwl_rx_beacon_notif(struct iwl_priv *priv, u8 rate = beacon->beacon_notify_hdr.rate.s.rate; #endif IWL_DEBUG_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - beacon->beacon_notify_hdr.status & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - beacon->ibss_mgr_status, - beacon->high_tsf, beacon->low_tsf, rate); + "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.status & TX_STATUS_MSK), + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); #endif } @@ -3895,7 +3906,7 @@ static void iwl_rx_scan_start_notif(struct iwl_priv *priv, struct iwl_rx_packet *pkt = (void *)rxb->skb->data; struct iwl_scanstart_notification *notif = (struct iwl_scanstart_notification *)pkt->u.raw; - priv->scan_start_tsf = notif->tsf_low; + priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); IWL_DEBUG_SCAN("Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", @@ -3918,10 +3929,10 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv, "elapsed=%lu usec (%dms since last)\n", notif->channel, notif->band ? "bg" : "a", - notif->tsf_high, - notif->tsf_low, - notif->statistics[0], - notif->tsf_low - priv->scan_start_tsf, + le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), + le32_to_cpu(notif->statistics[0]), + le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf, jiffies_to_msecs(elapsed_jiffies (priv->last_scan_jiffies, jiffies))); @@ -7139,9 +7150,10 @@ static void iwl_bg_request_scan(struct work_struct *data) scan->channel_count = iwl_get_channels_for_scan( priv, phymode, 1, /* active */ - direct_mask, (void *)&scan->data[scan->tx_cmd.len]); + direct_mask, + (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); - cmd.len += scan->tx_cmd.len + + cmd.len += le16_to_cpu(scan->tx_cmd.len) + scan->channel_count * sizeof(struct iwl_scan_channel); cmd.data = scan; scan->len = cmd.len; @@ -8404,12 +8416,12 @@ static ssize_t store_tune(struct device *d, char *p = (char *)buf; u16 tune = simple_strtoul(p, &p, 0); u8 phymode = (tune >> 8) & 0xff; - u8 channel = tune & 0xff; + u16 channel = tune & 0xff; IWL_DEBUG_INFO("Tune request to:%d channel:%d\n", phymode, channel); mutex_lock(&priv->mutex); - if ((priv->staging_rxon.channel != channel) || + if ((le16_to_cpu(priv->staging_rxon.channel) != channel) || (priv->phymode != phymode)) { const struct iwl_channel_info *ch_info; diff --git a/drivers/net/wireless/iwl-hw.h b/drivers/net/wireless/iwl-hw.h index 25a4728..0cc341b 100644 --- a/drivers/net/wireless/iwl-hw.h +++ b/drivers/net/wireless/iwl-hw.h @@ -368,10 +368,10 @@ struct iwl_rx_frame_hdr { #define RX_RES_STATUS_NO_RXE_OVERFLOW __constant_cpu_to_le32(1 << 1) #define RX_RES_PHY_FLAGS_BAND_24_MSK __constant_cpu_to_le16(1 << 0) -#define RX_RES_PHY_FLAGS_MOD_CCK_MSK (1 << 1) -#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK (1 << 2) -#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK (1 << 3) -#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0 +#define RX_RES_PHY_FLAGS_MOD_CCK_MSK __constant_cpu_to_le16(1 << 1) +#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK __constant_cpu_to_le16(1 << 2) +#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK __constant_cpu_to_le16(1 << 3) +#define RX_RES_PHY_FLAGS_ANTENNA_MSK __constant_cpu_to_le16(0xf0) #define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) #define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) @@ -422,7 +422,7 @@ struct iwl_txpowertable_cmd { */ /* Can abort will notify by complete notification with abort status. */ -#define CAN_ABORT_STATUS 0x1 +#define CAN_ABORT_STATUS __constant_cpu_to_le32(0x1) struct iwl_scanreq_notification { __le32 status; -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/7] iwlwifi: Endianity fixes for 3945 2007-07-31 2:56 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Zhu Yi @ 2007-07-31 2:56 ` Zhu Yi 2007-07-31 2:56 ` [PATCH 6/7] iwlwifi: Endianity fix for tx configuration Zhu Yi 2007-07-31 9:48 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Michael Buesch 1 sibling, 1 reply; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Tomas Winkler, Gregory Greenman, Zhu Yi From: Tomas Winkler <tomas.winkler@intel.com> This patch fixes most of endianity issues in iwl-3945.c. Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/iwl-3945.c | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/iwl-3945.c b/drivers/net/wireless/iwl-3945.c index b71e987..6074ae0 100644 --- a/drivers/net/wireless/iwl-3945.c +++ b/drivers/net/wireless/iwl-3945.c @@ -295,6 +295,8 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, struct iwl_rx_frame_end *rx_end = IWL_RX_END(pkt); struct ieee80211_hdr *header; u16 phy_flags = le16_to_cpu(rx_hdr->phy_flags); + u16 rx_stats_sig_avg = le16_to_cpu(rx_stats->sig_avg); + u16 rx_stats_noise_diff = le16_to_cpu(rx_stats->noise_diff); struct ieee80211_rx_status stats = { .mactime = le32_to_cpu(rx_end->beacon_timestamp), .freq = ieee80211chan2mhz(le16_to_cpu(rx_hdr->channel)), @@ -316,9 +318,8 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, return; } - if (!(le32_to_cpu(rx_end->status) & RX_RES_STATUS_NO_CRC32_ERROR) - || !(le32_to_cpu(rx_end->status) & - RX_RES_STATUS_NO_RXE_OVERFLOW)) { + if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) + || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { IWL_DEBUG_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -349,8 +350,8 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, * Convert linear SNR to dB SNR, then subtract that from rssi dBm * to obtain noise level in dBm. * Calculate stats.signal (quality indicator in %) based on SNR. */ - if (rx_stats->noise_diff) { - snr = rx_stats->sig_avg / rx_stats->noise_diff; + if (rx_stats_noise_diff) { + snr = rx_stats_sig_avg / rx_stats_noise_diff; stats.noise = stats.ssi - iwl_calc_db_from_ratio(snr); stats.signal = iwl_calc_sig_qual(stats.ssi, stats.noise); @@ -364,7 +365,7 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, IWL_DEBUG_STATS("Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n", stats.ssi, stats.noise, stats.signal, - rx_stats->sig_avg, rx_stats->noise_diff); + rx_stats_sig_avg, rx_stats_noise_diff); stats.freq = ieee80211chan2mhz(stats.channel); @@ -415,7 +416,7 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, pos = (__le32 *) & mgmt->u.beacon. timestamp; - priv->timestamp0 = le64_to_cpu(pos[0]); + priv->timestamp0 = le32_to_cpu(pos[0]); priv->timestamp1 = le32_to_cpu(pos[1]); priv->beacon_int = le16_to_cpu( mgmt->u.beacon.beacon_int); @@ -597,7 +598,7 @@ void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv, int rate; u8 rts_retry_limit; u8 data_retry_limit; - u32 tx_flags; + __le32 tx_flags; u16 fc = le16_to_cpu(hdr->frame_control); rate = iwl_rates[rate_index].plcp; @@ -663,7 +664,7 @@ void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv, "cck/ofdm mask: 0x%x/0x%x\n", sta_id, cmd->cmd.tx.rate, - BIT_ARG16(cmd->cmd.tx.tx_flags), + BIT_ARG16(le32_to_cpu(cmd->cmd.tx.tx_flags)), cmd->cmd.tx.supp_rates[1], cmd->cmd.tx.supp_rates[0]); } @@ -2108,7 +2109,7 @@ int iwl_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) struct iwl_shared *shared_data = priv->hw_setting.shared_virt; - shared_data->tx_base_ptr[txq_id] = (u32) txq->q.dma_addr; + shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); spin_lock_irqsave(&priv->lock, flags); rc = iwl_grab_restricted_access(priv); @@ -2140,7 +2141,7 @@ int iwl_hw_get_rx_read(struct iwl_priv *priv) struct iwl_shared *shared_data = (struct iwl_shared *)priv->hw_setting.shared_virt; - return shared_data->rx_read_ptr[0]; + return le32_to_cpu(shared_data->rx_read_ptr[0]); } /** -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/7] iwlwifi: Endianity fix for tx configuration 2007-07-31 2:56 ` [PATCH 5/7] iwlwifi: Endianity fixes for 3945 Zhu Yi @ 2007-07-31 2:56 ` Zhu Yi 2007-07-31 2:56 ` [PATCH 7/7] iwlwifi: Endian fix for rate setting in 3945 Zhu Yi 0 siblings, 1 reply; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Tomas Winkler, Gregory Greenman, Zhu Yi From: Tomas Winkler <tomas.winkler@intel.com> This patch fixes most of the endianity issues in the TX configuration path. Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/iwl-4965-hw.h | 2 +- drivers/net/wireless/iwl-4965.c | 7 +- drivers/net/wireless/iwl-base.c | 158 ++++++++++++++++++----------------- drivers/net/wireless/iwl-commands.h | 88 ++++++++++---------- drivers/net/wireless/iwl-hw.h | 2 +- drivers/net/wireless/iwlwifi.h | 5 +- 6 files changed, 135 insertions(+), 127 deletions(-) diff --git a/drivers/net/wireless/iwl-4965-hw.h b/drivers/net/wireless/iwl-4965-hw.h index 61229c8..d7b69f5 100644 --- a/drivers/net/wireless/iwl-4965-hw.h +++ b/drivers/net/wireless/iwl-4965-hw.h @@ -778,7 +778,7 @@ static inline u16 iwl_hw_get_rate_n_flags(__le32 rate_n_flags) } static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u16 flags) { - return cpu_to_le32(flags|rate); + return cpu_to_le32(flags|(u16)rate); } #if 0 diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c index 786c5d0..1b90838 100644 --- a/drivers/net/wireless/iwl-4965.c +++ b/drivers/net/wireless/iwl-4965.c @@ -2663,7 +2663,7 @@ void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv, u8 rate; u8 rts_retry_limit = 0; u8 data_retry_limit = 0; - u32 tx_flags; + __le32 tx_flags; tx_flags = cmd->cmd.tx.tx_flags; @@ -3287,7 +3287,8 @@ int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd, scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + offsetof(struct iwl_tx_cmd, scratch); - tx->dram_lsb_ptr = iwl4965_get_dma_lo_address(scratch_phys); + tx->dram_lsb_ptr = cpu_to_le32( + iwl4965_get_dma_lo_address(scratch_phys)); tx->dram_msb_ptr = iwl4965_get_dma_hi_address(scratch_phys); /* Hard coded to start at the highest retry fallback position @@ -4166,7 +4167,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, IWL_DEBUG_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", ack? "ACK":"NACK", i, idx, agg->start_idx + i); iwl4965_set_tx_status(priv, ba_resp->tid, idx, ack, 1, - agg->rate.rate_n_flags); + agg->rate_n_flags); } diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c index b7854b5..683f07d 100644 --- a/drivers/net/wireless/iwl-base.c +++ b/drivers/net/wireless/iwl-base.c @@ -561,7 +561,7 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) u32 *control_flags; struct iwl_cmd *out_cmd; u32 idx = 0; - u16 fix_size = (u16) (cmd->meta.len + sizeof(out_cmd->hdr)); + u16 fix_size = (u16)(cmd->meta.len + sizeof(out_cmd->hdr)); dma_addr_t phys_addr; #if IWL == 3945 int pad; @@ -596,10 +596,10 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) * information */ out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | - INDEX_TO_SEQ(q->first_empty); + out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | + INDEX_TO_SEQ(q->first_empty)); if (out_cmd->meta.flags & CMD_SIZE_HUGE) - out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; + out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME); phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx + offsetof(struct iwl_cmd, hdr); @@ -614,7 +614,7 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, out_cmd->hdr.sequence, + out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->first_empty, idx, IWL_CMD_QUEUE_NUM); txq->need_update = 1; @@ -1797,7 +1797,7 @@ void static iwl_set_ht_capab(struct ieee80211_hw *hw, /** * iwl_fill_probe_req - fill in all required fields and IE for probe request */ -static int iwl_fill_probe_req(struct iwl_priv *priv, +static u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, int left, int is_direct) { @@ -1892,7 +1892,7 @@ static int iwl_fill_probe_req(struct iwl_priv *priv, #endif fill_end: - return len; + return (u16)len; } /* @@ -2672,13 +2672,11 @@ static void iwl_build_tx_cmd_basic(struct iwl_priv *priv, struct ieee80211_hdr *hdr, int is_unicast, u8 std_id) { - u32 tx_flags; - u16 fc = le16_to_cpu(hdr->frame_control); __le16 *qc; + u16 fc = le16_to_cpu(hdr->frame_control); + __le32 tx_flags = cmd->cmd.tx.tx_flags; - tx_flags = cmd->cmd.tx.tx_flags; - - cmd->cmd.tx.stop_time.life_time = 0xFFFFFFFF; + cmd->cmd.tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; if (!(ctrl->flags & IEEE80211_TXCTL_NO_ACK)) { tx_flags |= TX_CMD_FLG_ACK_MSK; if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT) @@ -2717,9 +2715,11 @@ static void iwl_build_tx_cmd_basic(struct iwl_priv *priv, if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT) { if (((WLAN_FC_GET_STYPE(fc)) == IEEE80211_STYPE_ASSOC_REQ) || ((WLAN_FC_GET_STYPE(fc)) == IEEE80211_STYPE_REASSOC_REQ)) - cmd->cmd.tx.timeout.pm_frame_timeout = 3; + cmd->cmd.tx.timeout.pm_frame_timeout = + cpu_to_le16(3); else - cmd->cmd.tx.timeout.pm_frame_timeout = 2; + cmd->cmd.tx.timeout.pm_frame_timeout = + cpu_to_le16(2); } else cmd->cmd.tx.timeout.pm_frame_timeout = 0; @@ -2848,7 +2848,8 @@ static int iwl_tx_skb(struct iwl_priv *priv, seq_number = priv->stations[sta_id].tid[tid].seq_number & IEEE80211_SCTL_SEQ; hdr->seq_ctrl = cpu_to_le16(seq_number) | - (hdr->seq_ctrl & IEEE80211_SCTL_FRAG); + (hdr->seq_ctrl & + __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); seq_number += 0x10; #if IWL == 4965 #ifdef CONFIG_IWLWIFI_HT @@ -2879,8 +2880,8 @@ static int iwl_tx_skb(struct iwl_priv *priv, memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); memset(&out_cmd->cmd.tx, 0, sizeof(out_cmd->cmd.tx)); out_cmd->hdr.cmd = REPLY_TX; - out_cmd->hdr.sequence = QUEUE_TO_SEQ(txq_id) | - INDEX_TO_SEQ(q->first_empty); + out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | + INDEX_TO_SEQ(q->first_empty))); /* copy frags header */ memcpy(out_cmd->cmd.tx.hdr, hdr, hdr_len); @@ -2913,7 +2914,6 @@ static int iwl_tx_skb(struct iwl_priv *priv, iwl_hw_tx_queue_attach_buffer_to_tfd(priv, tfd, phys_addr, len); } - out_cmd->cmd.tx.len = skb->len; #if IWL == 3945 /* If there is no payload, then only one TFD is used */ @@ -2926,6 +2926,8 @@ static int iwl_tx_skb(struct iwl_priv *priv, if (len_org) out_cmd->cmd.tx.tx_flags |= TX_CMD_FLG_MH_PAD_MSK; #endif + len = (u16)skb->len; + out_cmd->cmd.tx.len = cpu_to_le16(len); /* TODO need this for burst mode later on */ iwl_build_tx_cmd_basic(priv, out_cmd, ctl, hdr, unicast, sta_id); @@ -2933,8 +2935,6 @@ static int iwl_tx_skb(struct iwl_priv *priv, /* set is_hcca to 0; it probably will never be implemented */ iwl_hw_build_tx_cmd_rate(priv, out_cmd, ctl, hdr, sta_id, 0); - len = out_cmd->cmd.tx.len; - #if IWL == 4965 iwl4965_tx_cmd(priv, out_cmd, sta_id, txcmd_phys, hdr, hdr_len, ctl, NULL); @@ -2958,7 +2958,7 @@ static int iwl_tx_skb(struct iwl_priv *priv, printk_buf(IWL_DL_TX, out_cmd->cmd.payload, sizeof(out_cmd->cmd.tx)); printk_buf(IWL_DL_TX, (u8 *) out_cmd->cmd.tx.hdr, - ieee80211_get_hdrlen(out_cmd->cmd.tx.hdr->frame_control)); + ieee80211_get_hdrlen(fc)); iwl4965_tx_queue_update_wr_ptr(priv, txq, len); @@ -3503,8 +3503,6 @@ static int iwl_is_tx_success(u32 status) #ifdef CONFIG_IWLWIFI_HT #ifdef CONFIG_IWLWIFI_HT_AGG -#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) - static inline int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) { @@ -3525,20 +3523,25 @@ static struct ieee80211_hdr *iwl_tx_queue_get_hdr( return NULL; } +static inline u32 iwl_get_scd_ssn(struct iwl_tx_resp *tx_resp) +{ + __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + + tx_resp->frame_count); + return le32_to_cpu(*scd_ssn & MAX_SN); + +} int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, struct iwl_ht_agg *agg, struct iwl_tx_resp *tx_resp, u16 start_idx) { - u16 status; - u16 seq; - u32 *frame_status = (u32 *)&tx_resp->status; - - int txq_id, idx; + u32 status; + __le32 *frame_status = &tx_resp->status; struct ieee80211_tx_status *tx_status = NULL; - - struct ieee80211_hdr *hdr; + struct ieee80211_hdr *hdr = NULL; int i, sh; + int txq_id, idx; + u16 seq; if (agg->wait_for_ba) { IWL_DEBUG_TX_REPLY("got tx repsons w/o back\n"); @@ -3547,11 +3550,11 @@ int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; - memcpy(&agg->rate, &tx_resp->rate, sizeof(agg->rate)); + agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); agg->bitmap0 = agg->bitmap1 = 0; if (agg->frame_count == 1) { - status = frame_status[0] & 0xff; - seq = frame_status[0] >> 16; + status = le32_to_cpu(frame_status[0]); + seq = status >> 16; idx = SEQ_TO_INDEX(seq); txq_id = SEQ_TO_QUEUE(seq); @@ -3561,23 +3564,22 @@ int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, tx_status = &(priv->txq[txq_id].txb[idx].status); tx_status->retry_count = tx_resp->failure_frame; - tx_status->queue_number = tx_resp->status; + tx_status->queue_number = status & 0xff; tx_status->queue_length = tx_resp->bt_kill_count; tx_status->queue_length |= tx_resp->failure_rts; tx_status->flags = iwl_is_tx_success(tx_resp->status)? IEEE80211_TX_STATUS_ACK : 0; - tx_status->control.tx_rate = tx_resp->rate.s.rate | - (tx_resp->rate.s.flags << 8); + tx_status->control.tx_rate = + iwl_hw_get_rate_n_flags(tx_resp->rate_n_flags); /* FIXME: code repetition end */ IWL_DEBUG_TX_REPLY("1 Frame 0x%x idx %d failure :%d\n", status & 0xff, idx, tx_resp->failure_frame); - IWL_DEBUG_TX_REPLY("Rate Info rate=%d flags=0x%x extf=0x%x\n", - tx_resp->rate.s.rate, tx_resp->rate.s.flags, - tx_resp->rate.s.ext_flags); + IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", + iwl_hw_get_rate_n_flags(tx_resp->rate_n_flags)); agg->wait_for_ba = 0; } else { @@ -3585,8 +3587,8 @@ int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, int start = agg->start_idx; for (i = 0; i < agg->frame_count; i++) { - status = frame_status[i] & 0xff; - seq = frame_status[i] >> 16; + status = le32_to_cpu(frame_status[i]); + seq = status >> 16; idx = SEQ_TO_INDEX(seq); txq_id = SEQ_TO_QUEUE(seq); @@ -3629,7 +3631,7 @@ int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, agg->bitmap0 = bitmap & 0xFFFFFFFF; agg->bitmap1 = bitmap >> 32; agg->start_idx = start; - memcpy(&agg->rate, &tx_resp->rate, sizeof(agg->rate)); + agg->rate_n_flags = cpu_to_le32(tx_resp->rate_n_flags); IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%x\n", agg->frame_count, agg->start_idx, @@ -3647,12 +3649,13 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) { struct iwl_rx_packet *pkt = (void *)rxb->skb->data; - u16 sequence = pkt->hdr.sequence; + u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct ieee80211_tx_status *status; - struct iwl_tx_resp *resp = (void *)&pkt->u.raw[0]; + struct ieee80211_tx_status *tx_status; + struct iwl_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + u32 status = le32_to_cpu(tx_resp->status); #if IWL == 4965 #ifdef CONFIG_IWLWIFI_HT #ifdef CONFIG_IWLWIFI_HT_AGG @@ -3673,8 +3676,7 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv, #ifdef CONFIG_IWLWIFI_HT #ifdef CONFIG_IWLWIFI_HT_AGG if (txq->sched_retry) { - const int scd_ssn = *((u32 *)&resp->status + resp->frame_count) & - MAX_SN; + const u32 scd_ssn = iwl_get_scd_ssn(tx_resp); struct ieee80211_hdr *hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); struct iwl_ht_agg *agg = NULL; @@ -3695,10 +3697,11 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv, agg = &priv->stations[sta_id].tid[tid].agg; - iwl4965_tx_status_reply_tx(priv, agg, resp, index); - - if ((resp->frame_count == 1) && !iwl_is_tx_success(resp->status) ) { + iwl4965_tx_status_reply_tx(priv, agg, tx_resp, index); + if ((tx_resp->frame_count == 1) && + !iwl_is_tx_success(status)) { + /* TODO: send BAR */ } if (txq->q.last_used != (scd_ssn & 0xff)) { @@ -3711,33 +3714,34 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv, #endif /* CONFIG_IWLWIFI_HT_AGG */ #endif /* CONFIG_IWLWIFI_HT */ #endif /* 4965 */ - status = &(txq->txb[txq->q.last_used].status); + tx_status = &(txq->txb[txq->q.last_used].status); - status->retry_count = resp->failure_frame; - status->queue_number = resp->status; - status->queue_length = resp->bt_kill_count; - status->queue_length |= resp->failure_rts; + tx_status->retry_count = tx_resp->failure_frame; + tx_status->queue_number = status; + tx_status->queue_length = tx_resp->bt_kill_count; + tx_status->queue_length |= tx_resp->failure_rts; - status->flags = - iwl_is_tx_success(resp->status) ? IEEE80211_TX_STATUS_ACK : 0; + tx_status->flags = + iwl_is_tx_success(status) ? IEEE80211_TX_STATUS_ACK : 0; #if IWL == 3945 - status->control.tx_rate = iwl_rate_index_from_plcp(resp->rate); + tx_status->control.tx_rate = iwl_rate_index_from_plcp(tx_resp->rate); IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, iwl_get_tx_fail_reason(resp->status), - resp->status, resp->rate, resp->failure_frame); + txq_id, iwl_get_tx_fail_reason(status), status, + tx_resp->rate, tx_resp->failure_frame); #elif IWL == 4965 - status->control.tx_rate = (u16) resp->rate.rate_n_flags; + tx_status->control.tx_rate = + iwl_hw_get_rate_n_flags(tx_resp->rate_n_flags); - IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate 0x%x%02x " + IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " "retries %d\n", - txq_id, iwl_get_tx_fail_reason(resp->status), - resp->status, resp->rate.s.flags, - resp->rate.s.rate, resp->failure_frame); + txq_id, iwl_get_tx_fail_reason(status), + status, le32_to_cpu(tx_resp->rate_n_flags), + tx_resp->failure_frame); #endif IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); @@ -3751,7 +3755,7 @@ static void iwl_rx_reply_tx(struct iwl_priv *priv, #endif /* CONFIG_IWLWIFI_HT */ #endif /* 4965 */ - if (iwl_check_bits(resp->status, TX_ABORT_REQUIRED_MSK)) + if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -3879,11 +3883,11 @@ static void iwl_rx_beacon_notif(struct iwl_priv *priv, #if IWL == 3945 u8 rate = beacon->beacon_notify_hdr.rate; #elif IWL == 4965 - u8 rate = beacon->beacon_notify_hdr.rate.s.rate; + u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); #endif IWL_DEBUG_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.status & TX_STATUS_MSK), + le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, le32_to_cpu(beacon->ibss_mgr_status), le32_to_cpu(beacon->high_tsf), @@ -4129,9 +4133,10 @@ static void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) { struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; - int txq_id = SEQ_TO_QUEUE(pkt->hdr.sequence); - int index = SEQ_TO_INDEX(pkt->hdr.sequence); - int is_huge = (pkt->hdr.sequence & SEQ_HUGE_FRAME); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int index = SEQ_TO_INDEX(sequence); + int is_huge = (sequence & SEQ_HUGE_FRAME); int cmd_index; struct iwl_cmd *cmd; @@ -4985,7 +4990,7 @@ static void iwl_error_recovery(struct iwl_priv *priv) iwl_rxon_add_station(priv, priv->bssid, 1); spin_lock_irqsave(&priv->lock, flags); - priv->assoc_id = priv->staging_rxon.assoc_id; + priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id); priv->error_recovering = 0; spin_unlock_irqrestore(&priv->lock, flags); } @@ -7079,9 +7084,9 @@ static void iwl_bg_request_scan(struct work_struct *data) /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ - scan->tx_cmd.len = - iwl_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, - IWL_MAX_SCAN_SIZE - sizeof(scan), 0); + scan->tx_cmd.len = cpu_to_le16( + iwl_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, + IWL_MAX_SCAN_SIZE - sizeof(scan), 0)); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = IWL_BROADCAST_ID; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; @@ -7089,7 +7094,7 @@ static void iwl_bg_request_scan(struct work_struct *data) /* flags + rate selection */ #if IWL == 4965 - scan->tx_cmd.tx_flags |= 0x200; + scan->tx_cmd.tx_flags |= cpu_to_le32(0x200); #endif switch (priv->scan_bands) { @@ -7102,6 +7107,7 @@ static void iwl_bg_request_scan(struct work_struct *data) iwl_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, RATE_MCS_ANT_B_MSK|RATE_MCS_CCK_MSK); #endif + scan->good_CRC_th = 0; phymode = MODE_IEEE80211G; break; diff --git a/drivers/net/wireless/iwl-commands.h b/drivers/net/wireless/iwl-commands.h index 0faf9c0..1942c8c 100644 --- a/drivers/net/wireless/iwl-commands.h +++ b/drivers/net/wireless/iwl-commands.h @@ -162,45 +162,43 @@ enum { */ /* Tx flags */ -enum { - TX_CMD_FLG_RTS_MSK = (1 << 1), - TX_CMD_FLG_CTS_MSK = (1 << 2), - TX_CMD_FLG_ACK_MSK = (1 << 3), - TX_CMD_FLG_STA_RATE_MSK = (1 << 4), - TX_CMD_FLG_IMM_BA_RSP_MASK = (1 << 6), - TX_CMD_FLG_FULL_TXOP_PROT_MSK = (1 << 7), - TX_CMD_FLG_ANT_SEL_MSK = 0xf00, - TX_CMD_FLG_ANT_A_MSK = (1 << 8), - TX_CMD_FLG_ANT_B_MSK = (1 << 9), +#define TX_CMD_FLG_RTS_MSK __constant_cpu_to_le32(1 << 1) +#define TX_CMD_FLG_CTS_MSK __constant_cpu_to_le32(1 << 2) +#define TX_CMD_FLG_ACK_MSK __constant_cpu_to_le32(1 << 3) +#define TX_CMD_FLG_STA_RATE_MSK __constant_cpu_to_le32(1 << 4) +#define TX_CMD_FLG_IMM_BA_RSP_MASK __constant_cpu_to_le32(1 << 6) +#define TX_CMD_FLG_FULL_TXOP_PROT_MSK __constant_cpu_to_le32(1 << 7) +#define TX_CMD_FLG_ANT_SEL_MSK __constant_cpu_to_le32(0xf00) +#define TX_CMD_FLG_ANT_A_MSK __constant_cpu_to_le32(1 << 8) +#define TX_CMD_FLG_ANT_B_MSK __constant_cpu_to_le32(1 << 9) - /* ucode ignores BT priority for this frame */ - TX_CMD_FLG_BT_DIS_MSK = (1 << 12), +/* ucode ignores BT priority for this frame */ +#define TX_CMD_FLG_BT_DIS_MSK __constant_cpu_to_le32(1 << 12) - /* ucode overrides sequence control */ - TX_CMD_FLG_SEQ_CTL_MSK = (1 << 13), +/* ucode overrides sequence control */ +#define TX_CMD_FLG_SEQ_CTL_MSK __constant_cpu_to_le32(1 << 13) - /* signal that this frame is non-last MPDU */ - TX_CMD_FLG_MORE_FRAG_MSK = (1 << 14), +/* signal that this frame is non-last MPDU */ +#define TX_CMD_FLG_MORE_FRAG_MSK __constant_cpu_to_le32(1 << 14) - /* calculate TSF in outgoing frame */ - TX_CMD_FLG_TSF_MSK = (1 << 16), +/* calculate TSF in outgoing frame */ +#define TX_CMD_FLG_TSF_MSK __constant_cpu_to_le32(1 << 16) - /* activate TX calibration. */ - TX_CMD_FLG_CALIB_MSK = (1 << 17), +/* activate TX calibration. */ +#define TX_CMD_FLG_CALIB_MSK __constant_cpu_to_le32(1 << 17) - /* signals that 2 bytes pad was inserted - * after the MAC header */ - TX_CMD_FLG_MH_PAD_MSK = (1 << 20), +/* signals that 2 bytes pad was inserted + after the MAC header */ +#define TX_CMD_FLG_MH_PAD_MSK __constant_cpu_to_le32(1 << 20) - /* HCCA-AP - disable duration overwriting. */ - TX_CMD_FLG_DUR_MSK = (1 << 25), -}; +/* HCCA-AP - disable duration overwriting. */ +#define TX_CMD_FLG_DUR_MSK __constant_cpu_to_le32(1 << 25) /* * TX command security control */ -#define TX_CMD_SEC_CCM 0x2 -#define TX_CMD_SEC_TKIP 0x3 +#define TX_CMD_SEC_CCM 0x2 +#define TX_CMD_SEC_TKIP 0x3 /* * TX command Frame life time @@ -313,11 +311,9 @@ enum { TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, }; -enum { - TX_PACKET_MODE_REGULAR = 0x0000, - TX_PACKET_MODE_BURST_PART = 0x00100, - TX_PACKET_MODE_BURST_FIRST = 0x0200, -}; +#define TX_PACKET_MODE_REGULAR 0x0000 +#define TX_PACKET_MODE_BURST_SEQ 0x0100 +#define TX_PACKET_MODE_BURST_FIRST 0x0200 enum { TX_POWER_PA_NOT_ACTIVE = 0x0, @@ -365,27 +361,32 @@ enum { #define AGG_TX_STATE_SEQ_NUM_POS 16 #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 -struct iwl_tx_resp { #if IWL == 4965 +struct iwl_tx_resp { u8 frame_count; /* 1 no aggregation, >1 aggregation */ u8 bt_kill_count; -#endif u8 failure_rts; u8 failure_frame; -#if IWL == 3945 - u8 bt_kill_count; - u8 rate; - __le32 wireless_media_time; -#elif IWL == 4965 - struct iwl_rate rate; + __le32 rate_n_flags; __le16 wireless_media_time; __le16 reserved; __le32 pa_power1; __le32 pa_power2; -#endif __le32 status; /* TX status (for aggregation status of 1st frame) */ } __attribute__ ((packed)); +#elif IWL == 3945 +struct iwl_tx_resp { + u8 failure_rts; + u8 failure_frame; + u8 bt_kill_count; + u8 rate; + __le32 wireless_media_time; + __le32 status; /* TX status (for aggregation status of 1st frame) */ +} __attribute__ ((packed)); +#endif + + /* TX command response is sent after *all* transmission attempts. * * NOTES: @@ -441,8 +442,7 @@ struct iwl_ssid_ie { } __attribute__ ((packed)); #define PROBE_OPTION_MAX 0x4 -#define TX_CMD_FLG_SEQ_CTL_MSK 0x2000 -#define TX_CMD_LIFE_TIME_INFINITE 0xFFFFFFFF +#define TX_CMD_LIFE_TIME_INFINITE __constant_cpu_to_le32(0xFFFFFFFF) #define IWL_GOOD_CRC_TH __constant_cpu_to_le16(1) #define IWL_MAX_SCAN_SIZE 1024 diff --git a/drivers/net/wireless/iwl-hw.h b/drivers/net/wireless/iwl-hw.h index 0cc341b..933a367 100644 --- a/drivers/net/wireless/iwl-hw.h +++ b/drivers/net/wireless/iwl-hw.h @@ -1207,7 +1207,7 @@ struct statistics { #define IWL_TX_QUEUE_HCCA_1 5 #define IWL_TX_QUEUE_HCCA_2 6 -#define U32_PAD(n) ((4-(n%4))%4) +#define U32_PAD(n) ((4-(n))&0x3) #define AC_BE_TID_MASK 0x9 /* TID 0 and 3 */ #define AC_BK_TID_MASK 0x6 /* TID 1 and 2 */ diff --git a/drivers/net/wireless/iwlwifi.h b/drivers/net/wireless/iwlwifi.h index dff6f6f..3de6425 100644 --- a/drivers/net/wireless/iwlwifi.h +++ b/drivers/net/wireless/iwlwifi.h @@ -229,9 +229,10 @@ struct iwl_frame { #define SEQ_TO_INDEX(x) (x & 0xff) #define INDEX_TO_SEQ(x) (x & 0xff) #define SEQ_HUGE_FRAME (0x4000) -#define SEQ_RX_FRAME (0x8000) +#define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000) #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) #define SN_TO_SEQ(ssn) (((ssn) << 4 ) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) enum { /* CMD_SIZE_NORMAL = 0, */ @@ -398,7 +399,7 @@ struct iwl_ht_agg { u16 start_idx; u32 bitmap0; u32 bitmap1; - struct iwl_rate rate; + u32 rate_n_flags; }; #endif /* CONFIG_IWLWIFI_HT_AGG */ #endif /* CONFIG_IWLWIFI_HT */ -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/7] iwlwifi: Endian fix for rate setting in 3945 2007-07-31 2:56 ` [PATCH 6/7] iwlwifi: Endianity fix for tx configuration Zhu Yi @ 2007-07-31 2:56 ` Zhu Yi 0 siblings, 0 replies; 9+ messages in thread From: Zhu Yi @ 2007-07-31 2:56 UTC (permalink / raw) To: linville; +Cc: linux-wireless, Tomas Winkler, Zhu Yi From: Tomas Winkler <tomas.winkler@intel.com> This patch fixes endianity issue in rate setting in 3945. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> --- drivers/net/wireless/iwl-3945-hw.h | 4 ++++ drivers/net/wireless/iwl-base.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/iwl-3945-hw.h b/drivers/net/wireless/iwl-3945-hw.h index 81c7263..8fdf9e0 100644 --- a/drivers/net/wireless/iwl-3945-hw.h +++ b/drivers/net/wireless/iwl-3945-hw.h @@ -97,4 +97,8 @@ static inline u16 iwl_hw_get_rate_n_flags(__le16 rate_n_flags) return le16_to_cpu(rate_n_flags); } +static inline __le16 iwl_hw_set_rate_n_flags(u8 rate, u16 flags) +{ + return cpu_to_le16((u16)rate|flags); +} #endif diff --git a/drivers/net/wireless/iwl-base.c b/drivers/net/wireless/iwl-base.c index 683f07d..44fc2cb 100644 --- a/drivers/net/wireless/iwl-base.c +++ b/drivers/net/wireless/iwl-base.c @@ -382,7 +382,9 @@ u8 iwl_add_station(struct iwl_priv *priv, const u8 * bssid, int is_ap, u8 flags) int index = IWL_INVALID_STATION; struct iwl_station_entry *station; unsigned long flags_spin; - +#if IWL == 3945 + u8 rate; +#endif spin_lock_irqsave(&priv->sta_lock, flags_spin); if (is_ap) { index = IWL_AP_ID; @@ -426,14 +428,15 @@ u8 iwl_add_station(struct iwl_priv *priv, const u8 * bssid, int is_ap, u8 flags) station->sta.sta.sta_id = i; station->sta.station_flags = 0; #if IWL == 3945 - station->sta.rate_n_flags = cpu_to_le16( - (priv->phymode == MODE_IEEE80211A) ? IWL_RATE_6M_PLCP : - IWL_RATE_1M_PLCP | priv->hw_setting.cck_flag); + rate = (priv->phymode == MODE_IEEE80211A) ? IWL_RATE_6M_PLCP : + IWL_RATE_1M_PLCP | priv->hw_setting.cck_flag; /* Turn on both antennas for the station... */ - station->sta.rate_n_flags |= RATE_MCS_ANT_AB_MSK; + station->sta.rate_n_flags = + iwl_hw_set_rate_n_flags(rate, RATE_MCS_ANT_AB_MSK); station->sta.station_flags |= STA_FLG_TX_RATE_MSK; + station->current_rate.rate_n_flags = le16_to_cpu( station->sta.rate_n_flags); #endif -- 1.5.2 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 4/7] iwlwifi: Endainity fix for rx configuration 2007-07-31 2:56 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Zhu Yi 2007-07-31 2:56 ` [PATCH 5/7] iwlwifi: Endianity fixes for 3945 Zhu Yi @ 2007-07-31 9:48 ` Michael Buesch 2007-07-31 10:11 ` Tomas Winkler 1 sibling, 1 reply; 9+ messages in thread From: Michael Buesch @ 2007-07-31 9:48 UTC (permalink / raw) To: Zhu Yi; +Cc: linville, linux-wireless, Tomas Winkler, Gregory Greenman On Tuesday 31 July 2007, Zhu Yi wrote: > From: Tomas Winkler <tomas.winkler@intel.com> > > This patch fixes endianity issues in rx configuration > related code. > > Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> > Signed-off-by: Zhu Yi <yi.zhu@intel.com> > --- > drivers/net/wireless/iwl-4965.c | 26 ++++--- > drivers/net/wireless/iwl-base.c | 148 +++++++++++++++++++++------------------ > drivers/net/wireless/iwl-hw.h | 10 ++-- > 3 files changed, 101 insertions(+), 83 deletions(-) > > diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c > index 19591a6..786c5d0 100644 > --- a/drivers/net/wireless/iwl-4965.c > +++ b/drivers/net/wireless/iwl-4965.c > @@ -3615,8 +3615,8 @@ static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data, > > hdr = (void *)(pkt->u.raw + > sizeof(struct iwl4965_rx_mpdu_res_start)); > - rx_end = (u32 *) (((u8 *) hdr) + amsdu->byte_count); > len = amsdu->byte_count; > + rx_end = (u32 *) (((u8 *) hdr) + len); I doubt rx_end is a pointer to u32. Most likely you want to use (__le32 *) here and also audit the users of rx_end, if they need le32_to_cpu(). ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/7] iwlwifi: Endainity fix for rx configuration 2007-07-31 9:48 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Michael Buesch @ 2007-07-31 10:11 ` Tomas Winkler 0 siblings, 0 replies; 9+ messages in thread From: Tomas Winkler @ 2007-07-31 10:11 UTC (permalink / raw) To: Michael Buesch; +Cc: Zhu Yi, linville, linux-wireless, Gregory Greenman On 7/31/07, Michael Buesch <mb@bu3sch.de> wrote: > On Tuesday 31 July 2007, Zhu Yi wrote: > > From: Tomas Winkler <tomas.winkler@intel.com> > > > > This patch fixes endianity issues in rx configuration > > related code. > > > > Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> > > Signed-off-by: Zhu Yi <yi.zhu@intel.com> > > --- > > drivers/net/wireless/iwl-4965.c | 26 ++++--- > > drivers/net/wireless/iwl-base.c | 148 +++++++++++++++++++++------------------ > > drivers/net/wireless/iwl-hw.h | 10 ++-- > > 3 files changed, 101 insertions(+), 83 deletions(-) > > > > diff --git a/drivers/net/wireless/iwl-4965.c b/drivers/net/wireless/iwl-4965.c > > index 19591a6..786c5d0 100644 > > --- a/drivers/net/wireless/iwl-4965.c > > +++ b/drivers/net/wireless/iwl-4965.c > > @@ -3615,8 +3615,8 @@ static void iwl4965_handle_data_packet(struct iwl_priv *priv, int is_data, > > > > hdr = (void *)(pkt->u.raw + > > sizeof(struct iwl4965_rx_mpdu_res_start)); > > - rx_end = (u32 *) (((u8 *) hdr) + amsdu->byte_count); > > len = amsdu->byte_count; > > + rx_end = (u32 *) (((u8 *) hdr) + len); > > I doubt rx_end is a pointer to u32. Most likely you want to use > (__le32 *) here and also audit the users of rx_end, if they > need le32_to_cpu(). > You are right. Only the len parameter was fixed. I will send another patch that fixes also the pointer. Thanks Tomas > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-07-31 10:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <11858505963374-git-send-email-yi.zhu@intel.com>
2007-07-31 2:56 ` [PATCH 1/7] iwlwifi: add IWLWIFI_HT Kconfig option Zhu Yi
2007-07-31 2:56 ` [PATCH 2/7] iwlwifi: fix rate setting in beacon command Zhu Yi
2007-07-31 2:56 ` [PATCH 3/7] iwlwifi: Endianity fix for TX host command Zhu Yi
2007-07-31 2:56 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Zhu Yi
2007-07-31 2:56 ` [PATCH 5/7] iwlwifi: Endianity fixes for 3945 Zhu Yi
2007-07-31 2:56 ` [PATCH 6/7] iwlwifi: Endianity fix for tx configuration Zhu Yi
2007-07-31 2:56 ` [PATCH 7/7] iwlwifi: Endian fix for rate setting in 3945 Zhu Yi
2007-07-31 9:48 ` [PATCH 4/7] iwlwifi: Endainity fix for rx configuration Michael Buesch
2007-07-31 10:11 ` Tomas Winkler
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).