Commit a42fa256 authored by Felix Fietkau's avatar Felix Fietkau Committed by Johannes Berg

mac80211: minstrel_ht: use bitfields to encode rate indexes

Get rid of a lot of divisions and modulo operations
Reduces code size and improves performance
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20210127055735.78599-1-nbd@nbd.nameSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 9e6d5126
This diff is collapsed.
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifndef __RC_MINSTREL_HT_H #ifndef __RC_MINSTREL_HT_H
#define __RC_MINSTREL_HT_H #define __RC_MINSTREL_HT_H
#include <linux/bitfield.h>
/* number of highest throughput rates to consider*/ /* number of highest throughput rates to consider*/
#define MAX_THR_RATES 4 #define MAX_THR_RATES 4
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */ #define SAMPLE_COLUMNS 10 /* number of columns in sample table */
...@@ -57,6 +59,17 @@ ...@@ -57,6 +59,17 @@
#define MCS_GROUP_RATES 10 #define MCS_GROUP_RATES 10
#define MI_RATE_IDX_MASK GENMASK(3, 0)
#define MI_RATE_GROUP_MASK GENMASK(15, 4)
#define MI_RATE(_group, _idx) \
(FIELD_PREP(MI_RATE_GROUP_MASK, _group) | \
FIELD_PREP(MI_RATE_IDX_MASK, _idx))
#define MI_RATE_IDX(_rate) FIELD_GET(MI_RATE_IDX_MASK, _rate)
#define MI_RATE_GROUP(_rate) FIELD_GET(MI_RATE_GROUP_MASK, _rate)
struct minstrel_priv { struct minstrel_priv {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
bool has_mrr; bool has_mrr;
......
...@@ -56,7 +56,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -56,7 +56,7 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
for (j = 0; j < MCS_GROUP_RATES; j++) { for (j = 0; j < MCS_GROUP_RATES; j++) {
struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
int idx = i * MCS_GROUP_RATES + j; int idx = MI_RATE(i, j);
unsigned int duration; unsigned int duration;
if (!(mi->supported[i] & BIT(j))) if (!(mi->supported[i] & BIT(j)))
...@@ -201,7 +201,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p) ...@@ -201,7 +201,7 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
for (j = 0; j < MCS_GROUP_RATES; j++) { for (j = 0; j < MCS_GROUP_RATES; j++) {
struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j]; struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
int idx = i * MCS_GROUP_RATES + j; int idx = MI_RATE(i, j);
unsigned int duration; unsigned int duration;
if (!(mi->supported[i] & BIT(j))) if (!(mi->supported[i] & BIT(j)))
......
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