Received: by 10.213.65.68 with SMTP id h4csp38712imn; Mon, 19 Mar 2018 18:48:40 -0700 (PDT) X-Google-Smtp-Source: AG47ELvhFK+UMMsedVH3qBmys98srvtWbPp+F+4squdRMCa+fIyTohNJLCl36S7dzubpu+98I4HD X-Received: by 2002:a17:902:a516:: with SMTP id s22-v6mr14290449plq.191.1521510520477; Mon, 19 Mar 2018 18:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510520; cv=none; d=google.com; s=arc-20160816; b=KABOQ5EwdJtmo8GFdgPsIMtA/4tKWXeY1OWDaDYl5fyVMHCY0YiS5d2vEdqfqDyWVA 2koynWceWdqVv5pYBd5AXO3LnqUll/fBe1GroEWAvqN+KgtG4s2POMuVlmgwJtviTYxT +B5mOREIl1PDIbkTcsStgsFs1ndoixLQ0knJGc1OZ6N6TYpwbPF/NZSg6PZNcRuXJBBN mJdPfDD8wN2EjZwTzUC2SEcgAW5fyi2GpqPHmTSHUBddJoxfU0+7LyXM5XGgAjqTGuEG Qcl3cbMFMKOE9XQkCQYRaEn8qc/yRfUkDZT+iW0Ot+US2fwoem/yJL+hZQp1GluZVOP0 zkjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=lOPZdfGUW0GadWgOFHk+PmqF2hKdr0WFfWkHAKY6lFk=; b=EpRtcX8D7Qh4oxK0/AZPvVfxgxjUpaH4hyZFpYQ58h4coZVH4rx/3VUhlPYaDfweSw hcP/USF/2MpsJVFPDIWpwF5y0q8oHgOyzemXwKGGcQ+6Gy1fwYe6Z49sJtMTHpQcvtnN RsnvtmpW72p2SF4m5v6gnQXaJaNyi5jZaXGQOfI2l7YlBcSRq3Y5gwh3lz6m/17USOAa 5dTbhIOk5Oi/zaELp1oLXZEoZnESbvq8yaU3iyN8On3zlw4ojl/36o8TyFY+FAovx9TY ZhmVh5QXfZQ1YKfcRRgEfLCSDG6X9ot34NsaXJrZI9lONHewat4cuw6+b66N29QICuLH NJmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be3-v6si514073plb.581.2018.03.19.18.48.26; Mon, 19 Mar 2018 18:48:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969647AbeCSTop (ORCPT + 99 others); Mon, 19 Mar 2018 15:44:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47848 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969553AbeCSSUv (ORCPT ); Mon, 19 Mar 2018 14:20:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DC8D811BC; Mon, 19 Mar 2018 18:20:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Iyappan Subramanian , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 031/241] drivers: net: xgene: Fix Rx checksum validation logic Date: Mon, 19 Mar 2018 19:04:56 +0100 Message-Id: <20180319180752.460359004@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Iyappan Subramanian [ Upstream commit 0a0400c3094b5d5cedd479ddbf1329de74c09c4b ] This patch fixes Rx checksum validation logic and adds NETIF_F_RXCSUM flag. Signed-off-by: Iyappan Subramanian Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 27 ++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -505,14 +505,24 @@ static netdev_tx_t xgene_enet_start_xmit return NETDEV_TX_OK; } -static void xgene_enet_skip_csum(struct sk_buff *skb) +static void xgene_enet_rx_csum(struct sk_buff *skb) { + struct net_device *ndev = skb->dev; struct iphdr *iph = ip_hdr(skb); - if (!ip_is_fragment(iph) || - (iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP)) { - skb->ip_summed = CHECKSUM_UNNECESSARY; - } + if (!(ndev->features & NETIF_F_RXCSUM)) + return; + + if (skb->protocol != htons(ETH_P_IP)) + return; + + if (ip_is_fragment(iph)) + return; + + if (iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP) + return; + + skb->ip_summed = CHECKSUM_UNNECESSARY; } static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring, @@ -555,10 +565,7 @@ static int xgene_enet_rx_frame(struct xg skb_checksum_none_assert(skb); skb->protocol = eth_type_trans(skb, ndev); - if (likely((ndev->features & NETIF_F_IP_CSUM) && - skb->protocol == htons(ETH_P_IP))) { - xgene_enet_skip_csum(skb); - } + xgene_enet_rx_csum(skb); rx_ring->rx_packets++; rx_ring->rx_bytes += datalen; @@ -1725,7 +1732,7 @@ static int xgene_enet_probe(struct platf xgene_enet_setup_ops(pdata); if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) { - ndev->features |= NETIF_F_TSO; + ndev->features |= NETIF_F_TSO | NETIF_F_RXCSUM; spin_lock_init(&pdata->mss_lock); } ndev->hw_features = ndev->features;