wifi: mt76: fix receiving LLC packets on mt7615/mt7915
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/2 wifi: mt76: fix receiving LLC packets on mt7615/mt7915
When 802.3 decap offload is enabled, the hardware indicates header translation failure, whenever either the LLC-SNAP header was not found, or a VLAN header with an unregcognized tag is present.
In that case, the hardware inserts a 2-byte length fields after the MAC addresses. For VLAN packets, this tag needs to be removed. However, for 802.3 LLC packets, the length bytes should be preserved, since there is no separate ethertype field in the data.
This fixes an issue where the length field was omitted for LLC frames, causing them to be malformed after hardware decap.
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 8 ++++---- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +4 -4
@@ -610,14 +610,14 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)* When header translation failure is indicated, * the hardware will insert an extra 2-byte field * containing the data length after the protocol -* type field. +* type field. This happens either when the LLC-SNAP +* pattern did not match, or if a VLAN header was +* detected. */ pad_start =12 ;if (get_unaligned_be16 (skb->data + pad_start) ==ETH_P_8021Q ) pad_start +=4 ; - -if (get_unaligned_be16 (skb->data + pad_start) != - skb->len - pad_start -2 ) +else pad_start =0 ; }
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +4 -4
@@ -446,14 +446,14 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)* When header translation failure is indicated, * the hardware will insert an extra 2-byte field * containing the data length after the protocol -* type field. +* type field. This happens either when the LLC-SNAP +* pattern did not match, or if a VLAN header was +* detected. */ pad_start =12 ;if (get_unaligned_be16 (skb->data + pad_start) ==ETH_P_8021Q ) pad_start +=4 ; - -if (get_unaligned_be16 (skb->data + pad_start) != - skb->len - pad_start -2 ) +else pad_start =0 ; }
Signature · 1 line
2.36.1
Felix Fietkau
maintainerPATCH 2/2 wifi: mt76: fix rx checksum offload on mt7615/mt7915/mt7921
Checking the relevant rxd bits for the checksum information only indicates if the checksum verification was performed by the hardware and doesn't show actual checksum errors. Checksum errors are indicated in the info field of the DMA descriptor. Fix packets erroneously marked as CHECKSUM_UNNECESSARY by checking the extra bits as well.
Those bits are only passed to the driver for MMIO devices at the moment, so limit checksum offload to those.
--- drivers/net/wireless/mediatek/mt76/dma.c | 5 +---- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 4 +++- 4 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +1 -4
@@ -717,10 +717,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget)skb_reserve (skb, q->buf_offset); -if (q == &dev->q_rx[MT_RXQ_MCU ]) { -u32 *rxfce = (u32 *)skb->cb; - *rxfce = info; - } + *(u32 *)skb->cb = info;__skb_put (skb, len); done++;
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -1
@@ -345,6 +345,7 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)u32 rxd1 =le32_to_cpu (rxd[1 ]);u32 rxd2 =le32_to_cpu (rxd[2 ]);u32 csum_mask =MT_RXD0_NORMAL_IP_SUM |MT_RXD0_NORMAL_UDP_TCP_SUM ; +u32 csum_status = *(u32 *)skb->cb;bool unicast, hdr_trans, remove_pad, insert_ccmp_hdr = false;u16 hdr_gap;int phy_idx;
@@ -394,7 +395,8 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)spin_unlock_bh (&dev->sta_poll_lock); } -if ((rxd0 & csum_mask) == csum_mask) +if (mt76_is_mmio (&dev->mt76) && (rxd0 & csum_mask) == csum_mask && + !(csum_status & (BIT (0 ) |BIT (2 ) |BIT (3 )))) skb->ip_summed =CHECKSUM_UNNECESSARY ;if (rxd2 &MT_RXD2_NORMAL_FCS_ERR )
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +3 -1
@@ -233,6 +233,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)u8 remove_pad, amsdu_info;u8 mode =0 , qos_ctl =0 ;struct mt7915_sta *msta =NULL ; +u32 csum_status = *(u32 *)skb->cb;bool hdr_trans;u16 hdr_gap;u16 seq_ctrl =0 ;
@@ -288,7 +289,8 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)if (!sband->channels)return -EINVAL ; -if ((rxd0 & csum_mask) == csum_mask) +if ((rxd0 & csum_mask) == csum_mask && + !(csum_status & (BIT (0 ) |BIT (2 ) |BIT (3 )))) skb->ip_summed =CHECKSUM_UNNECESSARY ;if (rxd1 &MT_RXD1_NORMAL_FCS_ERR )
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +3 -1
@@ -230,6 +230,7 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)struct mt76_phy *mphy = &dev->mt76.phy;struct mt7921_phy *phy = &dev->phy;struct ieee80211_supported_band *sband; +u32 csum_status = *(u32 *)skb->cb;u32 rxd0 =le32_to_cpu (rxd[0 ]);u32 rxd1 =le32_to_cpu (rxd[1 ]);u32 rxd2 =le32_to_cpu (rxd[2 ]);
@@ -290,7 +291,8 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)if (!sband->channels)return -EINVAL ; -if ((rxd0 & csum_mask) == csum_mask) +if (mt76_is_mmio (&dev->mt76) && (rxd0 & csum_mask) == csum_mask && + !(csum_status & (BIT (0 ) |BIT (2 ) |BIT (3 )))) skb->ip_summed =CHECKSUM_UNNECESSARY ;if (rxd1 &MT_RXD1_NORMAL_FCS_ERR )
Signature · 1 line
2.36.1
Quoted 10 lines · Felix Fietkau
When 802.3 decap offload is enabled, the hardware indicates header translation failure, whenever either the LLC-SNAP header was not found, or a VLAN header with an unregcognized tag is present.
In that case, the hardware inserts a 2-byte length fields after the MAC addresses. For VLAN packets, this tag needs to be removed. However, for 802.3 LLC packets, the length bytes should be preserved, since there is no separate ethertype field in the data.
This fixes an issue where the length field was omitted for LLC frames, causing them to be malformed after hardware decap.
Quoted 3 lines
Fixes 1eeff0b4c1a6 ("mt76: mt7915: fix decap offload corner case with 4-addr VLAN frames")Reported-by Chad Monroe <[email protected]>Signed-off-by Felix Fietkau <[email protected]>
2 patches applied to wireless.git, thanks.
47c44088ac08 wifi: mt76: fix receiving LLC packets on mt7615/mt7915 443dc85ad13e wifi: mt76: fix rx checksum offload on mt7615/mt7915/mt7921
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches