xref: /freebsd/sys/contrib/dev/athk/ath12k/dp_rx.h (revision 5c1def83)
1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2 /*
3  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4  * Copyright (c) 2021-2022 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 *vaddr;
18 	dma_addr_t paddr;
19 	u32 size;
20 	u32 ba_win_sz;
21 	bool active;
22 
23 	/* Info related to rx fragments */
24 	u32 cur_sn;
25 	u16 last_frag_no;
26 	u16 rx_frag_bitmap;
27 
28 	struct sk_buff_head rx_frags;
29 	struct hal_reo_dest_ring *dst_ring_desc;
30 
31 	/* Timer info related to fragments */
32 	struct timer_list frag_timer;
33 	struct ath12k_base *ab;
34 };
35 
36 struct ath12k_dp_rx_reo_cache_flush_elem {
37 	struct list_head list;
38 	struct ath12k_dp_rx_tid data;
39 	unsigned long ts;
40 };
41 
42 struct ath12k_dp_rx_reo_cmd {
43 	struct list_head list;
44 	struct ath12k_dp_rx_tid data;
45 	int cmd_num;
46 	void (*handler)(struct ath12k_dp *dp, void *ctx,
47 			enum hal_reo_cmd_status status);
48 };
49 
50 #define ATH12K_DP_RX_REO_DESC_FREE_THRES  64
51 #define ATH12K_DP_RX_REO_DESC_FREE_TIMEOUT_MS 1000
52 
53 enum ath12k_dp_rx_decap_type {
54 	DP_RX_DECAP_TYPE_RAW,
55 	DP_RX_DECAP_TYPE_NATIVE_WIFI,
56 	DP_RX_DECAP_TYPE_ETHERNET2_DIX,
57 	DP_RX_DECAP_TYPE_8023,
58 };
59 
60 struct ath12k_dp_rx_rfc1042_hdr {
61 	u8 llc_dsap;
62 	u8 llc_ssap;
63 	u8 llc_ctrl;
64 	u8 snap_oui[3];
65 	__be16 snap_type;
66 } __packed;
67 
ath12k_he_gi_to_nl80211_he_gi(u8 sgi)68 static inline u32 ath12k_he_gi_to_nl80211_he_gi(u8 sgi)
69 {
70 	u32 ret = 0;
71 
72 	switch (sgi) {
73 	case RX_MSDU_START_SGI_0_8_US:
74 		ret = NL80211_RATE_INFO_HE_GI_0_8;
75 		break;
76 	case RX_MSDU_START_SGI_1_6_US:
77 		ret = NL80211_RATE_INFO_HE_GI_1_6;
78 		break;
79 	case RX_MSDU_START_SGI_3_2_US:
80 		ret = NL80211_RATE_INFO_HE_GI_3_2;
81 		break;
82 	}
83 
84 	return ret;
85 }
86 
87 int ath12k_dp_rx_ampdu_start(struct ath12k *ar,
88 			     struct ieee80211_ampdu_params *params);
89 int ath12k_dp_rx_ampdu_stop(struct ath12k *ar,
90 			    struct ieee80211_ampdu_params *params);
91 int ath12k_dp_rx_peer_pn_replay_config(struct ath12k_vif *arvif,
92 				       const u8 *peer_addr,
93 				       enum set_key_cmd key_cmd,
94 				       struct ieee80211_key_conf *key);
95 void ath12k_dp_rx_peer_tid_cleanup(struct ath12k *ar, struct ath12k_peer *peer);
96 void ath12k_dp_rx_peer_tid_delete(struct ath12k *ar,
97 				  struct ath12k_peer *peer, u8 tid);
98 int ath12k_dp_rx_peer_tid_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id,
99 				u8 tid, u32 ba_win_sz, u16 ssn,
100 				enum hal_pn_type pn_type);
101 void ath12k_dp_htt_htc_t2h_msg_handler(struct ath12k_base *ab,
102 				       struct sk_buff *skb);
103 int ath12k_dp_rx_pdev_reo_setup(struct ath12k_base *ab);
104 void ath12k_dp_rx_pdev_reo_cleanup(struct ath12k_base *ab);
105 int ath12k_dp_rx_htt_setup(struct ath12k_base *ab);
106 int ath12k_dp_rx_alloc(struct ath12k_base *ab);
107 void ath12k_dp_rx_free(struct ath12k_base *ab);
108 int ath12k_dp_rx_pdev_alloc(struct ath12k_base *ab, int pdev_idx);
109 void ath12k_dp_rx_pdev_free(struct ath12k_base *ab, int pdev_idx);
110 void ath12k_dp_rx_reo_cmd_list_cleanup(struct ath12k_base *ab);
111 void ath12k_dp_rx_process_reo_status(struct ath12k_base *ab);
112 int ath12k_dp_rx_process_wbm_err(struct ath12k_base *ab,
113 				 struct napi_struct *napi, int budget);
114 int ath12k_dp_rx_process_err(struct ath12k_base *ab, struct napi_struct *napi,
115 			     int budget);
116 int ath12k_dp_rx_process(struct ath12k_base *ab, int mac_id,
117 			 struct napi_struct *napi,
118 			 int budget);
119 int ath12k_dp_rx_bufs_replenish(struct ath12k_base *ab, int mac_id,
120 				struct dp_rxdma_ring *rx_ring,
121 				int req_entries,
122 				enum hal_rx_buf_return_buf_manager mgr,
123 				bool hw_cc);
124 int ath12k_dp_rx_pdev_mon_attach(struct ath12k *ar);
125 int ath12k_dp_rx_peer_frag_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id);
126 
127 int ath12k_dp_rx_pktlog_start(struct ath12k_base *ab);
128 int ath12k_dp_rx_pktlog_stop(struct ath12k_base *ab, bool stop_timer);
129 u8 ath12k_dp_rx_h_l3pad(struct ath12k_base *ab,
130 			struct hal_rx_desc *desc);
131 struct ath12k_peer *
132 ath12k_dp_rx_h_find_peer(struct ath12k_base *ab, struct sk_buff *msdu);
133 u8 ath12k_dp_rx_h_decap_type(struct ath12k_base *ab,
134 			     struct hal_rx_desc *desc);
135 u32 ath12k_dp_rx_h_mpdu_err(struct ath12k_base *ab,
136 			    struct hal_rx_desc *desc);
137 void ath12k_dp_rx_h_ppdu(struct ath12k *ar, struct hal_rx_desc *rx_desc,
138 			 struct ieee80211_rx_status *rx_status);
139 struct ath12k_peer *
140 ath12k_dp_rx_h_find_peer(struct ath12k_base *ab, struct sk_buff *msdu);
141 
142 int ath12k_dp_rxdma_ring_sel_config_qcn9274(struct ath12k_base *ab);
143 int ath12k_dp_rxdma_ring_sel_config_wcn7850(struct ath12k_base *ab);
144 
145 #endif /* ATH12K_DP_RX_H */
146