xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/dp_tx.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
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  *
121  * This structure holds the complete MSDU information needed to program the
122  * Hardware TCL and MSDU extension descriptors for different frame types
123  *
124  */
125 struct dp_tx_msdu_info_s {
126 	enum dp_tx_frm_type frm_type;
127 	struct dp_tx_queue tx_queue;
128 	uint32_t num_seg;
129 	uint8_t tid;
130 	union {
131 		struct qdf_tso_info_t tso_info;
132 		struct dp_tx_sg_info_s sg_info;
133 	} u;
134 	uint32_t meta_data[6];
135 	uint8_t exception_fw;
136 };
137 
138 QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
139 QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
140 void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
141 
142 QDF_STATUS dp_tx_soc_attach(struct dp_soc *soc);
143 QDF_STATUS dp_tx_soc_detach(struct dp_soc *soc);
144 
145 /**
146  * dp_tso_attach() - TSO Attach handler
147  * @txrx_soc: Opaque Dp handle
148  *
149  * Reserve TSO descriptor buffers
150  *
151  * Return: QDF_STATUS_E_FAILURE on failure or
152  * QDF_STATUS_SUCCESS on success
153  */
154 QDF_STATUS dp_tso_soc_attach(void *txrx_soc);
155 
156 /**
157  * dp_tso_detach() - TSO Detach handler
158  * @txrx_soc: Opaque Dp handle
159  *
160  * Deallocate TSO descriptor buffers
161  *
162  * Return: QDF_STATUS_E_FAILURE on failure or
163  * QDF_STATUS_SUCCESS on success
164  */
165 QDF_STATUS dp_tso_soc_detach(void *txrx_soc);
166 
167 QDF_STATUS dp_tx_pdev_detach(struct dp_pdev *pdev);
168 QDF_STATUS dp_tx_pdev_attach(struct dp_pdev *pdev);
169 
170 qdf_nbuf_t dp_tx_send(void *data_vdev, qdf_nbuf_t nbuf);
171 qdf_nbuf_t dp_tx_send_exception(void *data_vdev, qdf_nbuf_t nbuf,
172 				struct cdp_tx_exception_metadata *tx_exc);
173 qdf_nbuf_t dp_tx_send_mesh(void *data_vdev, qdf_nbuf_t nbuf);
174 
175 #ifdef FEATURE_WLAN_TDLS
176 qdf_nbuf_t dp_tx_non_std(struct cdp_vdev *vdev_handle,
177 		enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
178 #endif
179 
180 /**
181  * dp_tx_comp_handler() - Tx completion handler
182  * @int_ctx: pointer to DP interrupt context
183  * @soc: core txrx main context
184  * @ring_id: completion ring id
185  * @quota: No. of packets/descriptors that can be serviced in one loop
186  *
187  * This function will collect hardware release ring element contents and
188  * handle descriptor contents. Based on contents, free packet or handle error
189  * conditions
190  *
191  * Return: Number of TX completions processed
192  */
193 uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
194 			    void *hal_srng, uint32_t quota);
195 
196 QDF_STATUS
197 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
198 
199 #ifdef FEATURE_WDS
200 void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
201 #else
202 static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
203 {
204 	return;
205 }
206 #endif
207 
208 #ifdef ATH_SUPPORT_IQUE
209 void dp_tx_me_exit(struct dp_pdev *pdev);
210 #else
211 static inline void dp_tx_me_exit(struct dp_pdev *pdev)
212 {
213 	return;
214 }
215 #endif
216 
217 #ifdef FEATURE_PERPKT_INFO
218 QDF_STATUS
219 dp_get_completion_indication_for_stack(struct dp_soc *soc,
220 				       struct dp_pdev *pdev,
221 				       struct dp_peer *peer,
222 				       struct hal_tx_completion_status *ts,
223 				       qdf_nbuf_t netbuf,
224 				       uint64_t time_latency);
225 
226 void  dp_send_completion_to_stack(struct dp_soc *soc,  struct dp_pdev *pdev,
227 		uint16_t peer_id, uint32_t ppdu_id,
228 		qdf_nbuf_t netbuf);
229 #endif
230 
231 void  dp_iterate_update_peer_list(void *pdev_hdl);
232 
233 #ifdef ATH_TX_PRI_OVERRIDE
234 #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
235 	((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
236 #else
237 #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
238 #endif
239 
240 /* TODO TX_FEATURE_NOT_YET */
241 static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
242 {
243 	return;
244 }
245 /* TODO TX_FEATURE_NOT_YET */
246 #endif
247