aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-4965.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2008-06-11 21:47:11 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-14 12:18:08 -0400
commite7d326ac437e9e9425dcd79382f4e5f6ca31fb16 (patch)
tree82dad05f71fd368c98f30b39eb15921c17487a78 /drivers/net/wireless/iwlwifi/iwl-4965.c
parent2a421b91d6fe89e27ded7544a25449c0b050098f (diff)
iwlwifi: move rate helpers to iwlcore
This patch moves rate helpers to iwlcore. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-4965.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c79
1 files changed, 11 insertions, 68 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 1b8dc2dbdb8f..87648d0536b3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -307,60 +307,6 @@ static int is_fat_channel(__le32 rxon_flags)
307 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK); 307 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK);
308} 308}
309 309
310int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags)
311{
312 int idx = 0;
313
314 /* 4965 HT rate format */
315 if (rate_n_flags & RATE_MCS_HT_MSK) {
316 idx = (rate_n_flags & 0xff);
317
318 if (idx >= IWL_RATE_MIMO2_6M_PLCP)
319 idx = idx - IWL_RATE_MIMO2_6M_PLCP;
320
321 idx += IWL_FIRST_OFDM_RATE;
322 /* skip 9M not supported in ht*/
323 if (idx >= IWL_RATE_9M_INDEX)
324 idx += 1;
325 if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE))
326 return idx;
327
328 /* 4965 legacy rate format, search for match in table */
329 } else {
330 for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++)
331 if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
332 return idx;
333 }
334
335 return -1;
336}
337
338/**
339 * translate ucode response to mac80211 tx status control values
340 */
341void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
342 struct ieee80211_tx_info *control)
343{
344 int rate_index;
345
346 control->antenna_sel_tx =
347 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
348 if (rate_n_flags & RATE_MCS_HT_MSK)
349 control->flags |= IEEE80211_TX_CTL_OFDM_HT;
350 if (rate_n_flags & RATE_MCS_GF_MSK)
351 control->flags |= IEEE80211_TX_CTL_GREEN_FIELD;
352 if (rate_n_flags & RATE_MCS_FAT_MSK)
353 control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH;
354 if (rate_n_flags & RATE_MCS_DUP_MSK)
355 control->flags |= IEEE80211_TX_CTL_DUP_DATA;
356 if (rate_n_flags & RATE_MCS_SGI_MSK)
357 control->flags |= IEEE80211_TX_CTL_SHORT_GI;
358 rate_index = iwl4965_hwrate_to_plcp_idx(rate_n_flags);
359 if (control->band == IEEE80211_BAND_5GHZ)
360 rate_index -= IWL_FIRST_OFDM_RATE;
361 control->tx_rate_idx = rate_index;
362}
363
364/* 310/*
365 * EEPROM handlers 311 * EEPROM handlers
366 */ 312 */
@@ -1796,10 +1742,10 @@ unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
1796 1742
1797 if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP)) 1743 if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP))
1798 tx_beacon_cmd->tx.rate_n_flags = 1744 tx_beacon_cmd->tx.rate_n_flags =
1799 iwl4965_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK); 1745 iwl_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK);
1800 else 1746 else
1801 tx_beacon_cmd->tx.rate_n_flags = 1747 tx_beacon_cmd->tx.rate_n_flags =
1802 iwl4965_hw_set_rate_n_flags(rate, 0); 1748 iwl_hw_set_rate_n_flags(rate, 0);
1803 1749
1804 tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | 1750 tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK |
1805 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK); 1751 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK);
@@ -2568,7 +2514,7 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2568 else 2514 else
2569 title = "Frame"; 2515 title = "Frame";
2570 2516
2571 rate_idx = iwl4965_hwrate_to_plcp_idx(rate_sym); 2517 rate_idx = iwl_hwrate_to_plcp_idx(rate_sym);
2572 if (unlikely(rate_idx == -1)) 2518 if (unlikely(rate_idx == -1))
2573 bitrate = 0; 2519 bitrate = 0;
2574 else 2520 else
@@ -2633,7 +2579,7 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv,
2633 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 2579 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
2634 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 2580 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
2635 rx_status.rate_idx = 2581 rx_status.rate_idx =
2636 iwl4965_hwrate_to_plcp_idx(le32_to_cpu(rx_start->rate_n_flags)); 2582 iwl_hwrate_to_plcp_idx(le32_to_cpu(rx_start->rate_n_flags));
2637 if (rx_status.band == IEEE80211_BAND_5GHZ) 2583 if (rx_status.band == IEEE80211_BAND_5GHZ)
2638 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; 2584 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE;
2639 2585
@@ -2842,7 +2788,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv,
2842 info->flags |= IEEE80211_TX_STAT_AMPDU; 2788 info->flags |= IEEE80211_TX_STAT_AMPDU;
2843 info->status.ampdu_ack_map = successes; 2789 info->status.ampdu_ack_map = successes;
2844 info->status.ampdu_ack_len = agg->frame_count; 2790 info->status.ampdu_ack_len = agg->frame_count;
2845 iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); 2791 iwl_hwrate_to_tx_control(priv, agg->rate_n_flags, info);
2846 2792
2847 IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); 2793 IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap);
2848 2794
@@ -3189,15 +3135,15 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3189 struct agg_tx_status *frame_status = tx_resp->u.agg_status; 3135 struct agg_tx_status *frame_status = tx_resp->u.agg_status;
3190 struct ieee80211_tx_info *info = NULL; 3136 struct ieee80211_tx_info *info = NULL;
3191 struct ieee80211_hdr *hdr = NULL; 3137 struct ieee80211_hdr *hdr = NULL;
3138 u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
3192 int i, sh, idx; 3139 int i, sh, idx;
3193 u16 seq; 3140 u16 seq;
3194
3195 if (agg->wait_for_ba) 3141 if (agg->wait_for_ba)
3196 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); 3142 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
3197 3143
3198 agg->frame_count = tx_resp->frame_count; 3144 agg->frame_count = tx_resp->frame_count;
3199 agg->start_idx = start_idx; 3145 agg->start_idx = start_idx;
3200 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3146 agg->rate_n_flags = rate_n_flags;
3201 agg->bitmap = 0; 3147 agg->bitmap = 0;
3202 3148
3203 /* # frames attempted by Tx command */ 3149 /* # frames attempted by Tx command */
@@ -3215,15 +3161,12 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3215 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 3161 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
3216 info->flags |= iwl_is_tx_success(status)? 3162 info->flags |= iwl_is_tx_success(status)?
3217 IEEE80211_TX_STAT_ACK : 0; 3163 IEEE80211_TX_STAT_ACK : 0;
3218 iwl4965_hwrate_to_tx_control(priv, 3164 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
3219 le32_to_cpu(tx_resp->rate_n_flags),
3220 info);
3221 /* FIXME: code repetition end */ 3165 /* FIXME: code repetition end */
3222 3166
3223 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 3167 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
3224 status & 0xff, tx_resp->failure_frame); 3168 status & 0xff, tx_resp->failure_frame);
3225 IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", 3169 IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
3226 iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags));
3227 3170
3228 agg->wait_for_ba = 0; 3171 agg->wait_for_ba = 0;
3229 } else { 3172 } else {
@@ -3281,7 +3224,6 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3281 3224
3282 agg->bitmap = bitmap; 3225 agg->bitmap = bitmap;
3283 agg->start_idx = start; 3226 agg->start_idx = start;
3284 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
3285 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", 3227 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
3286 agg->frame_count, agg->start_idx, 3228 agg->frame_count, agg->start_idx,
3287 (unsigned long long)agg->bitmap); 3229 (unsigned long long)agg->bitmap);
@@ -3375,7 +3317,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3375 info->status.retry_count = tx_resp->failure_frame; 3317 info->status.retry_count = tx_resp->failure_frame;
3376 info->flags |= 3318 info->flags |=
3377 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 3319 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
3378 iwl4965_hwrate_to_tx_control(priv, 3320 iwl_hwrate_to_tx_control(priv,
3379 le32_to_cpu(tx_resp->rate_n_flags), 3321 le32_to_cpu(tx_resp->rate_n_flags),
3380 info); 3322 info);
3381 3323
@@ -3386,6 +3328,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3386 tx_resp->failure_frame); 3328 tx_resp->failure_frame);
3387 3329
3388 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 3330 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
3331
3389 if (index != -1) { 3332 if (index != -1) {
3390 int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 3333 int freed = iwl_tx_queue_reclaim(priv, txq_id, index);
3391 if (tid != MAX_TID_COUNT) 3334 if (tid != MAX_TID_COUNT)