Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83007196 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by John W. Linville
Browse files

iwlegacy: get rid of ctx structure

parent 20c47eba
Loading
Loading
Loading
Loading
+30 −37
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ il3945_send_beacon_cmd(struct il_priv *il)
		return -ENOMEM;
	}

	rate = il_get_lowest_plcp(il, &il->ctx);
	rate = il_get_lowest_plcp(il);

	frame_size = il3945_hw_get_beacon_cmd(il, frame, rate);

@@ -512,7 +512,7 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
	hdr_len = ieee80211_hdrlen(fc);

	/* Find idx into station table for destination station */
	sta_id = il_sta_id_or_broadcast(il, &il->ctx, info->control.sta);
	sta_id = il_sta_id_or_broadcast(il, info->control.sta);
	if (sta_id == IL_INVALID_STATION) {
		D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1);
		goto drop;
@@ -541,7 +541,6 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
	/* Set up driver data for this TFD */
	memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info));
	txq->txb[q->write_ptr].skb = skb;
	txq->txb[q->write_ptr].ctx = &il->ctx;

	/* Init first empty entry in queue's array of Tx/cmd buffers */
	out_cmd = txq->cmd[idx];
@@ -2208,7 +2207,7 @@ il3945_alive_start(struct il_priv *il)
		active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
	} else {
		/* Initialize our rx_config data */
		il_connection_init_rx_config(il, &il->ctx);
		il_connection_init_rx_config(il);
	}

	/* Configure Bluetooth device coexistence support */
@@ -2217,7 +2216,7 @@ il3945_alive_start(struct il_priv *il)
	set_bit(S_READY, &il->status);

	/* Configure the adapter for unassociated operation */
	il3945_commit_rxon(il, &il->ctx);
	il3945_commit_rxon(il);

	il3945_reg_txpower_periodic(il);

@@ -2249,7 +2248,7 @@ __il3945_down(struct il_priv *il)
	del_timer_sync(&il->watchdog);

	/* Station information will now be cleared in device */
	il_clear_ucode_stations(il, NULL);
	il_clear_ucode_stations(il);
	il_dealloc_bcast_stations(il);
	il_clear_driver_stations(il);

