xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_w.h (revision 11f5a63a6cbdda84849a730de22f0a71e635d58c)
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 #define QDF_NBUF_CB_RX_FLOW_TAG(skb) \
86 		(((struct qdf_nbuf_cb *) \
87 		((skb)->cb))->u.rx.dev.priv_cb_w.flow_tag)
88 
89 #define __qdf_nbuf_set_rx_flow_tag(skb, val) \
90 		((QDF_NBUF_CB_RX_FLOW_TAG((skb))) = val)
91 
92 #define __qdf_nbuf_get_rx_flow_tag(skb) \
93 		(QDF_NBUF_CB_RX_FLOW_TAG((skb)))
94 
95 /**
96  * qdf_nbuf_cb_update_vdev_id() - update vdev id in skb cb
97  * @skb: skb pointer whose cb is updated with vdev id information
98  * @vdev_id: vdev id to be updated in cb
99  *
100  * Return: void
101  */
102 static inline void
103 qdf_nbuf_cb_update_vdev_id(struct sk_buff *skb, uint8_t vdev_id)
104 {
105 	/* Does not apply to WIN */
106 }
107 
108 /**
109  * __qdf_nbuf_push_head() - Push data in the front
110  * @skb: Pointer to network buffer
111  * @size: size to be pushed
112  *
113  * Return: New data pointer of this buf after data has been pushed,
114  *         or NULL if there is not enough room in this buf.
115  */
116 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
117 {
118 	return skb_push(skb, size);
119 }
120 
121 /**
122  * __qdf_nbuf_pull_head() - pull data out from the front
123  * @skb: Pointer to network buffer
124  * @size: size to be popped
125  *
126  * Return: New data pointer of this buf after data has been popped,
127  * or NULL if there is not sufficient data to pull.
128  */
129 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
130 {
131 	return skb_pull(skb, size);
132 }
133 
134 static inline void qdf_nbuf_init_replenish_timer(void) {}
135 static inline void qdf_nbuf_deinit_replenish_timer(void) {}
136 
137 #endif /*_I_QDF_NBUF_W_H */
138