.. | .. |
---|
7 | 7 | * |
---|
8 | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
---|
9 | 9 | * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH |
---|
10 | | - * Copyright(c) 2017 Intel Deutschland GmbH |
---|
11 | | - * Copyright(c) 2018 Intel Corporation |
---|
| 10 | + * Copyright(c) 2017 Intel Deutschland GmbH |
---|
| 11 | + * Copyright(c) 2018 - 2020 Intel Corporation |
---|
12 | 12 | * |
---|
13 | 13 | * This program is free software; you can redistribute it and/or modify |
---|
14 | 14 | * it under the terms of version 2 of the GNU General Public License as |
---|
.. | .. |
---|
30 | 30 | * |
---|
31 | 31 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
---|
32 | 32 | * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH |
---|
33 | | - * Copyright(c) 2018 Intel Corporation |
---|
| 33 | + * Copyright(c) 2018 - 2020 Intel Corporation |
---|
34 | 34 | * All rights reserved. |
---|
35 | 35 | * |
---|
36 | 36 | * Redistribution and use in source and binary forms, with or without |
---|
.. | .. |
---|
109 | 109 | return PHY_VHT_CTRL_POS_4_ABOVE; |
---|
110 | 110 | default: |
---|
111 | 111 | WARN(1, "Invalid channel definition"); |
---|
| 112 | + /* fall through */ |
---|
112 | 113 | case 0: |
---|
113 | 114 | /* |
---|
114 | 115 | * The FW is expected to check the control channel position only |
---|
.. | .. |
---|
124 | 125 | */ |
---|
125 | 126 | static void iwl_mvm_phy_ctxt_cmd_hdr(struct iwl_mvm_phy_ctxt *ctxt, |
---|
126 | 127 | struct iwl_phy_context_cmd *cmd, |
---|
127 | | - u32 action, u32 apply_time) |
---|
| 128 | + u32 action) |
---|
128 | 129 | { |
---|
129 | | - memset(cmd, 0, sizeof(struct iwl_phy_context_cmd)); |
---|
130 | | - |
---|
131 | 130 | cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(ctxt->id, |
---|
132 | 131 | ctxt->color)); |
---|
133 | 132 | cmd->action = cpu_to_le32(action); |
---|
134 | | - cmd->apply_time = cpu_to_le32(apply_time); |
---|
135 | 133 | } |
---|
136 | 134 | |
---|
137 | | -/* |
---|
138 | | - * Add the phy configuration to the PHY context command |
---|
139 | | - */ |
---|
140 | | -static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm, |
---|
141 | | - struct iwl_phy_context_cmd *cmd, |
---|
142 | | - struct cfg80211_chan_def *chandef, |
---|
143 | | - u8 chains_static, u8 chains_dynamic) |
---|
| 135 | +static void iwl_mvm_phy_ctxt_set_rxchain(struct iwl_mvm *mvm, |
---|
| 136 | + __le32 *rxchain_info, |
---|
| 137 | + u8 chains_static, |
---|
| 138 | + u8 chains_dynamic) |
---|
144 | 139 | { |
---|
145 | 140 | u8 active_cnt, idle_cnt; |
---|
146 | | - |
---|
147 | | - /* Set the channel info data */ |
---|
148 | | - cmd->ci.band = (chandef->chan->band == NL80211_BAND_2GHZ ? |
---|
149 | | - PHY_BAND_24 : PHY_BAND_5); |
---|
150 | | - |
---|
151 | | - cmd->ci.channel = chandef->chan->hw_value; |
---|
152 | | - cmd->ci.width = iwl_mvm_get_channel_width(chandef); |
---|
153 | | - cmd->ci.ctrl_pos = iwl_mvm_get_ctrl_pos(chandef); |
---|
154 | 141 | |
---|
155 | 142 | /* Set rx the chains */ |
---|
156 | 143 | idle_cnt = chains_static; |
---|
.. | .. |
---|
168 | 155 | active_cnt = 2; |
---|
169 | 156 | } |
---|
170 | 157 | |
---|
171 | | - cmd->rxchain_info = cpu_to_le32(iwl_mvm_get_valid_rx_ant(mvm) << |
---|
| 158 | + *rxchain_info = cpu_to_le32(iwl_mvm_get_valid_rx_ant(mvm) << |
---|
172 | 159 | PHY_RX_CHAIN_VALID_POS); |
---|
173 | | - cmd->rxchain_info |= cpu_to_le32(idle_cnt << PHY_RX_CHAIN_CNT_POS); |
---|
174 | | - cmd->rxchain_info |= cpu_to_le32(active_cnt << |
---|
| 160 | + *rxchain_info |= cpu_to_le32(idle_cnt << PHY_RX_CHAIN_CNT_POS); |
---|
| 161 | + *rxchain_info |= cpu_to_le32(active_cnt << |
---|
175 | 162 | PHY_RX_CHAIN_MIMO_CNT_POS); |
---|
176 | 163 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
---|
177 | 164 | if (unlikely(mvm->dbgfs_rx_phyinfo)) |
---|
178 | | - cmd->rxchain_info = cpu_to_le32(mvm->dbgfs_rx_phyinfo); |
---|
| 165 | + *rxchain_info = cpu_to_le32(mvm->dbgfs_rx_phyinfo); |
---|
179 | 166 | #endif |
---|
| 167 | +} |
---|
180 | 168 | |
---|
181 | | - cmd->txchain_info = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); |
---|
| 169 | +/* |
---|
| 170 | + * Add the phy configuration to the PHY context command |
---|
| 171 | + */ |
---|
| 172 | +static void iwl_mvm_phy_ctxt_cmd_data_v1(struct iwl_mvm *mvm, |
---|
| 173 | + struct iwl_phy_context_cmd_v1 *cmd, |
---|
| 174 | + struct cfg80211_chan_def *chandef, |
---|
| 175 | + u8 chains_static, u8 chains_dynamic) |
---|
| 176 | +{ |
---|
| 177 | + struct iwl_phy_context_cmd_tail *tail = |
---|
| 178 | + iwl_mvm_chan_info_cmd_tail(mvm, &cmd->ci); |
---|
| 179 | + |
---|
| 180 | + /* Set the channel info data */ |
---|
| 181 | + iwl_mvm_set_chan_info_chandef(mvm, &cmd->ci, chandef); |
---|
| 182 | + |
---|
| 183 | + iwl_mvm_phy_ctxt_set_rxchain(mvm, &tail->rxchain_info, |
---|
| 184 | + chains_static, chains_dynamic); |
---|
| 185 | + |
---|
| 186 | + tail->txchain_info = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); |
---|
| 187 | +} |
---|
| 188 | + |
---|
| 189 | +/* |
---|
| 190 | + * Add the phy configuration to the PHY context command |
---|
| 191 | + */ |
---|
| 192 | +static void iwl_mvm_phy_ctxt_cmd_data(struct iwl_mvm *mvm, |
---|
| 193 | + struct iwl_phy_context_cmd *cmd, |
---|
| 194 | + struct cfg80211_chan_def *chandef, |
---|
| 195 | + u8 chains_static, u8 chains_dynamic) |
---|
| 196 | +{ |
---|
| 197 | + cmd->lmac_id = cpu_to_le32(iwl_mvm_get_lmac_id(mvm->fw, |
---|
| 198 | + chandef->chan->band)); |
---|
| 199 | + |
---|
| 200 | + /* Set the channel info data */ |
---|
| 201 | + iwl_mvm_set_chan_info_chandef(mvm, &cmd->ci, chandef); |
---|
| 202 | + |
---|
| 203 | + iwl_mvm_phy_ctxt_set_rxchain(mvm, &cmd->rxchain_info, |
---|
| 204 | + chains_static, chains_dynamic); |
---|
182 | 205 | } |
---|
183 | 206 | |
---|
184 | 207 | /* |
---|
.. | .. |
---|
191 | 214 | struct iwl_mvm_phy_ctxt *ctxt, |
---|
192 | 215 | struct cfg80211_chan_def *chandef, |
---|
193 | 216 | u8 chains_static, u8 chains_dynamic, |
---|
194 | | - u32 action, u32 apply_time) |
---|
| 217 | + u32 action) |
---|
195 | 218 | { |
---|
196 | | - struct iwl_phy_context_cmd cmd; |
---|
197 | 219 | int ret; |
---|
| 220 | + int ver = iwl_fw_lookup_cmd_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP, |
---|
| 221 | + PHY_CONTEXT_CMD, 1); |
---|
198 | 222 | |
---|
199 | | - /* Set the command header fields */ |
---|
200 | | - iwl_mvm_phy_ctxt_cmd_hdr(ctxt, &cmd, action, apply_time); |
---|
| 223 | + if (ver == 3) { |
---|
| 224 | + struct iwl_phy_context_cmd cmd = {}; |
---|
201 | 225 | |
---|
202 | | - /* Set the command data */ |
---|
203 | | - iwl_mvm_phy_ctxt_cmd_data(mvm, &cmd, chandef, |
---|
204 | | - chains_static, chains_dynamic); |
---|
| 226 | + /* Set the command header fields */ |
---|
| 227 | + iwl_mvm_phy_ctxt_cmd_hdr(ctxt, &cmd, action); |
---|
205 | 228 | |
---|
206 | | - ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD, 0, |
---|
207 | | - sizeof(struct iwl_phy_context_cmd), |
---|
208 | | - &cmd); |
---|
| 229 | + /* Set the command data */ |
---|
| 230 | + iwl_mvm_phy_ctxt_cmd_data(mvm, &cmd, chandef, |
---|
| 231 | + chains_static, |
---|
| 232 | + chains_dynamic); |
---|
| 233 | + |
---|
| 234 | + ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD, |
---|
| 235 | + 0, sizeof(cmd), &cmd); |
---|
| 236 | + } else if (ver < 3) { |
---|
| 237 | + struct iwl_phy_context_cmd_v1 cmd = {}; |
---|
| 238 | + u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm); |
---|
| 239 | + |
---|
| 240 | + /* Set the command header fields */ |
---|
| 241 | + iwl_mvm_phy_ctxt_cmd_hdr(ctxt, |
---|
| 242 | + (struct iwl_phy_context_cmd *)&cmd, |
---|
| 243 | + action); |
---|
| 244 | + |
---|
| 245 | + /* Set the command data */ |
---|
| 246 | + iwl_mvm_phy_ctxt_cmd_data_v1(mvm, &cmd, chandef, |
---|
| 247 | + chains_static, |
---|
| 248 | + chains_dynamic); |
---|
| 249 | + ret = iwl_mvm_send_cmd_pdu(mvm, PHY_CONTEXT_CMD, |
---|
| 250 | + 0, len, &cmd); |
---|
| 251 | + } else { |
---|
| 252 | + IWL_ERR(mvm, "PHY ctxt cmd error ver %d not supported\n", ver); |
---|
| 253 | + return -EOPNOTSUPP; |
---|
| 254 | + } |
---|
| 255 | + |
---|
| 256 | + |
---|
209 | 257 | if (ret) |
---|
210 | 258 | IWL_ERR(mvm, "PHY ctxt cmd error. ret=%d\n", ret); |
---|
211 | 259 | return ret; |
---|
.. | .. |
---|
226 | 274 | |
---|
227 | 275 | return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, |
---|
228 | 276 | chains_static, chains_dynamic, |
---|
229 | | - FW_CTXT_ACTION_ADD, 0); |
---|
| 277 | + FW_CTXT_ACTION_ADD); |
---|
230 | 278 | } |
---|
231 | 279 | |
---|
232 | 280 | /* |
---|
.. | .. |
---|
260 | 308 | /* ... remove it here ...*/ |
---|
261 | 309 | ret = iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, |
---|
262 | 310 | chains_static, chains_dynamic, |
---|
263 | | - FW_CTXT_ACTION_REMOVE, 0); |
---|
| 311 | + FW_CTXT_ACTION_REMOVE); |
---|
264 | 312 | if (ret) |
---|
265 | 313 | return ret; |
---|
266 | 314 | |
---|
.. | .. |
---|
272 | 320 | ctxt->width = chandef->width; |
---|
273 | 321 | return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, |
---|
274 | 322 | chains_static, chains_dynamic, |
---|
275 | | - action, 0); |
---|
| 323 | + action); |
---|
276 | 324 | } |
---|
277 | 325 | |
---|
278 | 326 | void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt) |
---|
.. | .. |
---|
292 | 340 | if (ctxt->ref == 0) { |
---|
293 | 341 | struct ieee80211_channel *chan; |
---|
294 | 342 | struct cfg80211_chan_def chandef; |
---|
| 343 | + struct ieee80211_supported_band *sband = NULL; |
---|
| 344 | + enum nl80211_band band = NL80211_BAND_2GHZ; |
---|
295 | 345 | |
---|
296 | | - chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0]; |
---|
| 346 | + while (!sband && band < NUM_NL80211_BANDS) |
---|
| 347 | + sband = mvm->hw->wiphy->bands[band++]; |
---|
| 348 | + |
---|
| 349 | + if (WARN_ON(!sband)) |
---|
| 350 | + return; |
---|
| 351 | + |
---|
| 352 | + chan = &sband->channels[0]; |
---|
| 353 | + |
---|
297 | 354 | cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT); |
---|
298 | 355 | iwl_mvm_phy_ctxt_changed(mvm, ctxt, &chandef, 1, 1); |
---|
299 | 356 | } |
---|