From patchwork Mon Dec 10 08:59:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 10720869 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 1A07F15A6 for ; Mon, 10 Dec 2018 08:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0644D2988E for ; Mon, 10 Dec 2018 08:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC8E629895; Mon, 10 Dec 2018 08:59: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 371962988E for ; Mon, 10 Dec 2018 08:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726724AbeLJI7c (ORCPT ); Mon, 10 Dec 2018 03:59:32 -0500 Received: from kirsty.vergenet.net ([202.4.237.240]:39080 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbeLJI7c (ORCPT ); Mon, 10 Dec 2018 03:59:32 -0500 Received: from reginn.horms.nl (watermunt.horms.nl [80.127.179.77]) by kirsty.vergenet.net (Postfix) with ESMTPA id 6A35A25BE52; Mon, 10 Dec 2018 19:59:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1544432370; bh=DyYWaI6gqLyqF6mbwxl60n0gtCP+vK8F++W3TH4qVlE=; h=From:To:Cc:Subject:Date:From; b=NRliSwXscG+yZm7dGdk9ucGzkNSe4HGTNPflQMfB7d2C+3YMm50MqyBe26neqXY7M +qI4kAmDhm4Es8iAx3w9Sl+zdgsV+ViLxksUyV7PZaiMUJBUsTsVa3/pb+/ZUgaHfY 33ZEAUnMMyqXS6pPtBgtZLDndbnpcyPC7LRDB/n4= Received: by reginn.horms.nl (Postfix, from userid 7100) id 930A49402FD; Mon, 10 Dec 2018 09:59:28 +0100 (CET) From: Simon Horman To: Sergei Shtylyov Cc: Magnus Damm , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH/RFT net] ravb: expand rx descriptor data to accommodate hw checksum Date: Mon, 10 Dec 2018 09:59:17 +0100 Message-Id: <20181210085917.23056-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 From: Simon Horman 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(-) I have marked this patch as RTF as I would like it to see further testing before being applied. diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index defed0d0c51d..f7f130cf61e4 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 */ @@ -350,7 +352,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], @@ -533,13 +535,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 */