@@ -2335,12 +2334,11 @@ il3945_down(struct il_priv *il)
static int
il3945_alloc_bcast_station(struct il_priv *il)
{
	struct il_rxon_context *ctx = &il->ctx;
	unsigned long flags;
	u8 sta_id;

	spin_lock_irqsave(&il->sta_lock, flags);
	sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL);
	sta_id = il_prep_station(il, il_bcast_addr, false, NULL);
	if (sta_id == IL_INVALID_STATION) {
		IL_ERR("Unable to prepare broadcast station\n");
		spin_unlock_irqrestore(&il->sta_lock, flags);
@@ -2660,14 +2658,12 @@ il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
void
il3945_post_scan(struct il_priv *il)
{
	struct il_rxon_context *ctx = &il->ctx;

	/*
	 * Since setting the RXON may have been deferred while
	 * performing the scan, fire one off if needed
	 */
	if (memcmp(&il->staging, &il->active, sizeof(il->staging)))
		il3945_commit_rxon(il, ctx);
		il3945_commit_rxon(il);
}

static void
@@ -2680,7 +2676,8 @@ il3945_bg_restart(struct work_struct *data)

	if (test_and_clear_bit(S_FW_ERROR, &il->status)) {
		mutex_lock(&il->mutex);
		il->ctx.vif = NULL;
		/* FIXME: vif can be dereferenced */
		il->vif = NULL;
		il->is_open = 0;
		mutex_unlock(&il->mutex);
		il3945_down(il);
@@ -2718,12 +2715,11 @@ il3945_post_associate(struct il_priv *il)
{
	int rc = 0;
	struct ieee80211_conf *conf = NULL;
	struct il_rxon_context *ctx = &il->ctx;

	if (!ctx->vif || !il->is_open)
	if (!il->vif || !il->is_open)
		return;

	D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid,
	D_ASSOC("Associated as %d to: %pM\n", il->vif->bss_conf.aid,
		il->active.bssid_addr);

	if (test_bit(S_EXIT_PENDING, &il->status))
@@ -2734,34 +2730,34 @@ il3945_post_associate(struct il_priv *il)
	conf = &il->hw->conf;

	il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
	il3945_commit_rxon(il, ctx);
	il3945_commit_rxon(il);

	rc = il_send_rxon_timing(il, ctx);
	rc = il_send_rxon_timing(il);
	if (rc)
		IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n");

	il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;

	il->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid);
	il->staging.assoc_id = cpu_to_le16(il->vif->bss_conf.aid);

	D_ASSOC("assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid,
		ctx->vif->bss_conf.beacon_int);
	D_ASSOC("assoc id %d beacon interval %d\n", il->vif->bss_conf.aid,
		il->vif->bss_conf.beacon_int);

	if (ctx->vif->bss_conf.use_short_preamble)
	if (il->vif->bss_conf.use_short_preamble)
		il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
	else
		il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;

	if (il->staging.flags & RXON_FLG_BAND_24G_MSK) {
		if (ctx->vif->bss_conf.use_short_slot)
		if (il->vif->bss_conf.use_short_slot)
			il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
		else
			il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
	}

	il3945_commit_rxon(il, ctx);
	il3945_commit_rxon(il);

	switch (ctx->vif->type) {
	switch (il->vif->type) {
	case NL80211_IFTYPE_STATION:
		il3945_rate_scale_init(il->hw, IL_AP_ID);
		break;
@@ -2770,7 +2766,7 @@ il3945_post_associate(struct il_priv *il)
		break;
	default:
		IL_ERR("%s Should not be called in %d mode\n", __func__,
		       ctx->vif->type);
		      il->vif->type);
		break;
	}
}
@@ -2887,8 +2883,7 @@ il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
void
il3945_config_ap(struct il_priv *il)
{
	struct il_rxon_context *ctx = &il->ctx;
	struct ieee80211_vif *vif = ctx->vif;
	struct ieee80211_vif *vif = il->vif;
	int rc = 0;

	if (test_bit(S_EXIT_PENDING, &il->status))
@@ -2899,10 +2894,10 @@ il3945_config_ap(struct il_priv *il)

		/* RXON - unassoc (to set timing command) */
		il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
		il3945_commit_rxon(il, ctx);
		il3945_commit_rxon(il);

		/* RXON Timing */
		rc = il_send_rxon_timing(il, ctx);
		rc = il_send_rxon_timing(il);
		if (rc)
			IL_WARN("C_RXON_TIMING failed - "
				"Attempting to continue.\n");
@@ -2922,7 +2917,7 @@ il3945_config_ap(struct il_priv *il)
		}
		/* restore RXON assoc */
		il->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
		il3945_commit_rxon(il, ctx);
		il3945_commit_rxon(il);
	}
	il3945_send_beacon_cmd(il);
}
@@ -2955,7 +2950,7 @@ il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
	static_key = !il_is_associated(il);

	if (!static_key) {
		sta_id = il_sta_id_or_broadcast(il, &il->ctx, sta);
		sta_id = il_sta_id_or_broadcast(il, sta);
		if (sta_id == IL_INVALID_STATION)
			return -EINVAL;
	}
@@ -3003,8 +2998,7 @@ il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
	D_INFO("proceeding to add station %pM\n", sta->addr);
	sta_priv->common.sta_id = IL_INVALID_STATION;

	ret =
	    il_add_station_common(il, &il->ctx, sta->addr, is_ap, sta, &sta_id);
	ret = il_add_station_common(il, sta->addr, is_ap, sta, &sta_id);
	if (ret) {
		IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret);
		/* Should we return success if return code is EEXIST ? */
@@ -3184,7 +3178,7 @@ il3945_store_flags(struct device *d, struct device_attribute *attr,
		else {
			D_INFO("Committing rxon.flags = 0x%04X\n", flags);
			il->staging.flags = cpu_to_le32(flags);
			il3945_commit_rxon(il, &il->ctx);
			il3945_commit_rxon(il);
		}
	}
	mutex_unlock(&il->mutex);
