1 /* 2 * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: i_qdf_nbuf_m.h 22 * 23 * This file provides platform specific nbuf API's. 24 * Included by i_qdf_nbuf.h and should not be included 25 * directly from other files. 26 */ 27 28 #ifndef _I_QDF_NBUF_M_H 29 #define _I_QDF_NBUF_M_H 30 31 #define QDF_NBUF_CB_RX_TCP_SEQ_NUM(skb) \ 32 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.tcp_seq_num) 33 #define QDF_NBUF_CB_RX_TCP_ACK_NUM(skb) \ 34 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.tcp_ack_num) 35 #define QDF_NBUF_CB_RX_LRO_CTX(skb) \ 36 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.lro_ctx) 37 38 #define QDF_NBUF_CB_TX_IPA_OWNED(skb) \ 39 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.ipa.owned) 40 #define QDF_NBUF_CB_TX_IPA_PRIV(skb) \ 41 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.ipa.priv) 42 #define QDF_NBUF_CB_TX_DESC_ID(skb)\ 43 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.desc_id) 44 #define QDF_NBUF_CB_MGMT_TXRX_DESC_ID(skb)\ 45 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.mgmt_desc_id) 46 #define QDF_NBUF_CB_TX_DMA_BI_MAP(skb) \ 47 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m. \ 48 dma_option.bi_map) 49 #define QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(skb) \ 50 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m. \ 51 flag_notify_comp) 52 53 #define QDF_NBUF_CB_RX_PEER_ID(skb) \ 54 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \ 55 wifi3.peer_id) 56 57 #define QDF_NBUF_CB_RX_PKT_LEN(skb) \ 58 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \ 59 wifi3.msdu_len) 60 61 #define QDF_NBUF_CB_RX_MAP_IDX(skb) \ 62 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.dp. \ 63 wifi2.map_index) 64 65 #define QDF_NBUF_CB_RX_PEER_CACHED_FRM(skb) \ 66 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 67 peer_cached_buf_frm) 68 69 #define QDF_NBUF_CB_RX_FLUSH_IND(skb) \ 70 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.flush_ind) 71 72 #define QDF_NBUF_CB_RX_PACKET_BUFF_POOL(skb) \ 73 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 74 packet_buf_pool) 75 76 #define QDF_NBUF_CB_RX_PACKET_L3_HDR_PAD(skb) \ 77 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 78 l3_hdr_pad) 79 80 #define QDF_NBUF_CB_RX_PACKET_EXC_FRAME(skb) \ 81 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 82 exc_frm) 83 84 #define QDF_NBUF_CB_RX_PACKET_IPA_SMMU_MAP(skb) \ 85 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 86 ipa_smmu_map) 87 88 #define QDF_NBUF_CB_RX_PACKET_REO_DEST_IND_OR_SW_EXCPT(skb) \ 89 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 90 reo_dest_ind_or_sw_excpt) 91 92 #define QDF_NBUF_CB_RX_PACKET_LMAC_ID(skb) \ 93 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m. \ 94 lmac_id) 95 96 #define __qdf_nbuf_ipa_owned_get(skb) \ 97 QDF_NBUF_CB_TX_IPA_OWNED(skb) 98 99 #define __qdf_nbuf_ipa_owned_set(skb) \ 100 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1) 101 102 #define __qdf_nbuf_ipa_owned_clear(skb) \ 103 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0) 104 105 #define __qdf_nbuf_ipa_priv_get(skb) \ 106 QDF_NBUF_CB_TX_IPA_PRIV(skb) 107 108 #define __qdf_nbuf_ipa_priv_set(skb, priv) \ 109 (QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv)) 110 111 /** 112 * qdf_nbuf_cb_update_vdev_id() - update vdev id in skb cb 113 * @skb: skb pointer whose cb is updated with vdev id information 114 * @vdev_id: vdev id to be updated in cb 115 * 116 * Return: void 117 */ 118 static inline void 119 qdf_nbuf_cb_update_vdev_id(struct sk_buff *skb, uint8_t vdev_id) 120 { 121 QDF_NBUF_CB_RX_VDEV_ID(skb) = vdev_id; 122 } 123 124 void __qdf_nbuf_init_replenish_timer(void); 125 void __qdf_nbuf_deinit_replenish_timer(void); 126 127 /** 128 * __qdf_nbuf_push_head() - Push data in the front 129 * @skb: Pointer to network buffer 130 * @size: size to be pushed 131 * 132 * Return: New data pointer of this buf after data has been pushed, 133 * or NULL if there is not enough room in this buf. 134 */ 135 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size) 136 { 137 if (QDF_NBUF_CB_PADDR(skb)) 138 QDF_NBUF_CB_PADDR(skb) -= size; 139 140 return skb_push(skb, size); 141 } 142 143 144 /** 145 * __qdf_nbuf_pull_head() - pull data out from the front 146 * @skb: Pointer to network buffer 147 * @size: size to be popped 148 * 149 * Return: New data pointer of this buf after data has been popped, 150 * or NULL if there is not sufficient data to pull. 151 */ 152 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size) 153 { 154 if (QDF_NBUF_CB_PADDR(skb)) 155 QDF_NBUF_CB_PADDR(skb) += size; 156 157 return skb_pull(skb, size); 158 } 159 160 /** 161 * qdf_nbuf_is_intra_bss() - get intra bss bit 162 * @buf: Network buffer 163 * 164 * Return: integer value - 0/1 165 */ 166 static inline int qdf_nbuf_is_intra_bss(struct sk_buff *buf) 167 { 168 return 0; 169 } 170 171 /** 172 * qdf_nbuf_set_intra_bss() - set intra bss bit 173 * @buf: Network buffer 174 * @val: 0/1 175 * 176 * Return: void 177 */ 178 static inline void qdf_nbuf_set_intra_bss(struct sk_buff *buf, uint8_t val) 179 { 180 } 181 182 /** 183 * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer 184 * 185 * This function initializes the nbuf alloc fail replenish timer. 186 * 187 * Return: void 188 */ 189 static inline void 190 qdf_nbuf_init_replenish_timer(void) 191 { 192 __qdf_nbuf_init_replenish_timer(); 193 } 194 195 /** 196 * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer 197 * 198 * This function deinitializes the nbuf alloc fail replenish timer. 199 * 200 * Return: void 201 */ 202 static inline void 203 qdf_nbuf_deinit_replenish_timer(void) 204 { 205 __qdf_nbuf_deinit_replenish_timer(); 206 } 207 208 static inline void 209 __qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end) {} 210 211 static inline void 212 __qdf_nbuf_dma_inv_range_no_dsb(const void *buf_start, const void *buf_end) {} 213 214 static inline void 215 __qdf_nbuf_dma_clean_range_no_dsb(const void *buf_start, const void *buf_end) {} 216 217 static inline void 218 __qdf_dsb(void) {} 219 220 static inline void 221 __qdf_nbuf_dma_clean_range(const void *buf_start, const void *buf_end) {} 222 #endif /*_I_QDF_NBUF_M_H */ 223