[PATCH 1/2] wcn36xx: move supported_rates to wcn36xx_sta struct

Eugene Krasnikov k.eugene.e at gmail.com
Fri Sep 20 04:30:26 EDT 2013


This is were information about supported rates must be stored.
If sta is not available set default rates.

Signed-off-by: Eugene Krasnikov <k.eugene.e at gmail.com>
---
 main.c    | 80 +++++++++++++++++++++++++++++++++------------------------------
 smd.c     |  7 +++---
 wcn36xx.h |  6 ++---
 3 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/main.c b/main.c
index 5cc6228..12f61d5 100644
--- a/main.c
+++ b/main.c
@@ -451,19 +451,21 @@ static void wcn36xx_sw_scan_complete(struct ieee80211_hw *hw)
 	wcn36xx_smd_finish_scan(wcn, HAL_SYS_MODE_SCAN);
 }
 
-static void wcn36xx_update_allowed_rates(struct wcn36xx *wcn,
-					 struct ieee80211_sta *sta)
+static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
+					 enum ieee80211_band band)
 {
 	int i, size;
 	u16 *rates_table;
-	u32 rates = sta->supp_rates[wcn->hw->conf.chandef.chan->band];
+	struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+	u32 rates = sta->supp_rates[band];
 
-	memset(&wcn->supported_rates, 0, sizeof(wcn->supported_rates));
-	wcn->supported_rates.op_rate_mode = STA_11n;
+	memset(&sta_priv->supported_rates, 0,
+		sizeof(sta_priv->supported_rates));
+	sta_priv->supported_rates.op_rate_mode = STA_11n;
 
-	size = ARRAY_SIZE(wcn->supported_rates.dsss_rates);
-	rates_table = wcn->supported_rates.dsss_rates;
-	if (wcn->hw->conf.chandef.chan->band == IEEE80211_BAND_2GHZ) {
+	size = ARRAY_SIZE(sta_priv->supported_rates.dsss_rates);
+	rates_table = sta_priv->supported_rates.dsss_rates;
+	if (band == IEEE80211_BAND_2GHZ) {
 		for (i = 0; i < size; i++) {
 			if (rates & 0x01) {
 				rates_table[i] = wcn_2ghz_rates[i].hw_value;
@@ -472,8 +474,8 @@ static void wcn36xx_update_allowed_rates(struct wcn36xx *wcn,
 		}
 	}
 
-	size = ARRAY_SIZE(wcn->supported_rates.ofdm_rates);
-	rates_table = wcn->supported_rates.ofdm_rates;
+	size = ARRAY_SIZE(sta_priv->supported_rates.ofdm_rates);
+	rates_table = sta_priv->supported_rates.ofdm_rates;
 	for (i = 0; i < size; i++) {
 		if (rates & 0x01) {
 			rates_table[i] = wcn_5ghz_rates[i].hw_value;
@@ -482,14 +484,39 @@ static void wcn36xx_update_allowed_rates(struct wcn36xx *wcn,
 	}
 
 	if (sta->ht_cap.ht_supported) {
-		memcpy(wcn->supported_rates.supported_mcs_set,
+		BUILD_BUG_ON(sizeof(sta->ht_cap.mcs.rx_mask) >
+			sizeof(sta_priv->supported_rates.supported_mcs_set));
+		memcpy(sta_priv->supported_rates.supported_mcs_set,
 		       sta->ht_cap.mcs.rx_mask,
 		       sizeof(sta->ht_cap.mcs.rx_mask));
-		BUILD_BUG_ON(sizeof(sta->ht_cap.mcs.rx_mask) >
-			     sizeof(wcn->supported_rates.supported_mcs_set));
 	}
 }
+void wcn36xx_set_default_rates(struct wcn36xx_hal_supported_rates *rates)
+{
+	u16 ofdm_rates[WCN36XX_HAL_NUM_OFDM_RATES] = {
+		HW_RATE_INDEX_6MBPS,
+		HW_RATE_INDEX_9MBPS,
+		HW_RATE_INDEX_12MBPS,
+		HW_RATE_INDEX_18MBPS,
+		HW_RATE_INDEX_24MBPS,
+		HW_RATE_INDEX_36MBPS,
+		HW_RATE_INDEX_48MBPS,
+		HW_RATE_INDEX_54MBPS
+	};
+	u16 dsss_rates[WCN36XX_HAL_NUM_DSSS_RATES] = {
+		HW_RATE_INDEX_1MBPS,
+		HW_RATE_INDEX_2MBPS,
+		HW_RATE_INDEX_5_5MBPS,
+		HW_RATE_INDEX_11MBPS
+	};
 
+	rates->op_rate_mode = STA_11n;
+	memcpy(rates->dsss_rates, dsss_rates,
+		sizeof(*dsss_rates) * WCN36XX_HAL_NUM_DSSS_RATES);
+	memcpy(rates->ofdm_rates, ofdm_rates,
+		sizeof(*ofdm_rates) * WCN36XX_HAL_NUM_OFDM_RATES);
+	rates->supported_mcs_set[0] = 0xFF;
+}
 static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
 				     struct ieee80211_vif *vif,
 				     struct ieee80211_bss_conf *bss_conf,
@@ -574,7 +601,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
 			}
 			sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
 
-			wcn36xx_update_allowed_rates(wcn, sta);
+			wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
 
 			wcn36xx_smd_set_link_st(wcn, bss_conf->bssid,
 				vif->addr,
@@ -711,6 +738,7 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	 * at this stage AID is not available yet.
 	 */
 	if (NL80211_IFTYPE_STATION != vif->type) {
+		wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
 		sta_priv->aid = sta->aid;
 		wcn36xx_smd_config_sta(wcn, vif, sta);
 	}
@@ -919,22 +947,6 @@ static int wcn36xx_probe(struct platform_device *pdev)
 	struct ieee80211_hw *hw;
 	struct wcn36xx *wcn;
 	int ret;
-	u16 ofdm_rates[WCN36XX_HAL_NUM_OFDM_RATES] = {
-		HW_RATE_INDEX_6MBPS,
-		HW_RATE_INDEX_9MBPS,
-		HW_RATE_INDEX_12MBPS,
-		HW_RATE_INDEX_18MBPS,
-		HW_RATE_INDEX_24MBPS,
-		HW_RATE_INDEX_36MBPS,
-		HW_RATE_INDEX_48MBPS,
-		HW_RATE_INDEX_54MBPS
-	};
-	u16 dsss_rates[WCN36XX_HAL_NUM_DSSS_RATES] = {
-		HW_RATE_INDEX_1MBPS,
-		HW_RATE_INDEX_2MBPS,
-		HW_RATE_INDEX_5_5MBPS,
-		HW_RATE_INDEX_11MBPS
-	};
 	wcn36xx_dbg(WCN36XX_DBG_MAC, "platform probe\n");
 
 	hw = ieee80211_alloc_hw(sizeof(struct wcn36xx), &wcn36xx_ops);
@@ -951,14 +963,6 @@ static int wcn36xx_probe(struct platform_device *pdev)
 
 	mutex_init(&wcn->hal_mutex);
 
-	/* Configuring supported rates */
-	wcn->supported_rates.op_rate_mode = STA_11n;
-	memcpy(wcn->supported_rates.dsss_rates, dsss_rates,
-		sizeof(*dsss_rates) * WCN36XX_HAL_NUM_DSSS_RATES);
-	memcpy(wcn->supported_rates.ofdm_rates, ofdm_rates,
-		sizeof(*ofdm_rates) * WCN36XX_HAL_NUM_OFDM_RATES);
-	wcn->supported_rates.supported_mcs_set[0] = 0xFF;
-
 	if (!wcn->ctrl_ops->get_hw_mac(wcn->addresses.addr)) {
 		wcn36xx_info("mac address: %pM\n", wcn->addresses.addr);
 		SET_IEEE80211_PERM_ADDR(wcn->hw, wcn->addresses.addr);
diff --git a/smd.c b/smd.c
index c892820..9a71b95 100644
--- a/smd.c
+++ b/smd.c
@@ -153,9 +153,6 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
 	sta_params->bssid_index = priv_vif->bss_index;
 	sta_params->p2p = 0;
 
-	memcpy(&sta_params->supported_rates, &wcn->supported_rates,
-		sizeof(wcn->supported_rates));
-
 	if (sta) {
 		priv_sta = (struct wcn36xx_sta *)sta->drv_priv;
 		if (NL80211_IFTYPE_STATION == vif->type)
@@ -166,6 +163,10 @@ static void wcn36xx_smd_set_sta_params(struct wcn36xx *wcn,
 		sta_params->max_sp_len = sta->max_sp;
 		sta_params->aid = priv_sta->aid;
 		wcn36xx_smd_set_sta_ht_params(sta, sta_params);
+		memcpy(&sta_params->supported_rates, &priv_sta->supported_rates,
+			sizeof(priv_sta->supported_rates));
+	} else {
+		wcn36xx_set_default_rates(&sta_params->supported_rates);
 	}
 }
 
diff --git a/wcn36xx.h b/wcn36xx.h
index 3e5a838..060fe88 100644
--- a/wcn36xx.h
+++ b/wcn36xx.h
@@ -162,6 +162,8 @@ struct wcn36xx_sta {
 	u8 bss_sta_index;
 	u8 bss_dpu_desc_index;
 	bool is_data_encrypted;
+	/* Rates */
+	struct wcn36xx_hal_supported_rates supported_rates;
 };
 struct wcn36xx_dxe_ch;
 struct wcn36xx {
@@ -184,9 +186,6 @@ struct wcn36xx {
 	int			rx_irq;
 	void __iomem		*mmio;
 
-	/* Rates */
-	struct wcn36xx_hal_supported_rates supported_rates;
-
 	struct wcn36xx_platform_ctrl_ops *ctrl_ops;
 	/*
 	 * smd_buf must be protected with smd_mutex to garantee
@@ -235,5 +234,6 @@ static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn,
 		wcn->fw_version == version &&
 		wcn->fw_revision == revision);
 }
+void wcn36xx_set_default_rates(struct wcn36xx_hal_supported_rates *rates);
 
 #endif	/* _WCN36XX_H_ */
-- 
1.8.2.2




More information about the wcn36xx mailing list