Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp97696imm; Fri, 5 Oct 2018 00:05:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV62ZKmcuMo/Z5mKn9csGbKbLeRUft1wxP8GeZfxTzSiBX6rdZZLPXHUN1w3VsgmxtH/lfa4X X-Received: by 2002:a17:902:4381:: with SMTP id j1-v6mr9999663pld.59.1538723114125; Fri, 05 Oct 2018 00:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538723114; cv=none; d=google.com; s=arc-20160816; b=tGsIJ0x0I75ZGLZ/BgMsa9K6znaBMyJH960fuL47owvwFn4iJONR7MkWs7O6D4Gxpw 8DYvMQ5r/XCuy8F8p1EBr41N1nMdE60TfI6u1qMkaEdYhBdKfsjmVutbNGGa1eRzYR7u xGb5T8ITenWosNHC4i287mmlsM14HlxuE1C9bp7FF6Ypc0TabvusPEa9H9wX6k7chjTR 6W2L4SbEs6OL4Ezz635/TSW5CxLoZHBZsPSfHBv8298nmSMerd5xAWgSIihfUPnjthq6 VHc4L5/a+yYyzSGfT3G+5m5sD83R5cEoHD1LNa6vtzoEs35uzKrPIpAabOoikGt3L9mc jWSw== 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=jMDIKUlb2m8cJfa3nVGj1nsNFJTmNJ8h7nfjWnfHYqk=; b=IJLpcSSZv4kQFyLMxGGjjgN+D7TewOZswFMnF++hNSCs6MK8LOba8eTnq7Waxnz3GH BLzGstHRaDnProfG6qkEhBeU6GtxRUAl1DnJkKD6HOLnS6y3Ikl/EXr4d6yX0Ctk9NqI tdL/SDyPdXXKIX7oGETbzsT4ZJEw3ZUtPaysMM5Q/aGa+Nlxh5m8ew0eyey/nz7PJg7P XexHKZ9RL+qYr+rbZ2FR/ZcrVzXtPFi8+aFMAGA+zhJBq7UlxulcLcInmidd3lpox0Ue 2MG/3QtfrOv+RuVOFqhhf43nfuCeoEw0ihXAyLYMvUJ83Tq3mgH201fxYh6t/1vS9fsa nbMA== 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 k9-v6si7380902pgi.227.2018.10.05.00.04.57; Fri, 05 Oct 2018 00:05:14 -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 S1728116AbeJEOCG (ORCPT + 99 others); Fri, 5 Oct 2018 10:02:06 -0400 Received: from mail.bootlin.com ([62.4.15.54]:60197 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727185AbeJEOCF (ORCPT ); Fri, 5 Oct 2018 10:02:05 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 2A2722075C; Fri, 5 Oct 2018 09:04:43 +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, URIBL_BLOCKED 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 D0886206A7; Fri, 5 Oct 2018 09:04:42 +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 v2] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Date: Fri, 5 Oct 2018 09:04:40 +0200 Message-Id: <20181005070440.3294-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: 3f518509dedc ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Maxime Chevallier --- V2: Use htons on values that can be swapped at compile-time, following Yan's comment. Fix the "Fixes" tag and a typo, following Sergei's comment. 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..a74002b43b51 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -1725,7 +1725,7 @@ static void mvpp2_txq_desc_put(struct mvpp2_tx_queue *txq) } /* Set Tx descriptors fields relevant for CSUM calculation */ -static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto, +static u32 mvpp2_txq_desc_csum(int l3_offs, __be16 l3_proto, int ip_hdr_len, int l4_proto) { u32 command; @@ -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; + __be16 l3_proto = vlan_get_protocol(skb); - if (skb->protocol == htons(ETH_P_IP)) { + if (l3_proto == htons(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 == htons(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