Commit c360f1cc authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: simplify hif_set_tx_rate_retry_policy() usage

The structure hif_mib_set_tx_rate_retry_policy come from hardware
API. It is not intended to be manipulated in upper layers of the driver.

So, this patch relocate handling of this structure to
hif_set_tx_rate_retry_policy() (the low level function).
Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200115135338.14374-6-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9ab56465
...@@ -217,9 +217,8 @@ static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx) ...@@ -217,9 +217,8 @@ static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx)
static int wfx_tx_policy_upload(struct wfx_vif *wvif) static int wfx_tx_policy_upload(struct wfx_vif *wvif)
{ {
struct hif_mib_set_tx_rate_retry_policy *arg =
kzalloc(struct_size(arg, tx_rate_retry_policy, 1), GFP_KERNEL);
struct tx_policy *policies = wvif->tx_policy_cache.cache; struct tx_policy *policies = wvif->tx_policy_cache.cache;
u8 tmp_rates[12];
int i; int i;
do { do {
...@@ -230,22 +229,13 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) ...@@ -230,22 +229,13 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif)
break; break;
if (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES) { if (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES) {
policies[i].uploaded = 1; policies[i].uploaded = 1;
arg->num_tx_rate_policies = 1; memcpy(tmp_rates, policies[i].rates, sizeof(tmp_rates));
arg->tx_rate_retry_policy[0].policy_index = i;
arg->tx_rate_retry_policy[0].short_retry_count = 255;
arg->tx_rate_retry_policy[0].long_retry_count = 255;
arg->tx_rate_retry_policy[0].first_rate_sel = 1;
arg->tx_rate_retry_policy[0].terminate = 1;
arg->tx_rate_retry_policy[0].count_init = 1;
memcpy(&arg->tx_rate_retry_policy[0].rates,
policies[i].rates, sizeof(policies[i].rates));
spin_unlock_bh(&wvif->tx_policy_cache.lock); spin_unlock_bh(&wvif->tx_policy_cache.lock);
hif_set_tx_rate_retry_policy(wvif, arg); hif_set_tx_rate_retry_policy(wvif, i, tmp_rates);
} else { } else {
spin_unlock_bh(&wvif->tx_policy_cache.lock); spin_unlock_bh(&wvif->tx_policy_cache.lock);
} }
} while (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES); } while (i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES);
kfree(arg);
return 0; return 0;
} }
......
...@@ -181,13 +181,26 @@ static inline int hif_set_association_mode(struct wfx_vif *wvif, ...@@ -181,13 +181,26 @@ static inline int hif_set_association_mode(struct wfx_vif *wvif,
} }
static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif,
struct hif_mib_set_tx_rate_retry_policy *arg) int policy_index, uint8_t *rates)
{ {
size_t size = struct_size(arg, tx_rate_retry_policy, struct hif_mib_set_tx_rate_retry_policy *arg;
arg->num_tx_rate_policies); size_t size = struct_size(arg, tx_rate_retry_policy, 1);
int ret;
return hif_write_mib(wvif->wdev, wvif->id, arg = kzalloc(size, GFP_KERNEL);
arg->num_tx_rate_policies = 1;
arg->tx_rate_retry_policy[0].policy_index = policy_index;
arg->tx_rate_retry_policy[0].short_retry_count = 255;
arg->tx_rate_retry_policy[0].long_retry_count = 255;
arg->tx_rate_retry_policy[0].first_rate_sel = 1;
arg->tx_rate_retry_policy[0].terminate = 1;
arg->tx_rate_retry_policy[0].count_init = 1;
memcpy(&arg->tx_rate_retry_policy[0].rates, rates,
sizeof(arg->tx_rate_retry_policy[0].rates));
ret = hif_write_mib(wvif->wdev, wvif->id,
HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size);
kfree(arg);
return ret;
} }
static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif, static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES 2 #define HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES 2
static u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates) u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates)
{ {
int i; int i;
u32 ret = 0; u32 ret = 0;
......
...@@ -92,5 +92,6 @@ void wfx_suspend_resume(struct wfx_vif *wvif, ...@@ -92,5 +92,6 @@ void wfx_suspend_resume(struct wfx_vif *wvif,
void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad); void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad);
void wfx_update_filtering(struct wfx_vif *wvif); void wfx_update_filtering(struct wfx_vif *wvif);
int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable); int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable);
u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates);
#endif /* WFX_STA_H */ #endif /* WFX_STA_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment