ath10k: deduplicate bitrate to rate idx conversion
It's possible to derive rate index from bitrate without any additional mapping structures/logic. This should have little to none impact on performance since this is only done for management frames and the previous approach wasn't particularly optimized. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
This commit is contained in:
parent
5528e03270
commit
01cebe1c50
|
@ -104,6 +104,18 @@ u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
|
||||||
|
u32 bitrate)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < sband->n_bitrates; i++)
|
||||||
|
if (sband->bitrates[i].bitrate == bitrate)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**********/
|
/**********/
|
||||||
/* Crypto */
|
/* Crypto */
|
||||||
/**********/
|
/**********/
|
||||||
|
|
|
@ -55,8 +55,11 @@ bool ath10k_mac_is_peer_wep_key_set(struct ath10k *ar, const u8 *addr,
|
||||||
u8 keyidx);
|
u8 keyidx);
|
||||||
void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb);
|
void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb);
|
||||||
void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id);
|
void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id);
|
||||||
|
|
||||||
u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
|
u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
|
||||||
u8 hw_rate);
|
u8 hw_rate);
|
||||||
|
u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
|
||||||
|
u32 bitrate);
|
||||||
|
|
||||||
static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif)
|
static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1352,63 +1352,6 @@ static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
|
||||||
return band;
|
return band;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u8 get_rate_idx(u32 rate, enum ieee80211_band band)
|
|
||||||
{
|
|
||||||
u8 rate_idx = 0;
|
|
||||||
|
|
||||||
/* rate in Kbps */
|
|
||||||
switch (rate) {
|
|
||||||
case 1000:
|
|
||||||
rate_idx = 0;
|
|
||||||
break;
|
|
||||||
case 2000:
|
|
||||||
rate_idx = 1;
|
|
||||||
break;
|
|
||||||
case 5500:
|
|
||||||
rate_idx = 2;
|
|
||||||
break;
|
|
||||||
case 11000:
|
|
||||||
rate_idx = 3;
|
|
||||||
break;
|
|
||||||
case 6000:
|
|
||||||
rate_idx = 4;
|
|
||||||
break;
|
|
||||||
case 9000:
|
|
||||||
rate_idx = 5;
|
|
||||||
break;
|
|
||||||
case 12000:
|
|
||||||
rate_idx = 6;
|
|
||||||
break;
|
|
||||||
case 18000:
|
|
||||||
rate_idx = 7;
|
|
||||||
break;
|
|
||||||
case 24000:
|
|
||||||
rate_idx = 8;
|
|
||||||
break;
|
|
||||||
case 36000:
|
|
||||||
rate_idx = 9;
|
|
||||||
break;
|
|
||||||
case 48000:
|
|
||||||
rate_idx = 10;
|
|
||||||
break;
|
|
||||||
case 54000:
|
|
||||||
rate_idx = 11;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (band == IEEE80211_BAND_5GHZ) {
|
|
||||||
if (rate_idx > 3)
|
|
||||||
/* Omit CCK rates */
|
|
||||||
rate_idx -= 4;
|
|
||||||
else
|
|
||||||
rate_idx = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rate_idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If keys are configured, HW decrypts all frames
|
/* If keys are configured, HW decrypts all frames
|
||||||
* with protected bit set. Mark such frames as decrypted.
|
* with protected bit set. Mark such frames as decrypted.
|
||||||
*/
|
*/
|
||||||
|
@ -1490,6 +1433,7 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
|
||||||
struct wmi_mgmt_rx_ev_arg arg = {};
|
struct wmi_mgmt_rx_ev_arg arg = {};
|
||||||
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
|
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
|
||||||
struct ieee80211_hdr *hdr;
|
struct ieee80211_hdr *hdr;
|
||||||
|
struct ieee80211_supported_band *sband;
|
||||||
u32 rx_status;
|
u32 rx_status;
|
||||||
u32 channel;
|
u32 channel;
|
||||||
u32 phy_mode;
|
u32 phy_mode;
|
||||||
|
@ -1560,9 +1504,11 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
|
||||||
if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
|
if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
|
||||||
ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
|
ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
|
||||||
|
|
||||||
|
sband = &ar->mac.sbands[status->band];
|
||||||
|
|
||||||
status->freq = ieee80211_channel_to_frequency(channel, status->band);
|
status->freq = ieee80211_channel_to_frequency(channel, status->band);
|
||||||
status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
|
status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
|
||||||
status->rate_idx = get_rate_idx(rate, status->band);
|
status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100);
|
||||||
|
|
||||||
hdr = (struct ieee80211_hdr *)skb->data;
|
hdr = (struct ieee80211_hdr *)skb->data;
|
||||||
fc = le16_to_cpu(hdr->frame_control);
|
fc = le16_to_cpu(hdr->frame_control);
|
||||||
|
|
Loading…
Reference in New Issue