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