From patchwork Wed Mar 15 20:27:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 9626611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10C8D60244 for ; Wed, 15 Mar 2017 20:27:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00E5026E81 for ; Wed, 15 Mar 2017 20:27:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9E5928610; Wed, 15 Mar 2017 20:27:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E00D26E81 for ; Wed, 15 Mar 2017 20:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xnin+Qt+jhlAEyyLT7/rjseE1QDjjs3EHGGttc30dnc=; b=MTe1x+AhKlUYelz6HyZdSK5rM8 wDG67vEfrw4NjO3LFMK2OPn0FtA/yn3nQlQ85NL0fyLPXGSXdzCGRGZSBanA3JWlCXd7PwoaWm79k 7YnriJwzYl8kNcQI+JNrlmGqEfwBgHj+UrIJHrRaUIWGtNzwgTREzDYEVHvYOuWZL2KtdgsPOvHkU rWWgukl7z1j/f2v3lh+MEIctMsSB5SsdS3WLmgmWrEkld7J/R++YhDnhyl6gpcXeaRIZuLbUODfli /g1maRvUevzDZY5dvfoRAhFfntB9WQ5BiA1nVAPw23PmZ/9pe2wQwDs+ruNVYdVNndX5a0WX1DOOh mPdgnB8w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1coFVu-0001qL-30; Wed, 15 Mar 2017 20:27:18 +0000 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1coFV7-0000mt-J0 for linux-arm-kernel@lists.infradead.org; Wed, 15 Mar 2017 20:26:34 +0000 Received: by mail-pf0-x231.google.com with SMTP id x63so8274451pfx.2 for ; Wed, 15 Mar 2017 13:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rXKHPF6czZPq/GNGiGFSM2o56gDTE/cB8olf9WOF/xQ=; b=HCdr7pP2wj+hDGPJjg7frBzCwTZlPZGjq8wyeFdWvd1NNd8B3C9r5smMGZEu+Tqobd bvBO2HH5Mriatk5OYKe7YkCZyCmpimy2mOKu3zn1dr1Y44JuXiYDwt2JN8r7L9cz7jzN ET9cNto91x24G3dK8doaG1icGJ9AC7NwkQvLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rXKHPF6czZPq/GNGiGFSM2o56gDTE/cB8olf9WOF/xQ=; b=FUd9MfxYbBdST9WdJrUAWQEO5jil8gwLFPqW21EL3Uo1c+PBPJwbFxcdHyC5J9Kw24 vYqVsC0qOmSSLLBaOLIvduuX7IgVRoPZ9R5yLOVuWvz39g9/GR/osWZe+UHn4dE/y3Qq dtbbIvAhQ3RzZaG/WHOeCg2Uj4OYqDpXzSVMRQS6/MZ0uSC6+2lm43SBThjZGAwHjvwz fWoh68aSF2UWhqwaDzKy12UcIxwo5QYcvyWnzPU4rkucZY3P3ujWjGN2Ix4eH6afD/65 hU1INAphV97RhMx9ofAWy8wLNbZ1TKJLH7lxm/6Wp7AheFPZHYI/EIJ9mqnNrO9X1Bvd 4X7Q== X-Gm-Message-State: AFeK/H1V20XmdeyOa4KZKD+OppQ8dDLaW976S3YY4/0YAahUlV4z9tNmbF60SW/359xFZE74 X-Received: by 10.99.101.197 with SMTP id z188mr5873640pgb.164.1489609568689; Wed, 15 Mar 2017 13:26:08 -0700 (PDT) Received: from isubrama-dev.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id r67sm5922281pfb.125.2017.03.15.13.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Mar 2017 13:26:08 -0700 (PDT) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH net-next 4/7] drivers: net: xgene: Fix Rx checksum validation logic Date: Wed, 15 Mar 2017 13:27:18 -0700 Message-Id: <1489609641-31557-5-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489609641-31557-1-git-send-email-isubramanian@apm.com> References: <1489609641-31557-1-git-send-email-isubramanian@apm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170315_132629_878731_CEACFFC1 X-CRM114-Status: GOOD ( 11.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kchudgar@apm.com, Iyappan Subramanian , patches@apm.com, linux-arm-kernel@lists.infradead.org, qnguyen@apm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes Rx checksum validation logic and adds NETIF_F_RXCSUM flag. Signed-off-by: Iyappan Subramanian --- 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 ec43278..e881365 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c @@ -601,14 +601,24 @@ static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb, 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 void xgene_enet_free_pagepool(struct xgene_enet_desc_ring *buf_pool, @@ -729,10 +739,7 @@ static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring, skip_jumbo: 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; @@ -2039,7 +2046,7 @@ static int xgene_enet_probe(struct platform_device *pdev) 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;