xref: /linux/drivers/net/wireless/ath/ath12k/dp_peer.h (revision 1fd1dc41724319406b0aff221a352a400b0ddfc5)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5  */
6 
7 #ifndef ATH12K_DP_PEER_H
8 #define ATH12K_DP_PEER_H
9 
10 #include "dp_rx.h"
11 
12 #define ATH12K_DP_PEER_ID_INVALID              0x3FFF
13 
14 struct ppdu_user_delayba {
15 	u16 sw_peer_id;
16 	u32 info0;
17 	u16 ru_end;
18 	u16 ru_start;
19 	u32 info1;
20 	u32 rate_flags;
21 	u32 resp_rate_flags;
22 };
23 
24 #define ATH12K_PEER_ML_ID_VALID         BIT(13)
25 
26 struct ath12k_rx_peer_rate_stats {
27 	u64 ht_mcs_count[HAL_RX_MAX_MCS_HT + 1];
28 	u64 vht_mcs_count[HAL_RX_MAX_MCS_VHT + 1];
29 	u64 he_mcs_count[HAL_RX_MAX_MCS_HE + 1];
30 	u64 be_mcs_count[HAL_RX_MAX_MCS_BE + 1];
31 	u64 nss_count[HAL_RX_MAX_NSS];
32 	u64 bw_count[HAL_RX_BW_MAX];
33 	u64 gi_count[HAL_RX_GI_MAX];
34 	u64 legacy_count[HAL_RX_MAX_NUM_LEGACY_RATES];
35 	u64 rx_rate[HAL_RX_BW_MAX][HAL_RX_GI_MAX][HAL_RX_MAX_NSS][HAL_RX_MAX_MCS_HT + 1];
36 };
37 
38 struct ath12k_rx_peer_stats {
39 	u64 num_msdu;
40 	u64 num_mpdu_fcs_ok;
41 	u64 num_mpdu_fcs_err;
42 	u64 tcp_msdu_count;
43 	u64 udp_msdu_count;
44 	u64 other_msdu_count;
45 	u64 ampdu_msdu_count;
46 	u64 non_ampdu_msdu_count;
47 	u64 stbc_count;
48 	u64 beamformed_count;
49 	u64 coding_count[HAL_RX_SU_MU_CODING_MAX];
50 	u64 tid_count[IEEE80211_NUM_TIDS + 1];
51 	u64 pream_cnt[HAL_RX_PREAMBLE_MAX];
52 	u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX];
53 	u64 rx_duration;
54 	u64 dcm_count;
55 	u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX];
56 	struct ath12k_rx_peer_rate_stats pkt_stats;
57 	struct ath12k_rx_peer_rate_stats byte_stats;
58 };
59 
60 struct ath12k_wbm_tx_stats {
61 	u64 wbm_tx_comp_stats[HAL_WBM_REL_HTT_TX_COMP_STATUS_MAX];
62 };
63 
64 struct ath12k_dp_peer_stats {
65 	struct ath12k_rx_peer_stats *rx_stats;
66 	struct ath12k_wbm_tx_stats *wbm_tx_stats;
67 };
68 
69 DECLARE_EWMA(avg_rssi, 10, 8)
70 
71 struct ath12k_dp_link_peer {
72 	struct list_head list;
73 	struct ieee80211_sta *sta;
74 	struct ath12k_dp_peer *dp_peer;
75 	int vdev_id;
76 	u8 addr[ETH_ALEN];
77 	int peer_id;
78 	u16 ast_hash;
79 	u8 pdev_idx;
80 	u16 hw_peer_id;
81 
82 	struct ppdu_user_delayba ppdu_stats_delayba;
83 	bool delayba_flag;
84 	bool is_authorized;
85 	bool mlo;
86 	/* protected by ab->data_lock */
87 
88 	u16 ml_id;
89 
90 	/* any other ML info common for all partners can be added
91 	 * here and would be same for all partner peers.
92 	 */
93 	u8 ml_addr[ETH_ALEN];
94 
95 	/* To ensure only certain work related to dp is done once */
96 	bool primary_link;
97 
98 	/* for reference to ath12k_link_sta */
99 	u8 link_id;
100 
101 	/* peer addr based rhashtable list pointer */
102 	struct rhash_head rhash_addr;
103 
104 	u8 hw_link_id;
105 	u32 rx_tid_active_bitmask;
106 
107 	/* link stats */
108 	struct rate_info txrate;
109 	struct rate_info last_txrate;
110 	u64 rx_duration;
111 	u64 tx_duration;
112 	u8 rssi_comb;
113 	struct ewma_avg_rssi avg_rssi;
114 	struct ath12k_dp_peer_stats peer_stats;
115 	u32 tx_retry_failed;
116 	u32 tx_retry_count;
117 };
118 
119 void ath12k_dp_link_peer_unmap_event(struct ath12k_base *ab, u16 peer_id);
120 void ath12k_dp_link_peer_map_event(struct ath12k_base *ab, u8 vdev_id, u16 peer_id,
121 				   u8 *mac_addr, u16 ast_hash, u16 hw_peer_id);
122 
123 struct ath12k_dp_peer {
124 	struct list_head list;
125 	bool is_mlo;
126 	bool dp_setup_done;
127 
128 	u8 ucast_keyidx;
129 	u8 addr[ETH_ALEN];
130 
131 	u8 mcast_keyidx;
132 	bool ucast_ra_only;
133 	int peer_id;
134 	struct ieee80211_sta *sta;
135 
136 	u8 hw_links[ATH12K_GROUP_MAX_RADIO];
137 
138 	u16 sec_type_grp;
139 	u16 sec_type;
140 
141 	/* Info used in MMIC verification of * RX fragments */
142 	struct crypto_shash *tfm_mmic;
143 	struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
144 	struct ath12k_dp_link_peer __rcu *link_peers[ATH12K_NUM_MAX_LINKS];
145 	struct ath12k_reoq_buf reoq_bufs[IEEE80211_NUM_TIDS + 1];
146 	struct ath12k_dp_rx_tid rx_tid[IEEE80211_NUM_TIDS + 1];
147 };
148 
149 struct ath12k_dp_link_peer *
150 ath12k_dp_link_peer_find_by_vdev_and_addr(struct ath12k_dp *dp,
151 					  int vdev_id, const u8 *addr);
152 struct ath12k_dp_link_peer *
153 ath12k_dp_link_peer_find_by_addr(struct ath12k_dp *dp, const u8 *addr);
154 bool ath12k_dp_link_peer_exist_by_vdev_id(struct ath12k_dp *dp, int vdev_id);
155 struct ath12k_dp_link_peer *
156 ath12k_dp_link_peer_find_by_ast(struct ath12k_dp *dp, int ast_hash);
157 struct ath12k_dp_link_peer *
158 ath12k_dp_link_peer_find_by_pdev_and_addr(struct ath12k_dp *dp, u8 pdev_idx,
159 					  const u8 *addr);
160 struct ath12k_link_sta *ath12k_dp_link_peer_to_link_sta(struct ath12k_base *ab,
161 							struct ath12k_dp_link_peer *peer);
162 int ath12k_dp_link_peer_rhash_tbl_init(struct ath12k_dp *dp);
163 void ath12k_dp_link_peer_rhash_tbl_destroy(struct ath12k_dp *dp);
164 int ath12k_dp_link_peer_rhash_add(struct ath12k_dp *dp,
165 				  struct ath12k_dp_link_peer *peer);
166 void ath12k_dp_link_peer_rhash_delete(struct ath12k_dp *dp,
167 				      struct ath12k_dp_link_peer *peer);
168 int ath12k_dp_peer_create(struct ath12k_dp_hw *dp_hw, u8 *addr,
169 			  struct ath12k_dp_peer_create_params *params);
170 void ath12k_dp_peer_delete(struct ath12k_dp_hw *dp_hw, u8 *addr,
171 			   struct ieee80211_sta *sta);
172 struct ath12k_dp_peer *ath12k_dp_peer_find_by_addr(struct ath12k_dp_hw *dp_hw, u8 *addr);
173 struct ath12k_dp_peer *ath12k_dp_peer_find_by_addr_and_sta(struct ath12k_dp_hw *dp_hw,
174 							   u8 *addr,
175 							   struct ieee80211_sta *sta);
176 u16 ath12k_dp_peer_get_peerid_index(struct ath12k_dp *dp, u16 peer_id);
177 struct ath12k_dp_peer *ath12k_dp_peer_find_by_peerid(struct ath12k_pdev_dp *dp_pdev,
178 						     u16 peer_id);
179 struct ath12k_dp_link_peer *
180 ath12k_dp_link_peer_find_by_peerid(struct ath12k_pdev_dp *dp_pdev, u16 peer_id);
181 void ath12k_dp_link_peer_free(struct ath12k_dp_link_peer *peer);
182 #endif
183