@@ -3220,7 +3214,7 @@ il3945_store_filter_flags(struct device *d, struct device_attribute *attr,
			D_INFO("Committing rxon.filter_flags = " "0x%04X\n",
			       filter_flags);
			il->staging.filter_flags = cpu_to_le32(filter_flags);
			il3945_commit_rxon(il, &il->ctx);
			il3945_commit_rxon(il);
		}
	}
	mutex_unlock(&il->mutex);
@@ -3750,8 +3744,7 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
		goto out_release_irq;
	}

	il_set_rxon_channel(il, &il->bands[IEEE80211_BAND_2GHZ].channels[5],
			    &il->ctx);
	il_set_rxon_channel(il, &il->bands[IEEE80211_BAND_2GHZ].channels[5]);
	il3945_setup_deferred_work(il);
	il3945_setup_handlers(il);
	il_power_initialize(il);
+1 −2
Original line number Diff line number Diff line
@@ -927,8 +927,7 @@ il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)

	rcu_read_lock();

	sta =
	    ieee80211_find_sta(il->ctx.vif, il->stations[sta_id].sta.sta.addr);
	sta = ieee80211_find_sta(il->vif, il->stations[sta_id].sta.sta.addr);
	if (!sta) {
		D_RATE("Unable to find station to initialize rate scaling.\n");
		rcu_read_unlock();
+11 −12
Original line number Diff line number Diff line
@@ -1662,7 +1662,7 @@ il3945_hw_reg_set_txpower(struct il_priv *il, s8 power)
}

static int
il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx)
il3945_send_rxon_assoc(struct il_priv *il)
{
	int rc = 0;
	struct il_rx_pkt *pkt;
@@ -1714,7 +1714,7 @@ il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx)
 * a HW tune is required based on the RXON structure changes.
 */
int
il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
il3945_commit_rxon(struct il_priv *il)
{
	/* cast away the const for active_rxon in this function */
	struct il3945_rxon_cmd *active_rxon = (void *)&il->active;
@@ -1735,7 +1735,7 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
	staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
	staging_rxon->flags |= il3945_get_antenna_flags(il);

	rc = il_check_rxon_cmd(il, ctx);
	rc = il_check_rxon_cmd(il);
	if (rc) {
		IL_ERR("Invalid RXON configuration.  Not committing.\n");
		return -EINVAL;
@@ -1744,8 +1744,8 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
	/* If we don't need to send a full RXON, we can use
	 * il3945_rxon_assoc_cmd which is used to reconfigure filter
	 * and other flags for the current radio configuration. */
	if (!il_full_rxon_required(il, &il->ctx)) {
		rc = il_send_rxon_assoc(il, &il->ctx);
	if (!il_full_rxon_required(il)) {
		rc = il_send_rxon_assoc(il);
		if (rc) {
			IL_ERR("Error setting RXON_ASSOC "
			       "configuration (%d).\n", rc);
@@ -1786,8 +1786,8 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
			       "configuration (%d).\n", rc);
			return rc;
		}
		il_clear_ucode_stations(il, &il->ctx);
		il_restore_stations(il, &il->ctx);
		il_clear_ucode_stations(il);
		il_restore_stations(il);
	}

	D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n"
@@ -1801,7 +1801,7 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
	staging_rxon->reserved4 = 0;
	staging_rxon->reserved5 = 0;

	il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto);
	il_set_rxon_hwcrypto(il, !il3945_mod_params.sw_crypto);

	/* Apply the new configuration */
	rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd),
