blob: caadb3737b9ebb6a877d707d9be44533c8643063 [file] [log] [blame]
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001/*
2 * Marvell Wireless LAN device driver: utility functions
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20#ifndef _MWIFIEX_UTIL_H_
21#define _MWIFIEX_UTIL_H_
22
Aaron Durbindbccc922014-02-07 16:25:50 -080023struct mwifiex_dma_mapping {
24 dma_addr_t addr;
25 size_t len;
26};
27
Chin-Ran Lobca463e2014-06-06 19:37:10 -070028struct mwifiex_cb {
29 struct mwifiex_dma_mapping dma_mapping;
30 union {
31 struct mwifiex_rxinfo rx_info;
32 struct mwifiex_txinfo tx_info;
33 };
34};
35
36static inline struct mwifiex_rxinfo *MWIFIEX_SKB_RXCB(struct sk_buff *skb)
Amitkumar Karward930fae2011-10-11 17:41:21 -070037{
Chin-Ran Lobca463e2014-06-06 19:37:10 -070038 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
39
40 BUILD_BUG_ON(sizeof(struct mwifiex_cb) > sizeof(skb->cb));
41 return &cb->rx_info;
42}
43
44static inline struct mwifiex_txinfo *MWIFIEX_SKB_TXCB(struct sk_buff *skb)
45{
46 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
47
48 return &cb->tx_info;
49}
50
51static inline void mwifiex_store_mapping(struct sk_buff *skb,
52 struct mwifiex_dma_mapping *mapping)
53{
54 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
55
56 memcpy(&cb->dma_mapping, mapping, sizeof(*mapping));
57}
58
59static inline void mwifiex_get_mapping(struct sk_buff *skb,
60 struct mwifiex_dma_mapping *mapping)
61{
62 struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
63
64 memcpy(mapping, &cb->dma_mapping, sizeof(*mapping));
Bing Zhao5e6e3a92011-03-21 18:00:50 -070065}
Aaron Durbindbccc922014-02-07 16:25:50 -080066
67static inline dma_addr_t MWIFIEX_SKB_DMA_ADDR(struct sk_buff *skb)
68{
69 struct mwifiex_dma_mapping mapping;
70
Chin-Ran Lobca463e2014-06-06 19:37:10 -070071 mwifiex_get_mapping(skb, &mapping);
Aaron Durbindbccc922014-02-07 16:25:50 -080072
73 return mapping.addr;
74}
75
Bing Zhao5e6e3a92011-03-21 18:00:50 -070076#endif /* !_MWIFIEX_UTIL_H_ */