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