@@ -1814,8 +1814,8 @@ il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
	memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));

	if (!new_assoc) {
		il_clear_ucode_stations(il, &il->ctx);
		il_restore_stations(il, &il->ctx);
		il_clear_ucode_stations(il);
		il_restore_stations(il);
	}

	/* If we issue a new RXON command which required a tune then we must
@@ -2258,7 +2258,6 @@ il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data)
static int
il3945_add_bssid_station(struct il_priv *il, const u8 * addr, u8 * sta_id_r)
{
	struct il_rxon_context *ctx = &il->ctx;
	int ret;
	u8 sta_id;
	unsigned long flags;
@@ -2266,7 +2265,7 @@ il3945_add_bssid_station(struct il_priv *il, const u8 * addr, u8 * sta_id_r)
	if (sta_id_r)
		*sta_id_r = IL_INVALID_STATION;

	ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id);
	ret = il_add_station_common(il, addr, 0, NULL, &sta_id);
	if (ret) {
		IL_ERR("Unable to add station %pM\n", addr);
		return ret;
+1 −1
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ extern int il4965_get_temperature(const struct il_priv *il);
extern void il3945_post_associate(struct il_priv *il);
extern void il3945_config_ap(struct il_priv *il);

extern int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx);
extern int il3945_commit_rxon(struct il_priv *il);

/**
 * il3945_hw_find_station - Find station id for a given BSSID
+61 −89
Original line number Diff line number Diff line
@@ -843,7 +843,6 @@ il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
		.flags = CMD_SIZE_HUGE,
	};
	struct il_scan_cmd *scan;
	struct il_rxon_context *ctx = &il->ctx;
	u32 rate_flags = 0;
	u16 cmd_len;
	u16 rx_chain = 0;
@@ -859,8 +858,6 @@ il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif)

	lockdep_assert_held(&il->mutex);

	ctx = il_rxon_ctx_from_vif(vif);

	if (!il->scan_cmd) {
		il->scan_cmd =
		    kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE,
@@ -1033,8 +1030,7 @@ il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
	struct il_vif_priv *vif_priv = (void *)vif->drv_priv;

	if (add)
		return il4965_add_bssid_station(il, vif_priv->ctx,
						vif->bss_conf.bssid,
		return il4965_add_bssid_station(il, vif->bss_conf.bssid,
						&vif_priv->ibss_bssid_sta_id);
	return il_remove_station(il, vif_priv->ibss_bssid_sta_id,
				 vif->bss_conf.bssid);
@@ -1127,7 +1123,7 @@ il4965_count_chain_bitmap(u32 chain_bitmap)
 * This should not be used for scan command ... it puts data in wrong place.
 */
void
il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx)
il4965_set_rxon_chain(struct il_priv *il)
{
	bool is_single = il4965_is_single_rx_stream(il);
	bool is_cam = !test_bit(S_POWER_PMI, &il->status);
@@ -1456,7 +1452,7 @@ il4965_get_ac_from_tid(u16 tid)
}

static inline int
il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid)
il4965_get_fifo_from_tid(u16 tid)
{
	const u8 ac_to_fifo[] = {
		IL_TX_FIFO_VO,
@@ -1645,7 +1641,6 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
	struct il_device_cmd *out_cmd;
	struct il_cmd_meta *out_meta;
	struct il_tx_cmd *tx_cmd;
	struct il_rxon_context *ctx = &il->ctx;
	int txq_id;
	dma_addr_t phys_addr;
	dma_addr_t txcmd_phys;
@@ -1661,9 +1656,6 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
	unsigned long flags;
	bool is_agg = false;

	if (info->control.vif)
		ctx = il_rxon_ctx_from_vif(info->control.vif);

	spin_lock_irqsave(&il->lock, flags);
	if (il_is_rfkill(il)) {
		D_DROP("Dropping - RF KILL\n");
@@ -1688,7 +1680,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
		sta_id = il->hw_params.bcast_id;
	else {
		/* Find idx into station table for destination station */
		sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta);
		sta_id = il_sta_id_or_broadcast(il, info->control.sta);

		if (sta_id == IL_INVALID_STATION) {
			D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1);
@@ -1764,7 +1756,6 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
	/* Set up driver data for this TFD */
	memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info));
	txq->txb[q->write_ptr].skb = skb;
	txq->txb[q->write_ptr].ctx = ctx;

	/* Set up first empty entry in queue's array of Tx/cmd buffers */
	out_cmd = txq->cmd[q->write_ptr];
@@ -2228,7 +2219,8 @@ il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
	unsigned long flags;
	struct il_tid_data *tid_data;

	tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid);
	/* FIXME: warning if tx fifo not found ? */
	tx_fifo = il4965_get_fifo_from_tid(tid);
	if (unlikely(tx_fifo < 0))
		return tx_fifo;

@@ -2321,7 +2313,8 @@ il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
	int write_ptr, read_ptr;
	unsigned long flags;

	tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid);
	/* FIXME: warning if tx_fifo_id not found ? */
	tx_fifo_id = il4965_get_fifo_from_tid(tid);
	if (unlikely(tx_fifo_id < 0))
		return tx_fifo_id;

@@ -2395,9 +2388,6 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id)
	struct il_queue *q = &il->txq[txq_id].q;
	u8 *addr = il->stations[sta_id].sta.sta.addr;
	struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid];
	struct il_rxon_context *ctx;

	ctx = &il->ctx;

	lockdep_assert_held(&il->sta_lock);

@@ -2408,11 +2398,11 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id)
		if (txq_id == tid_data->agg.txq_id &&
		    q->read_ptr == q->write_ptr) {
			u16 ssn = SEQ_TO_SN(tid_data->seq_number);
			int tx_fifo = il4965_get_fifo_from_tid(ctx, tid);
			int tx_fifo = il4965_get_fifo_from_tid(tid);
			D_HT("HW queue empty: continue DELBA flow\n");
			il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo);
			tid_data->agg.state = IL_AGG_OFF;
			ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
			ieee80211_stop_tx_ba_cb_irqsafe(il->vif, addr, tid);
		}
		break;
	case IL_EMPTYING_HW_QUEUE_ADDBA:
@@ -2420,7 +2410,7 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id)
		if (tid_data->tfds_in_queue == 0) {
			D_HT("HW queue empty: continue ADDBA flow\n");
			tid_data->agg.state = IL_AGG_ON;
			ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
			ieee80211_start_tx_ba_cb_irqsafe(il->vif, addr, tid);
		}
		break;
	}
@@ -2429,14 +2419,13 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id)
}

static void
il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx,
			 const u8 *addr1)
il4965_non_agg_tx_status(struct il_priv *il, const u8 *addr1)
{
	struct ieee80211_sta *sta;
	struct il_station_priv *sta_priv;

	rcu_read_lock();
	sta = ieee80211_find_sta(ctx->vif, addr1);
	sta = ieee80211_find_sta(il->vif, addr1);
	if (sta) {
		sta_priv = (void *)sta->drv_priv;
		/* avoid atomic ops if this isn't a client */
@@ -2453,7 +2442,7 @@ il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, bool is_agg)
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data;

	if (!is_agg)
		il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1);
		il4965_non_agg_tx_status(il, hdr->addr1);

	ieee80211_tx_status_irqsafe(il->hw, tx_info->skb);
}
@@ -2769,8 +2758,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id)
 * Function sleeps.
 */
int
il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx,
			 const u8 *addr, u8 *sta_id_r)
il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r)
{
	int ret;
	u8 sta_id;
@@ -2780,7 +2768,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx,
	if (sta_id_r)
		*sta_id_r = IL_INVALID_STATION;

	ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id);
	ret = il_add_station_common(il, addr, 0, NULL, &sta_id);
	if (ret) {
		IL_ERR("Unable to add station %pM\n", addr);
		return ret;
@@ -2801,7 +2789,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx,
		return -ENOMEM;
	}

	ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true);
	ret = il_send_lq_cmd(il, link_cmd, CMD_SYNC, true);
	if (ret)
		IL_ERR("Link quality command failed (%d)\n", ret);

@@ -2813,8 +2801,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx,
}

static int
il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx,
			 bool send_if_empty)
il4965_static_wepkey_cmd(struct il_priv *il, bool send_if_empty)
{
	int i;
	u8 buff[sizeof(struct il_wep_cmd) +
@@ -2860,15 +2847,15 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx,
}

int
il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx)
il4965_restore_default_wep_keys(struct il_priv *il)
{
	lockdep_assert_held(&il->mutex);

	return il4965_static_wepkey_cmd(il, ctx, false);
	return il4965_static_wepkey_cmd(il, false);
}

int
il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
il4965_remove_default_wep_key(struct il_priv *il,
			      struct ieee80211_key_conf *keyconf)
{
	int ret;
@@ -2884,14 +2871,14 @@ il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
		/* but keys in device are clear anyway so return success */
		return 0;
	}
	ret = il4965_static_wepkey_cmd(il, ctx, 1);
	ret = il4965_static_wepkey_cmd(il, 1);
	D_WEP("Remove default WEP key: idx=%d ret=%d\n", idx, ret);

	return ret;
}

int
il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
il4965_set_default_wep_key(struct il_priv *il,
			   struct ieee80211_key_conf *keyconf)
{
	int ret;
@@ -2912,14 +2899,14 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
	il->_4965.wep_keys[idx].key_size = len;
	memcpy(&il->_4965.wep_keys[idx].key, &keyconf->key, len);

	ret = il4965_static_wepkey_cmd(il, ctx, false);
	ret = il4965_static_wepkey_cmd(il, false);

	D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", len, idx, ret);
	return ret;
}

static int
il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx,
il4965_set_wep_dynamic_key_info(struct il_priv *il,
				struct ieee80211_key_conf *keyconf, u8 sta_id)
{
	unsigned long flags;
@@ -2974,7 +2961,6 @@ il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx,

static int
il4965_set_ccmp_dynamic_key_info(struct il_priv *il,
				 struct il_rxon_context *ctx,
				 struct ieee80211_key_conf *keyconf, u8 sta_id)
{
	unsigned long flags;
@@ -3023,7 +3009,6 @@ il4965_set_ccmp_dynamic_key_info(struct il_priv *il,

static int
il4965_set_tkip_dynamic_key_info(struct il_priv *il,
				 struct il_rxon_context *ctx,
				 struct ieee80211_key_conf *keyconf, u8 sta_id)
{
	unsigned long flags;
@@ -3068,8 +3053,7 @@ il4965_set_tkip_dynamic_key_info(struct il_priv *il,
}

void
il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx,
		       struct ieee80211_key_conf *keyconf,
il4965_update_tkip_key(struct il_priv *il, struct ieee80211_key_conf *keyconf,
		       struct ieee80211_sta *sta, u32 iv32, u16 *phase1key)
{
	u8 sta_id;
@@ -3082,7 +3066,7 @@ il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx,
		return;
	}

	sta_id = il_sta_id_or_broadcast(il, ctx, sta);
	sta_id = il_sta_id_or_broadcast(il, sta);
	if (sta_id == IL_INVALID_STATION)
		return;

@@ -3100,11 +3084,10 @@ il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx,
	il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC);

	spin_unlock_irqrestore(&il->sta_lock, flags);

}

int
il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
il4965_remove_dynamic_key(struct il_priv *il,
			  struct ieee80211_key_conf *keyconf, u8 sta_id)
{
	unsigned long flags;
@@ -3165,8 +3148,8 @@ il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
}

int
il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
		       struct ieee80211_key_conf *keyconf, u8 sta_id)
il4965_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf,
		       u8 sta_id)
{
	int ret;

@@ -3178,15 +3161,15 @@ il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
	switch (keyconf->cipher) {
	case WLAN_CIPHER_SUITE_CCMP:
		ret =
		    il4965_set_ccmp_dynamic_key_info(il, ctx, keyconf, sta_id);
		    il4965_set_ccmp_dynamic_key_info(il, keyconf, sta_id);
		break;
	case WLAN_CIPHER_SUITE_TKIP:
		ret =
		    il4965_set_tkip_dynamic_key_info(il, ctx, keyconf, sta_id);
		    il4965_set_tkip_dynamic_key_info(il, keyconf, sta_id);
		break;
	case WLAN_CIPHER_SUITE_WEP40:
	case WLAN_CIPHER_SUITE_WEP104:
		ret = il4965_set_wep_dynamic_key_info(il, ctx, keyconf, sta_id);
		ret = il4965_set_wep_dynamic_key_info(il, keyconf, sta_id);
		break;
	default:
		IL_ERR("Unknown alg: %s cipher = %x\n", __func__,
@@ -3208,14 +3191,14 @@ il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
 * device at the next best time.
 */
int
il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx)
il4965_alloc_bcast_station(struct il_priv *il)
{
	struct il_link_quality_cmd *link_cmd;
	unsigned long flags;
	u8 sta_id;

	spin_lock_irqsave(&il->sta_lock, flags);
	sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL);
	sta_id = il_prep_station(il, il_bcast_addr, false, NULL);
	if (sta_id == IL_INVALID_STATION) {
		IL_ERR("Unable to prepare broadcast station\n");
		spin_unlock_irqrestore(&il->sta_lock, flags);
@@ -3248,7 +3231,7 @@ il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx)
 * code together.
 */
static int
il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx)
il4965_update_bcast_station(struct il_priv *il)
{
	unsigned long flags;
	struct il_link_quality_cmd *link_cmd;
@@ -3274,7 +3257,7 @@ il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx)
int
il4965_update_bcast_stations(struct il_priv *il)
{
	return il4965_update_bcast_station(il, &il->ctx);
	return il4965_update_bcast_station(il);
}

/**
@@ -3375,9 +3358,9 @@ void
il4965_update_chain_flags(struct il_priv *il)
{
	if (il->cfg->ops->hcmd->set_rxon_chain) {
		il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx);
		il->cfg->ops->hcmd->set_rxon_chain(il);
		if (il->active.rx_chain != il->staging.rx_chain)
			il_commit_rxon(il, &il->ctx);
			il_commit_rxon(il);
	}
}

@@ -3489,8 +3472,8 @@ il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame)

	lockdep_assert_held(&il->mutex);

	if (!il->beacon_ctx) {
		IL_ERR("trying to build beacon w/o beacon context!\n");
	if (!il->beacon_enabled) {
		IL_ERR("Trying to build beacon without beaconing enabled\n");
		return 0;
	}

@@ -3520,7 +3503,7 @@ il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame)
			      frame_size);

	/* Set up packet rate and flags */
	rate = il_get_lowest_plcp(il, il->beacon_ctx);
	rate = il_get_lowest_plcp(il);
	il4965_toggle_tx_ant(il, &il->mgmt_tx_ant, il->hw_params.valid_tx_ant);
	rate_flags = BIT(il->mgmt_tx_ant) << RATE_MCS_ANT_POS;
	if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE))
@@ -4977,7 +4960,6 @@ static void
il4965_alive_start(struct il_priv *il)
{
	int ret = 0;
	struct il_rxon_context *ctx = &il->ctx;

	D_INFO("Runtime Alive received.\n");

@@ -5025,10 +5007,10 @@ il4965_alive_start(struct il_priv *il)
		active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
	} else {
		/* Initialize our rx_config data */
		il_connection_init_rx_config(il, &il->ctx);
		il_connection_init_rx_config(il);

		if (il->cfg->ops->hcmd->set_rxon_chain)
			il->cfg->ops->hcmd->set_rxon_chain(il, ctx);
			il->cfg->ops->hcmd->set_rxon_chain(il);
	}

	/* Configure bluetooth coexistence if enabled */
@@ -5039,7 +5021,7 @@ il4965_alive_start(struct il_priv *il)
	set_bit(S_READY, &il->status);

	/* Configure the adapter for unassociated operation */
	il_commit_rxon(il, ctx);
	il_commit_rxon(il);

	/* At this point, the NIC is initialized and operational */
	il4965_rf_kill_ct_config(il);
@@ -5074,7 +5056,7 @@ __il4965_down(struct il_priv *il)
	 * to prevent rearm timer */
	del_timer_sync(&il->watchdog);

	il_clear_ucode_stations(il, NULL);
	il_clear_ucode_stations(il);

	/* FIXME: race conditions ? */
	spin_lock_irq(&il->sta_lock);
