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

Commit c587de0b authored by Tomas Winkler's avatar Tomas Winkler Committed by John W. Linville
Browse files

iwlwifi: unify station management



This patch unifies 3945 and AGN station management
It also removes useless struct iwl_station_mgmt ops
and cleanups a bit the interface

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Tested-by: default avatarAbhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 0aa8204b
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@

#include "iwl-commands.h"
#include "iwl-3945.h"
#include "iwl-sta.h"

#define RS_NAME "iwl-3945-rs"

@@ -714,13 +715,13 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,

	if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
	    !rs_sta->ibss_sta_added) {
		u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
		u8 sta_id = iwl_find_station(priv, hdr->addr1);

		if (sta_id == IWL_INVALID_STATION) {
			IWL_DEBUG_RATE(priv, "LQ: ADD station %pm\n",
				       hdr->addr1);
			sta_id = iwl3945_add_station(priv,
				    hdr->addr1, 0, CMD_ASYNC, NULL);
			sta_id = iwl_add_station(priv, hdr->addr1, false,
				CMD_ASYNC, NULL);
		}
		if (sta_id != IWL_INVALID_STATION)
			rs_sta->ibss_sta_added = 1;
@@ -975,7 +976,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)

	rcu_read_lock();

	sta = ieee80211_find_sta(hw, priv->stations_39[sta_id].sta.sta.addr);
	sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr);
	if (!sta) {
		rcu_read_unlock();
		return;
+22 −51
Original line number Diff line number Diff line
@@ -769,35 +769,6 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
	return ;
}

u8 iwl3945_hw_find_station(struct iwl_priv *priv, const u8 *addr)
{
	int i, start = IWL_AP_ID;
	int ret = IWL_INVALID_STATION;
	unsigned long flags;

	if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) ||
	    (priv->iw_mode == NL80211_IFTYPE_AP))
		start = IWL_STA_ID;

	if (is_broadcast_ether_addr(addr))
		return priv->hw_params.bcast_sta_id;

	spin_lock_irqsave(&priv->sta_lock, flags);
	for (i = start; i < priv->hw_params.max_stations; i++)
		if ((priv->stations_39[i].used) &&
		    (!compare_ether_addr
		     (priv->stations_39[i].sta.sta.addr, addr))) {
			ret = i;
			goto out;
		}

	IWL_DEBUG_INFO(priv, "can not find STA %pM (total %d)\n",
		       addr, priv->num_stations);
 out:
	spin_unlock_irqrestore(&priv->sta_lock, flags);
	return ret;
}

/**
 * iwl3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD:
 *
@@ -875,13 +846,13 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, struct iwl_cmd *cmd,
u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate, u8 flags)
{
	unsigned long flags_spin;
	struct iwl3945_station_entry *station;
	struct iwl_station_entry *station;

	if (sta_id == IWL_INVALID_STATION)
		return IWL_INVALID_STATION;

	spin_lock_irqsave(&priv->sta_lock, flags_spin);
	station = &priv->stations_39[sta_id];
	station = &priv->stations[sta_id];

	station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK;
	station->sta.rate_n_flags = cpu_to_le16(tx_rate);
@@ -889,8 +860,7 @@ u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate, u8 flags)

	spin_unlock_irqrestore(&priv->sta_lock, flags_spin);

	iwl_send_add_sta(priv,
			 (struct iwl_addsta_cmd *)&station->sta, flags);
	iwl_send_add_sta(priv, &station->sta, flags);
	IWL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n",
			sta_id, tx_rate);
	return sta_id;
@@ -2029,7 +1999,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)

	memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));

	priv->cfg->ops->smgmt->clear_station_table(priv);
	iwl_clear_stations_table(priv);

	/* If we issue a new RXON command which required a tune then we must
	 * send a new TXPOWER command or we won't be able to Tx any frames */
@@ -2040,7 +2010,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
	}

	/* Add the broadcast address so we can send broadcast frames */
	if (priv->cfg->ops->smgmt->add_station(priv, iwl_bcast_addr, 0, 0, NULL) ==
	if (iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL) ==
	    IWL_INVALID_STATION) {
		IWL_ERR(priv, "Error adding BROADCAST address for transmit.\n");
		return -EIO;
@@ -2050,9 +2020,8 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
	 * add the IWL_AP_ID to the station rate table */
	if (iwl_is_associated(priv) &&
	    (priv->iw_mode == NL80211_IFTYPE_STATION))
		if (priv->cfg->ops->smgmt->add_station(priv,
					priv->active_rxon.bssid_addr, 1, 0, NULL)
		    == IWL_INVALID_STATION) {
		if (iwl_add_station(priv, priv->active_rxon.bssid_addr,
				true, CMD_SYNC, NULL) == IWL_INVALID_STATION) {
			IWL_ERR(priv, "Error adding AP address for transmit\n");
			return -EIO;
		}
@@ -2466,13 +2435,25 @@ static u16 iwl3945_get_hcmd_size(u8 cmd_id, u16 len)
	}
}


