xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_w.h (revision 302a1d9701784af5f4797b1a9fe07ae820b51907)
1 /*
2  * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: i_qdf_nbuf_w.h
21  *
22  * This file provides platform specific nbuf API's.
23  * Included by i_qdf_nbuf.h and should not be included
24  * directly from other files.
25  */
26 
27 #ifndef _I_QDF_NBUF_W_H
28 #define _I_QDF_NBUF_W_H
29 
30 /* ext_cb accesor macros and internal API's */
31 
32 #define QDF_NBUF_CB_EXT_CB(skb) \
33 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_w.ext_cb_ptr)
34 
35 #define __qdf_nbuf_set_ext_cb(skb, ref) \
36 	do { \
37 		QDF_NBUF_CB_EXT_CB((skb)) = (ref); \
38 	} while (0)
39 
40 #define __qdf_nbuf_get_ext_cb(skb) \
41 	QDF_NBUF_CB_EXT_CB((skb))
42 
43 /* fctx accesor macros and internal API's*/
44 
45 #define QDF_NBUF_CB_RX_FCTX(skb) \
46 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_w.fctx)
47 
48 #define QDF_NBUF_CB_TX_FCTX(skb) \
49 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_w.fctx)
50 
51 #define __qdf_nbuf_set_rx_fctx_type(skb, ctx, type) \
52 	do { \
53 		QDF_NBUF_CB_RX_FCTX((skb)) = (ctx); \
54 		QDF_NBUF_CB_RX_FTYPE((skb)) = (type); \
55 	} while (0)
56 
57 #define __qdf_nbuf_get_rx_fctx(skb) \
58 		 QDF_NBUF_CB_RX_FCTX((skb))
59 
60 #define __qdf_nbuf_set_tx_fctx_type(skb, ctx, type) \
61 	do { \
62 		QDF_NBUF_CB_TX_FCTX((skb)) = (ctx); \
63 		QDF_NBUF_CB_TX_FTYPE((skb)) = (type); \
64 	} while (0)
65 
66 #define __qdf_nbuf_get_tx_fctx(skb) \
67 		 QDF_NBUF_CB_TX_FCTX((skb))
68 
69 /**
70  * qdf_nbuf_cb_update_peer_local_id() - update peer local id in skb cb
71  * @skb: skb pointer whose cb is updated with peer local id information
72  * @peer_local_id: peer local id to be update in cb
73  *
74  * Return: void
75  */
76 static inline void qdf_nbuf_cb_update_peer_local_id(struct sk_buff *skb,
77 						    uint32_t peer_local_id)
78 {
79 	/* Does not apply to WIN */
80 }
81 
82 /**
83  * __qdf_nbuf_push_head() - Push data in the front
84  * @skb: Pointer to network buffer
85  * @size: size to be pushed
86  *
87  * Return: New data pointer of this buf after data has been pushed,
88  *         or NULL if there is not enough room in this buf.
89  */
90 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
91 {
92 	return skb_push(skb, size);
93 }
94 
95 /**
96  * __qdf_nbuf_pull_head() - pull data out from the front
97  * @skb: Pointer to network buffer
98  * @size: size to be popped
99  *
100  * Return: New data pointer of this buf after data has been popped,
101  * or NULL if there is not sufficient data to pull.
102  */
103 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
104 {
105 	return skb_pull(skb, size);
106 }
107 
108 static inline void qdf_nbuf_init_replenish_timer(void) {}
109 static inline void qdf_nbuf_deinit_replenish_timer(void) {}
110 
111 #endif /*_I_QDF_NBUF_W_H */
112