Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp668055imm; Thu, 4 Oct 2018 01:03:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63M2V8mlbqPP6dpBEan1W52nOYR3K18w5t2viPyWC+huaybeO7ghmlspBx0pxjwdDaJwp5P X-Received: by 2002:a62:3995:: with SMTP id u21-v6mr5596595pfj.116.1538640228904; Thu, 04 Oct 2018 01:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538640228; cv=none; d=google.com; s=arc-20160816; b=ay/rymiFsM8n0eeiBdZ9CnCyody8+VX/okn6XnHbdp9t2FGMM/Uf6HitKhcL+SoGf3 B4Nih7yvdfBBbB4thCC6FoUHnGFLDG7mbM8osKkK2RpfI6gSRfWeIVsS2oLT1gtSSHki WSMVzPJYZpM8Ee9L9PniV5mcc+PGjsCnzovNlUiEhYS58fAJ2l2br/L2jTqquAYYISl5 XmxNy2BBvvJof5d5g1nY+36uExCRQcQhFCnJJaw2GOpYXBE7fstWJo7EThPWPTBcRcwN SRdC5OcMzVTy3sESReKi3ZGt5Dt6VHcKLAEEPxHEacHTUvGZcXkWONf6CqtZa6UPh4k3 reXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=0sqcS7S5gSpnQKwQftfpUaSLp0e7FYdGfAD/6IZU+x0=; b=LtUccTdwy0/DM8UZdcLX3AIAVP1QLvccIID43ROgDYxKktpKB191YbXNlqmOQpJeJM rGq7DgGAcB+3W4PvdIWmseFbLCVoYC1wmnI+qN3mp+GxC1X2iotfBuPaYsx1vHWu0p52 I/8B5nvLa+jsR+J+IX9Jx0bUVsX8OzZbMO4+O3ARAq1oe6ZP6Onqa+ay1f8wQXYbFZqq pmHAC40xvwIqpV3oIkKp7hxlEGHBYr0/ZapZtMd61xgJBTjSFSzWgEtWKFe6HT/uVgBm 7OUnaSHn/afx+YqcMd7E0Akjdza5hpNZxNNwnPOgiOuhO+edYZjXd6v43n79SY10OLCP 6fMw== 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 b41-v6si4383256pla.306.2018.10.04.01.03.32; Thu, 04 Oct 2018 01:03:48 -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 S1727721AbeJDOzZ (ORCPT + 99 others); Thu, 4 Oct 2018 10:55:25 -0400 Received: from mail.bootlin.com ([62.4.15.54]:55767 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbeJDOzY (ORCPT ); Thu, 4 Oct 2018 10:55:24 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 51A29207C4; Thu, 4 Oct 2018 10:03:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from mc-bl-xps13.lan (AAubervilliers-681-1-28-153.w90-88.abo.wanadoo.fr [90.88.148.153]) by mail.bootlin.com (Postfix) with ESMTPSA id 052CC20714; Thu, 4 Oct 2018 10:03:21 +0200 (CEST) From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Antoine Tenart , thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, miquel.raynal@bootlin.com, nadavh@marvell.com, stefanc@marvell.com, ymarkman@marvell.com, mw@semihalf.com Subject: [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Date: Thu, 4 Oct 2018 10:03:08 +0200 Message-Id: <20181004080308.7687-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When offloading the L3 and L4 csum computation on TX, we need to extract the l3_proto from the ethtype, independently of the presence of a vlan tag. The actual driver uses skb->protocol as-is, resulting in packets with the wrong L4 checksum being sent when there's a vlan tag in the packet header and checksum offloading is enabled. This commit makes use of vlan_protocol_get() to get the correct ethtype regardless the presence of a vlan tag. Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Maxime Chevallier --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 38cc01beea79..4bd5b251e3c7 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -1737,7 +1737,7 @@ static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto, command |= (ip_hdr_len << MVPP2_TXD_IP_HLEN_SHIFT); command |= MVPP2_TXD_IP_CSUM_DISABLE; - if (l3_proto == htons(ETH_P_IP)) { + if (l3_proto == ETH_P_IP) { command &= ~MVPP2_TXD_IP_CSUM_DISABLE; /* enable IPv4 csum */ command &= ~MVPP2_TXD_L3_IP6; /* enable IPv4 */ } else { @@ -2600,14 +2600,15 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb) if (skb->ip_summed == CHECKSUM_PARTIAL) { int ip_hdr_len = 0; u8 l4_proto; + int l3_proto = ntohs(vlan_get_protocol(skb)); - if (skb->protocol == htons(ETH_P_IP)) { + if (l3_proto == ETH_P_IP) { struct iphdr *ip4h = ip_hdr(skb); /* Calculate IPv4 checksum and L4 checksum */ ip_hdr_len = ip4h->ihl; l4_proto = ip4h->protocol; - } else if (skb->protocol == htons(ETH_P_IPV6)) { + } else if (l3_proto == ETH_P_IPV6) { struct ipv6hdr *ip6h = ipv6_hdr(skb); /* Read l4_protocol from one of IPv6 extra headers */ @@ -2619,7 +2620,7 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb) } return mvpp2_txq_desc_csum(skb_network_offset(skb), - skb->protocol, ip_hdr_len, l4_proto); + l3_proto, ip_hdr_len, l4_proto); } return MVPP2_TXD_L4_CSUM_NOT | MVPP2_TXD_IP_CSUM_DISABLE; -- 2.11.0