dp_rx_defrag.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (c) 2017-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. #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 <linux/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. #define UNI_DESC_OWNER_SW 0x1
  36. #define UNI_DESC_BUF_TYPE_RX_MSDU_LINK 0x6
  37. /**
  38. * struct dp_rx_defrag_cipher: structure to indicate cipher header
  39. * @ic_name: Name
  40. * @ic_header: header length
  41. * @ic_trailer: trail length
  42. * @ic_miclen: MIC length
  43. */
  44. struct dp_rx_defrag_cipher {
  45. const char *ic_name;
  46. uint16_t ic_header;
  47. uint8_t ic_trailer;
  48. uint8_t ic_miclen;
  49. };
  50. uint32_t dp_rx_frag_handle(struct dp_soc *soc, void *ring_desc,
  51. struct hal_rx_mpdu_desc_info *mpdu_desc_info,
  52. union dp_rx_desc_list_elem_t **head,
  53. union dp_rx_desc_list_elem_t **tail,
  54. uint32_t quota);
  55. /*
  56. * dp_rx_frag_get_mac_hdr() - Return pointer to the mac hdr
  57. * @rx_desc_info: Pointer to the pkt_tlvs in the
  58. * nbuf (pkt_tlvs->mac_hdr->data)
  59. *
  60. * It is inefficient to peek into the packet for received
  61. * frames but these APIs are required to get to some of
  62. * 802.11 fields that hardware does not populate in the
  63. * rx meta data.
  64. *
  65. * Returns: pointer to ieee80211_frame
  66. */
  67. static inline
  68. struct ieee80211_frame *dp_rx_frag_get_mac_hdr(uint8_t *rx_desc_info)
  69. {
  70. int rx_desc_len = hal_rx_get_desc_len();
  71. return (struct ieee80211_frame *)(rx_desc_info + rx_desc_len);
  72. }
  73. /*
  74. * dp_rx_frag_get_mpdu_seq_number() - Get mpdu sequence number
  75. * @rx_desc_info: Pointer to the pkt_tlvs in the
  76. * nbuf (pkt_tlvs->mac_hdr->data)
  77. *
  78. * Returns: uint16_t, rx sequence number
  79. */
  80. static inline
  81. uint16_t dp_rx_frag_get_mpdu_seq_number(uint8_t *rx_desc_info)
  82. {
  83. struct ieee80211_frame *mac_hdr;
  84. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  85. return qdf_le16_to_cpu(*(uint16_t *) mac_hdr->i_seq) >>
  86. IEEE80211_SEQ_SEQ_SHIFT;
  87. }
  88. /*
  89. * dp_rx_frag_get_mpdu_frag_number() - Get mpdu fragment number
  90. * @rx_desc_info: Pointer to the pkt_tlvs in the
  91. * nbuf (pkt_tlvs->mac_hdr->data)
  92. *
  93. * Returns: uint8_t, receive fragment number
  94. */
  95. static inline
  96. uint8_t dp_rx_frag_get_mpdu_frag_number(uint8_t *rx_desc_info)
  97. {
  98. struct ieee80211_frame *mac_hdr;
  99. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  100. return qdf_le16_to_cpu(*(uint16_t *) mac_hdr->i_seq) &
  101. IEEE80211_SEQ_FRAG_MASK;
  102. }
  103. /*
  104. * dp_rx_frag_get_more_frag_bit() - Get more fragment bit
  105. * @rx_desc_info: Pointer to the pkt_tlvs in the
  106. * nbuf (pkt_tlvs->mac_hdr->data)
  107. *
  108. * Returns: uint8_t, get more fragment bit
  109. */
  110. static inline
  111. uint8_t dp_rx_frag_get_more_frag_bit(uint8_t *rx_desc_info)
  112. {
  113. struct ieee80211_frame *mac_hdr;
  114. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  115. return (mac_hdr->i_fc[1] & IEEE80211_FC1_MORE_FRAG) >> 2;
  116. }
  117. static inline
  118. uint8_t dp_rx_get_pkt_dir(uint8_t *rx_desc_info)
  119. {
  120. struct ieee80211_frame *mac_hdr;
  121. mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info);
  122. return mac_hdr->i_fc[1] & IEEE80211_FC1_DIR_MASK;
  123. }
  124. void dp_rx_defrag_waitlist_flush(struct dp_soc *soc);
  125. void dp_rx_reorder_flush_frag(struct dp_peer *peer,
  126. unsigned int tid);
  127. void dp_rx_defrag_waitlist_remove(struct dp_peer *peer, unsigned tid);
  128. void dp_rx_defrag_cleanup(struct dp_peer *peer, unsigned tid);
  129. #endif /* _DP_RX_DEFRAG_H */