aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-2000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c104
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c35
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h17
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c43
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c13
14 files changed, 109 insertions, 151 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 7795855ff8fe..2f56b343e869 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -188,7 +188,6 @@ static struct iwl_lib_ops iwl1000_lib = {
188 188
189static const struct iwl_ops iwl1000_ops = { 189static const struct iwl_ops iwl1000_ops = {
190 .lib = &iwl1000_lib, 190 .lib = &iwl1000_lib,
191 .utils = &iwlagn_hcmd_utils,
192}; 191};
193 192
194static struct iwl_base_params iwl1000_base_params = { 193static struct iwl_base_params iwl1000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
index 21b68b2839c9..32ac8654b79a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
@@ -210,22 +210,18 @@ static struct iwl_lib_ops iwl2030_lib = {
210 210
211static const struct iwl_ops iwl2000_ops = { 211static const struct iwl_ops iwl2000_ops = {
212 .lib = &iwl2000_lib, 212 .lib = &iwl2000_lib,
213 .utils = &iwlagn_hcmd_utils,
214}; 213};
215 214
216static const struct iwl_ops iwl2030_ops = { 215static const struct iwl_ops iwl2030_ops = {
217 .lib = &iwl2030_lib, 216 .lib = &iwl2030_lib,
218 .utils = &iwlagn_hcmd_utils,
219}; 217};
220 218
221static const struct iwl_ops iwl105_ops = { 219static const struct iwl_ops iwl105_ops = {
222 .lib = &iwl2000_lib, 220 .lib = &iwl2000_lib,
223 .utils = &iwlagn_hcmd_utils,
224}; 221};
225 222
226static const struct iwl_ops iwl135_ops = { 223static const struct iwl_ops iwl135_ops = {
227 .lib = &iwl2030_lib, 224 .lib = &iwl2030_lib,
228 .utils = &iwlagn_hcmd_utils,
229}; 225};
230 226
231static struct iwl_base_params iwl2000_base_params = { 227static struct iwl_base_params iwl2000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 30c2df6ec83a..556489302da3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -362,12 +362,10 @@ static struct iwl_lib_ops iwl5150_lib = {
362 362
363static const struct iwl_ops iwl5000_ops = { 363static const struct iwl_ops iwl5000_ops = {
364 .lib = &iwl5000_lib, 364 .lib = &iwl5000_lib,
365 .utils = &iwlagn_hcmd_utils,
366}; 365};
367 366
368static const struct iwl_ops iwl5150_ops = { 367static const struct iwl_ops iwl5150_ops = {
369 .lib = &iwl5150_lib, 368 .lib = &iwl5150_lib,
370 .utils = &iwlagn_hcmd_utils,
371}; 369};
372 370
373static struct iwl_base_params iwl5000_base_params = { 371static struct iwl_base_params iwl5000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 57f31692894f..80f1ef61a3d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -313,24 +313,20 @@ static struct iwl_nic_ops iwl6150_nic_ops = {
313 313
314static const struct iwl_ops iwl6000_ops = { 314static const struct iwl_ops iwl6000_ops = {
315 .lib = &iwl6000_lib, 315 .lib = &iwl6000_lib,
316 .utils = &iwlagn_hcmd_utils,
317}; 316};
318 317
319static const struct iwl_ops iwl6050_ops = { 318static const struct iwl_ops iwl6050_ops = {
320 .lib = &iwl6000_lib, 319 .lib = &iwl6000_lib,
321 .utils = &iwlagn_hcmd_utils,
322 .nic = &iwl6050_nic_ops, 320 .nic = &iwl6050_nic_ops,
323}; 321};
324 322
325static const struct iwl_ops iwl6150_ops = { 323static const struct iwl_ops iwl6150_ops = {
326 .lib = &iwl6000_lib, 324 .lib = &iwl6000_lib,
327 .utils = &iwlagn_hcmd_utils,
328 .nic = &iwl6150_nic_ops, 325 .nic = &iwl6150_nic_ops,
329}; 326};
330 327
331static const struct iwl_ops iwl6030_ops = { 328static const struct iwl_ops iwl6030_ops = {
332 .lib = &iwl6030_lib, 329 .lib = &iwl6030_lib,
333 .utils = &iwlagn_hcmd_utils,
334}; 330};
335 331
336static struct iwl_base_params iwl6000_base_params = { 332static struct iwl_base_params iwl6000_base_params = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 710ada9c4132..02c7c65ee86a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -67,6 +67,7 @@
67#include "iwl-core.h" 67#include "iwl-core.h"
68#include "iwl-agn-calib.h" 68#include "iwl-agn-calib.h"
69#include "iwl-trans.h" 69#include "iwl-trans.h"
70#include "iwl-agn.h"
70 71
71/***************************************************************************** 72/*****************************************************************************
72 * INIT calibrations framework 73 * INIT calibrations framework
@@ -993,8 +994,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
993 IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", 994 IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n",
994 min_average_noise, min_average_noise_antenna_i); 995 min_average_noise, min_average_noise_antenna_i);
995 996
996 if (priv->cfg->ops->utils->gain_computation) 997 iwlagn_gain_computation(priv, average_noise,
997 priv->cfg->ops->utils->gain_computation(priv, average_noise,
998 min_average_noise_antenna_i, min_average_noise, 998 min_average_noise_antenna_i, min_average_noise,
999 find_first_chain(priv->cfg->valid_rx_ant)); 999 find_first_chain(priv->cfg->valid_rx_ant));
1000 1000
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
index 4ef4dd934254..a869fc9205d2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
@@ -71,13 +71,6 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv);
71 71
72void iwl_init_sensitivity(struct iwl_priv *priv); 72void iwl_init_sensitivity(struct iwl_priv *priv);
73void iwl_reset_run_time_calib(struct iwl_priv *priv); 73void iwl_reset_run_time_calib(struct iwl_priv *priv);
74static inline void iwl_chain_noise_reset(struct iwl_priv *priv)
75{
76
77 if (!priv->disable_chain_noise_cal &&
78 priv->cfg->ops->utils->chain_noise_reset)
79 priv->cfg->ops->utils->chain_noise_reset(priv);
80}
81 74
82int iwl_send_calib_results(struct iwl_priv *priv); 75int iwl_send_calib_results(struct iwl_priv *priv);
83int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len); 76int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index 4d7674c0c721..f0f5f5eada75 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -57,17 +57,7 @@ int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
57 } 57 }
58} 58}
59 59
60static u16 iwlagn_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) 60void iwlagn_gain_computation(struct iwl_priv *priv,
61{
62 u16 size = (u16)sizeof(struct iwl_addsta_cmd);
63 struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data;
64 memcpy(addsta, cmd, size);
65 /* resrved in 5000 */
66 addsta->rate_n_flags = cpu_to_le16(0);
67 return size;
68}
69
70static void iwlagn_gain_computation(struct iwl_priv *priv,
71 u32 average_noise[NUM_RX_CHAINS], 61 u32 average_noise[NUM_RX_CHAINS],
72 u16 min_average_noise_antenna_i, 62 u16 min_average_noise_antenna_i,
73 u32 min_average_noise, 63 u32 min_average_noise,
@@ -126,89 +116,6 @@ static void iwlagn_gain_computation(struct iwl_priv *priv,
126 } 116 }
127} 117}
128 118
129static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
130{
131 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
132 int ret;
133
134 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
135 iwl_is_any_associated(priv)) {
136 struct iwl_calib_chain_noise_reset_cmd cmd;
137
138 /* clear data for chain noise calibration algorithm */
139 data->chain_noise_a = 0;
140 data->chain_noise_b = 0;
141 data->chain_noise_c = 0;
142 data->chain_signal_a = 0;
143 data->chain_signal_b = 0;
144 data->chain_signal_c = 0;
145 data->beacon_count = 0;
146
147 memset(&cmd, 0, sizeof(cmd));
148 iwl_set_calib_hdr(&cmd.hdr,
149 priv->_agn.phy_calib_chain_noise_reset_cmd);
150 ret = trans_send_cmd_pdu(priv,
151 REPLY_PHY_CALIBRATION_CMD,
152 CMD_SYNC, sizeof(cmd), &cmd);
153 if (ret)
154 IWL_ERR(priv,
155 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
156 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
157 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
158 }
159}
160
161static void iwlagn_tx_cmd_protection(struct iwl_priv *priv,
162 struct ieee80211_tx_info *info,
163 __le16 fc, __le32 *tx_flags)
164{
165 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS ||
166 info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT ||
167 info->flags & IEEE80211_TX_CTL_AMPDU)
168 *tx_flags |= TX_CMD_FLG_PROT_REQUIRE_MSK;
169}
170
171/* Calc max signal level (dBm) among 3 possible receivers */
172static int iwlagn_calc_rssi(struct iwl_priv *priv,
173 struct iwl_rx_phy_res *rx_resp)
174{
175 /* data from PHY/DSP regarding signal strength, etc.,
176 * contents are always there, not configurable by host
177 */
178 struct iwlagn_non_cfg_phy *ncphy =
179 (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
180 u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
181 u8 agc;
182
183 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]);
184 agc = (val & IWLAGN_OFDM_AGC_MSK) >> IWLAGN_OFDM_AGC_BIT_POS;
185
186 /* Find max rssi among 3 possible receivers.
187 * These values are measured by the digital signal processor (DSP).
188 * They should stay fairly constant even as the signal strength varies,
189 * if the radio's automatic gain control (AGC) is working right.
190 * AGC value (see below) will provide the "interesting" info.
191 */
192 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]);
193 rssi_a = (val & IWLAGN_OFDM_RSSI_INBAND_A_BITMSK) >>
194 IWLAGN_OFDM_RSSI_A_BIT_POS;
195 rssi_b = (val & IWLAGN_OFDM_RSSI_INBAND_B_BITMSK) >>
196 IWLAGN_OFDM_RSSI_B_BIT_POS;
197 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]);
198 rssi_c = (val & IWLAGN_OFDM_RSSI_INBAND_C_BITMSK) >>
199 IWLAGN_OFDM_RSSI_C_BIT_POS;
200
201 max_rssi = max_t(u32, rssi_a, rssi_b);
202 max_rssi = max_t(u32, max_rssi, rssi_c);
203
204 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
205 rssi_a, rssi_b, rssi_c, max_rssi, agc);
206
207 /* dBm = max_rssi dB - agc dB - constant.
208 * Higher AGC (higher radio gain) means lower signal. */
209 return max_rssi - agc - IWLAGN_RSSI_OFFSET;
210}
211
212int iwlagn_set_pan_params(struct iwl_priv *priv) 119int iwlagn_set_pan_params(struct iwl_priv *priv)
213{ 120{
214 struct iwl_wipan_params_cmd cmd; 121 struct iwl_wipan_params_cmd cmd;
@@ -301,12 +208,3 @@ int iwlagn_set_pan_params(struct iwl_priv *priv)
301 208
302 return ret; 209 return ret;
303} 210}
304
305struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = {
306 .build_addsta_hcmd = iwlagn_build_addsta_hcmd,
307 .gain_computation = iwlagn_gain_computation,
308 .chain_noise_reset = iwlagn_chain_noise_reset,
309 .tx_cmd_protection = iwlagn_tx_cmd_protection,
310 .calc_rssi = iwlagn_calc_rssi,
311 .request_scan = iwlagn_request_scan,
312};
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index fca376e91541..dc64f2515357 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -674,6 +674,38 @@ static void iwlagn_check_needed_chains(struct iwl_priv *priv,
674 ht_conf->single_chain_sufficient = !need_multiple; 674 ht_conf->single_chain_sufficient = !need_multiple;
675} 675}
676 676
677static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
678{
679 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
680 int ret;
681
682 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
683 iwl_is_any_associated(priv)) {
684 struct iwl_calib_chain_noise_reset_cmd cmd;
685
686 /* clear data for chain noise calibration algorithm */
687 data->chain_noise_a = 0;
688 data->chain_noise_b = 0;
689 data->chain_noise_c = 0;
690 data->chain_signal_a = 0;
691 data->chain_signal_b = 0;
692 data->chain_signal_c = 0;
693 data->beacon_count = 0;
694
695 memset(&cmd, 0, sizeof(cmd));
696 iwl_set_calib_hdr(&cmd.hdr,
697 priv->_agn.phy_calib_chain_noise_reset_cmd);
698 ret = trans_send_cmd_pdu(priv,
699 REPLY_PHY_CALIBRATION_CMD,
700 CMD_SYNC, sizeof(cmd), &cmd);
701 if (ret)
702 IWL_ERR(priv,
703 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
704 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
705 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
706 }
707}
708
677void iwlagn_bss_info_changed(struct ieee80211_hw *hw, 709void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
678 struct ieee80211_vif *vif, 710 struct ieee80211_vif *vif,
679 struct ieee80211_bss_conf *bss_conf, 711 struct ieee80211_bss_conf *bss_conf,
@@ -782,7 +814,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
782 iwl_power_update_mode(priv, false); 814 iwl_power_update_mode(priv, false);
783 815
784 /* Enable RX differential gain and sensitivity calibrations */ 816 /* Enable RX differential gain and sensitivity calibrations */
785 iwl_chain_noise_reset(priv); 817 if (!priv->disable_chain_noise_cal)
818 iwlagn_chain_noise_reset(priv);
786 priv->start_calib = 1; 819 priv->start_calib = 1;
787 } 820 }
788 821
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 07c1242599f7..7d3aad83e0d6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -339,6 +339,16 @@ void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask)
339 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask); 339 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask);
340} 340}
341 341
342static void iwlagn_tx_cmd_protection(struct iwl_priv *priv,
343 struct ieee80211_tx_info *info,
344 __le16 fc, __le32 *tx_flags)
345{
346 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS ||
347 info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT ||
348 info->flags & IEEE80211_TX_CTL_AMPDU)
349 *tx_flags |= TX_CMD_FLG_PROT_REQUIRE_MSK;
350}
351
342/* 352/*
343 * handle build REPLY_TX command notification. 353 * handle build REPLY_TX command notification.
344 */ 354 */
@@ -388,7 +398,7 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
388 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; 398 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
389 } 399 }
390 400
391 priv->cfg->ops->utils->tx_cmd_protection(priv, info, fc, &tx_flags); 401 iwlagn_tx_cmd_protection(priv, info, fc, &tx_flags);
392 402
393 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); 403 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK);
394 if (ieee80211_is_mgmt(fc)) { 404 if (ieee80211_is_mgmt(fc)) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 81a009bdd67b..5f58b44bb2a0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -109,9 +109,6 @@ extern struct iwl_cfg iwl135_bg_cfg;
109extern struct iwl_cfg iwl135_bgn_cfg; 109extern struct iwl_cfg iwl135_bgn_cfg;
110 110
111extern struct iwl_mod_params iwlagn_mod_params; 111extern struct iwl_mod_params iwlagn_mod_params;
112extern struct iwl_hcmd_ops iwlagn_hcmd;
113extern struct iwl_hcmd_ops iwlagn_bt_hcmd;
114extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils;
115 112
116extern struct ieee80211_ops iwlagn_hw_ops; 113extern struct ieee80211_ops iwlagn_hw_ops;
117 114
@@ -253,6 +250,12 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv,
253int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant); 250int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant);
254int iwlagn_send_beacon_cmd(struct iwl_priv *priv); 251int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
255int iwlagn_set_pan_params(struct iwl_priv *priv); 252int iwlagn_set_pan_params(struct iwl_priv *priv);
253void iwlagn_gain_computation(struct iwl_priv *priv,
254 u32 average_noise[NUM_RX_CHAINS],
255 u16 min_average_noise_antenna_i,
256 u32 min_average_noise,
257 u8 default_chain);
258
256 259
257/* bt coex */ 260/* bt coex */
258void iwlagn_send_advance_bt_config(struct iwl_priv *priv); 261void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 2e3ea55cea77..692c30cb2fac 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -80,22 +80,6 @@ struct iwl_cmd;
80 80
81#define IWL_CMD(x) case x: return #x 81#define IWL_CMD(x) case x: return #x
82 82
83struct iwl_hcmd_utils_ops {
84 u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data);
85 void (*gain_computation)(struct iwl_priv *priv,
86 u32 *average_noise,
87 u16 min_average_noise_antennat_i,
88 u32 min_average_noise,
89 u8 default_chain);
90 void (*chain_noise_reset)(struct iwl_priv *priv);
91 void (*tx_cmd_protection)(struct iwl_priv *priv,
92 struct ieee80211_tx_info *info,
93 __le16 fc, __le32 *tx_flags);
94 int (*calc_rssi)(struct iwl_priv *priv,
95 struct iwl_rx_phy_res *rx_resp);
96 int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif);
97};
98
99struct iwl_lib_ops { 83struct iwl_lib_ops {
100 /* set hw dependent parameters */ 84 /* set hw dependent parameters */
101 int (*set_hw_params)(struct iwl_priv *priv); 85 int (*set_hw_params)(struct iwl_priv *priv);
@@ -126,7 +110,6 @@ struct iwl_nic_ops {
126 110
127struct iwl_ops { 111struct iwl_ops {
128 const struct iwl_lib_ops *lib; 112 const struct iwl_lib_ops *lib;
129 const struct iwl_hcmd_utils_ops *utils;
130 const struct iwl_nic_ops *nic; 113 const struct iwl_nic_ops *nic;
131}; 114};
132 115
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 1690b49bb136..f3f3efe38ce2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -902,6 +902,47 @@ static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
902 return decrypt_out; 902 return decrypt_out;
903} 903}
904 904
905/* Calc max signal level (dBm) among 3 possible receivers */
906static int iwlagn_calc_rssi(struct iwl_priv *priv,
907 struct iwl_rx_phy_res *rx_resp)
908{
909 /* data from PHY/DSP regarding signal strength, etc.,
910 * contents are always there, not configurable by host
911 */
912 struct iwlagn_non_cfg_phy *ncphy =
913 (struct iwlagn_non_cfg_phy *)rx_resp->non_cfg_phy_buf;
914 u32 val, rssi_a, rssi_b, rssi_c, max_rssi;
915 u8 agc;
916
917 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_AGC_IDX]);
918 agc = (val & IWLAGN_OFDM_AGC_MSK) >> IWLAGN_OFDM_AGC_BIT_POS;
919
920 /* Find max rssi among 3 possible receivers.
921 * These values are measured by the digital signal processor (DSP).
922 * They should stay fairly constant even as the signal strength varies,
923 * if the radio's automatic gain control (AGC) is working right.
924 * AGC value (see below) will provide the "interesting" info.
925 */
926 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_AB_IDX]);
927 rssi_a = (val & IWLAGN_OFDM_RSSI_INBAND_A_BITMSK) >>
928 IWLAGN_OFDM_RSSI_A_BIT_POS;
929 rssi_b = (val & IWLAGN_OFDM_RSSI_INBAND_B_BITMSK) >>
930 IWLAGN_OFDM_RSSI_B_BIT_POS;
931 val = le32_to_cpu(ncphy->non_cfg_phy[IWLAGN_RX_RES_RSSI_C_IDX]);
932 rssi_c = (val & IWLAGN_OFDM_RSSI_INBAND_C_BITMSK) >>
933 IWLAGN_OFDM_RSSI_C_BIT_POS;
934
935 max_rssi = max_t(u32, rssi_a, rssi_b);
936 max_rssi = max_t(u32, max_rssi, rssi_c);
937
938 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
939 rssi_a, rssi_b, rssi_c, max_rssi, agc);
940
941 /* dBm = max_rssi dB - agc dB - constant.
942 * Higher AGC (higher radio gain) means lower signal. */
943 return max_rssi - agc - IWLAGN_RSSI_OFFSET;
944}
945
905/* Called for REPLY_RX (legacy ABG frames), or 946/* Called for REPLY_RX (legacy ABG frames), or
906 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ 947 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
907static void iwl_rx_reply_rx(struct iwl_priv *priv, 948static void iwl_rx_reply_rx(struct iwl_priv *priv,
@@ -983,7 +1024,7 @@ static void iwl_rx_reply_rx(struct iwl_priv *priv,
983 priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); 1024 priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp);
984 1025
985 /* Find max signal strength (dBm) among 3 antenna/receiver chains */ 1026 /* Find max signal strength (dBm) among 3 antenna/receiver chains */
986 rx_status.signal = priv->cfg->ops->utils->calc_rssi(priv, phy_res); 1027 rx_status.signal = iwlagn_calc_rssi(priv, phy_res);
987 1028
988 iwl_dbg_log_rx_data_frame(priv, len, header); 1029 iwl_dbg_log_rx_data_frame(priv, len, header);
989 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", 1030 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 077d023ab7ea..f6ebe29eb790 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -350,9 +350,6 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
350 350
351 lockdep_assert_held(&priv->mutex); 351 lockdep_assert_held(&priv->mutex);
352 352
353 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
354 return -EOPNOTSUPP;
355
356 cancel_delayed_work(&priv->scan_check); 353 cancel_delayed_work(&priv->scan_check);
357 354
358 if (!iwl_is_ready_rf(priv)) { 355 if (!iwl_is_ready_rf(priv)) {
@@ -381,7 +378,7 @@ int __must_check iwl_scan_initiate(struct iwl_priv *priv,
381 priv->scan_start = jiffies; 378 priv->scan_start = jiffies;
382 priv->scan_band = band; 379 priv->scan_band = band;
383 380
384 ret = priv->cfg->ops->utils->request_scan(priv, vif); 381 ret = iwlagn_request_scan(priv, vif);
385 if (ret) { 382 if (ret) {
386 clear_bit(STATUS_SCANNING, &priv->status); 383 clear_bit(STATUS_SCANNING, &priv->status);
387 priv->scan_type = IWL_SCAN_NORMAL; 384 priv->scan_type = IWL_SCAN_NORMAL;
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 78cf1076c032..65386e575b1c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -36,6 +36,7 @@
36#include "iwl-core.h" 36#include "iwl-core.h"
37#include "iwl-sta.h" 37#include "iwl-sta.h"
38#include "iwl-trans.h" 38#include "iwl-trans.h"
39#include "iwl-agn.h"
39 40
40/* priv->sta_lock must be held */ 41/* priv->sta_lock must be held */
41static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) 42static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
@@ -133,6 +134,16 @@ static void iwl_add_sta_callback(struct iwl_priv *priv,
133 134
134} 135}
135 136
137static u16 iwlagn_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
138{
139 u16 size = (u16)sizeof(struct iwl_addsta_cmd);
140 struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data;
141 memcpy(addsta, cmd, size);
142 /* resrved in 5000 */
143 addsta->rate_n_flags = cpu_to_le16(0);
144 return size;
145}
146
136int iwl_send_add_sta(struct iwl_priv *priv, 147int iwl_send_add_sta(struct iwl_priv *priv,
137 struct iwl_addsta_cmd *sta, u8 flags) 148 struct iwl_addsta_cmd *sta, u8 flags)
138{ 149{
@@ -156,7 +167,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
156 might_sleep(); 167 might_sleep();
157 } 168 }
158 169
159 cmd.len[0] = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); 170 cmd.len[0] = iwlagn_build_addsta_hcmd(sta, data);
160 ret = trans_send_cmd(priv, &cmd); 171 ret = trans_send_cmd(priv, &cmd);
161 172
162 if (ret || (flags & CMD_ASYNC)) 173 if (ret || (flags & CMD_ASYNC))