dp_rx_defrag.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2017 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. #ifndef _DP_RX_DEFRAG_H
  19. #define _DP_RX_DEFRAG_H
  20. #include "hal_rx.h"
  21. #ifdef CONFIG_MCL
  22. #include <cds_ieee80211_common.h>
  23. #else
  24. #include <ieee80211.h>
  25. #endif
  26. #define DEFRAG_IEEE80211_ADDR_LEN 6
  27. #define DEFRAG_IEEE80211_KEY_LEN 8
  28. #define DEFRAG_IEEE80211_FCS_LEN 4
  29. #define DP_RX_DEFRAG_IEEE80211_ADDR_COPY(dst, src) \
  30. qdf_mem_copy(dst, src, IEEE80211_ADDR_LEN)
  31. #define DP_RX_DEFRAG_IEEE80211_QOS_HAS_SEQ(wh) \
  32. (((wh) & \
  33. (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == \
  34. (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
  35. /**
  36. * struct dp_rx_defrag_cipher: structure to indicate cipher header
  37. * @ic_name: Name
  38. * @ic_header: header length
  39. * @ic_trailer: trail length
  40. * @ic_miclen: MIC length
  41. */
  42. struct dp_rx_defrag_cipher {
  43. const char *ic_name;
  44. uint16_t ic_header;
  45. uint8_t ic_trailer;
  46. uint8_t ic_miclen;
  47. };
  48. uint32_t dp_rx_frag_handle(struct dp_soc *soc, void *ring_desc,
  49. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  50. union dp_rx_desc_list_elem_t **head,
  51. union dp_rx_desc_list_elem_t **tail,
  52. uint32_t quota);
  53. /*
  54. * dp_rx_frag_get_mac_hdr() - Return pointer to the mac hdr
  55. * @rx_desc_info: Pointer to the pkt_tlvs in the
  56. * nbuf (pkt_tlvs->mac_hdr->data)
  57. *
  58. * It is inefficient to peek into the packet for received
  59. * frames but these APIs are required to get to some of
  60. * 802.11 fields that hardware does not populate in the
  61. * rx meta data.
  62. *
  63. * Returns: pointer to ieee80211_frame
  64. */
  65. static inline
  66. struct ieee80211_frame *dp_rx_frag_get_mac_hdr(uint8_t *rx_desc_info)
  67. {
  68. int rx_desc_len = hal_rx_get_desc_len();
  69. return (struct ieee80211_frame *)(rx_desc_info + rx_desc_len);
  70. }
  71. /*
  72. * dp_rx_frag_get_mpdu_seq_number() - Get mpdu sequence number
  73. * @rx_desc_info: Pointer to the pkt_tlvs in the
  74. * nbuf (pkt_tlvs->mac_hdr->data)
  75. *
  76. * Returns: uint16_t, rx sequence number
  77. */
  78. static inline
  79. uint16_t dp_rx_frag_get_mpdu_seq_number(uint8_t *rx_desc_info)
  80. {
  81. struct ieee80211_frame *mac_hdr;
  82. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  83. return qdf_le16_to_cpu(*(uint16_t *) mac_hdr->i_seq) >>
  84. IEEE80211_SEQ_SEQ_SHIFT;
  85. }
  86. /*
  87. * dp_rx_frag_get_mpdu_frag_number() - Get mpdu fragment number
  88. * @rx_desc_info: Pointer to the pkt_tlvs in the
  89. * nbuf (pkt_tlvs->mac_hdr->data)
  90. *
  91. * Returns: uint8_t, receive fragment number
  92. */
  93. static inline
  94. uint8_t dp_rx_frag_get_mpdu_frag_number(uint8_t *rx_desc_info)
  95. {
  96. struct ieee80211_frame *mac_hdr;
  97. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  98. return qdf_le16_to_cpu(*(uint16_t *) mac_hdr->i_seq) &
  99. IEEE80211_SEQ_FRAG_MASK;
  100. }
  101. /*
  102. * dp_rx_frag_get_more_frag_bit() - Get more fragment bit
  103. * @rx_desc_info: Pointer to the pkt_tlvs in the
  104. * nbuf (pkt_tlvs->mac_hdr->data)
  105. *
  106. * Returns: uint8_t, get more fragment bit
  107. */
  108. static inline
  109. uint8_t dp_rx_frag_get_more_frag_bit(uint8_t *rx_desc_info)
  110. {
  111. struct ieee80211_frame *mac_hdr;
  112. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  113. return mac_hdr->i_fc[1] & IEEE80211_FC1_MORE_FRAG;
  114. }
  115. #endif /* _DP_RX_DEFRAG_H */