1 /* 2 * Copyright (c) 2014-2021 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 #define QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(skb) \ 49 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m. \ 50 flag_notify_comp) 51 52 #define QDF_NBUF_CB_RX_PEER_ID(skb) \ 53 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \ 54 wifi3.peer_id) 55 56 #define QDF_NBUF_CB_RX_PKT_LEN(skb) \ 57 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \ 58 wifi3.msdu_len) 59 60 #define QDF_NBUF_CB_RX_MAP_IDX(skb) \ 61 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \ 62 wifi2.map_index) 63 64 #define QDF_NBUF_CB_RX_PEER_CACHED_FRM(skb) \ 65 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 66 peer_cached_buf_frm) 67 68 #define QDF_NBUF_CB_RX_FLUSH_IND(skb) \ 69 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.flush_ind) 70 71 #define QDF_NBUF_CB_RX_PACKET_BUFF_POOL(skb) \ 72 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 73 packet_buf_pool) 74 75 #define QDF_NBUF_CB_RX_PACKET_L3_HDR_PAD(skb) \ 76 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 77 l3_hdr_pad) 78 79 #define QDF_NBUF_CB_RX_PACKET_EXC_FRAME(skb) \ 80 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 81 exc_frm) 82 83 #define QDF_NBUF_CB_RX_PACKET_IPA_SMMU_MAP(skb) \ 84 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 85 ipa_smmu_map) 86 87 #define QDF_NBUF_CB_RX_PACKET_REO_DEST_IND(skb) \ 88 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 89 reo_dest_ind) 90 91 #define __qdf_nbuf_ipa_owned_get(skb) \ 92 QDF_NBUF_CB_TX_IPA_OWNED(skb) 93 94 #define __qdf_nbuf_ipa_owned_set(skb) \ 95 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1) 96 97 #define __qdf_nbuf_ipa_owned_clear(skb) \ 98 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0) 99 100 #define __qdf_nbuf_ipa_priv_get(skb) \ 101 QDF_NBUF_CB_TX_IPA_PRIV(skb) 102 103 #define __qdf_nbuf_ipa_priv_set(skb, priv) \ 104 (QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv)) 105 106 /** 107 * qdf_nbuf_cb_update_vdev_id() - update vdev id in skb cb 108 * @skb: skb pointer whose cb is updated with vdev id information 109 * @vdev_id: vdev id to be updated in cb 110 * 111 * Return: void 112 */ 113 static inline void 114 qdf_nbuf_cb_update_vdev_id(struct sk_buff *skb, uint8_t vdev_id) 115 { 116 QDF_NBUF_CB_RX_VDEV_ID(skb) = vdev_id; 117 } 118 119 void __qdf_nbuf_init_replenish_timer(void); 120 void __qdf_nbuf_deinit_replenish_timer(void); 121 122 /** 123 * __qdf_nbuf_push_head() - Push data in the front 124 * @skb: Pointer to network buffer 125 * @size: size to be pushed 126 * 127 * Return: New data pointer of this buf after data has been pushed, 128 * or NULL if there is not enough room in this buf. 129 */ 130 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size) 131 { 132 if (QDF_NBUF_CB_PADDR(skb)) 133 QDF_NBUF_CB_PADDR(skb) -= size; 134 135 return skb_push(skb, size); 136 } 137 138 139 /** 140 * __qdf_nbuf_pull_head() - pull data out from the front 141 * @skb: Pointer to network buffer 142 * @size: size to be popped 143 * 144 * Return: New data pointer of this buf after data has been popped, 145 * or NULL if there is not sufficient data to pull. 146 */ 147 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size) 148 { 149 if (QDF_NBUF_CB_PADDR(skb)) 150 QDF_NBUF_CB_PADDR(skb) += size; 151 152 return skb_pull(skb, size); 153 } 154 155 /** 156 * qdf_nbuf_is_intra_bss() - get intra bss bit 157 * @buf: Network buffer 158 * 159 * Return: integer value - 0/1 160 */ 161 static inline int qdf_nbuf_is_intra_bss(struct sk_buff *buf) 162 { 163 return 0; 164 } 165 166 /** 167 * qdf_nbuf_set_intra_bss() - set intra bss bit 168 * @buf: Network buffer 169 * @val: 0/1 170 * 171 * Return: void 172 */ 173 static inline void qdf_nbuf_set_intra_bss(struct sk_buff *buf, uint8_t val) 174 { 175 } 176 177 /** 178 * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer 179 * 180 * This function initializes the nbuf alloc fail replenish timer. 181 * 182 * Return: void 183 */ 184 static inline void 185 qdf_nbuf_init_replenish_timer(void) 186 { 187 __qdf_nbuf_init_replenish_timer(); 188 } 189 190 /** 191 * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer 192 * 193 * This function deinitializes the nbuf alloc fail replenish timer. 194 * 195 * Return: void 196 */ 197 static inline void 198 qdf_nbuf_deinit_replenish_timer(void) 199 { 200 __qdf_nbuf_deinit_replenish_timer(); 201 } 202 203 static inline void 204 __qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end) {} 205 206 #endif /*_I_QDF_NBUF_M_H */ 207