Commit c23fa1bb authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

mt76: only set rx radiotap flag from within decoder functions

Only set RX_FLAG_RADIOTAP_HE and RX_FLAG_RADIOTAP_HE_MU from with their
own decoder functions to prevent header calculation error.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent dc5399a5
...@@ -268,10 +268,9 @@ mt7915_mac_decode_he_radiotap_ru(struct mt76_rx_status *status, ...@@ -268,10 +268,9 @@ mt7915_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
} }
static void static void
mt7915_mac_decode_he_mu_radiotap(struct sk_buff *skb, mt7915_mac_decode_he_mu_radiotap(struct sk_buff *skb, __le32 *rxv)
struct mt76_rx_status *status,
__le32 *rxv)
{ {
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
static const struct ieee80211_radiotap_he_mu mu_known = { static const struct ieee80211_radiotap_he_mu mu_known = {
.flags1 = HE_BITS(MU_FLAGS1_SIG_B_MCS_KNOWN) | .flags1 = HE_BITS(MU_FLAGS1_SIG_B_MCS_KNOWN) |
HE_BITS(MU_FLAGS1_SIG_B_DCM_KNOWN) | HE_BITS(MU_FLAGS1_SIG_B_DCM_KNOWN) |
...@@ -281,6 +280,8 @@ mt7915_mac_decode_he_mu_radiotap(struct sk_buff *skb, ...@@ -281,6 +280,8 @@ mt7915_mac_decode_he_mu_radiotap(struct sk_buff *skb,
}; };
struct ieee80211_radiotap_he_mu *he_mu = NULL; struct ieee80211_radiotap_he_mu *he_mu = NULL;
status->flag |= RX_FLAG_RADIOTAP_HE_MU;
he_mu = skb_push(skb, sizeof(mu_known)); he_mu = skb_push(skb, sizeof(mu_known));
memcpy(he_mu, &mu_known, sizeof(mu_known)); memcpy(he_mu, &mu_known, sizeof(mu_known));
...@@ -308,10 +309,9 @@ mt7915_mac_decode_he_mu_radiotap(struct sk_buff *skb, ...@@ -308,10 +309,9 @@ mt7915_mac_decode_he_mu_radiotap(struct sk_buff *skb,
} }
static void static void
mt7915_mac_decode_he_radiotap(struct sk_buff *skb, mt7915_mac_decode_he_radiotap(struct sk_buff *skb, __le32 *rxv, u32 mode)
struct mt76_rx_status *status,
__le32 *rxv, u32 phy)
{ {
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
static const struct ieee80211_radiotap_he known = { static const struct ieee80211_radiotap_he known = {
.data1 = HE_BITS(DATA1_DATA_MCS_KNOWN) | .data1 = HE_BITS(DATA1_DATA_MCS_KNOWN) |
HE_BITS(DATA1_DATA_DCM_KNOWN) | HE_BITS(DATA1_DATA_DCM_KNOWN) |
...@@ -329,6 +329,8 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, ...@@ -329,6 +329,8 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb,
struct ieee80211_radiotap_he *he = NULL; struct ieee80211_radiotap_he *he = NULL;
u32 ltf_size = le32_get_bits(rxv[2], MT_CRXV_HE_LTF_SIZE) + 1; u32 ltf_size = le32_get_bits(rxv[2], MT_CRXV_HE_LTF_SIZE) + 1;
status->flag |= RX_FLAG_RADIOTAP_HE;
he = skb_push(skb, sizeof(known)); he = skb_push(skb, sizeof(known));
memcpy(he, &known, sizeof(known)); memcpy(he, &known, sizeof(known));
...@@ -343,7 +345,7 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, ...@@ -343,7 +345,7 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb,
he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) | he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) |
HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]); HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]);
switch (phy) { switch (mode) {
case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_SU:
he->data1 |= HE_BITS(DATA1_FORMAT_SU) | he->data1 |= HE_BITS(DATA1_FORMAT_SU) |
HE_BITS(DATA1_UL_DL_KNOWN) | HE_BITS(DATA1_UL_DL_KNOWN) |
...@@ -366,6 +368,7 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, ...@@ -366,6 +368,7 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb,
he->data4 |= HE_PREP(DATA4_MU_STA_ID, MU_AID, rxv[7]); he->data4 |= HE_PREP(DATA4_MU_STA_ID, MU_AID, rxv[7]);
mt7915_mac_decode_he_radiotap_ru(status, he, rxv); mt7915_mac_decode_he_radiotap_ru(status, he, rxv);
mt7915_mac_decode_he_mu_radiotap(skb, rxv);
break; break;
case MT_PHY_TYPE_HE_TB: case MT_PHY_TYPE_HE_TB:
he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) | he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) |
...@@ -456,7 +459,6 @@ static int mt7915_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap) ...@@ -456,7 +459,6 @@ static int mt7915_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
else else
memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6);
status->flag &= ~(RX_FLAG_RADIOTAP_HE | RX_FLAG_RADIOTAP_HE_MU);
return 0; return 0;
} }
...@@ -467,7 +469,6 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -467,7 +469,6 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
struct mt76_phy *mphy = &dev->mt76.phy; struct mt76_phy *mphy = &dev->mt76.phy;
struct mt7915_phy *phy = &dev->phy; struct mt7915_phy *phy = &dev->phy;
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct ieee80211_hdr *hdr;
__le32 *rxd = (__le32 *)skb->data; __le32 *rxd = (__le32 *)skb->data;
__le32 *rxv = NULL; __le32 *rxv = NULL;
u32 mode = 0; u32 mode = 0;
...@@ -681,15 +682,12 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -681,15 +682,12 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
return -EINVAL; return -EINVAL;
break; break;
case MT_PHY_TYPE_HE_MU: case MT_PHY_TYPE_HE_MU:
status->flag |= RX_FLAG_RADIOTAP_HE_MU;
fallthrough;
case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_SU:
case MT_PHY_TYPE_HE_EXT_SU: case MT_PHY_TYPE_HE_EXT_SU:
case MT_PHY_TYPE_HE_TB: case MT_PHY_TYPE_HE_TB:
status->nss = status->nss =
FIELD_GET(MT_PRXV_NSTS, v0) + 1; FIELD_GET(MT_PRXV_NSTS, v0) + 1;
status->encoding = RX_ENC_HE; status->encoding = RX_ENC_HE;
status->flag |= RX_FLAG_RADIOTAP_HE;
i &= GENMASK(3, 0); i &= GENMASK(3, 0);
if (gi <= NL80211_RATE_INFO_HE_GI_3_2) if (gi <= NL80211_RATE_INFO_HE_GI_3_2)
...@@ -752,30 +750,26 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -752,30 +750,26 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
} }
} }
if (insert_ccmp_hdr && !hdr_trans) { if (!hdr_trans) {
u8 key_id = FIELD_GET(MT_RXD1_NORMAL_KEY_ID, rxd1); struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
mt76_insert_ccmp_hdr(skb, key_id); if (insert_ccmp_hdr) {
} u8 key_id = FIELD_GET(MT_RXD1_NORMAL_KEY_ID, rxd1);
mt76_insert_ccmp_hdr(skb, key_id);
}
if (!hdr_trans) {
hdr = mt76_skb_get_hdr(skb);
fc = hdr->frame_control; fc = hdr->frame_control;
if (ieee80211_is_data_qos(fc)) { if (ieee80211_is_data_qos(fc)) {
seq_ctrl = le16_to_cpu(hdr->seq_ctrl); seq_ctrl = le16_to_cpu(hdr->seq_ctrl);
qos_ctl = *ieee80211_get_qos_ctl(hdr); qos_ctl = *ieee80211_get_qos_ctl(hdr);
} }
} else { } else {
status->flag &= ~(RX_FLAG_RADIOTAP_HE |
RX_FLAG_RADIOTAP_HE_MU);
status->flag |= RX_FLAG_8023; status->flag |= RX_FLAG_8023;
} }
if (rxv && status->flag & RX_FLAG_RADIOTAP_HE) { if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023))
mt7915_mac_decode_he_radiotap(skb, status, rxv, mode); mt7915_mac_decode_he_radiotap(skb, rxv, mode);
if (status->flag & RX_FLAG_RADIOTAP_HE_MU)
mt7915_mac_decode_he_mu_radiotap(skb, status, rxv);
}
if (!status->wcid || !ieee80211_is_data_qos(fc)) if (!status->wcid || !ieee80211_is_data_qos(fc))
return 0; return 0;
......
...@@ -218,10 +218,9 @@ mt7921_mac_decode_he_radiotap_ru(struct mt76_rx_status *status, ...@@ -218,10 +218,9 @@ mt7921_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
} }
static void static void
mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb, mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb, __le32 *rxv)
struct mt76_rx_status *status,
__le32 *rxv)
{ {
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
static const struct ieee80211_radiotap_he_mu mu_known = { static const struct ieee80211_radiotap_he_mu mu_known = {
.flags1 = HE_BITS(MU_FLAGS1_SIG_B_MCS_KNOWN) | .flags1 = HE_BITS(MU_FLAGS1_SIG_B_MCS_KNOWN) |
HE_BITS(MU_FLAGS1_SIG_B_DCM_KNOWN) | HE_BITS(MU_FLAGS1_SIG_B_DCM_KNOWN) |
...@@ -233,6 +232,8 @@ mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb, ...@@ -233,6 +232,8 @@ mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb,
}; };
struct ieee80211_radiotap_he_mu *he_mu; struct ieee80211_radiotap_he_mu *he_mu;
status->flag |= RX_FLAG_RADIOTAP_HE_MU;
he_mu = skb_push(skb, sizeof(mu_known)); he_mu = skb_push(skb, sizeof(mu_known));
memcpy(he_mu, &mu_known, sizeof(mu_known)); memcpy(he_mu, &mu_known, sizeof(mu_known));
...@@ -263,10 +264,9 @@ mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb, ...@@ -263,10 +264,9 @@ mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb,
} }
static void static void
mt7921_mac_decode_he_radiotap(struct sk_buff *skb, mt7921_mac_decode_he_radiotap(struct sk_buff *skb, __le32 *rxv, u32 mode)
struct mt76_rx_status *status,
__le32 *rxv, u32 phy)
{ {
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
static const struct ieee80211_radiotap_he known = { static const struct ieee80211_radiotap_he known = {
.data1 = HE_BITS(DATA1_DATA_MCS_KNOWN) | .data1 = HE_BITS(DATA1_DATA_MCS_KNOWN) |
HE_BITS(DATA1_DATA_DCM_KNOWN) | HE_BITS(DATA1_DATA_DCM_KNOWN) |
...@@ -284,6 +284,8 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb, ...@@ -284,6 +284,8 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
struct ieee80211_radiotap_he *he = NULL; struct ieee80211_radiotap_he *he = NULL;
u32 ltf_size = le32_get_bits(rxv[2], MT_CRXV_HE_LTF_SIZE) + 1; u32 ltf_size = le32_get_bits(rxv[2], MT_CRXV_HE_LTF_SIZE) + 1;
status->flag |= RX_FLAG_RADIOTAP_HE;
he = skb_push(skb, sizeof(known)); he = skb_push(skb, sizeof(known));
memcpy(he, &known, sizeof(known)); memcpy(he, &known, sizeof(known));
...@@ -298,7 +300,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb, ...@@ -298,7 +300,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) | he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) |
HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]); HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]);
switch (phy) { switch (mode) {
case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_SU:
he->data1 |= HE_BITS(DATA1_FORMAT_SU) | he->data1 |= HE_BITS(DATA1_FORMAT_SU) |
HE_BITS(DATA1_UL_DL_KNOWN) | HE_BITS(DATA1_UL_DL_KNOWN) |
...@@ -322,6 +324,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb, ...@@ -322,6 +324,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
he->data4 |= HE_PREP(DATA4_MU_STA_ID, MU_AID, rxv[7]); he->data4 |= HE_PREP(DATA4_MU_STA_ID, MU_AID, rxv[7]);
mt7921_mac_decode_he_radiotap_ru(status, he, rxv); mt7921_mac_decode_he_radiotap_ru(status, he, rxv);
mt7921_mac_decode_he_mu_radiotap(skb, rxv);
break; break;
case MT_PHY_TYPE_HE_TB: case MT_PHY_TYPE_HE_TB:
he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) | he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) |
...@@ -467,7 +470,6 @@ static int mt7921_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap) ...@@ -467,7 +470,6 @@ static int mt7921_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
else else
memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6); memcpy(skb_push(skb, sizeof(hdr) - 6), &hdr, sizeof(hdr) - 6);
status->flag &= ~(RX_FLAG_RADIOTAP_HE | RX_FLAG_RADIOTAP_HE_MU);
return 0; return 0;
} }
...@@ -483,7 +485,6 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) ...@@ -483,7 +485,6 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
struct mt76_phy *mphy = &dev->mt76.phy; struct mt76_phy *mphy = &dev->mt76.phy;
struct mt7921_phy *phy = &dev->phy; struct mt7921_phy *phy = &dev->phy;
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
struct ieee80211_hdr *hdr;
u32 rxd0 = le32_to_cpu(rxd[0]); u32 rxd0 = le32_to_cpu(rxd[0]);
u32 rxd1 = le32_to_cpu(rxd[1]); u32 rxd1 = le32_to_cpu(rxd[1]);
u32 rxd2 = le32_to_cpu(rxd[2]); u32 rxd2 = le32_to_cpu(rxd[2]);
...@@ -689,15 +690,12 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) ...@@ -689,15 +690,12 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
return -EINVAL; return -EINVAL;
break; break;
case MT_PHY_TYPE_HE_MU: case MT_PHY_TYPE_HE_MU:
status->flag |= RX_FLAG_RADIOTAP_HE_MU;
fallthrough;
case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_SU:
case MT_PHY_TYPE_HE_EXT_SU: case MT_PHY_TYPE_HE_EXT_SU:
case MT_PHY_TYPE_HE_TB: case MT_PHY_TYPE_HE_TB:
status->nss = status->nss =
FIELD_GET(MT_PRXV_NSTS, v0) + 1; FIELD_GET(MT_PRXV_NSTS, v0) + 1;
status->encoding = RX_ENC_HE; status->encoding = RX_ENC_HE;
status->flag |= RX_FLAG_RADIOTAP_HE;
i &= GENMASK(3, 0); i &= GENMASK(3, 0);
if (gi <= NL80211_RATE_INFO_HE_GI_3_2) if (gi <= NL80211_RATE_INFO_HE_GI_3_2)
...@@ -767,6 +765,8 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) ...@@ -767,6 +765,8 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
} }
if (!hdr_trans) { if (!hdr_trans) {
struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
if (insert_ccmp_hdr) { if (insert_ccmp_hdr) {
u8 key_id = FIELD_GET(MT_RXD1_NORMAL_KEY_ID, rxd1); u8 key_id = FIELD_GET(MT_RXD1_NORMAL_KEY_ID, rxd1);
...@@ -780,19 +780,13 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) ...@@ -780,19 +780,13 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
qos_ctl = *ieee80211_get_qos_ctl(hdr); qos_ctl = *ieee80211_get_qos_ctl(hdr);
} }
} else { } else {
status->flag &= ~(RX_FLAG_RADIOTAP_HE |
RX_FLAG_RADIOTAP_HE_MU);
status->flag |= RX_FLAG_8023; status->flag |= RX_FLAG_8023;
} }
mt7921_mac_assoc_rssi(dev, skb); mt7921_mac_assoc_rssi(dev, skb);
if (rxv && status->flag & RX_FLAG_RADIOTAP_HE) { if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023))
mt7921_mac_decode_he_radiotap(skb, status, rxv, mode); mt7921_mac_decode_he_radiotap(skb, rxv, mode);
if (status->flag & RX_FLAG_RADIOTAP_HE_MU)
mt7921_mac_decode_he_mu_radiotap(skb, status, rxv);
}
if (!status->wcid || !ieee80211_is_data_qos(fc)) if (!status->wcid || !ieee80211_is_data_qos(fc))
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment