xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/dp_tx.h (revision 3149adf58a329e17232a4c0e58d460d025edd55a)
1 /*
2  * Copyright (c) 2016-2018 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 QDF_STATUS dp_tx_pdev_detach(struct dp_pdev *pdev);
146 QDF_STATUS dp_tx_pdev_attach(struct dp_pdev *pdev);
147 
148 qdf_nbuf_t dp_tx_send(void *data_vdev, qdf_nbuf_t nbuf);
149 qdf_nbuf_t dp_tx_send_exception(void *data_vdev, qdf_nbuf_t nbuf,
150 				struct cdp_tx_exception_metadata *tx_exc);
151 qdf_nbuf_t dp_tx_send_mesh(void *data_vdev, qdf_nbuf_t nbuf);
152 
153 #ifdef CONVERGED_TDLS_ENABLE
154 qdf_nbuf_t dp_tx_non_std(struct cdp_vdev *vdev_handle,
155 		enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
156 #endif
157 
158 uint32_t dp_tx_comp_handler(struct dp_soc *soc, void *hal_srng, uint32_t quota);
159 
160 QDF_STATUS
161 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
162 
163 #ifndef CONVERGED_TDLS_ENABLE
164 
165 static inline void dp_tx_update_tdls_flags(struct dp_tx_desc_s *tx_desc)
166 {
167 	return;
168 }
169 
170 static inline void dp_non_std_tx_comp_free_buff(struct dp_tx_desc_s *tx_desc,
171 				  struct dp_vdev *vdev)
172 {
173 	return;
174 }
175 
176 #endif
177 
178 
179 
180 #ifdef FEATURE_WDS
181 void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
182 #endif
183 
184 #ifdef ATH_SUPPORT_IQUE
185 void dp_tx_me_exit(struct dp_pdev *pdev);
186 #else
187 static inline void dp_tx_me_exit(struct dp_pdev *pdev)
188 {
189 	return;
190 }
191 #endif
192 
193 #ifdef FEATURE_PERPKT_INFO
194 QDF_STATUS
195 dp_get_completion_indication_for_stack(struct dp_soc *soc,  struct dp_pdev *pdev,
196 		      uint16_t peer_id, uint32_t ppdu_id, uint8_t first_msdu,
197 		      uint8_t last_msdu, qdf_nbuf_t netbuf);
198 
199 void  dp_send_completion_to_stack(struct dp_soc *soc,  struct dp_pdev *pdev,
200 					uint16_t peer_id, uint32_t ppdu_id,
201 					qdf_nbuf_t netbuf);
202 #endif
203 
204 /* TODO TX_FEATURE_NOT_YET */
205 static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
206 {
207 	return;
208 }
209 /* TODO TX_FEATURE_NOT_YET */
210 #endif
211