static u16 iwl3945_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
{
	u16 size = (u16)sizeof(struct iwl3945_addsta_cmd);
	memcpy(data, cmd, size);
	return size;
	struct iwl3945_addsta_cmd *addsta = (struct iwl3945_addsta_cmd *)data;
	addsta->mode = cmd->mode;
	memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify));
	memcpy(&addsta->key, &cmd->key, sizeof(struct iwl4965_keyinfo));
	addsta->station_flags = cmd->station_flags;
	addsta->station_flags_msk = cmd->station_flags_msk;
	addsta->tid_disable_tx = cpu_to_le16(0);
	addsta->rate_n_flags = cmd->rate_n_flags;
	addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid;
	addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid;
	addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn;

	return (u16)sizeof(struct iwl3945_addsta_cmd);
}


/**
 * iwl3945_init_hw_rate_table - Initialize the hardware rate fallback table
 */
@@ -2842,15 +2823,6 @@ static struct iwl_lib_ops iwl3945_lib = {
	.config_ap = iwl3945_config_ap,
};

static struct iwl_station_mgmt_ops iwl3945_station_mgmt = {
	.add_station = iwl3945_add_station,
#if 0
	.remove_station = iwl3945_remove_station,
#endif
	.find_station = iwl3945_hw_find_station,
	.clear_station_table = iwl3945_clear_stations_table,
};

static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
	.get_hcmd_size = iwl3945_get_hcmd_size,
	.build_addsta_hcmd = iwl3945_build_addsta_hcmd,
@@ -2860,7 +2832,6 @@ static struct iwl_ops iwl3945_ops = {
	.lib = &iwl3945_lib,
	.hcmd = &iwl3945_hcmd,
	.utils = &iwl3945_hcmd_utils,
	.smgmt = &iwl3945_station_mgmt,
};

static struct iwl_cfg iwl3945_bg_cfg = {
+0 −6
Original line number Diff line number Diff line
@@ -202,12 +202,6 @@ struct iwl3945_ibss_seq {
 * for use by iwl-*.c
 *
 *****************************************************************************/
struct iwl3945_addsta_cmd;
extern int iwl3945_send_add_station(struct iwl_priv *priv,
				struct iwl3945_addsta_cmd *sta, u8 flags);
extern u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *bssid,
			  int is_ap, u8 flags, struct ieee80211_sta_ht_cap *ht_info);
extern void iwl3945_clear_stations_table(struct iwl_priv *priv);
extern int iwl3945_power_init_handle(struct iwl_priv *priv);
extern int iwl3945_eeprom_init(struct iwl_priv *priv);
extern int iwl3945_calc_db_from_ratio(int sig_ratio);
+0 −8
Original line number Diff line number Diff line
@@ -2221,13 +2221,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
	cancel_work_sync(&priv->txpower_work);
}

static struct iwl_station_mgmt_ops iwl4965_station_mgmt = {
	.add_station = iwl_add_station_flags,
	.remove_station = iwl_remove_station,
	.find_station = iwl_find_station,
	.clear_station_table = iwl_clear_stations_table,
};

static struct iwl_hcmd_ops iwl4965_hcmd = {
	.rxon_assoc = iwl4965_send_rxon_assoc,
	.commit_rxon = iwl_commit_rxon,
@@ -2297,7 +2290,6 @@ static struct iwl_ops iwl4965_ops = {
	.lib = &iwl4965_lib,
	.hcmd = &iwl4965_hcmd,
	.utils = &iwl4965_hcmd_utils,
	.smgmt = &iwl4965_station_mgmt,
};

struct iwl_cfg iwl4965_agn_cfg = {
+5 −11
Original line number Diff line number Diff line
@@ -651,7 +651,7 @@ static void iwl5000_init_alive_start(struct iwl_priv *priv)
		goto restart;
	}

	priv->cfg->ops->smgmt->clear_station_table(priv);
	iwl_clear_stations_table(priv);
	ret = priv->cfg->ops->lib->alive_notify(priv);
	if (ret) {
		IWL_WARN(priv,
@@ -1049,7 +1049,10 @@ static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
{
	u16 size = (u16)sizeof(struct iwl_addsta_cmd);
	memcpy(data, cmd, size);
	struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data;
	memcpy(addsta, cmd, size);
	/* resrved in 5000 */
	addsta->rate_n_flags = cpu_to_le16(0);
	return size;
}

@@ -1423,13 +1426,6 @@ int iwl5000_calc_rssi(struct iwl_priv *priv,
	return max_rssi - agc - IWL49_RSSI_OFFSET;
}

struct iwl_station_mgmt_ops iwl5000_station_mgmt = {
	.add_station = iwl_add_station_flags,
	.remove_station = iwl_remove_station,
	.find_station = iwl_find_station,
	.clear_station_table = iwl_clear_stations_table,
};

struct iwl_hcmd_ops iwl5000_hcmd = {
	.rxon_assoc = iwl5000_send_rxon_assoc,
	.commit_rxon = iwl_commit_rxon,
@@ -1549,14 +1545,12 @@ struct iwl_ops iwl5000_ops = {
	.lib = &iwl5000_lib,
	.hcmd = &iwl5000_hcmd,
	.utils = &iwl5000_hcmd_utils,
	.smgmt = &iwl5000_station_mgmt,
};

static struct iwl_ops iwl5150_ops = {
	.lib = &iwl5150_lib,
	.hcmd = &iwl5000_hcmd,
	.utils = &iwl5000_hcmd_utils,
	.smgmt = &iwl5000_station_mgmt,
};

struct iwl_mod_params iwl50_mod_params = {
Loading