^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright 2002-2005, Devicescape Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright 2013-2014 Intel Mobile Communications GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright(c) 2015-2017 Intel Deutschland GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright(c) 2020-2021 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef STA_INFO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define STA_INFO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/average.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/bitfield.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/etherdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/rhashtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/u64_stats_sync.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "key.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * enum ieee80211_sta_info_flags - Stations flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * These flags are used with &struct sta_info's @flags member, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * only indirectly with set_sta_flag() and friends.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * @WLAN_STA_AUTH: Station is authenticated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @WLAN_STA_ASSOC: Station is associated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * @WLAN_STA_PS_STA: Station is in power-save mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @WLAN_STA_AUTHORIZED: Station is authorized to send/receive traffic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * This bit is always checked so needs to be enabled for all stations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * when virtual port control is not in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * frames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * @WLAN_STA_WDS: Station is one of our WDS peers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * frame to this station is transmitted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * @WLAN_STA_MFP: Management frame protection is used with this STA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * @WLAN_STA_BLOCK_BA: Used to deny ADDBA requests (both TX and RX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * during suspend/resume and station removal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @WLAN_STA_PS_DRIVER: driver requires keeping this station in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * power-save mode logically to flush frames that might still
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * be in the queues
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @WLAN_STA_PSPOLL: Station sent PS-poll while driver was keeping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * station in power-save mode, reply when the driver unblocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @WLAN_STA_TDLS_PEER: Station is a TDLS peer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @WLAN_STA_TDLS_PEER_AUTH: This TDLS peer is authorized to send direct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * packets. This means the link is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @WLAN_STA_TDLS_INITIATOR: We are the initiator of the TDLS link with this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * station.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @WLAN_STA_TDLS_CHAN_SWITCH: This TDLS peer supports TDLS channel-switching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @WLAN_STA_TDLS_OFF_CHANNEL: The local STA is currently off-channel with this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * TDLS peer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @WLAN_STA_TDLS_WIDER_BW: This TDLS peer supports working on a wider bw on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * the BSS base channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @WLAN_STA_UAPSD: Station requested unscheduled SP while driver was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * keeping station in power-save mode, reply when the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * unblocks the station.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * @WLAN_STA_SP: Station is in a service period, so don't try to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * reply to other uAPSD trigger frames or PS-Poll.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @WLAN_STA_INSERTED: This station is inserted into the hash table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @WLAN_STA_RATE_CONTROL: rate control was initialized for this station.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * @WLAN_STA_TOFFSET_KNOWN: toffset calculated for this station is valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * @WLAN_STA_MPSP_OWNER: local STA is owner of a mesh Peer Service Period.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @WLAN_STA_MPSP_RECIPIENT: local STA is recipient of a MPSP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @WLAN_STA_PS_DELIVER: station woke up, but we're still blocking TX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * until pending frames are delivered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @WLAN_STA_USES_ENCRYPTION: This station was configured for encryption,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * so drop all packets without a key later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @NUM_WLAN_STA_FLAGS: number of defined flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) enum ieee80211_sta_info_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) WLAN_STA_AUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) WLAN_STA_ASSOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) WLAN_STA_PS_STA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) WLAN_STA_AUTHORIZED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) WLAN_STA_SHORT_PREAMBLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) WLAN_STA_WDS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) WLAN_STA_CLEAR_PS_FILT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) WLAN_STA_MFP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) WLAN_STA_BLOCK_BA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) WLAN_STA_PS_DRIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) WLAN_STA_PSPOLL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) WLAN_STA_TDLS_PEER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) WLAN_STA_TDLS_PEER_AUTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) WLAN_STA_TDLS_INITIATOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) WLAN_STA_TDLS_CHAN_SWITCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) WLAN_STA_TDLS_OFF_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) WLAN_STA_TDLS_WIDER_BW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) WLAN_STA_UAPSD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) WLAN_STA_SP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) WLAN_STA_4ADDR_EVENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) WLAN_STA_INSERTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) WLAN_STA_RATE_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) WLAN_STA_TOFFSET_KNOWN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) WLAN_STA_MPSP_OWNER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) WLAN_STA_MPSP_RECIPIENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) WLAN_STA_PS_DELIVER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) WLAN_STA_USES_ENCRYPTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) NUM_WLAN_STA_FLAGS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define ADDBA_RESP_INTERVAL HZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define HT_AGG_MAX_RETRIES 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define HT_AGG_BURST_RETRIES 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define HT_AGG_RETRIES_PERIOD (15 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define HT_AGG_STATE_DRV_READY 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define HT_AGG_STATE_RESPONSE_RECEIVED 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define HT_AGG_STATE_OPERATIONAL 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define HT_AGG_STATE_STOPPING 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define HT_AGG_STATE_WANT_START 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define HT_AGG_STATE_WANT_STOP 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define HT_AGG_STATE_START_CB 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define HT_AGG_STATE_STOP_CB 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define HT_AGG_STATE_SENT_ADDBA 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) DECLARE_EWMA(avg_signal, 10, 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) enum ieee80211_agg_stop_reason {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) AGG_STOP_DECLINED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) AGG_STOP_LOCAL_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) AGG_STOP_PEER_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) AGG_STOP_DESTROY_STA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* Debugfs flags to enable/disable use of RX/TX airtime in scheduler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define AIRTIME_USE_TX BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define AIRTIME_USE_RX BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct airtime_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u64 rx_airtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) u64 tx_airtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) s64 deficit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) atomic_t aql_tx_pending; /* Estimated airtime for frames pending */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) u32 aql_limit_low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) u32 aql_limit_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct sta_info *sta, u8 ac,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) u16 tx_airtime, bool tx_completed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct sta_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * struct tid_ampdu_tx - TID aggregation information (Tx).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * @rcu_head: rcu head for freeing structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * @session_timer: check if we keep Tx-ing on the TID (by timeout value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * @addba_resp_timer: timer for peer's response to addba request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * @pending: pending frames queue -- use sta's spinlock to protect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * @sta: station we are attached to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * @dialog_token: dialog token for aggregation session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * @timeout: session timeout value to be filled in ADDBA requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * @tid: TID number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * @state: session state (see above)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * @last_tx: jiffies of last tx activity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * @stop_initiator: initiator of a session stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * @tx_stop: TX DelBA frame when stopping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * @buf_size: reorder buffer size at receiver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * @failed_bar_ssn: ssn of the last failed BAR tx attempt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * @bar_pending: BAR needs to be re-sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * @amsdu: support A-MSDU withing A-MDPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * This structure's lifetime is managed by RCU, assignments to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * the array holding it must hold the aggregation mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * The TX path can access it under RCU lock-free if, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * only if, the state has the flag %HT_AGG_STATE_OPERATIONAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * set. Otherwise, the TX path must also acquire the spinlock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * and re-check the state, see comments in the tx code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * touching it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct tid_ampdu_tx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct rcu_head rcu_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct timer_list session_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct timer_list addba_resp_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct sk_buff_head pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) unsigned long last_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) u16 timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u8 dialog_token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u8 stop_initiator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) bool tx_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u16 buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) u16 ssn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u16 failed_bar_ssn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) bool bar_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) bool amsdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) u8 tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * struct tid_ampdu_rx - TID aggregation information (Rx).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * @reorder_buf: buffer to reorder incoming aggregated MPDUs. An MPDU may be an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * A-MSDU with individually reported subframes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * @reorder_buf_filtered: bitmap indicating where there are filtered frames in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * the reorder buffer that should be ignored when releasing frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * @reorder_time: jiffies when skb was added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * @reorder_timer: releases expired frames from the reorder buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * @sta: station we are attached to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * @last_rx: jiffies of last rx activity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * @head_seq_num: head sequence number in reordering buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * @stored_mpdu_num: number of MPDUs in reordering buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * @ssn: Starting Sequence Number expected to be aggregated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * @buf_size: buffer size for incoming A-MPDUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * @timeout: reset timer value (in TUs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * @tid: TID number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * @rcu_head: RCU head used for freeing this struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * @reorder_lock: serializes access to reorder buffer, see below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * @auto_seq: used for offloaded BA sessions to automatically pick head_seq_and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * and ssn.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * @removed: this session is removed (but might have been found due to RCU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * @started: this session has started (head ssn or higher was received)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * This structure's lifetime is managed by RCU, assignments to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * the array holding it must hold the aggregation mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * The @reorder_lock is used to protect the members of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * struct, except for @timeout, @buf_size and @dialog_token,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * which are constant across the lifetime of the struct (the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * dialog token being used only for debugging).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct tid_ampdu_rx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct rcu_head rcu_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) spinlock_t reorder_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) u64 reorder_buf_filtered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) struct sk_buff_head *reorder_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) unsigned long *reorder_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct sta_info *sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct timer_list session_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct timer_list reorder_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) unsigned long last_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u16 head_seq_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) u16 stored_mpdu_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u16 ssn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) u16 buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) u16 timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) u8 tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) u8 auto_seq:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) removed:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) started:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * struct sta_ampdu_mlme - STA aggregation information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * @mtx: mutex to protect all TX data (except non-NULL assignments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * to tid_tx[idx], which are protected by the sta spinlock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * tid_start_tx is also protected by sta->lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * @tid_rx: aggregation info for Rx per TID -- RCU protected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * @tid_rx_token: dialog tokens for valid aggregation sessions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * @tid_rx_timer_expired: bitmap indicating on which TIDs the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * RX timer expired until the work for it runs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * @tid_rx_stop_requested: bitmap indicating which BA sessions per TID the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * driver requested to close until the work for it runs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * @tid_rx_manage_offl: bitmap indicating which BA sessions were requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * to be treated as started/stopped due to offloading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * @agg_session_valid: bitmap indicating which TID has a rx BA session open on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * @unexpected_agg: bitmap indicating which TID already sent a delBA due to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * unexpected aggregation related frames outside a session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * @work: work struct for starting/stopping aggregation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * @tid_tx: aggregation info for Tx per TID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * @tid_start_tx: sessions where start was requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * @last_addba_req_time: timestamp of the last addBA request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * @addba_req_num: number of times addBA request has been sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * @dialog_token_allocator: dialog token enumerator for each new session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct sta_ampdu_mlme {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct mutex mtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) /* rx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct tid_ampdu_rx __rcu *tid_rx[IEEE80211_NUM_TIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) u8 tid_rx_token[IEEE80211_NUM_TIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) unsigned long tid_rx_timer_expired[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) unsigned long tid_rx_stop_requested[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) unsigned long tid_rx_manage_offl[BITS_TO_LONGS(2 * IEEE80211_NUM_TIDS)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) unsigned long agg_session_valid[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) unsigned long unexpected_agg[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /* tx */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct tid_ampdu_tx __rcu *tid_tx[IEEE80211_NUM_TIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) struct tid_ampdu_tx *tid_start_tx[IEEE80211_NUM_TIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) unsigned long last_addba_req_time[IEEE80211_NUM_TIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) u8 addba_req_num[IEEE80211_NUM_TIDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u8 dialog_token_allocator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* Value to indicate no TID reservation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #define IEEE80211_TID_UNRESERVED 0xff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #define IEEE80211_FAST_XMIT_MAX_IV 18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * struct ieee80211_fast_tx - TX fastpath information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * @key: key to use for hw crypto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * @hdr: the 802.11 header to put with the frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * @hdr_len: actual 802.11 header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * @sa_offs: offset of the SA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * @da_offs: offset of the DA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * @pn_offs: offset where to put PN for crypto (or 0 if not needed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * @band: band this will be transmitted on, for tx_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * @rcu_head: RCU head to free this struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * This struct is small enough so that the common case (maximum crypto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * header length of 8 like for CCMP/GCMP) fits into a single 64-byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * cache line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) struct ieee80211_fast_tx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct ieee80211_key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) u8 hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) u8 sa_offs, da_offs, pn_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) u8 band;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) sizeof(rfc1042_header)] __aligned(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct rcu_head rcu_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * struct ieee80211_fast_rx - RX fastpath information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * @dev: netdevice for reporting the SKB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * @vif_type: (P2P-less) interface type of the original sdata (sdata->vif.type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * @vif_addr: interface address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * @rfc1042_hdr: copy of the RFC 1042 SNAP header (to have in cache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * @control_port_protocol: control port protocol copied from sdata
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * @expected_ds_bits: from/to DS bits expected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * @icv_len: length of the MIC if present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * @key: bool indicating encryption is expected (key is set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * @internal_forward: forward froms internally on AP/VLAN type interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * @uses_rss: copy of USES_RSS hw flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * @da_offs: offset of the DA in the header (for header conversion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * @sa_offs: offset of the SA in the header (for header conversion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * @rcu_head: RCU head for freeing this structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) struct ieee80211_fast_rx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) enum nl80211_iftype vif_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) u8 vif_addr[ETH_ALEN] __aligned(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) u8 rfc1042_hdr[6] __aligned(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) __be16 control_port_protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) __le16 expected_ds_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) u8 icv_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) u8 key:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) internal_forward:1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) uses_rss:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) u8 da_offs, sa_offs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) struct rcu_head rcu_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) /* we use only values in the range 0-100, so pick a large precision */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) DECLARE_EWMA(mesh_fail_avg, 20, 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) DECLARE_EWMA(mesh_tx_rate_avg, 8, 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * struct mesh_sta - mesh STA information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * @plink_lock: serialize access to plink fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) * @llid: Local link ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * @plid: Peer link ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * @aid: local aid supplied by peer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * @reason: Cancel reason on PLINK_HOLDING state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * @plink_retries: Retries in establishment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * @plink_state: peer link state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * @plink_timeout: timeout of peer link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * @plink_timer: peer link watch timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * @plink_sta: peer link watch timer's sta_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * @t_offset: timing offset relative to this host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * @t_offset_setpoint: reference timing offset of this sta to be used when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) * calculating clockdrift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * @local_pm: local link-specific power save mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) * @peer_pm: peer-specific power save mode towards local STA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * @nonpeer_pm: STA power save mode towards non-peer neighbors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * @processed_beacon: set to true after peer rates and capabilities are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * @connected_to_gate: true if mesh STA has a path to a mesh gate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * @connected_to_as: true if mesh STA has a path to a authentication server
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) * @fail_avg: moving percentage of failed MSDUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) * @tx_rate_avg: moving average of tx bitrate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) struct mesh_sta {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) struct timer_list plink_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) struct sta_info *plink_sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) s64 t_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) s64 t_offset_setpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) spinlock_t plink_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) u16 llid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) u16 plid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) u16 aid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) u16 reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) u8 plink_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) bool processed_beacon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) bool connected_to_gate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) bool connected_to_as;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) enum nl80211_plink_state plink_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) u32 plink_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) /* mesh power save */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) enum nl80211_mesh_power_mode local_pm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) enum nl80211_mesh_power_mode peer_pm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) enum nl80211_mesh_power_mode nonpeer_pm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* moving percentage of failed MSDUs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) struct ewma_mesh_fail_avg fail_avg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /* moving average of tx bitrate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) struct ewma_mesh_tx_rate_avg tx_rate_avg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) DECLARE_EWMA(signal, 10, 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) struct ieee80211_sta_rx_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) unsigned long packets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) unsigned long last_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) unsigned long num_duplicates;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) unsigned long fragments;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) unsigned long dropped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) int last_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) u8 chains;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) s8 chain_signal_last[IEEE80211_MAX_CHAINS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) u32 last_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) struct u64_stats_sync syncp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) u64 bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) u64 msdu[IEEE80211_NUM_TIDS + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) * IEEE 802.11-2016 (10.6 "Defragmentation") recommends support for "concurrent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) * reception of at least one MSDU per access category per associated STA"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) * on APs, or "at least one MSDU per access category" on other interface types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) * This limit can be increased by changing this define, at the cost of slower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) * frame reassembly and increased memory use while fragments are pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) #define IEEE80211_FRAGMENT_MAX 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) struct ieee80211_fragment_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) struct sk_buff_head skb_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) unsigned long first_frag_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) u16 seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) u16 extra_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) u16 last_frag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) u8 rx_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) u8 check_sequential_pn:1, /* needed for CCMP/GCMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) is_protected:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) unsigned int key_color;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) struct ieee80211_fragment_cache {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct ieee80211_fragment_entry entries[IEEE80211_FRAGMENT_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) unsigned int next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * The bandwidth threshold below which the per-station CoDel parameters will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * scaled to be more lenient (to prevent starvation of slow stations). This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) * value will be scaled by the number of active stations when it is being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * applied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #define STA_SLOW_THRESHOLD 6000 /* 6 Mbps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * struct sta_info - STA information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * This structure collects information about a station that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * mac80211 is communicating with.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * @list: global linked list entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * @free_list: list entry for keeping track of stations to free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * @hash_node: hash node for rhashtable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * @addr: station's MAC address - duplicated from public part to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * let the hash table work with just a single cacheline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * @local: pointer to the global information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * @sdata: virtual interface this station belongs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * @ptk: peer keys negotiated with this station, if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * @ptk_idx: last installed peer key index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * @gtk: group keys negotiated with this station, if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * @rate_ctrl: rate control algorithm reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * @rate_ctrl_lock: spinlock used to protect rate control data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * (data inside the algorithm, so serializes calls there)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * @rate_ctrl_priv: rate control private per-STA pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * @lock: used for locking all fields that require locking, see comments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * in the header file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * @drv_deliver_wk: used for delivering frames after driver PS unblocking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * @listen_interval: listen interval of this station, when we're acting as AP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * @ps_lock: used for powersave (when mac80211 is the AP) related locking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * @ps_tx_buf: buffers (per AC) of frames to transmit to this station
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) * when it leaves power saving state or polls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * @tx_filtered: buffers (per AC) of frames we already tried to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * transmit but were filtered by hardware due to STA having
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * entered power saving state, these are also delivered to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * the station when it leaves powersave or polls for frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * @driver_buffered_tids: bitmap of TIDs the driver has data buffered on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * @txq_buffered_tids: bitmap of TIDs that mac80211 has txq data buffered on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * @assoc_at: clock boottime (in ns) of last association
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * @last_connected: time (in seconds) when a station got connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * @last_seq_ctrl: last received seq/frag number from this STA (per TID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * plus one for non-QoS frames)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * @tid_seq: per-TID sequence numbers for sending to this STA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) * @airtime: per-AC struct airtime_info describing airtime statistics for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * station
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) * @airtime_weight: station weight for airtime fairness calculation purposes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * @ampdu_mlme: A-MPDU state machine state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * @mesh: mesh STA information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * @debugfs_dir: debug filesystem directory dentry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * @dead: set to true when sta is unlinked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * @removed: set to true when sta is being removed from sta_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * @uploaded: set to true when sta is uploaded to the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * @sta: station information we share with the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * @sta_state: duplicates information about station state (for debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * @rcu_head: RCU head used for freeing this station struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) * @cur_max_bandwidth: maximum bandwidth to use for TX to the station,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * taken from HT/VHT capabilities or VHT operating mode notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * AP only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * @cipher_scheme: optional cipher scheme for this station
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * @cparams: CoDel parameters for this station.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) * @reserved_tid: reserved TID (if any, otherwise IEEE80211_TID_UNRESERVED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) * @fast_tx: TX fastpath information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * @fast_rx: RX fastpath information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * @tdls_chandef: a TDLS peer can have a wider chandef that is compatible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) * the BSS one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * @tx_stats: TX statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) * @tx_stats.packets: # of packets transmitted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * @tx_stats.bytes: # of bytes in all packets transmitted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * @tx_stats.last_rate: last TX rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * @tx_stats.msdu: # of transmitted MSDUs per TID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * @rx_stats: RX statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * @rx_stats_avg: averaged RX statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * @rx_stats_avg.signal: averaged signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * @rx_stats_avg.chain_signal: averaged per-chain signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * @pcpu_rx_stats: per-CPU RX statistics, assigned only if the driver needs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * this (by advertising the USES_RSS hw flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * @status_stats: TX status statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * @status_stats.filtered: # of filtered frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * @status_stats.retry_failed: # of frames that failed after retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * @status_stats.retry_count: # of retries attempted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * @status_stats.lost_packets: # of lost packets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) * @status_stats.last_pkt_time: timestamp of last ACKed packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * @status_stats.msdu_retries: # of MSDU retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) * @status_stats.msdu_failed: # of failed MSDUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) * @status_stats.last_ack: last ack timestamp (jiffies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) * @status_stats.last_ack_signal: last ACK signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) * @status_stats.ack_signal_filled: last ACK signal validity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * @status_stats.avg_ack_signal: average ACK signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) * @frags: fragment cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) struct sta_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) /* General information, mostly static */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) struct list_head list, free_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct rcu_head rcu_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) struct rhlist_head hash_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) u8 addr[ETH_ALEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) struct ieee80211_local *local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) struct ieee80211_sub_if_data *sdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) NUM_DEFAULT_MGMT_KEYS +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) NUM_DEFAULT_BEACON_KEYS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) struct ieee80211_key __rcu *ptk[NUM_DEFAULT_KEYS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) u8 ptk_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) struct rate_control_ref *rate_ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) void *rate_ctrl_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) spinlock_t rate_ctrl_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct ieee80211_fast_tx __rcu *fast_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) struct ieee80211_fast_rx __rcu *fast_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct ieee80211_sta_rx_stats __percpu *pcpu_rx_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) #ifdef CONFIG_MAC80211_MESH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) struct mesh_sta *mesh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) struct work_struct drv_deliver_wk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) u16 listen_interval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) bool dead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) bool removed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) bool uploaded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) enum ieee80211_sta_state sta_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) /* use the accessors defined below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) unsigned long _flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) /* STA powersave lock and frame queues */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) spinlock_t ps_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) unsigned long driver_buffered_tids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) unsigned long txq_buffered_tids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) u64 assoc_at;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) long last_connected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) /* Updated from RX path only, no locking requirements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) struct ieee80211_sta_rx_stats rx_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) struct ewma_signal signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) struct ewma_signal chain_signal[IEEE80211_MAX_CHAINS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) } rx_stats_avg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /* Plus 1 for non-QoS frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) /* Updated from TX status path only, no locking requirements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) unsigned long filtered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) unsigned long retry_failed, retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) unsigned int lost_packets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) unsigned long last_pkt_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) u64 msdu_retries[IEEE80211_NUM_TIDS + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) u64 msdu_failed[IEEE80211_NUM_TIDS + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) unsigned long last_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) s8 last_ack_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) bool ack_signal_filled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) struct ewma_avg_signal avg_ack_signal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) } status_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) /* Updated from TX path only, no locking requirements */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) u64 packets[IEEE80211_NUM_ACS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) u64 bytes[IEEE80211_NUM_ACS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) struct ieee80211_tx_rate last_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) struct rate_info last_rate_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) u64 msdu[IEEE80211_NUM_TIDS + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) } tx_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) struct airtime_info airtime[IEEE80211_NUM_ACS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) u16 airtime_weight;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) * Aggregation information, locked with lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) struct sta_ampdu_mlme ampdu_mlme;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) #ifdef CONFIG_MAC80211_DEBUGFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) struct dentry *debugfs_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) enum ieee80211_sta_rx_bandwidth cur_max_bandwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) enum ieee80211_smps_mode known_smps_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) const struct ieee80211_cipher_scheme *cipher_scheme;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) struct codel_params cparams;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) u8 reserved_tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) struct cfg80211_chan_def tdls_chandef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) struct ieee80211_fragment_cache frags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) /* keep last! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) struct ieee80211_sta sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) static inline enum nl80211_plink_state sta_plink_state(struct sta_info *sta)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) #ifdef CONFIG_MAC80211_MESH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) return sta->mesh->plink_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) return NL80211_PLINK_LISTEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) static inline void set_sta_flag(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) enum ieee80211_sta_info_flags flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) WARN_ON(flag == WLAN_STA_AUTH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) flag == WLAN_STA_ASSOC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) flag == WLAN_STA_AUTHORIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) set_bit(flag, &sta->_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) static inline void clear_sta_flag(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) enum ieee80211_sta_info_flags flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) WARN_ON(flag == WLAN_STA_AUTH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) flag == WLAN_STA_ASSOC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) flag == WLAN_STA_AUTHORIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) clear_bit(flag, &sta->_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) static inline int test_sta_flag(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) enum ieee80211_sta_info_flags flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) return test_bit(flag, &sta->_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) static inline int test_and_clear_sta_flag(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) enum ieee80211_sta_info_flags flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) WARN_ON(flag == WLAN_STA_AUTH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) flag == WLAN_STA_ASSOC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) flag == WLAN_STA_AUTHORIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) return test_and_clear_bit(flag, &sta->_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) static inline int test_and_set_sta_flag(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) enum ieee80211_sta_info_flags flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) WARN_ON(flag == WLAN_STA_AUTH ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) flag == WLAN_STA_ASSOC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) flag == WLAN_STA_AUTHORIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) return test_and_set_bit(flag, &sta->_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) int sta_info_move_state(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) enum ieee80211_sta_state new_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) static inline void sta_info_pre_move_state(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) enum ieee80211_sta_state new_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) ret = sta_info_move_state(sta, new_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) WARN_ON_ONCE(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) struct tid_ampdu_tx *tid_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) static inline struct tid_ampdu_tx *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) rcu_dereference_protected_tid_tx(struct sta_info *sta, int tid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) return rcu_dereference_protected(sta->ampdu_mlme.tid_tx[tid],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) lockdep_is_held(&sta->lock) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) lockdep_is_held(&sta->ampdu_mlme.mtx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) /* Maximum number of frames to buffer per power saving station per AC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) #define STA_MAX_TX_BUFFER 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) /* Minimum buffered frame expiry time. If STA uses listen interval that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) * smaller than this value, the minimum value here is used instead. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) #define STA_TX_BUFFER_EXPIRE (10 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) /* How often station data is cleaned up (e.g., expiration of buffered frames)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) struct rhlist_head *sta_info_hash_lookup(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) * Get a STA info, must be under RCU read lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) /* user must hold sta_mtx or be in RCU critical section */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) const u8 *sta_addr, const u8 *vif_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) #define for_each_sta_info(local, _addr, _sta, _tmp) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) rhl_for_each_entry_rcu(_sta, _tmp, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) sta_info_hash_lookup(local, _addr), hash_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * Get STA info by index, BROKEN!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) * Create a new STA info, caller owns returned structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * until sta_info_insert().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) const u8 *addr, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) void sta_info_free(struct ieee80211_local *local, struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) * Insert STA info into hash table/list, returns zero or a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) * -EEXIST if (if the same MAC address is already present).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) * Calling the non-rcu version makes the caller relinquish,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) * the _rcu version calls read_lock_rcu() and must be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) * without it held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) int sta_info_insert(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) int __must_check __sta_info_destroy(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) void sta_info_recalc_tim(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) int sta_info_init(struct ieee80211_local *local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) void sta_info_stop(struct ieee80211_local *local);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) * __sta_info_flush - flush matching STA entries from the STA table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * Returns the number of removed STA entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) * @sdata: sdata to remove all stations from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) * @vlans: if the given interface is an AP interface, also flush VLANs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) * sta_info_flush - flush matching STA entries from the STA table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) * Returns the number of removed STA entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) * @sdata: sdata to remove all stations from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) static inline int sta_info_flush(struct ieee80211_sub_if_data *sdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) return __sta_info_flush(sdata, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) void sta_set_rate_info_tx(struct sta_info *sta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) const struct ieee80211_tx_rate *rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) struct rate_info *rinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) bool tidstats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) u32 sta_get_expected_throughput(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) unsigned long exp_time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) u8 sta_info_tx_streams(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) void ieee80211_sta_ps_deliver_poll_response(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) void ieee80211_sta_ps_deliver_uapsd(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) unsigned long ieee80211_sta_last_active(struct sta_info *sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) enum sta_stats_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) STA_STATS_RATE_TYPE_INVALID = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) STA_STATS_RATE_TYPE_LEGACY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) STA_STATS_RATE_TYPE_HT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) STA_STATS_RATE_TYPE_VHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) STA_STATS_RATE_TYPE_HE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) STA_STATS_RATE_TYPE_S1G,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) #define STA_STATS_FIELD_HT_MCS GENMASK( 7, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) #define STA_STATS_FIELD_LEGACY_IDX GENMASK( 3, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) #define STA_STATS_FIELD_LEGACY_BAND GENMASK( 7, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) #define STA_STATS_FIELD_VHT_MCS GENMASK( 3, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) #define STA_STATS_FIELD_VHT_NSS GENMASK( 7, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) #define STA_STATS_FIELD_HE_MCS GENMASK( 3, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) #define STA_STATS_FIELD_HE_NSS GENMASK( 7, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) #define STA_STATS_FIELD_BW GENMASK(11, 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) #define STA_STATS_FIELD_SGI GENMASK(12, 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) #define STA_STATS_FIELD_TYPE GENMASK(15, 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) #define STA_STATS_FIELD_HE_RU GENMASK(18, 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) #define STA_STATS_FIELD_HE_GI GENMASK(20, 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) #define STA_STATS_FIELD_HE_DCM GENMASK(21, 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) #define STA_STATS_FIELD(_n, _v) FIELD_PREP(STA_STATS_FIELD_ ## _n, _v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) #define STA_STATS_GET(_n, _v) FIELD_GET(STA_STATS_FIELD_ ## _n, _v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) #define STA_STATS_RATE_INVALID 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) static inline u32 sta_stats_encode_rate(struct ieee80211_rx_status *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) u32 r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) r = STA_STATS_FIELD(BW, s->bw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) if (s->enc_flags & RX_ENC_FLAG_SHORT_GI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) r |= STA_STATS_FIELD(SGI, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) switch (s->encoding) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) case RX_ENC_VHT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_VHT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) r |= STA_STATS_FIELD(VHT_NSS, s->nss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) r |= STA_STATS_FIELD(VHT_MCS, s->rate_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) case RX_ENC_HT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_HT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) r |= STA_STATS_FIELD(HT_MCS, s->rate_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) case RX_ENC_LEGACY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_LEGACY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) r |= STA_STATS_FIELD(LEGACY_BAND, s->band);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) r |= STA_STATS_FIELD(LEGACY_IDX, s->rate_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) case RX_ENC_HE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) r |= STA_STATS_FIELD(TYPE, STA_STATS_RATE_TYPE_HE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) r |= STA_STATS_FIELD(HE_NSS, s->nss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) r |= STA_STATS_FIELD(HE_MCS, s->rate_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) r |= STA_STATS_FIELD(HE_GI, s->he_gi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) r |= STA_STATS_FIELD(HE_RU, s->he_ru);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) r |= STA_STATS_FIELD(HE_DCM, s->he_dcm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) return STA_STATS_RATE_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) #endif /* STA_INFO_H */