From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00065.outbound.protection.outlook.com [40.107.0.65]) by dpdk.org (Postfix) with ESMTP id 180F498 for ; Wed, 25 Jul 2018 19:25:15 +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=v2aSS9WvKlc9xB1/YiIN2sMyV7sLD6lay/7qZ1jCczA=; b=Eaa6SAQOTyuQUN8q+Zc6a/9HRkpfOBk2i5ssi5oaC3XyrfYUSw+/EUxWoSJ4juJyfXlwKMVQ0l3coMz6RUf5Uvl/n+99r9SWO08XvieeGHYL5gofKeCTeNQBXoY/BmQc9ODJEyFCjZqFWNC4FqS7usi2O+n5rt0N5zAK1nBjQ5c= Received: from VI1PR0501MB2045.eurprd05.prod.outlook.com (10.167.195.147) by VI1PR0501MB2749.eurprd05.prod.outlook.com (10.172.11.11) 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 17:25:14 +0000 Received: from VI1PR0501MB2045.eurprd05.prod.outlook.com ([fe80::882c:f01c:dfb2:175]) by VI1PR0501MB2045.eurprd05.prod.outlook.com ([fe80::882c:f01c:dfb2:175%2]) with mapi id 15.20.0973.022; Wed, 25 Jul 2018 17:25:14 +0000 From: Yongseok Koh To: =?iso-8859-1?Q?N=E9lio_Laranjeiro?= CC: "dev@dpdk.org" , Shahaf Shuler , Ori Kam Thread-Topic: [PATCH] net/mlx5: fix count query when flow has not counters Thread-Index: AQHUI/P5nztXbk08x06c6q5BMYDCvqSgMPoA Date: Wed, 25 Jul 2018 17:25:13 +0000 Message-ID: <5078406F-E033-43EA-8FFF-0D53EA58DD57@mellanox.com> 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=yskoh@mellanox.com; x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2749; 6:HvD1j9fUMYtRMlgEHCFfr3AuKtgsiplbW0orO3sjmKo+82cIKyDjUiIf4UbXfWHRIEyXCLOz45GiS3iYmyR/ao80hWpHkEtiLsvrFZmGoMbDlLjRrbgJBizyTbHkvM+p9rSJQmCo19wyU9q7QYtehFTzI65BDuaMeo+zaXSoz4eTJJuh1sZ9PD/VDtkXH3QnLoJ2sElvqxliivRikGGk6Q+Qwn3f1BwdntSilF2QwQtucHbZUXRowoVxm5ZdVs7/u0gu3bMoPxAMEk0uKPIYBJTEQA/ksA7/ffZr686YTpQk5FpiP/kR2MNfc4MffVqYHGzQQ+Sb+DhsTxx5esw4kobRH6rOtpaOKPmgfB66TjAUc41acvhwUt1B37hk4+CGJHabuWK6CEJsHQIWZ29L2rgFy5+pOhFWs5B4reo67r26vfc740mdWXNa6zEe5ze/gE4G4eOjh4yb5NJ1QfaD8Q==; 5:HOpVp26yXZ0qe6JWjwc19XxdY3H0KDYMLqWKz0O1C7yswkQl3T7a4sFptdieSGXgOGk1Rdw/yBNh4dRpLzP5uz2nVQqrA+/nvo0iKbBKJxvzCp5ZP3+YS55+E+RmqvCrWjMY1mSLtaL2ikA4D6KRN8KwycEFnt40Tdu40a+w4g0=; 7:bap4exwIQBoMQyRlgaizyZvbd1FiD6AdCPr9TB0Nw57GXB2ZC7eimAXGzj2zzlP724LLEL2ZUWo32m9ICybaYZzvGfUykda+MQJ35X/lQDLvwV4CkOncBF1dDlJTn8nfcfCk5UHFh5iV1o2/An12kK7CcZYF+PI3q2ge/vyiDuOa7Pv+C5oXljENURaNJEf10BmXBo1LM+ykuATVsX/+cOcYKC/dLq88KSuG8ZKHgZG1pQpxLPXyk1NytsiJJEA6 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: f05448f8-47ca-4e66-7f61-08d5f2539516 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:VI1PR0501MB2749; x-ms-traffictypediagnostic: VI1PR0501MB2749: 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)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2749; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2749; x-forefront-prvs: 0744CFB5E8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(376002)(346002)(39860400002)(189003)(199004)(68736007)(6436002)(186003)(33656002)(8676002)(6506007)(81166006)(5250100002)(81156014)(446003)(8936002)(76176011)(53546011)(26005)(14454004)(478600001)(316002)(3846002)(6512007)(7736002)(105586002)(6486002)(102836004)(486006)(2616005)(4326008)(6116002)(97736004)(106356001)(305945005)(476003)(107886003)(229853002)(14444005)(11346002)(256004)(54906003)(5660300001)(2900100001)(83716003)(6916009)(86362001)(66066001)(99286004)(36756003)(82746002)(53936002)(25786009)(2906002)(6246003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2749; H:VI1PR0501MB2045.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: xfqStlz1PIxMETGiW5Pt9sbAypj2SZJNUKW7NDSb0RecDxgE3vjZe9aNo1584WHLODrBnYjLGkCO3o9aHM7hSuOiR683GonVTVqpZbNz2vThNLRRXmxP5sY9ysc0P7+nrf9AwAQA+3u7xs3cxrhy6NfUadrjmX64E9KgCc2ViUnIx9qm4eD6QeaCb939mLV8hhfBVh3q0jLXAAL9/BcpUzoOzYqd7MvgBqnNRvl1kCLS2YVADcqQV8zCOig46wg0fCp8OLNfuSIyUkx0MqfgvuM8kTRA2GlHJUlT0lqE65Brt/RxUTCbWkMdEENOjDXZ71ojDK0yQvSfKarbzDOl+zQuHKECtjLO9rASfuKuhYc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f05448f8-47ca-4e66-7f61-08d5f2539516 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2018 17:25:13.8959 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2749 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 17:25:17 -0000 > On Jul 25, 2018, at 1:46 AM, Nelio Laranjeiro wrote: >=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) { Instead of adding extra indentation, how about returning error immediately = if the flow doesn't have a counter? That looks more natural. But even if you i= nsist this way, I'm also okay. Please let Shahaf know if you will submit v2. Acked-by: Yongseok Koh =20 Thanks > + 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, > --=20 > 2.18.0 >=20