xref: /wlan-dirver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_nbuf_m.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
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_ipa_owned_get(skb) \
81 	QDF_NBUF_CB_TX_IPA_OWNED(skb)
82 
83 #define __qdf_nbuf_ipa_owned_set(skb) \
84 	(QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1)
85 
86 #define __qdf_nbuf_ipa_owned_clear(skb) \
87 	(QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0)
88 
89 #define __qdf_nbuf_ipa_priv_get(skb)	\
90 	QDF_NBUF_CB_TX_IPA_PRIV(skb)
91 
92 #define __qdf_nbuf_ipa_priv_set(skb, priv) \
93 	(QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv))
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 	QDF_NBUF_CB_RX_VDEV_ID(skb) = vdev_id;
106 }
107 
108 void __qdf_nbuf_init_replenish_timer(void);
109 void __qdf_nbuf_deinit_replenish_timer(void);
110 
111 /**
112  * __qdf_nbuf_push_head() - Push data in the front
113  * @skb: Pointer to network buffer
114  * @size: size to be pushed
115  *
116  * Return: New data pointer of this buf after data has been pushed,
117  *         or NULL if there is not enough room in this buf.
118  */
119 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size)
120 {
121 	if (QDF_NBUF_CB_PADDR(skb))
122 		QDF_NBUF_CB_PADDR(skb) -= size;
123 
124 	return skb_push(skb, size);
125 }
126 
127 
128 /**
129  * __qdf_nbuf_pull_head() - pull data out from the front
130  * @skb: Pointer to network buffer
131  * @size: size to be popped
132  *
133  * Return: New data pointer of this buf after data has been popped,
134  *	   or NULL if there is not sufficient data to pull.
135  */
136 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size)
137 {
138 	if (QDF_NBUF_CB_PADDR(skb))
139 		QDF_NBUF_CB_PADDR(skb) += size;
140 
141 	return skb_pull(skb, size);
142 }
143 
144 /**
145  * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer
146  *
147  * This function initializes the nbuf alloc fail replenish timer.
148  *
149  * Return: void
150  */
151 static inline void
152 qdf_nbuf_init_replenish_timer(void)
153 {
154 	__qdf_nbuf_init_replenish_timer();
155 }
156 
157 /**
158  * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer
159  *
160  * This function deinitializes the nbuf alloc fail replenish timer.
161  *
162  * Return: void
163  */
164 static inline void
165 qdf_nbuf_deinit_replenish_timer(void)
166 {
167 	__qdf_nbuf_deinit_replenish_timer();
168 }
169 
170 static inline void
171 __qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end) {}
172 
173 #endif /*_I_QDF_NBUF_M_H */
174