From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10055.outbound.protection.outlook.com [40.107.1.55]) by dpdk.org (Postfix) with ESMTP id CB2A731FC for ; Wed, 25 Jul 2018 14:55:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o83TW8IPBZtq84NXVjWmU35HDPbzQznbwN7crXi6vO4=; b=Ufieoo8bB5WeIdC5+k+ILmfqF9zezJo/vYq/W0oJj69em0bPyIB9qlYzqz5cEdZ1yhYqDao46mw4yVwL6P8uWzHxWDkBi7SwXzU1OE/FijLUVrwgpsZ3Yf0En0EqEJ2HiHNK2pq3rNdFL8IfHNufuiZ7ZpfzbJoJowYVR7LhzEU= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.187.142) by AM4PR05MB1793.eurprd05.prod.outlook.com (10.165.246.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Wed, 25 Jul 2018 12:55:38 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::6d55:c970:605a:4106]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::6d55:c970:605a:4106%4]) with mapi id 15.20.0973.022; Wed, 25 Jul 2018 12:55:38 +0000 From: Ori Kam To: =?iso-8859-1?Q?N=E9lio_Laranjeiro?= , "dev@dpdk.org" , Shahaf Shuler , Yongseok Koh Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: fix count query when flow has not counters Thread-Index: AQHUI/P8Oif3TFVuH0CyIstekwqlkqSf5X4Q Date: Wed, 25 Jul 2018 12:55:38 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=orika@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB1793; 6:VSlURGPfyFyQFz24bJ+M7J6HDHJBUltgc63MqcUXIuDpxR9ZgrFv2To7ywMUgMWlk4n/SCcq7oywB3TYNhjdboKQizH1t5dR3kMIEHP1C9Vxsby89XV+VNg7A3qoT6L6JGSZkAGcxpyqhhkkNQkZ4ntFUMHR4h/FRuJlwMcDFflSE8w5MTAeKV75P68w6bjG4z8lp6B91m0alnjLz/+8UXF6ux3uJRpY7/BWGNkC3wAVG4A3vfNMskHvIW2/3JtkvEKZrzKy+xuiQxgLwip5HZ15z8zbNEohWB5yEl6mAynEQQjxzt2b6M6L2oFWHywt+uMd9dH524TAagvGPGVVK/Q5VBVFq39H6G3Toi7sXz7DJVcbXrWiy1YYc2b99bDEiSmntTZ4PnH2bppsRNsXJFJPCKbQdvNUWjLuteDmSRtIv4hyGel/VVVIRO8aHLp1oBfNwdG/TuODNf+AdEIXPw==; 5:6WpF1pYNQTB46QG65hGkIGdRzoMyOhIq/wY0+E/2I+oKWoiDV9qASTsiGve9QDD3+G/uzR97zXcempAATuxwO3sMhhD3biCubs8BUtW1IpZMVmnEl5VjiiRmsUdMxXWaggFJTfJesXY7hxCdNZ+ZaZCmhI6kCZGA3udxhE5/Xno=; 7:s2NYa+u+chZLpDISR44jGzzoQQr4D99zHBF8ZcXznK+7uSvEdwXBOabqV2WhhtfIhM/6BE0roXt5YNhEn9GwmZcyY/uHr9ChEQGeeDTBaMakzQt4uICZ2dClt/s3niR/ATidwdZ4yghllMjrI6o+DDHUawkQvvwB4KjBSIi6BQhYoLkHlLh82LtAHIWmzJK2BRVFL8O17587+UMTM1VnDtFe3UCsbRrnSAwKLAvKHJwyUiK/svNM8Nv0zVZfYxxt x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 21c65d2c-a8d7-4ceb-d8df-08d5f22debde x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB1793; x-ms-traffictypediagnostic: AM4PR05MB1793: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr 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)(8121501046)(5005006)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:AM4PR05MB1793; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB1793; x-forefront-prvs: 0744CFB5E8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(136003)(366004)(376002)(39860400002)(189003)(199004)(13464003)(105586002)(68736007)(3846002)(33656002)(7696005)(186003)(2501003)(74316002)(5250100002)(81166006)(81156014)(6506007)(76176011)(26005)(53546011)(110136005)(446003)(478600001)(316002)(106356001)(55016002)(6436002)(305945005)(14454004)(102836004)(9686003)(8936002)(476003)(486006)(6116002)(256004)(97736004)(7736002)(14444005)(229853002)(11346002)(5660300001)(86362001)(6636002)(2900100001)(6246003)(53936002)(25786009)(66066001)(99286004)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1793; H:AM4PR05MB3425.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: s6cDeU07BQOmHhuhJw4Ymv3gW+QGfEgjV5OeNbLLL89fU65yy4Kba1Cm+fgdXdEg50XvhjYRj+LO6zXjzq7Gv07fVobWcA1kp0FlYTyc3J/ZkJ+q1m9U+9zM6LQGyYu5DmgUVSK9vN01W6nt8L7EcUcWizgyos5GAahJpluUpflu2OPVQYjjk58yJYar5vtRZ3hdQ3iVeBO3T6DSaAgR6ZxIzYOH3TDVgXWWHVUDWe6XUI2/hn5eAwRFWqYVWWzD3k8Dc+Ngz9erCUowpyZdxj7c/boIJYKBuHzLWiK7QiFTk71XTGTMvt5HLAbNNpqzbG/iomslNEN5qtjTC7yQ10RpMFZa1uRpykGda/3dQxE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21c65d2c-a8d7-4ceb-d8df-08d5f22debde X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2018 12:55:38.6192 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1793 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix count query when flow has not counters 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: Wed, 25 Jul 2018 12:55:40 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Nelio Laranjeiro > Sent: Wednesday, July 25, 2018 11:46 AM > To: dev@dpdk.org; Shahaf Shuler ; Yongseok Koh > > Subject: [dpdk-dev] [PATCH] net/mlx5: fix count query when flow has not > counters >=20 > Querying a counters on a flow without counter is ending with a > segmentation fault. >=20 > Fixes: 60bd8c9747e8 ("net/mlx5: add count flow action") >=20 > Signed-off-by: Nelio Laranjeiro > --- > drivers/net/mlx5/mlx5_flow.c | 56 ++++++++++++++++++++---------------- > 1 file changed, 32 insertions(+), 24 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 6fa4e30ae..efaa8b4fb 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -3192,32 +3192,40 @@ mlx5_flow_query_count(struct rte_flow *flow > __rte_unused, > struct rte_flow_error *error) > { > #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT > - struct rte_flow_query_count *qc =3D data; > - uint64_t counters[2] =3D {0, 0}; > - struct ibv_query_counter_set_attr query_cs_attr =3D { > - .cs =3D flow->counter->cs, > - .query_flags =3D IBV_COUNTER_SET_FORCE_UPDATE, > - }; > - struct ibv_counter_set_data query_out =3D { > - .out =3D counters, > - .outlen =3D 2 * sizeof(uint64_t), > - }; > - int err =3D mlx5_glue->query_counter_set(&query_cs_attr, > &query_out); > + if (flow->modifier & MLX5_FLOW_MOD_COUNT) { > + struct rte_flow_query_count *qc =3D data; > + uint64_t counters[2] =3D {0, 0}; > + struct ibv_query_counter_set_attr query_cs_attr =3D { > + .cs =3D flow->counter->cs, > + .query_flags =3D IBV_COUNTER_SET_FORCE_UPDATE, > + }; > + struct ibv_counter_set_data query_out =3D { > + .out =3D counters, > + .outlen =3D 2 * sizeof(uint64_t), > + }; > + int err =3D mlx5_glue->query_counter_set(&query_cs_attr, > + &query_out); >=20 > - if (err) > - return rte_flow_error_set(error, err, > - > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > - NULL, > - "cannot read counter"); > - qc->hits_set =3D 1; > - qc->bytes_set =3D 1; > - qc->hits =3D counters[0] - flow->counter->hits; > - qc->bytes =3D counters[1] - flow->counter->bytes; > - if (qc->reset) { > - flow->counter->hits =3D counters[0]; > - flow->counter->bytes =3D counters[1]; > + if (err) > + return rte_flow_error_set > + (error, err, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "cannot read counter"); > + qc->hits_set =3D 1; > + qc->bytes_set =3D 1; > + qc->hits =3D counters[0] - flow->counter->hits; > + qc->bytes =3D counters[1] - flow->counter->bytes; > + if (qc->reset) { > + flow->counter->hits =3D counters[0]; > + flow->counter->bytes =3D counters[1]; > + } > + return 0; > } > - return 0; > + return rte_flow_error_set(error, ENOTSUP, > + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "flow does not have counter"); > #endif > return rte_flow_error_set(error, ENOTSUP, > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > -- > 2.18.0 Acked-by: Ori Kam Best, Ori