xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_w.h (revision 1f55ed1a9f5050d8da228aa8dd3fff7c0242aa71)
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_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 /**
76  * qdf_nbuf_cb_update_peer_local_id() - update peer local id in skb cb
77  * @skb: skb pointer whose cb is updated with peer local id information
78  * @peer_local_id: peer local id to be update in cb
79  *
80  * Return: void
81  */
82 static inline void qdf_nbuf_cb_update_peer_local_id(struct sk_buff *skb,
83 						    uint16_t peer_local_id)
84 {
85 	/* Does not apply to WIN */
86 }
87 
88 /**
89  * __qdf_nbuf_push_head() - Push data in the front
90  * @skb: Pointer to network buffer
91  * @size: size to be pushed
92  *
93  * Return: New data pointer of this buf after data has been pushed,
94  *         or NULL if there is not enough room in this buf.
95  */
96 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
97 {
98 	return skb_push(skb, size);
99 }
100 
101 /**
102  * __qdf_nbuf_pull_head() - pull data out from the front
103  * @skb: Pointer to network buffer
104  * @size: size to be popped
105  *
106  * Return: New data pointer of this buf after data has been popped,
107  * or NULL if there is not sufficient data to pull.
108  */
109 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
110 {
111 	return skb_pull(skb, size);
112 }
113 
114 static inline void qdf_nbuf_init_replenish_timer(void) {}
115 static inline void qdf_nbuf_deinit_replenish_timer(void) {}
116 
117 #endif /*_I_QDF_NBUF_W_H */
118