xref: /wlan-driver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2014-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.h
22*5113495bSYour Name  * This file provides OS dependent nbuf API's.
23*5113495bSYour Name  */
24*5113495bSYour Name 
25*5113495bSYour Name #ifndef _I_QDF_NBUF_H
26*5113495bSYour Name #define _I_QDF_NBUF_H
27*5113495bSYour Name 
28*5113495bSYour Name #include <linux/skbuff.h>
29*5113495bSYour Name #include <linux/netdevice.h>
30*5113495bSYour Name #include <linux/etherdevice.h>
31*5113495bSYour Name #include <linux/dma-mapping.h>
32*5113495bSYour Name #include <linux/version.h>
33*5113495bSYour Name #include <asm/cacheflush.h>
34*5113495bSYour Name #include <qdf_types.h>
35*5113495bSYour Name #include <qdf_net_types.h>
36*5113495bSYour Name #include <qdf_status.h>
37*5113495bSYour Name #include <qdf_util.h>
38*5113495bSYour Name #include <qdf_mem.h>
39*5113495bSYour Name #include <linux/tcp.h>
40*5113495bSYour Name #include <qdf_util.h>
41*5113495bSYour Name #include <qdf_nbuf_frag.h>
42*5113495bSYour Name #include "qdf_time.h"
43*5113495bSYour Name 
44*5113495bSYour Name #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
45*5113495bSYour Name /* Since commit
46*5113495bSYour Name  *  baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")
47*5113495bSYour Name  *
48*5113495bSYour Name  * the function netif_rx() can be used in preemptible/thread context as
49*5113495bSYour Name  * well as in interrupt context.
50*5113495bSYour Name  *
51*5113495bSYour Name  * Use netif_rx().
52*5113495bSYour Name  */
53*5113495bSYour Name #define netif_rx_ni(skb) netif_rx(skb)
54*5113495bSYour Name #endif
55*5113495bSYour Name 
56*5113495bSYour Name /*
57*5113495bSYour Name  * Use socket buffer as the underlying implementation as skbuf .
58*5113495bSYour Name  * Linux use sk_buff to represent both packet and data,
59*5113495bSYour Name  * so we use sk_buffer to represent both skbuf .
60*5113495bSYour Name  */
61*5113495bSYour Name typedef struct sk_buff *__qdf_nbuf_t;
62*5113495bSYour Name 
63*5113495bSYour Name /*
64*5113495bSYour Name  * typedef __qdf_nbuf_queue_head_t - abstraction for sk_buff_head linux struct
65*5113495bSYour Name  *
66*5113495bSYour Name  * This is used for skb queue management via linux skb buff head APIs
67*5113495bSYour Name  */
68*5113495bSYour Name typedef struct sk_buff_head __qdf_nbuf_queue_head_t;
69*5113495bSYour Name 
70*5113495bSYour Name /*
71*5113495bSYour Name  * typedef __qdf_nbuf_shared_info_t for skb_shinfo linux struct
72*5113495bSYour Name  *
73*5113495bSYour Name  * This is used for skb shared info via linux skb shinfo APIs
74*5113495bSYour Name  */
75*5113495bSYour Name typedef struct skb_shared_info *__qdf_nbuf_shared_info_t;
76*5113495bSYour Name 
77*5113495bSYour Name #define QDF_NBUF_CB_TX_MAX_OS_FRAGS 1
78*5113495bSYour Name 
79*5113495bSYour Name #define QDF_SHINFO_SIZE    SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
80*5113495bSYour Name 
81*5113495bSYour Name /* QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS -
82*5113495bSYour Name  * max tx fragments added by the driver
83*5113495bSYour Name  * The driver will always add one tx fragment (the tx descriptor)
84*5113495bSYour Name  */
85*5113495bSYour Name #define QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS 2
86*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_EAPOL  1
87*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_ARP    2
88*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_WAPI   3
89*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_DHCP   4
90*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_ICMP   5
91*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_ICMPv6 6
92*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_DHCPV6 7
93*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_END_INDICATION 8
94*5113495bSYour Name #define QDF_NBUF_CB_PACKET_TYPE_TCP_ACK 9
95*5113495bSYour Name 
96*5113495bSYour Name #define RADIOTAP_BASE_HEADER_LEN sizeof(struct ieee80211_radiotap_header)
97*5113495bSYour Name 
98*5113495bSYour Name #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0))
99*5113495bSYour Name #define IEEE80211_RADIOTAP_HE 23
100*5113495bSYour Name #define IEEE80211_RADIOTAP_HE_MU 24
101*5113495bSYour Name #endif
102*5113495bSYour Name 
103*5113495bSYour Name #define IEEE80211_RADIOTAP_HE_MU_OTHER 25
104*5113495bSYour Name 
105*5113495bSYour Name #define IEEE80211_RADIOTAP_EXT1_USIG	1
106*5113495bSYour Name #define IEEE80211_RADIOTAP_EXT1_EHT	2
107*5113495bSYour Name 
108*5113495bSYour Name /* mark the first packet after wow wakeup */
109*5113495bSYour Name #define QDF_MARK_FIRST_WAKEUP_PACKET   0x80000000
110*5113495bSYour Name 
111*5113495bSYour Name /* TCP Related MASK */
112*5113495bSYour Name #define QDF_NBUF_PKT_TCPOP_FIN			0x01
113*5113495bSYour Name #define QDF_NBUF_PKT_TCPOP_FIN_ACK		0x11
114*5113495bSYour Name #define QDF_NBUF_PKT_TCPOP_RST			0x04
115*5113495bSYour Name 
116*5113495bSYour Name /*
117*5113495bSYour Name  * Make sure that qdf_dma_addr_t in the cb block is always 64 bit aligned
118*5113495bSYour Name  */
119*5113495bSYour Name typedef union {
120*5113495bSYour Name 	uint64_t       u64;
121*5113495bSYour Name 	qdf_dma_addr_t dma_addr;
122*5113495bSYour Name } qdf_paddr_t;
123*5113495bSYour Name 
124*5113495bSYour Name typedef void (*qdf_nbuf_trace_update_t)(char *);
125*5113495bSYour Name typedef void (*qdf_nbuf_free_t)(__qdf_nbuf_t);
126*5113495bSYour Name 
127*5113495bSYour Name #define __qdf_nbuf_mapped_paddr_get(skb) QDF_NBUF_CB_PADDR(skb)
128*5113495bSYour Name 
129*5113495bSYour Name #define __qdf_nbuf_mapped_paddr_set(skb, paddr)	\
130*5113495bSYour Name 	(QDF_NBUF_CB_PADDR(skb) = paddr)
131*5113495bSYour Name 
132*5113495bSYour Name #define __qdf_nbuf_frag_push_head(					\
133*5113495bSYour Name 	skb, frag_len, frag_vaddr, frag_paddr)				\
134*5113495bSYour Name 	do {					\
135*5113495bSYour Name 		QDF_NBUF_CB_TX_NUM_EXTRA_FRAGS(skb) = 1;		\
136*5113495bSYour Name 		QDF_NBUF_CB_TX_EXTRA_FRAG_VADDR(skb) = frag_vaddr;	\
137*5113495bSYour Name 		QDF_NBUF_CB_TX_EXTRA_FRAG_PADDR(skb) = frag_paddr;	\
138*5113495bSYour Name 		QDF_NBUF_CB_TX_EXTRA_FRAG_LEN(skb) = frag_len;		\
139*5113495bSYour Name 	} while (0)
140*5113495bSYour Name 
141*5113495bSYour Name #define __qdf_nbuf_get_frag_vaddr(skb, frag_num)		\
142*5113495bSYour Name 	((frag_num < QDF_NBUF_CB_TX_NUM_EXTRA_FRAGS(skb)) ?		\
143*5113495bSYour Name 	 QDF_NBUF_CB_TX_EXTRA_FRAG_VADDR(skb) : ((skb)->data))
144*5113495bSYour Name 
145*5113495bSYour Name #define __qdf_nbuf_get_frag_vaddr_always(skb)       \
146*5113495bSYour Name 			QDF_NBUF_CB_TX_EXTRA_FRAG_VADDR(skb)
147*5113495bSYour Name 
148*5113495bSYour Name #define __qdf_nbuf_get_frag_paddr(skb, frag_num)			\
149*5113495bSYour Name 	((frag_num < QDF_NBUF_CB_TX_NUM_EXTRA_FRAGS(skb)) ?		\
150*5113495bSYour Name 	 QDF_NBUF_CB_TX_EXTRA_FRAG_PADDR(skb) :				\
151*5113495bSYour Name 	 /* assume that the OS only provides a single fragment */	\
152*5113495bSYour Name 	 QDF_NBUF_CB_PADDR(skb))
153*5113495bSYour Name 
154*5113495bSYour Name #define __qdf_nbuf_get_tx_frag_paddr(skb) QDF_NBUF_CB_TX_EXTRA_FRAG_PADDR(skb)
155*5113495bSYour Name 
156*5113495bSYour Name #define __qdf_nbuf_get_frag_len(skb, frag_num)			\
157*5113495bSYour Name 	((frag_num < QDF_NBUF_CB_TX_NUM_EXTRA_FRAGS(skb)) ?		\
158*5113495bSYour Name 	 QDF_NBUF_CB_TX_EXTRA_FRAG_LEN(skb) : (skb)->len)
159*5113495bSYour Name 
160*5113495bSYour Name #define __qdf_nbuf_get_frag_is_wordstream(skb, frag_num)		\
161*5113495bSYour Name 	((frag_num < QDF_NBUF_CB_TX_NUM_EXTRA_FRAGS(skb))		\
162*5113495bSYour Name 	 ? (QDF_NBUF_CB_TX_EXTRA_FRAG_WORDSTR_EFRAG(skb))		\
163*5113495bSYour Name 	 : (QDF_NBUF_CB_TX_EXTRA_FRAG_WORDSTR_NBUF(skb)))
164*5113495bSYour Name 
165*5113495bSYour Name #define __qdf_nbuf_set_frag_is_wordstream(skb, frag_num, is_wstrm)	\
166*5113495bSYour Name 	do {								\
167*5113495bSYour Name 		if (frag_num >= QDF_NBUF_CB_TX_NUM_EXTRA_FRAGS(skb))	\
168*5113495bSYour Name 			frag_num = QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS;	\
169*5113495bSYour Name 		if (frag_num)						\
170*5113495bSYour Name 			QDF_NBUF_CB_TX_EXTRA_FRAG_WORDSTR_EFRAG(skb) =  \
171*5113495bSYour Name 							      is_wstrm; \
172*5113495bSYour Name 		else					\
173*5113495bSYour Name 			QDF_NBUF_CB_TX_EXTRA_FRAG_WORDSTR_NBUF(skb) =   \
174*5113495bSYour Name 							      is_wstrm; \
175*5113495bSYour Name 	} while (0)
176*5113495bSYour Name 
177*5113495bSYour Name #define __qdf_nbuf_set_vdev_ctx(skb, vdev_id) \
178*5113495bSYour Name 	do { \
179*5113495bSYour Name 		QDF_NBUF_CB_TX_VDEV_CTX((skb)) = (vdev_id); \
180*5113495bSYour Name 	} while (0)
181*5113495bSYour Name 
182*5113495bSYour Name #define __qdf_nbuf_get_vdev_ctx(skb) \
183*5113495bSYour Name 	QDF_NBUF_CB_TX_VDEV_CTX((skb))
184*5113495bSYour Name 
185*5113495bSYour Name #define __qdf_nbuf_set_tx_ftype(skb, type) \
186*5113495bSYour Name 	do { \
187*5113495bSYour Name 		QDF_NBUF_CB_TX_FTYPE((skb)) = (type); \
188*5113495bSYour Name 	} while (0)
189*5113495bSYour Name 
190*5113495bSYour Name #define __qdf_nbuf_set_vdev_xmit_type(skb, type) \
191*5113495bSYour Name 	do { \
192*5113495bSYour Name 		QDF_NBUF_CB_PKT_XMIT_TYPE((skb)) = (type); \
193*5113495bSYour Name 	} while (0)
194*5113495bSYour Name 
195*5113495bSYour Name #define __qdf_nbuf_get_tx_ftype(skb) \
196*5113495bSYour Name 		 QDF_NBUF_CB_TX_FTYPE((skb))
197*5113495bSYour Name 
198*5113495bSYour Name #define __qdf_nbuf_get_vdev_xmit_type(skb) \
199*5113495bSYour Name 		 QDF_NBUF_CB_PKT_XMIT_TYPE((skb))
200*5113495bSYour Name 
201*5113495bSYour Name 
202*5113495bSYour Name #define __qdf_nbuf_set_rx_ftype(skb, type) \
203*5113495bSYour Name 	do { \
204*5113495bSYour Name 		QDF_NBUF_CB_RX_FTYPE((skb)) = (type); \
205*5113495bSYour Name 	} while (0)
206*5113495bSYour Name 
207*5113495bSYour Name #define __qdf_nbuf_get_rx_ftype(skb) \
208*5113495bSYour Name 		 QDF_NBUF_CB_RX_FTYPE((skb))
209*5113495bSYour Name 
210*5113495bSYour Name #define __qdf_nbuf_set_rx_chfrag_start(skb, val) \
211*5113495bSYour Name 	((QDF_NBUF_CB_RX_CHFRAG_START((skb))) = val)
212*5113495bSYour Name 
213*5113495bSYour Name #define __qdf_nbuf_is_rx_chfrag_start(skb) \
214*5113495bSYour Name 	(QDF_NBUF_CB_RX_CHFRAG_START((skb)))
215*5113495bSYour Name 
216*5113495bSYour Name #define __qdf_nbuf_set_rx_chfrag_cont(skb, val) \
217*5113495bSYour Name 	do { \
218*5113495bSYour Name 		(QDF_NBUF_CB_RX_CHFRAG_CONT((skb))) = val; \
219*5113495bSYour Name 	} while (0)
220*5113495bSYour Name 
221*5113495bSYour Name #define __qdf_nbuf_is_rx_chfrag_cont(skb) \
222*5113495bSYour Name 	(QDF_NBUF_CB_RX_CHFRAG_CONT((skb)))
223*5113495bSYour Name 
224*5113495bSYour Name #define __qdf_nbuf_set_rx_chfrag_end(skb, val) \
225*5113495bSYour Name 	((QDF_NBUF_CB_RX_CHFRAG_END((skb))) = val)
226*5113495bSYour Name 
227*5113495bSYour Name #define __qdf_nbuf_is_rx_chfrag_end(skb) \
228*5113495bSYour Name 	(QDF_NBUF_CB_RX_CHFRAG_END((skb)))
229*5113495bSYour Name 
230*5113495bSYour Name #define __qdf_nbuf_set_da_mcbc(skb, val) \
231*5113495bSYour Name 	((QDF_NBUF_CB_RX_DA_MCBC((skb))) = val)
232*5113495bSYour Name 
233*5113495bSYour Name #define __qdf_nbuf_is_da_mcbc(skb) \
234*5113495bSYour Name 	(QDF_NBUF_CB_RX_DA_MCBC((skb)))
235*5113495bSYour Name 
236*5113495bSYour Name #define __qdf_nbuf_set_da_valid(skb, val) \
237*5113495bSYour Name 	((QDF_NBUF_CB_RX_DA_VALID((skb))) = val)
238*5113495bSYour Name 
239*5113495bSYour Name #define __qdf_nbuf_is_da_valid(skb) \
240*5113495bSYour Name 	(QDF_NBUF_CB_RX_DA_VALID((skb)))
241*5113495bSYour Name 
242*5113495bSYour Name #define __qdf_nbuf_set_sa_valid(skb, val) \
243*5113495bSYour Name 	((QDF_NBUF_CB_RX_SA_VALID((skb))) = val)
244*5113495bSYour Name 
245*5113495bSYour Name #define __qdf_nbuf_is_sa_valid(skb) \
246*5113495bSYour Name 	(QDF_NBUF_CB_RX_SA_VALID((skb)))
247*5113495bSYour Name 
248*5113495bSYour Name #define __qdf_nbuf_set_rx_retry_flag(skb, val) \
249*5113495bSYour Name 	((QDF_NBUF_CB_RX_RETRY_FLAG((skb))) = val)
250*5113495bSYour Name 
251*5113495bSYour Name #define __qdf_nbuf_is_rx_retry_flag(skb) \
252*5113495bSYour Name 	(QDF_NBUF_CB_RX_RETRY_FLAG((skb)))
253*5113495bSYour Name 
254*5113495bSYour Name #define __qdf_nbuf_set_raw_frame(skb, val) \
255*5113495bSYour Name 	((QDF_NBUF_CB_RX_RAW_FRAME((skb))) = val)
256*5113495bSYour Name 
257*5113495bSYour Name #define __qdf_nbuf_is_raw_frame(skb) \
258*5113495bSYour Name 	(QDF_NBUF_CB_RX_RAW_FRAME((skb)))
259*5113495bSYour Name 
260*5113495bSYour Name #define __qdf_nbuf_is_fr_ds_set(skb) \
261*5113495bSYour Name 	(QDF_NBUF_CB_RX_FROM_DS((skb)))
262*5113495bSYour Name 
263*5113495bSYour Name #define __qdf_nbuf_is_to_ds_set(skb) \
264*5113495bSYour Name 	(QDF_NBUF_CB_RX_TO_DS((skb)))
265*5113495bSYour Name 
266*5113495bSYour Name #define __qdf_nbuf_get_tid_val(skb) \
267*5113495bSYour Name 	(QDF_NBUF_CB_RX_TID_VAL((skb)))
268*5113495bSYour Name 
269*5113495bSYour Name #define __qdf_nbuf_set_tid_val(skb, val) \
270*5113495bSYour Name 	((QDF_NBUF_CB_RX_TID_VAL((skb))) = val)
271*5113495bSYour Name 
272*5113495bSYour Name #define __qdf_nbuf_set_is_frag(skb, val) \
273*5113495bSYour Name 	((QDF_NBUF_CB_RX_IS_FRAG((skb))) = val)
274*5113495bSYour Name 
275*5113495bSYour Name #define __qdf_nbuf_is_frag(skb) \
276*5113495bSYour Name 	(QDF_NBUF_CB_RX_IS_FRAG((skb)))
277*5113495bSYour Name 
278*5113495bSYour Name #define __qdf_nbuf_set_tx_chfrag_start(skb, val) \
279*5113495bSYour Name 	((QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_CHFRAG_START((skb))) = val)
280*5113495bSYour Name 
281*5113495bSYour Name #define __qdf_nbuf_is_tx_chfrag_start(skb) \
282*5113495bSYour Name 	(QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_CHFRAG_START((skb)))
283*5113495bSYour Name 
284*5113495bSYour Name #define __qdf_nbuf_set_tx_chfrag_cont(skb, val) \
285*5113495bSYour Name 	do { \
286*5113495bSYour Name 		(QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_CHFRAG_CONT((skb))) = val; \
287*5113495bSYour Name 	} while (0)
288*5113495bSYour Name 
289*5113495bSYour Name #define __qdf_nbuf_is_tx_chfrag_cont(skb) \
290*5113495bSYour Name 	(QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_CHFRAG_CONT((skb)))
291*5113495bSYour Name 
292*5113495bSYour Name #define __qdf_nbuf_set_tx_chfrag_end(skb, val) \
293*5113495bSYour Name 	((QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_CHFRAG_END((skb))) = val)
294*5113495bSYour Name 
295*5113495bSYour Name #define __qdf_nbuf_is_tx_chfrag_end(skb) \
296*5113495bSYour Name 	(QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_CHFRAG_END((skb)))
297*5113495bSYour Name 
298*5113495bSYour Name #define __qdf_nbuf_trace_set_proto_type(skb, proto_type)  \
299*5113495bSYour Name 	(QDF_NBUF_CB_TX_PROTO_TYPE(skb) = (proto_type))
300*5113495bSYour Name 
301*5113495bSYour Name #define __qdf_nbuf_trace_get_proto_type(skb) \
302*5113495bSYour Name 	QDF_NBUF_CB_TX_PROTO_TYPE(skb)
303*5113495bSYour Name 
304*5113495bSYour Name #define __qdf_nbuf_queue_walk_safe(queue, var, tvar)	\
305*5113495bSYour Name 		skb_queue_walk_safe(queue, var, tvar)
306*5113495bSYour Name 
307*5113495bSYour Name /*
308*5113495bSYour Name  * prototypes. Implemented in qdf_nbuf.c
309*5113495bSYour Name  */
310*5113495bSYour Name 
311*5113495bSYour Name /**
312*5113495bSYour Name  * __qdf_nbuf_alloc() - Allocate nbuf
313*5113495bSYour Name  * @osdev: Device handle
314*5113495bSYour Name  * @size: Netbuf requested size
315*5113495bSYour Name  * @reserve: headroom to start with
316*5113495bSYour Name  * @align: Align
317*5113495bSYour Name  * @prio: Priority
318*5113495bSYour Name  * @func: Function name of the call site
319*5113495bSYour Name  * @line: line number of the call site
320*5113495bSYour Name  *
321*5113495bSYour Name  * This allocates a nbuf aligns if needed and reserves some space in the front,
322*5113495bSYour Name  * since the reserve is done after alignment the reserve value if being
323*5113495bSYour Name  * unaligned will result in an unaligned address.
324*5113495bSYour Name  *
325*5113495bSYour Name  * Return: nbuf or %NULL if no memory
326*5113495bSYour Name  */
327*5113495bSYour Name __qdf_nbuf_t
328*5113495bSYour Name __qdf_nbuf_alloc(__qdf_device_t osdev, size_t size, int reserve, int align,
329*5113495bSYour Name 		 int prio, const char *func, uint32_t line);
330*5113495bSYour Name 
331*5113495bSYour Name __qdf_nbuf_t __qdf_nbuf_alloc_simple(__qdf_device_t osdev, size_t size,
332*5113495bSYour Name 				     const char *func, uint32_t line);
333*5113495bSYour Name 
334*5113495bSYour Name #if defined(QCA_DP_NBUF_FAST_PPEDS)
335*5113495bSYour Name /**
336*5113495bSYour Name  * __qdf_nbuf_alloc_ppe_ds() - Allocates nbuf
337*5113495bSYour Name  * @osdev: Device handle
338*5113495bSYour Name  * @size: Netbuf requested size
339*5113495bSYour Name  * @func: Function name of the call site
340*5113495bSYour Name  * @line: line number of the call site
341*5113495bSYour Name  *
342*5113495bSYour Name  * This allocates an nbuf for wifi module
343*5113495bSYour Name  * in DS mode and uses __netdev_alloc_skb_no_skb_reset API.
344*5113495bSYour Name  * The netdev API invokes skb_recycler_alloc with reset_skb
345*5113495bSYour Name  * as false. Hence, recycler pool will not do reset_struct
346*5113495bSYour Name  * when it allocates DS used buffer to DS module, which will
347*5113495bSYour Name  * helps to improve the performance
348*5113495bSYour Name  *
349*5113495bSYour Name  * Return: nbuf or %NULL if no memory
350*5113495bSYour Name  */
351*5113495bSYour Name 
352*5113495bSYour Name __qdf_nbuf_t __qdf_nbuf_alloc_ppe_ds(__qdf_device_t osdev, size_t size,
353*5113495bSYour Name 				     const char *func, uint32_t line);
354*5113495bSYour Name #endif /* QCA_DP_NBUF_FAST_PPEDS */
355*5113495bSYour Name 
356*5113495bSYour Name /**
357*5113495bSYour Name  * __qdf_nbuf_frag_alloc() - Allocate nbuf in page fragment way.
358*5113495bSYour Name  * @osdev: Device handle
359*5113495bSYour Name  * @size: Netbuf requested size
360*5113495bSYour Name  * @reserve: headroom to start with
361*5113495bSYour Name  * @align: Align
362*5113495bSYour Name  * @prio: Priority
363*5113495bSYour Name  * @func: Function name of the call site
364*5113495bSYour Name  * @line: line number of the call site
365*5113495bSYour Name  *
366*5113495bSYour Name  * This allocates a nbuf aligns if needed and reserves some space in the front,
367*5113495bSYour Name  * since the reserve is done after alignment the reserve value if being
368*5113495bSYour Name  * unaligned will result in an unaligned address.
369*5113495bSYour Name  * It will call into kernel page fragment APIs, long time keeping for scattered
370*5113495bSYour Name  * allocations should be considered for avoidance.
371*5113495bSYour Name  * This also brings in more probability of page frag allocation failures during
372*5113495bSYour Name  * low memory situation. In case of page frag allocation failure, fallback to
373*5113495bSYour Name  * non-frag slab allocations.
374*5113495bSYour Name  *
375*5113495bSYour Name  * Return: nbuf or %NULL if no memory
376*5113495bSYour Name  */
377*5113495bSYour Name __qdf_nbuf_t
378*5113495bSYour Name __qdf_nbuf_frag_alloc(__qdf_device_t osdev, size_t size, int reserve, int align,
379*5113495bSYour Name 		      int prio, const char *func, uint32_t line);
380*5113495bSYour Name 
381*5113495bSYour Name /**
382*5113495bSYour Name  * __qdf_nbuf_alloc_no_recycler() - Allocates skb
383*5113495bSYour Name  * @size: Size to be allocated for skb
384*5113495bSYour Name  * @reserve: Reserve headroom size
385*5113495bSYour Name  * @align: Align data
386*5113495bSYour Name  * @func: Function name of the call site
387*5113495bSYour Name  * @line: Line number of the callsite
388*5113495bSYour Name  *
389*5113495bSYour Name  * This API allocates a nbuf and aligns it if needed and reserves some headroom
390*5113495bSYour Name  * space after the alignment where nbuf is not allocated from skb recycler pool.
391*5113495bSYour Name  *
392*5113495bSYour Name  * Return: Allocated nbuf pointer
393*5113495bSYour Name  */
394*5113495bSYour Name __qdf_nbuf_t __qdf_nbuf_alloc_no_recycler(size_t size, int reserve, int align,
395*5113495bSYour Name 					  const char *func, uint32_t line);
396*5113495bSYour Name 
397*5113495bSYour Name /**
398*5113495bSYour Name  * __qdf_nbuf_page_frag_alloc() - Allocate nbuf from @pf_cache page
399*5113495bSYour Name  *				  fragment cache
400*5113495bSYour Name  * @osdev: Device handle
401*5113495bSYour Name  * @size: Netbuf requested size
402*5113495bSYour Name  * @reserve: headroom to start with
403*5113495bSYour Name  * @align: Align
404*5113495bSYour Name  * @pf_cache: Reference to page fragment cache
405*5113495bSYour Name  * @func: Function name of the call site
406*5113495bSYour Name  * @line: line number of the call site
407*5113495bSYour Name  *
408*5113495bSYour Name  * This allocates a nbuf, aligns if needed and reserves some space in the front,
409*5113495bSYour Name  * since the reserve is done after alignment the reserve value if being
410*5113495bSYour Name  * unaligned will result in an unaligned address.
411*5113495bSYour Name  *
412*5113495bSYour Name  * It will call kernel page fragment APIs for allocation of skb->head, prefer
413*5113495bSYour Name  * this API for buffers that are allocated and freed only once i.e., for
414*5113495bSYour Name  * reusable buffers.
415*5113495bSYour Name  *
416*5113495bSYour Name  * Return: nbuf or %NULL if no memory
417*5113495bSYour Name  */
418*5113495bSYour Name __qdf_nbuf_t
419*5113495bSYour Name __qdf_nbuf_page_frag_alloc(__qdf_device_t osdev, size_t size, int reserve,
420*5113495bSYour Name 			   int align, __qdf_frag_cache_t *pf_cache,
421*5113495bSYour Name 			   const char *func, uint32_t line);
422*5113495bSYour Name 
423*5113495bSYour Name /**
424*5113495bSYour Name  * __qdf_nbuf_clone() - clone the nbuf (copy is readonly)
425*5113495bSYour Name  * @nbuf: Pointer to network buffer
426*5113495bSYour Name  *
427*5113495bSYour Name  * if GFP_ATOMIC is overkill then we can check whether its
428*5113495bSYour Name  * called from interrupt context and then do it or else in
429*5113495bSYour Name  * normal case use GFP_KERNEL
430*5113495bSYour Name  *
431*5113495bSYour Name  * example     use "in_irq() || irqs_disabled()"
432*5113495bSYour Name  *
433*5113495bSYour Name  * Return: cloned skb
434*5113495bSYour Name  */
435*5113495bSYour Name __qdf_nbuf_t __qdf_nbuf_clone(__qdf_nbuf_t nbuf);
436*5113495bSYour Name 
437*5113495bSYour Name /**
438*5113495bSYour Name  * __qdf_nbuf_free() - free the nbuf its interrupt safe
439*5113495bSYour Name  * @skb: Pointer to network buffer
440*5113495bSYour Name  *
441*5113495bSYour Name  * Return: none
442*5113495bSYour Name  */
443*5113495bSYour Name void __qdf_nbuf_free(struct sk_buff *skb);
444*5113495bSYour Name 
445*5113495bSYour Name /**
446*5113495bSYour Name  * __qdf_nbuf_map() - map a buffer to local bus address space
447*5113495bSYour Name  * @osdev: OS device
448*5113495bSYour Name  * @skb: Pointer to network buffer
449*5113495bSYour Name  * @dir: Direction
450*5113495bSYour Name  *
451*5113495bSYour Name  * Return: QDF_STATUS
452*5113495bSYour Name  */
453*5113495bSYour Name QDF_STATUS __qdf_nbuf_map(__qdf_device_t osdev,
454*5113495bSYour Name 			struct sk_buff *skb, qdf_dma_dir_t dir);
455*5113495bSYour Name 
456*5113495bSYour Name /**
457*5113495bSYour Name  * __qdf_nbuf_unmap() - to unmap a previously mapped buf
458*5113495bSYour Name  * @osdev: OS device
459*5113495bSYour Name  * @skb: Pointer to network buffer
460*5113495bSYour Name  * @dir: dma direction
461*5113495bSYour Name  *
462*5113495bSYour Name  * Return: none
463*5113495bSYour Name  */
464*5113495bSYour Name void __qdf_nbuf_unmap(__qdf_device_t osdev,
465*5113495bSYour Name 			struct sk_buff *skb, qdf_dma_dir_t dir);
466*5113495bSYour Name 
467*5113495bSYour Name /**
468*5113495bSYour Name  * __qdf_nbuf_map_single() - map a single buffer to local bus address space
469*5113495bSYour Name  * @osdev: OS device
470*5113495bSYour Name  * @skb: Pointer to network buffer
471*5113495bSYour Name  * @dir: Direction
472*5113495bSYour Name  *
473*5113495bSYour Name  * Return: QDF_STATUS
474*5113495bSYour Name  */
475*5113495bSYour Name QDF_STATUS __qdf_nbuf_map_single(__qdf_device_t osdev,
476*5113495bSYour Name 				 struct sk_buff *skb, qdf_dma_dir_t dir);
477*5113495bSYour Name 
478*5113495bSYour Name /**
479*5113495bSYour Name  * __qdf_nbuf_unmap_single() -  unmap a previously mapped buf
480*5113495bSYour Name  * @osdev: OS device
481*5113495bSYour Name  * @skb: Pointer to network buffer
482*5113495bSYour Name  * @dir: Direction
483*5113495bSYour Name  *
484*5113495bSYour Name  * Return: none
485*5113495bSYour Name  */
486*5113495bSYour Name void __qdf_nbuf_unmap_single(__qdf_device_t osdev,
487*5113495bSYour Name 			struct sk_buff *skb, qdf_dma_dir_t dir);
488*5113495bSYour Name 
489*5113495bSYour Name /**
490*5113495bSYour Name  * __qdf_nbuf_reg_trace_cb() - register trace callback
491*5113495bSYour Name  * @cb_func_ptr: Pointer to trace callback function
492*5113495bSYour Name  *
493*5113495bSYour Name  * Return: none
494*5113495bSYour Name  */
495*5113495bSYour Name void __qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr);
496*5113495bSYour Name 
497*5113495bSYour Name /**
498*5113495bSYour Name  * __qdf_nbuf_reg_free_cb() - register nbuf free callback
499*5113495bSYour Name  * @cb_func_ptr: function pointer to the nbuf free callback
500*5113495bSYour Name  *
501*5113495bSYour Name  * This function registers a callback function for nbuf free.
502*5113495bSYour Name  *
503*5113495bSYour Name  * Return: none
504*5113495bSYour Name  */
505*5113495bSYour Name void __qdf_nbuf_reg_free_cb(qdf_nbuf_free_t cb_func_ptr);
506*5113495bSYour Name 
507*5113495bSYour Name /**
508*5113495bSYour Name  * __qdf_nbuf_dmamap_create() - create a DMA map.
509*5113495bSYour Name  * @osdev: qdf device handle
510*5113495bSYour Name  * @dmap: dma map handle
511*5113495bSYour Name  *
512*5113495bSYour Name  * This can later be used to map networking buffers. They :
513*5113495bSYour Name  * - need space in adf_drv's software descriptor
514*5113495bSYour Name  * - are typically created during adf_drv_create
515*5113495bSYour Name  * - need to be created before any API(qdf_nbuf_map) that uses them
516*5113495bSYour Name  *
517*5113495bSYour Name  * Return: QDF STATUS
518*5113495bSYour Name  */
519*5113495bSYour Name QDF_STATUS __qdf_nbuf_dmamap_create(qdf_device_t osdev, __qdf_dma_map_t *dmap);
520*5113495bSYour Name 
521*5113495bSYour Name /**
522*5113495bSYour Name  * __qdf_nbuf_dmamap_destroy() - delete a dma map
523*5113495bSYour Name  * @osdev: qdf device handle
524*5113495bSYour Name  * @dmap: dma map handle
525*5113495bSYour Name  *
526*5113495bSYour Name  * Return: none
527*5113495bSYour Name  */
528*5113495bSYour Name void __qdf_nbuf_dmamap_destroy(qdf_device_t osdev, __qdf_dma_map_t dmap);
529*5113495bSYour Name 
530*5113495bSYour Name /**
531*5113495bSYour Name  * __qdf_nbuf_dmamap_set_cb() - setup the map callback for a dma map
532*5113495bSYour Name  * @dmap: dma map
533*5113495bSYour Name  * @cb: callback
534*5113495bSYour Name  * @arg: argument
535*5113495bSYour Name  *
536*5113495bSYour Name  * Return: none
537*5113495bSYour Name  */
538*5113495bSYour Name void __qdf_nbuf_dmamap_set_cb(__qdf_dma_map_t dmap, void *cb, void *arg);
539*5113495bSYour Name 
540*5113495bSYour Name /**
541*5113495bSYour Name  * __qdf_nbuf_map_nbytes() - get the dma map of the nbuf
542*5113495bSYour Name  * @osdev: os device
543*5113495bSYour Name  * @skb: skb handle
544*5113495bSYour Name  * @dir: dma direction
545*5113495bSYour Name  * @nbytes: number of bytes to be mapped
546*5113495bSYour Name  *
547*5113495bSYour Name  * Return: QDF_STATUS
548*5113495bSYour Name  */
549*5113495bSYour Name QDF_STATUS __qdf_nbuf_map_nbytes(qdf_device_t osdev, struct sk_buff *skb,
550*5113495bSYour Name 				 qdf_dma_dir_t dir, int nbytes);
551*5113495bSYour Name 
552*5113495bSYour Name /**
553*5113495bSYour Name  * __qdf_nbuf_unmap_nbytes() - to unmap a previously mapped buf
554*5113495bSYour Name  * @osdev: OS device
555*5113495bSYour Name  * @skb: skb handle
556*5113495bSYour Name  * @dir: direction
557*5113495bSYour Name  * @nbytes: number of bytes
558*5113495bSYour Name  *
559*5113495bSYour Name  * Return: none
560*5113495bSYour Name  */
561*5113495bSYour Name void __qdf_nbuf_unmap_nbytes(qdf_device_t osdev, struct sk_buff *skb,
562*5113495bSYour Name 			     qdf_dma_dir_t dir, int nbytes);
563*5113495bSYour Name 
564*5113495bSYour Name /**
565*5113495bSYour Name  * __qdf_nbuf_sync_for_cpu() - nbuf sync
566*5113495bSYour Name  * @osdev: os device
567*5113495bSYour Name  * @skb: sk buff
568*5113495bSYour Name  * @dir: direction
569*5113495bSYour Name  *
570*5113495bSYour Name  * Return: none
571*5113495bSYour Name  */
572*5113495bSYour Name void __qdf_nbuf_sync_for_cpu(qdf_device_t osdev, struct sk_buff *skb,
573*5113495bSYour Name 	qdf_dma_dir_t dir);
574*5113495bSYour Name 
575*5113495bSYour Name /**
576*5113495bSYour Name  * __qdf_nbuf_dma_map_info() - return the dma map info
577*5113495bSYour Name  * @bmap: dma map
578*5113495bSYour Name  * @sg: dma map info
579*5113495bSYour Name  *
580*5113495bSYour Name  * Return: none
581*5113495bSYour Name  */
582*5113495bSYour Name void __qdf_nbuf_dma_map_info(__qdf_dma_map_t bmap, qdf_dmamap_info_t *sg);
583*5113495bSYour Name 
584*5113495bSYour Name /**
585*5113495bSYour Name  * __qdf_nbuf_get_frag_size() - get frag size
586*5113495bSYour Name  * @nbuf: sk buffer
587*5113495bSYour Name  * @cur_frag: current frag
588*5113495bSYour Name  *
589*5113495bSYour Name  * Return: frag size
590*5113495bSYour Name  */
591*5113495bSYour Name uint32_t __qdf_nbuf_get_frag_size(__qdf_nbuf_t nbuf, uint32_t cur_frag);
592*5113495bSYour Name 
593*5113495bSYour Name /**
594*5113495bSYour Name  * __qdf_nbuf_frag_info() - return the frag data & len, where frag no. is
595*5113495bSYour Name  *			specified by the index
596*5113495bSYour Name  * @skb: sk buff
597*5113495bSYour Name  * @sg: scatter/gather list of all the frags
598*5113495bSYour Name  *
599*5113495bSYour Name  * Return: none
600*5113495bSYour Name  */
601*5113495bSYour Name void __qdf_nbuf_frag_info(struct sk_buff *skb, qdf_sglist_t  *sg);
602*5113495bSYour Name 
603*5113495bSYour Name /**
604*5113495bSYour Name  * __qdf_nbuf_frag_map() - dma map frag
605*5113495bSYour Name  * @osdev: os device
606*5113495bSYour Name  * @nbuf: sk buff
607*5113495bSYour Name  * @offset: offset
608*5113495bSYour Name  * @dir: direction
609*5113495bSYour Name  * @cur_frag: current fragment
610*5113495bSYour Name  *
611*5113495bSYour Name  * Return: QDF status
612*5113495bSYour Name  */
613*5113495bSYour Name QDF_STATUS __qdf_nbuf_frag_map(
614*5113495bSYour Name 	qdf_device_t osdev, __qdf_nbuf_t nbuf,
615*5113495bSYour Name 	int offset, qdf_dma_dir_t dir, int cur_frag);
616*5113495bSYour Name 
617*5113495bSYour Name /**
618*5113495bSYour Name  * qdf_nbuf_classify_pkt() - classify packet
619*5113495bSYour Name  * @skb: sk buff
620*5113495bSYour Name  *
621*5113495bSYour Name  * Return: none
622*5113495bSYour Name  */
623*5113495bSYour Name void qdf_nbuf_classify_pkt(struct sk_buff *skb);
624*5113495bSYour Name 
625*5113495bSYour Name /**
626*5113495bSYour Name  * __qdf_nbuf_is_ipv4_wapi_pkt() - check if skb data is a wapi packet
627*5113495bSYour Name  * @skb: Pointer to network buffer
628*5113495bSYour Name  *
629*5113495bSYour Name  * This api is for ipv4 packet.
630*5113495bSYour Name  *
631*5113495bSYour Name  * Return: true if packet is WAPI packet
632*5113495bSYour Name  *	   false otherwise.
633*5113495bSYour Name  */
634*5113495bSYour Name bool __qdf_nbuf_is_ipv4_wapi_pkt(struct sk_buff *skb);
635*5113495bSYour Name 
636*5113495bSYour Name /**
637*5113495bSYour Name  * __qdf_nbuf_is_ipv4_tdls_pkt() - check if skb data is a tdls packet
638*5113495bSYour Name  * @skb: Pointer to network buffer
639*5113495bSYour Name  *
640*5113495bSYour Name  * This api is for ipv4 packet.
641*5113495bSYour Name  *
642*5113495bSYour Name  * Return: true if packet is tdls packet
643*5113495bSYour Name  *	   false otherwise.
644*5113495bSYour Name  */
645*5113495bSYour Name bool __qdf_nbuf_is_ipv4_tdls_pkt(struct sk_buff *skb);
646*5113495bSYour Name 
647*5113495bSYour Name /**
648*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_pkt() - check if packet is a ipv4 packet
649*5113495bSYour Name  * @data: Pointer to network data
650*5113495bSYour Name  *
651*5113495bSYour Name  * This api is for Tx packets.
652*5113495bSYour Name  *
653*5113495bSYour Name  * Return: true if packet is ipv4 packet
654*5113495bSYour Name  *	   false otherwise
655*5113495bSYour Name  */
656*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_pkt(uint8_t *data);
657*5113495bSYour Name 
658*5113495bSYour Name /**
659*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_pkt() - check if it is IPV6 packet.
660*5113495bSYour Name  * @data: Pointer to IPV6 packet data buffer
661*5113495bSYour Name  *
662*5113495bSYour Name  * This func. checks whether it is a IPV6 packet or not.
663*5113495bSYour Name  *
664*5113495bSYour Name  * Return: TRUE if it is a IPV6 packet
665*5113495bSYour Name  *         FALSE if not
666*5113495bSYour Name  */
667*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_pkt(uint8_t *data);
668*5113495bSYour Name 
669*5113495bSYour Name /**
670*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
671*5113495bSYour Name  * @data: Pointer to IPV4 packet data buffer
672*5113495bSYour Name  *
673*5113495bSYour Name  * This func. checks whether it is a IPV4 multicast packet or not.
674*5113495bSYour Name  *
675*5113495bSYour Name  * Return: TRUE if it is a IPV4 multicast packet
676*5113495bSYour Name  *         FALSE if not
677*5113495bSYour Name  */
678*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data);
679*5113495bSYour Name 
680*5113495bSYour Name /**
681*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet.
682*5113495bSYour Name  * @data: Pointer to IPV6 packet data buffer
683*5113495bSYour Name  *
684*5113495bSYour Name  * This func. checks whether it is a IPV6 multicast packet or not.
685*5113495bSYour Name  *
686*5113495bSYour Name  * Return: TRUE if it is a IPV6 multicast packet
687*5113495bSYour Name  *         FALSE if not
688*5113495bSYour Name  */
689*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data);
690*5113495bSYour Name 
691*5113495bSYour Name /**
692*5113495bSYour Name  * __qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet.
693*5113495bSYour Name  * @data: Pointer to IPV4 ICMP packet data buffer
694*5113495bSYour Name  *
695*5113495bSYour Name  * This func. checks whether it is a ICMP packet or not.
696*5113495bSYour Name  *
697*5113495bSYour Name  * Return: TRUE if it is a ICMP packet
698*5113495bSYour Name  *         FALSE if not
699*5113495bSYour Name  */
700*5113495bSYour Name bool __qdf_nbuf_data_is_icmp_pkt(uint8_t *data);
701*5113495bSYour Name 
702*5113495bSYour Name /**
703*5113495bSYour Name  * __qdf_nbuf_data_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
704*5113495bSYour Name  * @data: Pointer to IPV6 ICMPV6 packet data buffer
705*5113495bSYour Name  *
706*5113495bSYour Name  * This func. checks whether it is a ICMPV6 packet or not.
707*5113495bSYour Name  *
708*5113495bSYour Name  * Return: TRUE if it is a ICMPV6 packet
709*5113495bSYour Name  *         FALSE if not
710*5113495bSYour Name  */
711*5113495bSYour Name bool __qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data);
712*5113495bSYour Name 
713*5113495bSYour Name /**
714*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
715*5113495bSYour Name  * @data: Pointer to IPV4 UDP packet data buffer
716*5113495bSYour Name  *
717*5113495bSYour Name  * This func. checks whether it is a IPV4 UDP packet or not.
718*5113495bSYour Name  *
719*5113495bSYour Name  * Return: TRUE if it is a IPV4 UDP packet
720*5113495bSYour Name  *         FALSE if not
721*5113495bSYour Name  */
722*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data);
723*5113495bSYour Name 
724*5113495bSYour Name /**
725*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
726*5113495bSYour Name  * @data: Pointer to IPV4 TCP packet data buffer
727*5113495bSYour Name  *
728*5113495bSYour Name  * This func. checks whether it is a IPV4 TCP packet or not.
729*5113495bSYour Name  *
730*5113495bSYour Name  * Return: TRUE if it is a IPV4 TCP packet
731*5113495bSYour Name  *         FALSE if not
732*5113495bSYour Name  */
733*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_tcp_pkt(uint8_t *data);
734*5113495bSYour Name 
735*5113495bSYour Name /**
736*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
737*5113495bSYour Name  * @data: Pointer to IPV6 UDP packet data buffer
738*5113495bSYour Name  *
739*5113495bSYour Name  * This func. checks whether it is a IPV6 UDP packet or not.
740*5113495bSYour Name  *
741*5113495bSYour Name  * Return: TRUE if it is a IPV6 UDP packet
742*5113495bSYour Name  *         FALSE if not
743*5113495bSYour Name  */
744*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_udp_pkt(uint8_t *data);
745*5113495bSYour Name 
746*5113495bSYour Name /**
747*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
748*5113495bSYour Name  * @data: Pointer to IPV6 TCP packet data buffer
749*5113495bSYour Name  *
750*5113495bSYour Name  * This func. checks whether it is a IPV6 TCP packet or not.
751*5113495bSYour Name  *
752*5113495bSYour Name  * Return: TRUE if it is a IPV6 TCP packet
753*5113495bSYour Name  *         FALSE if not
754*5113495bSYour Name  */
755*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_tcp_pkt(uint8_t *data);
756*5113495bSYour Name 
757*5113495bSYour Name /**
758*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_dhcp_pkt() - check if skb data is a dhcp packet
759*5113495bSYour Name  * @data: Pointer to network data buffer
760*5113495bSYour Name  *
761*5113495bSYour Name  * This api is for ipv4 packet.
762*5113495bSYour Name  *
763*5113495bSYour Name  * Return: true if packet is DHCP packet
764*5113495bSYour Name  *	   false otherwise
765*5113495bSYour Name  */
766*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_dhcp_pkt(uint8_t *data);
767*5113495bSYour Name 
768*5113495bSYour Name /**
769*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_dhcp_pkt() - check if skb data is a dhcp packet
770*5113495bSYour Name  * @data: Pointer to network data buffer
771*5113495bSYour Name  *
772*5113495bSYour Name  * This api is for ipv6 packet.
773*5113495bSYour Name  *
774*5113495bSYour Name  * Return: true if packet is DHCP packet
775*5113495bSYour Name  *	   false otherwise
776*5113495bSYour Name  */
777*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_dhcp_pkt(uint8_t *data);
778*5113495bSYour Name 
779*5113495bSYour Name /**
780*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_mdns_pkt() - check if skb data is a mdns packet
781*5113495bSYour Name  * @data: Pointer to network data buffer
782*5113495bSYour Name  *
783*5113495bSYour Name  * This api is for ipv6 packet.
784*5113495bSYour Name  *
785*5113495bSYour Name  * Return: true if packet is MDNS packet
786*5113495bSYour Name  *	   false otherwise
787*5113495bSYour Name  */
788*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_mdns_pkt(uint8_t *data);
789*5113495bSYour Name 
790*5113495bSYour Name /**
791*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_eapol_pkt() - check if skb data is a eapol packet
792*5113495bSYour Name  * @data: Pointer to network data buffer
793*5113495bSYour Name  *
794*5113495bSYour Name  * This api is for ipv4 packet.
795*5113495bSYour Name  *
796*5113495bSYour Name  * Return: true if packet is EAPOL packet
797*5113495bSYour Name  *	   false otherwise.
798*5113495bSYour Name  */
799*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_eapol_pkt(uint8_t *data);
800*5113495bSYour Name 
801*5113495bSYour Name /**
802*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_igmp_pkt() - check if skb data is a igmp packet
803*5113495bSYour Name  * @data: Pointer to network data buffer
804*5113495bSYour Name  *
805*5113495bSYour Name  * This api is for ipv4 packet.
806*5113495bSYour Name  *
807*5113495bSYour Name  * Return: true if packet is igmp packet
808*5113495bSYour Name  *	   false otherwise.
809*5113495bSYour Name  */
810*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_igmp_pkt(uint8_t *data);
811*5113495bSYour Name 
812*5113495bSYour Name /**
813*5113495bSYour Name  * __qdf_nbuf_data_is_ipv6_igmp_pkt() - check if skb data is a igmp packet
814*5113495bSYour Name  * @data: Pointer to network data buffer
815*5113495bSYour Name  *
816*5113495bSYour Name  * This api is for ipv6 packet.
817*5113495bSYour Name  *
818*5113495bSYour Name  * Return: true if packet is igmp packet
819*5113495bSYour Name  *	   false otherwise.
820*5113495bSYour Name  */
821*5113495bSYour Name bool __qdf_nbuf_data_is_ipv6_igmp_pkt(uint8_t *data);
822*5113495bSYour Name 
823*5113495bSYour Name /**
824*5113495bSYour Name  * __qdf_nbuf_is_ipv4_igmp_leave_pkt() - check if skb is a igmp leave packet
825*5113495bSYour Name  * @buf: Pointer to network buffer
826*5113495bSYour Name  *
827*5113495bSYour Name  * This api is for ipv4 packet.
828*5113495bSYour Name  *
829*5113495bSYour Name  * Return: true if packet is igmp packet
830*5113495bSYour Name  *	   false otherwise.
831*5113495bSYour Name  */
832*5113495bSYour Name bool __qdf_nbuf_is_ipv4_igmp_leave_pkt(__qdf_nbuf_t buf);
833*5113495bSYour Name 
834*5113495bSYour Name /**
835*5113495bSYour Name  * __qdf_nbuf_is_ipv6_igmp_leave_pkt() - check if skb is a igmp leave packet
836*5113495bSYour Name  * @buf: Pointer to network buffer
837*5113495bSYour Name  *
838*5113495bSYour Name  * This api is for ipv6 packet.
839*5113495bSYour Name  *
840*5113495bSYour Name  * Return: true if packet is igmp packet
841*5113495bSYour Name  *	   false otherwise.
842*5113495bSYour Name  */
843*5113495bSYour Name bool __qdf_nbuf_is_ipv6_igmp_leave_pkt(__qdf_nbuf_t buf);
844*5113495bSYour Name 
845*5113495bSYour Name /**
846*5113495bSYour Name  * __qdf_nbuf_data_is_ipv4_arp_pkt() - check if skb data is a arp packet
847*5113495bSYour Name  * @data: Pointer to network data buffer
848*5113495bSYour Name  *
849*5113495bSYour Name  * This api is for ipv4 packet.
850*5113495bSYour Name  *
851*5113495bSYour Name  * Return: true if packet is ARP packet
852*5113495bSYour Name  *	   false otherwise.
853*5113495bSYour Name  */
854*5113495bSYour Name bool __qdf_nbuf_data_is_ipv4_arp_pkt(uint8_t *data);
855*5113495bSYour Name 
856*5113495bSYour Name /**
857*5113495bSYour Name  * __qdf_nbuf_is_bcast_pkt() - is destination address broadcast
858*5113495bSYour Name  * @nbuf: sk buff
859*5113495bSYour Name  *
860*5113495bSYour Name  * Return: true if packet is broadcast
861*5113495bSYour Name  *	   false otherwise
862*5113495bSYour Name  */
863*5113495bSYour Name bool __qdf_nbuf_is_bcast_pkt(__qdf_nbuf_t nbuf);
864*5113495bSYour Name 
865*5113495bSYour Name /**
866*5113495bSYour Name  * __qdf_nbuf_is_mcast_replay() - is multicast replay packet
867*5113495bSYour Name  * @nbuf: sk buff
868*5113495bSYour Name  *
869*5113495bSYour Name  * Return: true if packet is multicast replay
870*5113495bSYour Name  *	   false otherwise
871*5113495bSYour Name  */
872*5113495bSYour Name bool __qdf_nbuf_is_mcast_replay(__qdf_nbuf_t nbuf);
873*5113495bSYour Name 
874*5113495bSYour Name /**
875*5113495bSYour Name  * __qdf_nbuf_is_arp_local() - check if local or non local arp
876*5113495bSYour Name  * @skb: pointer to sk_buff
877*5113495bSYour Name  *
878*5113495bSYour Name  * Return: true if local arp or false otherwise.
879*5113495bSYour Name  */
880*5113495bSYour Name bool __qdf_nbuf_is_arp_local(struct sk_buff *skb);
881*5113495bSYour Name 
882*5113495bSYour Name /**
883*5113495bSYour Name  * __qdf_nbuf_data_is_arp_req() - check if skb data is a arp request
884*5113495bSYour Name  * @data: Pointer to network data buffer
885*5113495bSYour Name  *
886*5113495bSYour Name  * This api is for ipv4 packet.
887*5113495bSYour Name  *
888*5113495bSYour Name  * Return: true if packet is ARP request
889*5113495bSYour Name  *	   false otherwise.
890*5113495bSYour Name  */
891*5113495bSYour Name bool __qdf_nbuf_data_is_arp_req(uint8_t *data);
892*5113495bSYour Name 
893*5113495bSYour Name /**
894*5113495bSYour Name  * __qdf_nbuf_data_is_arp_rsp() - check if skb data is a arp response
895*5113495bSYour Name  * @data: Pointer to network data buffer
896*5113495bSYour Name  *
897*5113495bSYour Name  * This api is for ipv4 packet.
898*5113495bSYour Name  *
899*5113495bSYour Name  * Return: true if packet is ARP response
900*5113495bSYour Name  *	   false otherwise.
901*5113495bSYour Name  */
902*5113495bSYour Name bool __qdf_nbuf_data_is_arp_rsp(uint8_t *data);
903*5113495bSYour Name 
904*5113495bSYour Name /**
905*5113495bSYour Name  * __qdf_nbuf_get_arp_src_ip() - get arp src IP
906*5113495bSYour Name  * @data: Pointer to network data buffer
907*5113495bSYour Name  *
908*5113495bSYour Name  * This api is for ipv4 packet.
909*5113495bSYour Name  *
910*5113495bSYour Name  * Return: ARP packet source IP value.
911*5113495bSYour Name  */
912*5113495bSYour Name uint32_t __qdf_nbuf_get_arp_src_ip(uint8_t *data);
913*5113495bSYour Name 
914*5113495bSYour Name /**
915*5113495bSYour Name  * __qdf_nbuf_get_arp_tgt_ip() - get arp target IP
916*5113495bSYour Name  * @data: Pointer to network data buffer
917*5113495bSYour Name  *
918*5113495bSYour Name  * This api is for ipv4 packet.
919*5113495bSYour Name  *
920*5113495bSYour Name  * Return: ARP packet target IP value.
921*5113495bSYour Name  */
922*5113495bSYour Name uint32_t __qdf_nbuf_get_arp_tgt_ip(uint8_t *data);
923*5113495bSYour Name 
924*5113495bSYour Name /**
925*5113495bSYour Name  * __qdf_nbuf_get_dns_domain_name() - get dns domain name
926*5113495bSYour Name  * @data: Pointer to network data buffer
927*5113495bSYour Name  * @len: length to copy
928*5113495bSYour Name  *
929*5113495bSYour Name  * This api is for dns domain name
930*5113495bSYour Name  *
931*5113495bSYour Name  * Return: dns domain name.
932*5113495bSYour Name  */
933*5113495bSYour Name uint8_t *__qdf_nbuf_get_dns_domain_name(uint8_t *data, uint32_t len);
934*5113495bSYour Name 
935*5113495bSYour Name /**
936*5113495bSYour Name  * __qdf_nbuf_data_is_dns_query() - check if skb data is a dns query
937*5113495bSYour Name  * @data: Pointer to network data buffer
938*5113495bSYour Name  *
939*5113495bSYour Name  * This api is for dns query packet.
940*5113495bSYour Name  *
941*5113495bSYour Name  * Return: true if packet is dns query packet.
942*5113495bSYour Name  *	   false otherwise.
943*5113495bSYour Name  */
944*5113495bSYour Name bool __qdf_nbuf_data_is_dns_query(uint8_t *data);
945*5113495bSYour Name 
946*5113495bSYour Name /**
947*5113495bSYour Name  * __qdf_nbuf_data_is_dns_response() - check if skb data is a dns response
948*5113495bSYour Name  * @data: Pointer to network data buffer
949*5113495bSYour Name  *
950*5113495bSYour Name  * This api is for dns query response.
951*5113495bSYour Name  *
952*5113495bSYour Name  * Return: true if packet is dns response packet.
953*5113495bSYour Name  *	   false otherwise.
954*5113495bSYour Name  */
955*5113495bSYour Name bool __qdf_nbuf_data_is_dns_response(uint8_t *data);
956*5113495bSYour Name 
957*5113495bSYour Name /**
958*5113495bSYour Name  * __qdf_nbuf_data_is_tcp_fin() - check if skb data is a tcp fin
959*5113495bSYour Name  * @data: Pointer to network data buffer
960*5113495bSYour Name  *
961*5113495bSYour Name  * This api is to check if the packet is tcp fin.
962*5113495bSYour Name  *
963*5113495bSYour Name  * Return: true if packet is tcp fin packet.
964*5113495bSYour Name  *         false otherwise.
965*5113495bSYour Name  */
966*5113495bSYour Name bool __qdf_nbuf_data_is_tcp_fin(uint8_t *data);
967*5113495bSYour Name 
968*5113495bSYour Name /**
969*5113495bSYour Name  * __qdf_nbuf_data_is_tcp_fin_ack() - check if skb data is a tcp fin ack
970*5113495bSYour Name  * @data: Pointer to network data buffer
971*5113495bSYour Name  *
972*5113495bSYour Name  * This api is to check if the tcp packet is fin ack.
973*5113495bSYour Name  *
974*5113495bSYour Name  * Return: true if packet is tcp fin ack packet.
975*5113495bSYour Name  *         false otherwise.
976*5113495bSYour Name  */
977*5113495bSYour Name bool __qdf_nbuf_data_is_tcp_fin_ack(uint8_t *data);
978*5113495bSYour Name 
979*5113495bSYour Name /**
980*5113495bSYour Name  * __qdf_nbuf_data_is_tcp_syn() - check if skb data is a tcp syn
981*5113495bSYour Name  * @data: Pointer to network data buffer
982*5113495bSYour Name  *
983*5113495bSYour Name  * This api is for tcp syn packet.
984*5113495bSYour Name  *
985*5113495bSYour Name  * Return: true if packet is tcp syn packet.
986*5113495bSYour Name  *	   false otherwise.
987*5113495bSYour Name  */
988*5113495bSYour Name bool __qdf_nbuf_data_is_tcp_syn(uint8_t *data);
989*5113495bSYour Name 
990*5113495bSYour Name /**
991*5113495bSYour Name  * __qdf_nbuf_data_is_tcp_syn_ack() - check if skb data is a tcp syn ack
992*5113495bSYour Name  * @data: Pointer to network data buffer
993*5113495bSYour Name  *
994*5113495bSYour Name  * This api is for tcp syn ack packet.
995*5113495bSYour Name  *
996*5113495bSYour Name  * Return: true if packet is tcp syn ack packet.
997*5113495bSYour Name  *	   false otherwise.
998*5113495bSYour Name  */
999*5113495bSYour Name bool __qdf_nbuf_data_is_tcp_syn_ack(uint8_t *data);
1000*5113495bSYour Name 
1001*5113495bSYour Name /**
1002*5113495bSYour Name  * __qdf_nbuf_data_is_tcp_rst() - check if skb data is a tcp rst
1003*5113495bSYour Name  * @data: Pointer to network data buffer
1004*5113495bSYour Name  *
1005*5113495bSYour Name  * This api is to check if the tcp packet is rst.
1006*5113495bSYour Name  *
1007*5113495bSYour Name  * Return: true if packet is tcp rst packet.
1008*5113495bSYour Name  *         false otherwise.
1009*5113495bSYour Name  */
1010*5113495bSYour Name bool __qdf_nbuf_data_is_tcp_rst(uint8_t *data);
1011*5113495bSYour Name 
1012*5113495bSYour Name /**
1013*5113495bSYour Name  * __qdf_nbuf_data_is_tcp_ack() - check if skb data is a tcp ack
1014*5113495bSYour Name  * @data: Pointer to network data buffer
1015*5113495bSYour Name  *
1016*5113495bSYour Name  * This api is for tcp ack packet.
1017*5113495bSYour Name  *
1018*5113495bSYour Name  * Return: true if packet is tcp ack packet.
1019*5113495bSYour Name  *	   false otherwise.
1020*5113495bSYour Name  */
1021*5113495bSYour Name bool __qdf_nbuf_data_is_tcp_ack(uint8_t *data);
1022*5113495bSYour Name 
1023*5113495bSYour Name /**
1024*5113495bSYour Name  * __qdf_nbuf_data_get_tcp_src_port() - get tcp src port
1025*5113495bSYour Name  * @data: Pointer to network data buffer
1026*5113495bSYour Name  *
1027*5113495bSYour Name  * This api is for tcp packet.
1028*5113495bSYour Name  *
1029*5113495bSYour Name  * Return: tcp source port value.
1030*5113495bSYour Name  */
1031*5113495bSYour Name uint16_t __qdf_nbuf_data_get_tcp_src_port(uint8_t *data);
1032*5113495bSYour Name 
1033*5113495bSYour Name /**
1034*5113495bSYour Name  * __qdf_nbuf_data_get_tcp_dst_port() - get tcp dst port
1035*5113495bSYour Name  * @data: Pointer to network data buffer
1036*5113495bSYour Name  *
1037*5113495bSYour Name  * This api is for tcp packet.
1038*5113495bSYour Name  *
1039*5113495bSYour Name  * Return: tcp destination port value.
1040*5113495bSYour Name  */
1041*5113495bSYour Name uint16_t __qdf_nbuf_data_get_tcp_dst_port(uint8_t *data);
1042*5113495bSYour Name 
1043*5113495bSYour Name /**
1044*5113495bSYour Name  * __qdf_nbuf_data_is_icmpv4_req() - check if skb data is a icmpv4 request
1045*5113495bSYour Name  * @data: Pointer to network data buffer
1046*5113495bSYour Name  *
1047*5113495bSYour Name  * This api is for ipv4 req packet.
1048*5113495bSYour Name  *
1049*5113495bSYour Name  * Return: true if packet is icmpv4 request
1050*5113495bSYour Name  *	   false otherwise.
1051*5113495bSYour Name  */
1052*5113495bSYour Name bool __qdf_nbuf_data_is_icmpv4_req(uint8_t *data);
1053*5113495bSYour Name 
1054*5113495bSYour Name /**
1055*5113495bSYour Name  * __qdf_nbuf_data_is_icmpv4_redirect() - check if skb data is a icmpv4 redirect
1056*5113495bSYour Name  * @data: Pointer to network data buffer
1057*5113495bSYour Name  *
1058*5113495bSYour Name  * This api is for ipv4 req packet.
1059*5113495bSYour Name  *
1060*5113495bSYour Name  * Return: true if packet is icmpv4 redirect
1061*5113495bSYour Name  *	   false otherwise.
1062*5113495bSYour Name  */
1063*5113495bSYour Name bool __qdf_nbuf_data_is_icmpv4_redirect(uint8_t *data);
1064*5113495bSYour Name 
1065*5113495bSYour Name /**
1066*5113495bSYour Name  * __qdf_nbuf_data_is_icmpv6_redirect() - check if skb data is a icmpv6 redirect
1067*5113495bSYour Name  * @data: Pointer to network data buffer
1068*5113495bSYour Name  *
1069*5113495bSYour Name  * This api is for ipv6 req packet.
1070*5113495bSYour Name  *
1071*5113495bSYour Name  * Return: true if packet is icmpv6 redirect
1072*5113495bSYour Name  *	   false otherwise.
1073*5113495bSYour Name  */
1074*5113495bSYour Name bool __qdf_nbuf_data_is_icmpv6_redirect(uint8_t *data);
1075*5113495bSYour Name 
1076*5113495bSYour Name /**
1077*5113495bSYour Name  * __qdf_nbuf_data_is_icmpv4_rsp() - check if skb data is a icmpv4 res
1078*5113495bSYour Name  * @data: Pointer to network data buffer
1079*5113495bSYour Name  *
1080*5113495bSYour Name  * This api is for ipv4 res packet.
1081*5113495bSYour Name  *
1082*5113495bSYour Name  * Return: true if packet is icmpv4 response
1083*5113495bSYour Name  *	   false otherwise.
1084*5113495bSYour Name  */
1085*5113495bSYour Name bool __qdf_nbuf_data_is_icmpv4_rsp(uint8_t *data);
1086*5113495bSYour Name 
1087*5113495bSYour Name /**
1088*5113495bSYour Name  * __qdf_nbuf_get_icmpv4_src_ip() - get icmpv4 src IP
1089*5113495bSYour Name  * @data: Pointer to network data buffer
1090*5113495bSYour Name  *
1091*5113495bSYour Name  * This api is for ipv4 packet.
1092*5113495bSYour Name  *
1093*5113495bSYour Name  * Return: icmpv4 packet source IP value.
1094*5113495bSYour Name  */
1095*5113495bSYour Name uint32_t __qdf_nbuf_get_icmpv4_src_ip(uint8_t *data);
1096*5113495bSYour Name 
1097*5113495bSYour Name /**
1098*5113495bSYour Name  * __qdf_nbuf_get_icmpv4_tgt_ip() - get icmpv4 target IP
1099*5113495bSYour Name  * @data: Pointer to network data buffer
1100*5113495bSYour Name  *
1101*5113495bSYour Name  * This api is for ipv4 packet.
1102*5113495bSYour Name  *
1103*5113495bSYour Name  * Return: icmpv4 packet target IP value.
1104*5113495bSYour Name  */
1105*5113495bSYour Name uint32_t __qdf_nbuf_get_icmpv4_tgt_ip(uint8_t *data);
1106*5113495bSYour Name 
1107*5113495bSYour Name /**
1108*5113495bSYour Name  * __qdf_nbuf_data_get_dhcp_subtype() - get the subtype
1109*5113495bSYour Name  *              of DHCP packet.
1110*5113495bSYour Name  * @data: Pointer to DHCP packet data buffer
1111*5113495bSYour Name  *
1112*5113495bSYour Name  * This func. returns the subtype of DHCP packet.
1113*5113495bSYour Name  *
1114*5113495bSYour Name  * Return: subtype of the DHCP packet.
1115*5113495bSYour Name  */
1116*5113495bSYour Name enum qdf_proto_subtype  __qdf_nbuf_data_get_dhcp_subtype(uint8_t *data);
1117*5113495bSYour Name 
1118*5113495bSYour Name /**
1119*5113495bSYour Name  * __qdf_nbuf_data_get_eapol_subtype() - get the subtype of EAPOL packet.
1120*5113495bSYour Name  * @data: Pointer to EAPOL packet data buffer
1121*5113495bSYour Name  *
1122*5113495bSYour Name  * This func. returns the subtype of EAPOL packet.
1123*5113495bSYour Name  *
1124*5113495bSYour Name  * Return: subtype of the EAPOL packet.
1125*5113495bSYour Name  */
1126*5113495bSYour Name enum qdf_proto_subtype  __qdf_nbuf_data_get_eapol_subtype(uint8_t *data);
1127*5113495bSYour Name 
1128*5113495bSYour Name /**
1129*5113495bSYour Name  * __qdf_nbuf_data_get_arp_subtype() - get the subtype
1130*5113495bSYour Name  *            of ARP packet.
1131*5113495bSYour Name  * @data: Pointer to ARP packet data buffer
1132*5113495bSYour Name  *
1133*5113495bSYour Name  * This func. returns the subtype of ARP packet.
1134*5113495bSYour Name  *
1135*5113495bSYour Name  * Return: subtype of the ARP packet.
1136*5113495bSYour Name  */
1137*5113495bSYour Name enum qdf_proto_subtype  __qdf_nbuf_data_get_arp_subtype(uint8_t *data);
1138*5113495bSYour Name 
1139*5113495bSYour Name /**
1140*5113495bSYour Name  * __qdf_nbuf_data_get_icmp_subtype() - get the subtype
1141*5113495bSYour Name  *            of IPV4 ICMP packet.
1142*5113495bSYour Name  * @data: Pointer to IPV4 ICMP packet data buffer
1143*5113495bSYour Name  *
1144*5113495bSYour Name  * This func. returns the subtype of ICMP packet.
1145*5113495bSYour Name  *
1146*5113495bSYour Name  * Return: subtype of the ICMP packet.
1147*5113495bSYour Name  */
1148*5113495bSYour Name enum qdf_proto_subtype  __qdf_nbuf_data_get_icmp_subtype(uint8_t *data);
1149*5113495bSYour Name 
1150*5113495bSYour Name /**
1151*5113495bSYour Name  * __qdf_nbuf_data_get_icmpv6_subtype() - get the subtype
1152*5113495bSYour Name  *            of IPV6 ICMPV6 packet.
1153*5113495bSYour Name  * @data: Pointer to IPV6 ICMPV6 packet data buffer
1154*5113495bSYour Name  *
1155*5113495bSYour Name  * This func. returns the subtype of ICMPV6 packet.
1156*5113495bSYour Name  *
1157*5113495bSYour Name  * Return: subtype of the ICMPV6 packet.
1158*5113495bSYour Name  */
1159*5113495bSYour Name enum qdf_proto_subtype  __qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data);
1160*5113495bSYour Name 
1161*5113495bSYour Name /**
1162*5113495bSYour Name  * __qdf_nbuf_data_get_ipv4_proto() - get the proto type
1163*5113495bSYour Name  *            of IPV4 packet.
1164*5113495bSYour Name  * @data: Pointer to IPV4 packet data buffer
1165*5113495bSYour Name  *
1166*5113495bSYour Name  * This func. returns the proto type of IPV4 packet.
1167*5113495bSYour Name  *
1168*5113495bSYour Name  * Return: proto type of IPV4 packet.
1169*5113495bSYour Name  */
1170*5113495bSYour Name uint8_t __qdf_nbuf_data_get_ipv4_proto(uint8_t *data);
1171*5113495bSYour Name 
1172*5113495bSYour Name /**
1173*5113495bSYour Name  * __qdf_nbuf_data_get_ipv6_proto() - get the proto type
1174*5113495bSYour Name  *            of IPV6 packet.
1175*5113495bSYour Name  * @data: Pointer to IPV6 packet data buffer
1176*5113495bSYour Name  *
1177*5113495bSYour Name  * This func. returns the proto type of IPV6 packet.
1178*5113495bSYour Name  *
1179*5113495bSYour Name  * Return: proto type of IPV6 packet.
1180*5113495bSYour Name  */
1181*5113495bSYour Name uint8_t __qdf_nbuf_data_get_ipv6_proto(uint8_t *data);
1182*5113495bSYour Name 
1183*5113495bSYour Name /**
1184*5113495bSYour Name  * __qdf_nbuf_data_get_ipv4_tos() - get the TOS type of IPv4 packet
1185*5113495bSYour Name  * @data: Pointer to skb payload
1186*5113495bSYour Name  *
1187*5113495bSYour Name  * This func. returns the TOS type of IPv4 packet.
1188*5113495bSYour Name  *
1189*5113495bSYour Name  * Return: TOS type of IPv4 packet.
1190*5113495bSYour Name  */
1191*5113495bSYour Name uint8_t __qdf_nbuf_data_get_ipv4_tos(uint8_t *data);
1192*5113495bSYour Name 
1193*5113495bSYour Name /**
1194*5113495bSYour Name  * __qdf_nbuf_data_get_ipv6_tc() - get the TC field
1195*5113495bSYour Name  *                                 of IPv6 packet.
1196*5113495bSYour Name  * @data: Pointer to IPv6 packet data buffer
1197*5113495bSYour Name  *
1198*5113495bSYour Name  * This func. returns the TC field of IPv6 packet.
1199*5113495bSYour Name  *
1200*5113495bSYour Name  * Return: traffic classification of IPv6 packet.
1201*5113495bSYour Name  */
1202*5113495bSYour Name uint8_t __qdf_nbuf_data_get_ipv6_tc(uint8_t *data);
1203*5113495bSYour Name 
1204*5113495bSYour Name /**
1205*5113495bSYour Name  * __qdf_nbuf_data_set_ipv4_tos() - set the TOS for IPv4 packet
1206*5113495bSYour Name  * @data: pointer to skb payload
1207*5113495bSYour Name  * @tos: value of TOS to be set
1208*5113495bSYour Name  *
1209*5113495bSYour Name  * This func. set the TOS field of IPv4 packet.
1210*5113495bSYour Name  *
1211*5113495bSYour Name  * Return: None
1212*5113495bSYour Name  */
1213*5113495bSYour Name void __qdf_nbuf_data_set_ipv4_tos(uint8_t *data, uint8_t tos);
1214*5113495bSYour Name 
1215*5113495bSYour Name /**
1216*5113495bSYour Name  * __qdf_nbuf_data_set_ipv6_tc() - set the TC field
1217*5113495bSYour Name  *                                 of IPv6 packet.
1218*5113495bSYour Name  * @data: Pointer to skb payload
1219*5113495bSYour Name  * @tc: value to set to IPv6 header TC field
1220*5113495bSYour Name  *
1221*5113495bSYour Name  * This func. set the TC field of IPv6 header.
1222*5113495bSYour Name  *
1223*5113495bSYour Name  * Return: None
1224*5113495bSYour Name  */
1225*5113495bSYour Name void __qdf_nbuf_data_set_ipv6_tc(uint8_t *data, uint8_t tc);
1226*5113495bSYour Name 
1227*5113495bSYour Name /**
1228*5113495bSYour Name  * __qdf_nbuf_is_ipv4_last_fragment() - Check if IPv4 packet is last fragment
1229*5113495bSYour Name  * @skb: Buffer
1230*5113495bSYour Name  *
1231*5113495bSYour Name  * This function checks IPv4 packet is last fragment or not.
1232*5113495bSYour Name  * Caller has to call this function for IPv4 packets only.
1233*5113495bSYour Name  *
1234*5113495bSYour Name  * Return: True if IPv4 packet is last fragment otherwise false
1235*5113495bSYour Name  */
1236*5113495bSYour Name bool __qdf_nbuf_is_ipv4_last_fragment(struct sk_buff *skb);
1237*5113495bSYour Name 
1238*5113495bSYour Name /**
1239*5113495bSYour Name  * __qdf_nbuf_is_ipv4_fragment() - Check if IPv4 packet is fragment
1240*5113495bSYour Name  * @skb: Buffer
1241*5113495bSYour Name  *
1242*5113495bSYour Name  * This function checks IPv4 packet is fragment or not.
1243*5113495bSYour Name  * Caller has to call this function for IPv4 packets only.
1244*5113495bSYour Name  *
1245*5113495bSYour Name  * Return: True if IPv4 packet is fragment otherwise false
1246*5113495bSYour Name  */
1247*5113495bSYour Name bool __qdf_nbuf_is_ipv4_fragment(struct sk_buff *skb);
1248*5113495bSYour Name 
1249*5113495bSYour Name bool __qdf_nbuf_is_ipv4_v6_pure_tcp_ack(struct sk_buff *skb);
1250*5113495bSYour Name 
1251*5113495bSYour Name #ifdef QDF_NBUF_GLOBAL_COUNT
1252*5113495bSYour Name /**
1253*5113495bSYour Name  * __qdf_nbuf_count_get() - get nbuf global count
1254*5113495bSYour Name  *
1255*5113495bSYour Name  * Return: nbuf global count
1256*5113495bSYour Name  */
1257*5113495bSYour Name int __qdf_nbuf_count_get(void);
1258*5113495bSYour Name 
1259*5113495bSYour Name /**
1260*5113495bSYour Name  * __qdf_nbuf_count_inc() - increment nbuf global count
1261*5113495bSYour Name  *
1262*5113495bSYour Name  * @nbuf: sk buff
1263*5113495bSYour Name  *
1264*5113495bSYour Name  * Return: void
1265*5113495bSYour Name  */
1266*5113495bSYour Name void __qdf_nbuf_count_inc(struct sk_buff *nbuf);
1267*5113495bSYour Name 
1268*5113495bSYour Name /**
1269*5113495bSYour Name  * __qdf_nbuf_count_dec() - decrement nbuf global count
1270*5113495bSYour Name  *
1271*5113495bSYour Name  * @nbuf: sk buff
1272*5113495bSYour Name  *
1273*5113495bSYour Name  * Return: void
1274*5113495bSYour Name  */
1275*5113495bSYour Name void __qdf_nbuf_count_dec(struct sk_buff *nbuf);
1276*5113495bSYour Name 
1277*5113495bSYour Name /**
1278*5113495bSYour Name  * __qdf_nbuf_mod_init() - Initialization routine for qdf_nbuf
1279*5113495bSYour Name  *
1280*5113495bSYour Name  * Return void
1281*5113495bSYour Name  */
1282*5113495bSYour Name void __qdf_nbuf_mod_init(void);
1283*5113495bSYour Name 
1284*5113495bSYour Name /**
1285*5113495bSYour Name  * __qdf_nbuf_mod_exit() - Unintialization routine for qdf_nbuf
1286*5113495bSYour Name  *
1287*5113495bSYour Name  * Return void
1288*5113495bSYour Name  */
1289*5113495bSYour Name void __qdf_nbuf_mod_exit(void);
1290*5113495bSYour Name 
1291*5113495bSYour Name #else
1292*5113495bSYour Name 
__qdf_nbuf_count_get(void)1293*5113495bSYour Name static inline int __qdf_nbuf_count_get(void)
1294*5113495bSYour Name {
1295*5113495bSYour Name 	return 0;
1296*5113495bSYour Name }
1297*5113495bSYour Name 
__qdf_nbuf_count_inc(struct sk_buff * skb)1298*5113495bSYour Name static inline void __qdf_nbuf_count_inc(struct sk_buff *skb)
1299*5113495bSYour Name {
1300*5113495bSYour Name 	return;
1301*5113495bSYour Name }
1302*5113495bSYour Name 
__qdf_nbuf_count_dec(struct sk_buff * skb)1303*5113495bSYour Name static inline void __qdf_nbuf_count_dec(struct sk_buff *skb)
1304*5113495bSYour Name {
1305*5113495bSYour Name 	return;
1306*5113495bSYour Name }
1307*5113495bSYour Name 
__qdf_nbuf_mod_init(void)1308*5113495bSYour Name static inline void __qdf_nbuf_mod_init(void)
1309*5113495bSYour Name {
1310*5113495bSYour Name 	return;
1311*5113495bSYour Name }
1312*5113495bSYour Name 
__qdf_nbuf_mod_exit(void)1313*5113495bSYour Name static inline void __qdf_nbuf_mod_exit(void)
1314*5113495bSYour Name {
1315*5113495bSYour Name 	return;
1316*5113495bSYour Name }
1317*5113495bSYour Name #endif
1318*5113495bSYour Name 
1319*5113495bSYour Name /**
1320*5113495bSYour Name  * __qdf_to_status() - OS to QDF status conversion
1321*5113495bSYour Name  * @error : OS error
1322*5113495bSYour Name  *
1323*5113495bSYour Name  * Return: QDF status
1324*5113495bSYour Name  */
__qdf_to_status(signed int error)1325*5113495bSYour Name static inline QDF_STATUS __qdf_to_status(signed int error)
1326*5113495bSYour Name {
1327*5113495bSYour Name 	switch (error) {
1328*5113495bSYour Name 	case 0:
1329*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
1330*5113495bSYour Name 	case ENOMEM:
1331*5113495bSYour Name 	case -ENOMEM:
1332*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
1333*5113495bSYour Name 	default:
1334*5113495bSYour Name 		return QDF_STATUS_E_NOSUPPORT;
1335*5113495bSYour Name 	}
1336*5113495bSYour Name }
1337*5113495bSYour Name 
1338*5113495bSYour Name /**
1339*5113495bSYour Name  * __qdf_nbuf_cat() - link two nbufs
1340*5113495bSYour Name  * @dst: Buffer to piggyback into
1341*5113495bSYour Name  * @src: Buffer to put
1342*5113495bSYour Name  *
1343*5113495bSYour Name  * Concat two nbufs, the new buf(src) is piggybacked into the older one.
1344*5113495bSYour Name  * It is callers responsibility to free the src skb.
1345*5113495bSYour Name  *
1346*5113495bSYour Name  * Return: QDF_STATUS (status of the call) if failed the src skb
1347*5113495bSYour Name  *         is released
1348*5113495bSYour Name  */
1349*5113495bSYour Name static inline QDF_STATUS
__qdf_nbuf_cat(struct sk_buff * dst,struct sk_buff * src)1350*5113495bSYour Name __qdf_nbuf_cat(struct sk_buff *dst, struct sk_buff *src)
1351*5113495bSYour Name {
1352*5113495bSYour Name 	QDF_STATUS error = 0;
1353*5113495bSYour Name 
1354*5113495bSYour Name 	qdf_assert(dst && src);
1355*5113495bSYour Name 
1356*5113495bSYour Name 	/*
1357*5113495bSYour Name 	 * Since pskb_expand_head unconditionally reallocates the skb->head
1358*5113495bSYour Name 	 * buffer, first check whether the current buffer is already large
1359*5113495bSYour Name 	 * enough.
1360*5113495bSYour Name 	 */
1361*5113495bSYour Name 	if (skb_tailroom(dst) < src->len) {
1362*5113495bSYour Name 		error = pskb_expand_head(dst, 0, src->len, GFP_ATOMIC);
1363*5113495bSYour Name 		if (error)
1364*5113495bSYour Name 			return __qdf_to_status(error);
1365*5113495bSYour Name 	}
1366*5113495bSYour Name 
1367*5113495bSYour Name 	memcpy(skb_tail_pointer(dst), src->data, src->len);
1368*5113495bSYour Name 	skb_put(dst, src->len);
1369*5113495bSYour Name 	return __qdf_to_status(error);
1370*5113495bSYour Name }
1371*5113495bSYour Name 
1372*5113495bSYour Name /*
1373*5113495bSYour Name  * nbuf manipulation routines
1374*5113495bSYour Name  */
1375*5113495bSYour Name /**
1376*5113495bSYour Name  * __qdf_nbuf_headroom() - return the amount of tail space available
1377*5113495bSYour Name  * @skb: Pointer to network buffer
1378*5113495bSYour Name  *
1379*5113495bSYour Name  * Return: amount of tail room
1380*5113495bSYour Name  */
__qdf_nbuf_headroom(struct sk_buff * skb)1381*5113495bSYour Name static inline int __qdf_nbuf_headroom(struct sk_buff *skb)
1382*5113495bSYour Name {
1383*5113495bSYour Name 	return skb_headroom(skb);
1384*5113495bSYour Name }
1385*5113495bSYour Name 
1386*5113495bSYour Name /**
1387*5113495bSYour Name  * __qdf_nbuf_tailroom() - return the amount of tail space available
1388*5113495bSYour Name  * @skb: Pointer to network buffer
1389*5113495bSYour Name  *
1390*5113495bSYour Name  * Return: amount of tail room
1391*5113495bSYour Name  */
__qdf_nbuf_tailroom(struct sk_buff * skb)1392*5113495bSYour Name static inline uint32_t __qdf_nbuf_tailroom(struct sk_buff *skb)
1393*5113495bSYour Name {
1394*5113495bSYour Name 	return skb_tailroom(skb);
1395*5113495bSYour Name }
1396*5113495bSYour Name 
1397*5113495bSYour Name /**
1398*5113495bSYour Name  * __qdf_nbuf_put_tail() - Puts data in the end
1399*5113495bSYour Name  * @skb: Pointer to network buffer
1400*5113495bSYour Name  * @size: size to be pushed
1401*5113495bSYour Name  *
1402*5113495bSYour Name  * Return: data pointer of this buf where new data has to be
1403*5113495bSYour Name  *         put, or NULL if there is not enough room in this buf.
1404*5113495bSYour Name  */
__qdf_nbuf_put_tail(struct sk_buff * skb,size_t size)1405*5113495bSYour Name static inline uint8_t *__qdf_nbuf_put_tail(struct sk_buff *skb, size_t size)
1406*5113495bSYour Name {
1407*5113495bSYour Name 	if (skb_tailroom(skb) < size) {
1408*5113495bSYour Name 		if (unlikely(pskb_expand_head(skb, 0,
1409*5113495bSYour Name 			size - skb_tailroom(skb), GFP_ATOMIC))) {
1410*5113495bSYour Name 			__qdf_nbuf_count_dec(skb);
1411*5113495bSYour Name 			dev_kfree_skb_any(skb);
1412*5113495bSYour Name 			return NULL;
1413*5113495bSYour Name 		}
1414*5113495bSYour Name 	}
1415*5113495bSYour Name 	return skb_put(skb, size);
1416*5113495bSYour Name }
1417*5113495bSYour Name 
1418*5113495bSYour Name /**
1419*5113495bSYour Name  * __qdf_nbuf_trim_tail() - trim data out from the end
1420*5113495bSYour Name  * @skb: Pointer to network buffer
1421*5113495bSYour Name  * @size: size to be popped
1422*5113495bSYour Name  *
1423*5113495bSYour Name  * Return: none
1424*5113495bSYour Name  */
__qdf_nbuf_trim_tail(struct sk_buff * skb,size_t size)1425*5113495bSYour Name static inline void __qdf_nbuf_trim_tail(struct sk_buff *skb, size_t size)
1426*5113495bSYour Name {
1427*5113495bSYour Name 	return skb_trim(skb, skb->len - size);
1428*5113495bSYour Name }
1429*5113495bSYour Name 
1430*5113495bSYour Name 
1431*5113495bSYour Name /*
1432*5113495bSYour Name  * prototypes. Implemented in qdf_nbuf.c
1433*5113495bSYour Name  */
1434*5113495bSYour Name 
1435*5113495bSYour Name /**
1436*5113495bSYour Name  * __qdf_nbuf_get_tx_cksum() - get tx checksum
1437*5113495bSYour Name  * @skb: Pointer to network buffer
1438*5113495bSYour Name  *
1439*5113495bSYour Name  * Return: TX checksum value
1440*5113495bSYour Name  */
1441*5113495bSYour Name qdf_nbuf_tx_cksum_t __qdf_nbuf_get_tx_cksum(struct sk_buff *skb);
1442*5113495bSYour Name 
1443*5113495bSYour Name /**
1444*5113495bSYour Name  * __qdf_nbuf_set_rx_cksum() - set rx checksum
1445*5113495bSYour Name  * @skb: Pointer to network buffer
1446*5113495bSYour Name  * @cksum: Pointer to checksum value
1447*5113495bSYour Name  *
1448*5113495bSYour Name  * Return: QDF_STATUS
1449*5113495bSYour Name  */
1450*5113495bSYour Name QDF_STATUS __qdf_nbuf_set_rx_cksum(struct sk_buff *skb,
1451*5113495bSYour Name 				   qdf_nbuf_rx_cksum_t *cksum);
1452*5113495bSYour Name 
1453*5113495bSYour Name /**
1454*5113495bSYour Name  * __qdf_nbuf_get_tid() - get tid
1455*5113495bSYour Name  * @skb: Pointer to network buffer
1456*5113495bSYour Name  *
1457*5113495bSYour Name  * Return: tid
1458*5113495bSYour Name  */
1459*5113495bSYour Name uint8_t __qdf_nbuf_get_tid(struct sk_buff *skb);
1460*5113495bSYour Name 
1461*5113495bSYour Name /**
1462*5113495bSYour Name  * __qdf_nbuf_set_tid() - set tid
1463*5113495bSYour Name  * @skb: Pointer to network buffer
1464*5113495bSYour Name  * @tid: TID value to set
1465*5113495bSYour Name  *
1466*5113495bSYour Name  * Return: none
1467*5113495bSYour Name  */
1468*5113495bSYour Name void __qdf_nbuf_set_tid(struct sk_buff *skb, uint8_t tid);
1469*5113495bSYour Name 
1470*5113495bSYour Name /**
1471*5113495bSYour Name  * __qdf_nbuf_get_exemption_type() - get exemption type
1472*5113495bSYour Name  * @skb: Pointer to network buffer
1473*5113495bSYour Name  *
1474*5113495bSYour Name  * Return: exemption type
1475*5113495bSYour Name  */
1476*5113495bSYour Name uint8_t __qdf_nbuf_get_exemption_type(struct sk_buff *skb);
1477*5113495bSYour Name 
1478*5113495bSYour Name /**
1479*5113495bSYour Name  * __qdf_nbuf_ref() - Reference the nbuf so it can get held until the last free.
1480*5113495bSYour Name  * @skb: sk_buff handle
1481*5113495bSYour Name  *
1482*5113495bSYour Name  * Return: none
1483*5113495bSYour Name  */
1484*5113495bSYour Name 
1485*5113495bSYour Name void __qdf_nbuf_ref(struct sk_buff *skb);
1486*5113495bSYour Name 
1487*5113495bSYour Name /**
1488*5113495bSYour Name  * __qdf_nbuf_shared() - Check whether the buffer is shared
1489*5113495bSYour Name  *  @skb: sk_buff buffer
1490*5113495bSYour Name  *
1491*5113495bSYour Name  *  Return: true if more than one person has a reference to this buffer.
1492*5113495bSYour Name  */
1493*5113495bSYour Name int __qdf_nbuf_shared(struct sk_buff *skb);
1494*5113495bSYour Name 
1495*5113495bSYour Name /**
1496*5113495bSYour Name  * __qdf_nbuf_get_nr_frags() - return the number of fragments in an skb,
1497*5113495bSYour Name  * @skb: sk buff
1498*5113495bSYour Name  *
1499*5113495bSYour Name  * Return: number of fragments
1500*5113495bSYour Name  */
__qdf_nbuf_get_nr_frags(struct sk_buff * skb)1501*5113495bSYour Name static inline size_t __qdf_nbuf_get_nr_frags(struct sk_buff *skb)
1502*5113495bSYour Name {
1503*5113495bSYour Name 	return skb_shinfo(skb)->nr_frags;
1504*5113495bSYour Name }
1505*5113495bSYour Name 
1506*5113495bSYour Name /**
1507*5113495bSYour Name  * __qdf_nbuf_get_nr_frags_in_fraglist() - return the number of fragments
1508*5113495bSYour Name  * @skb: sk buff
1509*5113495bSYour Name  *
1510*5113495bSYour Name  * This API returns a total number of fragments from the fraglist
1511*5113495bSYour Name  * Return: total number of fragments
1512*5113495bSYour Name  */
__qdf_nbuf_get_nr_frags_in_fraglist(struct sk_buff * skb)1513*5113495bSYour Name static inline uint32_t __qdf_nbuf_get_nr_frags_in_fraglist(struct sk_buff *skb)
1514*5113495bSYour Name {
1515*5113495bSYour Name 	uint32_t num_frag = 0;
1516*5113495bSYour Name 	struct sk_buff *list = NULL;
1517*5113495bSYour Name 
1518*5113495bSYour Name 	num_frag = skb_shinfo(skb)->nr_frags;
1519*5113495bSYour Name 	skb_walk_frags(skb, list)
1520*5113495bSYour Name 		num_frag += skb_shinfo(list)->nr_frags;
1521*5113495bSYour Name 
1522*5113495bSYour Name 	return num_frag;
1523*5113495bSYour Name }
1524*5113495bSYour Name 
1525*5113495bSYour Name /*
1526*5113495bSYour Name  * qdf_nbuf_pool_delete() implementation - do nothing in linux
1527*5113495bSYour Name  */
1528*5113495bSYour Name #define __qdf_nbuf_pool_delete(osdev)
1529*5113495bSYour Name 
1530*5113495bSYour Name /**
1531*5113495bSYour Name  * __qdf_nbuf_copy() - returns a private copy of the skb
1532*5113495bSYour Name  * @skb: Pointer to network buffer
1533*5113495bSYour Name  *
1534*5113495bSYour Name  * This API returns a private copy of the skb, the skb returned is completely
1535*5113495bSYour Name  *  modifiable by callers
1536*5113495bSYour Name  *
1537*5113495bSYour Name  * Return: skb or NULL
1538*5113495bSYour Name  */
__qdf_nbuf_copy(struct sk_buff * skb)1539*5113495bSYour Name static inline struct sk_buff *__qdf_nbuf_copy(struct sk_buff *skb)
1540*5113495bSYour Name {
1541*5113495bSYour Name 	struct sk_buff *skb_new = NULL;
1542*5113495bSYour Name 
1543*5113495bSYour Name 	skb_new = skb_copy(skb, GFP_ATOMIC);
1544*5113495bSYour Name 	if (skb_new) {
1545*5113495bSYour Name 		__qdf_nbuf_count_inc(skb_new);
1546*5113495bSYour Name 	}
1547*5113495bSYour Name 	return skb_new;
1548*5113495bSYour Name }
1549*5113495bSYour Name 
1550*5113495bSYour Name #define __qdf_nbuf_reserve      skb_reserve
1551*5113495bSYour Name 
1552*5113495bSYour Name /**
1553*5113495bSYour Name  * __qdf_nbuf_set_data_pointer() - set buffer data pointer
1554*5113495bSYour Name  * @skb: Pointer to network buffer
1555*5113495bSYour Name  * @data: data pointer
1556*5113495bSYour Name  *
1557*5113495bSYour Name  * Return: none
1558*5113495bSYour Name  */
1559*5113495bSYour Name static inline void
__qdf_nbuf_set_data_pointer(struct sk_buff * skb,uint8_t * data)1560*5113495bSYour Name __qdf_nbuf_set_data_pointer(struct sk_buff *skb, uint8_t *data)
1561*5113495bSYour Name {
1562*5113495bSYour Name 	skb->data = data;
1563*5113495bSYour Name }
1564*5113495bSYour Name 
1565*5113495bSYour Name /**
1566*5113495bSYour Name  * __qdf_nbuf_set_len() - set buffer data length
1567*5113495bSYour Name  * @skb: Pointer to network buffer
1568*5113495bSYour Name  * @len: data length
1569*5113495bSYour Name  *
1570*5113495bSYour Name  * Return: none
1571*5113495bSYour Name  */
1572*5113495bSYour Name static inline void
__qdf_nbuf_set_len(struct sk_buff * skb,uint32_t len)1573*5113495bSYour Name __qdf_nbuf_set_len(struct sk_buff *skb, uint32_t len)
1574*5113495bSYour Name {
1575*5113495bSYour Name 	skb->len = len;
1576*5113495bSYour Name }
1577*5113495bSYour Name 
1578*5113495bSYour Name /**
1579*5113495bSYour Name  * __qdf_nbuf_set_tail_pointer() - set buffer data tail pointer
1580*5113495bSYour Name  * @skb: Pointer to network buffer
1581*5113495bSYour Name  * @len: skb data length
1582*5113495bSYour Name  *
1583*5113495bSYour Name  * Return: none
1584*5113495bSYour Name  */
1585*5113495bSYour Name static inline void
__qdf_nbuf_set_tail_pointer(struct sk_buff * skb,int len)1586*5113495bSYour Name __qdf_nbuf_set_tail_pointer(struct sk_buff *skb, int len)
1587*5113495bSYour Name {
1588*5113495bSYour Name 	skb_set_tail_pointer(skb, len);
1589*5113495bSYour Name }
1590*5113495bSYour Name 
1591*5113495bSYour Name /**
1592*5113495bSYour Name  * __qdf_nbuf_unlink_no_lock() - unlink an skb from skb queue
1593*5113495bSYour Name  * @skb: Pointer to network buffer
1594*5113495bSYour Name  * @list: list to use
1595*5113495bSYour Name  *
1596*5113495bSYour Name  * This is a lockless version, driver must acquire locks if it
1597*5113495bSYour Name  * needs to synchronize
1598*5113495bSYour Name  *
1599*5113495bSYour Name  * Return: none
1600*5113495bSYour Name  */
1601*5113495bSYour Name static inline void
__qdf_nbuf_unlink_no_lock(struct sk_buff * skb,struct sk_buff_head * list)1602*5113495bSYour Name __qdf_nbuf_unlink_no_lock(struct sk_buff *skb, struct sk_buff_head *list)
1603*5113495bSYour Name {
1604*5113495bSYour Name 	__skb_unlink(skb, list);
1605*5113495bSYour Name }
1606*5113495bSYour Name 
1607*5113495bSYour Name #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0))
1608*5113495bSYour Name /**
1609*5113495bSYour Name  * __qdf_nbuf_is_dev_scratch_supported() - dev_scratch support for network
1610*5113495bSYour Name  *                                         buffer in kernel
1611*5113495bSYour Name  *
1612*5113495bSYour Name  * Return: true if dev_scratch is supported
1613*5113495bSYour Name  *         false if dev_scratch is not supported
1614*5113495bSYour Name  */
__qdf_nbuf_is_dev_scratch_supported(void)1615*5113495bSYour Name static inline bool __qdf_nbuf_is_dev_scratch_supported(void)
1616*5113495bSYour Name {
1617*5113495bSYour Name 	return true;
1618*5113495bSYour Name }
1619*5113495bSYour Name 
1620*5113495bSYour Name /**
1621*5113495bSYour Name  * __qdf_nbuf_get_dev_scratch() - get dev_scratch of network buffer
1622*5113495bSYour Name  * @skb: Pointer to network buffer
1623*5113495bSYour Name  *
1624*5113495bSYour Name  * Return: dev_scratch if dev_scratch supported
1625*5113495bSYour Name  *         0 if dev_scratch not supported
1626*5113495bSYour Name  */
__qdf_nbuf_get_dev_scratch(struct sk_buff * skb)1627*5113495bSYour Name static inline unsigned long __qdf_nbuf_get_dev_scratch(struct sk_buff *skb)
1628*5113495bSYour Name {
1629*5113495bSYour Name 	return skb->dev_scratch;
1630*5113495bSYour Name }
1631*5113495bSYour Name 
1632*5113495bSYour Name /**
1633*5113495bSYour Name  * __qdf_nbuf_set_dev_scratch() - set dev_scratch of network buffer
1634*5113495bSYour Name  * @skb: Pointer to network buffer
1635*5113495bSYour Name  * @value: value to be set in dev_scratch of network buffer
1636*5113495bSYour Name  *
1637*5113495bSYour Name  * Return: void
1638*5113495bSYour Name  */
1639*5113495bSYour Name static inline void
__qdf_nbuf_set_dev_scratch(struct sk_buff * skb,unsigned long value)1640*5113495bSYour Name __qdf_nbuf_set_dev_scratch(struct sk_buff *skb, unsigned long value)
1641*5113495bSYour Name {
1642*5113495bSYour Name 	skb->dev_scratch = value;
1643*5113495bSYour Name }
1644*5113495bSYour Name #else
__qdf_nbuf_is_dev_scratch_supported(void)1645*5113495bSYour Name static inline bool __qdf_nbuf_is_dev_scratch_supported(void)
1646*5113495bSYour Name {
1647*5113495bSYour Name 	return false;
1648*5113495bSYour Name }
1649*5113495bSYour Name 
__qdf_nbuf_get_dev_scratch(struct sk_buff * skb)1650*5113495bSYour Name static inline unsigned long __qdf_nbuf_get_dev_scratch(struct sk_buff *skb)
1651*5113495bSYour Name {
1652*5113495bSYour Name 	return 0;
1653*5113495bSYour Name }
1654*5113495bSYour Name 
1655*5113495bSYour Name static inline void
__qdf_nbuf_set_dev_scratch(struct sk_buff * skb,unsigned long value)1656*5113495bSYour Name __qdf_nbuf_set_dev_scratch(struct sk_buff *skb, unsigned long value)
1657*5113495bSYour Name {
1658*5113495bSYour Name }
1659*5113495bSYour Name #endif /* KERNEL_VERSION(4, 14, 0) */
1660*5113495bSYour Name 
1661*5113495bSYour Name /**
1662*5113495bSYour Name  * __qdf_nbuf_head() - return the pointer the skb's head pointer
1663*5113495bSYour Name  * @skb: Pointer to network buffer
1664*5113495bSYour Name  *
1665*5113495bSYour Name  * Return: Pointer to head buffer
1666*5113495bSYour Name  */
__qdf_nbuf_head(struct sk_buff * skb)1667*5113495bSYour Name static inline uint8_t *__qdf_nbuf_head(struct sk_buff *skb)
1668*5113495bSYour Name {
1669*5113495bSYour Name 	return skb->head;
1670*5113495bSYour Name }
1671*5113495bSYour Name 
1672*5113495bSYour Name /**
1673*5113495bSYour Name  * __qdf_nbuf_data() - return the pointer to data header in the skb
1674*5113495bSYour Name  * @skb: Pointer to network buffer
1675*5113495bSYour Name  *
1676*5113495bSYour Name  * Return: Pointer to skb data
1677*5113495bSYour Name  */
__qdf_nbuf_data(struct sk_buff * skb)1678*5113495bSYour Name static inline uint8_t *__qdf_nbuf_data(struct sk_buff *skb)
1679*5113495bSYour Name {
1680*5113495bSYour Name 	return skb->data;
1681*5113495bSYour Name }
1682*5113495bSYour Name 
__qdf_nbuf_data_addr(struct sk_buff * skb)1683*5113495bSYour Name static inline uint8_t *__qdf_nbuf_data_addr(struct sk_buff *skb)
1684*5113495bSYour Name {
1685*5113495bSYour Name 	return (uint8_t *)&skb->data;
1686*5113495bSYour Name }
1687*5113495bSYour Name 
1688*5113495bSYour Name /**
1689*5113495bSYour Name  * __qdf_nbuf_get_protocol() - return the protocol value of the skb
1690*5113495bSYour Name  * @skb: Pointer to network buffer
1691*5113495bSYour Name  *
1692*5113495bSYour Name  * Return: skb protocol
1693*5113495bSYour Name  */
__qdf_nbuf_get_protocol(struct sk_buff * skb)1694*5113495bSYour Name static inline uint16_t __qdf_nbuf_get_protocol(struct sk_buff *skb)
1695*5113495bSYour Name {
1696*5113495bSYour Name 	return skb->protocol;
1697*5113495bSYour Name }
1698*5113495bSYour Name 
1699*5113495bSYour Name /**
1700*5113495bSYour Name  * __qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
1701*5113495bSYour Name  * @skb: Pointer to network buffer
1702*5113495bSYour Name  *
1703*5113495bSYour Name  * Return: skb ip_summed
1704*5113495bSYour Name  */
__qdf_nbuf_get_ip_summed(struct sk_buff * skb)1705*5113495bSYour Name static inline uint8_t __qdf_nbuf_get_ip_summed(struct sk_buff *skb)
1706*5113495bSYour Name {
1707*5113495bSYour Name 	return skb->ip_summed;
1708*5113495bSYour Name }
1709*5113495bSYour Name 
1710*5113495bSYour Name /**
1711*5113495bSYour Name  * __qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
1712*5113495bSYour Name  * @skb: Pointer to network buffer
1713*5113495bSYour Name  * @ip_summed: ip checksum
1714*5113495bSYour Name  *
1715*5113495bSYour Name  * Return: none
1716*5113495bSYour Name  */
__qdf_nbuf_set_ip_summed(struct sk_buff * skb,uint8_t ip_summed)1717*5113495bSYour Name static inline void __qdf_nbuf_set_ip_summed(struct sk_buff *skb,
1718*5113495bSYour Name 		 uint8_t ip_summed)
1719*5113495bSYour Name {
1720*5113495bSYour Name 	skb->ip_summed = ip_summed;
1721*5113495bSYour Name }
1722*5113495bSYour Name 
1723*5113495bSYour Name /**
1724*5113495bSYour Name  * __qdf_nbuf_get_priority() - return the priority value of the skb
1725*5113495bSYour Name  * @skb: Pointer to network buffer
1726*5113495bSYour Name  *
1727*5113495bSYour Name  * Return: skb priority
1728*5113495bSYour Name  */
__qdf_nbuf_get_priority(struct sk_buff * skb)1729*5113495bSYour Name static inline uint32_t __qdf_nbuf_get_priority(struct sk_buff *skb)
1730*5113495bSYour Name {
1731*5113495bSYour Name 	return skb->priority;
1732*5113495bSYour Name }
1733*5113495bSYour Name 
1734*5113495bSYour Name /**
1735*5113495bSYour Name  * __qdf_nbuf_set_priority() - sets the priority value of the skb
1736*5113495bSYour Name  * @skb: Pointer to network buffer
1737*5113495bSYour Name  * @p: priority
1738*5113495bSYour Name  *
1739*5113495bSYour Name  * Return: none
1740*5113495bSYour Name  */
__qdf_nbuf_set_priority(struct sk_buff * skb,uint32_t p)1741*5113495bSYour Name static inline void __qdf_nbuf_set_priority(struct sk_buff *skb, uint32_t p)
1742*5113495bSYour Name {
1743*5113495bSYour Name 	skb->priority = p;
1744*5113495bSYour Name }
1745*5113495bSYour Name 
1746*5113495bSYour Name /**
1747*5113495bSYour Name  * __qdf_nbuf_set_next() - sets the next skb pointer of the current skb
1748*5113495bSYour Name  * @skb: Current skb
1749*5113495bSYour Name  * @skb_next: Next skb
1750*5113495bSYour Name  *
1751*5113495bSYour Name  * Return: void
1752*5113495bSYour Name  */
1753*5113495bSYour Name static inline void
__qdf_nbuf_set_next(struct sk_buff * skb,struct sk_buff * skb_next)1754*5113495bSYour Name __qdf_nbuf_set_next(struct sk_buff *skb, struct sk_buff *skb_next)
1755*5113495bSYour Name {
1756*5113495bSYour Name 	skb->next = skb_next;
1757*5113495bSYour Name }
1758*5113495bSYour Name 
1759*5113495bSYour Name /**
1760*5113495bSYour Name  * __qdf_nbuf_next() - return the next skb pointer of the current skb
1761*5113495bSYour Name  * @skb: Current skb
1762*5113495bSYour Name  *
1763*5113495bSYour Name  * Return: the next skb pointed to by the current skb
1764*5113495bSYour Name  */
__qdf_nbuf_next(struct sk_buff * skb)1765*5113495bSYour Name static inline struct sk_buff *__qdf_nbuf_next(struct sk_buff *skb)
1766*5113495bSYour Name {
1767*5113495bSYour Name 	return skb->next;
1768*5113495bSYour Name }
1769*5113495bSYour Name 
1770*5113495bSYour Name /**
1771*5113495bSYour Name  * __qdf_nbuf_set_next_ext() - sets the next skb pointer of the current skb
1772*5113495bSYour Name  * @skb: Current skb
1773*5113495bSYour Name  * @skb_next: Next skb
1774*5113495bSYour Name  *
1775*5113495bSYour Name  * This fn is used to link up extensions to the head skb. Does not handle
1776*5113495bSYour Name  * linking to the head
1777*5113495bSYour Name  *
1778*5113495bSYour Name  * Return: none
1779*5113495bSYour Name  */
1780*5113495bSYour Name static inline void
__qdf_nbuf_set_next_ext(struct sk_buff * skb,struct sk_buff * skb_next)1781*5113495bSYour Name __qdf_nbuf_set_next_ext(struct sk_buff *skb, struct sk_buff *skb_next)
1782*5113495bSYour Name {
1783*5113495bSYour Name 	skb->next = skb_next;
1784*5113495bSYour Name }
1785*5113495bSYour Name 
1786*5113495bSYour Name /**
1787*5113495bSYour Name  * __qdf_nbuf_next_ext() - return the next skb pointer of the current skb
1788*5113495bSYour Name  * @skb: Current skb
1789*5113495bSYour Name  *
1790*5113495bSYour Name  * Return: the next skb pointed to by the current skb
1791*5113495bSYour Name  */
__qdf_nbuf_next_ext(struct sk_buff * skb)1792*5113495bSYour Name static inline struct sk_buff *__qdf_nbuf_next_ext(struct sk_buff *skb)
1793*5113495bSYour Name {
1794*5113495bSYour Name 	return skb->next;
1795*5113495bSYour Name }
1796*5113495bSYour Name 
1797*5113495bSYour Name /**
1798*5113495bSYour Name  * __qdf_nbuf_append_ext_list() - link list of packet extensions to the head
1799*5113495bSYour Name  * @skb_head: head_buf nbuf holding head segment (single)
1800*5113495bSYour Name  * @ext_list: nbuf list holding linked extensions to the head
1801*5113495bSYour Name  * @ext_len: Total length of all buffers in the extension list
1802*5113495bSYour Name  *
1803*5113495bSYour Name  * This function is used to link up a list of packet extensions (seg1, 2,*  ...)
1804*5113495bSYour Name  * to the nbuf holding the head segment (seg0)
1805*5113495bSYour Name  *
1806*5113495bSYour Name  * Return: none
1807*5113495bSYour Name  */
1808*5113495bSYour Name static inline void
__qdf_nbuf_append_ext_list(struct sk_buff * skb_head,struct sk_buff * ext_list,size_t ext_len)1809*5113495bSYour Name __qdf_nbuf_append_ext_list(struct sk_buff *skb_head,
1810*5113495bSYour Name 			struct sk_buff *ext_list, size_t ext_len)
1811*5113495bSYour Name {
1812*5113495bSYour Name 	skb_shinfo(skb_head)->frag_list = ext_list;
1813*5113495bSYour Name 	skb_head->data_len += ext_len;
1814*5113495bSYour Name 	skb_head->len += ext_len;
1815*5113495bSYour Name }
1816*5113495bSYour Name 
1817*5113495bSYour Name /**
1818*5113495bSYour Name  * __qdf_nbuf_get_shinfo() - return the shared info of the skb
1819*5113495bSYour Name  * @head_buf: Pointer to network buffer
1820*5113495bSYour Name  *
1821*5113495bSYour Name  * Return: skb shared info from head buf
1822*5113495bSYour Name  */
1823*5113495bSYour Name static inline
__qdf_nbuf_get_shinfo(struct sk_buff * head_buf)1824*5113495bSYour Name struct skb_shared_info *__qdf_nbuf_get_shinfo(struct sk_buff *head_buf)
1825*5113495bSYour Name {
1826*5113495bSYour Name 	return skb_shinfo(head_buf);
1827*5113495bSYour Name }
1828*5113495bSYour Name 
1829*5113495bSYour Name /**
1830*5113495bSYour Name  * __qdf_nbuf_get_ext_list() - Get the link to extended nbuf list.
1831*5113495bSYour Name  * @head_buf: Network buf holding head segment (single)
1832*5113495bSYour Name  *
1833*5113495bSYour Name  * This ext_list is populated when we have Jumbo packet, for example in case of
1834*5113495bSYour Name  * monitor mode amsdu packet reception, and are stiched using frags_list.
1835*5113495bSYour Name  *
1836*5113495bSYour Name  * Return: Network buf list holding linked extensions from head buf.
1837*5113495bSYour Name  */
__qdf_nbuf_get_ext_list(struct sk_buff * head_buf)1838*5113495bSYour Name static inline struct sk_buff *__qdf_nbuf_get_ext_list(struct sk_buff *head_buf)
1839*5113495bSYour Name {
1840*5113495bSYour Name 	return (skb_shinfo(head_buf)->frag_list);
1841*5113495bSYour Name }
1842*5113495bSYour Name 
1843*5113495bSYour Name /**
1844*5113495bSYour Name  * __qdf_nbuf_get_age() - return the checksum value of the skb
1845*5113495bSYour Name  * @skb: Pointer to network buffer
1846*5113495bSYour Name  *
1847*5113495bSYour Name  * Return: checksum value
1848*5113495bSYour Name  */
__qdf_nbuf_get_age(struct sk_buff * skb)1849*5113495bSYour Name static inline uint32_t __qdf_nbuf_get_age(struct sk_buff *skb)
1850*5113495bSYour Name {
1851*5113495bSYour Name 	return skb->csum;
1852*5113495bSYour Name }
1853*5113495bSYour Name 
1854*5113495bSYour Name /**
1855*5113495bSYour Name  * __qdf_nbuf_set_age() - sets the checksum value of the skb
1856*5113495bSYour Name  * @skb: Pointer to network buffer
1857*5113495bSYour Name  * @v: Value
1858*5113495bSYour Name  *
1859*5113495bSYour Name  * Return: none
1860*5113495bSYour Name  */
__qdf_nbuf_set_age(struct sk_buff * skb,uint32_t v)1861*5113495bSYour Name static inline void __qdf_nbuf_set_age(struct sk_buff *skb, uint32_t v)
1862*5113495bSYour Name {
1863*5113495bSYour Name 	skb->csum = v;
1864*5113495bSYour Name }
1865*5113495bSYour Name 
1866*5113495bSYour Name /**
1867*5113495bSYour Name  * __qdf_nbuf_adj_age() - adjusts the checksum/age value of the skb
1868*5113495bSYour Name  * @skb: Pointer to network buffer
1869*5113495bSYour Name  * @adj: Adjustment value
1870*5113495bSYour Name  *
1871*5113495bSYour Name  * Return: none
1872*5113495bSYour Name  */
__qdf_nbuf_adj_age(struct sk_buff * skb,uint32_t adj)1873*5113495bSYour Name static inline void __qdf_nbuf_adj_age(struct sk_buff *skb, uint32_t adj)
1874*5113495bSYour Name {
1875*5113495bSYour Name 	skb->csum -= adj;
1876*5113495bSYour Name }
1877*5113495bSYour Name 
1878*5113495bSYour Name /**
1879*5113495bSYour Name  * __qdf_nbuf_copy_bits() - return the length of the copy bits for skb
1880*5113495bSYour Name  * @skb: Pointer to network buffer
1881*5113495bSYour Name  * @offset: Offset value
1882*5113495bSYour Name  * @len: Length
1883*5113495bSYour Name  * @to: Destination pointer
1884*5113495bSYour Name  *
1885*5113495bSYour Name  * Return: length of the copy bits for skb
1886*5113495bSYour Name  */
1887*5113495bSYour Name static inline int32_t
__qdf_nbuf_copy_bits(struct sk_buff * skb,int32_t offset,int32_t len,void * to)1888*5113495bSYour Name __qdf_nbuf_copy_bits(struct sk_buff *skb, int32_t offset, int32_t len, void *to)
1889*5113495bSYour Name {
1890*5113495bSYour Name 	return skb_copy_bits(skb, offset, to, len);
1891*5113495bSYour Name }
1892*5113495bSYour Name 
1893*5113495bSYour Name /**
1894*5113495bSYour Name  * __qdf_nbuf_set_pktlen() - sets the length of the skb and adjust the tail
1895*5113495bSYour Name  * @skb: Pointer to network buffer
1896*5113495bSYour Name  * @len:  Packet length
1897*5113495bSYour Name  *
1898*5113495bSYour Name  * Return: none
1899*5113495bSYour Name  */
__qdf_nbuf_set_pktlen(struct sk_buff * skb,uint32_t len)1900*5113495bSYour Name static inline void __qdf_nbuf_set_pktlen(struct sk_buff *skb, uint32_t len)
1901*5113495bSYour Name {
1902*5113495bSYour Name 	if (skb->len > len) {
1903*5113495bSYour Name 		skb_trim(skb, len);
1904*5113495bSYour Name 	} else {
1905*5113495bSYour Name 		if (skb_tailroom(skb) < len - skb->len) {
1906*5113495bSYour Name 			if (unlikely(pskb_expand_head(skb, 0,
1907*5113495bSYour Name 				len - skb->len - skb_tailroom(skb),
1908*5113495bSYour Name 				GFP_ATOMIC))) {
1909*5113495bSYour Name 				QDF_DEBUG_PANIC(
1910*5113495bSYour Name 				   "SKB tailroom is lessthan requested length."
1911*5113495bSYour Name 				   " tail-room: %u, len: %u, skb->len: %u",
1912*5113495bSYour Name 				   skb_tailroom(skb), len, skb->len);
1913*5113495bSYour Name 				__qdf_nbuf_count_dec(skb);
1914*5113495bSYour Name 				dev_kfree_skb_any(skb);
1915*5113495bSYour Name 			}
1916*5113495bSYour Name 		}
1917*5113495bSYour Name 		skb_put(skb, (len - skb->len));
1918*5113495bSYour Name 	}
1919*5113495bSYour Name }
1920*5113495bSYour Name 
1921*5113495bSYour Name /**
1922*5113495bSYour Name  * __qdf_nbuf_set_protocol() - sets the protocol value of the skb
1923*5113495bSYour Name  * @skb: Pointer to network buffer
1924*5113495bSYour Name  * @protocol: Protocol type
1925*5113495bSYour Name  *
1926*5113495bSYour Name  * Return: none
1927*5113495bSYour Name  */
1928*5113495bSYour Name static inline void
__qdf_nbuf_set_protocol(struct sk_buff * skb,uint16_t protocol)1929*5113495bSYour Name __qdf_nbuf_set_protocol(struct sk_buff *skb, uint16_t protocol)
1930*5113495bSYour Name {
1931*5113495bSYour Name 	skb->protocol = protocol;
1932*5113495bSYour Name }
1933*5113495bSYour Name 
1934*5113495bSYour Name #define __qdf_nbuf_set_tx_htt2_frm(skb, candi) \
1935*5113495bSYour Name 	(QDF_NBUF_CB_TX_HL_HTT2_FRM(skb) = (candi))
1936*5113495bSYour Name 
1937*5113495bSYour Name #define __qdf_nbuf_get_tx_htt2_frm(skb)	\
1938*5113495bSYour Name 	QDF_NBUF_CB_TX_HL_HTT2_FRM(skb)
1939*5113495bSYour Name 
1940*5113495bSYour Name /**
1941*5113495bSYour Name  * __qdf_dmaaddr_to_32s() - return high and low parts of dma_addr
1942*5113495bSYour Name  * @dmaaddr: DMA address
1943*5113495bSYour Name  * @lo: low 32-bits of @dmaaddr
1944*5113495bSYour Name  * @hi: high 32-bits of @dmaaddr
1945*5113495bSYour Name  *
1946*5113495bSYour Name  * Returns the high and low 32-bits of the DMA addr in the provided ptrs
1947*5113495bSYour Name  *
1948*5113495bSYour Name  * Return: N/A
1949*5113495bSYour Name  */
1950*5113495bSYour Name void __qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr,
1951*5113495bSYour Name 				      uint32_t *lo, uint32_t *hi);
1952*5113495bSYour Name 
1953*5113495bSYour Name /**
1954*5113495bSYour Name  * __qdf_nbuf_get_tso_info() - function to divide a TSO nbuf
1955*5113495bSYour Name  * into segments
1956*5113495bSYour Name  * @osdev: qdf device handle
1957*5113495bSYour Name  * @skb: network buffer to be segmented
1958*5113495bSYour Name  * @tso_info: This is the output. The information about the
1959*5113495bSYour Name  *           TSO segments will be populated within this.
1960*5113495bSYour Name  *
1961*5113495bSYour Name  * This function fragments a TCP jumbo packet into smaller
1962*5113495bSYour Name  * segments to be transmitted by the driver. It chains the TSO
1963*5113495bSYour Name  * segments created into a list.
1964*5113495bSYour Name  *
1965*5113495bSYour Name  * Return: number of TSO segments
1966*5113495bSYour Name  */
1967*5113495bSYour Name uint32_t __qdf_nbuf_get_tso_info(qdf_device_t osdev, struct sk_buff *skb,
1968*5113495bSYour Name 				 struct qdf_tso_info_t *tso_info);
1969*5113495bSYour Name 
1970*5113495bSYour Name /**
1971*5113495bSYour Name  * __qdf_nbuf_unmap_tso_segment() - function to dma unmap TSO segment element
1972*5113495bSYour Name  *
1973*5113495bSYour Name  * @osdev: qdf device handle
1974*5113495bSYour Name  * @tso_seg: TSO segment element to be unmapped
1975*5113495bSYour Name  * @is_last_seg: whether this is last tso seg or not
1976*5113495bSYour Name  *
1977*5113495bSYour Name  * Return: none
1978*5113495bSYour Name  */
1979*5113495bSYour Name void __qdf_nbuf_unmap_tso_segment(qdf_device_t osdev,
1980*5113495bSYour Name 			  struct qdf_tso_seg_elem_t *tso_seg,
1981*5113495bSYour Name 			  bool is_last_seg);
1982*5113495bSYour Name 
1983*5113495bSYour Name #ifdef FEATURE_TSO
1984*5113495bSYour Name /**
1985*5113495bSYour Name  * __qdf_nbuf_get_tcp_payload_len() - function to return the tcp
1986*5113495bSYour Name  *                                    payload len
1987*5113495bSYour Name  * @skb: buffer
1988*5113495bSYour Name  *
1989*5113495bSYour Name  * Return: size
1990*5113495bSYour Name  */
1991*5113495bSYour Name size_t __qdf_nbuf_get_tcp_payload_len(struct sk_buff *skb);
1992*5113495bSYour Name 
1993*5113495bSYour Name /**
1994*5113495bSYour Name  * __qdf_nbuf_get_tso_num_seg() - function to divide a TSO nbuf
1995*5113495bSYour Name  *                                into segments
1996*5113495bSYour Name  * @skb:   network buffer to be segmented
1997*5113495bSYour Name  *
1998*5113495bSYour Name  * This function fragments a TCP jumbo packet into smaller
1999*5113495bSYour Name  * segments to be transmitted by the driver. It chains the TSO
2000*5113495bSYour Name  * segments created into a list.
2001*5113495bSYour Name  *
2002*5113495bSYour Name  * Return: number of segments
2003*5113495bSYour Name  */
2004*5113495bSYour Name uint32_t __qdf_nbuf_get_tso_num_seg(struct sk_buff *skb);
2005*5113495bSYour Name 
2006*5113495bSYour Name #else
2007*5113495bSYour Name static inline
__qdf_nbuf_get_tcp_payload_len(struct sk_buff * skb)2008*5113495bSYour Name size_t __qdf_nbuf_get_tcp_payload_len(struct sk_buff *skb)
2009*5113495bSYour Name {
2010*5113495bSYour Name 	return 0;
2011*5113495bSYour Name }
2012*5113495bSYour Name 
__qdf_nbuf_get_tso_num_seg(struct sk_buff * skb)2013*5113495bSYour Name static inline uint32_t __qdf_nbuf_get_tso_num_seg(struct sk_buff *skb)
2014*5113495bSYour Name {
2015*5113495bSYour Name 	return 0;
2016*5113495bSYour Name }
2017*5113495bSYour Name 
2018*5113495bSYour Name #endif /* FEATURE_TSO */
2019*5113495bSYour Name 
__qdf_nbuf_is_tso(struct sk_buff * skb)2020*5113495bSYour Name static inline bool __qdf_nbuf_is_tso(struct sk_buff *skb)
2021*5113495bSYour Name {
2022*5113495bSYour Name 	if (skb_is_gso(skb) &&
2023*5113495bSYour Name 		(skb_is_gso_v6(skb) ||
2024*5113495bSYour Name 		(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)))
2025*5113495bSYour Name 		return true;
2026*5113495bSYour Name 	else
2027*5113495bSYour Name 		return false;
2028*5113495bSYour Name }
2029*5113495bSYour Name 
2030*5113495bSYour Name struct sk_buff *__qdf_nbuf_inc_users(struct sk_buff *skb);
2031*5113495bSYour Name 
2032*5113495bSYour Name int __qdf_nbuf_get_users(struct sk_buff *skb);
2033*5113495bSYour Name 
2034*5113495bSYour Name /**
2035*5113495bSYour Name  * __qdf_nbuf_tx_info_get() - Modify pkt_type, set pkt_subtype,
2036*5113495bSYour Name  *			      and get hw_classify by peeking
2037*5113495bSYour Name  *			      into packet
2038*5113495bSYour Name  * @skb:		Network buffer (skb on Linux)
2039*5113495bSYour Name  * @pkt_type:		Pkt type (from enum htt_pkt_type)
2040*5113495bSYour Name  * @pkt_subtype:	Bit 4 of this field in HTT descriptor
2041*5113495bSYour Name  *			needs to be set in case of CE classification support
2042*5113495bSYour Name  *			Is set by this macro.
2043*5113495bSYour Name  * @hw_classify:	This is a flag which is set to indicate
2044*5113495bSYour Name  *			CE classification is enabled.
2045*5113495bSYour Name  *			Do not set this bit for VLAN packets
2046*5113495bSYour Name  *			OR for mcast / bcast frames.
2047*5113495bSYour Name  *
2048*5113495bSYour Name  * This macro parses the payload to figure out relevant Tx meta-data e.g.
2049*5113495bSYour Name  * whether to enable tx_classify bit in CE.
2050*5113495bSYour Name  *
2051*5113495bSYour Name  * Overrides pkt_type only if required for 802.3 frames (original ethernet)
2052*5113495bSYour Name  * If protocol is less than ETH_P_802_3_MIN (0x600), then
2053*5113495bSYour Name  * it is the length and a 802.3 frame else it is Ethernet Type II
2054*5113495bSYour Name  * (RFC 894).
2055*5113495bSYour Name  * Bit 4 in pkt_subtype is the tx_classify bit
2056*5113495bSYour Name  *
2057*5113495bSYour Name  * Return:	void
2058*5113495bSYour Name  */
2059*5113495bSYour Name #define __qdf_nbuf_tx_info_get(skb, pkt_type,			\
2060*5113495bSYour Name 				pkt_subtype, hw_classify)	\
2061*5113495bSYour Name do {								\
2062*5113495bSYour Name 	struct ethhdr *eh = (struct ethhdr *)skb->data;		\
2063*5113495bSYour Name 	uint16_t ether_type = ntohs(eh->h_proto);		\
2064*5113495bSYour Name 	bool is_mc_bc;						\
2065*5113495bSYour Name 								\
2066*5113495bSYour Name 	is_mc_bc = is_broadcast_ether_addr((uint8_t *)eh) ||	\
2067*5113495bSYour Name 		   is_multicast_ether_addr((uint8_t *)eh);	\
2068*5113495bSYour Name 								\
2069*5113495bSYour Name 	if (likely((ether_type != ETH_P_8021Q) && !is_mc_bc)) {	\
2070*5113495bSYour Name 		hw_classify = 1;				\
2071*5113495bSYour Name 		pkt_subtype = 0x01 <<				\
2072*5113495bSYour Name 			HTT_TX_CLASSIFY_BIT_S;			\
2073*5113495bSYour Name 	}							\
2074*5113495bSYour Name 								\
2075*5113495bSYour Name 	if (unlikely(ether_type < ETH_P_802_3_MIN))		\
2076*5113495bSYour Name 		pkt_type = htt_pkt_type_ethernet;		\
2077*5113495bSYour Name 								\
2078*5113495bSYour Name } while (0)
2079*5113495bSYour Name 
2080*5113495bSYour Name /*
2081*5113495bSYour Name  * nbuf private buffer routines
2082*5113495bSYour Name  */
2083*5113495bSYour Name 
2084*5113495bSYour Name /**
2085*5113495bSYour Name  * __qdf_nbuf_peek_header() - return the header's addr & m_len
2086*5113495bSYour Name  * @skb: Pointer to network buffer
2087*5113495bSYour Name  * @addr: Pointer to store header's addr
2088*5113495bSYour Name  * @len: network buffer length
2089*5113495bSYour Name  *
2090*5113495bSYour Name  * Return: none
2091*5113495bSYour Name  */
2092*5113495bSYour Name static inline void
__qdf_nbuf_peek_header(struct sk_buff * skb,uint8_t ** addr,uint32_t * len)2093*5113495bSYour Name __qdf_nbuf_peek_header(struct sk_buff *skb, uint8_t **addr, uint32_t *len)
2094*5113495bSYour Name {
2095*5113495bSYour Name 	*addr = skb->data;
2096*5113495bSYour Name 	*len = skb->len;
2097*5113495bSYour Name }
2098*5113495bSYour Name 
2099*5113495bSYour Name /**
2100*5113495bSYour Name  * typedef __qdf_nbuf_queue_t -  network buffer queue
2101*5113495bSYour Name  * @head: Head pointer
2102*5113495bSYour Name  * @tail: Tail pointer
2103*5113495bSYour Name  * @qlen: Queue length
2104*5113495bSYour Name  */
2105*5113495bSYour Name typedef struct __qdf_nbuf_qhead {
2106*5113495bSYour Name 	struct sk_buff *head;
2107*5113495bSYour Name 	struct sk_buff *tail;
2108*5113495bSYour Name 	unsigned int qlen;
2109*5113495bSYour Name } __qdf_nbuf_queue_t;
2110*5113495bSYour Name 
2111*5113495bSYour Name /******************Functions *************/
2112*5113495bSYour Name 
2113*5113495bSYour Name /**
2114*5113495bSYour Name  * __qdf_nbuf_queue_init() - initiallize the queue head
2115*5113495bSYour Name  * @qhead: Queue head
2116*5113495bSYour Name  *
2117*5113495bSYour Name  * Return: QDF status
2118*5113495bSYour Name  */
__qdf_nbuf_queue_init(__qdf_nbuf_queue_t * qhead)2119*5113495bSYour Name static inline QDF_STATUS __qdf_nbuf_queue_init(__qdf_nbuf_queue_t *qhead)
2120*5113495bSYour Name {
2121*5113495bSYour Name 	memset(qhead, 0, sizeof(struct __qdf_nbuf_qhead));
2122*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
2123*5113495bSYour Name }
2124*5113495bSYour Name 
2125*5113495bSYour Name /**
2126*5113495bSYour Name  * __qdf_nbuf_queue_add() - add an skb in the tail of the queue
2127*5113495bSYour Name  * @qhead: Queue head
2128*5113495bSYour Name  * @skb: Pointer to network buffer
2129*5113495bSYour Name  *
2130*5113495bSYour Name  * This is a lockless version, driver must acquire locks if it
2131*5113495bSYour Name  * needs to synchronize
2132*5113495bSYour Name  *
2133*5113495bSYour Name  * Return: none
2134*5113495bSYour Name  */
2135*5113495bSYour Name static inline void
__qdf_nbuf_queue_add(__qdf_nbuf_queue_t * qhead,struct sk_buff * skb)2136*5113495bSYour Name __qdf_nbuf_queue_add(__qdf_nbuf_queue_t *qhead, struct sk_buff *skb)
2137*5113495bSYour Name {
2138*5113495bSYour Name 	skb->next = NULL;       /*Nullify the next ptr */
2139*5113495bSYour Name 
2140*5113495bSYour Name 	if (!qhead->head)
2141*5113495bSYour Name 		qhead->head = skb;
2142*5113495bSYour Name 	else
2143*5113495bSYour Name 		qhead->tail->next = skb;
2144*5113495bSYour Name 
2145*5113495bSYour Name 	qhead->tail = skb;
2146*5113495bSYour Name 	qhead->qlen++;
2147*5113495bSYour Name }
2148*5113495bSYour Name 
2149*5113495bSYour Name /**
2150*5113495bSYour Name  * __qdf_nbuf_queue_append() - Append src list at the end of dest list
2151*5113495bSYour Name  * @dest: target netbuf queue
2152*5113495bSYour Name  * @src:  source netbuf queue
2153*5113495bSYour Name  *
2154*5113495bSYour Name  * Return: target netbuf queue
2155*5113495bSYour Name  */
2156*5113495bSYour Name static inline __qdf_nbuf_queue_t *
__qdf_nbuf_queue_append(__qdf_nbuf_queue_t * dest,__qdf_nbuf_queue_t * src)2157*5113495bSYour Name __qdf_nbuf_queue_append(__qdf_nbuf_queue_t *dest, __qdf_nbuf_queue_t *src)
2158*5113495bSYour Name {
2159*5113495bSYour Name 	if (!dest)
2160*5113495bSYour Name 		return NULL;
2161*5113495bSYour Name 	else if (!src || !(src->head))
2162*5113495bSYour Name 		return dest;
2163*5113495bSYour Name 
2164*5113495bSYour Name 	if (!(dest->head))
2165*5113495bSYour Name 		dest->head = src->head;
2166*5113495bSYour Name 	else
2167*5113495bSYour Name 		dest->tail->next = src->head;
2168*5113495bSYour Name 
2169*5113495bSYour Name 	dest->tail = src->tail;
2170*5113495bSYour Name 	dest->qlen += src->qlen;
2171*5113495bSYour Name 	return dest;
2172*5113495bSYour Name }
2173*5113495bSYour Name 
2174*5113495bSYour Name /**
2175*5113495bSYour Name  * __qdf_nbuf_queue_insert_head() - add an skb at  the head  of the queue
2176*5113495bSYour Name  * @qhead: Queue head
2177*5113495bSYour Name  * @skb: Pointer to network buffer
2178*5113495bSYour Name  *
2179*5113495bSYour Name  * This is a lockless version, driver must acquire locks if it needs to
2180*5113495bSYour Name  * synchronize
2181*5113495bSYour Name  *
2182*5113495bSYour Name  * Return: none
2183*5113495bSYour Name  */
2184*5113495bSYour Name static inline void
__qdf_nbuf_queue_insert_head(__qdf_nbuf_queue_t * qhead,__qdf_nbuf_t skb)2185*5113495bSYour Name __qdf_nbuf_queue_insert_head(__qdf_nbuf_queue_t *qhead, __qdf_nbuf_t skb)
2186*5113495bSYour Name {
2187*5113495bSYour Name 	if (!qhead->head) {
2188*5113495bSYour Name 		/*Empty queue Tail pointer Must be updated */
2189*5113495bSYour Name 		qhead->tail = skb;
2190*5113495bSYour Name 	}
2191*5113495bSYour Name 	skb->next = qhead->head;
2192*5113495bSYour Name 	qhead->head = skb;
2193*5113495bSYour Name 	qhead->qlen++;
2194*5113495bSYour Name }
2195*5113495bSYour Name 
2196*5113495bSYour Name /**
2197*5113495bSYour Name  * __qdf_nbuf_queue_remove_last() - remove a skb from the tail of the queue
2198*5113495bSYour Name  * @qhead: Queue head
2199*5113495bSYour Name  *
2200*5113495bSYour Name  * This is a lockless version. Driver should take care of the locks
2201*5113495bSYour Name  *
2202*5113495bSYour Name  * Return: skb or NULL
2203*5113495bSYour Name  */
2204*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_queue_remove_last(__qdf_nbuf_queue_t * qhead)2205*5113495bSYour Name __qdf_nbuf_queue_remove_last(__qdf_nbuf_queue_t *qhead)
2206*5113495bSYour Name {
2207*5113495bSYour Name 	__qdf_nbuf_t tmp_tail, node = NULL;
2208*5113495bSYour Name 
2209*5113495bSYour Name 	if (qhead->head) {
2210*5113495bSYour Name 		qhead->qlen--;
2211*5113495bSYour Name 		tmp_tail = qhead->tail;
2212*5113495bSYour Name 		node = qhead->head;
2213*5113495bSYour Name 		if (qhead->head == qhead->tail) {
2214*5113495bSYour Name 			qhead->head = NULL;
2215*5113495bSYour Name 			qhead->tail = NULL;
2216*5113495bSYour Name 			return node;
2217*5113495bSYour Name 		} else {
2218*5113495bSYour Name 			while (tmp_tail != node->next)
2219*5113495bSYour Name 			       node = node->next;
2220*5113495bSYour Name 			qhead->tail = node;
2221*5113495bSYour Name 			return node->next;
2222*5113495bSYour Name 		}
2223*5113495bSYour Name 	}
2224*5113495bSYour Name 	return node;
2225*5113495bSYour Name }
2226*5113495bSYour Name 
2227*5113495bSYour Name /**
2228*5113495bSYour Name  * __qdf_nbuf_queue_remove() - remove a skb from the head of the queue
2229*5113495bSYour Name  * @qhead: Queue head
2230*5113495bSYour Name  *
2231*5113495bSYour Name  * This is a lockless version. Driver should take care of the locks
2232*5113495bSYour Name  *
2233*5113495bSYour Name  * Return: skb or NULL
2234*5113495bSYour Name  */
2235*5113495bSYour Name static inline
__qdf_nbuf_queue_remove(__qdf_nbuf_queue_t * qhead)2236*5113495bSYour Name struct sk_buff *__qdf_nbuf_queue_remove(__qdf_nbuf_queue_t *qhead)
2237*5113495bSYour Name {
2238*5113495bSYour Name 	__qdf_nbuf_t tmp = NULL;
2239*5113495bSYour Name 
2240*5113495bSYour Name 	if (qhead->head) {
2241*5113495bSYour Name 		qhead->qlen--;
2242*5113495bSYour Name 		tmp = qhead->head;
2243*5113495bSYour Name 		if (qhead->head == qhead->tail) {
2244*5113495bSYour Name 			qhead->head = NULL;
2245*5113495bSYour Name 			qhead->tail = NULL;
2246*5113495bSYour Name 		} else {
2247*5113495bSYour Name 			qhead->head = tmp->next;
2248*5113495bSYour Name 		}
2249*5113495bSYour Name 		tmp->next = NULL;
2250*5113495bSYour Name 	}
2251*5113495bSYour Name 	return tmp;
2252*5113495bSYour Name }
2253*5113495bSYour Name 
2254*5113495bSYour Name /**
2255*5113495bSYour Name  * __qdf_nbuf_queue_first() - returns the first skb in the queue
2256*5113495bSYour Name  * @qhead: head of queue
2257*5113495bSYour Name  *
2258*5113495bSYour Name  * Return: NULL if the queue is empty
2259*5113495bSYour Name  */
2260*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_queue_first(__qdf_nbuf_queue_t * qhead)2261*5113495bSYour Name __qdf_nbuf_queue_first(__qdf_nbuf_queue_t *qhead)
2262*5113495bSYour Name {
2263*5113495bSYour Name 	return qhead->head;
2264*5113495bSYour Name }
2265*5113495bSYour Name 
2266*5113495bSYour Name /**
2267*5113495bSYour Name  * __qdf_nbuf_queue_last() - returns the last skb in the queue
2268*5113495bSYour Name  * @qhead: head of queue
2269*5113495bSYour Name  *
2270*5113495bSYour Name  * Return: NULL if the queue is empty
2271*5113495bSYour Name  */
2272*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_queue_last(__qdf_nbuf_queue_t * qhead)2273*5113495bSYour Name __qdf_nbuf_queue_last(__qdf_nbuf_queue_t *qhead)
2274*5113495bSYour Name {
2275*5113495bSYour Name 	return qhead->tail;
2276*5113495bSYour Name }
2277*5113495bSYour Name 
2278*5113495bSYour Name /**
2279*5113495bSYour Name  * __qdf_nbuf_queue_len() - return the queue length
2280*5113495bSYour Name  * @qhead: Queue head
2281*5113495bSYour Name  *
2282*5113495bSYour Name  * Return: Queue length
2283*5113495bSYour Name  */
__qdf_nbuf_queue_len(__qdf_nbuf_queue_t * qhead)2284*5113495bSYour Name static inline uint32_t __qdf_nbuf_queue_len(__qdf_nbuf_queue_t *qhead)
2285*5113495bSYour Name {
2286*5113495bSYour Name 	return qhead->qlen;
2287*5113495bSYour Name }
2288*5113495bSYour Name 
2289*5113495bSYour Name /**
2290*5113495bSYour Name  * __qdf_nbuf_queue_next() - return the next skb from packet chain
2291*5113495bSYour Name  * @skb: Pointer to network buffer
2292*5113495bSYour Name  *
2293*5113495bSYour Name  * This API returns the next skb from packet chain, remember the skb is
2294*5113495bSYour Name  * still in the queue
2295*5113495bSYour Name  *
2296*5113495bSYour Name  * Return: NULL if no packets are there
2297*5113495bSYour Name  */
__qdf_nbuf_queue_next(struct sk_buff * skb)2298*5113495bSYour Name static inline struct sk_buff *__qdf_nbuf_queue_next(struct sk_buff *skb)
2299*5113495bSYour Name {
2300*5113495bSYour Name 	return skb->next;
2301*5113495bSYour Name }
2302*5113495bSYour Name 
2303*5113495bSYour Name /**
2304*5113495bSYour Name  * __qdf_nbuf_is_queue_empty() - check if the queue is empty or not
2305*5113495bSYour Name  * @qhead: Queue head
2306*5113495bSYour Name  *
2307*5113495bSYour Name  * Return: true if length is 0 else false
2308*5113495bSYour Name  */
__qdf_nbuf_is_queue_empty(__qdf_nbuf_queue_t * qhead)2309*5113495bSYour Name static inline bool __qdf_nbuf_is_queue_empty(__qdf_nbuf_queue_t *qhead)
2310*5113495bSYour Name {
2311*5113495bSYour Name 	return qhead->qlen == 0;
2312*5113495bSYour Name }
2313*5113495bSYour Name 
2314*5113495bSYour Name /*
2315*5113495bSYour Name  * Use sk_buff_head as the implementation of qdf_nbuf_queue_t.
2316*5113495bSYour Name  * Because the queue head will most likely put in some structure,
2317*5113495bSYour Name  * we don't use pointer type as the definition.
2318*5113495bSYour Name  */
2319*5113495bSYour Name 
2320*5113495bSYour Name /*
2321*5113495bSYour Name  * Use sk_buff_head as the implementation of qdf_nbuf_queue_t.
2322*5113495bSYour Name  * Because the queue head will most likely put in some structure,
2323*5113495bSYour Name  * we don't use pointer type as the definition.
2324*5113495bSYour Name  */
2325*5113495bSYour Name 
2326*5113495bSYour Name static inline void
__qdf_nbuf_set_send_complete_flag(struct sk_buff * skb,bool flag)2327*5113495bSYour Name __qdf_nbuf_set_send_complete_flag(struct sk_buff *skb, bool flag)
2328*5113495bSYour Name {
2329*5113495bSYour Name }
2330*5113495bSYour Name 
2331*5113495bSYour Name /**
2332*5113495bSYour Name  * __qdf_nbuf_realloc_headroom() - This keeps the skb shell intact
2333*5113495bSYour Name  *        expands the headroom
2334*5113495bSYour Name  *        in the data region. In case of failure the skb is released.
2335*5113495bSYour Name  * @skb: sk buff
2336*5113495bSYour Name  * @headroom: size of headroom
2337*5113495bSYour Name  *
2338*5113495bSYour Name  * Return: skb or NULL
2339*5113495bSYour Name  */
2340*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_realloc_headroom(struct sk_buff * skb,uint32_t headroom)2341*5113495bSYour Name __qdf_nbuf_realloc_headroom(struct sk_buff *skb, uint32_t headroom)
2342*5113495bSYour Name {
2343*5113495bSYour Name 	if (pskb_expand_head(skb, headroom, 0, GFP_ATOMIC)) {
2344*5113495bSYour Name 		__qdf_nbuf_count_dec(skb);
2345*5113495bSYour Name 		dev_kfree_skb_any(skb);
2346*5113495bSYour Name 		skb = NULL;
2347*5113495bSYour Name 	}
2348*5113495bSYour Name 	return skb;
2349*5113495bSYour Name }
2350*5113495bSYour Name 
2351*5113495bSYour Name /**
2352*5113495bSYour Name  * __qdf_nbuf_realloc_tailroom() - This keeps the skb shell intact
2353*5113495bSYour Name  *        exapnds the tailroom
2354*5113495bSYour Name  *        in data region. In case of failure it releases the skb.
2355*5113495bSYour Name  * @skb: sk buff
2356*5113495bSYour Name  * @tailroom: size of tailroom
2357*5113495bSYour Name  *
2358*5113495bSYour Name  * Return: skb or NULL
2359*5113495bSYour Name  */
2360*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_realloc_tailroom(struct sk_buff * skb,uint32_t tailroom)2361*5113495bSYour Name __qdf_nbuf_realloc_tailroom(struct sk_buff *skb, uint32_t tailroom)
2362*5113495bSYour Name {
2363*5113495bSYour Name 	if (likely(!pskb_expand_head(skb, 0, tailroom, GFP_ATOMIC)))
2364*5113495bSYour Name 		return skb;
2365*5113495bSYour Name 	/**
2366*5113495bSYour Name 	 * unlikely path
2367*5113495bSYour Name 	 */
2368*5113495bSYour Name 	__qdf_nbuf_count_dec(skb);
2369*5113495bSYour Name 	dev_kfree_skb_any(skb);
2370*5113495bSYour Name 	return NULL;
2371*5113495bSYour Name }
2372*5113495bSYour Name 
2373*5113495bSYour Name /**
2374*5113495bSYour Name  * __qdf_nbuf_linearize() - skb linearize
2375*5113495bSYour Name  * @skb: sk buff
2376*5113495bSYour Name  *
2377*5113495bSYour Name  * create a version of the specified nbuf whose contents
2378*5113495bSYour Name  * can be safely modified without affecting other
2379*5113495bSYour Name  * users.If the nbuf is non-linear then this function
2380*5113495bSYour Name  * linearize. if unable to linearize returns -ENOMEM on
2381*5113495bSYour Name  * success 0 is returned
2382*5113495bSYour Name  *
2383*5113495bSYour Name  * Return: 0 on Success, -ENOMEM on failure is returned.
2384*5113495bSYour Name  */
2385*5113495bSYour Name static inline int
__qdf_nbuf_linearize(struct sk_buff * skb)2386*5113495bSYour Name __qdf_nbuf_linearize(struct sk_buff *skb)
2387*5113495bSYour Name {
2388*5113495bSYour Name 	return skb_linearize(skb);
2389*5113495bSYour Name }
2390*5113495bSYour Name 
2391*5113495bSYour Name /**
2392*5113495bSYour Name  * __qdf_nbuf_unshare() - skb unshare
2393*5113495bSYour Name  * @skb: sk buff
2394*5113495bSYour Name  *
2395*5113495bSYour Name  * create a version of the specified nbuf whose contents
2396*5113495bSYour Name  * can be safely modified without affecting other
2397*5113495bSYour Name  * users.If the nbuf is a clone then this function
2398*5113495bSYour Name  * creates a new copy of the data. If the buffer is not
2399*5113495bSYour Name  * a clone the original buffer is returned.
2400*5113495bSYour Name  *
2401*5113495bSYour Name  * Return: skb or NULL
2402*5113495bSYour Name  */
2403*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_unshare(struct sk_buff * skb)2404*5113495bSYour Name __qdf_nbuf_unshare(struct sk_buff *skb)
2405*5113495bSYour Name {
2406*5113495bSYour Name 	struct sk_buff *skb_new;
2407*5113495bSYour Name 
2408*5113495bSYour Name 	__qdf_frag_count_dec(__qdf_nbuf_get_nr_frags(skb));
2409*5113495bSYour Name 
2410*5113495bSYour Name 	skb_new = skb_unshare(skb, GFP_ATOMIC);
2411*5113495bSYour Name 	if (skb_new)
2412*5113495bSYour Name 		__qdf_frag_count_inc(__qdf_nbuf_get_nr_frags(skb_new));
2413*5113495bSYour Name 
2414*5113495bSYour Name 	return skb_new;
2415*5113495bSYour Name }
2416*5113495bSYour Name 
2417*5113495bSYour Name /**
2418*5113495bSYour Name  * __qdf_nbuf_is_cloned() - test whether the nbuf is cloned or not
2419*5113495bSYour Name  * @skb: sk buff
2420*5113495bSYour Name  *
2421*5113495bSYour Name  * Return: true/false
2422*5113495bSYour Name  */
__qdf_nbuf_is_cloned(struct sk_buff * skb)2423*5113495bSYour Name static inline bool __qdf_nbuf_is_cloned(struct sk_buff *skb)
2424*5113495bSYour Name {
2425*5113495bSYour Name 	return skb_cloned(skb);
2426*5113495bSYour Name }
2427*5113495bSYour Name 
2428*5113495bSYour Name /**
2429*5113495bSYour Name  * __qdf_nbuf_pool_init() - init pool
2430*5113495bSYour Name  * @net: net handle
2431*5113495bSYour Name  *
2432*5113495bSYour Name  * Return: QDF status
2433*5113495bSYour Name  */
__qdf_nbuf_pool_init(qdf_net_handle_t net)2434*5113495bSYour Name static inline QDF_STATUS __qdf_nbuf_pool_init(qdf_net_handle_t net)
2435*5113495bSYour Name {
2436*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
2437*5113495bSYour Name }
2438*5113495bSYour Name 
2439*5113495bSYour Name /*
2440*5113495bSYour Name  * adf_nbuf_pool_delete() implementation - do nothing in linux
2441*5113495bSYour Name  */
2442*5113495bSYour Name #define __qdf_nbuf_pool_delete(osdev)
2443*5113495bSYour Name 
2444*5113495bSYour Name /**
2445*5113495bSYour Name  * __qdf_nbuf_expand() - Expand both tailroom & headroom. In case of failure
2446*5113495bSYour Name  *        release the skb.
2447*5113495bSYour Name  * @skb: sk buff
2448*5113495bSYour Name  * @headroom: size of headroom
2449*5113495bSYour Name  * @tailroom: size of tailroom
2450*5113495bSYour Name  *
2451*5113495bSYour Name  * Return: skb or NULL
2452*5113495bSYour Name  */
2453*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_expand(struct sk_buff * skb,uint32_t headroom,uint32_t tailroom)2454*5113495bSYour Name __qdf_nbuf_expand(struct sk_buff *skb, uint32_t headroom, uint32_t tailroom)
2455*5113495bSYour Name {
2456*5113495bSYour Name 	if (likely(!pskb_expand_head(skb, headroom, tailroom, GFP_ATOMIC)))
2457*5113495bSYour Name 		return skb;
2458*5113495bSYour Name 
2459*5113495bSYour Name 	__qdf_nbuf_count_dec(skb);
2460*5113495bSYour Name 	dev_kfree_skb_any(skb);
2461*5113495bSYour Name 	return NULL;
2462*5113495bSYour Name }
2463*5113495bSYour Name 
2464*5113495bSYour Name /**
2465*5113495bSYour Name  * __qdf_nbuf_copy_expand() - copy and expand nbuf
2466*5113495bSYour Name  * @buf: Network buf instance
2467*5113495bSYour Name  * @headroom: Additional headroom to be added
2468*5113495bSYour Name  * @tailroom: Additional tailroom to be added
2469*5113495bSYour Name  *
2470*5113495bSYour Name  * Return: New nbuf that is a copy of buf, with additional head and tailroom
2471*5113495bSYour Name  *	or NULL if there is no memory
2472*5113495bSYour Name  */
2473*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_copy_expand(struct sk_buff * buf,int headroom,int tailroom)2474*5113495bSYour Name __qdf_nbuf_copy_expand(struct sk_buff *buf, int headroom, int tailroom)
2475*5113495bSYour Name {
2476*5113495bSYour Name 	struct sk_buff *copy;
2477*5113495bSYour Name 	copy = skb_copy_expand(buf, headroom, tailroom, GFP_ATOMIC);
2478*5113495bSYour Name 	if (copy)
2479*5113495bSYour Name 		__qdf_nbuf_count_inc(copy);
2480*5113495bSYour Name 
2481*5113495bSYour Name 	return copy;
2482*5113495bSYour Name }
2483*5113495bSYour Name 
2484*5113495bSYour Name /**
2485*5113495bSYour Name  * __qdf_nbuf_has_fraglist() - check buf has fraglist
2486*5113495bSYour Name  * @buf: Network buf instance
2487*5113495bSYour Name  *
2488*5113495bSYour Name  * Return: True, if buf has frag_list else return False
2489*5113495bSYour Name  */
2490*5113495bSYour Name static inline bool
__qdf_nbuf_has_fraglist(struct sk_buff * buf)2491*5113495bSYour Name __qdf_nbuf_has_fraglist(struct sk_buff *buf)
2492*5113495bSYour Name {
2493*5113495bSYour Name 	return skb_has_frag_list(buf);
2494*5113495bSYour Name }
2495*5113495bSYour Name 
2496*5113495bSYour Name /**
2497*5113495bSYour Name  * __qdf_nbuf_get_last_frag_list_nbuf() - Get last frag_list nbuf
2498*5113495bSYour Name  * @buf: Network buf instance
2499*5113495bSYour Name  *
2500*5113495bSYour Name  * Return: Network buf instance
2501*5113495bSYour Name  */
2502*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_get_last_frag_list_nbuf(struct sk_buff * buf)2503*5113495bSYour Name __qdf_nbuf_get_last_frag_list_nbuf(struct sk_buff *buf)
2504*5113495bSYour Name {
2505*5113495bSYour Name 	struct sk_buff *list;
2506*5113495bSYour Name 
2507*5113495bSYour Name 	if (!__qdf_nbuf_has_fraglist(buf))
2508*5113495bSYour Name 		return NULL;
2509*5113495bSYour Name 
2510*5113495bSYour Name 	for (list = skb_shinfo(buf)->frag_list; list->next; list = list->next)
2511*5113495bSYour Name 		;
2512*5113495bSYour Name 
2513*5113495bSYour Name 	return list;
2514*5113495bSYour Name }
2515*5113495bSYour Name 
2516*5113495bSYour Name /**
2517*5113495bSYour Name  * __qdf_nbuf_get_ref_fraglist() - get reference to fragments
2518*5113495bSYour Name  * @buf: Network buf instance
2519*5113495bSYour Name  *
2520*5113495bSYour Name  * Return: void
2521*5113495bSYour Name  */
2522*5113495bSYour Name static inline void
__qdf_nbuf_get_ref_fraglist(struct sk_buff * buf)2523*5113495bSYour Name __qdf_nbuf_get_ref_fraglist(struct sk_buff *buf)
2524*5113495bSYour Name {
2525*5113495bSYour Name 	struct sk_buff *list;
2526*5113495bSYour Name 
2527*5113495bSYour Name 	skb_walk_frags(buf, list)
2528*5113495bSYour Name 		skb_get(list);
2529*5113495bSYour Name }
2530*5113495bSYour Name 
2531*5113495bSYour Name /**
2532*5113495bSYour Name  * __qdf_nbuf_tx_cksum_info() - tx checksum info
2533*5113495bSYour Name  * @skb: Network buffer
2534*5113495bSYour Name  * @hdr_off:
2535*5113495bSYour Name  * @where:
2536*5113495bSYour Name  *
2537*5113495bSYour Name  * Return: true/false
2538*5113495bSYour Name  */
2539*5113495bSYour Name static inline bool
__qdf_nbuf_tx_cksum_info(struct sk_buff * skb,uint8_t ** hdr_off,uint8_t ** where)2540*5113495bSYour Name __qdf_nbuf_tx_cksum_info(struct sk_buff *skb, uint8_t **hdr_off,
2541*5113495bSYour Name 			 uint8_t **where)
2542*5113495bSYour Name {
2543*5113495bSYour Name 	qdf_assert(0);
2544*5113495bSYour Name 	return false;
2545*5113495bSYour Name }
2546*5113495bSYour Name 
2547*5113495bSYour Name /**
2548*5113495bSYour Name  * __qdf_nbuf_reset_ctxt() - mem zero control block
2549*5113495bSYour Name  * @nbuf: buffer
2550*5113495bSYour Name  *
2551*5113495bSYour Name  * Return: none
2552*5113495bSYour Name  */
__qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)2553*5113495bSYour Name static inline void __qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)
2554*5113495bSYour Name {
2555*5113495bSYour Name 	qdf_mem_zero(nbuf->cb, sizeof(nbuf->cb));
2556*5113495bSYour Name }
2557*5113495bSYour Name 
2558*5113495bSYour Name /**
2559*5113495bSYour Name  * __qdf_nbuf_network_header() - get network header
2560*5113495bSYour Name  * @buf: buffer
2561*5113495bSYour Name  *
2562*5113495bSYour Name  * Return: network header pointer
2563*5113495bSYour Name  */
__qdf_nbuf_network_header(__qdf_nbuf_t buf)2564*5113495bSYour Name static inline void *__qdf_nbuf_network_header(__qdf_nbuf_t buf)
2565*5113495bSYour Name {
2566*5113495bSYour Name 	return skb_network_header(buf);
2567*5113495bSYour Name }
2568*5113495bSYour Name 
2569*5113495bSYour Name /**
2570*5113495bSYour Name  * __qdf_nbuf_transport_header() - get transport header
2571*5113495bSYour Name  * @buf: buffer
2572*5113495bSYour Name  *
2573*5113495bSYour Name  * Return: transport header pointer
2574*5113495bSYour Name  */
__qdf_nbuf_transport_header(__qdf_nbuf_t buf)2575*5113495bSYour Name static inline void *__qdf_nbuf_transport_header(__qdf_nbuf_t buf)
2576*5113495bSYour Name {
2577*5113495bSYour Name 	return skb_transport_header(buf);
2578*5113495bSYour Name }
2579*5113495bSYour Name 
2580*5113495bSYour Name /**
2581*5113495bSYour Name  *  __qdf_nbuf_tcp_tso_size() - return the size of TCP segment size (MSS),
2582*5113495bSYour Name  *  passed as part of network buffer by network stack
2583*5113495bSYour Name  * @skb: sk buff
2584*5113495bSYour Name  *
2585*5113495bSYour Name  * Return: TCP MSS size
2586*5113495bSYour Name  *
2587*5113495bSYour Name  */
__qdf_nbuf_tcp_tso_size(struct sk_buff * skb)2588*5113495bSYour Name static inline size_t __qdf_nbuf_tcp_tso_size(struct sk_buff *skb)
2589*5113495bSYour Name {
2590*5113495bSYour Name 	return skb_shinfo(skb)->gso_size;
2591*5113495bSYour Name }
2592*5113495bSYour Name 
2593*5113495bSYour Name /**
2594*5113495bSYour Name  * __qdf_nbuf_init() - Re-initializes the skb for re-use
2595*5113495bSYour Name  * @nbuf: sk buff
2596*5113495bSYour Name  *
2597*5113495bSYour Name  * Return: none
2598*5113495bSYour Name  */
2599*5113495bSYour Name void __qdf_nbuf_init(__qdf_nbuf_t nbuf);
2600*5113495bSYour Name 
2601*5113495bSYour Name /**
2602*5113495bSYour Name  *  __qdf_nbuf_get_cb() - returns a pointer to skb->cb
2603*5113495bSYour Name  * @nbuf: sk buff
2604*5113495bSYour Name  *
2605*5113495bSYour Name  * Return: void ptr
2606*5113495bSYour Name  */
2607*5113495bSYour Name static inline void *
__qdf_nbuf_get_cb(__qdf_nbuf_t nbuf)2608*5113495bSYour Name __qdf_nbuf_get_cb(__qdf_nbuf_t nbuf)
2609*5113495bSYour Name {
2610*5113495bSYour Name 	return (void *)nbuf->cb;
2611*5113495bSYour Name }
2612*5113495bSYour Name 
2613*5113495bSYour Name /**
2614*5113495bSYour Name  * __qdf_nbuf_headlen() - return the length of linear buffer of the skb
2615*5113495bSYour Name  * @skb: sk buff
2616*5113495bSYour Name  *
2617*5113495bSYour Name  * Return: head size
2618*5113495bSYour Name  */
2619*5113495bSYour Name static inline size_t
__qdf_nbuf_headlen(struct sk_buff * skb)2620*5113495bSYour Name __qdf_nbuf_headlen(struct sk_buff *skb)
2621*5113495bSYour Name {
2622*5113495bSYour Name 	return skb_headlen(skb);
2623*5113495bSYour Name }
2624*5113495bSYour Name 
2625*5113495bSYour Name /**
2626*5113495bSYour Name  * __qdf_nbuf_tso_tcp_v4() - to check if the TSO TCP pkt is a IPv4 or not.
2627*5113495bSYour Name  * @skb: sk buff
2628*5113495bSYour Name  *
2629*5113495bSYour Name  * Return: true/false
2630*5113495bSYour Name  */
__qdf_nbuf_tso_tcp_v4(struct sk_buff * skb)2631*5113495bSYour Name static inline bool __qdf_nbuf_tso_tcp_v4(struct sk_buff *skb)
2632*5113495bSYour Name {
2633*5113495bSYour Name 	return skb_shinfo(skb)->gso_type == SKB_GSO_TCPV4 ? 1 : 0;
2634*5113495bSYour Name }
2635*5113495bSYour Name 
2636*5113495bSYour Name /**
2637*5113495bSYour Name  * __qdf_nbuf_tso_tcp_v6() - to check if the TSO TCP pkt is a IPv6 or not.
2638*5113495bSYour Name  * @skb: sk buff
2639*5113495bSYour Name  *
2640*5113495bSYour Name  * Return: true/false
2641*5113495bSYour Name  */
__qdf_nbuf_tso_tcp_v6(struct sk_buff * skb)2642*5113495bSYour Name static inline bool __qdf_nbuf_tso_tcp_v6(struct sk_buff *skb)
2643*5113495bSYour Name {
2644*5113495bSYour Name 	return skb_shinfo(skb)->gso_type == SKB_GSO_TCPV6 ? 1 : 0;
2645*5113495bSYour Name }
2646*5113495bSYour Name 
2647*5113495bSYour Name /**
2648*5113495bSYour Name  * __qdf_nbuf_l2l3l4_hdr_len() - return the l2+l3+l4 hdr length of the skb
2649*5113495bSYour Name  * @skb: sk buff
2650*5113495bSYour Name  *
2651*5113495bSYour Name  * Return: size of l2+l3+l4 header length
2652*5113495bSYour Name  */
__qdf_nbuf_l2l3l4_hdr_len(struct sk_buff * skb)2653*5113495bSYour Name static inline size_t __qdf_nbuf_l2l3l4_hdr_len(struct sk_buff *skb)
2654*5113495bSYour Name {
2655*5113495bSYour Name 	return skb_transport_offset(skb) + tcp_hdrlen(skb);
2656*5113495bSYour Name }
2657*5113495bSYour Name 
2658*5113495bSYour Name /**
2659*5113495bSYour Name  * __qdf_nbuf_get_tcp_hdr_len() - return TCP header length of the skb
2660*5113495bSYour Name  * @skb: sk buff
2661*5113495bSYour Name  *
2662*5113495bSYour Name  * Return: size of TCP header length
2663*5113495bSYour Name  */
__qdf_nbuf_get_tcp_hdr_len(struct sk_buff * skb)2664*5113495bSYour Name static inline size_t __qdf_nbuf_get_tcp_hdr_len(struct sk_buff *skb)
2665*5113495bSYour Name {
2666*5113495bSYour Name 	return tcp_hdrlen(skb);
2667*5113495bSYour Name }
2668*5113495bSYour Name 
2669*5113495bSYour Name /**
2670*5113495bSYour Name  * __qdf_nbuf_is_nonlinear() - test whether the nbuf is nonlinear or not
2671*5113495bSYour Name  * @skb: sk buff
2672*5113495bSYour Name  *
2673*5113495bSYour Name  * Return:  true/false
2674*5113495bSYour Name  */
__qdf_nbuf_is_nonlinear(struct sk_buff * skb)2675*5113495bSYour Name static inline bool __qdf_nbuf_is_nonlinear(struct sk_buff *skb)
2676*5113495bSYour Name {
2677*5113495bSYour Name 	if (skb_is_nonlinear(skb))
2678*5113495bSYour Name 		return true;
2679*5113495bSYour Name 	else
2680*5113495bSYour Name 		return false;
2681*5113495bSYour Name }
2682*5113495bSYour Name 
2683*5113495bSYour Name /**
2684*5113495bSYour Name  * __qdf_nbuf_tcp_seq() - get the TCP sequence number of the  skb
2685*5113495bSYour Name  * @skb: sk buff
2686*5113495bSYour Name  *
2687*5113495bSYour Name  * Return: TCP sequence number
2688*5113495bSYour Name  */
__qdf_nbuf_tcp_seq(struct sk_buff * skb)2689*5113495bSYour Name static inline uint32_t __qdf_nbuf_tcp_seq(struct sk_buff *skb)
2690*5113495bSYour Name {
2691*5113495bSYour Name 	return ntohl(tcp_hdr(skb)->seq);
2692*5113495bSYour Name }
2693*5113495bSYour Name 
2694*5113495bSYour Name /**
2695*5113495bSYour Name  * __qdf_nbuf_get_priv_ptr() - get the priv pointer from the nbuf'f private space
2696*5113495bSYour Name  *@skb: sk buff
2697*5113495bSYour Name  *
2698*5113495bSYour Name  * Return: data pointer to typecast into your priv structure
2699*5113495bSYour Name  */
2700*5113495bSYour Name static inline char *
__qdf_nbuf_get_priv_ptr(struct sk_buff * skb)2701*5113495bSYour Name __qdf_nbuf_get_priv_ptr(struct sk_buff *skb)
2702*5113495bSYour Name {
2703*5113495bSYour Name 	return &skb->cb[8];
2704*5113495bSYour Name }
2705*5113495bSYour Name 
2706*5113495bSYour Name /**
2707*5113495bSYour Name  * __qdf_nbuf_mark_wakeup_frame() - mark wakeup frame.
2708*5113495bSYour Name  * @buf: Pointer to nbuf
2709*5113495bSYour Name  *
2710*5113495bSYour Name  * Return: None
2711*5113495bSYour Name  */
2712*5113495bSYour Name static inline void
__qdf_nbuf_mark_wakeup_frame(__qdf_nbuf_t buf)2713*5113495bSYour Name __qdf_nbuf_mark_wakeup_frame(__qdf_nbuf_t buf)
2714*5113495bSYour Name {
2715*5113495bSYour Name 	buf->mark |= QDF_MARK_FIRST_WAKEUP_PACKET;
2716*5113495bSYour Name }
2717*5113495bSYour Name 
2718*5113495bSYour Name /**
2719*5113495bSYour Name  * __qdf_nbuf_record_rx_queue() - set rx queue in skb
2720*5113495bSYour Name  *
2721*5113495bSYour Name  * @skb: sk buff
2722*5113495bSYour Name  * @queue_id: Queue id
2723*5113495bSYour Name  *
2724*5113495bSYour Name  * Return: void
2725*5113495bSYour Name  */
2726*5113495bSYour Name static inline void
__qdf_nbuf_record_rx_queue(struct sk_buff * skb,uint16_t queue_id)2727*5113495bSYour Name __qdf_nbuf_record_rx_queue(struct sk_buff *skb, uint16_t queue_id)
2728*5113495bSYour Name {
2729*5113495bSYour Name 	skb_record_rx_queue(skb, queue_id);
2730*5113495bSYour Name }
2731*5113495bSYour Name 
2732*5113495bSYour Name /**
2733*5113495bSYour Name  * __qdf_nbuf_get_queue_mapping() - get the queue mapping set by linux kernel
2734*5113495bSYour Name  *
2735*5113495bSYour Name  * @skb: sk buff
2736*5113495bSYour Name  *
2737*5113495bSYour Name  * Return: Queue mapping
2738*5113495bSYour Name  */
2739*5113495bSYour Name static inline uint16_t
__qdf_nbuf_get_queue_mapping(struct sk_buff * skb)2740*5113495bSYour Name __qdf_nbuf_get_queue_mapping(struct sk_buff *skb)
2741*5113495bSYour Name {
2742*5113495bSYour Name 	return skb->queue_mapping;
2743*5113495bSYour Name }
2744*5113495bSYour Name 
2745*5113495bSYour Name /**
2746*5113495bSYour Name  * __qdf_nbuf_set_queue_mapping() - get the queue mapping set by linux kernel
2747*5113495bSYour Name  *
2748*5113495bSYour Name  * @skb: sk buff
2749*5113495bSYour Name  * @val: queue_id
2750*5113495bSYour Name  *
2751*5113495bSYour Name  */
2752*5113495bSYour Name static inline void
__qdf_nbuf_set_queue_mapping(struct sk_buff * skb,uint16_t val)2753*5113495bSYour Name __qdf_nbuf_set_queue_mapping(struct sk_buff *skb, uint16_t val)
2754*5113495bSYour Name {
2755*5113495bSYour Name 	skb_set_queue_mapping(skb, val);
2756*5113495bSYour Name }
2757*5113495bSYour Name 
2758*5113495bSYour Name /**
2759*5113495bSYour Name  * __qdf_nbuf_set_timestamp() - set the timestamp for frame
2760*5113495bSYour Name  *
2761*5113495bSYour Name  * @skb: sk buff
2762*5113495bSYour Name  *
2763*5113495bSYour Name  * Return: void
2764*5113495bSYour Name  */
2765*5113495bSYour Name static inline void
__qdf_nbuf_set_timestamp(struct sk_buff * skb)2766*5113495bSYour Name __qdf_nbuf_set_timestamp(struct sk_buff *skb)
2767*5113495bSYour Name {
2768*5113495bSYour Name 	__net_timestamp(skb);
2769*5113495bSYour Name }
2770*5113495bSYour Name 
2771*5113495bSYour Name /**
2772*5113495bSYour Name  * __qdf_nbuf_get_timestamp() - get the timestamp for frame
2773*5113495bSYour Name  *
2774*5113495bSYour Name  * @skb: sk buff
2775*5113495bSYour Name  *
2776*5113495bSYour Name  * Return: timestamp stored in skb in ms
2777*5113495bSYour Name  */
2778*5113495bSYour Name static inline uint64_t
__qdf_nbuf_get_timestamp(struct sk_buff * skb)2779*5113495bSYour Name __qdf_nbuf_get_timestamp(struct sk_buff *skb)
2780*5113495bSYour Name {
2781*5113495bSYour Name 	return ktime_to_ms(skb_get_ktime(skb));
2782*5113495bSYour Name }
2783*5113495bSYour Name 
2784*5113495bSYour Name /**
2785*5113495bSYour Name  * __qdf_nbuf_get_timestamp_us() - get the timestamp for frame
2786*5113495bSYour Name  *
2787*5113495bSYour Name  * @skb: sk buff
2788*5113495bSYour Name  *
2789*5113495bSYour Name  * Return: timestamp stored in skb in us
2790*5113495bSYour Name  */
2791*5113495bSYour Name static inline uint64_t
__qdf_nbuf_get_timestamp_us(struct sk_buff * skb)2792*5113495bSYour Name __qdf_nbuf_get_timestamp_us(struct sk_buff *skb)
2793*5113495bSYour Name {
2794*5113495bSYour Name 	return ktime_to_us(skb_get_ktime(skb));
2795*5113495bSYour Name }
2796*5113495bSYour Name 
2797*5113495bSYour Name /**
2798*5113495bSYour Name  * __qdf_nbuf_get_timedelta_ms() - get time difference in ms
2799*5113495bSYour Name  *
2800*5113495bSYour Name  * @skb: sk buff
2801*5113495bSYour Name  *
2802*5113495bSYour Name  * Return: time difference in ms
2803*5113495bSYour Name  */
2804*5113495bSYour Name static inline uint64_t
__qdf_nbuf_get_timedelta_ms(struct sk_buff * skb)2805*5113495bSYour Name __qdf_nbuf_get_timedelta_ms(struct sk_buff *skb)
2806*5113495bSYour Name {
2807*5113495bSYour Name 	return ktime_to_ms(net_timedelta(skb->tstamp));
2808*5113495bSYour Name }
2809*5113495bSYour Name 
2810*5113495bSYour Name /**
2811*5113495bSYour Name  * __qdf_nbuf_get_timedelta_us() - get time difference in micro seconds
2812*5113495bSYour Name  *
2813*5113495bSYour Name  * @skb: sk buff
2814*5113495bSYour Name  *
2815*5113495bSYour Name  * Return: time difference in micro seconds
2816*5113495bSYour Name  */
2817*5113495bSYour Name static inline uint64_t
__qdf_nbuf_get_timedelta_us(struct sk_buff * skb)2818*5113495bSYour Name __qdf_nbuf_get_timedelta_us(struct sk_buff *skb)
2819*5113495bSYour Name {
2820*5113495bSYour Name 	return ktime_to_us(net_timedelta(skb->tstamp));
2821*5113495bSYour Name }
2822*5113495bSYour Name 
2823*5113495bSYour Name /**
2824*5113495bSYour Name  * __qdf_nbuf_orphan() - orphan a nbuf
2825*5113495bSYour Name  * @skb: sk buff
2826*5113495bSYour Name  *
2827*5113495bSYour Name  * If a buffer currently has an owner then we call the
2828*5113495bSYour Name  * owner's destructor function
2829*5113495bSYour Name  *
2830*5113495bSYour Name  * Return: void
2831*5113495bSYour Name  */
__qdf_nbuf_orphan(struct sk_buff * skb)2832*5113495bSYour Name static inline void __qdf_nbuf_orphan(struct sk_buff *skb)
2833*5113495bSYour Name {
2834*5113495bSYour Name 	return skb_orphan(skb);
2835*5113495bSYour Name }
2836*5113495bSYour Name 
2837*5113495bSYour Name /**
2838*5113495bSYour Name  * __qdf_nbuf_get_end_offset() - Return the size of the nbuf from
2839*5113495bSYour Name  * head pointer to end pointer
2840*5113495bSYour Name  * @nbuf: qdf_nbuf_t
2841*5113495bSYour Name  *
2842*5113495bSYour Name  * Return: size of network buffer from head pointer to end
2843*5113495bSYour Name  * pointer
2844*5113495bSYour Name  */
__qdf_nbuf_get_end_offset(__qdf_nbuf_t nbuf)2845*5113495bSYour Name static inline unsigned int __qdf_nbuf_get_end_offset(__qdf_nbuf_t nbuf)
2846*5113495bSYour Name {
2847*5113495bSYour Name 	return skb_end_offset(nbuf);
2848*5113495bSYour Name }
2849*5113495bSYour Name 
2850*5113495bSYour Name /**
2851*5113495bSYour Name  * __qdf_nbuf_get_truesize() - Return the true size of the nbuf
2852*5113495bSYour Name  * including the header and variable data area
2853*5113495bSYour Name  * @skb: sk buff
2854*5113495bSYour Name  *
2855*5113495bSYour Name  * Return: size of network buffer
2856*5113495bSYour Name  */
__qdf_nbuf_get_truesize(struct sk_buff * skb)2857*5113495bSYour Name static inline unsigned int __qdf_nbuf_get_truesize(struct sk_buff *skb)
2858*5113495bSYour Name {
2859*5113495bSYour Name 	return skb->truesize;
2860*5113495bSYour Name }
2861*5113495bSYour Name 
2862*5113495bSYour Name /**
2863*5113495bSYour Name  * __qdf_nbuf_get_allocsize() - Return the actual size of the skb->head
2864*5113495bSYour Name  * excluding the header and variable data area
2865*5113495bSYour Name  * @skb: sk buff
2866*5113495bSYour Name  *
2867*5113495bSYour Name  * Return: actual allocated size of network buffer
2868*5113495bSYour Name  */
__qdf_nbuf_get_allocsize(struct sk_buff * skb)2869*5113495bSYour Name static inline unsigned int __qdf_nbuf_get_allocsize(struct sk_buff *skb)
2870*5113495bSYour Name {
2871*5113495bSYour Name 	return SKB_WITH_OVERHEAD(skb->truesize) -
2872*5113495bSYour Name 		SKB_DATA_ALIGN(sizeof(struct sk_buff));
2873*5113495bSYour Name }
2874*5113495bSYour Name 
2875*5113495bSYour Name #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
2876*5113495bSYour Name /**
2877*5113495bSYour Name  * __qdf_record_nbuf_nbytes() - add or subtract the size of the nbuf
2878*5113495bSYour Name  * from the total skb mem and DP tx/rx skb mem
2879*5113495bSYour Name  * @nbytes: number of bytes
2880*5113495bSYour Name  * @dir: direction
2881*5113495bSYour Name  * @is_mapped: is mapped or unmapped memory
2882*5113495bSYour Name  *
2883*5113495bSYour Name  * Return: none
2884*5113495bSYour Name  */
__qdf_record_nbuf_nbytes(int nbytes,qdf_dma_dir_t dir,bool is_mapped)2885*5113495bSYour Name static inline void __qdf_record_nbuf_nbytes(
2886*5113495bSYour Name 	int nbytes, qdf_dma_dir_t dir, bool is_mapped)
2887*5113495bSYour Name {
2888*5113495bSYour Name 	if (is_mapped) {
2889*5113495bSYour Name 		if (dir == QDF_DMA_TO_DEVICE) {
2890*5113495bSYour Name 			qdf_mem_dp_tx_skb_cnt_inc();
2891*5113495bSYour Name 			qdf_mem_dp_tx_skb_inc(nbytes);
2892*5113495bSYour Name 		} else if (dir == QDF_DMA_FROM_DEVICE) {
2893*5113495bSYour Name 			qdf_mem_dp_rx_skb_cnt_inc();
2894*5113495bSYour Name 			qdf_mem_dp_rx_skb_inc(nbytes);
2895*5113495bSYour Name 		}
2896*5113495bSYour Name 		qdf_mem_skb_total_inc(nbytes);
2897*5113495bSYour Name 	} else {
2898*5113495bSYour Name 		if (dir == QDF_DMA_TO_DEVICE) {
2899*5113495bSYour Name 			qdf_mem_dp_tx_skb_cnt_dec();
2900*5113495bSYour Name 			qdf_mem_dp_tx_skb_dec(nbytes);
2901*5113495bSYour Name 		} else if (dir == QDF_DMA_FROM_DEVICE) {
2902*5113495bSYour Name 			qdf_mem_dp_rx_skb_cnt_dec();
2903*5113495bSYour Name 			qdf_mem_dp_rx_skb_dec(nbytes);
2904*5113495bSYour Name 		}
2905*5113495bSYour Name 		qdf_mem_skb_total_dec(nbytes);
2906*5113495bSYour Name 	}
2907*5113495bSYour Name }
2908*5113495bSYour Name 
2909*5113495bSYour Name #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
__qdf_record_nbuf_nbytes(int nbytes,qdf_dma_dir_t dir,bool is_mapped)2910*5113495bSYour Name static inline void __qdf_record_nbuf_nbytes(
2911*5113495bSYour Name 	int nbytes, qdf_dma_dir_t dir, bool is_mapped)
2912*5113495bSYour Name {
2913*5113495bSYour Name }
2914*5113495bSYour Name #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
2915*5113495bSYour Name 
2916*5113495bSYour Name static inline struct sk_buff *
__qdf_nbuf_queue_head_dequeue(struct sk_buff_head * skb_queue_head)2917*5113495bSYour Name __qdf_nbuf_queue_head_dequeue(struct sk_buff_head *skb_queue_head)
2918*5113495bSYour Name {
2919*5113495bSYour Name 	return skb_dequeue(skb_queue_head);
2920*5113495bSYour Name }
2921*5113495bSYour Name 
2922*5113495bSYour Name static inline
__qdf_nbuf_queue_head_qlen(struct sk_buff_head * skb_queue_head)2923*5113495bSYour Name uint32_t __qdf_nbuf_queue_head_qlen(struct sk_buff_head *skb_queue_head)
2924*5113495bSYour Name {
2925*5113495bSYour Name 	return skb_queue_head->qlen;
2926*5113495bSYour Name }
2927*5113495bSYour Name 
2928*5113495bSYour Name static inline
__qdf_nbuf_queue_head_enqueue_tail(struct sk_buff_head * skb_queue_head,struct sk_buff * skb)2929*5113495bSYour Name void __qdf_nbuf_queue_head_enqueue_tail(struct sk_buff_head *skb_queue_head,
2930*5113495bSYour Name 					struct sk_buff *skb)
2931*5113495bSYour Name {
2932*5113495bSYour Name 	return skb_queue_tail(skb_queue_head, skb);
2933*5113495bSYour Name }
2934*5113495bSYour Name 
2935*5113495bSYour Name static inline
__qdf_nbuf_queue_head_init(struct sk_buff_head * skb_queue_head)2936*5113495bSYour Name void __qdf_nbuf_queue_head_init(struct sk_buff_head *skb_queue_head)
2937*5113495bSYour Name {
2938*5113495bSYour Name 	return skb_queue_head_init(skb_queue_head);
2939*5113495bSYour Name }
2940*5113495bSYour Name 
2941*5113495bSYour Name static inline
__qdf_nbuf_queue_head_purge(struct sk_buff_head * skb_queue_head)2942*5113495bSYour Name void __qdf_nbuf_queue_head_purge(struct sk_buff_head *skb_queue_head)
2943*5113495bSYour Name {
2944*5113495bSYour Name 	return skb_queue_purge(skb_queue_head);
2945*5113495bSYour Name }
2946*5113495bSYour Name 
2947*5113495bSYour Name static inline
__qdf_nbuf_queue_empty(__qdf_nbuf_queue_head_t * nbuf_queue_head)2948*5113495bSYour Name int __qdf_nbuf_queue_empty(__qdf_nbuf_queue_head_t *nbuf_queue_head)
2949*5113495bSYour Name {
2950*5113495bSYour Name 	return skb_queue_empty(nbuf_queue_head);
2951*5113495bSYour Name }
2952*5113495bSYour Name 
2953*5113495bSYour Name /**
2954*5113495bSYour Name  * __qdf_nbuf_queue_head_lock() - Acquire the skb list lock
2955*5113495bSYour Name  * @skb_queue_head: skb list for which lock is to be acquired
2956*5113495bSYour Name  *
2957*5113495bSYour Name  * Return: void
2958*5113495bSYour Name  */
2959*5113495bSYour Name static inline
__qdf_nbuf_queue_head_lock(struct sk_buff_head * skb_queue_head)2960*5113495bSYour Name void __qdf_nbuf_queue_head_lock(struct sk_buff_head *skb_queue_head)
2961*5113495bSYour Name {
2962*5113495bSYour Name 	spin_lock_bh(&skb_queue_head->lock);
2963*5113495bSYour Name }
2964*5113495bSYour Name 
2965*5113495bSYour Name /**
2966*5113495bSYour Name  * __qdf_nbuf_queue_head_unlock() - Release the skb list lock
2967*5113495bSYour Name  * @skb_queue_head: skb list for which lock is to be release
2968*5113495bSYour Name  *
2969*5113495bSYour Name  * Return: void
2970*5113495bSYour Name  */
2971*5113495bSYour Name static inline
__qdf_nbuf_queue_head_unlock(struct sk_buff_head * skb_queue_head)2972*5113495bSYour Name void __qdf_nbuf_queue_head_unlock(struct sk_buff_head *skb_queue_head)
2973*5113495bSYour Name {
2974*5113495bSYour Name 	spin_unlock_bh(&skb_queue_head->lock);
2975*5113495bSYour Name }
2976*5113495bSYour Name 
2977*5113495bSYour Name /**
2978*5113495bSYour Name  * __qdf_nbuf_get_frag_size_by_idx() - Get nbuf frag size at index idx
2979*5113495bSYour Name  * @nbuf: qdf_nbuf_t
2980*5113495bSYour Name  * @idx: Index for which frag size is requested
2981*5113495bSYour Name  *
2982*5113495bSYour Name  * Return: Frag size
2983*5113495bSYour Name  */
__qdf_nbuf_get_frag_size_by_idx(__qdf_nbuf_t nbuf,uint8_t idx)2984*5113495bSYour Name static inline unsigned int __qdf_nbuf_get_frag_size_by_idx(__qdf_nbuf_t nbuf,
2985*5113495bSYour Name 							   uint8_t idx)
2986*5113495bSYour Name {
2987*5113495bSYour Name 	unsigned int size = 0;
2988*5113495bSYour Name 
2989*5113495bSYour Name 	if (likely(idx < __QDF_NBUF_MAX_FRAGS))
2990*5113495bSYour Name 		size = skb_frag_size(&skb_shinfo(nbuf)->frags[idx]);
2991*5113495bSYour Name 	return size;
2992*5113495bSYour Name }
2993*5113495bSYour Name 
2994*5113495bSYour Name /**
2995*5113495bSYour Name  * __qdf_nbuf_get_frag_addr() - Get nbuf frag address at index idx
2996*5113495bSYour Name  * @nbuf: qdf_nbuf_t
2997*5113495bSYour Name  * @idx: Index for which frag address is requested
2998*5113495bSYour Name  *
2999*5113495bSYour Name  * Return: Frag address in success, else NULL
3000*5113495bSYour Name  */
__qdf_nbuf_get_frag_addr(__qdf_nbuf_t nbuf,uint8_t idx)3001*5113495bSYour Name static inline __qdf_frag_t __qdf_nbuf_get_frag_addr(__qdf_nbuf_t nbuf,
3002*5113495bSYour Name 						    uint8_t idx)
3003*5113495bSYour Name {
3004*5113495bSYour Name 	__qdf_frag_t frag_addr = NULL;
3005*5113495bSYour Name 
3006*5113495bSYour Name 	if (likely(idx < __QDF_NBUF_MAX_FRAGS))
3007*5113495bSYour Name 		frag_addr = skb_frag_address(&skb_shinfo(nbuf)->frags[idx]);
3008*5113495bSYour Name 	return frag_addr;
3009*5113495bSYour Name }
3010*5113495bSYour Name 
3011*5113495bSYour Name /**
3012*5113495bSYour Name  * __qdf_nbuf_trim_add_frag_size() - Increase/Decrease frag_size by size
3013*5113495bSYour Name  * @nbuf: qdf_nbuf_t
3014*5113495bSYour Name  * @idx: Frag index
3015*5113495bSYour Name  * @size: Size by which frag_size needs to be increased/decreased
3016*5113495bSYour Name  *        +Ve means increase, -Ve means decrease
3017*5113495bSYour Name  * @truesize: truesize
3018*5113495bSYour Name  */
__qdf_nbuf_trim_add_frag_size(__qdf_nbuf_t nbuf,uint8_t idx,int size,unsigned int truesize)3019*5113495bSYour Name static inline void __qdf_nbuf_trim_add_frag_size(__qdf_nbuf_t nbuf, uint8_t idx,
3020*5113495bSYour Name 						 int size,
3021*5113495bSYour Name 						 unsigned int truesize)
3022*5113495bSYour Name {
3023*5113495bSYour Name 	skb_coalesce_rx_frag(nbuf, idx, size, truesize);
3024*5113495bSYour Name }
3025*5113495bSYour Name 
3026*5113495bSYour Name /**
3027*5113495bSYour Name  * __qdf_nbuf_move_frag_page_offset() - Move frag page_offset by size
3028*5113495bSYour Name  *          and adjust length by size.
3029*5113495bSYour Name  * @nbuf: qdf_nbuf_t
3030*5113495bSYour Name  * @idx: Frag index
3031*5113495bSYour Name  * @offset: Frag page offset should be moved by offset.
3032*5113495bSYour Name  *      +Ve - Move offset forward.
3033*5113495bSYour Name  *      -Ve - Move offset backward.
3034*5113495bSYour Name  *
3035*5113495bSYour Name  * Return: QDF_STATUS
3036*5113495bSYour Name  */
3037*5113495bSYour Name QDF_STATUS __qdf_nbuf_move_frag_page_offset(__qdf_nbuf_t nbuf, uint8_t idx,
3038*5113495bSYour Name 					    int offset);
3039*5113495bSYour Name 
3040*5113495bSYour Name /**
3041*5113495bSYour Name  * __qdf_nbuf_remove_frag() - Remove frag from nbuf
3042*5113495bSYour Name  * @nbuf: nbuf pointer
3043*5113495bSYour Name  * @idx: frag idx need to be removed
3044*5113495bSYour Name  * @truesize: truesize of frag
3045*5113495bSYour Name  *
3046*5113495bSYour Name  * Return : void
3047*5113495bSYour Name  */
3048*5113495bSYour Name void __qdf_nbuf_remove_frag(__qdf_nbuf_t nbuf, uint16_t idx, uint16_t truesize);
3049*5113495bSYour Name /**
3050*5113495bSYour Name  * __qdf_nbuf_add_rx_frag() - Add frag to nbuf at nr_frag index
3051*5113495bSYour Name  * @buf: Frag pointer needs to be added in nbuf frag
3052*5113495bSYour Name  * @nbuf: qdf_nbuf_t where frag will be added
3053*5113495bSYour Name  * @offset: Offset in frag to be added to nbuf_frags
3054*5113495bSYour Name  * @frag_len: Frag length
3055*5113495bSYour Name  * @truesize: truesize
3056*5113495bSYour Name  * @take_frag_ref: Whether to take ref for frag or not
3057*5113495bSYour Name  *      This bool must be set as per below comdition:
3058*5113495bSYour Name  *      1. False: If this frag is being added in any nbuf
3059*5113495bSYour Name  *              for the first time after allocation.
3060*5113495bSYour Name  *      2. True: If frag is already attached part of any
3061*5113495bSYour Name  *              nbuf.
3062*5113495bSYour Name  *
3063*5113495bSYour Name  * It takes ref_count based on boolean flag take_frag_ref
3064*5113495bSYour Name  */
3065*5113495bSYour Name void __qdf_nbuf_add_rx_frag(__qdf_frag_t buf, __qdf_nbuf_t nbuf,
3066*5113495bSYour Name 			    int offset, int frag_len,
3067*5113495bSYour Name 			    unsigned int truesize, bool take_frag_ref);
3068*5113495bSYour Name 
3069*5113495bSYour Name /**
3070*5113495bSYour Name  * __qdf_nbuf_ref_frag() - get frag reference
3071*5113495bSYour Name  * @buf: Pointer to nbuf
3072*5113495bSYour Name  *
3073*5113495bSYour Name  * Return: void
3074*5113495bSYour Name  */
3075*5113495bSYour Name void __qdf_nbuf_ref_frag(qdf_frag_t buf);
3076*5113495bSYour Name 
3077*5113495bSYour Name /**
3078*5113495bSYour Name  * __qdf_nbuf_set_mark() - Set nbuf mark
3079*5113495bSYour Name  * @buf: Pointer to nbuf
3080*5113495bSYour Name  * @mark: Value to set mark
3081*5113495bSYour Name  *
3082*5113495bSYour Name  * Return: None
3083*5113495bSYour Name  */
__qdf_nbuf_set_mark(__qdf_nbuf_t buf,uint32_t mark)3084*5113495bSYour Name static inline void __qdf_nbuf_set_mark(__qdf_nbuf_t buf, uint32_t mark)
3085*5113495bSYour Name {
3086*5113495bSYour Name 	buf->mark = mark;
3087*5113495bSYour Name }
3088*5113495bSYour Name 
3089*5113495bSYour Name /**
3090*5113495bSYour Name  * __qdf_nbuf_get_mark() - Get nbuf mark
3091*5113495bSYour Name  * @buf: Pointer to nbuf
3092*5113495bSYour Name  *
3093*5113495bSYour Name  * Return: Value of mark
3094*5113495bSYour Name  */
__qdf_nbuf_get_mark(__qdf_nbuf_t buf)3095*5113495bSYour Name static inline uint32_t __qdf_nbuf_get_mark(__qdf_nbuf_t buf)
3096*5113495bSYour Name {
3097*5113495bSYour Name 	return buf->mark;
3098*5113495bSYour Name }
3099*5113495bSYour Name 
3100*5113495bSYour Name /**
3101*5113495bSYour Name  * __qdf_nbuf_get_data_len() - Return the size of the nbuf from
3102*5113495bSYour Name  * the data pointer to the end pointer
3103*5113495bSYour Name  * @nbuf: qdf_nbuf_t
3104*5113495bSYour Name  *
3105*5113495bSYour Name  * Return: size of skb from data pointer to end pointer
3106*5113495bSYour Name  */
__qdf_nbuf_get_data_len(__qdf_nbuf_t nbuf)3107*5113495bSYour Name static inline qdf_size_t __qdf_nbuf_get_data_len(__qdf_nbuf_t nbuf)
3108*5113495bSYour Name {
3109*5113495bSYour Name 	return (skb_end_pointer(nbuf) - nbuf->data);
3110*5113495bSYour Name }
3111*5113495bSYour Name 
3112*5113495bSYour Name /**
3113*5113495bSYour Name  * __qdf_nbuf_set_data_len() - Return the data_len of the nbuf
3114*5113495bSYour Name  * @nbuf: qdf_nbuf_t
3115*5113495bSYour Name  * @len: data_len to be set
3116*5113495bSYour Name  *
3117*5113495bSYour Name  * Return: value of data_len
3118*5113495bSYour Name  */
3119*5113495bSYour Name static inline
__qdf_nbuf_set_data_len(__qdf_nbuf_t nbuf,uint32_t len)3120*5113495bSYour Name qdf_size_t __qdf_nbuf_set_data_len(__qdf_nbuf_t nbuf, uint32_t len)
3121*5113495bSYour Name {
3122*5113495bSYour Name 	return nbuf->data_len = len;
3123*5113495bSYour Name }
3124*5113495bSYour Name 
3125*5113495bSYour Name /**
3126*5113495bSYour Name  * __qdf_nbuf_get_only_data_len() - Return the data_len of the nbuf
3127*5113495bSYour Name  * @nbuf: qdf_nbuf_t
3128*5113495bSYour Name  *
3129*5113495bSYour Name  * Return: value of data_len
3130*5113495bSYour Name  */
__qdf_nbuf_get_only_data_len(__qdf_nbuf_t nbuf)3131*5113495bSYour Name static inline qdf_size_t __qdf_nbuf_get_only_data_len(__qdf_nbuf_t nbuf)
3132*5113495bSYour Name {
3133*5113495bSYour Name 	return nbuf->data_len;
3134*5113495bSYour Name }
3135*5113495bSYour Name 
3136*5113495bSYour Name /**
3137*5113495bSYour Name  * __qdf_nbuf_set_hash() - set the hash of the buf
3138*5113495bSYour Name  * @buf: Network buf instance
3139*5113495bSYour Name  * @len: len to be set
3140*5113495bSYour Name  *
3141*5113495bSYour Name  * Return: None
3142*5113495bSYour Name  */
__qdf_nbuf_set_hash(__qdf_nbuf_t buf,uint32_t len)3143*5113495bSYour Name static inline void __qdf_nbuf_set_hash(__qdf_nbuf_t buf, uint32_t len)
3144*5113495bSYour Name {
3145*5113495bSYour Name 	buf->hash = len;
3146*5113495bSYour Name }
3147*5113495bSYour Name 
3148*5113495bSYour Name /**
3149*5113495bSYour Name  * __qdf_nbuf_set_sw_hash() - set the sw hash of the buf
3150*5113495bSYour Name  * @buf: Network buf instance
3151*5113495bSYour Name  * @len: len to be set
3152*5113495bSYour Name  *
3153*5113495bSYour Name  * Return: None
3154*5113495bSYour Name  */
__qdf_nbuf_set_sw_hash(__qdf_nbuf_t buf,uint32_t len)3155*5113495bSYour Name static inline void __qdf_nbuf_set_sw_hash(__qdf_nbuf_t buf, uint32_t len)
3156*5113495bSYour Name {
3157*5113495bSYour Name 	buf->sw_hash = len;
3158*5113495bSYour Name }
3159*5113495bSYour Name 
3160*5113495bSYour Name /**
3161*5113495bSYour Name  * __qdf_nbuf_set_csum_start() - set the csum start of the buf
3162*5113495bSYour Name  * @buf: Network buf instance
3163*5113495bSYour Name  * @len: len to be set
3164*5113495bSYour Name  *
3165*5113495bSYour Name  * Return: None
3166*5113495bSYour Name  */
__qdf_nbuf_set_csum_start(__qdf_nbuf_t buf,uint16_t len)3167*5113495bSYour Name static inline void __qdf_nbuf_set_csum_start(__qdf_nbuf_t buf, uint16_t len)
3168*5113495bSYour Name {
3169*5113495bSYour Name 	buf->csum_start = len;
3170*5113495bSYour Name }
3171*5113495bSYour Name 
3172*5113495bSYour Name /**
3173*5113495bSYour Name  * __qdf_nbuf_set_csum_offset() - set the csum offset of the buf
3174*5113495bSYour Name  * @buf: Network buf instance
3175*5113495bSYour Name  * @len: len to be set
3176*5113495bSYour Name  *
3177*5113495bSYour Name  * Return: None
3178*5113495bSYour Name  */
__qdf_nbuf_set_csum_offset(__qdf_nbuf_t buf,uint16_t len)3179*5113495bSYour Name static inline void __qdf_nbuf_set_csum_offset(__qdf_nbuf_t buf, uint16_t len)
3180*5113495bSYour Name {
3181*5113495bSYour Name 	buf->csum_offset = len;
3182*5113495bSYour Name }
3183*5113495bSYour Name 
3184*5113495bSYour Name /**
3185*5113495bSYour Name  * __qdf_nbuf_get_gso_segs() - Return the number of gso segments
3186*5113495bSYour Name  * @skb: Pointer to network buffer
3187*5113495bSYour Name  *
3188*5113495bSYour Name  * Return: Return the number of gso segments
3189*5113495bSYour Name  */
__qdf_nbuf_get_gso_segs(struct sk_buff * skb)3190*5113495bSYour Name static inline uint16_t __qdf_nbuf_get_gso_segs(struct sk_buff *skb)
3191*5113495bSYour Name {
3192*5113495bSYour Name 	return skb_shinfo(skb)->gso_segs;
3193*5113495bSYour Name }
3194*5113495bSYour Name 
3195*5113495bSYour Name /**
3196*5113495bSYour Name  * __qdf_nbuf_set_gso_segs() - set the number of gso segments
3197*5113495bSYour Name  * @skb: Pointer to network buffer
3198*5113495bSYour Name  * @val: val to be set
3199*5113495bSYour Name  *
3200*5113495bSYour Name  * Return: None
3201*5113495bSYour Name  */
__qdf_nbuf_set_gso_segs(struct sk_buff * skb,uint16_t val)3202*5113495bSYour Name static inline void __qdf_nbuf_set_gso_segs(struct sk_buff *skb, uint16_t val)
3203*5113495bSYour Name {
3204*5113495bSYour Name 	skb_shinfo(skb)->gso_segs = val;
3205*5113495bSYour Name }
3206*5113495bSYour Name 
3207*5113495bSYour Name /**
3208*5113495bSYour Name  * __qdf_nbuf_set_gso_type_udp_l4() - set the gso type to GSO UDP L4
3209*5113495bSYour Name  * @skb: Pointer to network buffer
3210*5113495bSYour Name  *
3211*5113495bSYour Name  * Return: None
3212*5113495bSYour Name  */
__qdf_nbuf_set_gso_type_udp_l4(struct sk_buff * skb)3213*5113495bSYour Name static inline void __qdf_nbuf_set_gso_type_udp_l4(struct sk_buff *skb)
3214*5113495bSYour Name {
3215*5113495bSYour Name 	skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
3216*5113495bSYour Name }
3217*5113495bSYour Name 
3218*5113495bSYour Name /**
3219*5113495bSYour Name  * __qdf_nbuf_set_ip_summed_partial() - set the ip summed to CHECKSUM_PARTIAL
3220*5113495bSYour Name  * @skb: Pointer to network buffer
3221*5113495bSYour Name  *
3222*5113495bSYour Name  * Return: None
3223*5113495bSYour Name  */
__qdf_nbuf_set_ip_summed_partial(struct sk_buff * skb)3224*5113495bSYour Name static inline void __qdf_nbuf_set_ip_summed_partial(struct sk_buff *skb)
3225*5113495bSYour Name {
3226*5113495bSYour Name 	skb->ip_summed = CHECKSUM_PARTIAL;
3227*5113495bSYour Name }
3228*5113495bSYour Name 
3229*5113495bSYour Name /**
3230*5113495bSYour Name  * __qdf_nbuf_get_gso_size() - Return the number of gso size
3231*5113495bSYour Name  * @skb: Pointer to network buffer
3232*5113495bSYour Name  *
3233*5113495bSYour Name  * Return: Return the number of gso segments
3234*5113495bSYour Name  */
__qdf_nbuf_get_gso_size(struct sk_buff * skb)3235*5113495bSYour Name static inline unsigned int __qdf_nbuf_get_gso_size(struct sk_buff *skb)
3236*5113495bSYour Name {
3237*5113495bSYour Name 	return skb_shinfo(skb)->gso_size;
3238*5113495bSYour Name }
3239*5113495bSYour Name 
3240*5113495bSYour Name /**
3241*5113495bSYour Name  * __qdf_nbuf_set_gso_size() - Set the gso size in nbuf
3242*5113495bSYour Name  * @skb: Pointer to network buffer
3243*5113495bSYour Name  * @val: the number of GSO segments
3244*5113495bSYour Name  *
3245*5113495bSYour Name  * Return: None
3246*5113495bSYour Name  */
3247*5113495bSYour Name static inline void
__qdf_nbuf_set_gso_size(struct sk_buff * skb,unsigned int val)3248*5113495bSYour Name __qdf_nbuf_set_gso_size(struct sk_buff *skb, unsigned int val)
3249*5113495bSYour Name {
3250*5113495bSYour Name 	skb_shinfo(skb)->gso_size = val;
3251*5113495bSYour Name }
3252*5113495bSYour Name 
3253*5113495bSYour Name /**
3254*5113495bSYour Name  * __qdf_nbuf_kfree() - Free nbuf using kfree
3255*5113495bSYour Name  * @skb: Pointer to network buffer
3256*5113495bSYour Name  *
3257*5113495bSYour Name  * This function is called to free the skb on failure cases
3258*5113495bSYour Name  *
3259*5113495bSYour Name  * Return: None
3260*5113495bSYour Name  */
__qdf_nbuf_kfree(struct sk_buff * skb)3261*5113495bSYour Name static inline void __qdf_nbuf_kfree(struct sk_buff *skb)
3262*5113495bSYour Name {
3263*5113495bSYour Name 	kfree_skb(skb);
3264*5113495bSYour Name }
3265*5113495bSYour Name 
3266*5113495bSYour Name /**
3267*5113495bSYour Name  * __qdf_nbuf_dev_kfree_list() - Free nbuf list using dev based os call
3268*5113495bSYour Name  * @nbuf_queue_head: Pointer to nbuf queue head
3269*5113495bSYour Name  *
3270*5113495bSYour Name  * This function is called to free the nbuf list on failure cases
3271*5113495bSYour Name  *
3272*5113495bSYour Name  * Return: None
3273*5113495bSYour Name  */
3274*5113495bSYour Name void
3275*5113495bSYour Name __qdf_nbuf_dev_kfree_list(__qdf_nbuf_queue_head_t *nbuf_queue_head);
3276*5113495bSYour Name 
3277*5113495bSYour Name /**
3278*5113495bSYour Name  * __qdf_nbuf_dev_queue_head() - queue a buffer using dev at the list head
3279*5113495bSYour Name  * @nbuf_queue_head: Pointer to skb list head
3280*5113495bSYour Name  * @buff: Pointer to nbuf
3281*5113495bSYour Name  *
3282*5113495bSYour Name  * This function is called to queue buffer at the skb list head
3283*5113495bSYour Name  *
3284*5113495bSYour Name  * Return: None
3285*5113495bSYour Name  */
3286*5113495bSYour Name static inline void
__qdf_nbuf_dev_queue_head(__qdf_nbuf_queue_head_t * nbuf_queue_head,__qdf_nbuf_t buff)3287*5113495bSYour Name __qdf_nbuf_dev_queue_head(__qdf_nbuf_queue_head_t *nbuf_queue_head,
3288*5113495bSYour Name 			  __qdf_nbuf_t buff)
3289*5113495bSYour Name {
3290*5113495bSYour Name 	 __skb_queue_head(nbuf_queue_head, buff);
3291*5113495bSYour Name }
3292*5113495bSYour Name 
3293*5113495bSYour Name /**
3294*5113495bSYour Name  * __qdf_nbuf_dev_kfree() - Free nbuf using dev based os call
3295*5113495bSYour Name  * @skb: Pointer to network buffer
3296*5113495bSYour Name  *
3297*5113495bSYour Name  * This function is called to free the skb on failure cases
3298*5113495bSYour Name  *
3299*5113495bSYour Name  * Return: None
3300*5113495bSYour Name  */
__qdf_nbuf_dev_kfree(struct sk_buff * skb)3301*5113495bSYour Name static inline void __qdf_nbuf_dev_kfree(struct sk_buff *skb)
3302*5113495bSYour Name {
3303*5113495bSYour Name 	dev_kfree_skb(skb);
3304*5113495bSYour Name }
3305*5113495bSYour Name 
3306*5113495bSYour Name /**
3307*5113495bSYour Name  * __qdf_nbuf_pkt_type_is_mcast() - check if skb pkt type is mcast
3308*5113495bSYour Name  * @skb: Network buffer
3309*5113495bSYour Name  *
3310*5113495bSYour Name  * Return: TRUE if skb pkt type is mcast
3311*5113495bSYour Name  *         FALSE if not
3312*5113495bSYour Name  */
3313*5113495bSYour Name static inline
__qdf_nbuf_pkt_type_is_mcast(struct sk_buff * skb)3314*5113495bSYour Name bool __qdf_nbuf_pkt_type_is_mcast(struct sk_buff *skb)
3315*5113495bSYour Name {
3316*5113495bSYour Name 	return skb->pkt_type == PACKET_MULTICAST;
3317*5113495bSYour Name }
3318*5113495bSYour Name 
3319*5113495bSYour Name /**
3320*5113495bSYour Name  * __qdf_nbuf_pkt_type_is_bcast() - check if skb pkt type is bcast
3321*5113495bSYour Name  * @skb: Network buffer
3322*5113495bSYour Name  *
3323*5113495bSYour Name  * Return: TRUE if skb pkt type is mcast
3324*5113495bSYour Name  *         FALSE if not
3325*5113495bSYour Name  */
3326*5113495bSYour Name static inline
__qdf_nbuf_pkt_type_is_bcast(struct sk_buff * skb)3327*5113495bSYour Name bool __qdf_nbuf_pkt_type_is_bcast(struct sk_buff *skb)
3328*5113495bSYour Name {
3329*5113495bSYour Name 	return skb->pkt_type == PACKET_BROADCAST;
3330*5113495bSYour Name }
3331*5113495bSYour Name 
3332*5113495bSYour Name /**
3333*5113495bSYour Name  * __qdf_nbuf_set_dev() - set dev of network buffer
3334*5113495bSYour Name  * @skb: Pointer to network buffer
3335*5113495bSYour Name  * @dev: value to be set in dev of network buffer
3336*5113495bSYour Name  *
3337*5113495bSYour Name  * Return: void
3338*5113495bSYour Name  */
3339*5113495bSYour Name static inline
__qdf_nbuf_set_dev(struct sk_buff * skb,struct net_device * dev)3340*5113495bSYour Name void __qdf_nbuf_set_dev(struct sk_buff *skb, struct net_device *dev)
3341*5113495bSYour Name {
3342*5113495bSYour Name 	skb->dev = dev;
3343*5113495bSYour Name }
3344*5113495bSYour Name 
3345*5113495bSYour Name /**
3346*5113495bSYour Name  * __qdf_nbuf_get_dev_mtu() - get dev mtu in n/w buffer
3347*5113495bSYour Name  * @skb: Pointer to network buffer
3348*5113495bSYour Name  *
3349*5113495bSYour Name  * Return: dev mtu value in nbuf
3350*5113495bSYour Name  */
3351*5113495bSYour Name static inline
__qdf_nbuf_get_dev_mtu(struct sk_buff * skb)3352*5113495bSYour Name unsigned int __qdf_nbuf_get_dev_mtu(struct sk_buff *skb)
3353*5113495bSYour Name {
3354*5113495bSYour Name 	return skb->dev->mtu;
3355*5113495bSYour Name }
3356*5113495bSYour Name 
3357*5113495bSYour Name /**
3358*5113495bSYour Name  * __qdf_nbuf_set_protocol_eth_type_trans() - set protocol using eth trans
3359*5113495bSYour Name  *                                            os API
3360*5113495bSYour Name  * @skb: Pointer to network buffer
3361*5113495bSYour Name  *
3362*5113495bSYour Name  * Return: None
3363*5113495bSYour Name  */
3364*5113495bSYour Name static inline
__qdf_nbuf_set_protocol_eth_type_trans(struct sk_buff * skb)3365*5113495bSYour Name void __qdf_nbuf_set_protocol_eth_type_trans(struct sk_buff *skb)
3366*5113495bSYour Name {
3367*5113495bSYour Name 	skb->protocol = eth_type_trans(skb, skb->dev);
3368*5113495bSYour Name }
3369*5113495bSYour Name 
3370*5113495bSYour Name /**
3371*5113495bSYour Name  * __qdf_nbuf_net_timedelta() - get time delta
3372*5113495bSYour Name  * @t: time as __qdf_ktime_t object
3373*5113495bSYour Name  *
3374*5113495bSYour Name  * Return: time delta as ktime_t object
3375*5113495bSYour Name  */
__qdf_nbuf_net_timedelta(qdf_ktime_t t)3376*5113495bSYour Name static inline qdf_ktime_t __qdf_nbuf_net_timedelta(qdf_ktime_t t)
3377*5113495bSYour Name {
3378*5113495bSYour Name 	return net_timedelta(t);
3379*5113495bSYour Name }
3380*5113495bSYour Name 
3381*5113495bSYour Name #ifdef CONFIG_NBUF_AP_PLATFORM
3382*5113495bSYour Name #include <i_qdf_nbuf_w.h>
3383*5113495bSYour Name #else
3384*5113495bSYour Name #include <i_qdf_nbuf_m.h>
3385*5113495bSYour Name #endif
3386*5113495bSYour Name #endif /*_I_QDF_NET_BUF_H */
3387