1 /* 2 * Copyright (c) 2017-2019 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 #ifndef _DP_RX_DEFRAG_H 20 #define _DP_RX_DEFRAG_H 21 22 #include "hal_rx.h" 23 24 #ifdef CONFIG_MCL 25 #include <cds_ieee80211_common.h> 26 #endif 27 28 #define DEFRAG_IEEE80211_KEY_LEN 8 29 #define DEFRAG_IEEE80211_FCS_LEN 4 30 31 #define DP_RX_DEFRAG_IEEE80211_ADDR_COPY(dst, src) \ 32 qdf_mem_copy(dst, src, QDF_MAC_ADDR_SIZE) 33 34 #define DP_RX_DEFRAG_IEEE80211_QOS_HAS_SEQ(wh) \ 35 (((wh) & \ 36 (IEEE80211_FC0_TYPE_MASK | QDF_IEEE80211_FC0_SUBTYPE_QOS)) == \ 37 (IEEE80211_FC0_TYPE_DATA | QDF_IEEE80211_FC0_SUBTYPE_QOS)) 38 39 #define UNI_DESC_OWNER_SW 0x1 40 #define UNI_DESC_BUF_TYPE_RX_MSDU_LINK 0x6 41 /** 42 * struct dp_rx_defrag_cipher: structure to indicate cipher header 43 * @ic_name: Name 44 * @ic_header: header length 45 * @ic_trailer: trail length 46 * @ic_miclen: MIC length 47 */ 48 struct dp_rx_defrag_cipher { 49 const char *ic_name; 50 uint16_t ic_header; 51 uint8_t ic_trailer; 52 uint8_t ic_miclen; 53 }; 54 55 uint32_t dp_rx_frag_handle(struct dp_soc *soc, void *ring_desc, 56 struct hal_rx_mpdu_desc_info *mpdu_desc_info, 57 struct dp_rx_desc *rx_desc, 58 uint8_t *mac_id, 59 uint32_t quota); 60 61 /* 62 * dp_rx_frag_get_mac_hdr() - Return pointer to the mac hdr 63 * @rx_desc_info: Pointer to the pkt_tlvs in the 64 * nbuf (pkt_tlvs->mac_hdr->data) 65 * 66 * It is inefficient to peek into the packet for received 67 * frames but these APIs are required to get to some of 68 * 802.11 fields that hardware does not populate in the 69 * rx meta data. 70 * 71 * Returns: pointer to ieee80211_frame 72 */ 73 static inline 74 struct ieee80211_frame *dp_rx_frag_get_mac_hdr(uint8_t *rx_desc_info) 75 { 76 int rx_desc_len = hal_rx_get_desc_len(); 77 return (struct ieee80211_frame *)(rx_desc_info + rx_desc_len); 78 } 79 80 /* 81 * dp_rx_frag_get_mpdu_seq_number() - Get mpdu sequence number 82 * @rx_desc_info: Pointer to the pkt_tlvs in the 83 * nbuf (pkt_tlvs->mac_hdr->data) 84 * 85 * Returns: uint16_t, rx sequence number 86 */ 87 static inline 88 uint16_t dp_rx_frag_get_mpdu_seq_number(uint8_t *rx_desc_info) 89 { 90 struct ieee80211_frame *mac_hdr; 91 mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info); 92 93 return qdf_le16_to_cpu(*(uint16_t *) mac_hdr->i_seq) >> 94 IEEE80211_SEQ_SEQ_SHIFT; 95 } 96 97 /* 98 * dp_rx_frag_get_mpdu_frag_number() - Get mpdu fragment number 99 * @rx_desc_info: Pointer to the pkt_tlvs in the 100 * nbuf (pkt_tlvs->mac_hdr->data) 101 * 102 * Returns: uint8_t, receive fragment number 103 */ 104 static inline 105 uint8_t dp_rx_frag_get_mpdu_frag_number(uint8_t *rx_desc_info) 106 { 107 struct ieee80211_frame *mac_hdr; 108 mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info); 109 110 return qdf_le16_to_cpu(*(uint16_t *) mac_hdr->i_seq) & 111 IEEE80211_SEQ_FRAG_MASK; 112 } 113 114 /* 115 * dp_rx_frag_get_more_frag_bit() - Get more fragment bit 116 * @rx_desc_info: Pointer to the pkt_tlvs in the 117 * nbuf (pkt_tlvs->mac_hdr->data) 118 * 119 * Returns: uint8_t, get more fragment bit 120 */ 121 static inline 122 uint8_t dp_rx_frag_get_more_frag_bit(uint8_t *rx_desc_info) 123 { 124 struct ieee80211_frame *mac_hdr; 125 mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info); 126 127 return (mac_hdr->i_fc[1] & IEEE80211_FC1_MORE_FRAG) >> 2; 128 } 129 130 static inline 131 uint8_t dp_rx_get_pkt_dir(uint8_t *rx_desc_info) 132 { 133 struct ieee80211_frame *mac_hdr; 134 mac_hdr = dp_rx_frag_get_mac_hdr(rx_desc_info); 135 136 return mac_hdr->i_fc[1] & IEEE80211_FC1_DIR_MASK; 137 } 138 139 void dp_rx_defrag_waitlist_flush(struct dp_soc *soc); 140 void dp_rx_reorder_flush_frag(struct dp_peer *peer, 141 unsigned int tid); 142 void dp_rx_defrag_waitlist_remove(struct dp_peer *peer, unsigned tid); 143 void dp_rx_defrag_cleanup(struct dp_peer *peer, unsigned tid); 144 145 QDF_STATUS dp_rx_defrag_add_last_frag(struct dp_soc *soc, 146 struct dp_peer *peer, uint16_t tid, 147 uint16_t rxseq, qdf_nbuf_t nbuf); 148 #endif /* _DP_RX_DEFRAG_H */ 149