xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/dp_tx.h (revision 95477ba01cefb0ae3dbf2b16d6a8e43c81681996)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 #ifndef __DP_TX_H
19 #define __DP_TX_H
20 
21 #include <qdf_types.h>
22 #include <qdf_nbuf.h>
23 #include "dp_types.h"
24 
25 
26 #define DP_TX_MAX_NUM_FRAGS 6
27 
28 #define DP_TX_DESC_FLAG_ALLOCATED	0x1
29 #define DP_TX_DESC_FLAG_TO_FW		0x2
30 #define DP_TX_DESC_FLAG_FRAG		0x4
31 #define DP_TX_DESC_FLAG_RAW		0x8
32 #define DP_TX_DESC_FLAG_MESH		0x10
33 #define DP_TX_DESC_FLAG_QUEUED_TX	0x20
34 #define DP_TX_DESC_FLAG_COMPLETED_TX	0x40
35 #define DP_TX_DESC_FLAG_ME		0x80
36 #define DP_TX_DESC_FLAG_TDLS_FRAME	0x100
37 
38 #define DP_TX_FREE_SINGLE_BUF(soc, buf)                  \
39 do {                                                           \
40 	qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_TO_DEVICE);  \
41 	qdf_nbuf_free(buf);                                    \
42 } while (0)
43 
44 #define OCB_HEADER_VERSION	 1
45 
46 /**
47  * struct dp_tx_frag_info_s
48  * @vaddr: hlos vritual address for buffer
49  * @paddr_lo: physical address lower 32bits
50  * @paddr_hi: physical address higher bits
51  * @len: length of the buffer
52  */
53 struct dp_tx_frag_info_s {
54 	uint8_t  *vaddr;
55 	uint32_t paddr_lo;
56 	uint16_t paddr_hi;
57 	uint16_t len;
58 };
59 
60 /**
61  * struct dp_tx_seg_info_s - Segmentation Descriptor
62  * @nbuf: NBUF pointer if segment corresponds to separate nbuf
63  * @frag_cnt: Fragment count in this segment
64  * @total_len: Total length of segment
65  * @frags: per-Fragment information
66  * @next: pointer to next MSDU segment
67  */
68 struct dp_tx_seg_info_s  {
69 	qdf_nbuf_t nbuf;
70 	uint16_t frag_cnt;
71 	uint16_t total_len;
72 	struct dp_tx_frag_info_s frags[DP_TX_MAX_NUM_FRAGS];
73 	struct dp_tx_seg_info_s *next;
74 };
75 
76 /**
77  * struct dp_tx_sg_info_s - Scatter Gather Descriptor
78  * @num_segs: Number of segments (TSO/ME) in the frame
79  * @total_len: Total length of the frame
80  * @curr_seg: Points to current segment descriptor to be processed. Chain of
81  * 	      descriptors for SG frames/multicast-unicast converted packets.
82  *
83  * Used for SG (802.3 or Raw) frames and Multicast-Unicast converted frames to
84  * carry fragmentation information
85  * Raw Frames will be handed over to driver as an SKB chain with MPDU boundaries
86  * indicated through flags in SKB CB (first_msdu and last_msdu). This will be
87  * converted into set of skb sg (nr_frags) structures.
88  */
89 struct dp_tx_sg_info_s {
90 	uint32_t num_segs;
91 	uint32_t total_len;
92 	struct dp_tx_seg_info_s *curr_seg;
93 };
94 
95 /**
96  * struct dp_tx_queue - Tx queue
97  * @desc_pool_id: Descriptor Pool to be used for the tx queue
98  * @ring_id: TCL descriptor ring ID corresponding to the tx queue
99  *
100  * Tx queue contains information of the software (Descriptor pool)
101  * and hardware resources (TCL ring id) to be used for a particular
102  * transmit queue (obtained from skb_queue_mapping in case of linux)
103  */
104 struct dp_tx_queue {
105 	uint8_t desc_pool_id;
106 	uint8_t ring_id;
107 };
108 
109 /**
110  * struct dp_tx_msdu_info_s - MSDU Descriptor
111  * @frm_type: Frame type - Regular/TSO/SG/Multicast enhancement
112  * @tx_queue: Tx queue on which this MSDU should be transmitted
113  * @num_seg: Number of segments (TSO)
114  * @tid: TID (override) that is sent from HLOS
115  * @u.tso_info: TSO information for TSO frame types
116  * 	     (chain of the TSO segments, number of segments)
117  * @u.sg_info: Scatter Gather information for non-TSO SG frames
118  * @meta_data: Mesh meta header information
119  * @exception_fw: Duplicate frame to be sent to firmware
120  * @ppdu_cookie: 16-bit ppdu_cookie that has to be replayed back in completions
121  * @ix_tx_sniffer: Indicates if the packet has to be sniffed
122  *
123  * This structure holds the complete MSDU information needed to program the
124  * Hardware TCL and MSDU extension descriptors for different frame types
125  *
126  */
127 struct dp_tx_msdu_info_s {
128 	enum dp_tx_frm_type frm_type;
129 	struct dp_tx_queue tx_queue;
130 	uint32_t num_seg;
131 	uint8_t tid;
132 	union {
133 		struct qdf_tso_info_t tso_info;
134 		struct dp_tx_sg_info_s sg_info;
135 	} u;
136 	uint32_t meta_data[7];
137 	uint8_t exception_fw;
138 	uint16_t ppdu_cookie;
139 	uint8_t is_tx_sniffer;
140 };
141 
142 QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
143 QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
144 void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
145 
146 QDF_STATUS dp_tx_soc_attach(struct dp_soc *soc);
147 QDF_STATUS dp_tx_soc_detach(struct dp_soc *soc);
148 
149 /**
150  * dp_tso_attach() - TSO Attach handler
151  * @txrx_soc: Opaque Dp handle
152  *
153  * Reserve TSO descriptor buffers
154  *
155  * Return: QDF_STATUS_E_FAILURE on failure or
156  * QDF_STATUS_SUCCESS on success
157  */
158 QDF_STATUS dp_tso_soc_attach(void *txrx_soc);
159 
160 /**
161  * dp_tso_detach() - TSO Detach handler
162  * @txrx_soc: Opaque Dp handle
163  *
164  * Deallocate TSO descriptor buffers
165  *
166  * Return: QDF_STATUS_E_FAILURE on failure or
167  * QDF_STATUS_SUCCESS on success
168  */
169 QDF_STATUS dp_tso_soc_detach(void *txrx_soc);
170 
171 QDF_STATUS dp_tx_pdev_detach(struct dp_pdev *pdev);
172 QDF_STATUS dp_tx_pdev_attach(struct dp_pdev *pdev);
173 
174 qdf_nbuf_t dp_tx_send(void *data_vdev, qdf_nbuf_t nbuf);
175 qdf_nbuf_t dp_tx_send_exception(void *data_vdev, qdf_nbuf_t nbuf,
176 				struct cdp_tx_exception_metadata *tx_exc);
177 qdf_nbuf_t dp_tx_send_mesh(void *data_vdev, qdf_nbuf_t nbuf);
178 
179 #ifdef FEATURE_WLAN_TDLS
180 qdf_nbuf_t dp_tx_non_std(struct cdp_vdev *vdev_handle,
181 		enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
182 #endif
183 
184 /**
185  * dp_tx_comp_handler() - Tx completion handler
186  * @int_ctx: pointer to DP interrupt context
187  * @soc: core txrx main context
188  * @ring_id: completion ring id
189  * @quota: No. of packets/descriptors that can be serviced in one loop
190  *
191  * This function will collect hardware release ring element contents and
192  * handle descriptor contents. Based on contents, free packet or handle error
193  * conditions
194  *
195  * Return: Number of TX completions processed
196  */
197 uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
198 			    void *hal_srng, uint32_t quota);
199 
200 QDF_STATUS
201 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
202 
203 #ifndef FEATURE_WDS
204 static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
205 {
206 	return;
207 }
208 #endif
209 
210 #ifdef ATH_SUPPORT_IQUE
211 void dp_tx_me_exit(struct dp_pdev *pdev);
212 #else
213 static inline void dp_tx_me_exit(struct dp_pdev *pdev)
214 {
215 	return;
216 }
217 #endif
218 
219 #ifdef FEATURE_PERPKT_INFO
220 QDF_STATUS
221 dp_get_completion_indication_for_stack(struct dp_soc *soc,
222 				       struct dp_pdev *pdev,
223 				       struct dp_peer *peer,
224 				       struct hal_tx_completion_status *ts,
225 				       qdf_nbuf_t netbuf,
226 				       uint64_t time_latency);
227 
228 void  dp_send_completion_to_stack(struct dp_soc *soc,  struct dp_pdev *pdev,
229 		uint16_t peer_id, uint32_t ppdu_id,
230 		qdf_nbuf_t netbuf);
231 #endif
232 
233 void  dp_iterate_update_peer_list(void *pdev_hdl);
234 
235 #ifdef ATH_TX_PRI_OVERRIDE
236 #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
237 	((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
238 #else
239 #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
240 #endif
241 
242 /* TODO TX_FEATURE_NOT_YET */
243 static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
244 {
245 	return;
246 }
247 /* TODO TX_FEATURE_NOT_YET */
248 #endif
249