From patchwork Thu Jan 10 14:02:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 10755859 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C99D76C5 for ; Thu, 10 Jan 2019 14:02:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B81C2298DB for ; Thu, 10 Jan 2019 14:02:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B64EB29902; Thu, 10 Jan 2019 14:02:33 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7912990C for ; Thu, 10 Jan 2019 14:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728923AbfAJOCb (ORCPT ); Thu, 10 Jan 2019 09:02:31 -0500 Received: from kirsty.vergenet.net ([202.4.237.240]:39719 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728321AbfAJOCb (ORCPT ); Thu, 10 Jan 2019 09:02:31 -0500 Received: from reginn.horms.nl (watermunt.horms.nl [80.127.179.77]) by kirsty.vergenet.net (Postfix) with ESMTPA id 0649925BEF2; Fri, 11 Jan 2019 01:02:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1547128948; bh=s51QzC+uYWlR+yjZSwNLdHw+cY3d5xJGtwXWIj+QhLM=; h=From:To:Cc:Subject:Date:From; b=GCtIADMzCwzfS7loYWPTFvR+FUdHWPRCN7fNp3/ux2CZZiOPYZ/zow6uZ2K1J3Vvk tdNd0KXUT5Lq5MmJQD6w2MIEaeNUvtfPuHHXg3SkU8PtVA30DsadAoNREMw7hf/nve JTGWUVt9a36OFGptjQ6+o90zF0x/u6nYNct7WB0Q= Received: by reginn.horms.nl (Postfix, from userid 7100) id 08DDD940462; Thu, 10 Jan 2019 15:02:25 +0100 (CET) From: Simon Horman To: David Miller , Sergei Shtylyov Cc: Magnus Damm , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Simon Horman Subject: [PATCH net] ravb: expand rx descriptor data to accommodate hw checksum Date: Thu, 10 Jan 2019 15:02:22 +0100 Message-Id: <20190110140222.32740-1-horms+renesas@verge.net.au> X-Mailer: git-send-email 2.11.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP EtherAVB may provide a checksum of packet data appended to packet data. In order to allow this checksum to be received by the host descriptor data needs to be enlarged by 2 bytes to accommodate the checksum. In the case of MTU-sized packets without a VLAN tag the checksum were already accommodated by virtue of the space reserved for the VLAN tag. However, a packet of MTU-size with a VLAN tag consumed all packet data space provided by a descriptor leaving no space for the trailing checksum. This was not detected by the driver which incorrectly used the last two bytes of packet data as the checksum and truncate the packet by two bytes. This resulted all such packets being dropped. A work around is to disable rx checksum offload # ethtool -K eth0 rx off This patch resolves this problem by increasing the size available for packet data in rx descriptors by two bytes. It also introduces RAVB_CSUM_LEN to make things a little clearer than "2" sprinkled lightly over the driver. Tested on R-Car E3 (r8a77990) ES1.0 based Ebisu-4D board Fixes: 4d86d3818627 ("ravb: RX checksum offload") Signed-off-by: Simon Horman --- drivers/net/ethernet/renesas/ravb_main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) Change since previous posting: drop RFC designation. I have tested this patch and it is ready to bring it to a wider audience is via upstream diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ffc1ada4e6da..545633128718 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -40,6 +40,8 @@ NETIF_MSG_RX_ERR | \ NETIF_MSG_TX_ERR) +#define RAVB_CSUM_LEN 2 + static const char *ravb_rx_irqs[NUM_RX_QUEUE] = { "ch0", /* RAVB_BE */ "ch1", /* RAVB_NC */ @@ -343,7 +345,7 @@ static int ravb_ring_init(struct net_device *ndev, int q) int i; priv->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ : ndev->mtu) + - ETH_HLEN + VLAN_HLEN; + ETH_HLEN + VLAN_HLEN + RAVB_CSUM_LEN; /* Allocate RX and TX skb rings */ priv->rx_skb[q] = kcalloc(priv->num_rx_ring[q], @@ -524,13 +526,15 @@ static void ravb_rx_csum(struct sk_buff *skb) { u8 *hw_csum; - /* The hardware checksum is 2 bytes appended to packet data */ - if (unlikely(skb->len < 2)) + /* The hardware checksum is contained in RAVB_CSUM_LEN (2) bytes + * appended to packet data + */ + if (unlikely(skb->len < RAVB_CSUM_LEN)) return; - hw_csum = skb_tail_pointer(skb) - 2; + hw_csum = skb_tail_pointer(skb) - RAVB_CSUM_LEN; skb->csum = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); skb->ip_summed = CHECKSUM_COMPLETE; - skb_trim(skb, skb->len - 2); + skb_trim(skb, skb->len - RAVB_CSUM_LEN); } /* Packet receive function for Ethernet AVB */