xref: /linux/drivers/net/wireless/ath/ath12k/dp_cmn.h (revision a34b0e4e21d6be3c3d620aa7f9dfbf0e9550c19e)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4  */
5 
6 #ifndef ATH12K_DP_CMN_H
7 #define ATH12K_DP_CMN_H
8 
9 #include "cmn_defs.h"
10 
11 struct ath12k_hw_group;
12 
13 /*
14  * ML Peer IDs start from 8192, assuming max SLO clients count 1536,
15  * then max peer id shall be 9728, therefore rounding the peer table size
16  * to the nearest next power of 2 i.e 16384.
17  */
18 #define MAX_DP_PEER_LIST_SIZE  16384
19 
20 struct ath12k_dp_hw {
21 	struct ath12k_dp_peer __rcu *dp_peers[MAX_DP_PEER_LIST_SIZE];
22 
23 	/* Lock for protection of dp_peer_list and peers */
24 	spinlock_t peer_lock;
25 	struct list_head dp_peers_list;
26 };
27 
28 struct ath12k_dp_hw_group {
29 	struct ath12k_dp *dp[ATH12K_MAX_DEVICES];
30 };
31 
32 struct ath12k_dp_link_vif {
33 	u32 vdev_id;
34 	u8 search_type;
35 	u8 hal_addr_search_flags;
36 	u8 pdev_idx;
37 	u8 lmac_id;
38 	u16 ast_idx;
39 	u16 ast_hash;
40 	u16 tcl_metadata;
41 	u8 vdev_id_check_en;
42 	int bank_id;
43 };
44 
45 struct ath12k_dp_vif {
46 	u8 tx_encap_type;
47 	u32 key_cipher;
48 	atomic_t mcbc_gsn;
49 	struct ath12k_dp_link_vif dp_link_vif[ATH12K_NUM_MAX_LINKS];
50 };
51 
52 /* TODO: Move this to a separate dp_stats file */
53 struct ath12k_per_peer_tx_stats {
54 	u32 succ_bytes;
55 	u32 retry_bytes;
56 	u32 failed_bytes;
57 	u32 duration;
58 	u16 succ_pkts;
59 	u16 retry_pkts;
60 	u16 failed_pkts;
61 	u16 ru_start;
62 	u16 ru_tones;
63 	u8 ba_fails;
64 	u8 ppdu_type;
65 	u32 mu_grpid;
66 	u32 mu_pos;
67 	bool is_ampdu;
68 };
69 
70 struct ath12k_dp_peer_create_params {
71 	struct ieee80211_sta *sta;
72 	bool is_mlo;
73 	u16 peer_id;
74 	bool ucast_ra_only;
75 };
76 
77 struct ath12k_dp_link_peer_rate_info {
78 	struct rate_info txrate;
79 	u64 rx_duration;
80 	u64 tx_duration;
81 	u8 rssi_comb;
82 	s8 signal_avg;
83 };
84 
85 static inline struct ath12k_dp_link_vif *
86 ath12k_dp_vif_to_dp_link_vif(struct ath12k_dp_vif *dp_vif, u8 link_id)
87 {
88 	return &dp_vif->dp_link_vif[link_id];
89 }
90 
91 void ath12k_dp_cmn_device_deinit(struct ath12k_dp *dp);
92 int ath12k_dp_cmn_device_init(struct ath12k_dp *dp);
93 void ath12k_dp_cmn_hw_group_unassign(struct ath12k_dp *dp,
94 				     struct ath12k_hw_group *ag);
95 void ath12k_dp_cmn_hw_group_assign(struct ath12k_dp *dp,
96 				   struct ath12k_hw_group *ag);
97 int ath12k_dp_link_peer_assign(struct ath12k_dp *dp, struct ath12k_dp_hw *dp_hw,
98 			       u8 vdev_id, struct ieee80211_sta *sta, u8 *addr,
99 			       u8 link_id, u32 hw_link_id);
100 void ath12k_dp_link_peer_unassign(struct ath12k_dp *dp, struct ath12k_dp_hw *dp_hw,
101 				  u8 vdev_id, u8 *addr, u32 hw_link_id);
102 void
103 ath12k_dp_link_peer_get_sta_rate_info_stats(struct ath12k_dp *dp, const u8 *addr,
104 					    struct ath12k_dp_link_peer_rate_info *info);
105 void ath12k_dp_link_peer_reset_rx_stats(struct ath12k_dp *dp, const u8 *addr);
106 #endif
107