OSDN Git Service

mt76: mt7921: enable rx csum offload
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 6 May 2021 18:13:35 +0000 (20:13 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 19 Jun 2021 07:22:43 +0000 (09:22 +0200)
As already done for mt7615 and mt7915, enable hw rx checksum offload.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/init.c
drivers/net/wireless/mediatek/mt76/mt7921/mac.c

index d5ad92a..b899b82 100644 (file)
@@ -50,6 +50,7 @@ mt7921_init_wiphy(struct ieee80211_hw *hw)
        hw->queues = 4;
        hw->max_rx_aggregation_subframes = 64;
        hw->max_tx_aggregation_subframes = 128;
+       hw->netdev_features = NETIF_F_RXCSUM;
 
        hw->radiotap_timestamp.units_pos =
                IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US;
index 74974f6..44b8918 100644 (file)
@@ -308,22 +308,23 @@ mt7921_mac_assoc_rssi(struct mt7921_dev *dev, struct sk_buff *skb)
 
 int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
 {
+       u32 csum_mask = MT_RXD0_NORMAL_IP_SUM | MT_RXD0_NORMAL_UDP_TCP_SUM;
        struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
        bool hdr_trans, unicast, insert_ccmp_hdr = false;
        u8 chfreq, qos_ctl = 0, remove_pad, amsdu_info;
+       __le32 *rxv = NULL, *rxd = (__le32 *)skb->data;
        struct mt76_phy *mphy = &dev->mt76.phy;
        struct mt7921_phy *phy = &dev->phy;
        struct ieee80211_supported_band *sband;
        struct ieee80211_hdr *hdr;
-       __le32 *rxd = (__le32 *)skb->data;
-       __le32 *rxv = NULL;
-       u32 mode = 0;
+       u32 rxd0 = le32_to_cpu(rxd[0]);
        u32 rxd1 = le32_to_cpu(rxd[1]);
        u32 rxd2 = le32_to_cpu(rxd[2]);
        u32 rxd3 = le32_to_cpu(rxd[3]);
        u32 rxd4 = le32_to_cpu(rxd[4]);
        u16 seq_ctrl = 0;
        __le16 fc = 0;
+       u32 mode = 0;
        int i, idx;
 
        memset(status, 0, sizeof(*status));
@@ -363,6 +364,9 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
        if (!sband->channels)
                return -EINVAL;
 
+       if ((rxd0 & csum_mask) == csum_mask)
+               skb->ip_summed = CHECKSUM_UNNECESSARY;
+
        if (rxd1 & MT_RXD1_NORMAL_FCS_ERR)
                status->flag |= RX_FLAG_FAILED_FCS_CRC;