xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_w.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
1 /*
2  * Copyright (c) 2014-2019 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_CB_RX_PEER_ID(skb) \
52 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_w.peer_id)
53 
54 #define QDF_NBUF_CB_RX_PKT_LEN(skb) \
55 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_w.msdu_len)
56 
57 #define __qdf_nbuf_set_rx_fctx_type(skb, ctx, type) \
58 	do { \
59 		QDF_NBUF_CB_RX_FCTX((skb)) = (ctx); \
60 		QDF_NBUF_CB_RX_FTYPE((skb)) = (type); \
61 	} while (0)
62 
63 #define __qdf_nbuf_get_rx_fctx(skb) \
64 		 QDF_NBUF_CB_RX_FCTX((skb))
65 
66 #define __qdf_nbuf_set_tx_fctx_type(skb, ctx, type) \
67 	do { \
68 		QDF_NBUF_CB_TX_FCTX((skb)) = (ctx); \
69 		QDF_NBUF_CB_TX_FTYPE((skb)) = (type); \
70 	} while (0)
71 
72 #define __qdf_nbuf_get_tx_fctx(skb) \
73 		 QDF_NBUF_CB_TX_FCTX((skb))
74 
75 #define QDF_NBUF_CB_RX_PROTOCOL_TAG(skb) \
76 		(((struct qdf_nbuf_cb *) \
77 		((skb)->cb))->u.rx.dev.priv_cb_w.protocol_tag)
78 
79 #define __qdf_nbuf_set_rx_protocol_tag(skb, val) \
80 		((QDF_NBUF_CB_RX_PROTOCOL_TAG((skb))) = val)
81 
82 #define __qdf_nbuf_get_rx_protocol_tag(skb) \
83 		(QDF_NBUF_CB_RX_PROTOCOL_TAG((skb)))
84 
85 /**
86  * qdf_nbuf_cb_update_peer_local_id() - update peer local id in skb cb
87  * @skb: skb pointer whose cb is updated with peer local id information
88  * @peer_local_id: peer local id to be update in cb
89  *
90  * Return: void
91  */
92 static inline void qdf_nbuf_cb_update_peer_local_id(struct sk_buff *skb,
93 						    uint16_t peer_local_id)
94 {
95 	/* Does not apply to WIN */
96 }
97 
98 /**
99  * __qdf_nbuf_push_head() - Push data in the front
100  * @skb: Pointer to network buffer
101  * @size: size to be pushed
102  *
103  * Return: New data pointer of this buf after data has been pushed,
104  *         or NULL if there is not enough room in this buf.
105  */
106 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
107 {
108 	return skb_push(skb, size);
109 }
110 
111 /**
112  * __qdf_nbuf_pull_head() - pull data out from the front
113  * @skb: Pointer to network buffer
114  * @size: size to be popped
115  *
116  * Return: New data pointer of this buf after data has been popped,
117  * or NULL if there is not sufficient data to pull.
118  */
119 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
120 {
121 	return skb_pull(skb, size);
122 }
123 
124 static inline void qdf_nbuf_init_replenish_timer(void) {}
125 static inline void qdf_nbuf_deinit_replenish_timer(void) {}
126 
127 #endif /*_I_QDF_NBUF_W_H */
128