iwlwifi: mvm: Ability to work with packed usniffer image
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / mvm / fw.c
CommitLineData
8ca151b5
JB
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
51368bf7 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
8b4139dc 9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
8ca151b5
JB
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23 * USA
24 *
25 * The full GNU General Public License is included in this distribution
410dc5aa 26 * in the file called COPYING.
8ca151b5
JB
27 *
28 * Contact Information:
29 * Intel Linux Wireless <ilw@linux.intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
51368bf7 34 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
8b4139dc 35 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
8ca151b5
JB
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 *
42 * * Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in
46 * the documentation and/or other materials provided with the
47 * distribution.
48 * * Neither the name Intel Corporation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63 *
64 *****************************************************************************/
65#include <net/mac80211.h>
66
67#include "iwl-trans.h"
68#include "iwl-op-mode.h"
69#include "iwl-fw.h"
70#include "iwl-debug.h"
71#include "iwl-csr.h" /* for iwl_mvm_rx_card_state_notif */
72#include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */
73#include "iwl-eeprom-parse.h"
74
75#include "mvm.h"
76#include "iwl-phy-db.h"
77
78#define MVM_UCODE_ALIVE_TIMEOUT HZ
79#define MVM_UCODE_CALIB_TIMEOUT (2*HZ)
80
81#define UCODE_VALID_OK cpu_to_le32(0x1)
82
8ca151b5
JB
83struct iwl_mvm_alive_data {
84 bool valid;
85 u32 scd_base_addr;
86};
87
88static inline const struct fw_img *
89iwl_get_ucode_image(struct iwl_mvm *mvm, enum iwl_ucode_type ucode_type)
90{
91 if (ucode_type >= IWL_UCODE_TYPE_MAX)
92 return NULL;
93
94 return &mvm->fw->img[ucode_type];
95}
96
97static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
98{
99 struct iwl_tx_ant_cfg_cmd tx_ant_cmd = {
100 .valid = cpu_to_le32(valid_tx_ant),
101 };
102
33223542 103 IWL_DEBUG_FW(mvm, "select valid tx ant: %u\n", valid_tx_ant);
a1022927 104 return iwl_mvm_send_cmd_pdu(mvm, TX_ANT_CONFIGURATION_CMD, 0,
8ca151b5
JB
105 sizeof(tx_ant_cmd), &tx_ant_cmd);
106}
107
108static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
109 struct iwl_rx_packet *pkt, void *data)
110{
111 struct iwl_mvm *mvm =
112 container_of(notif_wait, struct iwl_mvm, notif_wait);
113 struct iwl_mvm_alive_data *alive_data = data;
114 struct mvm_alive_resp *palive;
01a9ca51
EH
115 struct mvm_alive_resp_ver2 *palive2;
116
117 if (iwl_rx_packet_payload_len(pkt) == sizeof(*palive)) {
118 palive = (void *)pkt->data;
119
120 mvm->support_umac_log = false;
121 mvm->error_event_table =
122 le32_to_cpu(palive->error_event_table_ptr);
123 mvm->log_event_table = le32_to_cpu(palive->log_event_table_ptr);
124 alive_data->scd_base_addr = le32_to_cpu(palive->scd_base_ptr);
125
126 alive_data->valid = le16_to_cpu(palive->status) ==
127 IWL_ALIVE_STATUS_OK;
128 IWL_DEBUG_FW(mvm,
129 "Alive VER1 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
130 le16_to_cpu(palive->status), palive->ver_type,
131 palive->ver_subtype, palive->flags);
132 } else {
133 palive2 = (void *)pkt->data;
134
01a9ca51
EH
135 mvm->error_event_table =
136 le32_to_cpu(palive2->error_event_table_ptr);
137 mvm->log_event_table =
138 le32_to_cpu(palive2->log_event_table_ptr);
139 alive_data->scd_base_addr = le32_to_cpu(palive2->scd_base_ptr);
140 mvm->umac_error_event_table =
141 le32_to_cpu(palive2->error_info_addr);
91479b64
EH
142 mvm->sf_space.addr = le32_to_cpu(palive2->st_fwrd_addr);
143 mvm->sf_space.size = le32_to_cpu(palive2->st_fwrd_size);
01a9ca51
EH
144
145 alive_data->valid = le16_to_cpu(palive2->status) ==
146 IWL_ALIVE_STATUS_OK;
ffa70264
EG
147 if (mvm->umac_error_event_table)
148 mvm->support_umac_log = true;
149
01a9ca51
EH
150 IWL_DEBUG_FW(mvm,
151 "Alive VER2 ucode status 0x%04x revision 0x%01X 0x%01X flags 0x%01X\n",
152 le16_to_cpu(palive2->status), palive2->ver_type,
153 palive2->ver_subtype, palive2->flags);
154
155 IWL_DEBUG_FW(mvm,
156 "UMAC version: Major - 0x%x, Minor - 0x%x\n",
157 palive2->umac_major, palive2->umac_minor);
158 }
8ca151b5
JB
159
160 return true;
161}
162
163static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait,
164 struct iwl_rx_packet *pkt, void *data)
165{
166 struct iwl_phy_db *phy_db = data;
167
168 if (pkt->hdr.cmd != CALIB_RES_NOTIF_PHY_DB) {
169 WARN_ON(pkt->hdr.cmd != INIT_COMPLETE_NOTIF);
170 return true;
171 }
172
173 WARN_ON(iwl_phy_db_set_section(phy_db, pkt, GFP_ATOMIC));
174
175 return false;
176}
177
178static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
179 enum iwl_ucode_type ucode_type)
180{
181 struct iwl_notification_wait alive_wait;
182 struct iwl_mvm_alive_data alive_data;
183 const struct fw_img *fw;
184 int ret, i;
185 enum iwl_ucode_type old_type = mvm->cur_ucode;
186 static const u8 alive_cmd[] = { MVM_ALIVE };
91479b64 187 struct iwl_sf_region st_fwrd_space;
8ca151b5 188
61df750c
EH
189 if (ucode_type == IWL_UCODE_REGULAR &&
190 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_CUSTOM) &&
191 iwl_fw_dbg_conf_enabled(mvm->fw, FW_DBG_CUSTOM))
192 fw = iwl_get_ucode_image(mvm, IWL_UCODE_REGULAR_USNIFFER);
193 else
194 fw = iwl_get_ucode_image(mvm, ucode_type);
befe9b6f 195 if (WARN_ON(!fw))
8ca151b5 196 return -EINVAL;
befe9b6f
JB
197 mvm->cur_ucode = ucode_type;
198 mvm->ucode_loaded = false;
8ca151b5
JB
199
200 iwl_init_notification_wait(&mvm->notif_wait, &alive_wait,
201 alive_cmd, ARRAY_SIZE(alive_cmd),
202 iwl_alive_fn, &alive_data);
203
204 ret = iwl_trans_start_fw(mvm->trans, fw, ucode_type == IWL_UCODE_INIT);
205 if (ret) {
206 mvm->cur_ucode = old_type;
207 iwl_remove_notification(&mvm->notif_wait, &alive_wait);
208 return ret;
209 }
210
211 /*
212 * Some things may run in the background now, but we
213 * just wait for the ALIVE notification here.
214 */
215 ret = iwl_wait_notification(&mvm->notif_wait, &alive_wait,
216 MVM_UCODE_ALIVE_TIMEOUT);
217 if (ret) {
218 mvm->cur_ucode = old_type;
219 return ret;
220 }
221
222 if (!alive_data.valid) {
223 IWL_ERR(mvm, "Loaded ucode is not valid!\n");
224 mvm->cur_ucode = old_type;
225 return -EIO;
226 }
227
91479b64
EH
228 /*
229 * update the sdio allocation according to the pointer we get in the
230 * alive notification.
231 */
232 st_fwrd_space.addr = mvm->sf_space.addr;
233 st_fwrd_space.size = mvm->sf_space.size;
234 ret = iwl_trans_update_sf(mvm->trans, &st_fwrd_space);
82e8aea0
ES
235 if (ret) {
236 IWL_ERR(mvm, "Failed to update SF size. ret %d\n", ret);
237 return ret;
238 }
91479b64 239
8ca151b5
JB
240 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr);
241
242 /*
243 * Note: all the queues are enabled as part of the interface
244 * initialization, but in firmware restart scenarios they
245 * could be stopped, so wake them up. In firmware restart,
246 * mac80211 will have the queues stopped as well until the
247 * reconfiguration completes. During normal startup, they
248 * will be empty.
249 */
250
251 for (i = 0; i < IWL_MAX_HW_QUEUES; i++) {
19e737c9 252 if (i < mvm->first_agg_queue && i != IWL_MVM_CMD_QUEUE)
8ca151b5
JB
253 mvm->queue_to_mac80211[i] = i;
254 else
255 mvm->queue_to_mac80211[i] = IWL_INVALID_MAC80211_QUEUE;
8ca151b5
JB
256 }
257
df197c00
JB
258 for (i = 0; i < IEEE80211_MAX_QUEUES; i++)
259 atomic_set(&mvm->mac80211_queue_stop_count[i], 0);
8ca151b5
JB
260
261 mvm->ucode_loaded = true;
262
263 return 0;
264}
8ca151b5
JB
265
266static int iwl_send_phy_cfg_cmd(struct iwl_mvm *mvm)
267{
268 struct iwl_phy_cfg_cmd phy_cfg_cmd;
269 enum iwl_ucode_type ucode_type = mvm->cur_ucode;
270
271 /* Set parameters */
6221d47c 272 phy_cfg_cmd.phy_cfg = cpu_to_le32(mvm->fw->phy_config);
8ca151b5
JB
273 phy_cfg_cmd.calib_control.event_trigger =
274 mvm->fw->default_calib[ucode_type].event_trigger;
275 phy_cfg_cmd.calib_control.flow_trigger =
276 mvm->fw->default_calib[ucode_type].flow_trigger;
277
278 IWL_DEBUG_INFO(mvm, "Sending Phy CFG command: 0x%x\n",
279 phy_cfg_cmd.phy_cfg);
280
a1022927 281 return iwl_mvm_send_cmd_pdu(mvm, PHY_CONFIGURATION_CMD, 0,
8ca151b5
JB
282 sizeof(phy_cfg_cmd), &phy_cfg_cmd);
283}
284
8ca151b5
JB
285int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
286{
287 struct iwl_notification_wait calib_wait;
288 static const u8 init_complete[] = {
289 INIT_COMPLETE_NOTIF,
290 CALIB_RES_NOTIF_PHY_DB
291 };
292 int ret;
293
294 lockdep_assert_held(&mvm->mutex);
295
31b8b343 296 if (WARN_ON_ONCE(mvm->init_ucode_complete || mvm->calibrating))
8ca151b5
JB
297 return 0;
298
299 iwl_init_notification_wait(&mvm->notif_wait,
300 &calib_wait,
301 init_complete,
302 ARRAY_SIZE(init_complete),
303 iwl_wait_phy_db_entry,
304 mvm->phy_db);
305
306 /* Will also start the device */
307 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_INIT);
308 if (ret) {
309 IWL_ERR(mvm, "Failed to start INIT ucode: %d\n", ret);
310 goto error;
311 }
312
ae397472 313 ret = iwl_send_bt_init_conf(mvm);
931d4160
EG
314 if (ret)
315 goto error;
316
81a67e32 317 /* Read the NVM only at driver load time, no need to do this twice */
8ca151b5
JB
318 if (read_nvm) {
319 /* Read nvm */
14b485f0 320 ret = iwl_nvm_init(mvm, true);
8ca151b5
JB
321 if (ret) {
322 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret);
323 goto error;
324 }
325 }
326
81a67e32 327 /* In case we read the NVM from external file, load it to the NIC */
e02a9d60 328 if (mvm->nvm_file_name)
81a67e32
EL
329 iwl_mvm_load_nvm_to_nic(mvm);
330
8ca151b5
JB
331 ret = iwl_nvm_check_version(mvm->nvm_data, mvm->trans);
332 WARN_ON(ret);
333
4f59334b
EH
334 /*
335 * abort after reading the nvm in case RF Kill is on, we will complete
336 * the init seq later when RF kill will switch to off
337 */
9ee718aa 338 if (iwl_mvm_is_radio_killed(mvm)) {
4f59334b
EH
339 IWL_DEBUG_RF_KILL(mvm,
340 "jump over all phy activities due to RF kill\n");
341 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
a4082843
AN
342 ret = 1;
343 goto out;
4f59334b
EH
344 }
345
31b8b343
EG
346 mvm->calibrating = true;
347
e07cbb53 348 /* Send TX valid antennas before triggering calibrations */
4ed735e7 349 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
e07cbb53
DS
350 if (ret)
351 goto error;
352
8ca151b5
JB
353 /*
354 * Send phy configurations command to init uCode
355 * to start the 16.0 uCode init image internal calibrations.
356 */
357 ret = iwl_send_phy_cfg_cmd(mvm);
358 if (ret) {
359 IWL_ERR(mvm, "Failed to run INIT calibrations: %d\n",
360 ret);
361 goto error;
362 }
363
364 /*
365 * Some things may run in the background now, but we
366 * just wait for the calibration complete notification.
367 */
368 ret = iwl_wait_notification(&mvm->notif_wait, &calib_wait,
369 MVM_UCODE_CALIB_TIMEOUT);
370 if (!ret)
ff116373 371 mvm->init_ucode_complete = true;
31b8b343
EG
372
373 if (ret && iwl_mvm_is_radio_killed(mvm)) {
374 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
375 ret = 1;
376 }
8ca151b5
JB
377 goto out;
378
379error:
380 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
381out:
31b8b343 382 mvm->calibrating = false;
a4082843 383 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) {
8ca151b5
JB
384 /* we want to debug INIT and we have no NVM - fake */
385 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
386 sizeof(struct ieee80211_channel) +
387 sizeof(struct ieee80211_rate),
388 GFP_KERNEL);
389 if (!mvm->nvm_data)
390 return -ENOMEM;
8ca151b5
JB
391 mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
392 mvm->nvm_data->bands[0].n_channels = 1;
393 mvm->nvm_data->bands[0].n_bitrates = 1;
394 mvm->nvm_data->bands[0].bitrates =
395 (void *)mvm->nvm_data->channels + 1;
396 mvm->nvm_data->bands[0].bitrates->hw_value = 10;
397 }
398
399 return ret;
400}
401
6a951267
LK
402static int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm,
403 enum iwl_fw_dbg_conf conf_id)
404{
405 u8 *ptr;
406 int ret;
407 int i;
408
409 if (WARN_ONCE(conf_id >= ARRAY_SIZE(mvm->fw->dbg_conf_tlv),
410 "Invalid configuration %d\n", conf_id))
411 return -EINVAL;
412
413 if (!mvm->fw->dbg_conf_tlv[conf_id])
414 return -EINVAL;
415
416 if (mvm->fw_dbg_conf != FW_DBG_INVALID)
417 IWL_WARN(mvm, "FW already configured (%d) - re-configuring\n",
418 mvm->fw_dbg_conf);
419
420 /* Send all HCMDs for configuring the FW debug */
421 ptr = (void *)&mvm->fw->dbg_conf_tlv[conf_id]->hcmd;
422 for (i = 0; i < mvm->fw->dbg_conf_tlv[conf_id]->num_of_hcmds; i++) {
423 struct iwl_fw_dbg_conf_hcmd *cmd = (void *)ptr;
424
425 ret = iwl_mvm_send_cmd_pdu(mvm, cmd->id, 0,
426 le16_to_cpu(cmd->len), cmd->data);
427 if (ret)
428 return ret;
429
430 ptr += sizeof(*cmd);
431 ptr += le16_to_cpu(cmd->len);
432 }
433
434 mvm->fw_dbg_conf = conf_id;
435 return ret;
436}
437
8ca151b5
JB
438int iwl_mvm_up(struct iwl_mvm *mvm)
439{
440 int ret, i;
53a9d61e
IP
441 struct ieee80211_channel *chan;
442 struct cfg80211_chan_def chandef;
8ca151b5
JB
443
444 lockdep_assert_held(&mvm->mutex);
445
446 ret = iwl_trans_start_hw(mvm->trans);
447 if (ret)
448 return ret;
449
ff116373
EL
450 /*
451 * If we haven't completed the run of the init ucode during
452 * module loading, load init ucode now
453 * (for example, if we were in RFKILL)
454 */
455 if (!mvm->init_ucode_complete) {
8ca151b5
JB
456 ret = iwl_run_init_mvm_ucode(mvm, false);
457 if (ret && !iwlmvm_mod_params.init_dbg) {
458 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
4f59334b
EH
459 /* this can't happen */
460 if (WARN_ON(ret > 0))
461 ret = -ERFKILL;
8ca151b5
JB
462 goto error;
463 }
a4082843
AN
464 if (!iwlmvm_mod_params.init_dbg) {
465 /*
466 * should stop and start HW since that INIT
467 * image just loaded
468 */
469 iwl_trans_stop_device(mvm->trans);
470 ret = iwl_trans_start_hw(mvm->trans);
471 if (ret)
472 return ret;
473 }
8ca151b5
JB
474 }
475
476 if (iwlmvm_mod_params.init_dbg)
477 return 0;
478
479 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
480 if (ret) {
481 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
482 goto error;
483 }
484
1f3b0ff8
LE
485 ret = iwl_mvm_sf_update(mvm, NULL, false);
486 if (ret)
487 IWL_ERR(mvm, "Failed to initialize Smart Fifo\n");
488
6a951267
LK
489 mvm->fw_dbg_conf = FW_DBG_INVALID;
490 iwl_mvm_start_fw_dbg_conf(mvm, FW_DBG_CUSTOM);
491
4ed735e7 492 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
8ca151b5
JB
493 if (ret)
494 goto error;
495
931d4160
EG
496 ret = iwl_send_bt_init_conf(mvm);
497 if (ret)
498 goto error;
499
8ca151b5
JB
500 /* Send phy db control command and then phy db calibration*/
501 ret = iwl_send_phy_db_data(mvm->phy_db);
502 if (ret)
503 goto error;
504
505 ret = iwl_send_phy_cfg_cmd(mvm);
506 if (ret)
507 goto error;
508
509 /* init the fw <-> mac80211 STA mapping */
510 for (i = 0; i < IWL_MVM_STATION_COUNT; i++)
511 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
512
1d3c3f63
AN
513 mvm->tdls_cs.peer.sta_id = IWL_MVM_STATION_COUNT;
514
b2b7875b
JB
515 /* reset quota debouncing buffer - 0xff will yield invalid data */
516 memset(&mvm->last_quota_cmd, 0xff, sizeof(mvm->last_quota_cmd));
517
8ca151b5
JB
518 /* Add auxiliary station for scanning */
519 ret = iwl_mvm_add_aux_sta(mvm);
520 if (ret)
521 goto error;
522
53a9d61e
IP
523 /* Add all the PHY contexts */
524 chan = &mvm->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels[0];
525 cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
526 for (i = 0; i < NUM_PHY_CTX; i++) {
527 /*
528 * The channel used here isn't relevant as it's
529 * going to be overwritten in the other flows.
530 * For now use the first channel we have.
531 */
532 ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i],
533 &chandef, 1, 1);
534 if (ret)
535 goto error;
536 }
8ca151b5 537
0c0e2c71
IY
538 /* Initialize tx backoffs to the minimal possible */
539 iwl_mvm_tt_tx_backoff(mvm, 0);
540
9180ac50
EG
541 if (mvm->trans->ltr_enabled) {
542 struct iwl_ltr_config_cmd cmd = {
543 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE),
544 };
545
546 WARN_ON(iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0,
547 sizeof(cmd), &cmd));
548 }
549
c1cb92fc 550 ret = iwl_mvm_power_update_device(mvm);
64b928c4
AB
551 if (ret)
552 goto error;
553
d2496221
DS
554 if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
555 ret = iwl_mvm_config_scan(mvm);
556 if (ret)
557 goto error;
558 }
559
7498cf4c
EP
560 /* allow FW/transport low power modes if not during restart */
561 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
562 iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
563
53a9d61e 564 IWL_DEBUG_INFO(mvm, "RT uCode started.\n");
8ca151b5
JB
565 return 0;
566 error:
567 iwl_trans_stop_device(mvm->trans);
568 return ret;
569}
570
571int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
572{
573 int ret, i;
574
575 lockdep_assert_held(&mvm->mutex);
576
577 ret = iwl_trans_start_hw(mvm->trans);
578 if (ret)
579 return ret;
580
581 ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_WOWLAN);
582 if (ret) {
583 IWL_ERR(mvm, "Failed to start WoWLAN firmware: %d\n", ret);
584 goto error;
585 }
586
4ed735e7 587 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
8ca151b5
JB
588 if (ret)
589 goto error;
590
591 /* Send phy db control command and then phy db calibration*/
592 ret = iwl_send_phy_db_data(mvm->phy_db);
593 if (ret)
594 goto error;
595
596 ret = iwl_send_phy_cfg_cmd(mvm);
597 if (ret)
598 goto error;
599
600 /* init the fw <-> mac80211 STA mapping */
601 for (i = 0; i < IWL_MVM_STATION_COUNT; i++)
602 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);
603
604 /* Add auxiliary station for scanning */
605 ret = iwl_mvm_add_aux_sta(mvm);
606 if (ret)
607 goto error;
608
609 return 0;
610 error:
611 iwl_trans_stop_device(mvm->trans);
612 return ret;
613}
614
615int iwl_mvm_rx_card_state_notif(struct iwl_mvm *mvm,
616 struct iwl_rx_cmd_buffer *rxb,
617 struct iwl_device_cmd *cmd)
618{
619 struct iwl_rx_packet *pkt = rxb_addr(rxb);
620 struct iwl_card_state_notif *card_state_notif = (void *)pkt->data;
621 u32 flags = le32_to_cpu(card_state_notif->flags);
622
623 IWL_DEBUG_RF_KILL(mvm, "Card state received: HW:%s SW:%s CT:%s\n",
624 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
625 (flags & SW_CARD_DISABLED) ? "Kill" : "On",
626 (flags & CT_KILL_CARD_DISABLED) ?
627 "Reached" : "Not reached");
628
8ca151b5
JB
629 return 0;
630}
631
632int iwl_mvm_rx_radio_ver(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
633 struct iwl_device_cmd *cmd)
634{
635 struct iwl_rx_packet *pkt = rxb_addr(rxb);
636 struct iwl_radio_version_notif *radio_version = (void *)pkt->data;
637
638 /* TODO: what to do with that? */
639 IWL_DEBUG_INFO(mvm,
640 "Radio version: flavor: 0x%08x, step 0x%08x, dash 0x%08x\n",
641 le32_to_cpu(radio_version->radio_flavor),
642 le32_to_cpu(radio_version->radio_step),
643 le32_to_cpu(radio_version->radio_dash));
644 return 0;
645}
30269c12
CRI
646
647int iwl_mvm_rx_mfuart_notif(struct iwl_mvm *mvm,
648 struct iwl_rx_cmd_buffer *rxb,
649 struct iwl_device_cmd *cmd)
650{
651 struct iwl_rx_packet *pkt = rxb_addr(rxb);
652 struct iwl_mfuart_load_notif *mfuart_notif = (void *)pkt->data;
653
654 IWL_DEBUG_INFO(mvm,
655 "MFUART: installed ver: 0x%08x, external ver: 0x%08x, status: 0x%08x, duration: 0x%08x\n",
656 le32_to_cpu(mfuart_notif->installed_ver),
657 le32_to_cpu(mfuart_notif->external_ver),
658 le32_to_cpu(mfuart_notif->status),
659 le32_to_cpu(mfuart_notif->duration));
660 return 0;
661}
This page took 0.16027 seconds and 5 git commands to generate.