1 /*
2  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: Declare private API which shall be used internally only
22  * in pkt_capture component. This file shall include prototypes of
23  * pkt_capture data tx and data rx.
24  *
25  * Note: This API should be never accessed out of pkt_capture component.
26  */
27 
28 #ifndef _WLAN_PKT_CAPTURE_DATA_TXRX_H_
29 #define _WLAN_PKT_CAPTURE_DATA_TXRX_H_
30 
31 #include "cdp_txrx_cmn_struct.h"
32 #include <qdf_nbuf.h>
33 #include <qdf_list.h>
34 #ifndef WLAN_FEATURE_PKT_CAPTURE_V2
35 #include <htt_internal.h>
36 #endif
37 
38 #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
39 #define IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN 0x0020
40 #define IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN 0x4000
41 #define IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN 0x0002
42 #define IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN 0x0080
43 #define IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN 0x0200
44 #endif
45 
46 #define HAL_TX_PKT_TYPE_11B 1
47 
48 /**
49  * enum pkt_capture_data_process_type - data pkt types to process
50  * for packet capture mode
51  * @TXRX_PROCESS_TYPE_DATA_RX: process RX packets (normal rx + offloaded rx)
52  * @TXRX_PROCESS_TYPE_DATA_TX: process TX packets (ofloaded tx)
53  * @TXRX_PROCESS_TYPE_DATA_TX_COMPL: process TX compl packets (normal tx)
54  */
55 enum pkt_capture_data_process_type {
56 	TXRX_PROCESS_TYPE_DATA_RX,
57 	TXRX_PROCESS_TYPE_DATA_TX,
58 	TXRX_PROCESS_TYPE_DATA_TX_COMPL,
59 };
60 
61 #define TXRX_PKTCAPTURE_PKT_FORMAT_8023    0
62 #define TXRX_PKTCAPTURE_PKT_FORMAT_80211   1
63 
64 #define SHORT_PREAMBLE 1
65 #define LONG_PREAMBLE  0
66 
67 /**
68  * pkt_capture_datapkt_process() - process data tx and rx packets
69  * for pkt capture mode. (normal tx/rx + offloaded tx/rx)
70  * @vdev_id: vdev id for which packet is captured
71  * @mon_buf_list: netbuf list
72  * @type: data process type
73  * @tid:  tid number
74  * @status: Tx status
75  * @pkt_format: Frame format
76  * @bssid: bssid
77  * @pdev: pdev handle
78  * @tx_retry_cnt: tx retry count
79  *
80  * Return: none
81  */
82 void pkt_capture_datapkt_process(
83 			uint8_t vdev_id,
84 			qdf_nbuf_t mon_buf_list,
85 			enum pkt_capture_data_process_type type,
86 			uint8_t tid, uint8_t status, bool pkt_format,
87 			uint8_t *bssid, void *pdev,
88 			uint8_t tx_retry_cnt);
89 
90 #ifndef WLAN_FEATURE_PKT_CAPTURE_V2
91 /**
92  * pkt_capture_msdu_process_pkts() - process data rx pkts
93  * @bssid: bssid
94  * @head_msdu: pointer to head msdu
95  * @vdev_id: vdev_id
96  * @pdev: pdev handle
97  * @status: capture status
98  *
99  * Return: none
100  */
101 void pkt_capture_msdu_process_pkts(
102 			uint8_t *bssid,
103 			qdf_nbuf_t head_msdu,
104 			uint8_t vdev_id,
105 			htt_pdev_handle pdev, uint16_t status);
106 #else
107 void pkt_capture_msdu_process_pkts(
108 			uint8_t *bssid,
109 			qdf_nbuf_t head_msdu,
110 			uint8_t vdev_id,
111 			void *psoc, uint16_t status);
112 #endif
113 
114 /**
115  * pkt_capture_rx_in_order_drop_offload_pkt() - drop offload packets
116  * @head_msdu: pointer to head msdu
117  *
118  * Return: none
119  */
120 void pkt_capture_rx_in_order_drop_offload_pkt(qdf_nbuf_t head_msdu);
121 
122 /**
123  * pkt_capture_rx_in_order_offloaded_pkt() - check offloaded data pkt or not
124  * @rx_ind_msg: rx_ind_msg
125  *
126  * Return: false, if it is not offload pkt
127  *         true, if it is offload pkt
128  */
129 bool pkt_capture_rx_in_order_offloaded_pkt(qdf_nbuf_t rx_ind_msg);
130 
131 #ifndef WLAN_FEATURE_PKT_CAPTURE_V2
132 /**
133  * pkt_capture_offload_deliver_indication_handler() - Handle offload data pkts
134  * @msg: offload netbuf msg
135  * @vdev_id: vdev id
136  * @bssid: bssid
137  * @pdev: pdev handle
138  *
139  * Return: none
140  */
141 void pkt_capture_offload_deliver_indication_handler(
142 					void *msg, uint8_t vdev_id,
143 					uint8_t *bssid, htt_pdev_handle pdev);
144 #else
145 /**
146  * pkt_capture_offload_deliver_indication_handler() - Handle offload data pkts
147  * @msg: offload netbuf msg
148  * @vdev_id: vdev id
149  * @bssid: bssid
150  * @soc: dp_soc handle
151  *
152  * Return: none
153  */
154 void pkt_capture_offload_deliver_indication_handler(
155 					void *msg, uint8_t vdev_id,
156 					uint8_t *bssid, void *soc);
157 #endif
158 
159 /**
160  * struct pkt_capture_tx_hdr_elem_t - tx packets header structure to
161  * be used to update radiotap header for packet capture mode
162  * @timestamp: timestamp
163  * @preamble: preamble
164  * @mcs: MCS
165  * @rate: rate
166  * @rssi_comb: rssi in dBm
167  * @nss: if nss 1 means 1ss and 2 means 2ss
168  * @bw: BW (0=>20 MHz, 1=>40 MHz, 2=>80 MHz, 3=>160 MHz)
169  * @stbc: STBC
170  * @sgi: SGI
171  * @ldpc: LDPC
172  * @beamformed: beamformed
173  * @dir: direction rx: 0 and tx: 1
174  * @status: tx status
175  * @tx_retry_cnt: tx retry count
176  * @framectrl: frame control
177  * @seqno: sequence number
178  * @ppdu_id: ppdu_id of msdu
179  */
180 struct pkt_capture_tx_hdr_elem_t {
181 	uint32_t timestamp;
182 	uint8_t preamble;
183 	uint8_t mcs;
184 	uint8_t rate;
185 	uint8_t rssi_comb;
186 	uint8_t nss;
187 	uint8_t bw;
188 	bool stbc;
189 	bool sgi;
190 	bool ldpc;
191 	bool beamformed;
192 	bool dir;
193 	uint8_t status;
194 	uint8_t tx_retry_cnt;
195 	uint16_t framectrl;
196 	uint16_t seqno;
197 	uint32_t ppdu_id;
198 };
199 
200 /**
201  * struct pkt_capture_ppdu_stats_q_node - node structure to be enqueued
202  * in ppdu_stats_q
203  * @node: list node
204  * @buf: buffer data received from ppdu_stats
205  */
206 struct pkt_capture_ppdu_stats_q_node {
207 	qdf_list_node_t node;
208 	uint32_t buf[];
209 };
210 
211 /**
212  * pkt_capture_tx_get_txcomplete_data_hdr() - extract Tx data hdr from Tx
213  * completion for pkt capture mode
214  * @msg_word: Tx completion htt msg
215  * @num_msdus: number of msdus
216  *
217  * Return: tx data hdr information
218  */
219 struct htt_tx_data_hdr_information *pkt_capture_tx_get_txcomplete_data_hdr(
220 						uint32_t *msg_word,
221 						int num_msdus);
222 
223 #endif /* End  of _WLAN_PKT_CAPTURE_DATA_TXRX_H_ */
224