aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c59
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c210
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c93
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h13
6 files changed, 174 insertions, 222 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 19150398a24..2433389f8df 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -8,7 +8,7 @@ iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o
8iwlagn-objs += iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o 8iwlagn-objs += iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o
9iwlagn-objs += iwl-rx.o iwl-tx.o iwl-sta.o 9iwlagn-objs += iwl-rx.o iwl-tx.o iwl-sta.o
10iwlagn-objs += iwl-scan.o iwl-led.o 10iwlagn-objs += iwl-scan.o iwl-led.o
11iwlagn-objs += iwl-agn-rxon.o iwl-agn-hcmd.o iwl-agn-ict.o 11iwlagn-objs += iwl-agn-rxon.o iwl-agn-ict.o
12iwlagn-objs += iwl-5000.o 12iwlagn-objs += iwl-5000.o
13iwlagn-objs += iwl-6000.o 13iwlagn-objs += iwl-6000.o
14iwlagn-objs += iwl-1000.o 14iwlagn-objs += iwl-1000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 02c7c65ee86..540e66f5515 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -840,6 +840,65 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
840 active_chains); 840 active_chains);
841} 841}
842 842
843static void iwlagn_gain_computation(struct iwl_priv *priv,
844 u32 average_noise[NUM_RX_CHAINS],
845 u16 min_average_noise_antenna_i,
846 u32 min_average_noise,
847 u8 default_chain)
848{
849 int i;
850 s32 delta_g;
851 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
852
853 /*
854 * Find Gain Code for the chains based on "default chain"
855 */
856 for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) {
857 if ((data->disconn_array[i])) {
858 data->delta_gain_code[i] = 0;
859 continue;
860 }
861
862 delta_g = (priv->cfg->base_params->chain_noise_scale *
863 ((s32)average_noise[default_chain] -
864 (s32)average_noise[i])) / 1500;
865
866 /* bound gain by 2 bits value max, 3rd bit is sign */
867 data->delta_gain_code[i] =
868 min(abs(delta_g),
869 (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
870
871 if (delta_g < 0)
872 /*
873 * set negative sign ...
874 * note to Intel developers: This is uCode API format,
875 * not the format of any internal device registers.
876 * Do not change this format for e.g. 6050 or similar
877 * devices. Change format only if more resolution
878 * (i.e. more than 2 bits magnitude) is needed.
879 */
880 data->delta_gain_code[i] |= (1 << 2);
881 }
882
883 IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n",
884 data->delta_gain_code[1], data->delta_gain_code[2]);
885
886 if (!data->radio_write) {
887 struct iwl_calib_chain_noise_gain_cmd cmd;
888
889 memset(&cmd, 0, sizeof(cmd));
890
891 iwl_set_calib_hdr(&cmd.hdr,
892 priv->_agn.phy_calib_chain_noise_gain_cmd);
893 cmd.delta_gain_1 = data->delta_gain_code[1];
894 cmd.delta_gain_2 = data->delta_gain_code[2];
895 trans_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
896 CMD_ASYNC, sizeof(cmd), &cmd);
897
898 data->radio_write = 1;
899 data->state = IWL_CHAIN_NOISE_CALIBRATED;
900 }
901}
843 902
844/* 903/*
845 * Accumulate 16 beacons of signal and noise statistics for each of 904 * Accumulate 16 beacons of signal and noise statistics for each of
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
deleted file mode 100644
index f0f5f5eada7..00000000000
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/sched.h>
34
35#include "iwl-dev.h"
36#include "iwl-core.h"
37#include "iwl-io.h"
38#include "iwl-agn.h"
39#include "iwl-trans.h"
40
41int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
42{
43 struct iwl_tx_ant_config_cmd tx_ant_cmd = {
44 .valid = cpu_to_le32(valid_tx_ant),
45 };
46
47 if (IWL_UCODE_API(priv->ucode_ver) > 1) {
48 IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
49 return trans_send_cmd_pdu(priv,
50 TX_ANT_CONFIGURATION_CMD,
51 CMD_SYNC,
52 sizeof(struct iwl_tx_ant_config_cmd),
53 &tx_ant_cmd);
54 } else {
55 IWL_DEBUG_HC(priv, "TX_ANT_CONFIGURATION_CMD not supported\n");
56 return -EOPNOTSUPP;
57 }
58}
59
60void iwlagn_gain_computation(struct iwl_priv *priv,
61 u32 average_noise[NUM_RX_CHAINS],
62 u16 min_average_noise_antenna_i,
63 u32 min_average_noise,
64 u8 default_chain)
65{
66 int i;
67 s32 delta_g;
68 struct iwl_chain_noise_data *data = &priv->chain_noise_data;
69
70 /*
71 * Find Gain Code for the chains based on "default chain"
72 */
73 for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) {
74 if ((data->disconn_array[i])) {
75 data->delta_gain_code[i] = 0;
76 continue;
77 }
78
79 delta_g = (priv->cfg->base_params->chain_noise_scale *
80 ((s32)average_noise[default_chain] -
81 (s32)average_noise[i])) / 1500;
82
83 /* bound gain by 2 bits value max, 3rd bit is sign */
84 data->delta_gain_code[i] =
85 min(abs(delta_g), (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE);
86
87 if (delta_g < 0)
88 /*
89 * set negative sign ...
90 * note to Intel developers: This is uCode API format,
91 * not the format of any internal device registers.
92 * Do not change this format for e.g. 6050 or similar
93 * devices. Change format only if more resolution
94 * (i.e. more than 2 bits magnitude) is needed.
95 */
96 data->delta_gain_code[i] |= (1 << 2);
97 }
98
99 IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n",
100 data->delta_gain_code[1], data->delta_gain_code[2]);
101
102 if (!data->radio_write) {
103 struct iwl_calib_chain_noise_gain_cmd cmd;
104
105 memset(&cmd, 0, sizeof(cmd));
106
107 iwl_set_calib_hdr(&cmd.hdr,
108 priv->_agn.phy_calib_chain_noise_gain_cmd);
109 cmd.delta_gain_1 = data->delta_gain_code[1];
110 cmd.delta_gain_2 = data->delta_gain_code[2];
111 trans_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
112 CMD_ASYNC, sizeof(cmd), &cmd);
113
114 data->radio_write = 1;
115 data->state = IWL_CHAIN_NOISE_CALIBRATED;
116 }
117}
118
119int iwlagn_set_pan_params(struct iwl_priv *priv)
120{
121 struct iwl_wipan_params_cmd cmd;
122 struct iwl_rxon_context *ctx_bss, *ctx_pan;
123 int slot0 = 300, slot1 = 0;
124 int ret;
125
126 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS))
127 return 0;
128
129 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
130
131 lockdep_assert_held(&priv->mutex);
132
133 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
134 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
135
136 /*
137 * If the PAN context is inactive, then we don't need
138 * to update the PAN parameters, the last thing we'll
139 * have done before it goes inactive is making the PAN
140 * parameters be WLAN-only.
141 */
142 if (!ctx_pan->is_active)
143 return 0;
144
145 memset(&cmd, 0, sizeof(cmd));
146
147 /* only 2 slots are currently allowed */
148 cmd.num_slots = 2;
149
150 cmd.slots[0].type = 0; /* BSS */
151 cmd.slots[1].type = 1; /* PAN */
152
153 if (priv->_agn.hw_roc_channel) {
154 /* both contexts must be used for this to happen */
155 slot1 = priv->_agn.hw_roc_duration;
156 slot0 = IWL_MIN_SLOT_TIME;
157 } else if (ctx_bss->vif && ctx_pan->vif) {
158 int bcnint = ctx_pan->vif->bss_conf.beacon_int;
159 int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1;
160
161 /* should be set, but seems unused?? */
162 cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE);
163
164 if (ctx_pan->vif->type == NL80211_IFTYPE_AP &&
165 bcnint &&
166 bcnint != ctx_bss->vif->bss_conf.beacon_int) {
167 IWL_ERR(priv,
168 "beacon intervals don't match (%d, %d)\n",
169 ctx_bss->vif->bss_conf.beacon_int,
170 ctx_pan->vif->bss_conf.beacon_int);
171 } else
172 bcnint = max_t(int, bcnint,
173 ctx_bss->vif->bss_conf.beacon_int);
174 if (!bcnint)
175 bcnint = DEFAULT_BEACON_INTERVAL;
176 slot0 = bcnint / 2;
177 slot1 = bcnint - slot0;
178
179 if (test_bit(STATUS_SCAN_HW, &priv->status) ||
180 (!ctx_bss->vif->bss_conf.idle &&
181 !ctx_bss->vif->bss_conf.assoc)) {
182 slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME;
183 slot1 = IWL_MIN_SLOT_TIME;
184 } else if (!ctx_pan->vif->bss_conf.idle &&
185 !ctx_pan->vif->bss_conf.assoc) {
186 slot1 = bcnint * 3 - IWL_MIN_SLOT_TIME;
187 slot0 = IWL_MIN_SLOT_TIME;
188 }
189 } else if (ctx_pan->vif) {
190 slot0 = 0;
191 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
192 ctx_pan->vif->bss_conf.beacon_int;
193 slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1);
194
195 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
196 slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME;
197 slot1 = IWL_MIN_SLOT_TIME;
198 }
199 }
200
201 cmd.slots[0].width = cpu_to_le16(slot0);
202 cmd.slots[1].width = cpu_to_le16(slot1);
203
204 ret = trans_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC,
205 sizeof(cmd), &cmd);
206 if (ret)
207 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
208
209 return ret;
210}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index dc64f251535..53e74752d13 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -303,6 +303,99 @@ static int iwlagn_rxon_connect(struct iwl_priv *priv,
303 return 0; 303 return 0;
304} 304}
305 305
306int iwlagn_set_pan_params(struct iwl_priv *priv)
307{
308 struct iwl_wipan_params_cmd cmd;
309 struct iwl_rxon_context *ctx_bss, *ctx_pan;
310 int slot0 = 300, slot1 = 0;
311 int ret;
312
313 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS))
314 return 0;
315
316 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
317
318 lockdep_assert_held(&priv->mutex);
319
320 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
321 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
322
323 /*
324 * If the PAN context is inactive, then we don't need
325 * to update the PAN parameters, the last thing we'll
326 * have done before it goes inactive is making the PAN
327 * parameters be WLAN-only.
328 */
329 if (!ctx_pan->is_active)
330 return 0;
331
332 memset(&cmd, 0, sizeof(cmd));
333
334 /* only 2 slots are currently allowed */
335 cmd.num_slots = 2;
336
337 cmd.slots[0].type = 0; /* BSS */
338 cmd.slots[1].type = 1; /* PAN */
339
340 if (priv->_agn.hw_roc_channel) {
341 /* both contexts must be used for this to happen */
342 slot1 = priv->_agn.hw_roc_duration;
343 slot0 = IWL_MIN_SLOT_TIME;
344 } else if (ctx_bss->vif && ctx_pan->vif) {
345 int bcnint = ctx_pan->vif->bss_conf.beacon_int;
346 int dtim = ctx_pan->vif->bss_conf.dtim_period ?: 1;
347
348 /* should be set, but seems unused?? */
349 cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE);
350
351 if (ctx_pan->vif->type == NL80211_IFTYPE_AP &&
352 bcnint &&
353 bcnint != ctx_bss->vif->bss_conf.beacon_int) {
354 IWL_ERR(priv,
355 "beacon intervals don't match (%d, %d)\n",
356 ctx_bss->vif->bss_conf.beacon_int,
357 ctx_pan->vif->bss_conf.beacon_int);
358 } else
359 bcnint = max_t(int, bcnint,
360 ctx_bss->vif->bss_conf.beacon_int);
361 if (!bcnint)
362 bcnint = DEFAULT_BEACON_INTERVAL;
363 slot0 = bcnint / 2;
364 slot1 = bcnint - slot0;
365
366 if (test_bit(STATUS_SCAN_HW, &priv->status) ||
367 (!ctx_bss->vif->bss_conf.idle &&
368 !ctx_bss->vif->bss_conf.assoc)) {
369 slot0 = dtim * bcnint * 3 - IWL_MIN_SLOT_TIME;
370 slot1 = IWL_MIN_SLOT_TIME;
371 } else if (!ctx_pan->vif->bss_conf.idle &&
372 !ctx_pan->vif->bss_conf.assoc) {
373 slot1 = bcnint * 3 - IWL_MIN_SLOT_TIME;
374 slot0 = IWL_MIN_SLOT_TIME;
375 }
376 } else if (ctx_pan->vif) {
377 slot0 = 0;
378 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
379 ctx_pan->vif->bss_conf.beacon_int;
380 slot1 = max_t(int, DEFAULT_BEACON_INTERVAL, slot1);
381
382 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
383 slot0 = slot1 * 3 - IWL_MIN_SLOT_TIME;
384 slot1 = IWL_MIN_SLOT_TIME;
385 }
386 }
387
388 cmd.slots[0].width = cpu_to_le16(slot0);
389 cmd.slots[1].width = cpu_to_le16(slot1);
390
391 ret = trans_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, CMD_SYNC,
392 sizeof(cmd), &cmd);
393 if (ret)
394 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
395
396 return ret;
397}
398
306/** 399/**
307 * iwlagn_commit_rxon - commit staging_rxon to hardware 400 * iwlagn_commit_rxon - commit staging_rxon to hardware
308 * 401 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index ba4e2a85000..dceb4506366 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1954,6 +1954,25 @@ static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg)
1954} 1954}
1955 1955
1956 1956
1957static int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
1958{
1959 struct iwl_tx_ant_config_cmd tx_ant_cmd = {
1960 .valid = cpu_to_le32(valid_tx_ant),
1961 };
1962
1963 if (IWL_UCODE_API(priv->ucode_ver) > 1) {
1964 IWL_DEBUG_HC(priv, "select valid tx ant: %u\n", valid_tx_ant);
1965 return trans_send_cmd_pdu(priv,
1966 TX_ANT_CONFIGURATION_CMD,
1967 CMD_SYNC,
1968 sizeof(struct iwl_tx_ant_config_cmd),
1969 &tx_ant_cmd);
1970 } else {
1971 IWL_DEBUG_HC(priv, "TX_ANT_CONFIGURATION_CMD not supported\n");
1972 return -EOPNOTSUPP;
1973 }
1974}
1975
1957/** 1976/**
1958 * iwl_alive_start - called after REPLY_ALIVE notification received 1977 * iwl_alive_start - called after REPLY_ALIVE notification received
1959 * from protocol/runtime uCode (initialization uCode's 1978 * from protocol/runtime uCode (initialization uCode's
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 666376e3030..6ddfd9338ee 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -146,6 +146,7 @@ void iwl_free_tfds_in_queue(struct iwl_priv *priv,
146 int sta_id, int tid, int freed); 146 int sta_id, int tid, int freed);
147 147
148/* RXON */ 148/* RXON */
149int iwlagn_set_pan_params(struct iwl_priv *priv);
149int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 150int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
150void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx); 151void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
151int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed); 152int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed);
@@ -178,6 +179,7 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv);
178int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv); 179int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv);
179int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); 180int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control);
180void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); 181void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control);
182int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
181 183
182/* rx */ 184/* rx */
183void iwl_irq_tasklet(struct iwl_priv *priv); 185void iwl_irq_tasklet(struct iwl_priv *priv);
@@ -245,17 +247,6 @@ void iwlagn_post_scan(struct iwl_priv *priv);
245int iwlagn_manage_ibss_station(struct iwl_priv *priv, 247int iwlagn_manage_ibss_station(struct iwl_priv *priv,
246 struct ieee80211_vif *vif, bool add); 248 struct ieee80211_vif *vif, bool add);
247 249
248/* hcmd */
249int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant);
250int iwlagn_send_beacon_cmd(struct iwl_priv *priv);
251int iwlagn_set_pan_params(struct iwl_priv *priv);
252void iwlagn_gain_computation(struct iwl_priv *priv,
253 u32 average_noise[NUM_RX_CHAINS],
254 u16 min_average_noise_antenna_i,
255 u32 min_average_noise,
256 u8 default_chain);
257
258
259/* bt coex */ 250/* bt coex */
260void iwlagn_send_advance_bt_config(struct iwl_priv *priv); 251void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
261void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, 252void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,