Commit | Line | Data |
---|---|---|
a9533e7e HP |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
3327989a | 17 | #include <linux/kernel.h> |
c6ac24e9 | 18 | #include <linux/module.h> |
a1c16ed2 | 19 | #include <wlc_cfg.h> |
a9533e7e HP |
20 | #include <bcmdefs.h> |
21 | #include <osl.h> | |
22 | #include <bcmutils.h> | |
23 | #include <siutils.h> | |
a9533e7e HP |
24 | #include <proto/802.11.h> |
25 | #include <wlioctl.h> | |
a9533e7e | 26 | #include <bcmwifi.h> |
a52ba66c BR |
27 | #include <sbhndpio.h> |
28 | #include <sbhnddma.h> | |
a9533e7e HP |
29 | #include <d11.h> |
30 | #include <wlc_rate.h> | |
31 | #include <wlc_pub.h> | |
32 | #include <wlc_key.h> | |
33 | #include <wlc_channel.h> | |
34 | #include <wlc_bsscfg.h> | |
35 | #include <wlc_mac80211.h> | |
36 | #include <wlc_scb.h> | |
37 | #include <wl_export.h> | |
38 | #include <wlc_bmac.h> | |
39 | #include <wlc_stf.h> | |
69ec303a | 40 | #include <wl_dbg.h> |
a9533e7e | 41 | |
62b54dca AS |
42 | #define MIN_SPATIAL_EXPANSION 0 |
43 | #define MAX_SPATIAL_EXPANSION 1 | |
44 | ||
a9533e7e HP |
45 | #define WLC_STF_SS_STBC_RX(wlc) (WLCISNPHY(wlc->band) && \ |
46 | NREV_GT(wlc->band->phyrev, 3) && NREV_LE(wlc->band->phyrev, 6)) | |
47 | ||
c6a9e1fc RV |
48 | static bool wlc_stf_stbc_tx_set(struct wlc_info *wlc, s32 int_val); |
49 | static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 val); | |
50 | static int wlc_stf_spatial_policy_set(struct wlc_info *wlc, int val); | |
51 | static void wlc_stf_stbc_rx_ht_update(struct wlc_info *wlc, int val); | |
a9533e7e | 52 | |
c6a9e1fc RV |
53 | static void _wlc_stf_phy_txant_upd(struct wlc_info *wlc); |
54 | static u16 _wlc_stf_phytxchain_sel(struct wlc_info *wlc, ratespec_t rspec); | |
a9533e7e HP |
55 | |
56 | #define NSTS_1 1 | |
57 | #define NSTS_2 2 | |
58 | #define NSTS_3 3 | |
59 | #define NSTS_4 4 | |
41feb5ed | 60 | const u8 txcore_default[5] = { |
a9533e7e HP |
61 | (0), /* bitmap of the core enabled */ |
62 | (0x01), /* For Nsts = 1, enable core 1 */ | |
63 | (0x03), /* For Nsts = 2, enable core 1 & 2 */ | |
64 | (0x07), /* For Nsts = 3, enable core 1, 2 & 3 */ | |
65 | (0x0f) /* For Nsts = 4, enable all cores */ | |
66 | }; | |
67 | ||
c6a9e1fc | 68 | static void wlc_stf_stbc_rx_ht_update(struct wlc_info *wlc, int val) |
a9533e7e HP |
69 | { |
70 | ASSERT((val == HT_CAP_RX_STBC_NO) | |
71 | || (val == HT_CAP_RX_STBC_ONE_STREAM)); | |
72 | ||
73 | /* MIMOPHYs rev3-6 cannot receive STBC with only one rx core active */ | |
74 | if (WLC_STF_SS_STBC_RX(wlc)) { | |
75 | if ((wlc->stf->rxstreams == 1) && (val != HT_CAP_RX_STBC_NO)) | |
76 | return; | |
77 | } | |
78 | ||
651bd3a9 RV |
79 | wlc->ht_cap.cap_info &= ~HT_CAP_RX_STBC_MASK; |
80 | wlc->ht_cap.cap_info |= (val << HT_CAP_RX_STBC_SHIFT); | |
a9533e7e HP |
81 | |
82 | if (wlc->pub->up) { | |
83 | wlc_update_beacon(wlc); | |
0f0881b0 | 84 | wlc_update_probe_resp(wlc, true); |
a9533e7e HP |
85 | } |
86 | } | |
87 | ||
88 | /* every WLC_TEMPSENSE_PERIOD seconds temperature check to decide whether to turn on/off txchain */ | |
c6a9e1fc | 89 | void wlc_tempsense_upd(struct wlc_info *wlc) |
a9533e7e HP |
90 | { |
91 | wlc_phy_t *pi = wlc->band->pi; | |
92 | uint active_chains, txchain; | |
93 | ||
94 | /* Check if the chip is too hot. Disable one Tx chain, if it is */ | |
95 | /* high 4 bits are for Rx chain, low 4 bits are for Tx chain */ | |
96 | active_chains = wlc_phy_stf_chain_active_get(pi); | |
97 | txchain = active_chains & 0xf; | |
98 | ||
99 | if (wlc->stf->txchain == wlc->stf->hw_txchain) { | |
100 | if (txchain && (txchain < wlc->stf->hw_txchain)) { | |
101 | /* turn off 1 tx chain */ | |
0f0881b0 | 102 | wlc_stf_txchain_set(wlc, txchain, true); |
a9533e7e HP |
103 | } |
104 | } else if (wlc->stf->txchain < wlc->stf->hw_txchain) { | |
105 | if (txchain == wlc->stf->hw_txchain) { | |
106 | /* turn back on txchain */ | |
0f0881b0 | 107 | wlc_stf_txchain_set(wlc, txchain, true); |
a9533e7e HP |
108 | } |
109 | } | |
110 | } | |
111 | ||
112 | void | |
c6a9e1fc | 113 | wlc_stf_ss_algo_channel_get(struct wlc_info *wlc, u16 *ss_algo_channel, |
a9533e7e HP |
114 | chanspec_t chanspec) |
115 | { | |
116 | tx_power_t power; | |
41feb5ed | 117 | u8 siso_mcs_id, cdd_mcs_id, stbc_mcs_id; |
a9533e7e HP |
118 | |
119 | /* Clear previous settings */ | |
120 | *ss_algo_channel = 0; | |
121 | ||
122 | if (!wlc->pub->up) { | |
7d4df48e | 123 | *ss_algo_channel = (u16) -1; |
a9533e7e HP |
124 | return; |
125 | } | |
126 | ||
127 | wlc_phy_txpower_get_current(wlc->band->pi, &power, | |
128 | CHSPEC_CHANNEL(chanspec)); | |
129 | ||
130 | siso_mcs_id = (CHSPEC_IS40(chanspec)) ? | |
131 | WL_TX_POWER_MCS40_SISO_FIRST : WL_TX_POWER_MCS20_SISO_FIRST; | |
132 | cdd_mcs_id = (CHSPEC_IS40(chanspec)) ? | |
133 | WL_TX_POWER_MCS40_CDD_FIRST : WL_TX_POWER_MCS20_CDD_FIRST; | |
134 | stbc_mcs_id = (CHSPEC_IS40(chanspec)) ? | |
135 | WL_TX_POWER_MCS40_STBC_FIRST : WL_TX_POWER_MCS20_STBC_FIRST; | |
136 | ||
137 | /* criteria to choose stf mode */ | |
138 | ||
139 | /* the "+3dbm (12 0.25db units)" is to account for the fact that with CDD, tx occurs | |
140 | * on both chains | |
141 | */ | |
142 | if (power.target[siso_mcs_id] > (power.target[cdd_mcs_id] + 12)) | |
143 | setbit(ss_algo_channel, PHY_TXC1_MODE_SISO); | |
144 | else | |
145 | setbit(ss_algo_channel, PHY_TXC1_MODE_CDD); | |
146 | ||
147 | /* STBC is ORed into to algo channel as STBC requires per-packet SCB capability check | |
148 | * so cannot be default mode of operation. One of SISO, CDD have to be set | |
149 | */ | |
150 | if (power.target[siso_mcs_id] <= (power.target[stbc_mcs_id] + 12)) | |
151 | setbit(ss_algo_channel, PHY_TXC1_MODE_STBC); | |
152 | } | |
153 | ||
c6a9e1fc | 154 | static bool wlc_stf_stbc_tx_set(struct wlc_info *wlc, s32 int_val) |
a9533e7e HP |
155 | { |
156 | if ((int_val != AUTO) && (int_val != OFF) && (int_val != ON)) { | |
0965ae88 | 157 | return false; |
a9533e7e HP |
158 | } |
159 | ||
160 | if ((int_val == ON) && (wlc->stf->txstreams == 1)) | |
0965ae88 | 161 | return false; |
a9533e7e HP |
162 | |
163 | if ((int_val == OFF) || (wlc->stf->txstreams == 1) | |
164 | || !WLC_STBC_CAP_PHY(wlc)) | |
651bd3a9 | 165 | wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_TX_STBC; |
a9533e7e | 166 | else |
651bd3a9 | 167 | wlc->ht_cap.cap_info |= IEEE80211_HT_CAP_TX_STBC; |
a9533e7e | 168 | |
562c8850 GKH |
169 | wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = (s8) int_val; |
170 | wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = (s8) int_val; | |
a9533e7e | 171 | |
0f0881b0 | 172 | return true; |
a9533e7e HP |
173 | } |
174 | ||
c6a9e1fc | 175 | bool wlc_stf_stbc_rx_set(struct wlc_info *wlc, s32 int_val) |
a9533e7e HP |
176 | { |
177 | if ((int_val != HT_CAP_RX_STBC_NO) | |
178 | && (int_val != HT_CAP_RX_STBC_ONE_STREAM)) { | |
0965ae88 | 179 | return false; |
a9533e7e HP |
180 | } |
181 | ||
182 | if (WLC_STF_SS_STBC_RX(wlc)) { | |
183 | if ((int_val != HT_CAP_RX_STBC_NO) | |
184 | && (wlc->stf->rxstreams == 1)) | |
0965ae88 | 185 | return false; |
a9533e7e HP |
186 | } |
187 | ||
188 | wlc_stf_stbc_rx_ht_update(wlc, int_val); | |
0f0881b0 | 189 | return true; |
a9533e7e HP |
190 | } |
191 | ||
c6a9e1fc | 192 | static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 core_mask) |
a9533e7e | 193 | { |
f4528696 JP |
194 | WL_TRACE("wl%d: %s: Nsts %d core_mask %x\n", |
195 | wlc->pub->unit, __func__, Nsts, core_mask); | |
a9533e7e HP |
196 | |
197 | ASSERT((Nsts > 0) && (Nsts <= MAX_STREAMS_SUPPORTED)); | |
198 | ||
199 | if (WLC_BITSCNT(core_mask) > wlc->stf->txstreams) { | |
200 | core_mask = 0; | |
201 | } | |
202 | ||
203 | if ((WLC_BITSCNT(core_mask) == wlc->stf->txstreams) && | |
204 | ((core_mask & ~wlc->stf->txchain) | |
205 | || !(core_mask & wlc->stf->txchain))) { | |
206 | core_mask = wlc->stf->txchain; | |
207 | } | |
208 | ||
209 | ASSERT(!core_mask || Nsts <= WLC_BITSCNT(core_mask)); | |
210 | ||
211 | wlc->stf->txcore[Nsts] = core_mask; | |
212 | /* Nsts = 1..4, txcore index = 1..4 */ | |
213 | if (Nsts == 1) { | |
214 | /* Needs to update beacon and ucode generated response | |
215 | * frames when 1 stream core map changed | |
216 | */ | |
217 | wlc->stf->phytxant = core_mask << PHY_TXC_ANT_SHIFT; | |
218 | wlc_bmac_txant_set(wlc->hw, wlc->stf->phytxant); | |
219 | if (wlc->clk) { | |
220 | wlc_suspend_mac_and_wait(wlc); | |
221 | wlc_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); | |
222 | wlc_enable_mac(wlc); | |
223 | } | |
224 | } | |
225 | ||
226 | return BCME_OK; | |
227 | } | |
228 | ||
c6a9e1fc | 229 | static int wlc_stf_spatial_policy_set(struct wlc_info *wlc, int val) |
a9533e7e HP |
230 | { |
231 | int i; | |
41feb5ed | 232 | u8 core_mask = 0; |
a9533e7e | 233 | |
f4528696 | 234 | WL_TRACE("wl%d: %s: val %x\n", wlc->pub->unit, __func__, val); |
a9533e7e | 235 | |
562c8850 | 236 | wlc->stf->spatial_policy = (s8) val; |
a9533e7e HP |
237 | for (i = 1; i <= MAX_STREAMS_SUPPORTED; i++) { |
238 | core_mask = (val == MAX_SPATIAL_EXPANSION) ? | |
239 | wlc->stf->txchain : txcore_default[i]; | |
41feb5ed | 240 | wlc_stf_txcore_set(wlc, (u8) i, core_mask); |
a9533e7e HP |
241 | } |
242 | return BCME_OK; | |
243 | } | |
244 | ||
c6a9e1fc | 245 | int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force) |
a9533e7e | 246 | { |
41feb5ed GKH |
247 | u8 txchain = (u8) int_val; |
248 | u8 txstreams; | |
a9533e7e HP |
249 | uint i; |
250 | ||
251 | if (wlc->stf->txchain == txchain) | |
252 | return BCME_OK; | |
253 | ||
254 | if ((txchain & ~wlc->stf->hw_txchain) | |
255 | || !(txchain & wlc->stf->hw_txchain)) | |
256 | return BCME_RANGE; | |
257 | ||
258 | /* if nrate override is configured to be non-SISO STF mode, reject reducing txchain to 1 */ | |
41feb5ed | 259 | txstreams = (u8) WLC_BITSCNT(txchain); |
a9533e7e HP |
260 | if (txstreams > MAX_STREAMS_SUPPORTED) |
261 | return BCME_RANGE; | |
262 | ||
263 | if (txstreams == 1) { | |
264 | for (i = 0; i < NBANDS(wlc); i++) | |
265 | if ((RSPEC_STF(wlc->bandstate[i]->rspec_override) != | |
266 | PHY_TXC1_MODE_SISO) | |
267 | || (RSPEC_STF(wlc->bandstate[i]->mrspec_override) != | |
268 | PHY_TXC1_MODE_SISO)) { | |
269 | if (!force) | |
270 | return BCME_ERROR; | |
271 | ||
272 | /* over-write the override rspec */ | |
273 | if (RSPEC_STF(wlc->bandstate[i]->rspec_override) | |
274 | != PHY_TXC1_MODE_SISO) { | |
275 | wlc->bandstate[i]->rspec_override = 0; | |
f4528696 JP |
276 | WL_ERROR("%s(): temp sense override non-SISO rspec_override\n", |
277 | __func__); | |
a9533e7e HP |
278 | } |
279 | if (RSPEC_STF | |
280 | (wlc->bandstate[i]->mrspec_override) != | |
281 | PHY_TXC1_MODE_SISO) { | |
282 | wlc->bandstate[i]->mrspec_override = 0; | |
f4528696 JP |
283 | WL_ERROR("%s(): temp sense override non-SISO mrspec_override\n", |
284 | __func__); | |
a9533e7e HP |
285 | } |
286 | } | |
287 | } | |
288 | ||
289 | wlc->stf->txchain = txchain; | |
290 | wlc->stf->txstreams = txstreams; | |
291 | wlc_stf_stbc_tx_set(wlc, wlc->band->band_stf_stbc_tx); | |
292 | wlc_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); | |
293 | wlc_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); | |
294 | wlc->stf->txant = | |
295 | (wlc->stf->txstreams == 1) ? ANT_TX_FORCE_0 : ANT_TX_DEF; | |
296 | _wlc_stf_phy_txant_upd(wlc); | |
297 | ||
298 | wlc_phy_stf_chain_set(wlc->band->pi, wlc->stf->txchain, | |
299 | wlc->stf->rxchain); | |
300 | ||
301 | for (i = 1; i <= MAX_STREAMS_SUPPORTED; i++) | |
41feb5ed | 302 | wlc_stf_txcore_set(wlc, (u8) i, txcore_default[i]); |
a9533e7e HP |
303 | |
304 | return BCME_OK; | |
305 | } | |
306 | ||
a9533e7e | 307 | /* update wlc->stf->ss_opmode which represents the operational stf_ss mode we're using */ |
f077f718 | 308 | int wlc_stf_ss_update(struct wlc_info *wlc, struct wlcband *band) |
a9533e7e HP |
309 | { |
310 | int ret_code = 0; | |
41feb5ed GKH |
311 | u8 prev_stf_ss; |
312 | u8 upd_stf_ss; | |
a9533e7e HP |
313 | |
314 | prev_stf_ss = wlc->stf->ss_opmode; | |
315 | ||
316 | /* NOTE: opmode can only be SISO or CDD as STBC is decided on a per-packet basis */ | |
317 | if (WLC_STBC_CAP_PHY(wlc) && | |
318 | wlc->stf->ss_algosel_auto | |
7d4df48e | 319 | && (wlc->stf->ss_algo_channel != (u16) -1)) { |
a9533e7e HP |
320 | ASSERT(isset(&wlc->stf->ss_algo_channel, PHY_TXC1_MODE_CDD) |
321 | || isset(&wlc->stf->ss_algo_channel, | |
322 | PHY_TXC1_MODE_SISO)); | |
323 | upd_stf_ss = (wlc->stf->no_cddstbc || (wlc->stf->txstreams == 1) | |
324 | || isset(&wlc->stf->ss_algo_channel, | |
325 | PHY_TXC1_MODE_SISO)) ? PHY_TXC1_MODE_SISO | |
326 | : PHY_TXC1_MODE_CDD; | |
327 | } else { | |
328 | if (wlc->band != band) | |
329 | return ret_code; | |
330 | upd_stf_ss = (wlc->stf->no_cddstbc | |
331 | || (wlc->stf->txstreams == | |
332 | 1)) ? PHY_TXC1_MODE_SISO : band-> | |
333 | band_stf_ss_mode; | |
334 | } | |
335 | if (prev_stf_ss != upd_stf_ss) { | |
336 | wlc->stf->ss_opmode = upd_stf_ss; | |
337 | wlc_bmac_band_stf_ss_set(wlc->hw, upd_stf_ss); | |
338 | } | |
339 | ||
340 | return ret_code; | |
341 | } | |
342 | ||
c6a9e1fc | 343 | int wlc_stf_attach(struct wlc_info *wlc) |
a2627bc0 | 344 | { |
a9533e7e HP |
345 | wlc->bandstate[BAND_2G_INDEX]->band_stf_ss_mode = PHY_TXC1_MODE_SISO; |
346 | wlc->bandstate[BAND_5G_INDEX]->band_stf_ss_mode = PHY_TXC1_MODE_CDD; | |
347 | ||
348 | if (WLCISNPHY(wlc->band) && | |
349 | (wlc_phy_txpower_hw_ctrl_get(wlc->band->pi) != PHY_TPC_HW_ON)) | |
350 | wlc->bandstate[BAND_2G_INDEX]->band_stf_ss_mode = | |
351 | PHY_TXC1_MODE_CDD; | |
352 | wlc_stf_ss_update(wlc, wlc->bandstate[BAND_2G_INDEX]); | |
353 | wlc_stf_ss_update(wlc, wlc->bandstate[BAND_5G_INDEX]); | |
354 | ||
355 | wlc_stf_stbc_rx_ht_update(wlc, HT_CAP_RX_STBC_NO); | |
356 | wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = OFF; | |
357 | wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = OFF; | |
358 | ||
359 | if (WLC_STBC_CAP_PHY(wlc)) { | |
0f0881b0 | 360 | wlc->stf->ss_algosel_auto = true; |
7d4df48e | 361 | wlc->stf->ss_algo_channel = (u16) -1; /* Init the default value */ |
a9533e7e HP |
362 | } |
363 | return 0; | |
364 | } | |
365 | ||
c6a9e1fc | 366 | void wlc_stf_detach(struct wlc_info *wlc) |
a2627bc0 | 367 | { |
a9533e7e HP |
368 | } |
369 | ||
c6a9e1fc | 370 | int wlc_stf_ant_txant_validate(struct wlc_info *wlc, s8 val) |
a9533e7e HP |
371 | { |
372 | int bcmerror = BCME_OK; | |
373 | ||
374 | /* when there is only 1 tx_streams, don't allow to change the txant */ | |
375 | if (WLCISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) | |
376 | return ((val == wlc->stf->txant) ? bcmerror : BCME_RANGE); | |
377 | ||
378 | switch (val) { | |
379 | case -1: | |
380 | val = ANT_TX_DEF; | |
381 | break; | |
382 | case 0: | |
383 | val = ANT_TX_FORCE_0; | |
384 | break; | |
385 | case 1: | |
386 | val = ANT_TX_FORCE_1; | |
387 | break; | |
388 | case 3: | |
389 | val = ANT_TX_LAST_RX; | |
390 | break; | |
391 | default: | |
392 | bcmerror = BCME_RANGE; | |
393 | break; | |
394 | } | |
395 | ||
396 | if (bcmerror == BCME_OK) | |
562c8850 | 397 | wlc->stf->txant = (s8) val; |
a9533e7e HP |
398 | |
399 | return bcmerror; | |
400 | ||
401 | } | |
402 | ||
403 | /* | |
404 | * Centralized txant update function. call it whenever wlc->stf->txant and/or wlc->stf->txchain | |
405 | * change | |
406 | * | |
407 | * Antennas are controlled by ucode indirectly, which drives PHY or GPIO to | |
408 | * achieve various tx/rx antenna selection schemes | |
409 | * | |
410 | * legacy phy, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 means auto(last rx) | |
411 | * for NREV<3, bit 6 and bit 7 means antenna 0 and 1 respectively, bit6+bit7 means last rx and | |
412 | * do tx-antenna selection for SISO transmissions | |
413 | * for NREV=3, bit 6 and bit _8_ means antenna 0 and 1 respectively, bit6+bit7 means last rx and | |
414 | * do tx-antenna selection for SISO transmissions | |
415 | * for NREV>=7, bit 6 and bit 7 mean antenna 0 and 1 respectively, nit6+bit7 means both cores active | |
416 | */ | |
c6a9e1fc | 417 | static void _wlc_stf_phy_txant_upd(struct wlc_info *wlc) |
a9533e7e | 418 | { |
562c8850 | 419 | s8 txant; |
a9533e7e | 420 | |
562c8850 | 421 | txant = (s8) wlc->stf->txant; |
a9533e7e HP |
422 | ASSERT(txant == ANT_TX_FORCE_0 || txant == ANT_TX_FORCE_1 |
423 | || txant == ANT_TX_LAST_RX); | |
424 | ||
425 | if (WLC_PHY_11N_CAP(wlc->band)) { | |
426 | if (txant == ANT_TX_FORCE_0) { | |
427 | wlc->stf->phytxant = PHY_TXC_ANT_0; | |
428 | } else if (txant == ANT_TX_FORCE_1) { | |
429 | wlc->stf->phytxant = PHY_TXC_ANT_1; | |
430 | ||
431 | if (WLCISNPHY(wlc->band) && | |
432 | NREV_GE(wlc->band->phyrev, 3) | |
433 | && NREV_LT(wlc->band->phyrev, 7)) { | |
434 | wlc->stf->phytxant = PHY_TXC_ANT_2; | |
435 | } | |
436 | } else { | |
437 | if (WLCISLCNPHY(wlc->band) || WLCISSSLPNPHY(wlc->band)) | |
438 | wlc->stf->phytxant = PHY_TXC_LCNPHY_ANT_LAST; | |
439 | else { | |
440 | /* keep this assert to catch out of sync wlc->stf->txcore */ | |
441 | ASSERT(wlc->stf->txchain > 0); | |
442 | wlc->stf->phytxant = | |
443 | wlc->stf->txchain << PHY_TXC_ANT_SHIFT; | |
444 | } | |
445 | } | |
446 | } else { | |
447 | if (txant == ANT_TX_FORCE_0) | |
448 | wlc->stf->phytxant = PHY_TXC_OLD_ANT_0; | |
449 | else if (txant == ANT_TX_FORCE_1) | |
450 | wlc->stf->phytxant = PHY_TXC_OLD_ANT_1; | |
451 | else | |
452 | wlc->stf->phytxant = PHY_TXC_OLD_ANT_LAST; | |
453 | } | |
454 | ||
455 | wlc_bmac_txant_set(wlc->hw, wlc->stf->phytxant); | |
456 | } | |
457 | ||
c6a9e1fc | 458 | void wlc_stf_phy_txant_upd(struct wlc_info *wlc) |
a9533e7e HP |
459 | { |
460 | _wlc_stf_phy_txant_upd(wlc); | |
461 | } | |
462 | ||
c6a9e1fc | 463 | void wlc_stf_phy_chain_calc(struct wlc_info *wlc) |
a2627bc0 | 464 | { |
a9533e7e | 465 | /* get available rx/tx chains */ |
41feb5ed GKH |
466 | wlc->stf->hw_txchain = (u8) getintvar(wlc->pub->vars, "txchain"); |
467 | wlc->stf->hw_rxchain = (u8) getintvar(wlc->pub->vars, "rxchain"); | |
a9533e7e HP |
468 | |
469 | /* these parameter are intended to be used for all PHY types */ | |
470 | if (wlc->stf->hw_txchain == 0 || wlc->stf->hw_txchain == 0xf) { | |
471 | if (WLCISNPHY(wlc->band)) { | |
472 | wlc->stf->hw_txchain = TXCHAIN_DEF_NPHY; | |
473 | } else { | |
474 | wlc->stf->hw_txchain = TXCHAIN_DEF; | |
475 | } | |
476 | } | |
477 | ||
478 | wlc->stf->txchain = wlc->stf->hw_txchain; | |
41feb5ed | 479 | wlc->stf->txstreams = (u8) WLC_BITSCNT(wlc->stf->hw_txchain); |
a9533e7e HP |
480 | |
481 | if (wlc->stf->hw_rxchain == 0 || wlc->stf->hw_rxchain == 0xf) { | |
482 | if (WLCISNPHY(wlc->band)) { | |
483 | wlc->stf->hw_rxchain = RXCHAIN_DEF_NPHY; | |
484 | } else { | |
485 | wlc->stf->hw_rxchain = RXCHAIN_DEF; | |
486 | } | |
487 | } | |
488 | ||
489 | wlc->stf->rxchain = wlc->stf->hw_rxchain; | |
41feb5ed | 490 | wlc->stf->rxstreams = (u8) WLC_BITSCNT(wlc->stf->hw_rxchain); |
a9533e7e HP |
491 | |
492 | /* initialize the txcore table */ | |
02160695 | 493 | memcpy(wlc->stf->txcore, txcore_default, sizeof(wlc->stf->txcore)); |
a9533e7e HP |
494 | |
495 | /* default spatial_policy */ | |
496 | wlc->stf->spatial_policy = MIN_SPATIAL_EXPANSION; | |
497 | wlc_stf_spatial_policy_set(wlc, MIN_SPATIAL_EXPANSION); | |
498 | } | |
499 | ||
c6a9e1fc | 500 | static u16 _wlc_stf_phytxchain_sel(struct wlc_info *wlc, ratespec_t rspec) |
a9533e7e | 501 | { |
7d4df48e | 502 | u16 phytxant = wlc->stf->phytxant; |
a9533e7e HP |
503 | |
504 | if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) { | |
505 | ASSERT(wlc->stf->txstreams > 1); | |
506 | phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; | |
507 | } else if (wlc->stf->txant == ANT_TX_DEF) | |
508 | phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; | |
509 | phytxant &= PHY_TXC_ANT_MASK; | |
510 | return phytxant; | |
511 | } | |
512 | ||
c6a9e1fc | 513 | u16 wlc_stf_phytxchain_sel(struct wlc_info *wlc, ratespec_t rspec) |
a9533e7e HP |
514 | { |
515 | return _wlc_stf_phytxchain_sel(wlc, rspec); | |
516 | } | |
517 | ||
c6a9e1fc | 518 | u16 wlc_stf_d11hdrs_phyctl_txant(struct wlc_info *wlc, ratespec_t rspec) |
a9533e7e | 519 | { |
7d4df48e GKH |
520 | u16 phytxant = wlc->stf->phytxant; |
521 | u16 mask = PHY_TXC_ANT_MASK; | |
a9533e7e HP |
522 | |
523 | /* for non-siso rates or default setting, use the available chains */ | |
524 | if (WLCISNPHY(wlc->band)) { | |
525 | ASSERT(wlc->stf->txchain != 0); | |
526 | phytxant = _wlc_stf_phytxchain_sel(wlc, rspec); | |
527 | mask = PHY_TXC_HTANT_MASK; | |
528 | } | |
529 | phytxant |= phytxant & mask; | |
530 | return phytxant; | |
531 | } |