Esempio n. 1
0
File: ops.c Progetto: 03199618/linux
static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode)
{
	struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
	int i;

	iwl_mvm_leds_exit(mvm);

	iwl_mvm_tt_exit(mvm);

	ieee80211_unregister_hw(mvm->hw);

	kfree(mvm->scan_cmd);

#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_IWLWIFI_DEBUGFS)
	kfree(mvm->d3_resume_sram);
#endif

	iwl_trans_stop_hw(mvm->trans, true);

	iwl_phy_db_free(mvm->phy_db);
	mvm->phy_db = NULL;

	iwl_free_nvm_data(mvm->nvm_data);
	for (i = 0; i < NVM_NUM_OF_SECTIONS; i++)
		kfree(mvm->nvm_sections[i].data);

	ieee80211_free_hw(mvm->hw);
}
Esempio n. 2
0
static void iwl_mvm_mac_stop(struct ieee80211_hw *hw)
{
    struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);

    flush_work(&mvm->async_handlers_wk);

    mutex_lock(&mvm->mutex);
    /* async_handlers_wk is now blocked */

    /*
     * The work item could be running or queued if the
     * ROC time event stops just as we get here.
     */
    cancel_work_sync(&mvm->roc_done_wk);

    iwl_trans_stop_device(mvm->trans);
    iwl_trans_stop_hw(mvm->trans, false);

    iwl_mvm_async_handlers_purge(mvm);
    /* async_handlers_list is empty and will stay empty: HW is stopped */

    /* the fw is stopped, the aux sta is dead: clean up driver state */
    iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta);

    mutex_unlock(&mvm->mutex);

    /*
     * The worker might have been waiting for the mutex, let it run and
     * discover that its list is now empty.
     */
    cancel_work_sync(&mvm->async_handlers_wk);
}
Esempio n. 3
0
static void check_exit_ctkill(struct work_struct *work)
{
	struct iwl_mvm_tt_mgmt *tt;
	struct iwl_mvm *mvm;
	u32 duration;
	s32 temp;

	tt = container_of(work, struct iwl_mvm_tt_mgmt, ct_kill_exit.work);
	mvm = container_of(tt, struct iwl_mvm, thermal_throttle);

	duration = tt->params->ct_kill_duration;

	iwl_trans_start_hw(mvm->trans);
	temp = check_nic_temperature(mvm);
	iwl_trans_stop_hw(mvm->trans, false);

	if (temp < MIN_TEMPERATURE || temp > MAX_TEMPERATURE) {
		IWL_DEBUG_TEMP(mvm, "Failed to measure NIC temperature\n");
		goto reschedule;
	}
	IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp);

	if (temp <= tt->params->ct_kill_exit) {
		iwl_mvm_exit_ctkill(mvm);
		return;
	}

