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 49 #define __qdf_nbuf_ipa_owned_get(skb) \ 50 QDF_NBUF_CB_TX_IPA_OWNED(skb) 51 52 #define __qdf_nbuf_ipa_owned_set(skb) \ 53 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 1) 54 55 #define __qdf_nbuf_ipa_owned_clear(skb) \ 56 (QDF_NBUF_CB_TX_IPA_OWNED(skb) = 0) 57 58 #define __qdf_nbuf_ipa_priv_get(skb) \ 59 QDF_NBUF_CB_TX_IPA_PRIV(skb) 60 61 #define __qdf_nbuf_ipa_priv_set(skb, priv) \ 62 (QDF_NBUF_CB_TX_IPA_PRIV(skb) = (priv)) 63 64 /** 65 * qdf_nbuf_cb_update_peer_local_id() - update peer local id in skb cb 66 * @skb: skb pointer whose cb is updated with peer local id information 67 * @peer_local_id: peer local id to be update in cb 68 * 69 * Return: void 70 */ 71 static inline void qdf_nbuf_cb_update_peer_local_id(struct sk_buff *skb, 72 uint32_t peer_local_id) 73 { 74 QDF_NBUF_CB_RX_PEER_LOCAL_ID(skb) = peer_local_id; 75 } 76 77 void __qdf_nbuf_init_replenish_timer(void); 78 void __qdf_nbuf_deinit_replenish_timer(void); 79 80 /** 81 * __qdf_nbuf_push_head() - Push data in the front 82 * @skb: Pointer to network buffer 83 * @size: size to be pushed 84 * 85 * Return: New data pointer of this buf after data has been pushed, 86 * or NULL if there is not enough room in this buf. 87 */ 88 static inline uint8_t *__qdf_nbuf_push_head(struct sk_buff *skb, size_t size) 89 { 90 if (QDF_NBUF_CB_PADDR(skb)) 91 QDF_NBUF_CB_PADDR(skb) -= size; 92 93 return skb_push(skb, size); 94 } 95 96 97 /** 98 * __qdf_nbuf_pull_head() - pull data out from the front 99 * @skb: Pointer to network buffer 100 * @size: size to be popped 101 * 102 * Return: New data pointer of this buf after data has been popped, 103 * or NULL if there is not sufficient data to pull. 104 */ 105 static inline uint8_t *__qdf_nbuf_pull_head(struct sk_buff *skb, size_t size) 106 { 107 if (QDF_NBUF_CB_PADDR(skb)) 108 QDF_NBUF_CB_PADDR(skb) += size; 109 110 return skb_pull(skb, size); 111 } 112 113 /** 114 * qdf_nbuf_init_replenish_timer - Initialize the alloc replenish timer 115 * 116 * This function initializes the nbuf alloc fail replenish timer. 117 * 118 * Return: void 119 */ 120 static inline void 121 qdf_nbuf_init_replenish_timer(void) 122 { 123 __qdf_nbuf_init_replenish_timer(); 124 } 125 126 /** 127 * qdf_nbuf_deinit_replenish_timer - Deinitialize the alloc replenish timer 128 * 129 * This function deinitializes the nbuf alloc fail replenish timer. 130 * 131 * Return: void 132 */ 133 static inline void 134 qdf_nbuf_deinit_replenish_timer(void) 135 { 136 __qdf_nbuf_deinit_replenish_timer(); 137 } 138 139 #endif /*_I_QDF_NBUF_M_H */ 140