xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_m.h (revision 503663c6daafffe652fa360bde17243568cd6d2a)
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_m.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_M_H
28 #define _I_QDF_NBUF_M_H
29 
30 #define QDF_NBUF_CB_RX_TCP_SEQ_NUM(skb) \
31 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.tcp_seq_num)
32 #define QDF_NBUF_CB_RX_TCP_ACK_NUM(skb) \
33 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.tcp_ack_num)
34 #define QDF_NBUF_CB_RX_LRO_CTX(skb) \
35 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.lro_ctx)
36 
37 #define QDF_NBUF_CB_TX_IPA_OWNED(skb) \
38 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.ipa.owned)
39 #define QDF_NBUF_CB_TX_IPA_PRIV(skb) \
40 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.ipa.priv)
41 #define QDF_NBUF_CB_TX_DESC_ID(skb)\
42 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.desc_id)
43 #define QDF_NBUF_CB_MGMT_TXRX_DESC_ID(skb)\
44 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.mgmt_desc_id)
45 #define QDF_NBUF_CB_TX_DMA_BI_MAP(skb) \
46 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m. \
47 	dma_option.bi_map)
48 
49 #define QDF_NBUF_CB_RX_PEER_ID(skb) \
50 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \
51 	wifi3.peer_id)
52 
53 #define QDF_NBUF_CB_RX_PKT_LEN(skb) \
54 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \
55 	wifi3.msdu_len)
56 
57 #define QDF_NBUF_CB_RX_MAP_IDX(skb) \
58 	(((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \
59 	wifi2.map_index)
60 
61 #define  QDF_NBUF_CB_RX_PEER_CACHED_FRM(skb) \
62 	 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \
63 	 peer_cached_buf_frm)
64 
65 #define  QDF_NBUF_CB_RX_FLUSH_IND(skb) \
66 	 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.flush_ind)
67 
68 #define  QDF_NBUF_CB_RX_PACKET_BUFF_POOL(skb) \
69 	 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \
70 	 packet_buf_pool)
71 
72 #define __qdf_nbuf_ipa_owned_get(skb) \
73 	QDF_NBUF_CB_TX_IPA_OWNED(skb)
74 
75 #define __qdf_nbuf_ipa_owned_set(skb) \
76 	(QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1)
77 
78 #define __qdf_nbuf_ipa_owned_clear(skb) \
79 	(QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0)
80 
81 #define __qdf_nbuf_ipa_priv_get(skb)	\
82 	QDF_NBUF_CB_TX_IPA_PRIV(skb)
83 
84 #define __qdf_nbuf_ipa_priv_set(skb, priv) \
85 	(QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv))
86 
87 /**
88  * qdf_nbuf_cb_update_vdev_id() - update vdev id in skb cb
89  * @skb: skb pointer whose cb is updated with vdev id information
90  * @vdev_id: vdev id to be updated in cb
91  *
92  * Return: void
93  */
94 static inline void
95 qdf_nbuf_cb_update_vdev_id(struct sk_buff *skb, uint8_t vdev_id)
96 {
97 	QDF_NBUF_CB_RX_VDEV_ID(skb) = vdev_id;
98 }
99 
100 void __qdf_nbuf_init_replenish_timer(void);
101 void __qdf_nbuf_deinit_replenish_timer(void);
102 
103 /**
104  * __qdf_nbuf_push_head() - Push data in the front
105  * @skb: Pointer to network buffer
106  * @size: size to be pushed
107  *
108  * Return: New data pointer of this buf after data has been pushed,
109  *         or NULL if there is not enough room in this buf.
110  */
111 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
112 {
113 	if (QDF_NBUF_CB_PADDR(skb))
114 		QDF_NBUF_CB_PADDR(skb) -= size;
115 
116 	return skb_push(skb, size);
117 }
118 
119 
120 /**
121  * __qdf_nbuf_pull_head() - pull data out from the front
122  * @skb: Pointer to network buffer
123  * @size: size to be popped
124  *
125  * Return: New data pointer of this buf after data has been popped,
126  *	   or NULL if there is not sufficient data to pull.
127  */
128 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
129 {
130 	if (QDF_NBUF_CB_PADDR(skb))
131 		QDF_NBUF_CB_PADDR(skb) += size;
132 
133 	return skb_pull(skb, size);
134 }
135 
136 /**
137  * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer
138  *
139  * This function initializes the nbuf alloc fail replenish timer.
140  *
141  * Return: void
142  */
143 static inline void
144 qdf_nbuf_init_replenish_timer(void)
145 {
146 	__qdf_nbuf_init_replenish_timer();
147 }
148 
149 /**
150  * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer
151  *
152  * This function deinitializes the nbuf alloc fail replenish timer.
153  *
154  * Return: void
155  */
156 static inline void
157 qdf_nbuf_deinit_replenish_timer(void)
158 {
159 	__qdf_nbuf_deinit_replenish_timer();
160 }
161 
162 #endif /*_I_QDF_NBUF_M_H */
163