xref: /wlan-driver/qca-wifi-host-cmn/qdf/inc/i_qdf_nbuf_api_m.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2014-2017,2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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: i_qdf_nbuf_api_m.h
22  *
23  * Platform specific qdf_nbuf_public network buffer API
24  * This file defines the network buffer abstraction.
25  * Included by qdf_nbuf.h and should not be included
26  * directly from other files.
27  */
28 
29 #ifndef _QDF_NBUF_M_H
30 #define _QDF_NBUF_M_H
31 
qdf_nbuf_ipa_owned_get(qdf_nbuf_t buf)32 static inline int qdf_nbuf_ipa_owned_get(qdf_nbuf_t buf)
33 {
34 	return __qdf_nbuf_ipa_owned_get(buf);
35 }
36 
qdf_nbuf_ipa_owned_set(qdf_nbuf_t buf)37 static inline void qdf_nbuf_ipa_owned_set(qdf_nbuf_t buf)
38 {
39 	__qdf_nbuf_ipa_owned_set(buf);
40 }
41 
qdf_nbuf_ipa_owned_clear(qdf_nbuf_t buf)42 static inline void qdf_nbuf_ipa_owned_clear(qdf_nbuf_t buf)
43 {
44 	__qdf_nbuf_ipa_owned_clear(buf);
45 }
46 
qdf_nbuf_ipa_priv_get(qdf_nbuf_t buf)47 static inline int qdf_nbuf_ipa_priv_get(qdf_nbuf_t buf)
48 {
49 	return __qdf_nbuf_ipa_priv_get(buf);
50 }
51 
qdf_nbuf_ipa_priv_set(qdf_nbuf_t buf,uint32_t priv)52 static inline void qdf_nbuf_ipa_priv_set(qdf_nbuf_t buf, uint32_t priv)
53 {
54 
55 	QDF_BUG(!(priv & QDF_NBUF_IPA_CHECK_MASK));
56 	__qdf_nbuf_ipa_priv_set(buf, priv);
57 }
58 
qdf_nbuf_tx_notify_comp_set(qdf_nbuf_t buf,uint8_t val)59 static inline void qdf_nbuf_tx_notify_comp_set(qdf_nbuf_t buf, uint8_t val)
60 {
61 	QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(buf) = val;
62 }
63 
qdf_nbuf_tx_notify_comp_get(qdf_nbuf_t buf)64 static inline uint8_t qdf_nbuf_tx_notify_comp_get(qdf_nbuf_t buf)
65 {
66 	return QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(buf);
67 }
68 
69 /**
70  * qdf_nbuf_set_rx_protocol_tag()
71  * @buf: Network buffer
72  * @val: Value to be set in the nbuf
73  * Return: None
74  */
qdf_nbuf_set_rx_protocol_tag(qdf_nbuf_t buf,uint16_t val)75 static inline void qdf_nbuf_set_rx_protocol_tag(qdf_nbuf_t buf, uint16_t val)
76 {
77 }
78 
79 /**
80  * qdf_nbuf_get_rx_protocol_tag()
81  * @buf: Network buffer
82  * Return: Value of rx protocol tag, here 0
83  */
qdf_nbuf_get_rx_protocol_tag(qdf_nbuf_t buf)84 static inline uint16_t qdf_nbuf_get_rx_protocol_tag(qdf_nbuf_t buf)
85 {
86 	return 0;
87 }
88 
89 /**
90  * qdf_nbuf_set_rx_flow_tag() - set given value in flow tag field
91  * of buf(skb->cb)
92  * @buf: Network buffer
93  * @val: Rx Flow Tag to be set in the nbuf
94  * Return: None
95  */
qdf_nbuf_set_rx_flow_tag(qdf_nbuf_t buf,uint16_t val)96 static inline void qdf_nbuf_set_rx_flow_tag(qdf_nbuf_t buf, uint16_t val)
97 {
98 }
99 
100 /**
101  * qdf_nbuf_get_rx_flow_tag() - Get the value of flow_tag
102  * field of buf(skb->cb)
103  * @buf: Network buffer
104  * Return: Value of rx flow tag, here 0
105  */
qdf_nbuf_get_rx_flow_tag(qdf_nbuf_t buf)106 static inline uint16_t qdf_nbuf_get_rx_flow_tag(qdf_nbuf_t buf)
107 {
108 	return 0;
109 }
110 
111 /**
112  * qdf_nbuf_set_exc_frame() - set exception frame flag
113  * @buf: Network buffer whose cb is to set exception frame flag
114  * @value: exception frame flag, value 0 or 1.
115  *
116  * Return: none
117  */
qdf_nbuf_set_exc_frame(qdf_nbuf_t buf,uint8_t value)118 static inline void qdf_nbuf_set_exc_frame(qdf_nbuf_t buf, uint8_t value)
119 {
120 	QDF_NBUF_CB_RX_PACKET_EXC_FRAME(buf) = value;
121 }
122 
123 /**
124  * qdf_nbuf_is_exc_frame() - check exception frame flag bit
125  * @buf: Network buffer to get exception flag
126  *
127  * Return: 0 or 1
128  */
qdf_nbuf_is_exc_frame(qdf_nbuf_t buf)129 static inline uint8_t qdf_nbuf_is_exc_frame(qdf_nbuf_t buf)
130 {
131 	return QDF_NBUF_CB_RX_PACKET_EXC_FRAME(buf);
132 }
133 
134 /**
135  * qdf_nbuf_set_lmac_id() - set lmac ID
136  * @buf: Network buffer
137  * @value: lmac ID value
138  *
139  * Return: none
140  */
qdf_nbuf_set_lmac_id(qdf_nbuf_t buf,uint8_t value)141 static inline void qdf_nbuf_set_lmac_id(qdf_nbuf_t buf, uint8_t value)
142 {
143 	QDF_NBUF_CB_RX_PACKET_LMAC_ID(buf) = value;
144 }
145 
146 /**
147  * qdf_nbuf_get_lmac_id() - get lmac ID of RX packet
148  * @buf: Network buffer
149  *
150  * Return: lmac ID value
151  */
qdf_nbuf_get_lmac_id(qdf_nbuf_t buf)152 static inline uint8_t qdf_nbuf_get_lmac_id(qdf_nbuf_t buf)
153 {
154 	return QDF_NBUF_CB_RX_PACKET_LMAC_ID(buf);
155 }
156 
157 /**
158  * qdf_nbuf_get_mpdu_seq_num() - get MPDU sequence number
159  * @buf: Network buffer
160  *
161  * Return: mpdu sequence number value
162  */
qdf_nbuf_get_mpdu_seq_num(qdf_nbuf_t buf)163 static inline uint16_t qdf_nbuf_get_mpdu_seq_num(qdf_nbuf_t buf)
164 {
165 	return QDF_NBUF_CB_RX_MPDU_SEQ_NUM(buf);
166 }
167 
168 /**
169  * qdf_nbuf_set_rx_ipa_smmu_map() - set ipa smmu mapped flag
170  * @buf: Network buffer
171  * @value: 1 - ipa smmu mapped, 0 - ipa smmu unmapped
172  *
173  * Return: none
174  */
qdf_nbuf_set_rx_ipa_smmu_map(qdf_nbuf_t buf,uint8_t value)175 static inline void qdf_nbuf_set_rx_ipa_smmu_map(qdf_nbuf_t buf,
176 						uint8_t value)
177 {
178 	QDF_NBUF_CB_RX_PACKET_IPA_SMMU_MAP(buf) = value;
179 }
180 
181 /**
182  * qdf_nbuf_is_rx_ipa_smmu_map() - check ipa smmu map flag
183  * @buf: Network buffer
184  *
185  * Return 0 or 1
186  */
qdf_nbuf_is_rx_ipa_smmu_map(qdf_nbuf_t buf)187 static inline uint8_t qdf_nbuf_is_rx_ipa_smmu_map(qdf_nbuf_t buf)
188 {
189 	return QDF_NBUF_CB_RX_PACKET_IPA_SMMU_MAP(buf);
190 }
191 
192 /**
193  * qdf_nbuf_set_rx_reo_dest_ind_or_sw_excpt() - set reo destination indication
194  *						or sw exception flag
195  * @buf: Network buffer
196  * @value: value to set
197  *
198  * Return: none
199  */
qdf_nbuf_set_rx_reo_dest_ind_or_sw_excpt(qdf_nbuf_t buf,uint8_t value)200 static inline void qdf_nbuf_set_rx_reo_dest_ind_or_sw_excpt(qdf_nbuf_t buf,
201 							    uint8_t value)
202 {
203 	QDF_NBUF_CB_RX_PACKET_REO_DEST_IND_OR_SW_EXCPT(buf) = value;
204 }
205 
206 /**
207  * qdf_nbuf_get_rx_reo_dest_ind_or_sw_excpt() - get reo destination indication
208  *						or sw exception flag
209  * @buf: Network buffer
210  *
211  * Return reo destination indication value (0 ~ 31) or sw exception (0 ~ 1)
212  */
qdf_nbuf_get_rx_reo_dest_ind_or_sw_excpt(qdf_nbuf_t buf)213 static inline uint8_t qdf_nbuf_get_rx_reo_dest_ind_or_sw_excpt(qdf_nbuf_t buf)
214 {
215 	return QDF_NBUF_CB_RX_PACKET_REO_DEST_IND_OR_SW_EXCPT(buf);
216 }
217 
218 /**
219  * qdf_nbuf_get_tx_fctx() - get fctx of nbuf
220  *
221  * @buf: Network buffer
222  * Return: fctx value
223  */
qdf_nbuf_get_tx_fctx(qdf_nbuf_t buf)224 static inline void *qdf_nbuf_get_tx_fctx(qdf_nbuf_t buf)
225 {
226 	return NULL;
227 }
228 
229 /**
230  * qdf_nbuf_set_tx_fctx_type() - set ftype and fctx
231  *
232  * @buf: Network buffer
233  * @ctx: address to fctx
234  * @type: ftype
235  *
236  * Return: void
237  */
238 static inline void
qdf_nbuf_set_tx_fctx_type(qdf_nbuf_t buf,void * ctx,uint8_t type)239 qdf_nbuf_set_tx_fctx_type(qdf_nbuf_t buf, void *ctx, uint8_t type)
240 {
241 }
242 
243 /**
244  * qdf_nbuf_tx_set_band() - Set band in nbuf cb
245  * @nbuf: nbuf pointer
246  * @band: peer band
247  *
248  * Return: None
249  */
250 static inline void
qdf_nbuf_tx_set_band(qdf_nbuf_t nbuf,uint8_t band)251 qdf_nbuf_tx_set_band(qdf_nbuf_t nbuf, uint8_t band)
252 {
253 	QDF_NBUF_CB_TX_BAND(nbuf) = band;
254 }
255 
256 /**
257  * qdf_nbuf_tx_get_band() - Get band from nbuf cb
258  * @nbuf: nbuf pointer
259  *
260  * Return: Band
261  */
262 static inline uint8_t
qdf_nbuf_tx_get_band(qdf_nbuf_t nbuf)263 qdf_nbuf_tx_get_band(qdf_nbuf_t nbuf)
264 {
265 	return QDF_NBUF_CB_TX_BAND(nbuf);
266 }
267 
268 /**
269  * qdf_nbuf_rx_set_band() - Set band in nbuf cb
270  * @nbuf: nbuf pointer
271  * @band: peer band
272  *
273  * Return: None
274  */
275 static inline void
qdf_nbuf_rx_set_band(qdf_nbuf_t nbuf,uint8_t band)276 qdf_nbuf_rx_set_band(qdf_nbuf_t nbuf, uint8_t band)
277 {
278 	QDF_NBUF_CB_RX_BAND(nbuf) = band;
279 }
280 
281 /**
282  * qdf_nbuf_rx_get_band() - Get band from nbuf cb
283  * @nbuf: nbuf pointer
284  *
285  * Return: Band
286  */
287 static inline uint8_t
qdf_nbuf_rx_get_band(qdf_nbuf_t nbuf)288 qdf_nbuf_rx_get_band(qdf_nbuf_t nbuf)
289 {
290 	return QDF_NBUF_CB_RX_BAND(nbuf);
291 }
292 
293 /**
294  * qdf_nbuf_set_tx_ts() - set tx timestamp of nbuf
295  * @buf: Network buffer
296  *
297  * Return: None
298  */
qdf_nbuf_set_tx_ts(qdf_nbuf_t buf)299 static inline void qdf_nbuf_set_tx_ts(qdf_nbuf_t buf)
300 {
301 	__qdf_nbuf_set_tx_ts(buf, qdf_ktime_real_get());
302 }
303 
304 /**
305  * qdf_nbuf_get_tx_ts() - get tx timestamp of nbuf
306  * @buf: Network buffer
307  * @clear: clear the fields after getting tx timestamp
308  *
309  * Return: tx timestamp
310  */
qdf_nbuf_get_tx_ts(qdf_nbuf_t buf,bool clear)311 static inline qdf_time_t qdf_nbuf_get_tx_ts(qdf_nbuf_t buf, bool clear)
312 {
313 	qdf_time_t ts = __qdf_nbuf_get_tx_ts(buf);
314 
315 	if (clear)
316 		__qdf_nbuf_clear_tx_ts(buf);
317 	return ts;
318 }
319 #endif /* _QDF_NBUF_M_H */
320