| 1 |
/* SPDX-License-Identifier: BSD-3-Clause-Clear */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. |
| 4 |
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
| 5 |
*/ |
| 6 |
#ifndef ATH12K_DP_RX_H |
| 7 |
#define ATH12K_DP_RX_H |
| 8 |
|
| 9 |
#include <crypto/hash.h> |
| 10 |
#include "core.h" |
| 11 |
#include "debug.h" |
| 12 |
|
| 13 |
#define DP_MAX_NWIFI_HDR_LEN 30 |
| 14 |
|
| 15 |
struct ath12k_reoq_buf { |
| 16 |
void *vaddr; |
| 17 |
dma_addr_t paddr_aligned; |
| 18 |
u32 size; |
| 19 |
}; |
| 20 |
|
| 21 |
struct ath12k_dp_rx_tid { |
| 22 |
u8 tid; |
| 23 |
u32 ba_win_sz; |
| 24 |
struct ath12k_reoq_buf qbuf; |
| 25 |
|
| 26 |
/* Info related to rx fragments */ |
| 27 |
u32 cur_sn; |
| 28 |
u16 last_frag_no; |
| 29 |
u16 rx_frag_bitmap; |
| 30 |
|
| 31 |
struct sk_buff_head rx_frags; |
| 32 |
struct hal_reo_dest_ring *dst_ring_desc; |
| 33 |
|
| 34 |
/* Timer info related to fragments */ |
| 35 |
struct timer_list frag_timer; |
| 36 |
struct ath12k_dp *dp; |
| 37 |
}; |
| 38 |
|
| 39 |
struct ath12k_dp_rx_tid_rxq { |
| 40 |
u8 tid; |
| 41 |
bool active; |
| 42 |
struct ath12k_reoq_buf qbuf; |
| 43 |
}; |
| 44 |
|
| 45 |
struct ath12k_dp_rx_reo_cache_flush_elem { |
| 46 |
struct list_head list; |
| 47 |
struct ath12k_dp_rx_tid_rxq data; |
| 48 |
unsigned long ts; |
| 49 |
}; |
| 50 |
|
| 51 |
struct dp_reo_update_rx_queue_elem { |
| 52 |
struct list_head list; |
| 53 |
struct ath12k_dp_rx_tid_rxq rx_tid; |
| 54 |
int peer_id; |
| 55 |
bool is_ml_peer; |
| 56 |
u16 ml_peer_id; |
| 57 |
}; |
| 58 |
|
| 59 |
struct ath12k_dp_rx_reo_cmd { |
| 60 |
struct list_head list; |
| 61 |
struct ath12k_dp_rx_tid_rxq data; |
| 62 |
int cmd_num; |
| 63 |
void (*handler)(struct ath12k_dp *dp, void *ctx, |
| 64 |
enum hal_reo_cmd_status status); |
| 65 |
}; |
| 66 |
|
| 67 |
#define ATH12K_DP_RX_FRAGMENT_TIMEOUT_MS (2 * HZ) |
| 68 |
|
| 69 |
#define ATH12K_DP_RX_REO_DESC_FREE_THRES 64 |
| 70 |
#define ATH12K_DP_RX_REO_DESC_FREE_TIMEOUT_MS 1000 |
| 71 |
|
| 72 |
enum ath12k_dp_rx_decap_type { |
| 73 |
DP_RX_DECAP_TYPE_RAW, |
| 74 |
DP_RX_DECAP_TYPE_NATIVE_WIFI, |
| 75 |
DP_RX_DECAP_TYPE_ETHERNET2_DIX, |
| 76 |
DP_RX_DECAP_TYPE_8023, |
| 77 |
}; |
| 78 |
|
| 79 |
struct ath12k_dp_rx_rfc1042_hdr { |
| 80 |
u8 llc_dsap; |
| 81 |
u8 llc_ssap; |
| 82 |
u8 llc_ctrl; |
| 83 |
u8 snap_oui[3]; |
| 84 |
__be16 snap_type; |
| 85 |
} __packed; |
| 86 |
|
| 87 |
static inline u32 ath12k_he_gi_to_nl80211_he_gi(u8 sgi) |
| 88 |
{ |
| 89 |
u32 ret = 0; |
| 90 |
|
| 91 |
switch (sgi) { |
| 92 |
case RX_MSDU_START_SGI_0_8_US: |
| 93 |
ret = NL80211_RATE_INFO_HE_GI_0_8; |
| 94 |
break; |
| 95 |
case RX_MSDU_START_SGI_1_6_US: |
| 96 |
ret = NL80211_RATE_INFO_HE_GI_1_6; |
| 97 |
break; |
| 98 |
case RX_MSDU_START_SGI_3_2_US: |
| 99 |
ret = NL80211_RATE_INFO_HE_GI_3_2; |
| 100 |
break; |
| 101 |
default: |
| 102 |
ret = NL80211_RATE_INFO_HE_GI_0_8; |
| 103 |
break; |
| 104 |
} |
| 105 |
|
| 106 |
return ret; |
| 107 |
} |
| 108 |
|
| 109 |
static inline bool ath12k_dp_rx_h_more_frags(struct ath12k_hal *hal, |
| 110 |
struct sk_buff *skb) |
| 111 |
{ |
| 112 |
struct ieee80211_hdr *hdr; |
| 113 |
|
| 114 |
hdr = (struct ieee80211_hdr *)(skb->data + hal->hal_desc_sz); |
| 115 |
return ieee80211_has_morefrags(hdr->frame_control); |
| 116 |
} |
| 117 |
|
| 118 |
static inline u16 ath12k_dp_rx_h_frag_no(struct ath12k_hal *hal, |
| 119 |
struct sk_buff *skb) |
| 120 |
{ |
| 121 |
struct ieee80211_hdr *hdr; |
| 122 |
|
| 123 |
hdr = (struct ieee80211_hdr *)(skb->data + hal->hal_desc_sz); |
| 124 |
return le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG; |
| 125 |
} |
| 126 |
|
| 127 |
static inline u8 ath12k_dp_rx_h_l3pad(struct ath12k_base *ab, |
| 128 |
struct hal_rx_desc *desc) |
| 129 |
{ |
| 130 |
return ab->hal.ops->rx_desc_get_l3_pad_bytes(desc); |
| 131 |
} |
| 132 |
|
| 133 |
static inline void ath12k_dp_rx_desc_end_tlv_copy(struct ath12k_hal *hal, |
| 134 |
struct hal_rx_desc *fdesc, |
| 135 |
struct hal_rx_desc *ldesc) |
| 136 |
{ |
| 137 |
hal->ops->rx_desc_copy_end_tlv(fdesc, ldesc); |
| 138 |
} |
| 139 |
|
| 140 |
static inline void ath12k_dp_rxdesc_set_msdu_len(struct ath12k_hal *hal, |
| 141 |
struct hal_rx_desc *desc, |
| 142 |
u16 len) |
| 143 |
{ |
| 144 |
hal->ops->rx_desc_set_msdu_len(desc, len); |
| 145 |
} |
| 146 |
|
| 147 |
static inline u32 ath12k_dp_rxdesc_get_ppduid(struct ath12k_base *ab, |
| 148 |
struct hal_rx_desc *rx_desc) |
| 149 |
{ |
| 150 |
return ab->hal.ops->rx_desc_get_mpdu_ppdu_id(rx_desc); |
| 151 |
} |
| 152 |
|
| 153 |
static inline void ath12k_dp_rx_desc_get_dot11_hdr(struct ath12k_hal *hal, |
| 154 |
struct hal_rx_desc *desc, |
| 155 |
struct ieee80211_hdr *hdr) |
| 156 |
{ |
| 157 |
hal->ops->rx_desc_get_dot11_hdr(desc, hdr); |
| 158 |
} |
| 159 |
|
| 160 |
static inline void ath12k_dp_rx_desc_get_crypto_header(struct ath12k_hal *hal, |
| 161 |
struct hal_rx_desc *desc, |
| 162 |
u8 *crypto_hdr, |
| 163 |
enum hal_encrypt_type enctype) |
| 164 |
{ |
| 165 |
hal->ops->rx_desc_get_crypto_header(desc, crypto_hdr, enctype); |
| 166 |
} |
| 167 |
|
| 168 |
static inline u8 ath12k_dp_rx_get_msdu_src_link(struct ath12k_hal *hal, |
| 169 |
struct hal_rx_desc *desc) |
| 170 |
{ |
| 171 |
return hal->ops->rx_desc_get_msdu_src_link_id(desc); |
| 172 |
} |
| 173 |
|
| 174 |
static inline void ath12k_dp_clean_up_skb_list(struct sk_buff_head *skb_list) |
| 175 |
{ |
| 176 |
struct sk_buff *skb; |
| 177 |
|
| 178 |
while ((skb = __skb_dequeue(skb_list))) |
| 179 |
dev_kfree_skb_any(skb); |
| 180 |
} |
| 181 |
|
| 182 |
static inline |
| 183 |
void ath12k_dp_extract_rx_desc_data(struct ath12k_hal *hal, |
| 184 |
struct hal_rx_desc_data *rx_info, |
| 185 |
struct hal_rx_desc *rx_desc, |
| 186 |
struct hal_rx_desc *ldesc) |
| 187 |
{ |
| 188 |
hal->ops->extract_rx_desc_data(rx_info, rx_desc, ldesc); |
| 189 |
} |
| 190 |
|
| 191 |
void ath12k_dp_rx_h_undecap(struct ath12k_pdev_dp *dp_pdev, struct sk_buff *msdu, |
| 192 |
struct hal_rx_desc *rx_desc, |
| 193 |
enum hal_encrypt_type enctype, |
| 194 |
bool decrypted, |
| 195 |
struct hal_rx_desc_data *rx_info); |
| 196 |
void ath12k_dp_rx_deliver_msdu(struct ath12k_pdev_dp *dp_pdev, struct napi_struct *napi, |
| 197 |
struct sk_buff *msdu, |
| 198 |
struct hal_rx_desc_data *rx_info); |
| 199 |
bool ath12k_dp_rx_check_nwifi_hdr_len_valid(struct ath12k_dp *dp, |
| 200 |
struct hal_rx_desc *rx_desc, |
| 201 |
struct sk_buff *msdu, |
| 202 |
struct hal_rx_desc_data *rx_info); |
| 203 |
u64 ath12k_dp_rx_h_get_pn(struct ath12k_dp *dp, struct sk_buff *skb); |
| 204 |
void ath12k_dp_rx_h_sort_frags(struct ath12k_hal *hal, |
| 205 |
struct sk_buff_head *frag_list, |
| 206 |
struct sk_buff *cur_frag); |
| 207 |
void ath12k_dp_rx_h_undecap_frag(struct ath12k_pdev_dp *dp_pdev, struct sk_buff *msdu, |
| 208 |
enum hal_encrypt_type enctype, u32 flags); |
| 209 |
int ath12k_dp_rx_h_michael_mic(struct crypto_shash *tfm, u8 *key, |
| 210 |
struct ieee80211_hdr *hdr, u8 *data, |
| 211 |
size_t data_len, u8 *mic); |
| 212 |
int ath12k_dp_rx_ampdu_start(struct ath12k *ar, |
| 213 |
struct ieee80211_ampdu_params *params, |
| 214 |
u8 link_id); |
| 215 |
int ath12k_dp_rx_ampdu_stop(struct ath12k *ar, |
| 216 |
struct ieee80211_ampdu_params *params, |
| 217 |
u8 link_id); |
| 218 |
int ath12k_dp_rx_peer_pn_replay_config(struct ath12k_link_vif *arvif, |
| 219 |
const u8 *peer_addr, |
| 220 |
enum set_key_cmd key_cmd, |
| 221 |
struct ieee80211_key_conf *key); |
| 222 |
void ath12k_dp_rx_peer_tid_cleanup(struct ath12k *ar, struct ath12k_dp_link_peer *peer); |
| 223 |
void ath12k_dp_rx_peer_tid_delete(struct ath12k *ar, |
| 224 |
struct ath12k_dp_link_peer *peer, u8 tid); |
| 225 |
int ath12k_dp_rx_peer_tid_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id, |
| 226 |
u8 tid, u32 ba_win_sz, u16 ssn, |
| 227 |
enum hal_pn_type pn_type); |
| 228 |
int ath12k_dp_rx_pdev_reo_setup(struct ath12k_base *ab); |
| 229 |
void ath12k_dp_rx_pdev_reo_cleanup(struct ath12k_base *ab); |
| 230 |
int ath12k_dp_rx_htt_setup(struct ath12k_base *ab); |
| 231 |
int ath12k_dp_rx_alloc(struct ath12k_base *ab); |
| 232 |
void ath12k_dp_rx_free(struct ath12k_base *ab); |
| 233 |
int ath12k_dp_rx_pdev_alloc(struct ath12k_base *ab, int pdev_idx); |
| 234 |
void ath12k_dp_rx_pdev_free(struct ath12k_base *ab, int pdev_idx); |
| 235 |
void ath12k_dp_rx_reo_cmd_list_cleanup(struct ath12k_base *ab); |
| 236 |
int ath12k_dp_rx_bufs_replenish(struct ath12k_dp *dp, |
| 237 |
struct dp_rxdma_ring *rx_ring, |
| 238 |
struct list_head *used_list, |
| 239 |
int req_entries); |
| 240 |
int ath12k_dp_rx_pdev_mon_attach(struct ath12k *ar); |
| 241 |
int ath12k_dp_rx_peer_frag_setup(struct ath12k *ar, const u8 *peer_mac, int vdev_id); |
| 242 |
|
| 243 |
u8 ath12k_dp_rx_h_l3pad(struct ath12k_base *ab, |
| 244 |
struct hal_rx_desc *desc); |
| 245 |
struct ath12k_dp_link_peer * |
| 246 |
ath12k_dp_rx_h_find_link_peer(struct ath12k_pdev_dp *dp_pdev, struct sk_buff *msdu, |
| 247 |
struct hal_rx_desc_data *rx_info); |
| 248 |
u8 ath12k_dp_rx_h_decap_type(struct ath12k_base *ab, |
| 249 |
struct hal_rx_desc *desc); |
| 250 |
u32 ath12k_dp_rx_h_mpdu_err(struct ath12k_base *ab, |
| 251 |
struct hal_rx_desc *desc); |
| 252 |
int ath12k_dp_rx_crypto_mic_len(struct ath12k_dp *dp, enum hal_encrypt_type enctype); |
| 253 |
u32 ath12k_dp_rxdesc_get_ppduid(struct ath12k_base *ab, |
| 254 |
struct hal_rx_desc *rx_desc); |
| 255 |
void ath12k_dp_rx_h_ppdu(struct ath12k_pdev_dp *dp_pdev, |
| 256 |
struct hal_rx_desc_data *rx_info); |
| 257 |
struct sk_buff *ath12k_dp_rx_get_msdu_last_buf(struct sk_buff_head *msdu_list, |
| 258 |
struct sk_buff *first); |
| 259 |
void ath12k_dp_reo_cmd_free(struct ath12k_dp *dp, void *ctx, |
| 260 |
enum hal_reo_cmd_status status); |
| 261 |
void ath12k_dp_rx_tid_del_func(struct ath12k_dp *dp, void *ctx, |
| 262 |
enum hal_reo_cmd_status status); |
| 263 |
void ath12k_dp_rx_process_reo_cmd_update_rx_queue_list(struct ath12k_dp *dp); |
| 264 |
void ath12k_dp_init_rx_tid_rxq(struct ath12k_dp_rx_tid_rxq *rx_tid_rxq, |
| 265 |
struct ath12k_dp_rx_tid *rx_tid, |
| 266 |
bool active); |
| 267 |
void ath12k_dp_mark_tid_as_inactive(struct ath12k_dp *dp, int peer_id, u8 tid); |
| 268 |
#endif /* ATH12K_DP_RX_H */ |