@@ -5239,7 +5221,7 @@ __il4965_up(struct il_priv *il)
		return -EIO;
	}

	ret = il4965_alloc_bcast_station(il, &il->ctx);
	ret = il4965_alloc_bcast_station(il);
	if (ret) {
		il_dealloc_bcast_stations(il);
		return ret;
@@ -5393,7 +5375,8 @@ il4965_bg_restart(struct work_struct *data)

	if (test_and_clear_bit(S_FW_ERROR, &il->status)) {
		mutex_lock(&il->mutex);
		il->ctx.vif = NULL;
		/* FIXME: do we dereference vif without mutex locked ? */
		il->vif = NULL;
		il->is_open = 0;

		__il4965_down(il);
@@ -5590,12 +5573,10 @@ il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
			   struct ieee80211_sta *sta, u32 iv32, u16 * phase1key)
{
	struct il_priv *il = hw->priv;
	struct il_vif_priv *vif_priv = (void *)vif->drv_priv;

	D_MAC80211("enter\n");

	il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32,
			       phase1key);
	il4965_update_tkip_key(il, keyconf, sta, iv32, phase1key);

	D_MAC80211("leave\n");
}
@@ -5606,8 +5587,6 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
		   struct ieee80211_key_conf *key)
{
	struct il_priv *il = hw->priv;
	struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
	struct il_rxon_context *ctx = vif_priv->ctx;
	int ret;
	u8 sta_id;
	bool is_default_wep_key = false;
@@ -5619,7 +5598,7 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
		return -EOPNOTSUPP;
	}

	sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta);
	sta_id = il_sta_id_or_broadcast(il, sta);
	if (sta_id == IL_INVALID_STATION)
		return -EINVAL;

@@ -5644,20 +5623,17 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
	switch (cmd) {
	case SET_KEY:
		if (is_default_wep_key)
			ret =
			    il4965_set_default_wep_key(il, vif_priv->ctx, key);
			ret = il4965_set_default_wep_key(il, key);
		else
			ret =
			    il4965_set_dynamic_key(il, vif_priv->ctx, key,
						   sta_id);
			ret = il4965_set_dynamic_key(il, key, sta_id);

		D_MAC80211("enable hwcrypto key\n");
		break;
	case DISABLE_KEY:
		if (is_default_wep_key)
			ret = il4965_remove_default_wep_key(il, ctx, key);
			ret = il4965_remove_default_wep_key(il, key);
		else
			ret = il4965_remove_dynamic_key(il, ctx, key, sta_id);
			ret = il4965_remove_dynamic_key(il, key, sta_id);

		D_MAC80211("disable hwcrypto key\n");
		break;
@@ -5723,7 +5699,6 @@ il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
{
	struct il_priv *il = hw->priv;
	struct il_station_priv *sta_priv = (void *)sta->drv_priv;
	struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
	bool is_ap = vif->type == NL80211_IFTYPE_STATION;
	int ret;
	u8 sta_id;
@@ -5736,8 +5711,7 @@ il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
	atomic_set(&sta_priv->pending_frames, 0);

	ret =
	    il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta,
				  &sta_id);
	    il_add_station_common(il, sta->addr, is_ap, sta, &sta_id);
	if (ret) {
		IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret);
		/* Should we return success if return code is EEXIST ? */
@@ -5764,8 +5738,6 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
	struct ieee80211_conf *conf = &hw->conf;
	struct ieee80211_channel *channel = ch_switch->channel;
	struct il_ht_config *ht_conf = &il->current_ht_config;

	struct il_rxon_context *ctx = &il->ctx;
	u16 ch;

	D_MAC80211("enter\n");
@@ -5822,9 +5794,9 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
	if ((le16_to_cpu(il->staging.channel) != ch))
		il->staging.flags = 0;

	il_set_rxon_channel(il, channel, ctx);
	il_set_rxon_channel(il, channel);
	il_set_rxon_ht(il, ht_conf);
	il_set_flags_for_band(il, ctx, channel->band, ctx->vif);
	il_set_flags_for_band(il, channel->band, il->vif);

	spin_unlock_irq(&il->lock);

@@ -5838,7 +5810,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
	if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) {
		clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status);
		il->switch_channel = 0;
		ieee80211_chswitch_done(ctx->vif, false);
		ieee80211_chswitch_done(il->vif, false);
	}

out:
@@ -6049,7 +6021,7 @@ il4965_init_drv(struct il_priv *il)

	/* Choose which receivers/antennas to use */
	if (il->cfg->ops->hcmd->set_rxon_chain)
		il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx);
		il->cfg->ops->hcmd->set_rxon_chain(il);

	il_init_scan_params(il);

Loading