util.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Marvell Wireless LAN device driver: utility functions
  3. *
  4. * Copyright (C) 2011-2014, 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. #ifndef _MWIFIEX_UTIL_H_
  20. #define _MWIFIEX_UTIL_H_
  21. struct mwifiex_dma_mapping {
  22. dma_addr_t addr;
  23. size_t len;
  24. };
  25. struct mwifiex_cb {
  26. struct mwifiex_dma_mapping dma_mapping;
  27. union {
  28. struct mwifiex_rxinfo rx_info;
  29. struct mwifiex_txinfo tx_info;
  30. };
  31. };
  32. static inline struct mwifiex_rxinfo *MWIFIEX_SKB_RXCB(struct sk_buff *skb)
  33. {
  34. struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
  35. BUILD_BUG_ON(sizeof(struct mwifiex_cb) > sizeof(skb->cb));
  36. return &cb->rx_info;
  37. }
  38. static inline struct mwifiex_txinfo *MWIFIEX_SKB_TXCB(struct sk_buff *skb)
  39. {
  40. struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
  41. return &cb->tx_info;
  42. }
  43. static inline void mwifiex_store_mapping(struct sk_buff *skb,
  44. struct mwifiex_dma_mapping *mapping)
  45. {
  46. struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
  47. memcpy(&cb->dma_mapping, mapping, sizeof(*mapping));
  48. }
  49. static inline void mwifiex_get_mapping(struct sk_buff *skb,
  50. struct mwifiex_dma_mapping *mapping)
  51. {
  52. struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb;
  53. memcpy(mapping, &cb->dma_mapping, sizeof(*mapping));
  54. }
  55. static inline dma_addr_t MWIFIEX_SKB_DMA_ADDR(struct sk_buff *skb)
  56. {
  57. struct mwifiex_dma_mapping mapping;
  58. mwifiex_get_mapping(skb, &mapping);
  59. return mapping.addr;
  60. }
  61. #endif /* !_MWIFIEX_UTIL_H_ */