From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0062.outbound.protection.outlook.com [104.47.36.62]) by dpdk.org (Postfix) with ESMTP id B46CF325F; Mon, 12 Nov 2018 18:54:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6/WrwFDlup8G/Wno5dSluZ+eQ4SHLAIotEnEXnFY2uY=; b=lxDeBqeA6ESm1NBB0ZQdTLKFcAqnF3Z9ZpmudfY/oWtsu8VZpzaZQlRfm0lsYiYtqAnIBrnfwSWasKZzEHWZgfPVak6CuHAMqXoCJ3yeL7BMWNcDHW7dlHl5UEdRdVKe17qxla7Ua6f10tTKDxfNra+OBzpk8ZsSv7S0QeBCewQ= Received: from SN6PR07MB4911.namprd07.prod.outlook.com (52.135.77.157) by SN6PR07MB4349.namprd07.prod.outlook.com (52.135.90.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 12 Nov 2018 17:54:09 +0000 Received: from SN6PR07MB4911.namprd07.prod.outlook.com ([fe80::cd76:e8cc:c0:ebf4]) by SN6PR07MB4911.namprd07.prod.outlook.com ([fe80::cd76:e8cc:c0:ebf4%3]) with mapi id 15.20.1294.044; Mon, 12 Nov 2018 17:54:09 +0000 From: Anoob Joseph To: Ferruh Yigit , "Jacob, Jerin" CC: "Saxena, Nitin" , "Joseph, Anoob" , "Athreya, Narayana Prasad" , "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] net/octeontx: fix mbuf corruption with larger priv sizes Thread-Index: AQHUerC23gNE6BW370K40cwRvsuB0A== Date: Mon, 12 Nov 2018 17:54:09 +0000 Message-ID: <1542045165-31148-1-git-send-email-anoob.joseph@caviumnetworks.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [115.113.156.2] x-clientproxiedby: BM1PR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::22) To SN6PR07MB4911.namprd07.prod.outlook.com (2603:10b6:805:3c::29) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SN6PR07MB4349; 6:YpeWclIJXloh92IVrI2/BViqd2ifQEfAZ0kz7YwDmWN/x3GtERw2d1N02NNgbcyHXdU3g4o1tF+YVniOva03xJmhWQIJQ98hSun7PeaMGRYbXrPPPEnSXcY5zA9UOxn+3/2XSPU4Bd7+/DTa6K0Rh7wem6yANKkDM++udjrsqYPlsoSUZkDwgy/XZRK2JMXfNaBh4W9Mv9WM3QJWLRx2Bc3th9PuXqCjSDszE9pw7aZ4lLiRGOXpRwVKf84DwLscNBx0FKjvFDD2/Xky4+2GayPUHayaYx/Rx5RGgC5j47Lx08MNQlXrWQoZfcGikRcjTHdv8gH5qk0djORon+X4hLU5HrD45Q5VZOv/p3Vqf7QVl1pCGxyeo5iGadb33K/Ij3PCao97B1v7JaP4UaXRocZSQcEdWo2tvKuCrnYXqLilzamdPzKZxZrR/mGmCW5TeNLlMtDsEZ2ghbjLdiSdEQ==; 5:QzOmhbfpXnN108IiwWY9fI0x/GzcBoo5CG/FmzZYVg5NHqLsDcDazTGWId7IArG5PeXTPGwZU71W/890SvBOAlsbukf1ZHLSVrTawZmxbmXISvAnZnHGkfHV1S8yiroR1pDcnSIkKqZPFTiklzQDTBIHhxpyrXAoF/O8uhg3scA=; 7:/FDwob16sXQuYf2F+Ng35NcQ0o3XOZPC6pABCaXvP0oMzwO8w0kgjj3LA1cQC9jk1Wi+1UHfSKhndhLdBvxHN9ezd93ShaDPQvHAMB1eeRKUzleaOJDy+uHNKwcWbD1CvHz062glZYfPQQfks7CVTw== x-ms-office365-filtering-correlation-id: c6df6d99-184d-4fbd-eb68-08d648c7d861 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4349; x-ms-traffictypediagnostic: SN6PR07MB4349: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231382)(944501410)(52105112)(93006095)(10201501046)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:SN6PR07MB4349; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4349; x-forefront-prvs: 0854128AF0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39860400002)(346002)(136003)(396003)(189003)(199004)(106356001)(256004)(97736004)(102836004)(26005)(386003)(55236004)(6506007)(105586002)(25786009)(53936002)(42882007)(486006)(476003)(2616005)(14454004)(6486002)(186003)(1857600001)(2906002)(71190400001)(478600001)(36756003)(71200400001)(66066001)(316002)(110136005)(54906003)(7736002)(305945005)(2900100001)(6436002)(5660300001)(8936002)(52116002)(6512007)(6116002)(8676002)(72206003)(3846002)(68736007)(99286004)(81156014)(4326008)(81166006); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4349; H:SN6PR07MB4911.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: O2q1PviW4h3gJ3ntYtgj16o5ePhC3VVISJYbOBd/91nQ0q96USsf5d1RbhfEO+gDdSvi4h/VQQB+c9+4TQlj/kM+/VM0S5k0VnL7RhkuCPpCsj12k3rUgy5iJDYTNiuHBAC1g4weoC1G47426CRBoU7SlegSL/SlzeBfS5erKv6Mh+XEAw07FkzlN2r0N46RRosXsfHnv+jgROhFGMe6WaFdDLarTty6Mv0ZZ6BJ/lWca7MMO797+GV3rl5NxzobwN2Ocjr9Y4k2tk7aHzL7rBtUBmG8wYp9tXkYqXQ1qWwScqNLElZTmSUenxdlm6ViXg4tQIcWmLdCpH5SvwgPQMXdXagHXUgOQE4+GiV8biY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6df6d99-184d-4fbd-eb68-08d648c7d861 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2018 17:54:09.3487 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4349 Subject: [dpdk-dev] [PATCH] net/octeontx: fix mbuf corruption with larger priv sizes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Nov 2018 17:54:12 -0000 From: Nitin Saxena When the priv_size of the mbuf is > 128 bytes, the mbuf would not be properly constructed. This would lead to a corrupt mbuf. This patch fixes the issue by accounting for rte_pktmbuf_priv_size(pool) and RTE_PKTMBUF_HEADROOM while configuring first skip register calculation. Fixes: 197438ee9f18 ("net/octeontx: add Rx queue setup and release ops") Cc: stable@dpdk.org Suggested-by: Jerin Jacob Signed-off-by: Anoob Joseph Signed-off-by: Nitin Saxena --- drivers/net/octeontx/base/octeontx_pki_var.h | 13 +++++++++++-- drivers/net/octeontx/octeontx_ethdev.c | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/octeontx/base/octeontx_pki_var.h b/drivers/net/oct= eontx/base/octeontx_pki_var.h index c793b65..f4661d2 100644 --- a/drivers/net/octeontx/base/octeontx_pki_var.h +++ b/drivers/net/octeontx/base/octeontx_pki_var.h @@ -7,8 +7,17 @@ =20 #include =20 -#define OCTTX_PACKET_WQE_SKIP 128 -#define OCTTX_PACKET_FIRST_SKIP 240 +#define OCTTX_PACKET_WQE_SKIP 128 +#define OCTTX_PACKET_FIRST_SKIP_MAXREGVAL 496 +#define OCTTX_PACKET_FIRST_SKIP_MAXLEN 512 +#define OCTTX_PACKET_FIRST_SKIP_ADJUST(x) \ + (RTE_MIN(x, OCTTX_PACKET_FIRST_SKIP_MAXREGVAL)) +#define OCTTX_PACKET_FIRST_SKIP_SUM(p) \ + (OCTTX_PACKET_WQE_SKIP \ + + rte_pktmbuf_priv_size(p) \ + + RTE_PKTMBUF_HEADROOM) +#define OCTTX_PACKET_FIRST_SKIP(p) \ + OCTTX_PACKET_FIRST_SKIP_ADJUST(OCTTX_PACKET_FIRST_SKIP_SUM(p)) #define OCTTX_PACKET_LATER_SKIP 128 =20 /* WQE descriptor */ diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/= octeontx_ethdev.c index 9c287df..b30defe 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -844,10 +844,11 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, = uint16_t qidx, pktbuf_conf.mmask.f_cache_mode =3D 1; =20 pktbuf_conf.wqe_skip =3D OCTTX_PACKET_WQE_SKIP; - pktbuf_conf.first_skip =3D OCTTX_PACKET_FIRST_SKIP; + pktbuf_conf.first_skip =3D OCTTX_PACKET_FIRST_SKIP(mb_pool); pktbuf_conf.later_skip =3D OCTTX_PACKET_LATER_SKIP; pktbuf_conf.mbuff_size =3D (mb_pool->elt_size - RTE_PKTMBUF_HEADROOM - + rte_pktmbuf_priv_size(mb_pool) - sizeof(struct rte_mbuf)); =20 pktbuf_conf.cache_mode =3D PKI_OPC_MODE_STF2_STT; --=20 2.7.4