xref: /linux/drivers/net/wireless/ath/ath12k/dp_rx.h (revision 746680ec6696585e30db3e18c93a63df9cbec39c)
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_reo_cache_flush_elem {
35 	struct list_head list;
36 	struct ath12k_dp_rx_tid data;
37 	unsigned long ts;
38 };
39 
40 struct ath12k_dp_rx_reo_cmd {
41 	struct list_head list;
42 	struct ath12k_dp_rx_tid data;
43 	int cmd_num;
44 	void (*handler)(struct ath12k_dp *dp, void *ctx,
45 			enum hal_reo_cmd_status status);
46 };
47 
48 #define ATH12K_DP_RX_REO_DESC_FREE_THRES  64
49 #define ATH12K_DP_RX_REO_DESC_FREE_TIMEOUT_MS 1000
50 
51 enum ath12k_dp_rx_decap_type {
52 	DP_RX_DECAP_TYPE_RAW,
53 	DP_RX_DECAP_TYPE_NATIVE_WIFI,
54 	DP_RX_DECAP_TYPE_ETHERNET2_DIX,
55 	DP_RX_DECAP_TYPE_8023,
56 };
57 
58 struct ath12k_dp_rx_rfc1042_hdr {
59 	u8 llc_dsap;
60 	u8 llc_ssap;
61 	u8 llc_ctrl;
62 	u8 snap_oui[3];
63 	__be16 snap_type;
64 } __packed;
65 
66 struct ath12k_dp_rx_info {
67 	struct ieee80211_rx_status *rx_status;
68 	u32 phy_meta_data;
69 	u16 peer_id;
70 	u8 decap_type;
71 	u8 pkt_type;
72 	u8 sgi;
73 	u8 rate_mcs;
74 	u8 bw;
75 	u8 nss;
76 	u8 addr2[ETH_ALEN];
77 	u8 tid;
78 	bool ip_csum_fail;
79 	bool l4_csum_fail;
80 	bool is_mcbc;
81 	bool addr2_present;
82 };
83 
84 static inline u32 ath12k_he_gi_to_nl80211_he_gi(u8 sgi)
85 {
86 	u32 ret = 0;
87 
88 	switch (sgi) {
89 	case RX_MSDU_START_SGI_0_8_US:
90 		ret = NL80211_RATE_INFO_HE_GI_0_8;
91 		break;
92 	case RX_MSDU_START_SGI_1_6_US:
93 		ret = NL80211_RATE_INFO_HE_GI_1_6;
94 		break;
95 	case RX_MSDU_START_SGI_3_2_US:
96 		ret = NL80211_RATE_INFO_HE_GI_3_2;
97 		break;
98 	default:
99 		ret = NL80211_RATE_INFO_HE_GI_0_8;
100 		break;
101 	}
102 
103 	return ret;
104 }
105 
106 int ath12k_dp_rx_ampdu_start(struct ath12k *ar,
107 			     struct ieee80211_ampdu_params *params,
108 			     u8 link_id);
109 int ath12k_dp_rx_ampdu_stop(struct ath12k *ar,
110 			    struct ieee80211_ampdu_params *params,
111 			    u8 link_id);
112 int ath12k_dp_rx_peer_pn_replay_config(struct ath12k_link_vif *arvif,
113 				       const u8 *peer_addr,
114 				       enum set_key_cmd key_cmd,
115 				       struct ieee80211_key_conf *key);
116 void ath12k_dp_rx_peer_tid_cleanup(struct ath12k *ar, struct ath12k_peer *peer);
117 void ath12k_dp_rx_peer_tid_delete(struct ath12k *ar,
118 				  struct ath12k_peer *peer, u8 tid);
119 int ath12k_dp_rx_peer_tid_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id,
120 				u8 tid, u32 ba_win_sz, u16 ssn,
121 				enum hal_pn_type pn_type);
122 void ath12k_dp_htt_htc_t2h_msg_handler(struct ath12k_base *ab,
123 				       struct sk_buff *skb);
124 int ath12k_dp_rx_pdev_reo_setup(struct ath12k_base *ab);
125 void ath12k_dp_rx_pdev_reo_cleanup(struct ath12k_base *ab);
126 int ath12k_dp_rx_htt_setup(struct ath12k_base *ab);
127 int ath12k_dp_rx_alloc(struct ath12k_base *ab);
128 void ath12k_dp_rx_free(struct ath12k_base *ab);
129 int ath12k_dp_rx_pdev_alloc(struct ath12k_base *ab, int pdev_idx);
130 void ath12k_dp_rx_pdev_free(struct ath12k_base *ab, int pdev_idx);
131 void ath12k_dp_rx_reo_cmd_list_cleanup(struct ath12k_base *ab);
132 void ath12k_dp_rx_process_reo_status(struct ath12k_base *ab);
133 int ath12k_dp_rx_process_wbm_err(struct ath12k_base *ab,
134 				 struct napi_struct *napi, int budget);
135 int ath12k_dp_rx_process_err(struct ath12k_base *ab, struct napi_struct *napi,
136 			     int budget);
137 int ath12k_dp_rx_process(struct ath12k_base *ab, int mac_id,
138 			 struct napi_struct *napi,
139 			 int budget);
140 int ath12k_dp_rx_bufs_replenish(struct ath12k_base *ab,
141 				struct dp_rxdma_ring *rx_ring,
142 				struct list_head *used_list,
143 				int req_entries);
144 int ath12k_dp_rx_pdev_mon_attach(struct ath12k *ar);
145 int ath12k_dp_rx_peer_frag_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id);
146 
147 u8 ath12k_dp_rx_h_l3pad(struct ath12k_base *ab,
148 			struct hal_rx_desc *desc);
149 struct ath12k_peer *
150 ath12k_dp_rx_h_find_peer(struct ath12k_base *ab, struct sk_buff *msdu,
151 			 struct ath12k_dp_rx_info *rx_info);
152 u8 ath12k_dp_rx_h_decap_type(struct ath12k_base *ab,
153 			     struct hal_rx_desc *desc);
154 u32 ath12k_dp_rx_h_mpdu_err(struct ath12k_base *ab,
155 			    struct hal_rx_desc *desc);
156 void ath12k_dp_rx_h_ppdu(struct ath12k *ar, struct ath12k_dp_rx_info *rx_info);
157 int ath12k_dp_rxdma_ring_sel_config_qcn9274(struct ath12k_base *ab);
158 int ath12k_dp_rxdma_ring_sel_config_wcn7850(struct ath12k_base *ab);
159 
160 int ath12k_dp_htt_tlv_iter(struct ath12k_base *ab, const void *ptr, size_t len,
161 			   int (*iter)(struct ath12k_base *ar, u16 tag, u16 len,
162 				       const void *ptr, void *data),
163 			   void *data);
164 void ath12k_dp_rx_h_fetch_info(struct ath12k_base *ab,  struct hal_rx_desc *rx_desc,
165 			       struct ath12k_dp_rx_info *rx_info);
166 
167 int ath12k_dp_rx_crypto_mic_len(struct ath12k *ar, enum hal_encrypt_type enctype);
168 u32 ath12k_dp_rxdesc_get_ppduid(struct ath12k_base *ab,
169 				struct hal_rx_desc *rx_desc);
170 bool ath12k_dp_rxdesc_mpdu_valid(struct ath12k_base *ab,
171 				 struct hal_rx_desc *rx_desc);
172 int ath12k_dp_rx_link_desc_return(struct ath12k_base *ab,
173 				  struct ath12k_buffer_addr *buf_addr_info,
174 				  enum hal_wbm_rel_bm_act action);
175 bool ath12k_dp_rxdesc_mpdu_valid(struct ath12k_base *ab,
176 				 struct hal_rx_desc *rx_desc);
177 #endif /* ATH12K_DP_RX_H */
178