From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) by dpdk.org (Postfix) with ESMTP id BF2AD1B276 for ; Fri, 19 Oct 2018 17:21:48 +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=K2kq//UExLALynuZht4qTWnFOd38YlfAsjR4nkHKfOA=; b=af6e4MnoTrxmtwP8agQc/3Wh414R97kepEx3JuWuFVob4QI0R7OV5ygoXNSsW6c27mDMkW9yLn8h22AlKCLq3+xdg69de2gc/tirMOGkgNVO2Qq0YuvlutjAmAIJleoTI3IgD+IgUfxJysOmAicgFtCuQC3+QdlMwXRdMqBZTQY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR05MB3268.eurprd05.prod.outlook.com (2603:10a6:205:4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.31; Fri, 19 Oct 2018 15:21:47 +0000 From: Viacheslav Ovsiienko To: shahafs@mellanox.com, yskoh@mellanox.com Cc: dev@dpdk.org, Viacheslav Ovsiienko Date: Fri, 19 Oct 2018 15:21:09 +0000 Message-Id: <1539962470-10950-6-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539962470-10950-1-git-send-email-viacheslavo@mellanox.com> References: <1539784438-29242-1-git-send-email-viacheslavo@mellanox.com> <1539962470-10950-1-git-send-email-viacheslavo@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: CWXP265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:39::19) To AM4PR05MB3268.eurprd05.prod.outlook.com (2603:10a6:205:4::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68a9cd4d-c434-441e-2b05-08d635d69609 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3268; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3268; 3:x8mjTzP5mMcWF5wLa6Jvl14HdRTny4MOcisJlkvDICADNT/3bRieMn+Y1fQMCiogt4KZwKwh38Y+9k3HOxZnd2VPdJYH33rdsWea/ESpFwmjZ7II195fXy+2QEUb7wDGOCJGSQZVlO01Dhmhds7RhEGjX+5+z/I62kYAZPtWx2Mo3ofyNWqR6atf6WD0wedEqiDwRD6wI3Pup2GKKQwCcRmVkbNKVxuOY+NeVOdKzoY7buJ+t26MHoiYTMjmEFHf; 25:Pc34KzckT5tXIGG6U0CBkD8M/8yYsJ1M9a5Ph9+jD4PS45ysgRI0dSAM6MMBq5Rm0fHxsOwHwFEAjb8vE3WDrwm+kQkWv8zT2g+nhNiO4a87+eNs4/Flm63rCw/cfaTN7C7pYEU6a2uOfKTgwOH5je0MtovIAdDGxH4R5peO+UI0buID+Olqs8+MEWHcW5/qViUJRMuji6AvWV4T/BkkEvrUcKJ4uvDvyABn8JY/yKz6FjNahpAxxYmfncE75uIYqvLsGbZRQN8FlMEAFnhPimlGcjGPaSpiglxi24fQGHSRkCEAKoNFHSUfuJZ+mYuYHZGlawW6cGQG7BqnbMFXjg==; 31:W6TvMmwZK7Uq82VzfdSDxfROaJm3vuHZk6+80RSa4fVomfsUvTUiV/qO4jBxoRHZ/bFHIjdMWFa4C1BMakQtiAsho3oNCsBhCH/96mX+VJdkI9jHgIQAYS4XLp6+RVa3fc47yEzD4Ydj9VicOr2ezvqd3CgSi6Bf3vvQrpXjO2M9TdifzdJXvAOwbKokwcZtj0IVD9IYx8sMb9mxAkZy7SJN8KnMExjnbrMYsRRnYNI= X-MS-TrafficTypeDiagnostic: AM4PR05MB3268: X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3268; 20:Zp2X3qesfXzesqzXVppX6XoQ23rOo5kq461/CAmH1opOlKuSPF0u63YDIZqrwi/6d2uUr87VzLvxQGIxuG6q2/JAFlOVsXrP203NnTeUw5FGCxPE2HSj45gUVcHQ/s1ESpsTzlQui9O+nG9AIy1OOdxZpxi1cMc+rqzQOhsrOb5RfEfuhFFvZsRTd88FVaFBdVd5zXUcXdOmYzk+QrTH4ceIDR48aMlDpoi8hAiMO6cvGSGhabN5L9513UuCIP4zDTcGfQMGPSlGDQjPWFyisxm6tY+hwAT+nkxoZGucOVdH4G2E9QLZDqVyEu3xa8KnDcEQ/NhBRN5+WwebPcna7zYUHJ2r7JDoSTRKTwSg4Kh2/h++GLKy4xGCxmebWfEUDKSmtqRQvmWzknwNlMGj6M6R/YgdhrWCwoe0g2QBsi9YkCOJKkV9DJOqoX1UmJgOLOV2C3SrpZRaVbsM9EblydhSZsyReChQKm2zE56NDCperupL/Z4j5z+aR73uD8E5; 4:R6+nF01VRLYPhMqcFUc6tQ2VXoSDngJr2iKamFECL4XaKq7zqdIAOJIoiz+rCWq9q7AK+b2QxfzR8zXKK+WR4+gYQkrEcOOgHKbHsTak/h4eK5BT0BXEUc1HqZ/nKLJB+V++9OHrhM0vDRFntJM7wd+WTIzWAJO1D0f6LRM6OhZpX8vVIZhFes2KFH7cSRKu/BWg68zEI4FFk26Spjfn27EoJ6+DeN2wKa36M8guiVFy21jFD+v2D8cBEY5Nba2KX9dDtloHlkzuIF8mH5yAvg== 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)(10201501046)(93006095)(93001095)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB3268; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3268; X-Forefront-PRVS: 0830866D19 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39850400004)(376002)(366004)(136003)(396003)(199004)(189003)(2906002)(8676002)(50226002)(69596002)(33026002)(6116002)(3846002)(476003)(446003)(4326008)(11346002)(76176011)(7696005)(486006)(51416003)(386003)(186003)(956004)(81156014)(81166006)(8936002)(25786009)(2616005)(36756003)(14444005)(105586002)(86362001)(66066001)(47776003)(97736004)(16526019)(26005)(316002)(16586007)(52116002)(68736007)(50466002)(5660300001)(478600001)(48376002)(8886007)(55016002)(21086003)(4720700003)(6636002)(6666004)(106356001)(107886003)(53936002)(7736002)(85306007)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3268; H:mellanox.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-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR05MB3268; 23:oOiZMm/xUZ4drpk3z98SONGnUhlAsW2uOBPkgZjhD?= =?us-ascii?Q?Oqof42LJ8QtzIaAgMvnE7uph2ZP0hRkOw8TkkZVPQgCJ996tyEzoQug7vOgZ?= =?us-ascii?Q?P/lwTQFaRtZi+CmbJFxEpshG3tJWal1jc1zQy+35vMgb4vg2t3qF+cRCgGwB?= =?us-ascii?Q?b01kPoIGl36qSYCyigHXOgYA8xsQajh8NmqBgKJ2kgg1VnOprIkLXSYgbwjc?= =?us-ascii?Q?d/IQpNyaWWqhInse+6tn4fRMs1AVcpRVYLjWKqMY+Ms0yNDl28Du0YvMy2RP?= =?us-ascii?Q?DwETn12Q8T4qWQ5DjE91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A2WgCLmZEE5Ri8GiOQt0JUtSp5ku114bSEXA9GdYMyGeswj7H0MLsxl6hZ6wx0Bmh655fq0zsYy/JD3UK65zGZVctWWabBhGXjw/xw/TNKBb1i+4NsMoFL56Zsj4Jdg/g5a9q3MhURe4omWHuK9GdMsu6ixfLb7LEU=; 7:GDmkDXFbZYjz+D7YxS3hrmstd94LLmzkQfVVB2KEYrimnzAebkcVhPDh5JeePmR5QrFXbKpNPn4lBDGYLX50cQTqpx5Ar9L+nodo1CAAhAlsF+4j90fkR9yOPnuHbTAunHz7hweOfTlfBPoxZKSnaw8W07xIya2NxhHoCj97XkR0YXahYjOMe0gVQJBDS4aiE6KD84/F/5iECPVcxgEG2rYlLXF6YxH/7EA8H8ggPXdNbqVCbr/CjrP6hIFslmxS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2018 15:21:47.0804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68a9cd4d-c434-441e-2b05-08d635d69609 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3268 Subject: [dpdk-dev] [PATCH v3 5/6] net/mlx5: flow counters query function move and rename 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: Fri, 19 Oct 2018 15:21:49 -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_flow_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 @@ } /** + * 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 = data; + uint64_t counters[2] = {0, 0}; + struct ibv_query_counter_set_attr query_cs_attr = { + .cs = flow->counter->cs, + .query_flags = IBV_COUNTER_SET_FORCE_UPDATE, + }; + struct ibv_counter_set_data query_out = { + .out = counters, + .outlen = 2 * sizeof(uint64_t), + }; + int err = 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 = 1; + qc->bytes_set = 1; + qc->hits = counters[0] - flow->counter->hits; + qc->bytes = counters[1] - flow->counter->bytes; + if (qc->reset) { + flow->counter->hits = counters[0]; + flow->counter->bytes = 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 @@ } /** - * 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 = data; - uint64_t counters[2] = {0, 0}; - struct ibv_query_counter_set_attr query_cs_attr = { - .cs = flow->counter->cs, - .query_flags = IBV_COUNTER_SET_FORCE_UPDATE, - }; - struct ibv_counter_set_data query_out = { - .out = counters, - .outlen = 2 * sizeof(uint64_t), - }; - int err = 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 = 1; - qc->bytes_set = 1; - qc->hits = counters[0] - flow->counter->hits; - qc->bytes = counters[1] - flow->counter->bytes; - if (qc->reset) { - flow->counter->hits = counters[0]; - flow->counter->bytes = 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 = flow_verbs_query_count(dev, flow, data, error); + ret = flow_verbs_counter_query(dev, flow, data, error); break; default: return rte_flow_error_set(error, ENOTSUP, -- 1.8.3.1