Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp672834imm; Thu, 4 Oct 2018 01:09:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV63c8dq1DuYSIdJD48mUioqKThLhd+IhhBxpg2mDrlg5h0DyNpwFme+fOGyRnlsVH1PdLZlN X-Received: by 2002:a17:902:720b:: with SMTP id ba11-v6mr5311775plb.199.1538640552573; Thu, 04 Oct 2018 01:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538640552; cv=none; d=google.com; s=arc-20160816; b=TVtIL7uVIfDHpkv4yZkl7SUicTemLKOfyW3tu4N0g2T+9CwsSm3SZHP/hQoAGGPBx7 OjKDNat5UrRo1yvbAKJ5+zPB3wkA/dX0Bzj0y16jVzm8dRBQ/txcz0pE549yMU97TBl2 dWWiQRHwtByacoP5cWqA0COXHl9odHio+vA4+cI0rGadAMAcw7VPwiFK0UuPrgmZEq4w auBU9YWaPQ2AOuu7WJl59LFkgae7qrDPlZvRqiymmurPUufyZXQA75KIFYEITFD0jL5K DtOrrKYsN+PL64X5w2bxebAAxu5mdY5Ytdvvd9RHCx8PgIsG6ER51iXl/AEiIclRLDY/ r2SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=s2oKyfl20M2NNnZD5f+EmlQH5eg1d8wPiwErQ842aE0=; b=s+82qlXP7R1RYHZpOMrsqlvtK+3jqUXTDDhrN7SOp5hzl8tnKYU93HfPDc+idB9AEP SNZYe8TX6DTilc4HXWAq7/go5qZscDNeLJNBcRY4cPx4CL3DvbJdsBHQl4E+4BaKkGd7 HsA/Mm8QDmvU/CRf1frDY5ZXE6A3alAh5PLwIpGx+om47g2al8MjpaS9FEK0wn32YlBg UMaaKxDpFvpfnmmTWVlMqWCpnNaS90LkV0mymfnccOtF+J8PCHkuVlxoLCjo4llHAwqY 7NpNZrS2P+SrmUnrNuW6UDQj69bXAntlKupKreSGkeM0C2oJ3bYw3sYJzA+6+1cEm+EL 7TAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b="CPDi3s/F"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si4513664pld.419.2018.10.04.01.08.56; Thu, 04 Oct 2018 01:09:12 -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; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b="CPDi3s/F"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbeJDPAh (ORCPT + 99 others); Thu, 4 Oct 2018 11:00:37 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:53390 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbeJDPAh (ORCPT ); Thu, 4 Oct 2018 11:00:37 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9480MrB009798; Thu, 4 Oct 2018 01:08:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=s2oKyfl20M2NNnZD5f+EmlQH5eg1d8wPiwErQ842aE0=; b=CPDi3s/FaN+Un38LpMtod8QxqImMXZfqAS0EjDIiW/e1ca/NVHu2m5fBYvGVN7c6zsvA dYbPo4/3nTs+TI/3ACkpzy00UvUOW1wuRhR1Pt2ESf2tsAYAmGjreaPKyTgPtBBt7gim ttgRuFdI3zPHwvW63XfsgWsI7dhv9p4It2E10XwAPODOkfbmqtO4AXZbaLR9BMz13Alu i/qBwwi8zpFHz12Hc/1Y/1nnzoBOTvbaIMd6oFiA/Y4KB+UX1aM1eMHS+zNjHvP7fWGm QdlpJXvhI14lLvq8BbAO0OiFyHasIDeVlMJXKFfjPrvPVG2epXpQgMjJoUbd++NIoRO6 wg== Received: from il-exch02.marvell.com ([199.203.130.102]) by mx0b-0016f401.pphosted.com with ESMTP id 2mt8wh063a-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 04 Oct 2018 01:08:32 -0700 Received: from IL-EXCH02.marvell.com (10.4.102.221) by IL-EXCH02.marvell.com (10.4.102.221) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 4 Oct 2018 11:08:25 +0300 Received: from IL-EXCH02.marvell.com ([fe80::5893:b43a:12ee:1b7b]) by IL-EXCH02.marvell.com ([fe80::5893:b43a:12ee:1b7b%20]) with mapi id 15.00.1210.000; Thu, 4 Oct 2018 11:08:25 +0300 From: Yan Markman To: Maxime Chevallier , "davem@davemloft.net" CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Antoine Tenart , "thomas.petazzoni@bootlin.com" , "gregory.clement@bootlin.com" , "miquel.raynal@bootlin.com" , Nadav Haklai , "Stefan Chulski" , "mw@semihalf.com" Subject: RE: [EXT] [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Thread-Topic: [EXT] [PATCH net] net: mvpp2: Extract the correct ethtype from the skb for tx csum offload Thread-Index: AQHUW7i7bKe3wJSXT06HrXe4bVthZaUOumRg Date: Thu, 4 Oct 2018 08:08:24 +0000 Message-ID: <763e186250f44f9ab7208478442ce1a4@IL-EXCH02.marvell.com> References: <20181004080308.7687-1-maxime.chevallier@bootlin.com> In-Reply-To: <20181004080308.7687-1-maxime.chevallier@bootlin.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.5.102.207] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-04_03:,, signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810040083 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I'm not sure that kind of ntohs() using is good for the Performance.=20 htons(ETH_P_IP) is CONSTANT swapped Big/LittleEndian by COMPILER whilst the= =20 ntohs(vlan_get_protocol(skb)) is run-time short/byte-swap for every packet. Yan Markman -----Original Message----- From: Maxime Chevallier [mailto:maxime.chevallier@bootlin.com]=20 Sent: Thursday, October 04, 2018 11:03 AM To: davem@davemloft.net Cc: Maxime Chevallier ; netdev@vger.kernel.o= rg; linux-kernel@vger.kernel.org; Antoine Tenart ; thomas.petazzoni@bootlin.com; gregory.clement@bootlin.com; miquel.rayna= l@bootlin.com; Nadav Haklai ; Stefan Chulski ; Yan Markman ; mw@semihalf.com Subject: [EXT] [PATCH net] net: mvpp2: Extract the correct ethtype from the= skb for tx csum offload External Email ---------------------------------------------------------------------- When offloading the L3 and L4 csum computation on TX, we need to extract th= e 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 w= rong L4 checksum being sent when there's a vlan tag in the packet header an= d checksum offloading is enabled. This commit makes use of vlan_protocol_get() to get the correct ethtype reg= ardless the presence of a vlan tag. Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network un= it") 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_pr= oto, command |=3D (ip_hdr_len << MVPP2_TXD_IP_HLEN_SHIFT); command |=3D MVPP2_TXD_IP_CSUM_DISABLE; =20 - if (l3_proto =3D=3D htons(ETH_P_IP)) { + if (l3_proto =3D=3D ETH_P_IP) { command &=3D ~MVPP2_TXD_IP_CSUM_DISABLE; /* enable IPv4 csum */ command &=3D ~MVPP2_TXD_L3_IP6; /* enable IPv4 */ } else { @@ -2600,14 +2600,15 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *por= t, struct sk_buff *skb) if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { int ip_hdr_len =3D 0; u8 l4_proto; + int l3_proto =3D ntohs(vlan_get_protocol(skb)); =20 - if (skb->protocol =3D=3D htons(ETH_P_IP)) { + if (l3_proto =3D=3D ETH_P_IP) { struct iphdr *ip4h =3D ip_hdr(skb); =20 /* Calculate IPv4 checksum and L4 checksum */ ip_hdr_len =3D ip4h->ihl; l4_proto =3D ip4h->protocol; - } else if (skb->protocol =3D=3D htons(ETH_P_IPV6)) { + } else if (l3_proto =3D=3D ETH_P_IPV6) { struct ipv6hdr *ip6h =3D ipv6_hdr(skb); =20 /* 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) } =20 return mvpp2_txq_desc_csum(skb_network_offset(skb), - skb->protocol, ip_hdr_len, l4_proto); + l3_proto, ip_hdr_len, l4_proto); } =20 return MVPP2_TXD_L4_CSUM_NOT | MVPP2_TXD_IP_CSUM_DISABLE; -- 2.11.0