reschedule:
	schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit,
			      round_jiffies(duration * HZ));
}
Esempio n. 4
0
static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
{
    iwl_trans_stop_device(mvm->trans);
    iwl_trans_stop_hw(mvm->trans, false);

    mvm->scan_status = IWL_MVM_SCAN_NONE;

    /* just in case one was running */
    ieee80211_remain_on_channel_expired(mvm->hw);

    ieee80211_iterate_active_interfaces_atomic(
        mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
        iwl_mvm_cleanup_iterator, mvm);

    memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
    memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained));

    ieee80211_wake_queues(mvm->hw);

    mvm->vif_count = 0;
}
Esempio n. 5
0
static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode)
{
	struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
	int i;

	iwl_mvm_leds_exit(mvm);

	ieee80211_unregister_hw(mvm->hw);

	kfree(mvm->scan_cmd);

	iwl_trans_stop_hw(mvm->trans, true);

	iwl_phy_db_free(mvm->phy_db);
	mvm->phy_db = NULL;

	kfree(mvm->eeprom_blob);
	iwl_free_nvm_data(mvm->nvm_data);
	for (i = 0; i < NVM_NUM_OF_SECTIONS; i++)
		kfree(mvm->nvm_sections[i].data);

	ieee80211_free_hw(mvm->hw);
}
Esempio n. 6
0
File: ops.c Progetto: 03199618/linux
static struct iwl_op_mode *
iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
		      const struct iwl_fw *fw, struct dentry *dbgfs_dir)
{
	struct ieee80211_hw *hw;
	struct iwl_op_mode *op_mode;
	struct iwl_mvm *mvm;
	struct iwl_trans_config trans_cfg = {};
	static const u8 no_reclaim_cmds[] = {
		TX_CMD,
	};
	int err, scan_size;

	/********************************
	 * 1. Allocating and configuring HW data
	 ********************************/
	hw = ieee80211_alloc_hw(sizeof(struct iwl_op_mode) +
				sizeof(struct iwl_mvm),
				&iwl_mvm_hw_ops);
	if (!hw)
		return NULL;

	op_mode = hw->priv;
	op_mode->ops = &iwl_mvm_ops;
	op_mode->trans = trans;

	mvm = IWL_OP_MODE_GET_MVM(op_mode);
	mvm->dev = trans->dev;
	mvm->trans = trans;
	mvm->cfg = cfg;
	mvm->fw = fw;
	mvm->hw = hw;

	mvm->restart_fw = iwlwifi_mod_params.restart_fw ? -1 : 0;

	mutex_init(&mvm->mutex);
	spin_lock_init(&mvm->async_handlers_lock);
	INIT_LIST_HEAD(&mvm->time_event_list);
	INIT_LIST_HEAD(&mvm->async_handlers_list);
	spin_lock_init(&mvm->time_event_lock);

	INIT_WORK(&mvm->async_handlers_wk, iwl_mvm_async_handlers_wk);
	INIT_WORK(&mvm->roc_done_wk, iwl_mvm_roc_done_wk);
	INIT_WORK(&mvm->sta_drained_wk, iwl_mvm_sta_drained_wk);

	SET_IEEE80211_DEV(mvm->hw, mvm->trans->dev);

	/*
	 * Populate the state variables that the transport layer needs
	 * to know about.
	 */
	trans_cfg.op_mode = op_mode;
	trans_cfg.no_reclaim_cmds = no_reclaim_cmds;
	trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds);
	trans_cfg.rx_buf_size_8k = iwlwifi_mod_params.amsdu_size_8K;

	if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DW_BC_TABLE)
		trans_cfg.bc_table_dword = true;

	if (!iwlwifi_mod_params.wd_disable)
		trans_cfg.queue_watchdog_timeout = cfg->base_params->wd_timeout;
	else
		trans_cfg.queue_watchdog_timeout = IWL_WATCHDOG_DISABLED;

	trans_cfg.command_names = iwl_mvm_cmd_strings;

	trans_cfg.cmd_queue = IWL_MVM_CMD_QUEUE;
	trans_cfg.cmd_fifo = IWL_MVM_CMD_FIFO;

	snprintf(mvm->hw->wiphy->fw_version,
		 sizeof(mvm->hw->wiphy->fw_version),
		 "%s", fw->fw_version);

	/* Configure transport layer */
	iwl_trans_configure(mvm->trans, &trans_cfg);

	trans->rx_mpdu_cmd = REPLY_RX_MPDU_CMD;
	trans->rx_mpdu_cmd_hdr_size = sizeof(struct iwl_rx_mpdu_res_start);

	/* set up notification wait support */
	iwl_notification_wait_init(&mvm->notif_wait);

	/* Init phy db */
	mvm->phy_db = iwl_phy_db_init(trans);
	if (!mvm->phy_db) {
		IWL_ERR(mvm, "Cannot init phy_db\n");
		goto out_free;
	}

	IWL_INFO(mvm, "Detected %s, REV=0x%X\n",
		 mvm->cfg->name, mvm->trans->hw_rev);

	err = iwl_trans_start_hw(mvm->trans);
	if (err)
		goto out_free;

	iwl_mvm_tt_initialize(mvm);

	mutex_lock(&mvm->mutex);
	err = iwl_run_init_mvm_ucode(mvm, true);
	mutex_unlock(&mvm->mutex);
	/* returns 0 if successful, 1 if success but in rfkill */
	if (err < 0 && !iwlmvm_mod_params.init_dbg) {
		IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", err);
		goto out_free;
	}

	/* Stop the hw after the ALIVE and NVM has been read */
	if (!iwlmvm_mod_params.init_dbg)
		iwl_trans_stop_hw(mvm->trans, false);

	scan_size = sizeof(struct iwl_scan_cmd) +
		mvm->fw->ucode_capa.max_probe_length +
		(MAX_NUM_SCAN_CHANNELS * sizeof(struct iwl_scan_channel));
	mvm->scan_cmd = kmalloc(scan_size, GFP_KERNEL);
	if (!mvm->scan_cmd)
		goto out_free;

	err = iwl_mvm_mac_setup_register(mvm);
	if (err)
		goto out_free;

	err = iwl_mvm_dbgfs_register(mvm, dbgfs_dir);
	if (err)
		goto out_unregister;

	if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD)
		mvm->pm_ops = &pm_mac_ops;
	else
		mvm->pm_ops = &pm_legacy_ops;

	memset(&mvm->rx_stats, 0, sizeof(struct mvm_statistics_rx));

	return op_mode;

 out_unregister:
	ieee80211_unregister_hw(mvm->hw);
 out_free:
	iwl_phy_db_free(mvm->phy_db);
	kfree(mvm->scan_cmd);
	iwl_trans_stop_hw(trans, true);
	ieee80211_free_hw(mvm->hw);
	return NULL;
}
Esempio n. 7
0
File: fw.c Progetto: 03199618/linux
int iwl_mvm_up(struct iwl_mvm *mvm)
{
	int ret, i;
	struct ieee80211_channel *chan;
	struct cfg80211_chan_def chandef;

	lockdep_assert_held(&mvm->mutex);

	ret = iwl_trans_start_hw(mvm->trans);
	if (ret)
		return ret;

	/* If we were in RFKILL during module loading, load init ucode now */
	if (!mvm->init_ucode_run) {
		ret = iwl_run_init_mvm_ucode(mvm, false);
		if (ret && !iwlmvm_mod_params.init_dbg) {
			IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);
			/* this can't happen */
			if (WARN_ON(ret > 0))
				ret = -ERFKILL;
			goto error;
		}
		/* should stop & start HW since that INIT image just loaded */
		iwl_trans_stop_hw(mvm->trans, false);
		ret = iwl_trans_start_hw(mvm->trans);
		if (ret)
			return ret;
	}

	if (iwlmvm_mod_params.init_dbg)
		return 0;

	ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
	if (ret) {
		IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
		goto error;
	}

	ret = iwl_send_tx_ant_cfg(mvm, iwl_fw_valid_tx_ant(mvm->fw));
	if (ret)
		goto error;

	ret = iwl_send_bt_prio_tbl(mvm);
	if (ret)
		goto error;

	ret = iwl_send_bt_init_conf(mvm);
	if (ret)
		goto error;

	/* Send phy db control command and then phy db calibration*/
	ret = iwl_send_phy_db_data(mvm->phy_db);
	if (ret)
		goto error;

	ret = iwl_send_phy_cfg_cmd(mvm);
	if (ret)
		goto error;

	/* init the fw <-> mac80211 STA mapping */
	for (i = 0; i < IWL_MVM_STATION_COUNT; i++)
		RCU_INIT_POINTER(mvm->fw_id_to_mac_id[i], NULL);

	/* Add auxiliary station for scanning */
	ret = iwl_mvm_add_aux_sta(mvm);
	if (ret)
		goto error;

	/* Add all the PHY contexts */
	chan = &mvm->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels[0];
	cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
	for (i = 0; i < NUM_PHY_CTX; i++) {
		/*
		 * The channel used here isn't relevant as it's
		 * going to be overwritten in the other flows.
		 * For now use the first channel we have.
		 */
		ret = iwl_mvm_phy_ctxt_add(mvm, &mvm->phy_ctxts[i],
					   &chandef, 1, 1);
		if (ret)
			goto error;
	}

	IWL_DEBUG_INFO(mvm, "RT uCode started.\n");
	return 0;
 error:
	iwl_trans_stop_device(mvm->trans);
	return ret;
}