From a4aac6b8890fef31c94cc658d4b56591d20cf5f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Pouiller?= Date: Mon, 6 Apr 2020 13:17:48 +0200 Subject: [PATCH] staging: wfx: relocate TX_RETRY_POLICY_MAX and TX_RETRY_POLICY_INVALID to hif API MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The definitions TX_RETRY_POLICY_MAX and TX_RETRY_POLICY_INVALID are imposed by the hardware. Therefore, they should be located in the hardware interface API. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200406111756.154086-4-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 16 +++++++--------- drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/hif_api_mib.h | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 757e374..a34f623 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -16,8 +16,6 @@ #include "traces.h" #include "hif_tx_mib.h" -#define WFX_INVALID_RATE_ID 15 - static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate *rate) { @@ -117,7 +115,7 @@ static int wfx_tx_policy_get(struct wfx_vif *wvif, if (list_empty(&cache->free)) { WARN(1, "unable to get a valid Tx policy"); spin_unlock_bh(&cache->lock); - return WFX_INVALID_RATE_ID; + return HIF_TX_RETRY_POLICY_INVALID; } idx = wfx_tx_policy_find(cache, &wanted); if (idx >= 0) { @@ -146,7 +144,7 @@ static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx) int usage, locked; struct tx_policy_cache *cache = &wvif->tx_policy_cache; - if (idx == WFX_INVALID_RATE_ID) + if (idx == HIF_TX_RETRY_POLICY_INVALID) return; spin_lock_bh(&cache->lock); locked = list_empty(&cache->free); @@ -164,11 +162,11 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) do { spin_lock_bh(&wvif->tx_policy_cache.lock); - for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) + for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i) if (!policies[i].uploaded && memzcmp(policies[i].rates, sizeof(policies[i].rates))) break; - if (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES) { + if (i < HIF_TX_RETRY_POLICY_MAX) { policies[i].uploaded = true; memcpy(tmp_rates, policies[i].rates, sizeof(tmp_rates)); spin_unlock_bh(&wvif->tx_policy_cache.lock); @@ -176,7 +174,7 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) } else { spin_unlock_bh(&wvif->tx_policy_cache.lock); } - } while (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES); + } while (i < HIF_TX_RETRY_POLICY_MAX); return 0; } @@ -200,7 +198,7 @@ void wfx_tx_policy_init(struct wfx_vif *wvif) INIT_LIST_HEAD(&cache->used); INIT_LIST_HEAD(&cache->free); - for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) + for (i = 0; i < HIF_TX_RETRY_POLICY_MAX; ++i) list_add(&cache->cache[i].link, &cache->free); } @@ -308,7 +306,7 @@ static u8 wfx_tx_get_rate_id(struct wfx_vif *wvif, rate_id = wfx_tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); - if (rate_id == WFX_INVALID_RATE_ID) + if (rate_id == HIF_TX_RETRY_POLICY_INVALID) dev_warn(wvif->wdev->dev, "unable to get a valid Tx policy"); if (tx_policy_renew) { diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index 7f201f6..a308af3 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -26,7 +26,7 @@ struct tx_policy { }; struct tx_policy_cache { - struct tx_policy cache[HIF_MIB_NUM_TX_RATE_RETRY_POLICIES]; + struct tx_policy cache[HIF_TX_RETRY_POLICY_MAX]; // FIXME: use a trees and drop hash from tx_policy struct list_head used; struct list_head free; diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h index 0c67cd4..36c9152 100644 --- a/drivers/staging/wfx/hif_api_mib.h +++ b/drivers/staging/wfx/hif_api_mib.h @@ -500,7 +500,8 @@ struct hif_mib_tx_rate_retry_policy { u8 rates[12]; } __packed; -#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES 15 +#define HIF_TX_RETRY_POLICY_MAX 15 +#define HIF_TX_RETRY_POLICY_INVALID HIF_TX_RETRY_POLICY_MAX struct hif_mib_set_tx_rate_retry_policy { u8 num_tx_rate_policies; -- 2.7.4