1 /* 2 * Copyright (c) 2014-2018 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_RX_PEER_LOCAL_ID(skb) \ 38 (((struct qdf_nbuf_cb *)((skb)->cb))->u.rx.dev.priv_cb_m.peer_local_id) 39 40 #define QDF_NBUF_CB_TX_IPA_OWNED(skb) \ 41 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.ipa.owned) 42 #define QDF_NBUF_CB_TX_IPA_PRIV(skb) \ 43 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.ipa.priv) 44 #define QDF_NBUF_CB_TX_DESC_ID(skb)\ 45 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.desc_id) 46 #define QDF_NBUF_CB_MGMT_TXRX_DESC_ID(skb)\ 47 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m.mgmt_desc_id) 48 #define QDF_NBUF_CB_TX_DMA_BI_MAP(skb) \ 49 (((struct qdf_nbuf_cb *)((skb)->cb))->u.tx.dev.priv_cb_m. \ 50 dma_option.bi_map) 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_ipa_owned_get(skb) \ 65 QDF_NBUF_CB_TX_IPA_OWNED(skb) 66 67 #define __qdf_nbuf_ipa_owned_set(skb) \ 68 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1) 69 70 #define __qdf_nbuf_ipa_owned_clear(skb) \ 71 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0) 72 73 #define __qdf_nbuf_ipa_priv_get(skb) \ 74 QDF_NBUF_CB_TX_IPA_PRIV(skb) 75 76 #define __qdf_nbuf_ipa_priv_set(skb, priv) \ 77 (QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv)) 78 79 /** 80 * qdf_nbuf_cb_update_peer_local_id() - update peer local id in skb cb 81 * @skb: skb pointer whose cb is updated with peer local id information 82 * @peer_local_id: peer local id to be update in cb 83 * 84 * Return: void 85 */ 86 static inline void qdf_nbuf_cb_update_peer_local_id(struct sk_buff *skb, 87 uint16_t peer_local_id) 88 { 89 QDF_NBUF_CB_RX_PEER_LOCAL_ID(skb) = peer_local_id; 90 } 91 92 void __qdf_nbuf_init_replenish_timer(void); 93 void __qdf_nbuf_deinit_replenish_timer(void); 94 95 /** 96 * __qdf_nbuf_push_head() - Push data in the front 97 * @skb: Pointer to network buffer 98 * @size: size to be pushed 99 * 100 * Return: New data pointer of this buf after data has been pushed, 101 * or NULL if there is not enough room in this buf. 102 */ 103 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size) 104 { 105 if (QDF_NBUF_CB_PADDR(skb)) 106 QDF_NBUF_CB_PADDR(skb) -= size; 107 108 return skb_push(skb, size); 109 } 110 111 112 /** 113 * __qdf_nbuf_pull_head() - pull data out from the front 114 * @skb: Pointer to network buffer 115 * @size: size to be popped 116 * 117 * Return: New data pointer of this buf after data has been popped, 118 * or NULL if there is not sufficient data to pull. 119 */ 120 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size) 121 { 122 if (QDF_NBUF_CB_PADDR(skb)) 123 QDF_NBUF_CB_PADDR(skb) += size; 124 125 return skb_pull(skb, size); 126 } 127 128 /** 129 * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer 130 * 131 * This function initializes the nbuf alloc fail replenish timer. 132 * 133 * Return: void 134 */ 135 static inline void 136 qdf_nbuf_init_replenish_timer(void) 137 { 138 __qdf_nbuf_init_replenish_timer(); 139 } 140 141 /** 142 * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer 143 * 144 * This function deinitializes the nbuf alloc fail replenish timer. 145 * 146 * Return: void 147 */ 148 static inline void 149 qdf_nbuf_deinit_replenish_timer(void) 150 { 151 __qdf_nbuf_deinit_replenish_timer(); 152 } 153 154 #endif /*_I_QDF_NBUF_M_H */ 155