OSDN Git Service

mt76: mt7915: add rx checksum offload support
authorFelix Fietkau <nbd@nbd.name>
Wed, 16 Dec 2020 18:04:24 +0000 (19:04 +0100)
committerFelix Fietkau <nbd@nbd.name>
Sun, 11 Apr 2021 16:50:37 +0000 (18:50 +0200)
Set skb->ip_summed to CHECKSUM_UNNECESSARY if the hardware has validated
the IP and TCP/UDP checksum

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/init.c
drivers/net/wireless/mediatek/mt76/mt7915/mac.c

index 76dfcb7..34a4fee 100644 (file)
@@ -93,6 +93,7 @@ mt7915_init_wiphy(struct ieee80211_hw *hw)
        hw->queues = 4;
        hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
        hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF;
+       hw->netdev_features = NETIF_F_RXCSUM;
 
        phy->slottime = 9;
 
index 48408ec..83dd504 100644 (file)
@@ -317,10 +317,12 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
        __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]);
+       u32 csum_mask = MT_RXD0_NORMAL_IP_SUM | MT_RXD0_NORMAL_UDP_TCP_SUM;
        bool unicast, insert_ccmp_hdr = false;
        u8 remove_pad, amsdu_info;
        int i, idx;
@@ -366,6 +368,9 @@ int mt7915_mac_fill_rx(struct mt7915_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;