From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70047.outbound.protection.outlook.com [40.107.7.47]) by dpdk.org (Postfix) with ESMTP id 0FEEB1B19A for ; Tue, 23 Oct 2018 12:04: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=EU6F1GfgkRonWnT8EznXlg5xQcqU9p/2+j8Ek8ERXaA=; b=e5glPrmk0o5NlYwEm34DW21Et/bOsrEI83NctD3GBEkEboiWGF7n9tFYp1M9wvoWMvlrwrVMpf6s9DUzxQRq0QYm7AS1R7cnWMBRcOMsQ4tcSiygoSUtvrTdjNuRfEMyICD1MAA/mEoxLWRJ7ttfA8+ebUjpl/O9/ABlNNBxf1M= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB3380.eurprd05.prod.outlook.com (10.171.187.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Tue, 23 Oct 2018 10:04:14 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::477:2091:24b4:439f]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::477:2091:24b4:439f%4]) with mapi id 15.20.1250.028; Tue, 23 Oct 2018 10:04:14 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 5/8] net/mlx5: relocate flow counters query function Thread-Index: AQHUarfAl065SpO+pUSZ/lImHT1tnw== Date: Tue, 23 Oct 2018 10:04:13 +0000 Message-ID: <1540289032-29628-6-git-send-email-viacheslavo@mellanox.com> References: <1539962470-10950-1-git-send-email-viacheslavo@mellanox.com> <1540289032-29628-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1540289032-29628-1-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0442.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::22) To AM4PR05MB3265.eurprd05.prod.outlook.com (2603:10a6:205:4::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3380; 6:+NCrj5p+FvbavaL4nAfBFe92wKpqPTDOnNoOJPnWDrX+fioY5p37n4tiv+mtntfkYFEog/fCwIVmh+mjwdM+vubneVRMPPf4c4gyTFHC8Ne1i/TVJOuMuxXWMlihW2GEMeCcG1iqKiA1iM4LCs6gs7h7lJ11dJiTQMwKAxssGTLu49NhiLriHWudrKSfl5z7rEOCuhA7NnV6nKxq+YXSFIVtFAKWGJ3JkdlzkFH0OJR3UUT5pT0KKg8KUa47ExLVUr5YgB8GAaSYpU7sJc2hLcsr1uEbRTzSxxJgkVZ1KrwQGG8EQr3EpeZub6LCWf77OJt4epVEnpVsivUQUenTGSwHCdzXbJ5PGnU/7lJAU2kNj4bjpNBrlG1ArViTUMGqdI0PX/CsVse44S9N9+yBC16P+MtW1IHuhKnl+AnqymG+aUY4AM7Xnob1dD2bo72ikAPPobSRIjS02k/9ghRpFQ==; 5:1whEPUUkmIgkP8yRAGHM88nIew+32FVJjIm3wHSyvwQlOH8fnzHeI2UYUKVC76ufruCLrHVLki1AeNsfLIhS+QGGHSG47WsohE927ucVGMOJHK6BMkX9zG9dvDzjzowtDemdcjQgMLiLWvfHhMQ3Xqp7/zLaxRI9xQrkU8/cexo=; 7:kO0l/zVvQfgLBxp35CH00ImzWk0qOW/VmPJWtnTyHo3G+6phF7ppyh0LK3mUBQooTXOk9W01tNA5ypfKFo/SIfn3SCKkiGmksuYN+/noLdJH+XVae4HkHSJ/2tkSJJ+cyLBjCkGWE/dNkuNcIuWZdYkXvKUBTafDk3Gr9s2ChYrTvwouSTEtO+7rAqRYoV9bareuw9MNxrjNhKqJzaVuI52dcR+EK3ch5+RE7kU5Yq5zOPvLVFN5GmKOe8kYpa8W x-ms-office365-filtering-correlation-id: 85ebf9fa-22fe-458b-0c00-08d638cee291 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3380; x-ms-traffictypediagnostic: AM4PR05MB3380: 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)(93006095)(93001095)(10201501046)(3231355)(944501410)(52105095)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3380; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3380; x-forefront-prvs: 0834BAF534 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(346002)(39860400002)(376002)(366004)(199004)(189003)(71200400001)(6512007)(2906002)(478600001)(5660300001)(446003)(2616005)(14454004)(53936002)(6436002)(37006003)(3846002)(81156014)(6862004)(86362001)(36756003)(2900100001)(5250100002)(7736002)(305945005)(14444005)(6116002)(6486002)(105586002)(7049001)(316002)(97736004)(68736007)(71190400001)(52116002)(102836004)(4326008)(476003)(25786009)(99286004)(66066001)(106356001)(8676002)(81166006)(256004)(76176011)(6506007)(386003)(486006)(11346002)(6200100001)(26005)(186003)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3380; H:AM4PR05MB3265.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: M1FXm+8xndCTpwTTC5ZQ4minZw8UUNx4GanfdrQsWoaUOrkNcrHCe89ngSRsSHhXDqnyVHeAmX+tH7IiSagk4QdOwq5C3zhJUgoheKREJXrR6XATx2DMDXGiV5RGipPNUffOn+vFKv4CIGbbpZag1wXJgv2TsHLFa3lF+I6MgqY7aCJR7DiwFaX3kEGRn6moJFcJSrllqHpx2ezQZoDD0txUYVQT3w8fLB05b6/BMYOVgaC6tKNlP6Bv+KfYEqsOWkTUCeU0E07oecsTQBYmSD46849j9xnx8rTiBtOm6RKuDjDW+O8v7rWHtg1nrgkS0hY0MuqYaOHEsGBuVSdFie00dZKXXFBGhzrsCOesYUk= 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: 85ebf9fa-22fe-458b-0c00-08d638cee291 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:13.8661 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3380 Subject: [dpdk-dev] [PATCH v4 5/8] net/mlx5: relocate flow counters query function 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: Tue, 23 Oct 2018 10:04:15 -0000 The flow_verbs_query_count() is moved into the the group of counter managing functions and renamed to flow_verbs_counter_query() in order to be in unified fashion with others. Also minor function modification is made to avoid unreachable code warnings if there is no counter support at compile time. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_verbs.c | 111 +++++++++++++++++++--------------= ---- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flo= w_verbs.c index 3d6fedb..f720c35 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -110,6 +110,61 @@ } =20 /** + * Query a flow counter via Verbs library call. + * + * @see rte_flow_query() + * @see rte_flow_ops + */ +static int +flow_verbs_counter_query(struct rte_eth_dev *dev __rte_unused, + struct rte_flow *flow __rte_unused, + void *data __rte_unused, + struct rte_flow_error *error) +{ +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 + if (flow->actions & MLX5_FLOW_ACTION_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); + + 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 rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "flow does not have counter"); +#else + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "counters are not available"); +#endif +} + +/** * Add a verbs item specification into @p flow. * * @param[in, out] flow @@ -1654,60 +1709,6 @@ } =20 /** - * Query a flows. - * - * @see rte_flow_query() - * @see rte_flow_ops - */ -static int -flow_verbs_query_count(struct rte_eth_dev *dev __rte_unused, - struct rte_flow *flow __rte_unused, - void *data __rte_unused, - struct rte_flow_error *error) -{ -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 - if (flow->actions & MLX5_FLOW_ACTION_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); - - 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 rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "flow does not have counter"); -#endif - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "counters are not available"); -} - -/** * Query a flow. * * @see rte_flow_query() @@ -1727,7 +1728,7 @@ case RTE_FLOW_ACTION_TYPE_VOID: break; case RTE_FLOW_ACTION_TYPE_COUNT: - ret =3D flow_verbs_query_count(dev, flow, data, error); + ret =3D flow_verbs_counter_query(dev, flow, data, error); break; default: return rte_flow_error_set(error, ENOTSUP, --=20 1.8.3.1