123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
#ifndef STA_INFO_H
#define STA_INFO_H
#include <linux/list.h>
#include <linux/types.h>
#include <linux/if_ether.h>
#include <linux/workqueue.h>
#include <linux/average.h>
#include <linux/bitfield.h>
#include <linux/etherdevice.h>
#include <linux/rhashtable.h>
#include <linux/u64_stats_sync.h>
#include "key.h"
enum ieee80211_sta_info_flags {
WLAN_STA_AUTH,
WLAN_STA_ASSOC,
WLAN_STA_PS_STA,
WLAN_STA_AUTHORIZED,
WLAN_STA_SHORT_PREAMBLE,
WLAN_STA_WDS,
WLAN_STA_CLEAR_PS_FILT,
WLAN_STA_MFP,
WLAN_STA_BLOCK_BA,
WLAN_STA_PS_DRIVER,
WLAN_STA_PSPOLL,
WLAN_STA_TDLS_PEER,
WLAN_STA_TDLS_PEER_AUTH,
WLAN_STA_TDLS_INITIATOR,
WLAN_STA_TDLS_CHAN_SWITCH,
WLAN_STA_TDLS_OFF_CHANNEL,
WLAN_STA_TDLS_WIDER_BW,
WLAN_STA_UAPSD,
WLAN_STA_SP,
WLAN_STA_4ADDR_EVENT,
WLAN_STA_INSERTED,
WLAN_STA_RATE_CONTROL,
WLAN_STA_TOFFSET_KNOWN,
WLAN_STA_MPSP_OWNER,
WLAN_STA_MPSP_RECIPIENT,
WLAN_STA_PS_DELIVER,
WLAN_STA_USES_ENCRYPTION,
WLAN_STA_DECAP_OFFLOAD,
NUM_WLAN_STA_FLAGS,
};
#define ADDBA_RESP_INTERVAL HZ
#define HT_AGG_MAX_RETRIES 15
#define HT_AGG_BURST_RETRIES 3
#define HT_AGG_RETRIES_PERIOD (15 * HZ)
#define HT_AGG_STATE_DRV_READY 0
#define HT_AGG_STATE_RESPONSE_RECEIVED 1
#define HT_AGG_STATE_OPERATIONAL 2
#define HT_AGG_STATE_STOPPING 3
#define HT_AGG_STATE_WANT_START 4
#define HT_AGG_STATE_WANT_STOP 5
#define HT_AGG_STATE_START_CB 6
#define HT_AGG_STATE_STOP_CB 7
#define HT_AGG_STATE_SENT_ADDBA 8
DECLARE_EWMA(avg_signal, 10, 8)
enum ieee80211_agg_stop_reason {
AGG_STOP_DECLINED,
AGG_STOP_LOCAL_REQUEST,
AGG_STOP_PEER_REQUEST,
AGG_STOP_DESTROY_STA,
};
#define AIRTIME_USE_TX BIT(0)
#define AIRTIME_USE_RX BIT(1)
struct airtime_info {
u64 rx_airtime;
u64 tx_airtime;
unsigned long last_active;
s32 deficit;
atomic_t aql_tx_pending;
u32 aql_limit_low;
u32 aql_limit_high;
};
void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
struct sta_info *sta, u8 ac,
u16 tx_airtime, bool tx_completed,
bool mcast);
struct sta_info;
struct tid_ampdu_tx {
struct rcu_head rcu_head;
struct timer_list session_timer;
struct timer_list addba_resp_timer;
struct sk_buff_head pending;
struct sta_info *sta;
unsigned long state;
unsigned long last_tx;
u16 timeout;
u8 dialog_token;
u8 stop_initiator;
bool tx_stop;
u16 buf_size;
u16 ssn;
u16 failed_bar_ssn;
bool bar_pending;
bool amsdu;
bool ndp;
u8 tid;
};
struct tid_ampdu_rx {
struct rcu_head rcu_head;
spinlock_t reorder_lock;
u64 reorder_buf_filtered;
struct sta_info *sta;
struct timer_list session_timer;
struct timer_list reorder_timer;
unsigned long last_rx;
u16 head_seq_num;
u16 stored_mpdu_num;
u16 ssn;
u16 buf_size;
u16 timeout;
u8 tid;
u8 auto_seq:1,
removed:1,
started:1;
struct {
struct sk_buff_head buf;
unsigned long time;
} reorder[];
};
struct sta_ampdu_mlme {
struct tid_ampdu_rx __rcu *tid_rx[IEEE80211_NUM_TIDS];
u8 tid_rx_token[IEEE80211_NUM_TIDS];
unsigned long tid_rx_timer_expired[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
unsigned long tid_rx_stop_requested[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
unsigned long tid_rx_manage_offl[BITS_TO_LONGS(2 * IEEE80211_NUM_TIDS)];
unsigned long agg_session_valid[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
unsigned long unexpected_agg[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
struct wiphy_work work;
struct tid_ampdu_tx __rcu *tid_tx[IEEE80211_NUM_TIDS];
struct tid_ampdu_tx *tid_start_tx[IEEE80211_NUM_TIDS];
unsigned long last_addba_req_time[IEEE80211_NUM_TIDS];
u8 addba_req_num[IEEE80211_NUM_TIDS];
u8 dialog_token_allocator;
};
#define IEEE80211_TID_UNRESERVED 0xff
#define IEEE80211_FAST_XMIT_MAX_IV 18
struct ieee80211_fast_tx {
struct ieee80211_key *key;
u8 hdr_len;
u8 sa_offs, da_offs, pn_offs;
u8 band;
u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
sizeof(rfc1042_header)] __aligned(2);
struct rcu_head rcu_head;
};
struct ieee80211_fast_rx {
struct net_device *dev;
enum nl80211_iftype vif_type;
u8 vif_addr[ETH_ALEN] __aligned(2);
u8 rfc1042_hdr[6] __aligned(2);
__be16 control_port_protocol;
__le16 expected_ds_bits;
u8 icv_len;
u8 key:1,
internal_forward:1,
uses_rss:1;
u8 da_offs, sa_offs;
struct rcu_head rcu_head;
};
DECLARE_EWMA(mesh_fail_avg, 20, 8)
DECLARE_EWMA(mesh_tx_rate_avg, 8, 16)
struct mesh_sta {
struct timer_list plink_timer;
struct sta_info *plink_sta;
s64 t_offset;
s64 t_offset_setpoint;
spinlock_t plink_lock;
u16 llid;
u16 plid;
u16 aid;
u16 reason;
u8 plink_retries;
bool processed_beacon;
bool connected_to_gate;
bool connected_to_as;
enum nl80211_plink_state plink_state;
u32 plink_timeout;
enum nl80211_mesh_power_mode local_pm;
enum nl80211_mesh_power_mode peer_pm;
enum nl80211_mesh_power_mode nonpeer_pm;
struct ewma_mesh_fail_avg fail_avg;
struct ewma_mesh_tx_rate_avg tx_rate_avg;
};
DECLARE_EWMA(signal, 10, 8)
struct ieee80211_sta_rx_stats {
unsigned long packets;
unsigned long last_rx;
unsigned long num_duplicates;
unsigned long fragments;
unsigned long dropped;
int last_signal;
u8 chains;
s8 chain_signal_last[IEEE80211_MAX_CHAINS];
u32 last_rate;
struct u64_stats_sync syncp;
u64_stats_t bytes;
u64_stats_t msdu[IEEE80211_NUM_TIDS + 1];
};
#define IEEE80211_FRAGMENT_MAX 4
struct ieee80211_fragment_entry {
struct sk_buff_head skb_list;
unsigned long first_frag_time;
u16 seq;
u16 extra_len;
u16 last_frag;
u8 rx_queue;
u8 check_sequential_pn:1,
is_protected:1;
u8 last_pn[6];
unsigned int key_color;
};
struct ieee80211_fragment_cache {
struct ieee80211_fragment_entry entries[IEEE80211_FRAGMENT_MAX];
unsigned int next;
};
struct link_sta_info {
u8 addr[ETH_ALEN];
u8 link_id;
u8 op_mode_nss, capa_nss;
struct rhlist_head link_hash_node;
struct sta_info *sta;
struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS +
NUM_DEFAULT_MGMT_KEYS +
NUM_DEFAULT_BEACON_KEYS];
struct ieee80211_key __rcu *cigtk[NUM_CTRL_KEYS];
struct ieee80211_sta_rx_stats __percpu *pcpu_rx_stats;
struct ieee80211_sta_rx_stats rx_stats;
struct {
struct ewma_signal signal;
struct ewma_signal chain_signal[IEEE80211_MAX_CHAINS];
} rx_stats_avg;
struct {
unsigned long filtered;
unsigned long retry_failed, retry_count;
unsigned int lost_packets;
unsigned long last_pkt_time;
u64 msdu_retries[IEEE80211_NUM_TIDS + 1];
u64 msdu_failed[IEEE80211_NUM_TIDS + 1];
unsigned long last_ack;
s8 last_ack_signal;
bool ack_signal_filled;
struct ewma_avg_signal avg_ack_signal;
} status_stats;
struct {
u64 packets[IEEE80211_NUM_ACS];
u64 bytes[IEEE80211_NUM_ACS];
struct ieee80211_tx_rate last_rate;
struct rate_info last_rate_info;
u64 msdu[IEEE80211_NUM_TIDS + 1];
} tx_stats;
enum ieee80211_sta_rx_bandwidth op_mode_bw;
enum ieee80211_sta_rx_bandwidth rx_omi_bw_rx,
rx_omi_bw_tx,
rx_omi_bw_staging;
enum ieee80211_sta_rx_bandwidth uhr_usable_tx_width;
bool uhr_dbe_enabled;
#ifdef CONFIG_MAC80211_DEBUGFS
struct dentry *debugfs_dir;
#endif
struct ieee80211_link_sta *pub;
};
struct ieee80211_sta_removed_link_stats {
u32 rx_packets;
u32 tx_packets;
u64 rx_bytes;
u64 tx_bytes;
u32 tx_retries;
u32 tx_failed;
u32 rx_dropped_misc;
u32 beacon_loss_count;
u32 expected_throughput;
struct {
u64 rx_msdu;
u64 tx_msdu;
u64 tx_msdu_retries;
u64 tx_msdu_failed;
} pertid_stats;
};
struct sta_info {
struct list_head list, free_list;
struct rcu_head rcu_head;
struct rhlist_head hash_node;
u8 addr[ETH_ALEN];
struct ieee80211_local *local;
struct ieee80211_sub_if_data *sdata;
struct ieee80211_key __rcu *ptk[NUM_DEFAULT_KEYS];
u8 ptk_idx;
struct rate_control_ref *rate_ctrl;
void *rate_ctrl_priv;
spinlock_t rate_ctrl_lock;
spinlock_t lock;
struct ieee80211_fast_tx __rcu *fast_tx;
struct ieee80211_fast_rx __rcu *fast_rx;
#ifdef CONFIG_MAC80211_MESH
struct mesh_sta *mesh;
#endif
struct work_struct drv_deliver_wk;
u16 listen_interval;
bool dead;
bool removed;
bool uploaded;
enum ieee80211_sta_state sta_state;
unsigned long _flags;
spinlock_t ps_lock;
struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
unsigned long driver_buffered_tids;
unsigned long txq_buffered_tids;
u64 assoc_at;
long last_connected;
__le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
struct airtime_info airtime[IEEE80211_NUM_ACS];
u16 airtime_weight;
struct sta_ampdu_mlme ampdu_mlme;
#ifdef CONFIG_MAC80211_DEBUGFS
struct dentry *debugfs_dir;
#endif
u8 reserved_tid;
s8 amsdu_mesh_control;
struct cfg80211_chan_def tdls_chandef;
struct ieee80211_fragment_cache frags;
struct ieee80211_sta_aggregates cur;
struct link_sta_info deflink;
struct link_sta_info __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
struct ieee80211_sta_removed_link_stats rem_link_stats;
struct ieee80211_sta sta;
};
static inline int ieee80211_tdls_sta_link_id(struct sta_info *sta)
{
return sta->sta.valid_links ? __ffs(sta->sta.valid_links) : 0;
}
static inline enum nl80211_plink_state sta_plink_state(struct sta_info *sta)
{
#ifdef CONFIG_MAC80211_MESH
return sta->mesh->plink_state;
#endif
return NL80211_PLINK_LISTEN;
}
static inline void set_sta_flag(struct sta_info *sta,
enum ieee80211_sta_info_flags flag)
{
WARN_ON(flag == WLAN_STA_AUTH ||
flag == WLAN_STA_ASSOC ||
flag == WLAN_STA_AUTHORIZED);
set_bit(flag, &sta->_flags);
}
static inline void clear_sta_flag(struct sta_info *sta,
enum ieee80211_sta_info_flags flag)
{
WARN_ON(flag == WLAN_STA_AUTH ||
flag == WLAN_STA_ASSOC ||
flag == WLAN_STA_AUTHORIZED);
clear_bit(flag, &sta->_flags);
}
static inline int test_sta_flag(struct sta_info *sta,
enum ieee80211_sta_info_flags flag)
{
return test_bit(flag, &sta->_flags);
}
static inline int test_and_clear_sta_flag(struct sta_info *sta,
enum ieee80211_sta_info_flags flag)
{
WARN_ON(flag == WLAN_STA_AUTH ||
flag == WLAN_STA_ASSOC ||
flag == WLAN_STA_AUTHORIZED);
return test_and_clear_bit(flag, &sta->_flags);
}
static inline int test_and_set_sta_flag(struct sta_info *sta,
enum ieee80211_sta_info_flags flag)
{
WARN_ON(flag == WLAN_STA_AUTH ||
flag == WLAN_STA_ASSOC ||
flag == WLAN_STA_AUTHORIZED);
return test_and_set_bit(flag, &sta->_flags);
}
int sta_info_move_state(struct sta_info *sta,
enum ieee80211_sta_state new_state);
static inline void sta_info_pre_move_state(struct sta_info *sta,
enum ieee80211_sta_state new_state)
{
int ret;
WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
ret = sta_info_move_state(sta, new_state);
WARN_ON_ONCE(ret);
}
void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
struct tid_ampdu_tx *tid_tx);
#define rcu_dereference_protected_tid_tx(sta, tid) \
rcu_dereference_protected((sta)->ampdu_mlme.tid_tx[tid], \
lockdep_is_held(&(sta)->lock) || \
lockdep_is_held(&(sta)->local->hw.wiphy->mtx));
#define STA_MAX_TX_BUFFER 64
#define STA_TX_BUFFER_EXPIRE (10 * HZ)
#define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local,
const u8 *addr);
struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
const u8 *addr);
struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
const u8 *addr);
struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
const u8 *sta_addr, const u8 *vif_addr);
#define for_each_sta_info(local, _addr, _sta, _tmp) \
rhl_for_each_entry_rcu(_sta, _tmp, \
sta_info_hash_lookup(local, _addr), hash_node)
struct rhlist_head *link_sta_info_hash_lookup(struct ieee80211_local *local,
const u8 *addr);
#define for_each_link_sta_info(local, _addr, _sta, _tmp) \
rhl_for_each_entry_rcu(_sta, _tmp, \
link_sta_info_hash_lookup(local, _addr), \
link_hash_node)
struct link_sta_info *
link_sta_info_get_bss(struct ieee80211_sub_if_data *sdata, const u8 *addr);
struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
int idx);
struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
const u8 *addr, gfp_t gfp);
struct sta_info *sta_info_alloc_with_link(struct ieee80211_sub_if_data *sdata,
const u8 *mld_addr,
unsigned int link_id,
const u8 *link_addr,
gfp_t gfp);
void sta_info_free(struct ieee80211_local *local, struct sta_info *sta);
int sta_info_insert(struct sta_info *sta);
int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU);
int __must_check __sta_info_destroy(struct sta_info *sta);
int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata,
const u8 *addr);
int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
const u8 *addr);
void sta_info_recalc_tim(struct sta_info *sta);
int sta_info_init(struct ieee80211_local *local);
void sta_info_stop(struct ieee80211_local *local);
int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans,
int link_id, struct sta_info *do_not_flush_sta);
static inline int sta_info_flush(struct ieee80211_sub_if_data *sdata,
int link_id)
{
return __sta_info_flush(sdata, false, link_id, NULL);
}
void sta_set_rate_info_tx(struct sta_info *sta,
const struct ieee80211_tx_rate *rate,
struct rate_info *rinfo);
int __sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
bool tidstats, bool locked);
static inline void sta_set_sinfo(struct sta_info *sta,
struct station_info *sinfo, bool tidstats)
{
__sta_set_sinfo(sta, sinfo, tidstats, true);
}
void sta_set_accumulated_removed_links_sinfo(struct sta_info *sta,
struct station_info *sinfo);
u32 sta_get_expected_throughput(struct sta_info *sta);
void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
unsigned long exp_time);
int ieee80211_sta_allocate_link(struct sta_info *sta, unsigned int link_id);
void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id);
int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id);
void ieee80211_sta_remove_link(struct sta_info *sta, unsigned int link_id);
void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta);
void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta);
void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta);
unsigned long ieee80211_sta_last_active(struct sta_info *sta, int link_id);
void ieee80211_sta_init_nss_bw_capa(struct link_sta_info *link_sta,
struct cfg80211_chan_def *chandef);
void ieee80211_sta_set_max_amsdu_subframes(struct sta_info *sta,
const u8 *ext_capab,
unsigned int ext_capab_len);
void __ieee80211_sta_recalc_aggregates(struct sta_info *sta, u16 active_links);
enum ieee80211_sta_bw_direction {
IEEE80211_STA_BW_RX_FROM_STA,
IEEE80211_STA_BW_TX_TO_STA,
};
enum ieee80211_sta_rx_bandwidth
ieee80211_sta_current_bw(struct link_sta_info *link_sta,
struct cfg80211_chan_def *chandef,
enum ieee80211_sta_bw_direction direction);
bool ieee80211_link_sta_update_rc_bw(struct ieee80211_link_data *link,
struct link_sta_info *link_sta);
enum sta_stats_type {
STA_STATS_RATE_TYPE_INVALID = 0,
STA_STATS_RATE_TYPE_LEGACY,
STA_STATS_RATE_TYPE_HT,
STA_STATS_RATE_TYPE_VHT,
STA_STATS_RATE_TYPE_HE,
STA_STATS_RATE_TYPE_S1G,
STA_STATS_RATE_TYPE_EHT,
STA_STATS_RATE_TYPE_UHR,
};
#define STA_STATS_FIELD_TYPE 0x0000000F
#define STA_STATS_FIELD_BW 0x000001F0
#define STA_STATS_FIELD_RESERVED 0x00000E00
#define STA_STATS_FIELD_LEGACY_IDX 0x0000F000
#define STA_STATS_FIELD_LEGACY_BAND 0x000F0000
#define STA_STATS_FIELD_HT_MCS 0x000FF000
#define STA_STATS_FIELD_VHT_MCS 0x0000F000
#define STA_STATS_FIELD_VHT_NSS 0x000F0000
#define STA_STATS_FIELD_SGI 0x00100000
#define STA_STATS_FIELD_HE_MCS 0x0000F000
#define STA_STATS_FIELD_HE_NSS 0x000F0000
#define STA_STATS_FIELD_HE_RU 0x00700000
#define STA_STATS_FIELD_HE_GI 0x01800000
#define STA_STATS_FIELD_HE_DCM 0x02000000
#define STA_STATS_FIELD_EHT_MCS 0x0000F000
#define STA_STATS_FIELD_EHT_NSS 0x000F0000
#define STA_STATS_FIELD_EHT_RU 0x00F00000
#define STA_STATS_FIELD_EHT_GI 0x03000000
#define STA_STATS_FIELD_UHR_MCS 0x0001F000
#define STA_STATS_FIELD_UHR_NSS 0x001E0000
#define STA_STATS_FIELD_UHR_RU 0x01E00000
#define STA_STATS_FIELD_UHR_GI 0x06000000
#define STA_STATS_FIELD_UHR_ELR 0x08000000
#define STA_STATS_FIELD_UHR_IM 0x10000000
#define STA_STATS_FIELD_S1G_MCS 0x0000F000
#define STA_STATS_FIELD_S1G_NSS 0x000F0000
#define STA_STATS_FIELD(_n, _v) FIELD_PREP(STA_STATS_FIELD_ ## _n, _v)
#define STA_STATS_GET(_n, _v) FIELD_GET(STA_STATS_FIELD_ ## _n, _v)
#define STA_STATS_RATE_INVALID 0
static inline u32 sta_stats_encode_rate(struct ieee80211_rx_status *s)
{
u32 r;
r = STA_STATS_FIELD(BW, s->bw);
switch (s->encoding) {
case RX_ENC_HT:
case RX_ENC_VHT:
case RX_ENC_S1G:
if (s->enc_flags & RX_ENC_FLAG_SHORT_GI)
r |= STA_STATS_FIELD(SGI, 1);
break;
default:
break;
}
switch (s->encoding) {
case RX_ENC_VHT:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_VHT);
r |= STA_STATS_FIELD(VHT_NSS, s->nss);
r |= STA_STATS_FIELD(VHT_MCS, s->rate_idx);
break;
case RX_ENC_HT:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_HT);
r |= STA_STATS_FIELD(HT_MCS, s->rate_idx);
break;
case RX_ENC_LEGACY:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_LEGACY);
r |= STA_STATS_FIELD(LEGACY_BAND, s->band);
r |= STA_STATS_FIELD(LEGACY_IDX, s->rate_idx);
break;
case RX_ENC_HE:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_HE);
r |= STA_STATS_FIELD(HE_NSS, s->nss);
r |= STA_STATS_FIELD(HE_MCS, s->rate_idx);
r |= STA_STATS_FIELD(HE_GI, s->he_gi);
r |= STA_STATS_FIELD(HE_RU, s->he_ru);
r |= STA_STATS_FIELD(HE_DCM, s->he_dcm);
break;
case RX_ENC_EHT:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_EHT);
r |= STA_STATS_FIELD(EHT_NSS, s->nss);
r |= STA_STATS_FIELD(EHT_MCS, s->rate_idx);
r |= STA_STATS_FIELD(EHT_GI, s->eht.gi);
r |= STA_STATS_FIELD(EHT_RU, s->eht.ru);
break;
case RX_ENC_UHR:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_UHR);
r |= STA_STATS_FIELD(UHR_NSS, s->nss);
r |= STA_STATS_FIELD(UHR_MCS, s->rate_idx);
r |= STA_STATS_FIELD(UHR_GI, s->uhr.gi);
r |= STA_STATS_FIELD(UHR_RU, s->uhr.ru);
r |= STA_STATS_FIELD(UHR_ELR, s->uhr.elr);
r |= STA_STATS_FIELD(UHR_IM, s->uhr.im);
break;
case RX_ENC_S1G:
r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_S1G);
r |= STA_STATS_FIELD(S1G_NSS, s->nss);
r |= STA_STATS_FIELD(S1G_MCS, s->rate_idx);
break;
default:
WARN_ON(1);
return STA_STATS_RATE_INVALID;
}
return r;
}
#endif /* STA_INFO_H */