xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_m.h (revision 45a38684b07295822dc8eba39e293408f203eec8)
1 /*
2  * Copyright (c) 2014-2020 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_CB_RX_PACKET_L3_HDR_PAD(skb) \
73 	 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \
74 	 l3_hdr_pad)
75 
76 #define  QDF_NBUF_CB_RX_PACKET_EXC_FRAME(skb) \
77 	 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \
78 	 exc_frm)
79 
80 #define  QDF_NBUF_CB_RX_PACKET_IPA_SMMU_MAP(skb) \
81 	 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \
82 	 ipa_smmu_map)
83 
84 #define __qdf_nbuf_ipa_owned_get(skb) \
85 	QDF_NBUF_CB_TX_IPA_OWNED(skb)
86 
87 #define __qdf_nbuf_ipa_owned_set(skb) \
88 	(QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1)
89 
90 #define __qdf_nbuf_ipa_owned_clear(skb) \
91 	(QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0)
92 
93 #define __qdf_nbuf_ipa_priv_get(skb)	\
94 	QDF_NBUF_CB_TX_IPA_PRIV(skb)
95 
96 #define __qdf_nbuf_ipa_priv_set(skb, priv) \
97 	(QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv))
98 
99 /**
100  * qdf_nbuf_cb_update_vdev_id() - update vdev id in skb cb
101  * @skb: skb pointer whose cb is updated with vdev id information
102  * @vdev_id: vdev id to be updated in cb
103  *
104  * Return: void
105  */
106 static inline void
107 qdf_nbuf_cb_update_vdev_id(struct sk_buff *skb, uint8_t vdev_id)
108 {
109 	QDF_NBUF_CB_RX_VDEV_ID(skb) = vdev_id;
110 }
111 
112 void __qdf_nbuf_init_replenish_timer(void);
113 void __qdf_nbuf_deinit_replenish_timer(void);
114 
115 /**
116  * __qdf_nbuf_push_head() - Push data in the front
117  * @skb: Pointer to network buffer
118  * @size: size to be pushed
119  *
120  * Return: New data pointer of this buf after data has been pushed,
121  *         or NULL if there is not enough room in this buf.
122  */
123 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
124 {
125 	if (QDF_NBUF_CB_PADDR(skb))
126 		QDF_NBUF_CB_PADDR(skb) -= size;
127 
128 	return skb_push(skb, size);
129 }
130 
131 
132 /**
133  * __qdf_nbuf_pull_head() - pull data out from the front
134  * @skb: Pointer to network buffer
135  * @size: size to be popped
136  *
137  * Return: New data pointer of this buf after data has been popped,
138  *	   or NULL if there is not sufficient data to pull.
139  */
140 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
141 {
142 	if (QDF_NBUF_CB_PADDR(skb))
143 		QDF_NBUF_CB_PADDR(skb) += size;
144 
145 	return skb_pull(skb, size);
146 }
147 
148 /**
149  * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer
150  *
151  * This function initializes the nbuf alloc fail replenish timer.
152  *
153  * Return: void
154  */
155 static inline void
156 qdf_nbuf_init_replenish_timer(void)
157 {
158 	__qdf_nbuf_init_replenish_timer();
159 }
160 
161 /**
162  * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer
163  *
164  * This function deinitializes the nbuf alloc fail replenish timer.
165  *
166  * Return: void
167  */
168 static inline void
169 qdf_nbuf_deinit_replenish_timer(void)
170 {
171 	__qdf_nbuf_deinit_replenish_timer();
172 }
173 
174 static inline void
175 __qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end) {}
176 
177 #endif /*_I_QDF_NBUF_M_H */
178