aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-4965.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-4965.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c388
1 files changed, 93 insertions, 295 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index aee7014bcb94..ab5027345a01 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -46,6 +46,9 @@
46#include "iwl-calib.h" 46#include "iwl-calib.h"
47#include "iwl-sta.h" 47#include "iwl-sta.h"
48 48
49static int iwl4965_send_tx_power(struct iwl_priv *priv);
50static int iwl4965_hw_get_temperature(const struct iwl_priv *priv);
51
49/* module parameters */ 52/* module parameters */
50static struct iwl_mod_params iwl4965_mod_params = { 53static struct iwl_mod_params iwl4965_mod_params = {
51 .num_of_queues = IWL49_NUM_QUEUES, 54 .num_of_queues = IWL49_NUM_QUEUES,
@@ -281,7 +284,7 @@ static void iwl4965_init_alive_start(struct iwl_priv *priv)
281 } 284 }
282 285
283 /* Calculate temperature */ 286 /* Calculate temperature */
284 priv->temperature = iwl4965_get_temperature(priv); 287 priv->temperature = iwl4965_hw_get_temperature(priv);
285 288
286 /* Send pointers to protocol/runtime uCode image ... init code will 289 /* Send pointers to protocol/runtime uCode image ... init code will
287 * load and launch runtime uCode, which will send us another "Alive" 290 * load and launch runtime uCode, which will send us another "Alive"
@@ -305,60 +308,6 @@ static int is_fat_channel(__le32 rxon_flags)
305 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK); 308 (rxon_flags & RXON_FLG_CHANNEL_MODE_MIXED_MSK);
306} 309}
307 310
308int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags)
309{
310 int idx = 0;
311
312 /* 4965 HT rate format */
313 if (rate_n_flags & RATE_MCS_HT_MSK) {
314 idx = (rate_n_flags & 0xff);
315
316 if (idx >= IWL_RATE_MIMO2_6M_PLCP)
317 idx = idx - IWL_RATE_MIMO2_6M_PLCP;
318
319 idx += IWL_FIRST_OFDM_RATE;
320 /* skip 9M not supported in ht*/
321 if (idx >= IWL_RATE_9M_INDEX)
322 idx += 1;
323 if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE))
324 return idx;
325
326 /* 4965 legacy rate format, search for match in table */
327 } else {
328 for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++)
329 if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
330 return idx;
331 }
332
333 return -1;
334}
335
336/**
337 * translate ucode response to mac80211 tx status control values
338 */
339void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
340 struct ieee80211_tx_info *control)
341{
342 int rate_index;
343
344 control->antenna_sel_tx =
345 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
346 if (rate_n_flags & RATE_MCS_HT_MSK)
347 control->flags |= IEEE80211_TX_CTL_OFDM_HT;
348 if (rate_n_flags & RATE_MCS_GF_MSK)
349 control->flags |= IEEE80211_TX_CTL_GREEN_FIELD;
350 if (rate_n_flags & RATE_MCS_FAT_MSK)
351 control->flags |= IEEE80211_TX_CTL_40_MHZ_WIDTH;
352 if (rate_n_flags & RATE_MCS_DUP_MSK)
353 control->flags |= IEEE80211_TX_CTL_DUP_DATA;
354 if (rate_n_flags & RATE_MCS_SGI_MSK)
355 control->flags |= IEEE80211_TX_CTL_SHORT_GI;
356 rate_index = iwl4965_hwrate_to_plcp_idx(rate_n_flags);
357 if (control->band == IEEE80211_BAND_5GHZ)
358 rate_index -= IWL_FIRST_OFDM_RATE;
359 control->tx_rate_idx = rate_index;
360}
361
362/* 311/*
363 * EEPROM handlers 312 * EEPROM handlers
364 */ 313 */
@@ -608,52 +557,6 @@ out:
608 557
609#define REG_RECALIB_PERIOD (60) 558#define REG_RECALIB_PERIOD (60)
610 559
611/**
612 * iwl4965_bg_statistics_periodic - Timer callback to queue statistics
613 *
614 * This callback is provided in order to send a statistics request.
615 *
616 * This timer function is continually reset to execute within
617 * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION
618 * was received. We need to ensure we receive the statistics in order
619 * to update the temperature used for calibrating the TXPOWER.
620 */
621static void iwl4965_bg_statistics_periodic(unsigned long data)
622{
623 struct iwl_priv *priv = (struct iwl_priv *)data;
624
625 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
626 return;
627
628 iwl_send_statistics_request(priv, CMD_ASYNC);
629}
630
631void iwl4965_rf_kill_ct_config(struct iwl_priv *priv)
632{
633 struct iwl4965_ct_kill_config cmd;
634 unsigned long flags;
635 int ret = 0;
636
637 spin_lock_irqsave(&priv->lock, flags);
638 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
639 CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
640 spin_unlock_irqrestore(&priv->lock, flags);
641
642 cmd.critical_temperature_R =
643 cpu_to_le32(priv->hw_params.ct_kill_threshold);
644
645 ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD,
646 sizeof(cmd), &cmd);
647 if (ret)
648 IWL_ERROR("REPLY_CT_KILL_CONFIG_CMD failed\n");
649 else
650 IWL_DEBUG_INFO("REPLY_CT_KILL_CONFIG_CMD succeeded, "
651 "critical temperature is %d\n",
652 cmd.critical_temperature_R);
653}
654
655#ifdef CONFIG_IWL4965_RUN_TIME_CALIB
656
657/* Reset differential Rx gains in NIC to prepare for chain noise calibration. 560/* Reset differential Rx gains in NIC to prepare for chain noise calibration.
658 * Called after every association, but this runs only once! 561 * Called after every association, but this runs only once!
659 * ... once chain noise is calibrated the first time, it's good forever. */ 562 * ... once chain noise is calibrated the first time, it's good forever. */
@@ -741,30 +644,6 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
741 data->beacon_count = 0; 644 data->beacon_count = 0;
742} 645}
743 646
744static void iwl4965_bg_sensitivity_work(struct work_struct *work)
745{
746 struct iwl_priv *priv = container_of(work, struct iwl_priv,
747 sensitivity_work);
748
749 mutex_lock(&priv->mutex);
750
751 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
752 test_bit(STATUS_SCANNING, &priv->status)) {
753 mutex_unlock(&priv->mutex);
754 return;
755 }
756
757 if (priv->start_calib) {
758 iwl_chain_noise_calibration(priv, &priv->statistics);
759
760 iwl_sensitivity_calibration(priv, &priv->statistics);
761 }
762
763 mutex_unlock(&priv->mutex);
764 return;
765}
766#endif /*CONFIG_IWL4965_RUN_TIME_CALIB*/
767
768static void iwl4965_bg_txpower_work(struct work_struct *work) 647static void iwl4965_bg_txpower_work(struct work_struct *work)
769{ 648{
770 struct iwl_priv *priv = container_of(work, struct iwl_priv, 649 struct iwl_priv *priv = container_of(work, struct iwl_priv,
@@ -783,7 +662,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work)
783 /* Regardless of if we are assocaited, we must reconfigure the 662 /* Regardless of if we are assocaited, we must reconfigure the
784 * TX power since frames can be sent on non-radar channels while 663 * TX power since frames can be sent on non-radar channels while
785 * not associated */ 664 * not associated */
786 iwl4965_hw_reg_send_txpower(priv); 665 iwl4965_send_tx_power(priv);
787 666
788 /* Update last_temperature to keep is_calib_needed from running 667 /* Update last_temperature to keep is_calib_needed from running
789 * when it isn't needed... */ 668 * when it isn't needed... */
@@ -843,7 +722,7 @@ static const u16 default_queue_to_tx_fifo[] = {
843 IWL_TX_FIFO_HCCA_2 722 IWL_TX_FIFO_HCCA_2
844}; 723};
845 724
846int iwl4965_alive_notify(struct iwl_priv *priv) 725static int iwl4965_alive_notify(struct iwl_priv *priv)
847{ 726{
848 u32 a; 727 u32 a;
849 int i = 0; 728 int i = 0;
@@ -920,7 +799,6 @@ int iwl4965_alive_notify(struct iwl_priv *priv)
920 return ret; 799 return ret;
921} 800}
922 801
923#ifdef CONFIG_IWL4965_RUN_TIME_CALIB
924static struct iwl_sensitivity_ranges iwl4965_sensitivity = { 802static struct iwl_sensitivity_ranges iwl4965_sensitivity = {
925 .min_nrg_cck = 97, 803 .min_nrg_cck = 97,
926 .max_nrg_cck = 0, 804 .max_nrg_cck = 0,
@@ -943,14 +821,13 @@ static struct iwl_sensitivity_ranges iwl4965_sensitivity = {
943 .nrg_th_cck = 100, 821 .nrg_th_cck = 100,
944 .nrg_th_ofdm = 100, 822 .nrg_th_ofdm = 100,
945}; 823};
946#endif
947 824
948/** 825/**
949 * iwl4965_hw_set_hw_params 826 * iwl4965_hw_set_hw_params
950 * 827 *
951 * Called when initializing driver 828 * Called when initializing driver
952 */ 829 */
953int iwl4965_hw_set_hw_params(struct iwl_priv *priv) 830static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
954{ 831{
955 832
956 if ((priv->cfg->mod_params->num_of_queues > IWL49_NUM_QUEUES) || 833 if ((priv->cfg->mod_params->num_of_queues > IWL49_NUM_QUEUES) ||
@@ -961,6 +838,7 @@ int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
961 } 838 }
962 839
963 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues; 840 priv->hw_params.max_txq_num = priv->cfg->mod_params->num_of_queues;
841 priv->hw_params.first_ampdu_q = IWL49_FIRST_AMPDU_QUEUE;
964 priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; 842 priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto;
965 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; 843 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE;
966 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; 844 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
@@ -983,9 +861,7 @@ int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
983 priv->hw_params.valid_rx_ant = ANT_A | ANT_B; 861 priv->hw_params.valid_rx_ant = ANT_A | ANT_B;
984 priv->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD); 862 priv->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD);
985 863
986#ifdef CONFIG_IWL4965_RUN_TIME_CALIB
987 priv->hw_params.sens = &iwl4965_sensitivity; 864 priv->hw_params.sens = &iwl4965_sensitivity;
988#endif
989 865
990 return 0; 866 return 0;
991} 867}
@@ -1001,11 +877,6 @@ static int iwl4965_set_power(struct iwl_priv *priv,
1001 cmd, NULL); 877 cmd, NULL);
1002 return ret; 878 return ret;
1003} 879}
1004int iwl4965_hw_reg_set_txpower(struct iwl_priv *priv, s8 power)
1005{
1006 IWL_ERROR("TODO: Implement iwl4965_hw_reg_set_txpower!\n");
1007 return -EINVAL;
1008}
1009 880
1010static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) 881static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res)
1011{ 882{
@@ -1056,20 +927,6 @@ static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage,
1056 return comp; 927 return comp;
1057} 928}
1058 929
1059static const struct iwl_channel_info *
1060iwl4965_get_channel_txpower_info(struct iwl_priv *priv,
1061 enum ieee80211_band band, u16 channel)
1062{
1063 const struct iwl_channel_info *ch_info;
1064
1065 ch_info = iwl_get_channel_info(priv, band, channel);
1066
1067 if (!is_channel_valid(ch_info))
1068 return NULL;
1069
1070 return ch_info;
1071}
1072
1073static s32 iwl4965_get_tx_atten_grp(u16 channel) 930static s32 iwl4965_get_tx_atten_grp(u16 channel)
1074{ 931{
1075 if (channel >= CALIB_IWL_TX_ATTEN_GR5_FCH && 932 if (channel >= CALIB_IWL_TX_ATTEN_GR5_FCH &&
@@ -1493,30 +1350,17 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1493 s32 factory_actual_pwr[2]; 1350 s32 factory_actual_pwr[2];
1494 s32 power_index; 1351 s32 power_index;
1495 1352
1496 /* Sanity check requested level (dBm) */
1497 if (priv->user_txpower_limit < IWL_TX_POWER_TARGET_POWER_MIN) {
1498 IWL_WARNING("Requested user TXPOWER %d below limit.\n",
1499 priv->user_txpower_limit);
1500 return -EINVAL;
1501 }
1502 if (priv->user_txpower_limit > IWL_TX_POWER_TARGET_POWER_MAX) {
1503 IWL_WARNING("Requested user TXPOWER %d above limit.\n",
1504 priv->user_txpower_limit);
1505 return -EINVAL;
1506 }
1507
1508 /* user_txpower_limit is in dBm, convert to half-dBm (half-dB units 1353 /* user_txpower_limit is in dBm, convert to half-dBm (half-dB units
1509 * are used for indexing into txpower table) */ 1354 * are used for indexing into txpower table) */
1510 user_target_power = 2 * priv->user_txpower_limit; 1355 user_target_power = 2 * priv->tx_power_user_lmt;
1511 1356
1512 /* Get current (RXON) channel, band, width */ 1357 /* Get current (RXON) channel, band, width */
1513 ch_info =
1514 iwl4965_get_channel_txpower_info(priv, priv->band, channel);
1515
1516 IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band, 1358 IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band,
1517 is_fat); 1359 is_fat);
1518 1360
1519 if (!ch_info) 1361 ch_info = iwl_get_channel_info(priv, priv->band, channel);
1362
1363 if (!is_channel_valid(ch_info))
1520 return -EINVAL; 1364 return -EINVAL;
1521 1365
1522 /* get txatten group, used to select 1) thermal txpower adjustment 1366 /* get txatten group, used to select 1) thermal txpower adjustment
@@ -1717,12 +1561,12 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1717} 1561}
1718 1562
1719/** 1563/**
1720 * iwl4965_hw_reg_send_txpower - Configure the TXPOWER level user limit 1564 * iwl4965_send_tx_power - Configure the TXPOWER level user limit
1721 * 1565 *
1722 * Uses the active RXON for channel, band, and characteristics (fat, high) 1566 * Uses the active RXON for channel, band, and characteristics (fat, high)
1723 * The power limit is taken from priv->user_txpower_limit. 1567 * The power limit is taken from priv->tx_power_user_lmt.
1724 */ 1568 */
1725int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv) 1569static int iwl4965_send_tx_power(struct iwl_priv *priv)
1726{ 1570{
1727 struct iwl4965_txpowertable_cmd cmd = { 0 }; 1571 struct iwl4965_txpowertable_cmd cmd = { 0 };
1728 int ret; 1572 int ret;
@@ -1848,11 +1692,6 @@ static int iwl4965_shared_mem_rx_idx(struct iwl_priv *priv)
1848 return le32_to_cpu(s->rb_closed) & 0xFFF; 1692 return le32_to_cpu(s->rb_closed) & 0xFFF;
1849} 1693}
1850 1694
1851int iwl4965_hw_get_temperature(struct iwl_priv *priv)
1852{
1853 return priv->temperature;
1854}
1855
1856unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, 1695unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
1857 struct iwl_frame *frame, u8 rate) 1696 struct iwl_frame *frame, u8 rate)
1858{ 1697{
@@ -1875,10 +1714,10 @@ unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
1875 1714
1876 if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP)) 1715 if ((rate == IWL_RATE_1M_PLCP) || (rate >= IWL_RATE_2M_PLCP))
1877 tx_beacon_cmd->tx.rate_n_flags = 1716 tx_beacon_cmd->tx.rate_n_flags =
1878 iwl4965_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK); 1717 iwl_hw_set_rate_n_flags(rate, RATE_MCS_CCK_MSK);
1879 else 1718 else
1880 tx_beacon_cmd->tx.rate_n_flags = 1719 tx_beacon_cmd->tx.rate_n_flags =
1881 iwl4965_hw_set_rate_n_flags(rate, 0); 1720 iwl_hw_set_rate_n_flags(rate, 0);
1882 1721
1883 tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | 1722 tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK |
1884 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK); 1723 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK);
@@ -1950,12 +1789,12 @@ static s32 sign_extend(u32 oper, int index)
1950} 1789}
1951 1790
1952/** 1791/**
1953 * iwl4965_get_temperature - return the calibrated temperature (in Kelvin) 1792 * iwl4965_hw_get_temperature - return the calibrated temperature (in Kelvin)
1954 * @statistics: Provides the temperature reading from the uCode 1793 * @statistics: Provides the temperature reading from the uCode
1955 * 1794 *
1956 * A return of <0 indicates bogus data in the statistics 1795 * A return of <0 indicates bogus data in the statistics
1957 */ 1796 */
1958int iwl4965_get_temperature(const struct iwl_priv *priv) 1797static int iwl4965_hw_get_temperature(const struct iwl_priv *priv)
1959{ 1798{
1960 s32 temperature; 1799 s32 temperature;
1961 s32 vt; 1800 s32 vt;
@@ -1990,8 +1829,7 @@ int iwl4965_get_temperature(const struct iwl_priv *priv)
1990 vt = sign_extend( 1829 vt = sign_extend(
1991 le32_to_cpu(priv->statistics.general.temperature), 23); 1830 le32_to_cpu(priv->statistics.general.temperature), 23);
1992 1831
1993 IWL_DEBUG_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", 1832 IWL_DEBUG_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt);
1994 R1, R2, R3, vt);
1995 1833
1996 if (R3 == R1) { 1834 if (R3 == R1) {
1997 IWL_ERROR("Calibration conflict R1 == R3\n"); 1835 IWL_ERROR("Calibration conflict R1 == R3\n");
@@ -2002,11 +1840,10 @@ int iwl4965_get_temperature(const struct iwl_priv *priv)
2002 * Add offset to center the adjustment around 0 degrees Centigrade. */ 1840 * Add offset to center the adjustment around 0 degrees Centigrade. */
2003 temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); 1841 temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2);
2004 temperature /= (R3 - R1); 1842 temperature /= (R3 - R1);
2005 temperature = (temperature * 97) / 100 + 1843 temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET;
2006 TEMPERATURE_CALIB_KELVIN_OFFSET;
2007 1844
2008 IWL_DEBUG_TEMP("Calibrated temperature: %dK, %dC\n", temperature, 1845 IWL_DEBUG_TEMP("Calibrated temperature: %dK, %dC\n",
2009 KELVIN_TO_CELSIUS(temperature)); 1846 temperature, KELVIN_TO_CELSIUS(temperature));
2010 1847
2011 return temperature; 1848 return temperature;
2012} 1849}
@@ -2123,9 +1960,7 @@ void iwl4965_hw_rx_statistics(struct iwl_priv *priv,
2123 if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && 1960 if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) &&
2124 (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { 1961 (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) {
2125 iwl4965_rx_calc_noise(priv); 1962 iwl4965_rx_calc_noise(priv);
2126#ifdef CONFIG_IWL4965_RUN_TIME_CALIB 1963 queue_work(priv->workqueue, &priv->run_time_calib_work);
2127 queue_work(priv->workqueue, &priv->sensitivity_work);
2128#endif
2129 } 1964 }
2130 1965
2131 iwl_leds_background(priv); 1966 iwl_leds_background(priv);
@@ -2136,7 +1971,7 @@ void iwl4965_hw_rx_statistics(struct iwl_priv *priv,
2136 if (!change) 1971 if (!change)
2137 return; 1972 return;
2138 1973
2139 temp = iwl4965_get_temperature(priv); 1974 temp = iwl4965_hw_get_temperature(priv);
2140 if (temp < 0) 1975 if (temp < 0)
2141 return; 1976 return;
2142 1977
@@ -2155,8 +1990,9 @@ void iwl4965_hw_rx_statistics(struct iwl_priv *priv,
2155 priv->temperature = temp; 1990 priv->temperature = temp;
2156 set_bit(STATUS_TEMPERATURE, &priv->status); 1991 set_bit(STATUS_TEMPERATURE, &priv->status);
2157 1992
2158 if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && 1993 if (!priv->disable_tx_power_cal &&
2159 iwl4965_is_temp_calib_needed(priv)) 1994 unlikely(!test_bit(STATUS_SCANNING, &priv->status)) &&
1995 iwl4965_is_temp_calib_needed(priv))
2160 queue_work(priv->workqueue, &priv->txpower_work); 1996 queue_work(priv->workqueue, &priv->txpower_work);
2161} 1997}
2162 1998
@@ -2552,7 +2388,7 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2552 u32 print_dump = 0; /* set to 1 to dump all frames' contents */ 2388 u32 print_dump = 0; /* set to 1 to dump all frames' contents */
2553 u32 hundred = 0; 2389 u32 hundred = 0;
2554 u32 dataframe = 0; 2390 u32 dataframe = 0;
2555 u16 fc; 2391 __le16 fc;
2556 u16 seq_ctl; 2392 u16 seq_ctl;
2557 u16 channel; 2393 u16 channel;
2558 u16 phy_flags; 2394 u16 phy_flags;
@@ -2575,7 +2411,7 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2575 return; 2411 return;
2576 2412
2577 /* MAC header */ 2413 /* MAC header */
2578 fc = le16_to_cpu(header->frame_control); 2414 fc = header->frame_control;
2579 seq_ctl = le16_to_cpu(header->seq_ctrl); 2415 seq_ctl = le16_to_cpu(header->seq_ctrl);
2580 2416
2581 /* metadata */ 2417 /* metadata */
@@ -2600,8 +2436,8 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2600 2436
2601 /* if data frame is to us and all is good, 2437 /* if data frame is to us and all is good,
2602 * (optionally) print summary for only 1 out of every 100 */ 2438 * (optionally) print summary for only 1 out of every 100 */
2603 if (to_us && (fc & ~IEEE80211_FCTL_PROTECTED) == 2439 if (to_us && (fc & ~cpu_to_le16(IEEE80211_FCTL_PROTECTED)) ==
2604 (IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) { 2440 cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FTYPE_DATA)) {
2605 dataframe = 1; 2441 dataframe = 1;
2606 if (!group100) 2442 if (!group100)
2607 print_summary = 1; /* print each frame */ 2443 print_summary = 1; /* print each frame */
@@ -2625,13 +2461,13 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2625 2461
2626 if (hundred) 2462 if (hundred)
2627 title = "100Frames"; 2463 title = "100Frames";
2628 else if (fc & IEEE80211_FCTL_RETRY) 2464 else if (ieee80211_has_retry(fc))
2629 title = "Retry"; 2465 title = "Retry";
2630 else if (ieee80211_is_assoc_response(fc)) 2466 else if (ieee80211_is_assoc_resp(fc))
2631 title = "AscRsp"; 2467 title = "AscRsp";
2632 else if (ieee80211_is_reassoc_response(fc)) 2468 else if (ieee80211_is_reassoc_resp(fc))
2633 title = "RasRsp"; 2469 title = "RasRsp";
2634 else if (ieee80211_is_probe_response(fc)) { 2470 else if (ieee80211_is_probe_resp(fc)) {
2635 title = "PrbRsp"; 2471 title = "PrbRsp";
2636 print_dump = 1; /* dump frame contents */ 2472 print_dump = 1; /* dump frame contents */
2637 } else if (ieee80211_is_beacon(fc)) { 2473 } else if (ieee80211_is_beacon(fc)) {
@@ -2648,7 +2484,7 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2648 else 2484 else
2649 title = "Frame"; 2485 title = "Frame";
2650 2486
2651 rate_idx = iwl4965_hwrate_to_plcp_idx(rate_sym); 2487 rate_idx = iwl_hwrate_to_plcp_idx(rate_sym);
2652 if (unlikely(rate_idx == -1)) 2488 if (unlikely(rate_idx == -1))
2653 bitrate = 0; 2489 bitrate = 0;
2654 else 2490 else
@@ -2660,14 +2496,14 @@ static void iwl4965_dbg_report_frame(struct iwl_priv *priv,
2660 if (dataframe) 2496 if (dataframe)
2661 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, " 2497 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, "
2662 "len=%u, rssi=%d, chnl=%d, rate=%u, \n", 2498 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
2663 title, fc, header->addr1[5], 2499 title, le16_to_cpu(fc), header->addr1[5],
2664 length, rssi, channel, bitrate); 2500 length, rssi, channel, bitrate);
2665 else { 2501 else {
2666 /* src/dst addresses assume managed mode */ 2502 /* src/dst addresses assume managed mode */
2667 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, " 2503 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, "
2668 "src=0x%02x, rssi=%u, tim=%lu usec, " 2504 "src=0x%02x, rssi=%u, tim=%lu usec, "
2669 "phy=0x%02x, chnl=%d\n", 2505 "phy=0x%02x, chnl=%d\n",
2670 title, fc, header->addr1[5], 2506 title, le16_to_cpu(fc), header->addr1[5],
2671 header->addr3[5], rssi, 2507 header->addr3[5], rssi,
2672 tsf_low - priv->scan_start_tsf, 2508 tsf_low - priv->scan_start_tsf,
2673 phy_flags, channel); 2509 phy_flags, channel);
@@ -2713,7 +2549,7 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv,
2713 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 2549 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
2714 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 2550 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
2715 rx_status.rate_idx = 2551 rx_status.rate_idx =
2716 iwl4965_hwrate_to_plcp_idx(le32_to_cpu(rx_start->rate_n_flags)); 2552 iwl_hwrate_to_plcp_idx(le32_to_cpu(rx_start->rate_n_flags));
2717 if (rx_status.band == IEEE80211_BAND_5GHZ) 2553 if (rx_status.band == IEEE80211_BAND_5GHZ)
2718 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; 2554 rx_status.rate_idx -= IWL_FIRST_OFDM_RATE;
2719 2555
@@ -2819,7 +2655,6 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv,
2819 break; 2655 break;
2820 2656
2821 case IEEE80211_FTYPE_CTL: 2657 case IEEE80211_FTYPE_CTL:
2822#ifdef CONFIG_IWL4965_HT
2823 switch (fc & IEEE80211_FCTL_STYPE) { 2658 switch (fc & IEEE80211_FCTL_STYPE) {
2824 case IEEE80211_STYPE_BACK_REQ: 2659 case IEEE80211_STYPE_BACK_REQ:
2825 IWL_DEBUG_HT("IEEE80211_STYPE_BACK_REQ arrived\n"); 2660 IWL_DEBUG_HT("IEEE80211_STYPE_BACK_REQ arrived\n");
@@ -2829,7 +2664,6 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv,
2829 default: 2664 default:
2830 break; 2665 break;
2831 } 2666 }
2832#endif
2833 break; 2667 break;
2834 2668
2835 case IEEE80211_FTYPE_DATA: { 2669 case IEEE80211_FTYPE_DATA: {
@@ -2863,8 +2697,6 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv,
2863 } 2697 }
2864} 2698}
2865 2699
2866#ifdef CONFIG_IWL4965_HT
2867
2868/** 2700/**
2869 * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack 2701 * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack
2870 * 2702 *
@@ -2926,7 +2758,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv,
2926 info->flags |= IEEE80211_TX_STAT_AMPDU; 2758 info->flags |= IEEE80211_TX_STAT_AMPDU;
2927 info->status.ampdu_ack_map = successes; 2759 info->status.ampdu_ack_map = successes;
2928 info->status.ampdu_ack_len = agg->frame_count; 2760 info->status.ampdu_ack_len = agg->frame_count;
2929 iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); 2761 iwl_hwrate_to_tx_control(priv, agg->rate_n_flags, info);
2930 2762
2931 IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); 2763 IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap);
2932 2764
@@ -2948,7 +2780,7 @@ static void iwl4965_tx_queue_stop_scheduler(struct iwl_priv *priv,
2948} 2780}
2949 2781
2950/** 2782/**
2951 * txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID 2783 * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE
2952 * priv->lock must be held by the caller 2784 * priv->lock must be held by the caller
2953 */ 2785 */
2954static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, 2786static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
@@ -2956,9 +2788,9 @@ static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
2956{ 2788{
2957 int ret = 0; 2789 int ret = 0;
2958 2790
2959 if (IWL_BACK_QUEUE_FIRST_ID > txq_id) { 2791 if (IWL49_FIRST_AMPDU_QUEUE > txq_id) {
2960 IWL_WARNING("queue number too small: %d, must be > %d\n", 2792 IWL_WARNING("queue number too small: %d, must be > %d\n",
2961 txq_id, IWL_BACK_QUEUE_FIRST_ID); 2793 txq_id, IWL49_FIRST_AMPDU_QUEUE);
2962 return -EINVAL; 2794 return -EINVAL;
2963 } 2795 }
2964 2796
@@ -3046,7 +2878,7 @@ static void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv,
3046 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { 2878 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) {
3047 /* calculate mac80211 ampdu sw queue to wake */ 2879 /* calculate mac80211 ampdu sw queue to wake */
3048 int ampdu_q = 2880 int ampdu_q =
3049 scd_flow - IWL_BACK_QUEUE_FIRST_ID + priv->hw->queues; 2881 scd_flow - priv->hw_params.first_ampdu_q + priv->hw->queues;
3050 int freed = iwl_tx_queue_reclaim(priv, scd_flow, index); 2882 int freed = iwl_tx_queue_reclaim(priv, scd_flow, index);
3051 priv->stations[ba_resp->sta_id]. 2883 priv->stations[ba_resp->sta_id].
3052 tid[ba_resp->tid].tfds_in_queue -= freed; 2884 tid[ba_resp->tid].tfds_in_queue -= freed;
@@ -3091,7 +2923,7 @@ static int iwl4965_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
3091/** 2923/**
3092 * iwl4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue 2924 * iwl4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue
3093 * 2925 *
3094 * NOTE: txq_id must be greater than IWL_BACK_QUEUE_FIRST_ID, 2926 * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE,
3095 * i.e. it must be one of the higher queues used for aggregation 2927 * i.e. it must be one of the higher queues used for aggregation
3096 */ 2928 */
3097static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, 2929static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
@@ -3101,9 +2933,9 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
3101 int ret; 2933 int ret;
3102 u16 ra_tid; 2934 u16 ra_tid;
3103 2935
3104 if (IWL_BACK_QUEUE_FIRST_ID > txq_id) 2936 if (IWL49_FIRST_AMPDU_QUEUE > txq_id)
3105 IWL_WARNING("queue number too small: %d, must be > %d\n", 2937 IWL_WARNING("queue number too small: %d, must be > %d\n",
3106 txq_id, IWL_BACK_QUEUE_FIRST_ID); 2938 txq_id, IWL49_FIRST_AMPDU_QUEUE);
3107 2939
3108 ra_tid = BUILD_RAxTID(sta_id, tid); 2940 ra_tid = BUILD_RAxTID(sta_id, tid);
3109 2941
@@ -3154,10 +2986,6 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
3154 return 0; 2986 return 0;
3155} 2987}
3156 2988
3157#endif /* CONFIG_IWL4965_HT */
3158
3159
3160#ifdef CONFIG_IWL4965_HT
3161static int iwl4965_rx_agg_start(struct iwl_priv *priv, 2989static int iwl4965_rx_agg_start(struct iwl_priv *priv,
3162 const u8 *addr, int tid, u16 ssn) 2990 const u8 *addr, int tid, u16 ssn)
3163{ 2991{
@@ -3231,8 +3059,6 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
3231 } 3059 }
3232 return 0; 3060 return 0;
3233} 3061}
3234#endif /* CONFIG_IWL4965_HT */
3235
3236 3062
3237static u16 iwl4965_get_hcmd_size(u8 cmd_id, u16 len) 3063static u16 iwl4965_get_hcmd_size(u8 cmd_id, u16 len)
3238{ 3064{
@@ -3262,13 +3088,9 @@ static u16 iwl4965_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
3262 return (u16)sizeof(struct iwl4965_addsta_cmd); 3088 return (u16)sizeof(struct iwl4965_addsta_cmd);
3263} 3089}
3264 3090
3265#ifdef CONFIG_IWL4965_HT
3266static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) 3091static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
3267{ 3092{
3268 __le32 *scd_ssn = (__le32 *)((u32 *)&tx_resp->status + 3093 return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN;
3269 tx_resp->frame_count);
3270 return le32_to_cpu(*scd_ssn) & MAX_SN;
3271
3272} 3094}
3273 3095
3274/** 3096/**
@@ -3276,32 +3098,29 @@ static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp)
3276 */ 3098 */
3277static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, 3099static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3278 struct iwl_ht_agg *agg, 3100 struct iwl_ht_agg *agg,
3279 struct iwl4965_tx_resp_agg *tx_resp, 3101 struct iwl4965_tx_resp *tx_resp,
3280 u16 start_idx) 3102 int txq_id, u16 start_idx)
3281{ 3103{
3282 u16 status; 3104 u16 status;
3283 struct agg_tx_status *frame_status = &tx_resp->status; 3105 struct agg_tx_status *frame_status = tx_resp->u.agg_status;
3284 struct ieee80211_tx_info *info = NULL; 3106 struct ieee80211_tx_info *info = NULL;
3285 struct ieee80211_hdr *hdr = NULL; 3107 struct ieee80211_hdr *hdr = NULL;
3286 int i, sh; 3108 u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
3287 int txq_id, idx; 3109 int i, sh, idx;
3288 u16 seq; 3110 u16 seq;
3289
3290 if (agg->wait_for_ba) 3111 if (agg->wait_for_ba)
3291 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); 3112 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n");
3292 3113
3293 agg->frame_count = tx_resp->frame_count; 3114 agg->frame_count = tx_resp->frame_count;
3294 agg->start_idx = start_idx; 3115 agg->start_idx = start_idx;
3295 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); 3116 agg->rate_n_flags = rate_n_flags;
3296 agg->bitmap = 0; 3117 agg->bitmap = 0;
3297 3118
3298 /* # frames attempted by Tx command */ 3119 /* # frames attempted by Tx command */
3299 if (agg->frame_count == 1) { 3120 if (agg->frame_count == 1) {
3300 /* Only one frame was attempted; no block-ack will arrive */ 3121 /* Only one frame was attempted; no block-ack will arrive */
3301 status = le16_to_cpu(frame_status[0].status); 3122 status = le16_to_cpu(frame_status[0].status);
3302 seq = le16_to_cpu(frame_status[0].sequence); 3123 idx = start_idx;
3303 idx = SEQ_TO_INDEX(seq);
3304 txq_id = SEQ_TO_QUEUE(seq);
3305 3124
3306 /* FIXME: code repetition */ 3125 /* FIXME: code repetition */
3307 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", 3126 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n",
@@ -3312,15 +3131,12 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3312 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 3131 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
3313 info->flags |= iwl_is_tx_success(status)? 3132 info->flags |= iwl_is_tx_success(status)?
3314 IEEE80211_TX_STAT_ACK : 0; 3133 IEEE80211_TX_STAT_ACK : 0;
3315 iwl4965_hwrate_to_tx_control(priv, 3134 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
3316 le32_to_cpu(tx_resp->rate_n_flags),
3317 info);
3318 /* FIXME: code repetition end */ 3135 /* FIXME: code repetition end */
3319 3136
3320 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 3137 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n",
3321 status & 0xff, tx_resp->failure_frame); 3138 status & 0xff, tx_resp->failure_frame);
3322 IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", 3139 IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags);
3323 iwl4965_hw_get_rate_n_flags(tx_resp->rate_n_flags));
3324 3140
3325 agg->wait_for_ba = 0; 3141 agg->wait_for_ba = 0;
3326 } else { 3142 } else {
@@ -3378,7 +3194,6 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3378 3194
3379 agg->bitmap = bitmap; 3195 agg->bitmap = bitmap;
3380 agg->start_idx = start; 3196 agg->start_idx = start;
3381 agg->rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags);
3382 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", 3197 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n",
3383 agg->frame_count, agg->start_idx, 3198 agg->frame_count, agg->start_idx,
3384 (unsigned long long)agg->bitmap); 3199 (unsigned long long)agg->bitmap);
@@ -3388,7 +3203,6 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
3388 } 3203 }
3389 return 0; 3204 return 0;
3390} 3205}
3391#endif
3392 3206
3393/** 3207/**
3394 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response 3208 * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response
@@ -3403,13 +3217,11 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3403 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 3217 struct iwl_tx_queue *txq = &priv->txq[txq_id];
3404 struct ieee80211_tx_info *info; 3218 struct ieee80211_tx_info *info;
3405 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; 3219 struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
3406 u32 status = le32_to_cpu(tx_resp->status); 3220 u32 status = le32_to_cpu(tx_resp->u.status);
3407#ifdef CONFIG_IWL4965_HT
3408 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION; 3221 int tid = MAX_TID_COUNT, sta_id = IWL_INVALID_STATION;
3409 u16 fc; 3222 __le16 fc;
3410 struct ieee80211_hdr *hdr; 3223 struct ieee80211_hdr *hdr;
3411 u8 *qc = NULL; 3224 u8 *qc = NULL;
3412#endif
3413 3225
3414 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) { 3226 if ((index >= txq->q.n_bd) || (iwl_queue_used(&txq->q, index) == 0)) {
3415 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " 3227 IWL_ERROR("Read index for DMA queue txq_id (%d) index %d "
@@ -3422,11 +3234,10 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3422 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]); 3234 info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb[0]);
3423 memset(&info->status, 0, sizeof(info->status)); 3235 memset(&info->status, 0, sizeof(info->status));
3424 3236
3425#ifdef CONFIG_IWL4965_HT
3426 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index); 3237 hdr = iwl_tx_queue_get_hdr(priv, txq_id, index);
3427 fc = le16_to_cpu(hdr->frame_control); 3238 fc = hdr->frame_control;
3428 if (ieee80211_is_qos_data(fc)) { 3239 if (ieee80211_is_data_qos(fc)) {
3429 qc = ieee80211_get_qos_ctrl(hdr, ieee80211_get_hdrlen(fc)); 3240 qc = ieee80211_get_qos_ctl(hdr);
3430 tid = qc[0] & 0xf; 3241 tid = qc[0] & 0xf;
3431 } 3242 }
3432 3243
@@ -3445,8 +3256,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3445 3256
3446 agg = &priv->stations[sta_id].tid[tid].agg; 3257 agg = &priv->stations[sta_id].tid[tid].agg;
3447 3258
3448 iwl4965_tx_status_reply_tx(priv, agg, 3259 iwl4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
3449 (struct iwl4965_tx_resp_agg *)tx_resp, index);
3450 3260
3451 if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) { 3261 if ((tx_resp->frame_count == 1) && !iwl_is_tx_success(status)) {
3452 /* TODO: send BAR */ 3262 /* TODO: send BAR */
@@ -3464,7 +3274,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3464 txq_id >= 0 && priv->mac80211_registered && 3274 txq_id >= 0 && priv->mac80211_registered &&
3465 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) { 3275 agg->state != IWL_EMPTYING_HW_QUEUE_DELBA) {
3466 /* calculate mac80211 ampdu sw queue to wake */ 3276 /* calculate mac80211 ampdu sw queue to wake */
3467 ampdu_q = txq_id - IWL_BACK_QUEUE_FIRST_ID + 3277 ampdu_q = txq_id - IWL49_FIRST_AMPDU_QUEUE +
3468 priv->hw->queues; 3278 priv->hw->queues;
3469 if (agg->state == IWL_AGG_OFF) 3279 if (agg->state == IWL_AGG_OFF)
3470 ieee80211_wake_queue(priv->hw, txq_id); 3280 ieee80211_wake_queue(priv->hw, txq_id);
@@ -3474,32 +3284,32 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
3474 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 3284 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
3475 } 3285 }
3476 } else { 3286 } else {
3477#endif /* CONFIG_IWL4965_HT */ 3287 info->status.retry_count = tx_resp->failure_frame;
3478 3288 info->flags |=
3479 info->status.retry_count = tx_resp->failure_frame; 3289 iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0;
3480 info->flags |= iwl_is_tx_success(status) ? IEEE80211_TX_STAT_ACK : 0; 3290 iwl_hwrate_to_tx_control(priv,
3481 iwl4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), 3291 le32_to_cpu(tx_resp->rate_n_flags),
3482 info); 3292 info);
3483 3293
3484 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags 0x%x " 3294 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) rate_n_flags "
3485 "retries %d\n", txq_id, iwl_get_tx_fail_reason(status), 3295 "0x%x retries %d\n", txq_id,
3486 status, le32_to_cpu(tx_resp->rate_n_flags), 3296 iwl_get_tx_fail_reason(status),
3487 tx_resp->failure_frame); 3297 status, le32_to_cpu(tx_resp->rate_n_flags),
3488 3298 tx_resp->failure_frame);
3489 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 3299
3490#ifdef CONFIG_IWL4965_HT 3300 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index);
3491 if (index != -1) { 3301
3492 int freed = iwl_tx_queue_reclaim(priv, txq_id, index); 3302 if (index != -1) {
3493 if (tid != MAX_TID_COUNT) 3303 int freed = iwl_tx_queue_reclaim(priv, txq_id, index);
3304 if (tid != MAX_TID_COUNT)
3494 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 3305 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
3495 if (iwl_queue_space(&txq->q) > txq->q.low_mark && 3306 if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
3496 (txq_id >= 0) && priv->mac80211_registered) 3307 (txq_id >= 0) && priv->mac80211_registered)
3497 ieee80211_wake_queue(priv->hw, txq_id); 3308 ieee80211_wake_queue(priv->hw, txq_id);
3498 if (tid != MAX_TID_COUNT) 3309 if (tid != MAX_TID_COUNT)
3499 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 3310 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
3311 }
3500 } 3312 }
3501 }
3502#endif /* CONFIG_IWL4965_HT */
3503 3313
3504 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 3314 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
3505 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n"); 3315 IWL_ERROR("TODO: Implement Tx ABORT REQUIRED!!!\n");
@@ -3513,28 +3323,18 @@ static void iwl4965_rx_handler_setup(struct iwl_priv *priv)
3513 priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx; 3323 priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx;
3514 /* Tx response */ 3324 /* Tx response */
3515 priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; 3325 priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx;
3516 3326 /* block ack */
3517#ifdef CONFIG_IWL4965_HT
3518 priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba; 3327 priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba;
3519#endif /* CONFIG_IWL4965_HT */
3520} 3328}
3521 3329
3522void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv) 3330static void iwl4965_setup_deferred_work(struct iwl_priv *priv)
3523{ 3331{
3524 INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work); 3332 INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work);
3525#ifdef CONFIG_IWL4965_RUN_TIME_CALIB
3526 INIT_WORK(&priv->sensitivity_work, iwl4965_bg_sensitivity_work);
3527#endif
3528 init_timer(&priv->statistics_periodic);
3529 priv->statistics_periodic.data = (unsigned long)priv;
3530 priv->statistics_periodic.function = iwl4965_bg_statistics_periodic;
3531} 3333}
3532 3334
3533void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv) 3335static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
3534{ 3336{
3535 del_timer_sync(&priv->statistics_periodic); 3337 cancel_work_sync(&priv->txpower_work);
3536
3537 cancel_delayed_work(&priv->init_alive_start);
3538} 3338}
3539 3339
3540 3340
@@ -3545,10 +3345,8 @@ static struct iwl_hcmd_ops iwl4965_hcmd = {
3545static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { 3345static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
3546 .get_hcmd_size = iwl4965_get_hcmd_size, 3346 .get_hcmd_size = iwl4965_get_hcmd_size,
3547 .build_addsta_hcmd = iwl4965_build_addsta_hcmd, 3347 .build_addsta_hcmd = iwl4965_build_addsta_hcmd,
3548#ifdef CONFIG_IWL4965_RUN_TIME_CALIB
3549 .chain_noise_reset = iwl4965_chain_noise_reset, 3348 .chain_noise_reset = iwl4965_chain_noise_reset,
3550 .gain_computation = iwl4965_gain_computation, 3349 .gain_computation = iwl4965_gain_computation,
3551#endif
3552}; 3350};
3553 3351
3554static struct iwl_lib_ops iwl4965_lib = { 3352static struct iwl_lib_ops iwl4965_lib = {
@@ -3558,11 +3356,11 @@ static struct iwl_lib_ops iwl4965_lib = {
3558 .shared_mem_rx_idx = iwl4965_shared_mem_rx_idx, 3356 .shared_mem_rx_idx = iwl4965_shared_mem_rx_idx,
3559 .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, 3357 .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl,
3560 .txq_set_sched = iwl4965_txq_set_sched, 3358 .txq_set_sched = iwl4965_txq_set_sched,
3561#ifdef CONFIG_IWL4965_HT
3562 .txq_agg_enable = iwl4965_txq_agg_enable, 3359 .txq_agg_enable = iwl4965_txq_agg_enable,
3563 .txq_agg_disable = iwl4965_txq_agg_disable, 3360 .txq_agg_disable = iwl4965_txq_agg_disable,
3564#endif
3565 .rx_handler_setup = iwl4965_rx_handler_setup, 3361 .rx_handler_setup = iwl4965_rx_handler_setup,
3362 .setup_deferred_work = iwl4965_setup_deferred_work,
3363 .cancel_deferred_work = iwl4965_cancel_deferred_work,
3566 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, 3364 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr,
3567 .alive_notify = iwl4965_alive_notify, 3365 .alive_notify = iwl4965_alive_notify,
3568 .init_alive_start = iwl4965_init_alive_start, 3366 .init_alive_start = iwl4965_init_alive_start,
@@ -3590,8 +3388,8 @@ static struct iwl_lib_ops iwl4965_lib = {
3590 .check_version = iwl4965_eeprom_check_version, 3388 .check_version = iwl4965_eeprom_check_version,
3591 .query_addr = iwlcore_eeprom_query_addr, 3389 .query_addr = iwlcore_eeprom_query_addr,
3592 }, 3390 },
3593 .radio_kill_sw = iwl4965_radio_kill_sw,
3594 .set_power = iwl4965_set_power, 3391 .set_power = iwl4965_set_power,
3392 .send_tx_power = iwl4965_send_tx_power,
3595 .update_chain_flags = iwl4965_update_chain_flags, 3393 .update_chain_flags = iwl4965_update_chain_flags,
3596}; 3394};
3597 3395