Return-Path: Received: from mail-co1nam03on0109.outbound.protection.outlook.com ([104.47.40.109]:6764 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932872AbeCCWb6 (ORCPT ); Sat, 3 Mar 2018 17:31:58 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Iyappan Subramanian , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 033/219] drivers: net: xgene: Fix Rx checksum validation logic Date: Sat, 3 Mar 2018 22:28:14 +0000 Message-ID: <20180303222716.26640-33-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: 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 --- drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 27 +++++++++++++++-----= ---- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net= /ethernet/apm/xgene/xgene_enet_main.c index de1546a63a7f..651f308cdc60 100644 --- 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(struct sk_bu= ff *skb, return NETDEV_TX_OK; } =20 -static void xgene_enet_skip_csum(struct sk_buff *skb) +static void xgene_enet_rx_csum(struct sk_buff *skb) { + struct net_device *ndev =3D skb->dev; struct iphdr *iph =3D ip_hdr(skb); =20 - if (!ip_is_fragment(iph) || - (iph->protocol !=3D IPPROTO_TCP && iph->protocol !=3D IPPROTO_UDP)) { - skb->ip_summed =3D CHECKSUM_UNNECESSARY; - } + if (!(ndev->features & NETIF_F_RXCSUM)) + return; + + if (skb->protocol !=3D htons(ETH_P_IP)) + return; + + if (ip_is_fragment(iph)) + return; + + if (iph->protocol !=3D IPPROTO_TCP && iph->protocol !=3D IPPROTO_UDP) + return; + + skb->ip_summed =3D CHECKSUM_UNNECESSARY; } =20 static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring, @@ -555,10 +565,7 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_= ring *rx_ring, =20 skb_checksum_none_assert(skb); skb->protocol =3D eth_type_trans(skb, ndev); - if (likely((ndev->features & NETIF_F_IP_CSUM) && - skb->protocol =3D=3D htons(ETH_P_IP))) { - xgene_enet_skip_csum(skb); - } + xgene_enet_rx_csum(skb); =20 rx_ring->rx_packets++; rx_ring->rx_bytes +=3D datalen; @@ -1725,7 +1732,7 @@ static int xgene_enet_probe(struct platform_device *p= dev) xgene_enet_setup_ops(pdata); =20 if (pdata->phy_mode =3D=3D PHY_INTERFACE_MODE_XGMII) { - ndev->features |=3D NETIF_F_TSO; + ndev->features |=3D NETIF_F_TSO | NETIF_F_RXCSUM; spin_lock_init(&pdata->mss_lock); } ndev->hw_features =3D ndev->features; --=20 2.14.1