xref: /linux/drivers/net/wireless/ath/ath12k/dp_rx.h (revision 55a42f78ffd386e01a5404419f8c5ded7db70a21)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4  * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
5  */
6 #ifndef ATH12K_DP_RX_H
7 #define ATH12K_DP_RX_H
8 
9 #include "core.h"
10 #include "rx_desc.h"
11 #include "debug.h"
12 
13 #define DP_MAX_NWIFI_HDR_LEN	30
14 
15 struct ath12k_dp_rx_tid {
16 	u8 tid;
17 	u32 ba_win_sz;
18 	bool active;
19 	struct ath12k_reoq_buf qbuf;
20 
21 	/* Info related to rx fragments */
22 	u32 cur_sn;
23 	u16 last_frag_no;
24 	u16 rx_frag_bitmap;
25 
26 	struct sk_buff_head rx_frags;
27 	struct hal_reo_dest_ring *dst_ring_desc;
28 
29 	/* Timer info related to fragments */
30 	struct timer_list frag_timer;
31 	struct ath12k_base *ab;
32 };
33 
34 struct ath12k_dp_rx_tid_rxq {
35 	u8 tid;
36 	bool active;
37 	struct ath12k_reoq_buf qbuf;
38 };
39 
40 struct ath12k_dp_rx_reo_cache_flush_elem {
41 	struct list_head list;
42 	struct ath12k_dp_rx_tid_rxq data;
43 	unsigned long ts;
44 };
45 
46 struct dp_reo_update_rx_queue_elem {
47 	struct list_head list;
48 	struct ath12k_dp_rx_tid_rxq rx_tid;
49 	int peer_id;
50 	bool is_ml_peer;
51 	u16 ml_peer_id;
52 };
53 
54 struct ath12k_dp_rx_reo_cmd {
55 	struct list_head list;
56 	struct ath12k_dp_rx_tid_rxq data;
57 	int cmd_num;
58 	void (*handler)(struct ath12k_dp *dp, void *ctx,
59 			enum hal_reo_cmd_status status);
60 };
61 
62 #define ATH12K_DP_RX_REO_DESC_FREE_THRES  64
63 #define ATH12K_DP_RX_REO_DESC_FREE_TIMEOUT_MS 1000
64 
65 enum ath12k_dp_rx_decap_type {
66 	DP_RX_DECAP_TYPE_RAW,
67 	DP_RX_DECAP_TYPE_NATIVE_WIFI,
68 	DP_RX_DECAP_TYPE_ETHERNET2_DIX,
69 	DP_RX_DECAP_TYPE_8023,
70 };
71 
72 struct ath12k_dp_rx_rfc1042_hdr {
73 	u8 llc_dsap;
74 	u8 llc_ssap;
75 	u8 llc_ctrl;
76 	u8 snap_oui[3];
77 	__be16 snap_type;
78 } __packed;
79 
80 struct ath12k_dp_rx_info {
81 	struct ieee80211_rx_status *rx_status;
82 	u32 phy_meta_data;
83 	u16 peer_id;
84 	u8 decap_type;
85 	u8 pkt_type;
86 	u8 sgi;
87 	u8 rate_mcs;
88 	u8 bw;
89 	u8 nss;
90 	u8 addr2[ETH_ALEN];
91 	u8 tid;
92 	bool ip_csum_fail;
93 	bool l4_csum_fail;
94 	bool is_mcbc;
95 	bool addr2_present;
96 };
97 
98 static inline u32 ath12k_he_gi_to_nl80211_he_gi(u8 sgi)
99 {
100 	u32 ret = 0;
101 
102 	switch (sgi) {
103 	case RX_MSDU_START_SGI_0_8_US:
104 		ret = NL80211_RATE_INFO_HE_GI_0_8;
105 		break;
106 	case RX_MSDU_START_SGI_1_6_US:
107 		ret = NL80211_RATE_INFO_HE_GI_1_6;
108 		break;
109 	case RX_MSDU_START_SGI_3_2_US:
110 		ret = NL80211_RATE_INFO_HE_GI_3_2;
111 		break;
112 	default:
113 		ret = NL80211_RATE_INFO_HE_GI_0_8;
114 		break;
115 	}
116 
117 	return ret;
118 }
119 
120 int ath12k_dp_rx_ampdu_start(struct ath12k *ar,
121 			     struct ieee80211_ampdu_params *params,
122 			     u8 link_id);
123 int ath12k_dp_rx_ampdu_stop(struct ath12k *ar,
124 			    struct ieee80211_ampdu_params *params,
125 			    u8 link_id);
126 int ath12k_dp_rx_peer_pn_replay_config(struct ath12k_link_vif *arvif,
127 				       const u8 *peer_addr,
128 				       enum set_key_cmd key_cmd,
129 				       struct ieee80211_key_conf *key);
130 void ath12k_dp_rx_peer_tid_cleanup(struct ath12k *ar, struct ath12k_peer *peer);
131 void ath12k_dp_rx_peer_tid_delete(struct ath12k *ar,
132 				  struct ath12k_peer *peer, u8 tid);
133 int ath12k_dp_rx_peer_tid_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id,
134 				u8 tid, u32 ba_win_sz, u16 ssn,
135 				enum hal_pn_type pn_type);
136 void ath12k_dp_htt_htc_t2h_msg_handler(struct ath12k_base *ab,
137 				       struct sk_buff *skb);
138 int ath12k_dp_rx_pdev_reo_setup(struct ath12k_base *ab);
139 void ath12k_dp_rx_pdev_reo_cleanup(struct ath12k_base *ab);
140 int ath12k_dp_rx_htt_setup(struct ath12k_base *ab);
141 int ath12k_dp_rx_alloc(struct ath12k_base *ab);
142 void ath12k_dp_rx_free(struct ath12k_base *ab);
143 int ath12k_dp_rx_pdev_alloc(struct ath12k_base *ab, int pdev_idx);
144 void ath12k_dp_rx_pdev_free(struct ath12k_base *ab, int pdev_idx);
145 void ath12k_dp_rx_reo_cmd_list_cleanup(struct ath12k_base *ab);
146 void ath12k_dp_rx_process_reo_status(struct ath12k_base *ab);
147 int ath12k_dp_rx_process_wbm_err(struct ath12k_base *ab,
148 				 struct napi_struct *napi, int budget);
149 int ath12k_dp_rx_process_err(struct ath12k_base *ab, struct napi_struct *napi,
150 			     int budget);
151 int ath12k_dp_rx_process(struct ath12k_base *ab, int mac_id,
152 			 struct napi_struct *napi,
153 			 int budget);
154 int ath12k_dp_rx_bufs_replenish(struct ath12k_base *ab,
155 				struct dp_rxdma_ring *rx_ring,
156 				struct list_head *used_list,
157 				int req_entries);
158 int ath12k_dp_rx_pdev_mon_attach(struct ath12k *ar);
159 int ath12k_dp_rx_peer_frag_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id);
160 
161 u8 ath12k_dp_rx_h_l3pad(struct ath12k_base *ab,
162 			struct hal_rx_desc *desc);
163 struct ath12k_peer *
164 ath12k_dp_rx_h_find_peer(struct ath12k_base *ab, struct sk_buff *msdu,
165 			 struct ath12k_dp_rx_info *rx_info);
166 u8 ath12k_dp_rx_h_decap_type(struct ath12k_base *ab,
167 			     struct hal_rx_desc *desc);
168 u32 ath12k_dp_rx_h_mpdu_err(struct ath12k_base *ab,
169 			    struct hal_rx_desc *desc);
170 void ath12k_dp_rx_h_ppdu(struct ath12k *ar, struct ath12k_dp_rx_info *rx_info);
171 int ath12k_dp_rxdma_ring_sel_config_qcn9274(struct ath12k_base *ab);
172 int ath12k_dp_rxdma_ring_sel_config_wcn7850(struct ath12k_base *ab);
173 
174 int ath12k_dp_htt_tlv_iter(struct ath12k_base *ab, const void *ptr, size_t len,
175 			   int (*iter)(struct ath12k_base *ar, u16 tag, u16 len,
176 				       const void *ptr, void *data),
177 			   void *data);
178 void ath12k_dp_rx_h_fetch_info(struct ath12k_base *ab,  struct hal_rx_desc *rx_desc,
179 			       struct ath12k_dp_rx_info *rx_info);
180 
181 int ath12k_dp_rx_crypto_mic_len(struct ath12k *ar, enum hal_encrypt_type enctype);
182 u32 ath12k_dp_rxdesc_get_ppduid(struct ath12k_base *ab,
183 				struct hal_rx_desc *rx_desc);
184 bool ath12k_dp_rxdesc_mpdu_valid(struct ath12k_base *ab,
185 				 struct hal_rx_desc *rx_desc);
186 int ath12k_dp_rx_link_desc_return(struct ath12k_base *ab,
187 				  struct ath12k_buffer_addr *buf_addr_info,
188 				  enum hal_wbm_rel_bm_act action);
189 bool ath12k_dp_rxdesc_mpdu_valid(struct ath12k_base *ab,
190 				 struct hal_rx_desc *rx_desc);
191 #endif /* ATH12K_DP_RX_H */
192