| 1 |
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause |
| 2 |
/* |
| 3 |
* Copyright (C) 2012-2014, 2018-2025 Intel Corporation |
| 4 |
* Copyright (C) 2013-2015 Intel Mobile Communications GmbH |
| 5 |
* Copyright (C) 2015-2017 Intel Deutschland GmbH |
| 6 |
*/ |
| 7 |
#include <linux/etherdevice.h> |
| 8 |
#include <linux/skbuff.h> |
| 9 |
#include "iwl-trans.h" |
| 10 |
#include "mvm.h" |
| 11 |
#include "fw-api.h" |
| 12 |
#include "time-sync.h" |
| 13 |
|
| 14 |
static inline int iwl_mvm_check_pn(struct iwl_mvm *mvm, struct sk_buff *skb, |
| 15 |
int queue, struct ieee80211_sta *sta) |
| 16 |
{ |
| 17 |
struct iwl_mvm_sta *mvmsta; |
| 18 |
struct ieee80211_hdr *hdr = (void *)skb_mac_header(skb); |
| 19 |
struct ieee80211_rx_status *stats = IEEE80211_SKB_RXCB(skb); |
| 20 |
struct iwl_mvm_key_pn *ptk_pn; |
| 21 |
int res; |
| 22 |
u8 tid, keyidx; |
| 23 |
u8 pn[IEEE80211_CCMP_PN_LEN]; |
| 24 |
u8 *extiv; |
| 25 |
|
| 26 |
/* do PN checking */ |
| 27 |
|
| 28 |
/* multicast and non-data only arrives on default queue */ |
| 29 |
if (!ieee80211_is_data(hdr->frame_control) || |
| 30 |
is_multicast_ether_addr(hdr->addr1)) |
| 31 |
return 0; |
| 32 |
|
| 33 |
/* do not check PN for open AP */ |
| 34 |
if (!(stats->flag & RX_FLAG_DECRYPTED)) |
| 35 |
return 0; |
| 36 |
|
| 37 |
/* |
| 38 |
* avoid checking for default queue - we don't want to replicate |
| 39 |
* all the logic that's necessary for checking the PN on fragmented |
| 40 |
* frames, leave that to mac80211 |
| 41 |
*/ |
| 42 |
if (queue == 0) |
| 43 |
return 0; |
| 44 |
|
| 45 |
/* if we are here - this for sure is either CCMP or GCMP */ |
| 46 |
if (IS_ERR_OR_NULL(sta)) { |
| 47 |
IWL_DEBUG_DROP(mvm, |
| 48 |
"expected hw-decrypted unicast frame for station\n"); |
| 49 |
return -1; |
| 50 |
} |
| 51 |
|
| 52 |
mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 53 |
|
| 54 |
extiv = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control); |
| 55 |
keyidx = extiv[3] >> 6; |
| 56 |
|
| 57 |
ptk_pn = rcu_dereference(mvmsta->ptk_pn[keyidx]); |
| 58 |
if (!ptk_pn) |
| 59 |
return -1; |
| 60 |
|
| 61 |
if (ieee80211_is_data_qos(hdr->frame_control)) |
| 62 |
tid = ieee80211_get_tid(hdr); |
| 63 |
else |
| 64 |
tid = 0; |
| 65 |
|
| 66 |
/* we don't use HCCA/802.11 QoS TSPECs, so drop such frames */ |
| 67 |
if (tid >= IWL_MAX_TID_COUNT) |
| 68 |
return -1; |
| 69 |
|
| 70 |
/* load pn */ |
| 71 |
pn[0] = extiv[7]; |
| 72 |
pn[1] = extiv[6]; |
| 73 |
pn[2] = extiv[5]; |
| 74 |
pn[3] = extiv[4]; |
| 75 |
pn[4] = extiv[1]; |
| 76 |
pn[5] = extiv[0]; |
| 77 |
|
| 78 |
res = memcmp(pn, ptk_pn->q[queue].pn[tid], IEEE80211_CCMP_PN_LEN); |
| 79 |
if (res < 0) |
| 80 |
return -1; |
| 81 |
if (!res && !(stats->flag & RX_FLAG_ALLOW_SAME_PN)) |
| 82 |
return -1; |
| 83 |
|
| 84 |
memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN); |
| 85 |
stats->flag |= RX_FLAG_PN_VALIDATED; |
| 86 |
|
| 87 |
return 0; |
| 88 |
} |
| 89 |
|
| 90 |
/* iwl_mvm_create_skb Adds the rxb to a new skb */ |
| 91 |
static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, |
| 92 |
struct ieee80211_hdr *hdr, u16 len, u8 crypt_len, |
| 93 |
struct iwl_rx_cmd_buffer *rxb) |
| 94 |
{ |
| 95 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 96 |
struct iwl_rx_mpdu_desc *desc = (void *)pkt->data; |
| 97 |
unsigned int headlen, fraglen, pad_len = 0; |
| 98 |
unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control); |
| 99 |
u8 mic_crc_len = u8_get_bits(desc->mac_flags1, |
| 100 |
IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_MASK) << 1; |
| 101 |
|
| 102 |
if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD) { |
| 103 |
len -= 2; |
| 104 |
pad_len = 2; |
| 105 |
} |
| 106 |
|
| 107 |
/* |
| 108 |
* For non monitor interface strip the bytes the RADA might not have |
| 109 |
* removed (it might be disabled, e.g. for mgmt frames). As a monitor |
| 110 |
* interface cannot exist with other interfaces, this removal is safe |
| 111 |
* and sufficient, in monitor mode there's no decryption being done. |
| 112 |
*/ |
| 113 |
if (len > mic_crc_len && !ieee80211_hw_check(mvm->hw, RX_INCLUDES_FCS)) |
| 114 |
len -= mic_crc_len; |
| 115 |
|
| 116 |
/* If frame is small enough to fit in skb->head, pull it completely. |
| 117 |
* If not, only pull ieee80211_hdr (including crypto if present, and |
| 118 |
* an additional 8 bytes for SNAP/ethertype, see below) so that |
| 119 |
* splice() or TCP coalesce are more efficient. |
| 120 |
* |
| 121 |
* Since, in addition, ieee80211_data_to_8023() always pull in at |
| 122 |
* least 8 bytes (possibly more for mesh) we can do the same here |
| 123 |
* to save the cost of doing it later. That still doesn't pull in |
| 124 |
* the actual IP header since the typical case has a SNAP header. |
| 125 |
* If the latter changes (there are efforts in the standards group |
| 126 |
* to do so) we should revisit this and ieee80211_data_to_8023(). |
| 127 |
*/ |
| 128 |
headlen = (len <= skb_tailroom(skb)) ? len : |
| 129 |
hdrlen + crypt_len + 8; |
| 130 |
|
| 131 |
/* The firmware may align the packet to DWORD. |
| 132 |
* The padding is inserted after the IV. |
| 133 |
* After copying the header + IV skip the padding if |
| 134 |
* present before copying packet data. |
| 135 |
*/ |
| 136 |
hdrlen += crypt_len; |
| 137 |
|
| 138 |
if (unlikely(headlen < hdrlen)) |
| 139 |
return -EINVAL; |
| 140 |
|
| 141 |
/* Since data doesn't move data while putting data on skb and that is |
| 142 |
* the only way we use, data + len is the next place that hdr would be put |
| 143 |
*/ |
| 144 |
skb_set_mac_header(skb, skb->len); |
| 145 |
skb_put_data(skb, hdr, hdrlen); |
| 146 |
skb_put_data(skb, (u8 *)hdr + hdrlen + pad_len, headlen - hdrlen); |
| 147 |
|
| 148 |
/* |
| 149 |
* If we did CHECKSUM_COMPLETE, the hardware only does it right for |
| 150 |
* certain cases and starts the checksum after the SNAP. Check if |
| 151 |
* this is the case - it's easier to just bail out to CHECKSUM_NONE |
| 152 |
* in the cases the hardware didn't handle, since it's rare to see |
| 153 |
* such packets, even though the hardware did calculate the checksum |
| 154 |
* in this case, just starting after the MAC header instead. |
| 155 |
* |
| 156 |
* Starting from Bz hardware, it calculates starting directly after |
| 157 |
* the MAC header, so that matches mac80211's expectation. |
| 158 |
*/ |
| 159 |
if (skb->ip_summed == CHECKSUM_COMPLETE) { |
| 160 |
struct { |
| 161 |
u8 hdr[6]; |
| 162 |
__be16 type; |
| 163 |
} __packed *shdr = (void *)((u8 *)hdr + hdrlen + pad_len); |
| 164 |
|
| 165 |
if (unlikely(headlen - hdrlen < sizeof(*shdr) || |
| 166 |
!ether_addr_equal(shdr->hdr, rfc1042_header) || |
| 167 |
(shdr->type != htons(ETH_P_IP) && |
| 168 |
shdr->type != htons(ETH_P_ARP) && |
| 169 |
shdr->type != htons(ETH_P_IPV6) && |
| 170 |
shdr->type != htons(ETH_P_8021Q) && |
| 171 |
shdr->type != htons(ETH_P_PAE) && |
| 172 |
shdr->type != htons(ETH_P_TDLS)))) |
| 173 |
skb->ip_summed = CHECKSUM_NONE; |
| 174 |
else if (mvm->trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_BZ) |
| 175 |
/* mac80211 assumes full CSUM including SNAP header */ |
| 176 |
skb_postpush_rcsum(skb, shdr, sizeof(*shdr)); |
| 177 |
} |
| 178 |
|
| 179 |
fraglen = len - headlen; |
| 180 |
|
| 181 |
if (fraglen) { |
| 182 |
int offset = (u8 *)hdr + headlen + pad_len - |
| 183 |
(u8 *)rxb_addr(rxb) + rxb_offset(rxb); |
| 184 |
|
| 185 |
skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset, |
| 186 |
fraglen, rxb->truesize); |
| 187 |
} |
| 188 |
|
| 189 |
return 0; |
| 190 |
} |
| 191 |
|
| 192 |
/* put a TLV on the skb and return data pointer |
| 193 |
* |
| 194 |
* Also pad to 4 the len and zero out all data part |
| 195 |
*/ |
| 196 |
static void * |
| 197 |
iwl_mvm_radiotap_put_tlv(struct sk_buff *skb, u16 type, u16 len) |
| 198 |
{ |
| 199 |
struct ieee80211_radiotap_tlv *tlv; |
| 200 |
|
| 201 |
tlv = skb_put(skb, sizeof(*tlv)); |
| 202 |
tlv->type = cpu_to_le16(type); |
| 203 |
tlv->len = cpu_to_le16(len); |
| 204 |
return skb_put_zero(skb, ALIGN(len, 4)); |
| 205 |
} |
| 206 |
|
| 207 |
static void iwl_mvm_add_rtap_sniffer_config(struct iwl_mvm *mvm, |
| 208 |
struct sk_buff *skb) |
| 209 |
{ |
| 210 |
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); |
| 211 |
struct ieee80211_radiotap_vendor_content *radiotap; |
| 212 |
const u16 vendor_data_len = sizeof(mvm->cur_aid); |
| 213 |
|
| 214 |
if (!mvm->cur_aid) |
| 215 |
return; |
| 216 |
|
| 217 |
radiotap = iwl_mvm_radiotap_put_tlv(skb, |
| 218 |
IEEE80211_RADIOTAP_VENDOR_NAMESPACE, |
| 219 |
sizeof(*radiotap) + vendor_data_len); |
| 220 |
|
| 221 |
/* Intel OUI */ |
| 222 |
radiotap->oui[0] = 0xf6; |
| 223 |
radiotap->oui[1] = 0x54; |
| 224 |
radiotap->oui[2] = 0x25; |
| 225 |
/* radiotap sniffer config sub-namespace */ |
| 226 |
radiotap->oui_subtype = 1; |
| 227 |
radiotap->vendor_type = 0; |
| 228 |
|
| 229 |
/* fill the data now */ |
| 230 |
memcpy(radiotap->data, &mvm->cur_aid, sizeof(mvm->cur_aid)); |
| 231 |
|
| 232 |
rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END; |
| 233 |
} |
| 234 |
|
| 235 |
/* iwl_mvm_pass_packet_to_mac80211 - passes the packet for mac80211 */ |
| 236 |
static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm, |
| 237 |
struct napi_struct *napi, |
| 238 |
struct sk_buff *skb, int queue, |
| 239 |
struct ieee80211_sta *sta) |
| 240 |
{ |
| 241 |
if (unlikely(iwl_mvm_check_pn(mvm, skb, queue, sta))) { |
| 242 |
kfree_skb(skb); |
| 243 |
return; |
| 244 |
} |
| 245 |
|
| 246 |
ieee80211_rx_napi(mvm->hw, sta, skb, napi); |
| 247 |
} |
| 248 |
|
| 249 |
static bool iwl_mvm_used_average_energy(struct iwl_mvm *mvm, |
| 250 |
struct iwl_rx_mpdu_desc *desc, |
| 251 |
struct ieee80211_hdr *hdr, |
| 252 |
struct ieee80211_rx_status *rx_status) |
| 253 |
{ |
| 254 |
struct iwl_mvm_vif *mvm_vif; |
| 255 |
struct ieee80211_vif *vif; |
| 256 |
u32 id; |
| 257 |
|
| 258 |
if (unlikely(!hdr || !desc)) |
| 259 |
return false; |
| 260 |
|
| 261 |
if (likely(!ieee80211_is_beacon(hdr->frame_control))) |
| 262 |
return false; |
| 263 |
|
| 264 |
/* for the link conf lookup */ |
| 265 |
guard(rcu)(); |
| 266 |
|
| 267 |
/* MAC or link ID depending on FW, but driver has them equal */ |
| 268 |
id = u8_get_bits(desc->mac_phy_band, |
| 269 |
IWL_RX_MPDU_MAC_PHY_BAND_MAC_MASK); |
| 270 |
|
| 271 |
/* >= means AUX MAC/link ID, no energy correction needed then */ |
| 272 |
if (id >= ARRAY_SIZE(mvm->vif_id_to_mac)) |
| 273 |
return false; |
| 274 |
|
| 275 |
vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true); |
| 276 |
if (!vif) |
| 277 |
return false; |
| 278 |
|
| 279 |
mvm_vif = iwl_mvm_vif_from_mac80211(vif); |
| 280 |
|
| 281 |
/* |
| 282 |
* If we know the MAC by MAC or link ID then the frame was |
| 283 |
* received for the link, so by filtering it means it was |
| 284 |
* from the AP the link is connected to. |
| 285 |
*/ |
| 286 |
|
| 287 |
/* skip also in case we don't have it (yet) */ |
| 288 |
if (!mvm_vif->deflink.average_beacon_energy) |
| 289 |
return false; |
| 290 |
|
| 291 |
IWL_DEBUG_STATS(mvm, "energy override by average %d\n", |
| 292 |
mvm_vif->deflink.average_beacon_energy); |
| 293 |
rx_status->signal = -mvm_vif->deflink.average_beacon_energy; |
| 294 |
return true; |
| 295 |
} |
| 296 |
|
| 297 |
static void iwl_mvm_get_signal_strength(struct iwl_mvm *mvm, |
| 298 |
struct iwl_rx_mpdu_desc *desc, |
| 299 |
struct ieee80211_hdr *hdr, |
| 300 |
struct ieee80211_rx_status *rx_status, |
| 301 |
u32 rate_n_flags, int energy_a, |
| 302 |
int energy_b) |
| 303 |
{ |
| 304 |
int max_energy; |
| 305 |
|
| 306 |
energy_a = energy_a ? -energy_a : S8_MIN; |
| 307 |
energy_b = energy_b ? -energy_b : S8_MIN; |
| 308 |
max_energy = max(energy_a, energy_b); |
| 309 |
|
| 310 |
IWL_DEBUG_STATS(mvm, "energy In A %d B %d, and max %d\n", |
| 311 |
energy_a, energy_b, max_energy); |
| 312 |
|
| 313 |
if (iwl_mvm_used_average_energy(mvm, desc, hdr, rx_status)) |
| 314 |
return; |
| 315 |
|
| 316 |
rx_status->signal = max_energy; |
| 317 |
rx_status->chains = u32_get_bits(rate_n_flags, RATE_MCS_ANT_AB_MSK); |
| 318 |
rx_status->chain_signal[0] = energy_a; |
| 319 |
rx_status->chain_signal[1] = energy_b; |
| 320 |
} |
| 321 |
|
| 322 |
static int iwl_mvm_rx_mgmt_prot(struct ieee80211_sta *sta, |
| 323 |
struct ieee80211_hdr *hdr, |
| 324 |
struct iwl_rx_mpdu_desc *desc, |
| 325 |
u32 status, |
| 326 |
struct ieee80211_rx_status *stats) |
| 327 |
{ |
| 328 |
struct wireless_dev *wdev; |
| 329 |
struct iwl_mvm_sta *mvmsta; |
| 330 |
struct iwl_mvm_vif *mvmvif; |
| 331 |
u8 keyid; |
| 332 |
struct ieee80211_key_conf *key; |
| 333 |
u32 len = le16_to_cpu(desc->mpdu_len); |
| 334 |
const u8 *frame = (void *)hdr; |
| 335 |
const u8 *mmie; |
| 336 |
|
| 337 |
if ((status & IWL_RX_MPDU_STATUS_SEC_MASK) == IWL_RX_MPDU_STATUS_SEC_NONE) |
| 338 |
return 0; |
| 339 |
|
| 340 |
/* |
| 341 |
* For non-beacon, we don't really care. But beacons may |
| 342 |
* be filtered out, and we thus need the firmware's replay |
| 343 |
* detection, otherwise beacons the firmware previously |
| 344 |
* filtered could be replayed, or something like that, and |
| 345 |
* it can filter a lot - though usually only if nothing has |
| 346 |
* changed. |
| 347 |
*/ |
| 348 |
if (!ieee80211_is_beacon(hdr->frame_control)) |
| 349 |
return 0; |
| 350 |
|
| 351 |
if (!sta) |
| 352 |
return -1; |
| 353 |
|
| 354 |
mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 355 |
mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif); |
| 356 |
|
| 357 |
/* key mismatch - will also report !MIC_OK but we shouldn't count it */ |
| 358 |
if (!(status & IWL_RX_MPDU_STATUS_KEY_VALID)) |
| 359 |
goto report; |
| 360 |
|
| 361 |
/* good cases */ |
| 362 |
if (likely(status & IWL_RX_MPDU_STATUS_MIC_OK && |
| 363 |
!(status & IWL_RX_MPDU_STATUS_REPLAY_ERROR))) { |
| 364 |
stats->flag |= RX_FLAG_DECRYPTED; |
| 365 |
return 0; |
| 366 |
} |
| 367 |
|
| 368 |
/* |
| 369 |
* both keys will have the same cipher and MIC length, use |
| 370 |
* whichever one is available |
| 371 |
*/ |
| 372 |
key = rcu_dereference(mvmvif->bcn_prot.keys[0]); |
| 373 |
if (!key) { |
| 374 |
key = rcu_dereference(mvmvif->bcn_prot.keys[1]); |
| 375 |
if (!key) |
| 376 |
goto report; |
| 377 |
} |
| 378 |
|
| 379 |
if (len < key->icv_len) |
| 380 |
goto report; |
| 381 |
|
| 382 |
/* get the real key ID */ |
| 383 |
mmie = frame + (len - key->icv_len); |
| 384 |
|
| 385 |
/* the position of the key_id in ieee80211_mmie_16 is the same */ |
| 386 |
keyid = le16_to_cpu(((const struct ieee80211_mmie *) mmie)->key_id); |
| 387 |
|
| 388 |
/* and if that's the other key, look it up */ |
| 389 |
if (keyid != key->keyidx) { |
| 390 |
/* |
| 391 |
* shouldn't happen since firmware checked, but be safe |
| 392 |
* in case the MIC length is wrong too, for example |
| 393 |
*/ |
| 394 |
if (keyid != 6 && keyid != 7) |
| 395 |
return -1; |
| 396 |
key = rcu_dereference(mvmvif->bcn_prot.keys[keyid - 6]); |
| 397 |
if (!key) |
| 398 |
goto report; |
| 399 |
} |
| 400 |
|
| 401 |
/* Report status to mac80211 */ |
| 402 |
if (!(status & IWL_RX_MPDU_STATUS_MIC_OK)) |
| 403 |
ieee80211_key_mic_failure(key); |
| 404 |
else if (status & IWL_RX_MPDU_STATUS_REPLAY_ERROR) |
| 405 |
ieee80211_key_replay(key); |
| 406 |
report: |
| 407 |
wdev = ieee80211_vif_to_wdev(mvmsta->vif); |
| 408 |
if (wdev->netdev) |
| 409 |
cfg80211_rx_unprot_mlme_mgmt(wdev->netdev, (void *)hdr, len); |
| 410 |
|
| 411 |
return -1; |
| 412 |
} |
| 413 |
|
| 414 |
static int iwl_mvm_rx_crypto(struct iwl_mvm *mvm, struct ieee80211_sta *sta, |
| 415 |
struct ieee80211_hdr *hdr, |
| 416 |
struct ieee80211_rx_status *stats, u16 phy_info, |
| 417 |
struct iwl_rx_mpdu_desc *desc, |
| 418 |
u32 pkt_flags, int queue, u8 *crypt_len) |
| 419 |
{ |
| 420 |
u32 status = le32_to_cpu(desc->status); |
| 421 |
|
| 422 |
/* |
| 423 |
* Drop UNKNOWN frames in aggregation, unless in monitor mode |
| 424 |
* (where we don't have the keys). |
| 425 |
* We limit this to aggregation because in TKIP this is a valid |
| 426 |
* scenario, since we may not have the (correct) TTAK (phase 1 |
| 427 |
* key) in the firmware. |
| 428 |
*/ |
| 429 |
if (phy_info & IWL_RX_MPDU_PHY_AMPDU && |
| 430 |
(status & IWL_RX_MPDU_STATUS_SEC_MASK) == |
| 431 |
IWL_RX_MPDU_STATUS_SEC_UNKNOWN && !mvm->monitor_on) { |
| 432 |
IWL_DEBUG_DROP(mvm, "Dropping packets, bad enc status\n"); |
| 433 |
return -1; |
| 434 |
} |
| 435 |
|
| 436 |
if (unlikely(ieee80211_is_mgmt(hdr->frame_control) && |
| 437 |
!ieee80211_has_protected(hdr->frame_control))) |
| 438 |
return iwl_mvm_rx_mgmt_prot(sta, hdr, desc, status, stats); |
| 439 |
|
| 440 |
if (!ieee80211_has_protected(hdr->frame_control) || |
| 441 |
(status & IWL_RX_MPDU_STATUS_SEC_MASK) == |
| 442 |
IWL_RX_MPDU_STATUS_SEC_NONE) |
| 443 |
return 0; |
| 444 |
|
| 445 |
/* TODO: handle packets encrypted with unknown alg */ |
| 446 |
|
| 447 |
switch (status & IWL_RX_MPDU_STATUS_SEC_MASK) { |
| 448 |
case IWL_RX_MPDU_STATUS_SEC_CCM: |
| 449 |
case IWL_RX_MPDU_STATUS_SEC_GCM: |
| 450 |
BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN != IEEE80211_GCMP_PN_LEN); |
| 451 |
/* alg is CCM: check MIC only */ |
| 452 |
if (!(status & IWL_RX_MPDU_STATUS_MIC_OK)) { |
| 453 |
IWL_DEBUG_DROP(mvm, |
| 454 |
"Dropping packet, bad MIC (CCM/GCM)\n"); |
| 455 |
return -1; |
| 456 |
} |
| 457 |
|
| 458 |
stats->flag |= RX_FLAG_DECRYPTED | RX_FLAG_MIC_STRIPPED; |
| 459 |
*crypt_len = IEEE80211_CCMP_HDR_LEN; |
| 460 |
return 0; |
| 461 |
case IWL_RX_MPDU_STATUS_SEC_TKIP: |
| 462 |
/* Don't drop the frame and decrypt it in SW */ |
| 463 |
if (!fw_has_api(&mvm->fw->ucode_capa, |
| 464 |
IWL_UCODE_TLV_API_DEPRECATE_TTAK) && |
| 465 |
!(status & IWL_RX_MPDU_RES_STATUS_TTAK_OK)) |
| 466 |
return 0; |
| 467 |
|
| 468 |
if (mvm->trans->mac_cfg->gen2 && |
| 469 |
!(status & RX_MPDU_RES_STATUS_MIC_OK)) |
| 470 |
stats->flag |= RX_FLAG_MMIC_ERROR; |
| 471 |
|
| 472 |
*crypt_len = IEEE80211_TKIP_IV_LEN; |
| 473 |
fallthrough; |
| 474 |
case IWL_RX_MPDU_STATUS_SEC_WEP: |
| 475 |
if (!(status & IWL_RX_MPDU_STATUS_ICV_OK)) |
| 476 |
return -1; |
| 477 |
|
| 478 |
stats->flag |= RX_FLAG_DECRYPTED; |
| 479 |
if ((status & IWL_RX_MPDU_STATUS_SEC_MASK) == |
| 480 |
IWL_RX_MPDU_STATUS_SEC_WEP) |
| 481 |
*crypt_len = IEEE80211_WEP_IV_LEN; |
| 482 |
|
| 483 |
if (pkt_flags & FH_RSCSR_RADA_EN) { |
| 484 |
stats->flag |= RX_FLAG_ICV_STRIPPED; |
| 485 |
if (mvm->trans->mac_cfg->gen2) |
| 486 |
stats->flag |= RX_FLAG_MMIC_STRIPPED; |
| 487 |
} |
| 488 |
|
| 489 |
return 0; |
| 490 |
case IWL_RX_MPDU_STATUS_SEC_EXT_ENC: |
| 491 |
if (!(status & IWL_RX_MPDU_STATUS_MIC_OK)) |
| 492 |
return -1; |
| 493 |
stats->flag |= RX_FLAG_DECRYPTED; |
| 494 |
return 0; |
| 495 |
case RX_MPDU_RES_STATUS_SEC_CMAC_GMAC_ENC: |
| 496 |
break; |
| 497 |
default: |
| 498 |
/* |
| 499 |
* Sometimes we can get frames that were not decrypted |
| 500 |
* because the firmware didn't have the keys yet. This can |
| 501 |
* happen after connection where we can get multicast frames |
| 502 |
* before the GTK is installed. |
| 503 |
* Silently drop those frames. |
| 504 |
* Also drop un-decrypted frames in monitor mode. |
| 505 |
*/ |
| 506 |
if (!is_multicast_ether_addr(hdr->addr1) && |
| 507 |
!mvm->monitor_on && net_ratelimit()) |
| 508 |
IWL_WARN(mvm, "Unhandled alg: 0x%x\n", status); |
| 509 |
} |
| 510 |
|
| 511 |
return 0; |
| 512 |
} |
| 513 |
|
| 514 |
static void iwl_mvm_rx_csum(struct iwl_mvm *mvm, |
| 515 |
struct ieee80211_sta *sta, |
| 516 |
struct sk_buff *skb, |
| 517 |
struct iwl_rx_packet *pkt) |
| 518 |
{ |
| 519 |
struct iwl_rx_mpdu_desc *desc = (void *)pkt->data; |
| 520 |
|
| 521 |
if (mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { |
| 522 |
if (pkt->len_n_flags & cpu_to_le32(FH_RSCSR_RPA_EN)) { |
| 523 |
u16 hwsum = be16_to_cpu(desc->v3.raw_xsum); |
| 524 |
|
| 525 |
skb->ip_summed = CHECKSUM_COMPLETE; |
| 526 |
skb->csum = csum_unfold(~(__force __sum16)hwsum); |
| 527 |
} |
| 528 |
} else { |
| 529 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 530 |
struct iwl_mvm_vif *mvmvif; |
| 531 |
u16 flags = le16_to_cpu(desc->l3l4_flags); |
| 532 |
u8 l3_prot = (u8)((flags & IWL_RX_L3L4_L3_PROTO_MASK) >> |
| 533 |
IWL_RX_L3_PROTO_POS); |
| 534 |
|
| 535 |
mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif); |
| 536 |
|
| 537 |
if (mvmvif->features & NETIF_F_RXCSUM && |
| 538 |
flags & IWL_RX_L3L4_TCP_UDP_CSUM_OK && |
| 539 |
(flags & IWL_RX_L3L4_IP_HDR_CSUM_OK || |
| 540 |
l3_prot == IWL_RX_L3_TYPE_IPV6 || |
| 541 |
l3_prot == IWL_RX_L3_TYPE_IPV6_FRAG)) |
| 542 |
skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 543 |
} |
| 544 |
} |
| 545 |
|
| 546 |
/* |
| 547 |
* returns true if a packet is a duplicate or invalid tid and should be dropped. |
| 548 |
* Updates AMSDU PN tracking info |
| 549 |
*/ |
| 550 |
static bool iwl_mvm_is_dup(struct ieee80211_sta *sta, int queue, |
| 551 |
struct ieee80211_rx_status *rx_status, |
| 552 |
struct ieee80211_hdr *hdr, |
| 553 |
struct iwl_rx_mpdu_desc *desc) |
| 554 |
{ |
| 555 |
struct iwl_mvm_sta *mvm_sta; |
| 556 |
struct iwl_mvm_rxq_dup_data *dup_data; |
| 557 |
u8 tid, sub_frame_idx; |
| 558 |
|
| 559 |
if (WARN_ON(IS_ERR_OR_NULL(sta))) |
| 560 |
return false; |
| 561 |
|
| 562 |
mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 563 |
|
| 564 |
if (WARN_ON_ONCE(!mvm_sta->dup_data)) |
| 565 |
return false; |
| 566 |
|
| 567 |
dup_data = &mvm_sta->dup_data[queue]; |
| 568 |
|
| 569 |
/* |
| 570 |
* Drop duplicate 802.11 retransmissions |
| 571 |
* (IEEE 802.11-2012: 9.3.2.10 "Duplicate detection and recovery") |
| 572 |
*/ |
| 573 |
if (ieee80211_is_ctl(hdr->frame_control) || |
| 574 |
ieee80211_is_any_nullfunc(hdr->frame_control) || |
| 575 |
is_multicast_ether_addr(hdr->addr1)) |
| 576 |
return false; |
| 577 |
|
| 578 |
if (ieee80211_is_data_qos(hdr->frame_control)) { |
| 579 |
/* frame has qos control */ |
| 580 |
tid = ieee80211_get_tid(hdr); |
| 581 |
if (tid >= IWL_MAX_TID_COUNT) |
| 582 |
return true; |
| 583 |
} else { |
| 584 |
tid = IWL_MAX_TID_COUNT; |
| 585 |
} |
| 586 |
|
| 587 |
/* If this wasn't a part of an A-MSDU the sub-frame index will be 0 */ |
| 588 |
sub_frame_idx = desc->amsdu_info & |
| 589 |
IWL_RX_MPDU_AMSDU_SUBFRAME_IDX_MASK; |
| 590 |
|
| 591 |
if (unlikely(ieee80211_has_retry(hdr->frame_control) && |
| 592 |
dup_data->last_seq[tid] == hdr->seq_ctrl && |
| 593 |
dup_data->last_sub_frame[tid] >= sub_frame_idx)) |
| 594 |
return true; |
| 595 |
|
| 596 |
/* Allow same PN as the first subframe for following sub frames */ |
| 597 |
if (dup_data->last_seq[tid] == hdr->seq_ctrl && |
| 598 |
sub_frame_idx > dup_data->last_sub_frame[tid] && |
| 599 |
desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) |
| 600 |
rx_status->flag |= RX_FLAG_ALLOW_SAME_PN; |
| 601 |
|
| 602 |
dup_data->last_seq[tid] = hdr->seq_ctrl; |
| 603 |
dup_data->last_sub_frame[tid] = sub_frame_idx; |
| 604 |
|
| 605 |
rx_status->flag |= RX_FLAG_DUP_VALIDATED; |
| 606 |
|
| 607 |
return false; |
| 608 |
} |
| 609 |
|
| 610 |
static void iwl_mvm_release_frames(struct iwl_mvm *mvm, |
| 611 |
struct ieee80211_sta *sta, |
| 612 |
struct napi_struct *napi, |
| 613 |
struct iwl_mvm_baid_data *baid_data, |
| 614 |
struct iwl_mvm_reorder_buffer *reorder_buf, |
| 615 |
u16 nssn) |
| 616 |
{ |
| 617 |
struct iwl_mvm_reorder_buf_entry *entries = |
| 618 |
&baid_data->entries[reorder_buf->queue * |
| 619 |
baid_data->entries_per_queue]; |
| 620 |
u16 ssn = reorder_buf->head_sn; |
| 621 |
|
| 622 |
lockdep_assert_held(&reorder_buf->lock); |
| 623 |
|
| 624 |
while (ieee80211_sn_less(ssn, nssn)) { |
| 625 |
int index = ssn % baid_data->buf_size; |
| 626 |
struct sk_buff_head *skb_list = &entries[index].frames; |
| 627 |
struct sk_buff *skb; |
| 628 |
|
| 629 |
ssn = ieee80211_sn_inc(ssn); |
| 630 |
|
| 631 |
/* |
| 632 |
* Empty the list. Will have more than one frame for A-MSDU. |
| 633 |
* Empty list is valid as well since nssn indicates frames were |
| 634 |
* received. |
| 635 |
*/ |
| 636 |
while ((skb = __skb_dequeue(skb_list))) { |
| 637 |
iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, |
| 638 |
reorder_buf->queue, |
| 639 |
sta); |
| 640 |
reorder_buf->num_stored--; |
| 641 |
} |
| 642 |
} |
| 643 |
reorder_buf->head_sn = nssn; |
| 644 |
} |
| 645 |
|
| 646 |
static void iwl_mvm_del_ba(struct iwl_mvm *mvm, int queue, |
| 647 |
struct iwl_mvm_delba_data *data) |
| 648 |
{ |
| 649 |
struct iwl_mvm_baid_data *ba_data; |
| 650 |
struct ieee80211_sta *sta; |
| 651 |
struct iwl_mvm_reorder_buffer *reorder_buf; |
| 652 |
u8 baid = data->baid; |
| 653 |
u32 sta_id; |
| 654 |
|
| 655 |
if (WARN_ONCE(baid >= IWL_MAX_BAID, "invalid BAID: %x\n", baid)) |
| 656 |
return; |
| 657 |
|
| 658 |
rcu_read_lock(); |
| 659 |
|
| 660 |
ba_data = rcu_dereference(mvm->baid_map[baid]); |
| 661 |
if (WARN_ON_ONCE(!ba_data)) |
| 662 |
goto out; |
| 663 |
|
| 664 |
/* pick any STA ID to find the pointer */ |
| 665 |
sta_id = ffs(ba_data->sta_mask) - 1; |
| 666 |
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); |
| 667 |
if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) |
| 668 |
goto out; |
| 669 |
|
| 670 |
reorder_buf = &ba_data->reorder_buf[queue]; |
| 671 |
|
| 672 |
/* release all frames that are in the reorder buffer to the stack */ |
| 673 |
spin_lock_bh(&reorder_buf->lock); |
| 674 |
iwl_mvm_release_frames(mvm, sta, NULL, ba_data, reorder_buf, |
| 675 |
ieee80211_sn_add(reorder_buf->head_sn, |
| 676 |
ba_data->buf_size)); |
| 677 |
spin_unlock_bh(&reorder_buf->lock); |
| 678 |
|
| 679 |
out: |
| 680 |
rcu_read_unlock(); |
| 681 |
} |
| 682 |
|
| 683 |
static void iwl_mvm_release_frames_from_notif(struct iwl_mvm *mvm, |
| 684 |
struct napi_struct *napi, |
| 685 |
u8 baid, u16 nssn, int queue) |
| 686 |
{ |
| 687 |
struct ieee80211_sta *sta; |
| 688 |
struct iwl_mvm_reorder_buffer *reorder_buf; |
| 689 |
struct iwl_mvm_baid_data *ba_data; |
| 690 |
u32 sta_id; |
| 691 |
|
| 692 |
IWL_DEBUG_HT(mvm, "Frame release notification for BAID %u, NSSN %d\n", |
| 693 |
baid, nssn); |
| 694 |
|
| 695 |
if (IWL_FW_CHECK(mvm, |
| 696 |
baid == IWL_RX_REORDER_DATA_INVALID_BAID || |
| 697 |
baid >= ARRAY_SIZE(mvm->baid_map), |
| 698 |
"invalid BAID from FW: %d\n", baid)) |
| 699 |
return; |
| 700 |
|
| 701 |
rcu_read_lock(); |
| 702 |
|
| 703 |
ba_data = rcu_dereference(mvm->baid_map[baid]); |
| 704 |
if (!ba_data) { |
| 705 |
IWL_DEBUG_RX(mvm, |
| 706 |
"Got valid BAID %d but not allocated, invalid frame release!\n", |
| 707 |
baid); |
| 708 |
goto out; |
| 709 |
} |
| 710 |
|
| 711 |
/* pick any STA ID to find the pointer */ |
| 712 |
sta_id = ffs(ba_data->sta_mask) - 1; |
| 713 |
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); |
| 714 |
if (WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) |
| 715 |
goto out; |
| 716 |
|
| 717 |
reorder_buf = &ba_data->reorder_buf[queue]; |
| 718 |
|
| 719 |
spin_lock_bh(&reorder_buf->lock); |
| 720 |
iwl_mvm_release_frames(mvm, sta, napi, ba_data, |
| 721 |
reorder_buf, nssn); |
| 722 |
spin_unlock_bh(&reorder_buf->lock); |
| 723 |
|
| 724 |
out: |
| 725 |
rcu_read_unlock(); |
| 726 |
} |
| 727 |
|
| 728 |
void iwl_mvm_rx_queue_notif(struct iwl_mvm *mvm, struct napi_struct *napi, |
| 729 |
struct iwl_rx_cmd_buffer *rxb, int queue) |
| 730 |
{ |
| 731 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 732 |
struct iwl_rxq_sync_notification *notif; |
| 733 |
struct iwl_mvm_internal_rxq_notif *internal_notif; |
| 734 |
u32 len = iwl_rx_packet_payload_len(pkt); |
| 735 |
|
| 736 |
notif = (void *)pkt->data; |
| 737 |
internal_notif = (void *)notif->payload; |
| 738 |
|
| 739 |
if (WARN_ONCE(len < sizeof(*notif) + sizeof(*internal_notif), |
| 740 |
"invalid notification size %d (%d)", |
| 741 |
len, (int)(sizeof(*notif) + sizeof(*internal_notif)))) |
| 742 |
return; |
| 743 |
len -= sizeof(*notif) + sizeof(*internal_notif); |
| 744 |
|
| 745 |
if (WARN_ONCE(internal_notif->sync && |
| 746 |
mvm->queue_sync_cookie != internal_notif->cookie, |
| 747 |
"Received expired RX queue sync message (cookie %d but wanted %d, queue %d)\n", |
| 748 |
internal_notif->cookie, mvm->queue_sync_cookie, queue)) |
| 749 |
return; |
| 750 |
|
| 751 |
switch (internal_notif->type) { |
| 752 |
case IWL_MVM_RXQ_EMPTY: |
| 753 |
WARN_ONCE(len, "invalid empty notification size %d", len); |
| 754 |
break; |
| 755 |
case IWL_MVM_RXQ_NOTIF_DEL_BA: |
| 756 |
if (WARN_ONCE(len != sizeof(struct iwl_mvm_delba_data), |
| 757 |
"invalid delba notification size %d (%d)", |
| 758 |
len, (int)sizeof(struct iwl_mvm_delba_data))) |
| 759 |
break; |
| 760 |
iwl_mvm_del_ba(mvm, queue, (void *)internal_notif->data); |
| 761 |
break; |
| 762 |
default: |
| 763 |
WARN_ONCE(1, "Invalid identifier %d", internal_notif->type); |
| 764 |
} |
| 765 |
|
| 766 |
if (internal_notif->sync) { |
| 767 |
WARN_ONCE(!test_and_clear_bit(queue, &mvm->queue_sync_state), |
| 768 |
"queue sync: queue %d responded a second time!\n", |
| 769 |
queue); |
| 770 |
if (READ_ONCE(mvm->queue_sync_state) == 0) |
| 771 |
wake_up(&mvm->rx_sync_waitq); |
| 772 |
} |
| 773 |
} |
| 774 |
|
| 775 |
/* |
| 776 |
* Returns true if the MPDU was buffered\dropped, false if it should be passed |
| 777 |
* to upper layer. |
| 778 |
*/ |
| 779 |
static bool iwl_mvm_reorder(struct iwl_mvm *mvm, |
| 780 |
struct napi_struct *napi, |
| 781 |
int queue, |
| 782 |
struct ieee80211_sta *sta, |
| 783 |
struct sk_buff *skb, |
| 784 |
struct iwl_rx_mpdu_desc *desc) |
| 785 |
{ |
| 786 |
struct ieee80211_hdr *hdr = (void *)skb_mac_header(skb); |
| 787 |
struct iwl_mvm_baid_data *baid_data; |
| 788 |
struct iwl_mvm_reorder_buffer *buffer; |
| 789 |
u32 reorder = le32_to_cpu(desc->reorder_data); |
| 790 |
bool amsdu = desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU; |
| 791 |
bool last_subframe = |
| 792 |
desc->amsdu_info & IWL_RX_MPDU_AMSDU_LAST_SUBFRAME; |
| 793 |
u8 tid = ieee80211_get_tid(hdr); |
| 794 |
struct iwl_mvm_reorder_buf_entry *entries; |
| 795 |
u32 sta_mask; |
| 796 |
int index; |
| 797 |
u16 nssn, sn; |
| 798 |
u8 baid; |
| 799 |
|
| 800 |
baid = (reorder & IWL_RX_MPDU_REORDER_BAID_MASK) >> |
| 801 |
IWL_RX_MPDU_REORDER_BAID_SHIFT; |
| 802 |
|
| 803 |
if (mvm->trans->mac_cfg->device_family == IWL_DEVICE_FAMILY_9000) |
| 804 |
return false; |
| 805 |
|
| 806 |
/* |
| 807 |
* This also covers the case of receiving a Block Ack Request |
| 808 |
* outside a BA session; we'll pass it to mac80211 and that |
| 809 |
* then sends a delBA action frame. |
| 810 |
* This also covers pure monitor mode, in which case we won't |
| 811 |
* have any BA sessions. |
| 812 |
*/ |
| 813 |
if (baid == IWL_RX_REORDER_DATA_INVALID_BAID) |
| 814 |
return false; |
| 815 |
|
| 816 |
/* no sta yet */ |
| 817 |
if (WARN_ONCE(IS_ERR_OR_NULL(sta), |
| 818 |
"Got valid BAID without a valid station assigned\n")) |
| 819 |
return false; |
| 820 |
|
| 821 |
/* not a data packet or a bar */ |
| 822 |
if (!ieee80211_is_back_req(hdr->frame_control) && |
| 823 |
(!ieee80211_is_data_qos(hdr->frame_control) || |
| 824 |
is_multicast_ether_addr(hdr->addr1))) |
| 825 |
return false; |
| 826 |
|
| 827 |
if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) |
| 828 |
return false; |
| 829 |
|
| 830 |
baid_data = rcu_dereference(mvm->baid_map[baid]); |
| 831 |
if (!baid_data) { |
| 832 |
IWL_DEBUG_RX(mvm, |
| 833 |
"Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n", |
| 834 |
baid, reorder); |
| 835 |
return false; |
| 836 |
} |
| 837 |
|
| 838 |
sta_mask = iwl_mvm_sta_fw_id_mask(mvm, sta, -1); |
| 839 |
|
| 840 |
if (IWL_FW_CHECK(mvm, |
| 841 |
tid != baid_data->tid || |
| 842 |
!(sta_mask & baid_data->sta_mask), |
| 843 |
"baid 0x%x is mapped to sta_mask:0x%x tid:%d, but was received for sta_mask:0x%x tid:%d\n", |
| 844 |
baid, baid_data->sta_mask, baid_data->tid, |
| 845 |
sta_mask, tid)) |
| 846 |
return false; |
| 847 |
|
| 848 |
nssn = reorder & IWL_RX_MPDU_REORDER_NSSN_MASK; |
| 849 |
sn = (reorder & IWL_RX_MPDU_REORDER_SN_MASK) >> |
| 850 |
IWL_RX_MPDU_REORDER_SN_SHIFT; |
| 851 |
|
| 852 |
buffer = &baid_data->reorder_buf[queue]; |
| 853 |
entries = &baid_data->entries[queue * baid_data->entries_per_queue]; |
| 854 |
|
| 855 |
spin_lock_bh(&buffer->lock); |
| 856 |
|
| 857 |
if (!buffer->valid) { |
| 858 |
if (reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN) { |
| 859 |
spin_unlock_bh(&buffer->lock); |
| 860 |
return false; |
| 861 |
} |
| 862 |
buffer->valid = true; |
| 863 |
} |
| 864 |
|
| 865 |
/* drop any duplicated packets */ |
| 866 |
if (desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_DUPLICATE)) |
| 867 |
goto drop; |
| 868 |
|
| 869 |
/* drop any oudated packets */ |
| 870 |
if (reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN) |
| 871 |
goto drop; |
| 872 |
|
| 873 |
/* release immediately if allowed by nssn and no stored frames */ |
| 874 |
if (!buffer->num_stored && ieee80211_sn_less(sn, nssn)) { |
| 875 |
if (!amsdu || last_subframe) |
| 876 |
buffer->head_sn = nssn; |
| 877 |
|
| 878 |
spin_unlock_bh(&buffer->lock); |
| 879 |
return false; |
| 880 |
} |
| 881 |
|
| 882 |
/* |
| 883 |
* release immediately if there are no stored frames, and the sn is |
| 884 |
* equal to the head. |
| 885 |
* This can happen due to reorder timer, where NSSN is behind head_sn. |
| 886 |
* When we released everything, and we got the next frame in the |
| 887 |
* sequence, according to the NSSN we can't release immediately, |
| 888 |
* while technically there is no hole and we can move forward. |
| 889 |
*/ |
| 890 |
if (!buffer->num_stored && sn == buffer->head_sn) { |
| 891 |
if (!amsdu || last_subframe) |
| 892 |
buffer->head_sn = ieee80211_sn_inc(buffer->head_sn); |
| 893 |
|
| 894 |
spin_unlock_bh(&buffer->lock); |
| 895 |
return false; |
| 896 |
} |
| 897 |
|
| 898 |
/* put in reorder buffer */ |
| 899 |
index = sn % baid_data->buf_size; |
| 900 |
__skb_queue_tail(&entries[index].frames, skb); |
| 901 |
buffer->num_stored++; |
| 902 |
|
| 903 |
/* |
| 904 |
* We cannot trust NSSN for AMSDU sub-frames that are not the last. |
| 905 |
* The reason is that NSSN advances on the first sub-frame, and may |
| 906 |
* cause the reorder buffer to advance before all the sub-frames arrive. |
| 907 |
* Example: reorder buffer contains SN 0 & 2, and we receive AMSDU with |
| 908 |
* SN 1. NSSN for first sub frame will be 3 with the result of driver |
| 909 |
* releasing SN 0,1, 2. When sub-frame 1 arrives - reorder buffer is |
| 910 |
* already ahead and it will be dropped. |
| 911 |
* If the last sub-frame is not on this queue - we will get frame |
| 912 |
* release notification with up to date NSSN. |
| 913 |
* If this is the first frame that is stored in the buffer, the head_sn |
| 914 |
* may be outdated. Update it based on the last NSSN to make sure it |
| 915 |
* will be released when the frame release notification arrives. |
| 916 |
*/ |
| 917 |
if (!amsdu || last_subframe) |
| 918 |
iwl_mvm_release_frames(mvm, sta, napi, baid_data, |
| 919 |
buffer, nssn); |
| 920 |
else if (buffer->num_stored == 1) |
| 921 |
buffer->head_sn = nssn; |
| 922 |
|
| 923 |
spin_unlock_bh(&buffer->lock); |
| 924 |
return true; |
| 925 |
|
| 926 |
drop: |
| 927 |
kfree_skb(skb); |
| 928 |
spin_unlock_bh(&buffer->lock); |
| 929 |
return true; |
| 930 |
} |
| 931 |
|
| 932 |
static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm, |
| 933 |
u32 reorder_data, u8 baid) |
| 934 |
{ |
| 935 |
unsigned long now = jiffies; |
| 936 |
unsigned long timeout; |
| 937 |
struct iwl_mvm_baid_data *data; |
| 938 |
|
| 939 |
rcu_read_lock(); |
| 940 |
|
| 941 |
data = rcu_dereference(mvm->baid_map[baid]); |
| 942 |
if (!data) { |
| 943 |
IWL_DEBUG_RX(mvm, |
| 944 |
"Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n", |
| 945 |
baid, reorder_data); |
| 946 |
goto out; |
| 947 |
} |
| 948 |
|
| 949 |
if (!data->timeout) |
| 950 |
goto out; |
| 951 |
|
| 952 |
timeout = data->timeout; |
| 953 |
/* |
| 954 |
* Do not update last rx all the time to avoid cache bouncing |
| 955 |
* between the rx queues. |
| 956 |
* Update it every timeout. Worst case is the session will |
| 957 |
* expire after ~ 2 * timeout, which doesn't matter that much. |
| 958 |
*/ |
| 959 |
if (time_before(data->last_rx + TU_TO_JIFFIES(timeout), now)) |
| 960 |
/* Update is atomic */ |
| 961 |
data->last_rx = now; |
| 962 |
|
| 963 |
out: |
| 964 |
rcu_read_unlock(); |
| 965 |
} |
| 966 |
|
| 967 |
static void iwl_mvm_flip_address(u8 *addr) |
| 968 |
{ |
| 969 |
int i; |
| 970 |
u8 mac_addr[ETH_ALEN]; |
| 971 |
|
| 972 |
for (i = 0; i < ETH_ALEN; i++) |
| 973 |
mac_addr[i] = addr[ETH_ALEN - i - 1]; |
| 974 |
ether_addr_copy(addr, mac_addr); |
| 975 |
} |
| 976 |
|
| 977 |
struct iwl_mvm_rx_phy_data { |
| 978 |
enum iwl_rx_phy_info_type info_type; |
| 979 |
__le32 d0, d1, d2, d3, eht_d4, d5; |
| 980 |
__le16 d4; |
| 981 |
bool with_data; |
| 982 |
bool first_subframe; |
| 983 |
__le32 rx_vec[4]; |
| 984 |
|
| 985 |
u32 rate_n_flags; |
| 986 |
u32 gp2_on_air_rise; |
| 987 |
u16 phy_info; |
| 988 |
u8 energy_a, energy_b; |
| 989 |
u8 channel; |
| 990 |
}; |
| 991 |
|
| 992 |
static void iwl_mvm_decode_he_mu_ext(struct iwl_mvm *mvm, |
| 993 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 994 |
struct ieee80211_radiotap_he_mu *he_mu) |
| 995 |
{ |
| 996 |
u32 phy_data2 = le32_to_cpu(phy_data->d2); |
| 997 |
u32 phy_data3 = le32_to_cpu(phy_data->d3); |
| 998 |
u16 phy_data4 = le16_to_cpu(phy_data->d4); |
| 999 |
u32 rate_n_flags = phy_data->rate_n_flags; |
| 1000 |
|
| 1001 |
if (FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH1_CRC_OK, phy_data4)) { |
| 1002 |
he_mu->flags1 |= |
| 1003 |
cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_RU_KNOWN | |
| 1004 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU_KNOWN); |
| 1005 |
|
| 1006 |
he_mu->flags1 |= |
| 1007 |
le16_encode_bits(FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH1_CTR_RU, |
| 1008 |
phy_data4), |
| 1009 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU); |
| 1010 |
|
| 1011 |
he_mu->ru_ch1[0] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH1_RU0, |
| 1012 |
phy_data2); |
| 1013 |
he_mu->ru_ch1[1] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH1_RU1, |
| 1014 |
phy_data3); |
| 1015 |
he_mu->ru_ch1[2] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH1_RU2, |
| 1016 |
phy_data2); |
| 1017 |
he_mu->ru_ch1[3] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH1_RU3, |
| 1018 |
phy_data3); |
| 1019 |
} |
| 1020 |
|
| 1021 |
if (FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH2_CRC_OK, phy_data4) && |
| 1022 |
(rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK_V1) != RATE_MCS_CHAN_WIDTH_20) { |
| 1023 |
he_mu->flags1 |= |
| 1024 |
cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_RU_KNOWN | |
| 1025 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_CTR_26T_RU_KNOWN); |
| 1026 |
|
| 1027 |
he_mu->flags2 |= |
| 1028 |
le16_encode_bits(FIELD_GET(IWL_RX_PHY_DATA4_HE_MU_EXT_CH2_CTR_RU, |
| 1029 |
phy_data4), |
| 1030 |
IEEE80211_RADIOTAP_HE_MU_FLAGS2_CH2_CTR_26T_RU); |
| 1031 |
|
| 1032 |
he_mu->ru_ch2[0] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH2_RU0, |
| 1033 |
phy_data2); |
| 1034 |
he_mu->ru_ch2[1] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH2_RU1, |
| 1035 |
phy_data3); |
| 1036 |
he_mu->ru_ch2[2] = FIELD_GET(IWL_RX_PHY_DATA2_HE_MU_EXT_CH2_RU2, |
| 1037 |
phy_data2); |
| 1038 |
he_mu->ru_ch2[3] = FIELD_GET(IWL_RX_PHY_DATA3_HE_MU_EXT_CH2_RU3, |
| 1039 |
phy_data3); |
| 1040 |
} |
| 1041 |
} |
| 1042 |
|
| 1043 |
static void |
| 1044 |
iwl_mvm_decode_he_phy_ru_alloc(struct iwl_mvm_rx_phy_data *phy_data, |
| 1045 |
struct ieee80211_radiotap_he *he, |
| 1046 |
struct ieee80211_radiotap_he_mu *he_mu, |
| 1047 |
struct ieee80211_rx_status *rx_status) |
| 1048 |
{ |
| 1049 |
/* |
| 1050 |
* Unfortunately, we have to leave the mac80211 data |
| 1051 |
* incorrect for the case that we receive an HE-MU |
| 1052 |
* transmission and *don't* have the HE phy data (due |
| 1053 |
* to the bits being used for TSF). This shouldn't |
| 1054 |
* happen though as management frames where we need |
| 1055 |
* the TSF/timers are not be transmitted in HE-MU. |
| 1056 |
*/ |
| 1057 |
u8 ru = le32_get_bits(phy_data->d1, IWL_RX_PHY_DATA1_HE_RU_ALLOC_MASK); |
| 1058 |
u32 rate_n_flags = phy_data->rate_n_flags; |
| 1059 |
u32 he_type = rate_n_flags & RATE_MCS_HE_TYPE_MSK; |
| 1060 |
u8 offs = 0; |
| 1061 |
|
| 1062 |
rx_status->bw = RATE_INFO_BW_HE_RU; |
| 1063 |
|
| 1064 |
he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN); |
| 1065 |
|
| 1066 |
switch (ru) { |
| 1067 |
case 0 ... 36: |
| 1068 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_26; |
| 1069 |
offs = ru; |
| 1070 |
break; |
| 1071 |
case 37 ... 52: |
| 1072 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_52; |
| 1073 |
offs = ru - 37; |
| 1074 |
break; |
| 1075 |
case 53 ... 60: |
| 1076 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_106; |
| 1077 |
offs = ru - 53; |
| 1078 |
break; |
| 1079 |
case 61 ... 64: |
| 1080 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_242; |
| 1081 |
offs = ru - 61; |
| 1082 |
break; |
| 1083 |
case 65 ... 66: |
| 1084 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_484; |
| 1085 |
offs = ru - 65; |
| 1086 |
break; |
| 1087 |
case 67: |
| 1088 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_996; |
| 1089 |
break; |
| 1090 |
case 68: |
| 1091 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_2x996; |
| 1092 |
break; |
| 1093 |
} |
| 1094 |
he->data2 |= le16_encode_bits(offs, |
| 1095 |
IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET); |
| 1096 |
he->data2 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN | |
| 1097 |
IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN); |
| 1098 |
if (phy_data->d1 & cpu_to_le32(IWL_RX_PHY_DATA1_HE_RU_ALLOC_SEC80)) |
| 1099 |
he->data2 |= |
| 1100 |
cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC); |
| 1101 |
|
| 1102 |
#define CHECK_BW(bw) \ |
| 1103 |
BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_ ## bw ## MHZ != \ |
| 1104 |
RATE_MCS_CHAN_WIDTH_##bw >> RATE_MCS_CHAN_WIDTH_POS); \ |
| 1105 |
BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_ ## bw ## MHZ != \ |
| 1106 |
RATE_MCS_CHAN_WIDTH_##bw >> RATE_MCS_CHAN_WIDTH_POS) |
| 1107 |
CHECK_BW(20); |
| 1108 |
CHECK_BW(40); |
| 1109 |
CHECK_BW(80); |
| 1110 |
CHECK_BW(160); |
| 1111 |
|
| 1112 |
if (he_mu) |
| 1113 |
he_mu->flags2 |= |
| 1114 |
le16_encode_bits(FIELD_GET(RATE_MCS_CHAN_WIDTH_MSK, |
| 1115 |
rate_n_flags), |
| 1116 |
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW); |
| 1117 |
else if (he_type == RATE_MCS_HE_TYPE_TRIG) |
| 1118 |
he->data6 |= |
| 1119 |
cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_KNOWN) | |
| 1120 |
le16_encode_bits(FIELD_GET(RATE_MCS_CHAN_WIDTH_MSK, |
| 1121 |
rate_n_flags), |
| 1122 |
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW); |
| 1123 |
} |
| 1124 |
|
| 1125 |
static void iwl_mvm_decode_he_phy_data(struct iwl_mvm *mvm, |
| 1126 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1127 |
struct ieee80211_radiotap_he *he, |
| 1128 |
struct ieee80211_radiotap_he_mu *he_mu, |
| 1129 |
struct ieee80211_rx_status *rx_status, |
| 1130 |
int queue) |
| 1131 |
{ |
| 1132 |
switch (phy_data->info_type) { |
| 1133 |
case IWL_RX_PHY_INFO_TYPE_NONE: |
| 1134 |
case IWL_RX_PHY_INFO_TYPE_CCK: |
| 1135 |
case IWL_RX_PHY_INFO_TYPE_OFDM_LGCY: |
| 1136 |
case IWL_RX_PHY_INFO_TYPE_HT: |
| 1137 |
case IWL_RX_PHY_INFO_TYPE_VHT_SU: |
| 1138 |
case IWL_RX_PHY_INFO_TYPE_VHT_MU: |
| 1139 |
case IWL_RX_PHY_INFO_TYPE_EHT_MU: |
| 1140 |
case IWL_RX_PHY_INFO_TYPE_EHT_TB: |
| 1141 |
case IWL_RX_PHY_INFO_TYPE_EHT_MU_EXT: |
| 1142 |
case IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT: |
| 1143 |
return; |
| 1144 |
case IWL_RX_PHY_INFO_TYPE_HE_TB_EXT: |
| 1145 |
he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN | |
| 1146 |
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE2_KNOWN | |
| 1147 |
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE3_KNOWN | |
| 1148 |
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE4_KNOWN); |
| 1149 |
he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2, |
| 1150 |
IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE1), |
| 1151 |
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE1); |
| 1152 |
he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2, |
| 1153 |
IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE2), |
| 1154 |
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE2); |
| 1155 |
he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2, |
| 1156 |
IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE3), |
| 1157 |
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE3); |
| 1158 |
he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d2, |
| 1159 |
IWL_RX_PHY_DATA2_HE_TB_EXT_SPTL_REUSE4), |
| 1160 |
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE4); |
| 1161 |
fallthrough; |
| 1162 |
case IWL_RX_PHY_INFO_TYPE_HE_SU: |
| 1163 |
case IWL_RX_PHY_INFO_TYPE_HE_MU: |
| 1164 |
case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT: |
| 1165 |
case IWL_RX_PHY_INFO_TYPE_HE_TB: |
| 1166 |
/* HE common */ |
| 1167 |
he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN | |
| 1168 |
IEEE80211_RADIOTAP_HE_DATA1_DOPPLER_KNOWN | |
| 1169 |
IEEE80211_RADIOTAP_HE_DATA1_BSS_COLOR_KNOWN); |
| 1170 |
he->data2 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN | |
| 1171 |
IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN | |
| 1172 |
IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN | |
| 1173 |
IEEE80211_RADIOTAP_HE_DATA2_NUM_LTF_SYMS_KNOWN); |
| 1174 |
he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1175 |
IWL_RX_PHY_DATA0_HE_BSS_COLOR_MASK), |
| 1176 |
IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR); |
| 1177 |
if (phy_data->info_type != IWL_RX_PHY_INFO_TYPE_HE_TB && |
| 1178 |
phy_data->info_type != IWL_RX_PHY_INFO_TYPE_HE_TB_EXT) { |
| 1179 |
he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN); |
| 1180 |
he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1181 |
IWL_RX_PHY_DATA0_HE_UPLINK), |
| 1182 |
IEEE80211_RADIOTAP_HE_DATA3_UL_DL); |
| 1183 |
} |
| 1184 |
he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1185 |
IWL_RX_PHY_DATA0_HE_LDPC_EXT_SYM), |
| 1186 |
IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG); |
| 1187 |
he->data5 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1188 |
IWL_RX_PHY_DATA0_HE_PRE_FEC_PAD_MASK), |
| 1189 |
IEEE80211_RADIOTAP_HE_DATA5_PRE_FEC_PAD); |
| 1190 |
he->data5 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1191 |
IWL_RX_PHY_DATA0_HE_PE_DISAMBIG), |
| 1192 |
IEEE80211_RADIOTAP_HE_DATA5_PE_DISAMBIG); |
| 1193 |
he->data5 |= le16_encode_bits(le32_get_bits(phy_data->d1, |
| 1194 |
IWL_RX_PHY_DATA1_HE_LTF_NUM_MASK), |
| 1195 |
IEEE80211_RADIOTAP_HE_DATA5_NUM_LTF_SYMS); |
| 1196 |
he->data6 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1197 |
IWL_RX_PHY_DATA0_HE_TXOP_DUR_MASK), |
| 1198 |
IEEE80211_RADIOTAP_HE_DATA6_TXOP); |
| 1199 |
he->data6 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1200 |
IWL_RX_PHY_DATA0_HE_DOPPLER), |
| 1201 |
IEEE80211_RADIOTAP_HE_DATA6_DOPPLER); |
| 1202 |
break; |
| 1203 |
} |
| 1204 |
|
| 1205 |
switch (phy_data->info_type) { |
| 1206 |
case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT: |
| 1207 |
case IWL_RX_PHY_INFO_TYPE_HE_MU: |
| 1208 |
case IWL_RX_PHY_INFO_TYPE_HE_SU: |
| 1209 |
he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN); |
| 1210 |
he->data4 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1211 |
IWL_RX_PHY_DATA0_HE_SPATIAL_REUSE_MASK), |
| 1212 |
IEEE80211_RADIOTAP_HE_DATA4_SU_MU_SPTL_REUSE); |
| 1213 |
break; |
| 1214 |
default: |
| 1215 |
/* nothing here */ |
| 1216 |
break; |
| 1217 |
} |
| 1218 |
|
| 1219 |
switch (phy_data->info_type) { |
| 1220 |
case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT: |
| 1221 |
he_mu->flags1 |= |
| 1222 |
le16_encode_bits(le16_get_bits(phy_data->d4, |
| 1223 |
IWL_RX_PHY_DATA4_HE_MU_EXT_SIGB_DCM), |
| 1224 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM); |
| 1225 |
he_mu->flags1 |= |
| 1226 |
le16_encode_bits(le16_get_bits(phy_data->d4, |
| 1227 |
IWL_RX_PHY_DATA4_HE_MU_EXT_SIGB_MCS_MASK), |
| 1228 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS); |
| 1229 |
he_mu->flags2 |= |
| 1230 |
le16_encode_bits(le16_get_bits(phy_data->d4, |
| 1231 |
IWL_RX_PHY_DATA4_HE_MU_EXT_PREAMBLE_PUNC_TYPE_MASK), |
| 1232 |
IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW); |
| 1233 |
iwl_mvm_decode_he_mu_ext(mvm, phy_data, he_mu); |
| 1234 |
fallthrough; |
| 1235 |
case IWL_RX_PHY_INFO_TYPE_HE_MU: |
| 1236 |
he_mu->flags2 |= |
| 1237 |
le16_encode_bits(le32_get_bits(phy_data->d1, |
| 1238 |
IWL_RX_PHY_DATA1_HE_MU_SIBG_SYM_OR_USER_NUM_MASK), |
| 1239 |
IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_SYMS_USERS); |
| 1240 |
he_mu->flags2 |= |
| 1241 |
le16_encode_bits(le32_get_bits(phy_data->d1, |
| 1242 |
IWL_RX_PHY_DATA1_HE_MU_SIGB_COMPRESSION), |
| 1243 |
IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_COMP); |
| 1244 |
fallthrough; |
| 1245 |
case IWL_RX_PHY_INFO_TYPE_HE_TB: |
| 1246 |
case IWL_RX_PHY_INFO_TYPE_HE_TB_EXT: |
| 1247 |
iwl_mvm_decode_he_phy_ru_alloc(phy_data, he, he_mu, rx_status); |
| 1248 |
break; |
| 1249 |
case IWL_RX_PHY_INFO_TYPE_HE_SU: |
| 1250 |
he->data1 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN); |
| 1251 |
he->data3 |= le16_encode_bits(le32_get_bits(phy_data->d0, |
| 1252 |
IWL_RX_PHY_DATA0_HE_BEAM_CHNG), |
| 1253 |
IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE); |
| 1254 |
break; |
| 1255 |
default: |
| 1256 |
/* nothing */ |
| 1257 |
break; |
| 1258 |
} |
| 1259 |
} |
| 1260 |
|
| 1261 |
#define LE32_DEC_ENC(value, dec_bits, enc_bits) \ |
| 1262 |
le32_encode_bits(le32_get_bits(value, dec_bits), enc_bits) |
| 1263 |
|
| 1264 |
#define IWL_MVM_ENC_USIG_VALUE_MASK(usig, in_value, dec_bits, enc_bits) do { \ |
| 1265 |
typeof(enc_bits) _enc_bits = enc_bits; \ |
| 1266 |
typeof(usig) _usig = usig; \ |
| 1267 |
(_usig)->mask |= cpu_to_le32(_enc_bits); \ |
| 1268 |
(_usig)->value |= LE32_DEC_ENC(in_value, dec_bits, _enc_bits); \ |
| 1269 |
} while (0) |
| 1270 |
|
| 1271 |
#define __IWL_MVM_ENC_EHT_RU(rt_data, rt_ru, fw_data, fw_ru) \ |
| 1272 |
eht->data[(rt_data)] |= \ |
| 1273 |
(cpu_to_le32 \ |
| 1274 |
(IEEE80211_RADIOTAP_EHT_DATA ## rt_data ## _RU_ALLOC_CC_ ## rt_ru ## _KNOWN) | \ |
| 1275 |
LE32_DEC_ENC(data ## fw_data, \ |
| 1276 |
IWL_RX_PHY_DATA ## fw_data ## _EHT_MU_EXT_RU_ALLOC_ ## fw_ru, \ |
| 1277 |
IEEE80211_RADIOTAP_EHT_DATA ## rt_data ## _RU_ALLOC_CC_ ## rt_ru)) |
| 1278 |
|
| 1279 |
#define _IWL_MVM_ENC_EHT_RU(rt_data, rt_ru, fw_data, fw_ru) \ |
| 1280 |
__IWL_MVM_ENC_EHT_RU(rt_data, rt_ru, fw_data, fw_ru) |
| 1281 |
|
| 1282 |
#define IEEE80211_RADIOTAP_RU_DATA_1_1_1 1 |
| 1283 |
#define IEEE80211_RADIOTAP_RU_DATA_2_1_1 2 |
| 1284 |
#define IEEE80211_RADIOTAP_RU_DATA_1_1_2 2 |
| 1285 |
#define IEEE80211_RADIOTAP_RU_DATA_2_1_2 2 |
| 1286 |
#define IEEE80211_RADIOTAP_RU_DATA_1_2_1 3 |
| 1287 |
#define IEEE80211_RADIOTAP_RU_DATA_2_2_1 3 |
| 1288 |
#define IEEE80211_RADIOTAP_RU_DATA_1_2_2 3 |
| 1289 |
#define IEEE80211_RADIOTAP_RU_DATA_2_2_2 4 |
| 1290 |
|
| 1291 |
#define IWL_RX_RU_DATA_A1 2 |
| 1292 |
#define IWL_RX_RU_DATA_A2 2 |
| 1293 |
#define IWL_RX_RU_DATA_B1 2 |
| 1294 |
#define IWL_RX_RU_DATA_B2 4 |
| 1295 |
#define IWL_RX_RU_DATA_C1 3 |
| 1296 |
#define IWL_RX_RU_DATA_C2 3 |
| 1297 |
#define IWL_RX_RU_DATA_D1 4 |
| 1298 |
#define IWL_RX_RU_DATA_D2 4 |
| 1299 |
|
| 1300 |
#define IWL_MVM_ENC_EHT_RU(rt_ru, fw_ru) \ |
| 1301 |
_IWL_MVM_ENC_EHT_RU(IEEE80211_RADIOTAP_RU_DATA_ ## rt_ru, \ |
| 1302 |
rt_ru, \ |
| 1303 |
IWL_RX_RU_DATA_ ## fw_ru, \ |
| 1304 |
fw_ru) |
| 1305 |
|
| 1306 |
static void iwl_mvm_decode_eht_ext_mu(struct iwl_mvm *mvm, |
| 1307 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1308 |
struct ieee80211_rx_status *rx_status, |
| 1309 |
struct ieee80211_radiotap_eht *eht, |
| 1310 |
struct ieee80211_radiotap_eht_usig *usig) |
| 1311 |
{ |
| 1312 |
if (phy_data->with_data) { |
| 1313 |
__le32 data1 = phy_data->d1; |
| 1314 |
__le32 data2 = phy_data->d2; |
| 1315 |
__le32 data3 = phy_data->d3; |
| 1316 |
__le32 data4 = phy_data->eht_d4; |
| 1317 |
__le32 data5 = phy_data->d5; |
| 1318 |
u32 phy_bw = phy_data->rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK; |
| 1319 |
|
| 1320 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, data5, |
| 1321 |
IWL_RX_PHY_DATA5_EHT_TYPE_AND_COMP, |
| 1322 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE); |
| 1323 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, data5, |
| 1324 |
IWL_RX_PHY_DATA5_EHT_MU_PUNC_CH_CODE, |
| 1325 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO); |
| 1326 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, data4, |
| 1327 |
IWL_RX_PHY_DATA4_EHT_MU_EXT_SIGB_MCS, |
| 1328 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS); |
| 1329 |
IWL_MVM_ENC_USIG_VALUE_MASK |
| 1330 |
(usig, data1, IWL_RX_PHY_DATA1_EHT_MU_NUM_SIG_SYM_USIGA2, |
| 1331 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS); |
| 1332 |
|
| 1333 |
eht->user_info[0] |= |
| 1334 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID_KNOWN) | |
| 1335 |
LE32_DEC_ENC(data5, IWL_RX_PHY_DATA5_EHT_MU_STA_ID_USR, |
| 1336 |
IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID); |
| 1337 |
|
| 1338 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_NR_NON_OFDMA_USERS_M); |
| 1339 |
eht->data[7] |= LE32_DEC_ENC |
| 1340 |
(data5, IWL_RX_PHY_DATA5_EHT_MU_NUM_USR_NON_OFDMA, |
| 1341 |
IEEE80211_RADIOTAP_EHT_DATA7_NUM_OF_NON_OFDMA_USERS); |
| 1342 |
|
| 1343 |
/* |
| 1344 |
* Hardware labels the content channels/RU allocation values |
| 1345 |
* as follows: |
| 1346 |
* Content Channel 1 Content Channel 2 |
| 1347 |
* 20 MHz: A1 |
| 1348 |
* 40 MHz: A1 B1 |
| 1349 |
* 80 MHz: A1 C1 B1 D1 |
| 1350 |
* 160 MHz: A1 C1 A2 C2 B1 D1 B2 D2 |
| 1351 |
* 320 MHz: A1 C1 A2 C2 A3 C3 A4 C4 B1 D1 B2 D2 B3 D3 B4 D4 |
| 1352 |
* |
| 1353 |
* However firmware can only give us A1-D2, so the higher |
| 1354 |
* frequencies are missing. |
| 1355 |
*/ |
| 1356 |
|
| 1357 |
switch (phy_bw) { |
| 1358 |
case RATE_MCS_CHAN_WIDTH_320: |
| 1359 |
/* additional values are missing in RX metadata */ |
| 1360 |
case RATE_MCS_CHAN_WIDTH_160: |
| 1361 |
/* content channel 1 */ |
| 1362 |
IWL_MVM_ENC_EHT_RU(1_2_1, A2); |
| 1363 |
IWL_MVM_ENC_EHT_RU(1_2_2, C2); |
| 1364 |
/* content channel 2 */ |
| 1365 |
IWL_MVM_ENC_EHT_RU(2_2_1, B2); |
| 1366 |
IWL_MVM_ENC_EHT_RU(2_2_2, D2); |
| 1367 |
fallthrough; |
| 1368 |
case RATE_MCS_CHAN_WIDTH_80: |
| 1369 |
/* content channel 1 */ |
| 1370 |
IWL_MVM_ENC_EHT_RU(1_1_2, C1); |
| 1371 |
/* content channel 2 */ |
| 1372 |
IWL_MVM_ENC_EHT_RU(2_1_2, D1); |
| 1373 |
fallthrough; |
| 1374 |
case RATE_MCS_CHAN_WIDTH_40: |
| 1375 |
/* content channel 2 */ |
| 1376 |
IWL_MVM_ENC_EHT_RU(2_1_1, B1); |
| 1377 |
fallthrough; |
| 1378 |
case RATE_MCS_CHAN_WIDTH_20: |
| 1379 |
IWL_MVM_ENC_EHT_RU(1_1_1, A1); |
| 1380 |
break; |
| 1381 |
} |
| 1382 |
} else { |
| 1383 |
__le32 usig_a1 = phy_data->rx_vec[0]; |
| 1384 |
__le32 usig_a2 = phy_data->rx_vec[1]; |
| 1385 |
|
| 1386 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a1, |
| 1387 |
IWL_RX_USIG_A1_DISREGARD, |
| 1388 |
IEEE80211_RADIOTAP_EHT_USIG1_MU_B20_B24_DISREGARD); |
| 1389 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a1, |
| 1390 |
IWL_RX_USIG_A1_VALIDATE, |
| 1391 |
IEEE80211_RADIOTAP_EHT_USIG1_MU_B25_VALIDATE); |
| 1392 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1393 |
IWL_RX_USIG_A2_EHT_PPDU_TYPE, |
| 1394 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE); |
| 1395 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1396 |
IWL_RX_USIG_A2_EHT_USIG2_VALIDATE_B2, |
| 1397 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B2_VALIDATE); |
| 1398 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1399 |
IWL_RX_USIG_A2_EHT_PUNC_CHANNEL, |
| 1400 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO); |
| 1401 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1402 |
IWL_RX_USIG_A2_EHT_USIG2_VALIDATE_B8, |
| 1403 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B8_VALIDATE); |
| 1404 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1405 |
IWL_RX_USIG_A2_EHT_SIG_MCS, |
| 1406 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS); |
| 1407 |
IWL_MVM_ENC_USIG_VALUE_MASK |
| 1408 |
(usig, usig_a2, IWL_RX_USIG_A2_EHT_SIG_SYM_NUM, |
| 1409 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS); |
| 1410 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1411 |
IWL_RX_USIG_A2_EHT_CRC_OK, |
| 1412 |
IEEE80211_RADIOTAP_EHT_USIG2_MU_B16_B19_CRC); |
| 1413 |
} |
| 1414 |
} |
| 1415 |
|
| 1416 |
static void iwl_mvm_decode_eht_ext_tb(struct iwl_mvm *mvm, |
| 1417 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1418 |
struct ieee80211_rx_status *rx_status, |
| 1419 |
struct ieee80211_radiotap_eht *eht, |
| 1420 |
struct ieee80211_radiotap_eht_usig *usig) |
| 1421 |
{ |
| 1422 |
if (phy_data->with_data) { |
| 1423 |
__le32 data5 = phy_data->d5; |
| 1424 |
|
| 1425 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, data5, |
| 1426 |
IWL_RX_PHY_DATA5_EHT_TYPE_AND_COMP, |
| 1427 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE); |
| 1428 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, data5, |
| 1429 |
IWL_RX_PHY_DATA5_EHT_TB_SPATIAL_REUSE1, |
| 1430 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1); |
| 1431 |
|
| 1432 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, data5, |
| 1433 |
IWL_RX_PHY_DATA5_EHT_TB_SPATIAL_REUSE2, |
| 1434 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2); |
| 1435 |
} else { |
| 1436 |
__le32 usig_a1 = phy_data->rx_vec[0]; |
| 1437 |
__le32 usig_a2 = phy_data->rx_vec[1]; |
| 1438 |
|
| 1439 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a1, |
| 1440 |
IWL_RX_USIG_A1_DISREGARD, |
| 1441 |
IEEE80211_RADIOTAP_EHT_USIG1_TB_B20_B25_DISREGARD); |
| 1442 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1443 |
IWL_RX_USIG_A2_EHT_PPDU_TYPE, |
| 1444 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE); |
| 1445 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1446 |
IWL_RX_USIG_A2_EHT_USIG2_VALIDATE_B2, |
| 1447 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B2_VALIDATE); |
| 1448 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1449 |
IWL_RX_USIG_A2_EHT_TRIG_SPATIAL_REUSE_1, |
| 1450 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1); |
| 1451 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1452 |
IWL_RX_USIG_A2_EHT_TRIG_SPATIAL_REUSE_2, |
| 1453 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2); |
| 1454 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1455 |
IWL_RX_USIG_A2_EHT_TRIG_USIG2_DISREGARD, |
| 1456 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B11_B15_DISREGARD); |
| 1457 |
IWL_MVM_ENC_USIG_VALUE_MASK(usig, usig_a2, |
| 1458 |
IWL_RX_USIG_A2_EHT_CRC_OK, |
| 1459 |
IEEE80211_RADIOTAP_EHT_USIG2_TB_B16_B19_CRC); |
| 1460 |
} |
| 1461 |
} |
| 1462 |
|
| 1463 |
static void iwl_mvm_decode_eht_ru(struct iwl_mvm *mvm, |
| 1464 |
struct ieee80211_rx_status *rx_status, |
| 1465 |
struct ieee80211_radiotap_eht *eht) |
| 1466 |
{ |
| 1467 |
u32 ru = le32_get_bits(eht->data[8], |
| 1468 |
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1); |
| 1469 |
enum nl80211_eht_ru_alloc nl_ru; |
| 1470 |
|
| 1471 |
/* Using D1.5 Table 9-53a - Encoding of PS160 and RU Allocation subfields |
| 1472 |
* in an EHT variant User Info field |
| 1473 |
*/ |
| 1474 |
|
| 1475 |
switch (ru) { |
| 1476 |
case 0 ... 36: |
| 1477 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_26; |
| 1478 |
break; |
| 1479 |
case 37 ... 52: |
| 1480 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_52; |
| 1481 |
break; |
| 1482 |
case 53 ... 60: |
| 1483 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_106; |
| 1484 |
break; |
| 1485 |
case 61 ... 64: |
| 1486 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_242; |
| 1487 |
break; |
| 1488 |
case 65 ... 66: |
| 1489 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_484; |
| 1490 |
break; |
| 1491 |
case 67: |
| 1492 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_996; |
| 1493 |
break; |
| 1494 |
case 68: |
| 1495 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_2x996; |
| 1496 |
break; |
| 1497 |
case 69: |
| 1498 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_4x996; |
| 1499 |
break; |
| 1500 |
case 70 ... 81: |
| 1501 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_52P26; |
| 1502 |
break; |
| 1503 |
case 82 ... 89: |
| 1504 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_106P26; |
| 1505 |
break; |
| 1506 |
case 90 ... 93: |
| 1507 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_484P242; |
| 1508 |
break; |
| 1509 |
case 94 ... 95: |
| 1510 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_996P484; |
| 1511 |
break; |
| 1512 |
case 96 ... 99: |
| 1513 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242; |
| 1514 |
break; |
| 1515 |
case 100 ... 103: |
| 1516 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484; |
| 1517 |
break; |
| 1518 |
case 104: |
| 1519 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_3x996; |
| 1520 |
break; |
| 1521 |
case 105 ... 106: |
| 1522 |
nl_ru = NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484; |
| 1523 |
break; |
| 1524 |
default: |
| 1525 |
return; |
| 1526 |
} |
| 1527 |
|
| 1528 |
rx_status->bw = RATE_INFO_BW_EHT_RU; |
| 1529 |
rx_status->eht.ru = nl_ru; |
| 1530 |
} |
| 1531 |
|
| 1532 |
static void iwl_mvm_decode_eht_phy_data(struct iwl_mvm *mvm, |
| 1533 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1534 |
struct ieee80211_rx_status *rx_status, |
| 1535 |
struct ieee80211_radiotap_eht *eht, |
| 1536 |
struct ieee80211_radiotap_eht_usig *usig) |
| 1537 |
|
| 1538 |
{ |
| 1539 |
__le32 data0 = phy_data->d0; |
| 1540 |
__le32 data1 = phy_data->d1; |
| 1541 |
__le32 usig_a1 = phy_data->rx_vec[0]; |
| 1542 |
u8 info_type = phy_data->info_type; |
| 1543 |
|
| 1544 |
/* Not in EHT range */ |
| 1545 |
if (info_type < IWL_RX_PHY_INFO_TYPE_EHT_MU || |
| 1546 |
info_type > IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT) |
| 1547 |
return; |
| 1548 |
|
| 1549 |
usig->common |= cpu_to_le32 |
| 1550 |
(IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL_KNOWN | |
| 1551 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR_KNOWN); |
| 1552 |
if (phy_data->with_data) { |
| 1553 |
usig->common |= LE32_DEC_ENC(data0, |
| 1554 |
IWL_RX_PHY_DATA0_EHT_UPLINK, |
| 1555 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL); |
| 1556 |
usig->common |= LE32_DEC_ENC(data0, |
| 1557 |
IWL_RX_PHY_DATA0_EHT_BSS_COLOR_MASK, |
| 1558 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR); |
| 1559 |
} else { |
| 1560 |
usig->common |= LE32_DEC_ENC(usig_a1, |
| 1561 |
IWL_RX_USIG_A1_UL_FLAG, |
| 1562 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL); |
| 1563 |
usig->common |= LE32_DEC_ENC(usig_a1, |
| 1564 |
IWL_RX_USIG_A1_BSS_COLOR, |
| 1565 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR); |
| 1566 |
} |
| 1567 |
|
| 1568 |
if (fw_has_capa(&mvm->fw->ucode_capa, |
| 1569 |
IWL_UCODE_TLV_CAPA_SNIFF_VALIDATE_SUPPORT)) { |
| 1570 |
usig->common |= |
| 1571 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_CHECKED); |
| 1572 |
usig->common |= |
| 1573 |
LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_VALIDATE, |
| 1574 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_OK); |
| 1575 |
} |
| 1576 |
|
| 1577 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_SPATIAL_REUSE); |
| 1578 |
eht->data[0] |= LE32_DEC_ENC(data0, |
| 1579 |
IWL_RX_PHY_DATA0_ETH_SPATIAL_REUSE_MASK, |
| 1580 |
IEEE80211_RADIOTAP_EHT_DATA0_SPATIAL_REUSE); |
| 1581 |
|
| 1582 |
/* All RU allocating size/index is in TB format */ |
| 1583 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_RU_ALLOC_TB_FMT); |
| 1584 |
eht->data[8] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PS160, |
| 1585 |
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_PS_160); |
| 1586 |
eht->data[8] |= LE32_DEC_ENC(data1, IWL_RX_PHY_DATA1_EHT_RU_ALLOC_B0, |
| 1587 |
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B0); |
| 1588 |
eht->data[8] |= LE32_DEC_ENC(data1, IWL_RX_PHY_DATA1_EHT_RU_ALLOC_B1_B7, |
| 1589 |
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1); |
| 1590 |
|
| 1591 |
iwl_mvm_decode_eht_ru(mvm, rx_status, eht); |
| 1592 |
|
| 1593 |
/* We only get here in case of IWL_RX_MPDU_PHY_TSF_OVERLOAD is set |
| 1594 |
* which is on only in case of monitor mode so no need to check monitor |
| 1595 |
* mode |
| 1596 |
*/ |
| 1597 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PRIMARY_80); |
| 1598 |
eht->data[1] |= |
| 1599 |
le32_encode_bits(mvm->monitor_p80, |
| 1600 |
IEEE80211_RADIOTAP_EHT_DATA1_PRIMARY_80); |
| 1601 |
|
| 1602 |
usig->common |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP_KNOWN); |
| 1603 |
if (phy_data->with_data) |
| 1604 |
usig->common |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_TXOP_DUR_MASK, |
| 1605 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP); |
| 1606 |
else |
| 1607 |
usig->common |= LE32_DEC_ENC(usig_a1, IWL_RX_USIG_A1_TXOP_DURATION, |
| 1608 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP); |
| 1609 |
|
| 1610 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_LDPC_EXTRA_SYM_OM); |
| 1611 |
eht->data[0] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_LDPC_EXT_SYM, |
| 1612 |
IEEE80211_RADIOTAP_EHT_DATA0_LDPC_EXTRA_SYM_OM); |
| 1613 |
|
| 1614 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PRE_PADD_FACOR_OM); |
| 1615 |
eht->data[0] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PRE_FEC_PAD_MASK, |
| 1616 |
IEEE80211_RADIOTAP_EHT_DATA0_PRE_PADD_FACOR_OM); |
| 1617 |
|
| 1618 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_PE_DISAMBIGUITY_OM); |
| 1619 |
eht->data[0] |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PE_DISAMBIG, |
| 1620 |
IEEE80211_RADIOTAP_EHT_DATA0_PE_DISAMBIGUITY_OM); |
| 1621 |
|
| 1622 |
/* TODO: what about IWL_RX_PHY_DATA0_EHT_BW320_SLOT */ |
| 1623 |
|
| 1624 |
if (!le32_get_bits(data0, IWL_RX_PHY_DATA0_EHT_SIGA_CRC_OK)) |
| 1625 |
usig->common |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BAD_USIG_CRC); |
| 1626 |
|
| 1627 |
usig->common |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER_KNOWN); |
| 1628 |
usig->common |= LE32_DEC_ENC(data0, IWL_RX_PHY_DATA0_EHT_PHY_VER, |
| 1629 |
IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER); |
| 1630 |
|
| 1631 |
/* |
| 1632 |
* TODO: what about TB - IWL_RX_PHY_DATA1_EHT_TB_PILOT_TYPE, |
| 1633 |
* IWL_RX_PHY_DATA1_EHT_TB_LOW_SS |
| 1634 |
*/ |
| 1635 |
|
| 1636 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_EHT_LTF); |
| 1637 |
eht->data[0] |= LE32_DEC_ENC(data1, IWL_RX_PHY_DATA1_EHT_SIG_LTF_NUM, |
| 1638 |
IEEE80211_RADIOTAP_EHT_DATA0_EHT_LTF); |
| 1639 |
|
| 1640 |
if (info_type == IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT || |
| 1641 |
info_type == IWL_RX_PHY_INFO_TYPE_EHT_TB) |
| 1642 |
iwl_mvm_decode_eht_ext_tb(mvm, phy_data, rx_status, eht, usig); |
| 1643 |
|
| 1644 |
if (info_type == IWL_RX_PHY_INFO_TYPE_EHT_MU_EXT || |
| 1645 |
info_type == IWL_RX_PHY_INFO_TYPE_EHT_MU) |
| 1646 |
iwl_mvm_decode_eht_ext_mu(mvm, phy_data, rx_status, eht, usig); |
| 1647 |
} |
| 1648 |
|
| 1649 |
static void iwl_mvm_rx_eht(struct iwl_mvm *mvm, struct sk_buff *skb, |
| 1650 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1651 |
int queue) |
| 1652 |
{ |
| 1653 |
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); |
| 1654 |
|
| 1655 |
struct ieee80211_radiotap_eht *eht; |
| 1656 |
struct ieee80211_radiotap_eht_usig *usig; |
| 1657 |
size_t eht_len = sizeof(*eht); |
| 1658 |
|
| 1659 |
u32 rate_n_flags = phy_data->rate_n_flags; |
| 1660 |
u32 he_type = rate_n_flags & RATE_MCS_HE_TYPE_MSK; |
| 1661 |
/* EHT and HE have the same valus for LTF */ |
| 1662 |
u8 ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN; |
| 1663 |
u16 phy_info = phy_data->phy_info; |
| 1664 |
u32 bw; |
| 1665 |
|
| 1666 |
/* u32 for 1 user_info */ |
| 1667 |
if (phy_data->with_data) |
| 1668 |
eht_len += sizeof(u32); |
| 1669 |
|
| 1670 |
eht = iwl_mvm_radiotap_put_tlv(skb, IEEE80211_RADIOTAP_EHT, eht_len); |
| 1671 |
|
| 1672 |
usig = iwl_mvm_radiotap_put_tlv(skb, IEEE80211_RADIOTAP_EHT_USIG, |
| 1673 |
sizeof(*usig)); |
| 1674 |
rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END; |
| 1675 |
usig->common |= |
| 1676 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_KNOWN); |
| 1677 |
|
| 1678 |
/* specific handling for 320MHz */ |
| 1679 |
bw = FIELD_GET(RATE_MCS_CHAN_WIDTH_MSK, rate_n_flags); |
| 1680 |
if (bw == RATE_MCS_CHAN_WIDTH_320_VAL) |
| 1681 |
bw += FIELD_GET(IWL_RX_PHY_DATA0_EHT_BW320_SLOT, |
| 1682 |
le32_to_cpu(phy_data->d0)); |
| 1683 |
|
| 1684 |
usig->common |= cpu_to_le32 |
| 1685 |
(FIELD_PREP(IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW, bw)); |
| 1686 |
|
| 1687 |
/* report the AMPDU-EOF bit on single frames */ |
| 1688 |
if (!queue && !(phy_info & IWL_RX_MPDU_PHY_AMPDU)) { |
| 1689 |
rx_status->flag |= RX_FLAG_AMPDU_DETAILS; |
| 1690 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN; |
| 1691 |
if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF)) |
| 1692 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT; |
| 1693 |
} |
| 1694 |
|
| 1695 |
/* update aggregation data for monitor sake on default queue */ |
| 1696 |
if (!queue && (phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD) && |
| 1697 |
(phy_info & IWL_RX_MPDU_PHY_AMPDU) && phy_data->first_subframe) { |
| 1698 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN; |
| 1699 |
if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF)) |
| 1700 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT; |
| 1701 |
} |
| 1702 |
|
| 1703 |
if (phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD) |
| 1704 |
iwl_mvm_decode_eht_phy_data(mvm, phy_data, rx_status, eht, usig); |
| 1705 |
|
| 1706 |
#define CHECK_TYPE(F) \ |
| 1707 |
BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA1_FORMAT_ ## F != \ |
| 1708 |
(RATE_MCS_HE_TYPE_ ## F >> RATE_MCS_HE_TYPE_POS)) |
| 1709 |
|
| 1710 |
CHECK_TYPE(SU); |
| 1711 |
CHECK_TYPE(EXT_SU); |
| 1712 |
CHECK_TYPE(MU); |
| 1713 |
CHECK_TYPE(TRIG); |
| 1714 |
|
| 1715 |
switch (FIELD_GET(RATE_MCS_HE_GI_LTF_MSK, rate_n_flags)) { |
| 1716 |
case 0: |
| 1717 |
if (he_type == RATE_MCS_HE_TYPE_TRIG) { |
| 1718 |
rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_1_6; |
| 1719 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X; |
| 1720 |
} else { |
| 1721 |
rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_0_8; |
| 1722 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X; |
| 1723 |
} |
| 1724 |
break; |
| 1725 |
case 1: |
| 1726 |
rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_1_6; |
| 1727 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X; |
| 1728 |
break; |
| 1729 |
case 2: |
| 1730 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X; |
| 1731 |
if (he_type == RATE_MCS_HE_TYPE_TRIG) |
| 1732 |
rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_3_2; |
| 1733 |
else |
| 1734 |
rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_0_8; |
| 1735 |
break; |
| 1736 |
case 3: |
| 1737 |
if (he_type != RATE_MCS_HE_TYPE_TRIG) { |
| 1738 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X; |
| 1739 |
rx_status->eht.gi = NL80211_RATE_INFO_EHT_GI_3_2; |
| 1740 |
} |
| 1741 |
break; |
| 1742 |
default: |
| 1743 |
/* nothing here */ |
| 1744 |
break; |
| 1745 |
} |
| 1746 |
|
| 1747 |
if (ltf != IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN) { |
| 1748 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_GI); |
| 1749 |
eht->data[0] |= cpu_to_le32 |
| 1750 |
(FIELD_PREP(IEEE80211_RADIOTAP_EHT_DATA0_LTF, |
| 1751 |
ltf) | |
| 1752 |
FIELD_PREP(IEEE80211_RADIOTAP_EHT_DATA0_GI, |
| 1753 |
rx_status->eht.gi)); |
| 1754 |
} |
| 1755 |
|
| 1756 |
|
| 1757 |
if (!phy_data->with_data) { |
| 1758 |
eht->known |= cpu_to_le32(IEEE80211_RADIOTAP_EHT_KNOWN_NSS_S | |
| 1759 |
IEEE80211_RADIOTAP_EHT_KNOWN_BEAMFORMED_S); |
| 1760 |
eht->data[7] |= |
| 1761 |
le32_encode_bits(le32_get_bits(phy_data->rx_vec[2], |
| 1762 |
RX_NO_DATA_RX_VEC2_EHT_NSTS_MSK), |
| 1763 |
IEEE80211_RADIOTAP_EHT_DATA7_NSS_S); |
| 1764 |
if (rate_n_flags & RATE_MCS_BF_MSK) |
| 1765 |
eht->data[7] |= |
| 1766 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_DATA7_BEAMFORMED_S); |
| 1767 |
} else { |
| 1768 |
eht->user_info[0] |= |
| 1769 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_MCS_KNOWN | |
| 1770 |
IEEE80211_RADIOTAP_EHT_USER_INFO_CODING_KNOWN | |
| 1771 |
IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_KNOWN_O | |
| 1772 |
IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_KNOWN_O | |
| 1773 |
IEEE80211_RADIOTAP_EHT_USER_INFO_DATA_FOR_USER); |
| 1774 |
|
| 1775 |
if (rate_n_flags & RATE_MCS_BF_MSK) |
| 1776 |
eht->user_info[0] |= |
| 1777 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_O); |
| 1778 |
|
| 1779 |
if (rate_n_flags & RATE_MCS_LDPC_MSK) |
| 1780 |
eht->user_info[0] |= |
| 1781 |
cpu_to_le32(IEEE80211_RADIOTAP_EHT_USER_INFO_CODING); |
| 1782 |
|
| 1783 |
eht->user_info[0] |= cpu_to_le32 |
| 1784 |
(FIELD_PREP(IEEE80211_RADIOTAP_EHT_USER_INFO_MCS, |
| 1785 |
FIELD_GET(RATE_VHT_MCS_RATE_CODE_MSK, |
| 1786 |
rate_n_flags)) | |
| 1787 |
FIELD_PREP(IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_O, |
| 1788 |
FIELD_GET(RATE_MCS_NSS_MSK, rate_n_flags))); |
| 1789 |
} |
| 1790 |
} |
| 1791 |
|
| 1792 |
static void iwl_mvm_rx_he(struct iwl_mvm *mvm, struct sk_buff *skb, |
| 1793 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1794 |
int queue) |
| 1795 |
{ |
| 1796 |
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); |
| 1797 |
struct ieee80211_radiotap_he *he = NULL; |
| 1798 |
struct ieee80211_radiotap_he_mu *he_mu = NULL; |
| 1799 |
u32 rate_n_flags = phy_data->rate_n_flags; |
| 1800 |
u32 he_type = rate_n_flags & RATE_MCS_HE_TYPE_MSK; |
| 1801 |
u8 ltf; |
| 1802 |
static const struct ieee80211_radiotap_he known = { |
| 1803 |
.data1 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN | |
| 1804 |
IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN | |
| 1805 |
IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN | |
| 1806 |
IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN), |
| 1807 |
.data2 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN | |
| 1808 |
IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN), |
| 1809 |
}; |
| 1810 |
static const struct ieee80211_radiotap_he_mu mu_known = { |
| 1811 |
.flags1 = cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS_KNOWN | |
| 1812 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM_KNOWN | |
| 1813 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN | |
| 1814 |
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_COMP_KNOWN), |
| 1815 |
.flags2 = cpu_to_le16(IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN | |
| 1816 |
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN), |
| 1817 |
}; |
| 1818 |
u16 phy_info = phy_data->phy_info; |
| 1819 |
|
| 1820 |
he = skb_put_data(skb, &known, sizeof(known)); |
| 1821 |
rx_status->flag |= RX_FLAG_RADIOTAP_HE; |
| 1822 |
|
| 1823 |
if (phy_data->info_type == IWL_RX_PHY_INFO_TYPE_HE_MU || |
| 1824 |
phy_data->info_type == IWL_RX_PHY_INFO_TYPE_HE_MU_EXT) { |
| 1825 |
he_mu = skb_put_data(skb, &mu_known, sizeof(mu_known)); |
| 1826 |
rx_status->flag |= RX_FLAG_RADIOTAP_HE_MU; |
| 1827 |
} |
| 1828 |
|
| 1829 |
/* report the AMPDU-EOF bit on single frames */ |
| 1830 |
if (!queue && !(phy_info & IWL_RX_MPDU_PHY_AMPDU)) { |
| 1831 |
rx_status->flag |= RX_FLAG_AMPDU_DETAILS; |
| 1832 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN; |
| 1833 |
if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_HE_DELIM_EOF)) |
| 1834 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT; |
| 1835 |
} |
| 1836 |
|
| 1837 |
if (phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD) |
| 1838 |
iwl_mvm_decode_he_phy_data(mvm, phy_data, he, he_mu, rx_status, |
| 1839 |
queue); |
| 1840 |
|
| 1841 |
/* update aggregation data for monitor sake on default queue */ |
| 1842 |
if (!queue && (phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD) && |
| 1843 |
(phy_info & IWL_RX_MPDU_PHY_AMPDU) && phy_data->first_subframe) { |
| 1844 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT_KNOWN; |
| 1845 |
if (phy_data->d0 & cpu_to_le32(IWL_RX_PHY_DATA0_EHT_DELIM_EOF)) |
| 1846 |
rx_status->flag |= RX_FLAG_AMPDU_EOF_BIT; |
| 1847 |
} |
| 1848 |
|
| 1849 |
if (he_type == RATE_MCS_HE_TYPE_EXT_SU && |
| 1850 |
rate_n_flags & RATE_MCS_HE_106T_MSK) { |
| 1851 |
rx_status->bw = RATE_INFO_BW_HE_RU; |
| 1852 |
rx_status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_106; |
| 1853 |
} |
| 1854 |
|
| 1855 |
/* actually data is filled in mac80211 */ |
| 1856 |
if (he_type == RATE_MCS_HE_TYPE_SU || |
| 1857 |
he_type == RATE_MCS_HE_TYPE_EXT_SU) |
| 1858 |
he->data1 |= |
| 1859 |
cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN); |
| 1860 |
|
| 1861 |
#define CHECK_TYPE(F) \ |
| 1862 |
BUILD_BUG_ON(IEEE80211_RADIOTAP_HE_DATA1_FORMAT_ ## F != \ |
| 1863 |
(RATE_MCS_HE_TYPE_ ## F >> RATE_MCS_HE_TYPE_POS)) |
| 1864 |
|
| 1865 |
CHECK_TYPE(SU); |
| 1866 |
CHECK_TYPE(EXT_SU); |
| 1867 |
CHECK_TYPE(MU); |
| 1868 |
CHECK_TYPE(TRIG); |
| 1869 |
|
| 1870 |
he->data1 |= cpu_to_le16(he_type >> RATE_MCS_HE_TYPE_POS); |
| 1871 |
|
| 1872 |
if (rate_n_flags & RATE_MCS_BF_MSK) |
| 1873 |
he->data5 |= cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA5_TXBF); |
| 1874 |
|
| 1875 |
switch ((rate_n_flags & RATE_MCS_HE_GI_LTF_MSK) >> |
| 1876 |
RATE_MCS_HE_GI_LTF_POS) { |
| 1877 |
case 0: |
| 1878 |
if (he_type == RATE_MCS_HE_TYPE_TRIG) |
| 1879 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_1_6; |
| 1880 |
else |
| 1881 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_0_8; |
| 1882 |
if (he_type == RATE_MCS_HE_TYPE_MU) |
| 1883 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X; |
| 1884 |
else |
| 1885 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X; |
| 1886 |
break; |
| 1887 |
case 1: |
| 1888 |
if (he_type == RATE_MCS_HE_TYPE_TRIG) |
| 1889 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_1_6; |
| 1890 |
else |
| 1891 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_0_8; |
| 1892 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X; |
| 1893 |
break; |
| 1894 |
case 2: |
| 1895 |
if (he_type == RATE_MCS_HE_TYPE_TRIG) { |
| 1896 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_3_2; |
| 1897 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X; |
| 1898 |
} else { |
| 1899 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_1_6; |
| 1900 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X; |
| 1901 |
} |
| 1902 |
break; |
| 1903 |
case 3: |
| 1904 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_3_2; |
| 1905 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X; |
| 1906 |
break; |
| 1907 |
case 4: |
| 1908 |
rx_status->he_gi = NL80211_RATE_INFO_HE_GI_0_8; |
| 1909 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X; |
| 1910 |
break; |
| 1911 |
default: |
| 1912 |
ltf = IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN; |
| 1913 |
} |
| 1914 |
|
| 1915 |
he->data5 |= le16_encode_bits(ltf, |
| 1916 |
IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE); |
| 1917 |
} |
| 1918 |
|
| 1919 |
static void iwl_mvm_decode_lsig(struct sk_buff *skb, |
| 1920 |
struct iwl_mvm_rx_phy_data *phy_data) |
| 1921 |
{ |
| 1922 |
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); |
| 1923 |
struct ieee80211_radiotap_lsig *lsig; |
| 1924 |
|
| 1925 |
switch (phy_data->info_type) { |
| 1926 |
case IWL_RX_PHY_INFO_TYPE_HT: |
| 1927 |
case IWL_RX_PHY_INFO_TYPE_VHT_SU: |
| 1928 |
case IWL_RX_PHY_INFO_TYPE_VHT_MU: |
| 1929 |
case IWL_RX_PHY_INFO_TYPE_HE_TB_EXT: |
| 1930 |
case IWL_RX_PHY_INFO_TYPE_HE_SU: |
| 1931 |
case IWL_RX_PHY_INFO_TYPE_HE_MU: |
| 1932 |
case IWL_RX_PHY_INFO_TYPE_HE_MU_EXT: |
| 1933 |
case IWL_RX_PHY_INFO_TYPE_HE_TB: |
| 1934 |
case IWL_RX_PHY_INFO_TYPE_EHT_MU: |
| 1935 |
case IWL_RX_PHY_INFO_TYPE_EHT_TB: |
| 1936 |
case IWL_RX_PHY_INFO_TYPE_EHT_MU_EXT: |
| 1937 |
case IWL_RX_PHY_INFO_TYPE_EHT_TB_EXT: |
| 1938 |
lsig = skb_put(skb, sizeof(*lsig)); |
| 1939 |
lsig->data1 = cpu_to_le16(IEEE80211_RADIOTAP_LSIG_DATA1_LENGTH_KNOWN); |
| 1940 |
lsig->data2 = le16_encode_bits(le32_get_bits(phy_data->d1, |
| 1941 |
IWL_RX_PHY_DATA1_LSIG_LEN_MASK), |
| 1942 |
IEEE80211_RADIOTAP_LSIG_DATA2_LENGTH); |
| 1943 |
rx_status->flag |= RX_FLAG_RADIOTAP_LSIG; |
| 1944 |
break; |
| 1945 |
default: |
| 1946 |
break; |
| 1947 |
} |
| 1948 |
} |
| 1949 |
|
| 1950 |
struct iwl_rx_sta_csa { |
| 1951 |
bool all_sta_unblocked; |
| 1952 |
struct ieee80211_vif *vif; |
| 1953 |
}; |
| 1954 |
|
| 1955 |
static void iwl_mvm_rx_get_sta_block_tx(void *data, struct ieee80211_sta *sta) |
| 1956 |
{ |
| 1957 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 1958 |
struct iwl_rx_sta_csa *rx_sta_csa = data; |
| 1959 |
|
| 1960 |
if (mvmsta->vif != rx_sta_csa->vif) |
| 1961 |
return; |
| 1962 |
|
| 1963 |
if (mvmsta->disable_tx) |
| 1964 |
rx_sta_csa->all_sta_unblocked = false; |
| 1965 |
} |
| 1966 |
|
| 1967 |
/* |
| 1968 |
* Note: requires also rx_status->band to be prefilled, as well |
| 1969 |
* as phy_data (apart from phy_data->info_type) |
| 1970 |
* Note: desc/hdr may be NULL |
| 1971 |
*/ |
| 1972 |
static void iwl_mvm_rx_fill_status(struct iwl_mvm *mvm, |
| 1973 |
struct iwl_rx_mpdu_desc *desc, |
| 1974 |
struct ieee80211_hdr *hdr, |
| 1975 |
struct sk_buff *skb, |
| 1976 |
struct iwl_mvm_rx_phy_data *phy_data, |
| 1977 |
int queue) |
| 1978 |
{ |
| 1979 |
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); |
| 1980 |
u32 rate_n_flags = phy_data->rate_n_flags; |
| 1981 |
u8 stbc = u32_get_bits(rate_n_flags, RATE_MCS_STBC_MSK); |
| 1982 |
u32 format = rate_n_flags & RATE_MCS_MOD_TYPE_MSK; |
| 1983 |
bool is_sgi; |
| 1984 |
|
| 1985 |
phy_data->info_type = IWL_RX_PHY_INFO_TYPE_NONE; |
| 1986 |
|
| 1987 |
if (phy_data->phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD) |
| 1988 |
phy_data->info_type = |
| 1989 |
le32_get_bits(phy_data->d1, |
| 1990 |
IWL_RX_PHY_DATA1_INFO_TYPE_MASK); |
| 1991 |
|
| 1992 |
/* This may be overridden by iwl_mvm_rx_he() to HE_RU */ |
| 1993 |
switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) { |
| 1994 |
case RATE_MCS_CHAN_WIDTH_20: |
| 1995 |
break; |
| 1996 |
case RATE_MCS_CHAN_WIDTH_40: |
| 1997 |
rx_status->bw = RATE_INFO_BW_40; |
| 1998 |
break; |
| 1999 |
case RATE_MCS_CHAN_WIDTH_80: |
| 2000 |
rx_status->bw = RATE_INFO_BW_80; |
| 2001 |
break; |
| 2002 |
case RATE_MCS_CHAN_WIDTH_160: |
| 2003 |
rx_status->bw = RATE_INFO_BW_160; |
| 2004 |
break; |
| 2005 |
case RATE_MCS_CHAN_WIDTH_320: |
| 2006 |
rx_status->bw = RATE_INFO_BW_320; |
| 2007 |
break; |
| 2008 |
} |
| 2009 |
|
| 2010 |
/* must be before L-SIG data */ |
| 2011 |
if (format == RATE_MCS_MOD_TYPE_HE) |
| 2012 |
iwl_mvm_rx_he(mvm, skb, phy_data, queue); |
| 2013 |
|
| 2014 |
iwl_mvm_decode_lsig(skb, phy_data); |
| 2015 |
|
| 2016 |
rx_status->device_timestamp = phy_data->gp2_on_air_rise; |
| 2017 |
|
| 2018 |
if (mvm->rx_ts_ptp && mvm->monitor_on) { |
| 2019 |
u64 adj_time = |
| 2020 |
iwl_mvm_ptp_get_adj_time(mvm, phy_data->gp2_on_air_rise * NSEC_PER_USEC); |
| 2021 |
|
| 2022 |
rx_status->mactime = div64_u64(adj_time, NSEC_PER_USEC); |
| 2023 |
rx_status->flag |= RX_FLAG_MACTIME_IS_RTAP_TS64; |
| 2024 |
rx_status->flag &= ~RX_FLAG_MACTIME; |
| 2025 |
} |
| 2026 |
|
| 2027 |
rx_status->freq = ieee80211_channel_to_frequency(phy_data->channel, |
| 2028 |
rx_status->band); |
| 2029 |
iwl_mvm_get_signal_strength(mvm, desc, hdr, rx_status, rate_n_flags, |
| 2030 |
phy_data->energy_a, phy_data->energy_b); |
| 2031 |
|
| 2032 |
/* using TLV format and must be after all fixed len fields */ |
| 2033 |
if (format == RATE_MCS_MOD_TYPE_EHT) |
| 2034 |
iwl_mvm_rx_eht(mvm, skb, phy_data, queue); |
| 2035 |
|
| 2036 |
if (unlikely(mvm->monitor_on)) |
| 2037 |
iwl_mvm_add_rtap_sniffer_config(mvm, skb); |
| 2038 |
|
| 2039 |
is_sgi = format == RATE_MCS_MOD_TYPE_HE ? |
| 2040 |
iwl_he_is_sgi(rate_n_flags) : |
| 2041 |
rate_n_flags & RATE_MCS_SGI_MSK; |
| 2042 |
|
| 2043 |
if (!(format == RATE_MCS_MOD_TYPE_CCK) && is_sgi) |
| 2044 |
rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI; |
| 2045 |
|
| 2046 |
if (rate_n_flags & RATE_MCS_LDPC_MSK) |
| 2047 |
rx_status->enc_flags |= RX_ENC_FLAG_LDPC; |
| 2048 |
|
| 2049 |
switch (format) { |
| 2050 |
case RATE_MCS_MOD_TYPE_VHT: |
| 2051 |
rx_status->encoding = RX_ENC_VHT; |
| 2052 |
break; |
| 2053 |
case RATE_MCS_MOD_TYPE_HE: |
| 2054 |
rx_status->encoding = RX_ENC_HE; |
| 2055 |
rx_status->he_dcm = |
| 2056 |
!!(rate_n_flags & RATE_HE_DUAL_CARRIER_MODE_MSK); |
| 2057 |
break; |
| 2058 |
case RATE_MCS_MOD_TYPE_EHT: |
| 2059 |
rx_status->encoding = RX_ENC_EHT; |
| 2060 |
break; |
| 2061 |
} |
| 2062 |
|
| 2063 |
switch (format) { |
| 2064 |
case RATE_MCS_MOD_TYPE_HT: |
| 2065 |
rx_status->encoding = RX_ENC_HT; |
| 2066 |
rx_status->rate_idx = RATE_HT_MCS_INDEX(rate_n_flags); |
| 2067 |
rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT; |
| 2068 |
break; |
| 2069 |
case RATE_MCS_MOD_TYPE_VHT: |
| 2070 |
case RATE_MCS_MOD_TYPE_HE: |
| 2071 |
case RATE_MCS_MOD_TYPE_EHT: |
| 2072 |
rx_status->nss = |
| 2073 |
u32_get_bits(rate_n_flags, RATE_MCS_NSS_MSK) + 1; |
| 2074 |
rx_status->rate_idx = rate_n_flags & RATE_MCS_CODE_MSK; |
| 2075 |
rx_status->enc_flags |= stbc << RX_ENC_FLAG_STBC_SHIFT; |
| 2076 |
break; |
| 2077 |
default: { |
| 2078 |
int rate = iwl_mvm_legacy_hw_idx_to_mac80211_idx(rate_n_flags, |
| 2079 |
rx_status->band); |
| 2080 |
|
| 2081 |
rx_status->rate_idx = rate; |
| 2082 |
|
| 2083 |
if ((rate < 0 || rate > 0xFF)) { |
| 2084 |
rx_status->rate_idx = 0; |
| 2085 |
if (net_ratelimit()) |
| 2086 |
IWL_ERR(mvm, "Invalid rate flags 0x%x, band %d,\n", |
| 2087 |
rate_n_flags, rx_status->band); |
| 2088 |
} |
| 2089 |
|
| 2090 |
break; |
| 2091 |
} |
| 2092 |
} |
| 2093 |
} |
| 2094 |
|
| 2095 |
void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, |
| 2096 |
struct iwl_rx_cmd_buffer *rxb, int queue) |
| 2097 |
{ |
| 2098 |
struct ieee80211_rx_status *rx_status; |
| 2099 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 2100 |
struct iwl_rx_mpdu_desc *desc = (void *)pkt->data; |
| 2101 |
struct ieee80211_hdr *hdr; |
| 2102 |
u32 len; |
| 2103 |
u32 pkt_len = iwl_rx_packet_payload_len(pkt); |
| 2104 |
struct ieee80211_sta *sta = NULL; |
| 2105 |
struct sk_buff *skb; |
| 2106 |
u8 crypt_len = 0; |
| 2107 |
size_t desc_size; |
| 2108 |
struct iwl_mvm_rx_phy_data phy_data = {}; |
| 2109 |
u32 format; |
| 2110 |
|
| 2111 |
if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))) |
| 2112 |
return; |
| 2113 |
|
| 2114 |
if (mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) |
| 2115 |
desc_size = sizeof(*desc); |
| 2116 |
else |
| 2117 |
desc_size = IWL_RX_DESC_SIZE_V1; |
| 2118 |
|
| 2119 |
if (unlikely(pkt_len < desc_size)) { |
| 2120 |
IWL_DEBUG_DROP(mvm, "Bad REPLY_RX_MPDU_CMD size\n"); |
| 2121 |
return; |
| 2122 |
} |
| 2123 |
|
| 2124 |
if (mvm->trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { |
| 2125 |
phy_data.rate_n_flags = |
| 2126 |
iwl_mvm_v3_rate_from_fw(desc->v3.rate_n_flags, |
| 2127 |
mvm->fw_rates_ver); |
| 2128 |
phy_data.channel = desc->v3.channel; |
| 2129 |
phy_data.gp2_on_air_rise = le32_to_cpu(desc->v3.gp2_on_air_rise); |
| 2130 |
phy_data.energy_a = desc->v3.energy_a; |
| 2131 |
phy_data.energy_b = desc->v3.energy_b; |
| 2132 |
|
| 2133 |
phy_data.d0 = desc->v3.phy_data0; |
| 2134 |
phy_data.d1 = desc->v3.phy_data1; |
| 2135 |
phy_data.d2 = desc->v3.phy_data2; |
| 2136 |
phy_data.d3 = desc->v3.phy_data3; |
| 2137 |
phy_data.eht_d4 = desc->phy_eht_data4; |
| 2138 |
phy_data.d5 = desc->v3.phy_data5; |
| 2139 |
} else { |
| 2140 |
phy_data.rate_n_flags = |
| 2141 |
iwl_mvm_v3_rate_from_fw(desc->v1.rate_n_flags, |
| 2142 |
mvm->fw_rates_ver); |
| 2143 |
phy_data.channel = desc->v1.channel; |
| 2144 |
phy_data.gp2_on_air_rise = le32_to_cpu(desc->v1.gp2_on_air_rise); |
| 2145 |
phy_data.energy_a = desc->v1.energy_a; |
| 2146 |
phy_data.energy_b = desc->v1.energy_b; |
| 2147 |
|
| 2148 |
phy_data.d0 = desc->v1.phy_data0; |
| 2149 |
phy_data.d1 = desc->v1.phy_data1; |
| 2150 |
phy_data.d2 = desc->v1.phy_data2; |
| 2151 |
phy_data.d3 = desc->v1.phy_data3; |
| 2152 |
} |
| 2153 |
|
| 2154 |
format = phy_data.rate_n_flags & RATE_MCS_MOD_TYPE_MSK; |
| 2155 |
|
| 2156 |
len = le16_to_cpu(desc->mpdu_len); |
| 2157 |
|
| 2158 |
if (unlikely(len + desc_size > pkt_len)) { |
| 2159 |
IWL_DEBUG_DROP(mvm, "FW lied about packet len\n"); |
| 2160 |
return; |
| 2161 |
} |
| 2162 |
|
| 2163 |
phy_data.with_data = true; |
| 2164 |
phy_data.phy_info = le16_to_cpu(desc->phy_info); |
| 2165 |
phy_data.d4 = desc->phy_data4; |
| 2166 |
|
| 2167 |
hdr = (void *)(pkt->data + desc_size); |
| 2168 |
/* Dont use dev_alloc_skb(), we'll have enough headroom once |
| 2169 |
* ieee80211_hdr pulled. |
| 2170 |
*/ |
| 2171 |
skb = alloc_skb(128, GFP_ATOMIC); |
| 2172 |
if (!skb) { |
| 2173 |
IWL_ERR(mvm, "alloc_skb failed\n"); |
| 2174 |
return; |
| 2175 |
} |
| 2176 |
|
| 2177 |
if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD) { |
| 2178 |
/* |
| 2179 |
* If the device inserted padding it means that (it thought) |
| 2180 |
* the 802.11 header wasn't a multiple of 4 bytes long. In |
| 2181 |
* this case, reserve two bytes at the start of the SKB to |
| 2182 |
* align the payload properly in case we end up copying it. |
| 2183 |
*/ |
| 2184 |
skb_reserve(skb, 2); |
| 2185 |
} |
| 2186 |
|
| 2187 |
rx_status = IEEE80211_SKB_RXCB(skb); |
| 2188 |
|
| 2189 |
/* |
| 2190 |
* Keep packets with CRC errors (and with overrun) for monitor mode |
| 2191 |
* (otherwise the firmware discards them) but mark them as bad. |
| 2192 |
*/ |
| 2193 |
if (!(desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_CRC_OK)) || |
| 2194 |
!(desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_OVERRUN_OK))) { |
| 2195 |
IWL_DEBUG_RX(mvm, "Bad CRC or FIFO: 0x%08X.\n", |
| 2196 |
le32_to_cpu(desc->status)); |
| 2197 |
rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; |
| 2198 |
} |
| 2199 |
|
| 2200 |
/* set the preamble flag if appropriate */ |
| 2201 |
if (format == RATE_MCS_MOD_TYPE_CCK && |
| 2202 |
phy_data.phy_info & IWL_RX_MPDU_PHY_SHORT_PREAMBLE) |
| 2203 |
rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; |
| 2204 |
|
| 2205 |
if (likely(!(phy_data.phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD))) { |
| 2206 |
u64 tsf_on_air_rise; |
| 2207 |
|
| 2208 |
if (mvm->trans->mac_cfg->device_family >= |
| 2209 |
IWL_DEVICE_FAMILY_AX210) |
| 2210 |
tsf_on_air_rise = le64_to_cpu(desc->v3.tsf_on_air_rise); |
| 2211 |
else |
| 2212 |
tsf_on_air_rise = le64_to_cpu(desc->v1.tsf_on_air_rise); |
| 2213 |
|
| 2214 |
rx_status->mactime = tsf_on_air_rise; |
| 2215 |
/* TSF as indicated by the firmware is at INA time */ |
| 2216 |
rx_status->flag |= RX_FLAG_MACTIME_PLCP_START; |
| 2217 |
} |
| 2218 |
|
| 2219 |
if (iwl_mvm_is_band_in_rx_supported(mvm)) { |
| 2220 |
u8 band = u8_get_bits(desc->mac_phy_band, |
| 2221 |
IWL_RX_MPDU_MAC_PHY_BAND_BAND_MASK); |
| 2222 |
|
| 2223 |
rx_status->band = iwl_mvm_nl80211_band_from_phy(band); |
| 2224 |
} else { |
| 2225 |
rx_status->band = phy_data.channel > 14 ? NL80211_BAND_5GHZ : |
| 2226 |
NL80211_BAND_2GHZ; |
| 2227 |
} |
| 2228 |
|
| 2229 |
/* update aggregation data for monitor sake on default queue */ |
| 2230 |
if (!queue && (phy_data.phy_info & IWL_RX_MPDU_PHY_AMPDU)) { |
| 2231 |
bool toggle_bit; |
| 2232 |
|
| 2233 |
toggle_bit = phy_data.phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE; |
| 2234 |
rx_status->flag |= RX_FLAG_AMPDU_DETAILS; |
| 2235 |
/* |
| 2236 |
* Toggle is switched whenever new aggregation starts. Make |
| 2237 |
* sure ampdu_reference is never 0 so we can later use it to |
| 2238 |
* see if the frame was really part of an A-MPDU or not. |
| 2239 |
*/ |
| 2240 |
if (toggle_bit != mvm->ampdu_toggle) { |
| 2241 |
mvm->ampdu_ref++; |
| 2242 |
if (mvm->ampdu_ref == 0) |
| 2243 |
mvm->ampdu_ref++; |
| 2244 |
mvm->ampdu_toggle = toggle_bit; |
| 2245 |
phy_data.first_subframe = true; |
| 2246 |
} |
| 2247 |
rx_status->ampdu_reference = mvm->ampdu_ref; |
| 2248 |
} |
| 2249 |
|
| 2250 |
rcu_read_lock(); |
| 2251 |
|
| 2252 |
if (desc->status & cpu_to_le32(IWL_RX_MPDU_STATUS_SRC_STA_FOUND)) { |
| 2253 |
u8 sta_id = le32_get_bits(desc->status, |
| 2254 |
IWL_RX_MPDU_STATUS_STA_ID); |
| 2255 |
|
| 2256 |
if (!WARN_ON_ONCE(sta_id >= mvm->fw->ucode_capa.num_stations)) { |
| 2257 |
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); |
| 2258 |
if (IS_ERR(sta)) |
| 2259 |
sta = NULL; |
| 2260 |
} |
| 2261 |
} else if (!is_multicast_ether_addr(hdr->addr2)) { |
| 2262 |
/* |
| 2263 |
* This is fine since we prevent two stations with the same |
| 2264 |
* address from being added. |
| 2265 |
*/ |
| 2266 |
sta = ieee80211_find_sta_by_ifaddr(mvm->hw, hdr->addr2, NULL); |
| 2267 |
} |
| 2268 |
|
| 2269 |
if (iwl_mvm_rx_crypto(mvm, sta, hdr, rx_status, phy_data.phy_info, desc, |
| 2270 |
le32_to_cpu(pkt->len_n_flags), queue, |
| 2271 |
&crypt_len)) { |
| 2272 |
kfree_skb(skb); |
| 2273 |
goto out; |
| 2274 |
} |
| 2275 |
|
| 2276 |
iwl_mvm_rx_fill_status(mvm, desc, hdr, skb, &phy_data, queue); |
| 2277 |
|
| 2278 |
if (sta) { |
| 2279 |
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
| 2280 |
struct ieee80211_vif *tx_blocked_vif = |
| 2281 |
rcu_dereference(mvm->csa_tx_blocked_vif); |
| 2282 |
u8 baid = (u8)((le32_to_cpu(desc->reorder_data) & |
| 2283 |
IWL_RX_MPDU_REORDER_BAID_MASK) >> |
| 2284 |
IWL_RX_MPDU_REORDER_BAID_SHIFT); |
| 2285 |
struct iwl_fw_dbg_trigger_tlv *trig; |
| 2286 |
struct ieee80211_vif *vif = mvmsta->vif; |
| 2287 |
|
| 2288 |
if (!mvm->tcm.paused && len >= sizeof(*hdr) && |
| 2289 |
!is_multicast_ether_addr(hdr->addr1) && |
| 2290 |
ieee80211_is_data(hdr->frame_control) && |
| 2291 |
time_after(jiffies, mvm->tcm.ts + MVM_TCM_PERIOD)) |
| 2292 |
schedule_delayed_work(&mvm->tcm.work, 0); |
| 2293 |
|
| 2294 |
/* |
| 2295 |
* We have tx blocked stations (with CS bit). If we heard |
| 2296 |
* frames from a blocked station on a new channel we can |
| 2297 |
* TX to it again. |
| 2298 |
*/ |
| 2299 |
if (unlikely(tx_blocked_vif) && tx_blocked_vif == vif) { |
| 2300 |
struct iwl_mvm_vif *mvmvif = |
| 2301 |
iwl_mvm_vif_from_mac80211(tx_blocked_vif); |
| 2302 |
struct iwl_rx_sta_csa rx_sta_csa = { |
| 2303 |
.all_sta_unblocked = true, |
| 2304 |
.vif = tx_blocked_vif, |
| 2305 |
}; |
| 2306 |
|
| 2307 |
if (mvmvif->csa_target_freq == rx_status->freq) |
| 2308 |
iwl_mvm_sta_modify_disable_tx_ap(mvm, sta, |
| 2309 |
false); |
| 2310 |
ieee80211_iterate_stations_atomic(mvm->hw, |
| 2311 |
iwl_mvm_rx_get_sta_block_tx, |
| 2312 |
&rx_sta_csa); |
| 2313 |
|
| 2314 |
if (rx_sta_csa.all_sta_unblocked) { |
| 2315 |
RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); |
| 2316 |
/* Unblock BCAST / MCAST station */ |
| 2317 |
iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, false); |
| 2318 |
cancel_delayed_work(&mvm->cs_tx_unblock_dwork); |
| 2319 |
} |
| 2320 |
} |
| 2321 |
|
| 2322 |
rs_update_last_rssi(mvm, mvmsta, rx_status); |
| 2323 |
|
| 2324 |
trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, |
| 2325 |
ieee80211_vif_to_wdev(vif), |
| 2326 |
FW_DBG_TRIGGER_RSSI); |
| 2327 |
|
| 2328 |
if (trig && ieee80211_is_beacon(hdr->frame_control)) { |
| 2329 |
struct iwl_fw_dbg_trigger_low_rssi *rssi_trig; |
| 2330 |
s32 rssi; |
| 2331 |
|
| 2332 |
rssi_trig = (void *)trig->data; |
| 2333 |
rssi = le32_to_cpu(rssi_trig->rssi); |
| 2334 |
|
| 2335 |
if (rx_status->signal < rssi) |
| 2336 |
iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, |
| 2337 |
NULL); |
| 2338 |
} |
| 2339 |
|
| 2340 |
if (ieee80211_is_data(hdr->frame_control)) |
| 2341 |
iwl_mvm_rx_csum(mvm, sta, skb, pkt); |
| 2342 |
|
| 2343 |
if (iwl_mvm_is_dup(sta, queue, rx_status, hdr, desc)) { |
| 2344 |
IWL_DEBUG_DROP(mvm, "Dropping duplicate packet 0x%x\n", |
| 2345 |
le16_to_cpu(hdr->seq_ctrl)); |
| 2346 |
kfree_skb(skb); |
| 2347 |
goto out; |
| 2348 |
} |
| 2349 |
|
| 2350 |
/* |
| 2351 |
* Our hardware de-aggregates AMSDUs but copies the mac header |
| 2352 |
* as it to the de-aggregated MPDUs. We need to turn off the |
| 2353 |
* AMSDU bit in the QoS control ourselves. |
| 2354 |
* In addition, HW reverses addr3 and addr4 - reverse it back. |
| 2355 |
*/ |
| 2356 |
if ((desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) && |
| 2357 |
!WARN_ON(!ieee80211_is_data_qos(hdr->frame_control))) { |
| 2358 |
u8 *qc = ieee80211_get_qos_ctl(hdr); |
| 2359 |
|
| 2360 |
*qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT; |
| 2361 |
|
| 2362 |
if (mvm->trans->mac_cfg->device_family == |
| 2363 |
IWL_DEVICE_FAMILY_9000) { |
| 2364 |
iwl_mvm_flip_address(hdr->addr3); |
| 2365 |
|
| 2366 |
if (ieee80211_has_a4(hdr->frame_control)) |
| 2367 |
iwl_mvm_flip_address(hdr->addr4); |
| 2368 |
} |
| 2369 |
} |
| 2370 |
if (baid != IWL_RX_REORDER_DATA_INVALID_BAID) { |
| 2371 |
u32 reorder_data = le32_to_cpu(desc->reorder_data); |
| 2372 |
|
| 2373 |
iwl_mvm_agg_rx_received(mvm, reorder_data, baid); |
| 2374 |
} |
| 2375 |
} |
| 2376 |
|
| 2377 |
/* management stuff on default queue */ |
| 2378 |
if (!queue) { |
| 2379 |
if (unlikely((ieee80211_is_beacon(hdr->frame_control) || |
| 2380 |
ieee80211_is_probe_resp(hdr->frame_control)) && |
| 2381 |
mvm->sched_scan_pass_all == |
| 2382 |
SCHED_SCAN_PASS_ALL_ENABLED)) |
| 2383 |
mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_FOUND; |
| 2384 |
|
| 2385 |
if (unlikely(ieee80211_is_beacon(hdr->frame_control) || |
| 2386 |
ieee80211_is_probe_resp(hdr->frame_control))) |
| 2387 |
rx_status->boottime_ns = ktime_get_boottime_ns(); |
| 2388 |
} |
| 2389 |
|
| 2390 |
if (iwl_mvm_create_skb(mvm, skb, hdr, len, crypt_len, rxb)) { |
| 2391 |
kfree_skb(skb); |
| 2392 |
goto out; |
| 2393 |
} |
| 2394 |
|
| 2395 |
if (!iwl_mvm_reorder(mvm, napi, queue, sta, skb, desc) && |
| 2396 |
likely(!iwl_mvm_time_sync_frame(mvm, skb, hdr->addr2)) && |
| 2397 |
likely(!iwl_mvm_mei_filter_scan(mvm, skb))) { |
| 2398 |
if (mvm->trans->mac_cfg->device_family == IWL_DEVICE_FAMILY_9000 && |
| 2399 |
(desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) && |
| 2400 |
!(desc->amsdu_info & IWL_RX_MPDU_AMSDU_LAST_SUBFRAME)) |
| 2401 |
rx_status->flag |= RX_FLAG_AMSDU_MORE; |
| 2402 |
|
| 2403 |
iwl_mvm_pass_packet_to_mac80211(mvm, napi, skb, queue, sta); |
| 2404 |
} |
| 2405 |
out: |
| 2406 |
rcu_read_unlock(); |
| 2407 |
} |
| 2408 |
|
| 2409 |
void iwl_mvm_rx_monitor_no_data(struct iwl_mvm *mvm, struct napi_struct *napi, |
| 2410 |
struct iwl_rx_cmd_buffer *rxb, int queue) |
| 2411 |
{ |
| 2412 |
struct ieee80211_rx_status *rx_status; |
| 2413 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 2414 |
struct iwl_rx_no_data_ver_3 *desc = (void *)pkt->data; |
| 2415 |
u32 rssi; |
| 2416 |
struct ieee80211_sta *sta = NULL; |
| 2417 |
struct sk_buff *skb; |
| 2418 |
struct iwl_mvm_rx_phy_data phy_data; |
| 2419 |
u32 format; |
| 2420 |
|
| 2421 |
if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))) |
| 2422 |
return; |
| 2423 |
|
| 2424 |
if (unlikely(iwl_rx_packet_payload_len(pkt) < sizeof(struct iwl_rx_no_data))) |
| 2425 |
return; |
| 2426 |
|
| 2427 |
rssi = le32_to_cpu(desc->rssi); |
| 2428 |
phy_data.d0 = desc->phy_info[0]; |
| 2429 |
phy_data.d1 = desc->phy_info[1]; |
| 2430 |
phy_data.phy_info = IWL_RX_MPDU_PHY_TSF_OVERLOAD; |
| 2431 |
phy_data.gp2_on_air_rise = le32_to_cpu(desc->on_air_rise_time); |
| 2432 |
phy_data.energy_a = u32_get_bits(rssi, RX_NO_DATA_CHAIN_A_MSK); |
| 2433 |
phy_data.energy_b = u32_get_bits(rssi, RX_NO_DATA_CHAIN_B_MSK); |
| 2434 |
phy_data.channel = u32_get_bits(rssi, RX_NO_DATA_CHANNEL_MSK); |
| 2435 |
phy_data.with_data = false; |
| 2436 |
phy_data.rx_vec[0] = desc->rx_vec[0]; |
| 2437 |
phy_data.rx_vec[1] = desc->rx_vec[1]; |
| 2438 |
|
| 2439 |
phy_data.rate_n_flags = iwl_mvm_v3_rate_from_fw(desc->rate, |
| 2440 |
mvm->fw_rates_ver); |
| 2441 |
|
| 2442 |
format = phy_data.rate_n_flags & RATE_MCS_MOD_TYPE_MSK; |
| 2443 |
|
| 2444 |
if (iwl_fw_lookup_notif_ver(mvm->fw, DATA_PATH_GROUP, |
| 2445 |
RX_NO_DATA_NOTIF, 0) >= 3) { |
| 2446 |
if (unlikely(iwl_rx_packet_payload_len(pkt) < |
| 2447 |
sizeof(struct iwl_rx_no_data_ver_3))) |
| 2448 |
/* invalid len for ver 3 */ |
| 2449 |
return; |
| 2450 |
phy_data.rx_vec[2] = desc->rx_vec[2]; |
| 2451 |
phy_data.rx_vec[3] = desc->rx_vec[3]; |
| 2452 |
} else { |
| 2453 |
if (format == RATE_MCS_MOD_TYPE_EHT) |
| 2454 |
/* no support for EHT before version 3 API */ |
| 2455 |
return; |
| 2456 |
} |
| 2457 |
|
| 2458 |
/* Dont use dev_alloc_skb(), we'll have enough headroom once |
| 2459 |
* ieee80211_hdr pulled. |
| 2460 |
*/ |
| 2461 |
skb = alloc_skb(128, GFP_ATOMIC); |
| 2462 |
if (!skb) { |
| 2463 |
IWL_ERR(mvm, "alloc_skb failed\n"); |
| 2464 |
return; |
| 2465 |
} |
| 2466 |
|
| 2467 |
rx_status = IEEE80211_SKB_RXCB(skb); |
| 2468 |
|
| 2469 |
/* 0-length PSDU */ |
| 2470 |
rx_status->flag |= RX_FLAG_NO_PSDU; |
| 2471 |
|
| 2472 |
/* mark as failed PLCP on any errors to skip checks in mac80211 */ |
| 2473 |
if (le32_get_bits(desc->info, RX_NO_DATA_INFO_ERR_MSK) != |
| 2474 |
RX_NO_DATA_INFO_ERR_NONE) |
| 2475 |
rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; |
| 2476 |
|
| 2477 |
switch (le32_get_bits(desc->info, RX_NO_DATA_INFO_TYPE_MSK)) { |
| 2478 |
case RX_NO_DATA_INFO_TYPE_NDP: |
| 2479 |
rx_status->zero_length_psdu_type = |
| 2480 |
IEEE80211_RADIOTAP_ZERO_LEN_PSDU_SOUNDING; |
| 2481 |
break; |
| 2482 |
case RX_NO_DATA_INFO_TYPE_MU_UNMATCHED: |
| 2483 |
case RX_NO_DATA_INFO_TYPE_TB_UNMATCHED: |
| 2484 |
rx_status->zero_length_psdu_type = |
| 2485 |
IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED; |
| 2486 |
break; |
| 2487 |
default: |
| 2488 |
rx_status->zero_length_psdu_type = |
| 2489 |
IEEE80211_RADIOTAP_ZERO_LEN_PSDU_VENDOR; |
| 2490 |
break; |
| 2491 |
} |
| 2492 |
|
| 2493 |
rx_status->band = phy_data.channel > 14 ? NL80211_BAND_5GHZ : |
| 2494 |
NL80211_BAND_2GHZ; |
| 2495 |
|
| 2496 |
iwl_mvm_rx_fill_status(mvm, NULL, NULL, skb, &phy_data, queue); |
| 2497 |
|
| 2498 |
/* no more radio tap info should be put after this point. |
| 2499 |
* |
| 2500 |
* We mark it as mac header, for upper layers to know where |
| 2501 |
* all radio tap header ends. |
| 2502 |
* |
| 2503 |
* Since data doesn't move data while putting data on skb and that is |
| 2504 |
* the only way we use, data + len is the next place that hdr would be put |
| 2505 |
*/ |
| 2506 |
skb_set_mac_header(skb, skb->len); |
| 2507 |
|
| 2508 |
/* |
| 2509 |
* Override the nss from the rx_vec since the rate_n_flags has |
| 2510 |
* only 2 bits for the nss which gives a max of 4 ss but there |
| 2511 |
* may be up to 8 spatial streams. |
| 2512 |
*/ |
| 2513 |
switch (format) { |
| 2514 |
case RATE_MCS_MOD_TYPE_VHT: |
| 2515 |
rx_status->nss = |
| 2516 |
le32_get_bits(desc->rx_vec[0], |
| 2517 |
RX_NO_DATA_RX_VEC0_VHT_NSTS_MSK) + 1; |
| 2518 |
break; |
| 2519 |
case RATE_MCS_MOD_TYPE_HE: |
| 2520 |
rx_status->nss = |
| 2521 |
le32_get_bits(desc->rx_vec[0], |
| 2522 |
RX_NO_DATA_RX_VEC0_HE_NSTS_MSK) + 1; |
| 2523 |
break; |
| 2524 |
case RATE_MCS_MOD_TYPE_EHT: |
| 2525 |
rx_status->nss = |
| 2526 |
le32_get_bits(desc->rx_vec[2], |
| 2527 |
RX_NO_DATA_RX_VEC2_EHT_NSTS_MSK) + 1; |
| 2528 |
} |
| 2529 |
|
| 2530 |
rcu_read_lock(); |
| 2531 |
ieee80211_rx_napi(mvm->hw, sta, skb, napi); |
| 2532 |
rcu_read_unlock(); |
| 2533 |
} |
| 2534 |
|
| 2535 |
void iwl_mvm_rx_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, |
| 2536 |
struct iwl_rx_cmd_buffer *rxb, int queue) |
| 2537 |
{ |
| 2538 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 2539 |
struct iwl_frame_release *release = (void *)pkt->data; |
| 2540 |
|
| 2541 |
if (unlikely(iwl_rx_packet_payload_len(pkt) < sizeof(*release))) |
| 2542 |
return; |
| 2543 |
|
| 2544 |
iwl_mvm_release_frames_from_notif(mvm, napi, release->baid, |
| 2545 |
le16_to_cpu(release->nssn), |
| 2546 |
queue); |
| 2547 |
} |
| 2548 |
|
| 2549 |
void iwl_mvm_rx_bar_frame_release(struct iwl_mvm *mvm, struct napi_struct *napi, |
| 2550 |
struct iwl_rx_cmd_buffer *rxb, int queue) |
| 2551 |
{ |
| 2552 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 2553 |
struct iwl_bar_frame_release *release = (void *)pkt->data; |
| 2554 |
struct iwl_mvm_baid_data *baid_data; |
| 2555 |
u32 pkt_len = iwl_rx_packet_payload_len(pkt); |
| 2556 |
unsigned int baid, nssn, sta_id, tid; |
| 2557 |
|
| 2558 |
if (IWL_FW_CHECK(mvm, pkt_len < sizeof(*release), |
| 2559 |
"Unexpected frame release notif size %d (expected %zu)\n", |
| 2560 |
pkt_len, sizeof(*release))) |
| 2561 |
return; |
| 2562 |
|
| 2563 |
baid = le32_get_bits(release->ba_info, |
| 2564 |
IWL_BAR_FRAME_RELEASE_BAID_MASK); |
| 2565 |
nssn = le32_get_bits(release->ba_info, |
| 2566 |
IWL_BAR_FRAME_RELEASE_NSSN_MASK); |
| 2567 |
sta_id = le32_get_bits(release->sta_tid, |
| 2568 |
IWL_BAR_FRAME_RELEASE_STA_MASK); |
| 2569 |
tid = le32_get_bits(release->sta_tid, |
| 2570 |
IWL_BAR_FRAME_RELEASE_TID_MASK); |
| 2571 |
|
| 2572 |
if (WARN_ON_ONCE(baid == IWL_RX_REORDER_DATA_INVALID_BAID || |
| 2573 |
baid >= ARRAY_SIZE(mvm->baid_map))) |
| 2574 |
return; |
| 2575 |
|
| 2576 |
rcu_read_lock(); |
| 2577 |
baid_data = rcu_dereference(mvm->baid_map[baid]); |
| 2578 |
if (!baid_data) { |
| 2579 |
IWL_DEBUG_RX(mvm, |
| 2580 |
"Got valid BAID %d but not allocated, invalid BAR release!\n", |
| 2581 |
baid); |
| 2582 |
goto out; |
| 2583 |
} |
| 2584 |
|
| 2585 |
if (WARN(tid != baid_data->tid || sta_id > IWL_STATION_COUNT_MAX || |
| 2586 |
!(baid_data->sta_mask & BIT(sta_id)), |
| 2587 |
"baid 0x%x is mapped to sta_mask:0x%x tid:%d, but BAR release received for sta:%d tid:%d\n", |
| 2588 |
baid, baid_data->sta_mask, baid_data->tid, sta_id, |
| 2589 |
tid)) |
| 2590 |
goto out; |
| 2591 |
|
| 2592 |
IWL_DEBUG_DROP(mvm, "Received a BAR, expect packet loss: nssn %d\n", |
| 2593 |
nssn); |
| 2594 |
|
| 2595 |
iwl_mvm_release_frames_from_notif(mvm, napi, baid, nssn, queue); |
| 2596 |
out: |
| 2597 |
rcu_read_unlock(); |
| 2598 |
} |
| 2599 |
|
| 2600 |
void iwl_mvm_rx_beacon_filter_notif(struct iwl_mvm *mvm, |
| 2601 |
struct iwl_rx_cmd_buffer *rxb) |
| 2602 |
{ |
| 2603 |
struct iwl_rx_packet *pkt = rxb_addr(rxb); |
| 2604 |
/* MAC or link ID in v1/v2, but driver has the IDs equal */ |
| 2605 |
struct iwl_beacon_filter_notif *notif = (void *)pkt->data; |
| 2606 |
u32 id = le32_to_cpu(notif->link_id); |
| 2607 |
struct iwl_mvm_vif *mvm_vif; |
| 2608 |
struct ieee80211_vif *vif; |
| 2609 |
|
| 2610 |
/* >= means AUX MAC/link ID, no energy correction needed then */ |
| 2611 |
if (IWL_FW_CHECK(mvm, id >= ARRAY_SIZE(mvm->vif_id_to_mac), |
| 2612 |
"invalid link ID %d\n", id)) |
| 2613 |
return; |
| 2614 |
|
| 2615 |
vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, false); |
| 2616 |
if (!vif) |
| 2617 |
return; |
| 2618 |
|
| 2619 |
mvm_vif = iwl_mvm_vif_from_mac80211(vif); |
| 2620 |
|
| 2621 |
mvm_vif->deflink.average_beacon_energy = |
| 2622 |
le32_to_cpu(notif->average_energy); |
| 2623 |
} |