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