From patchwork Mon Aug 20 13:34:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 43791 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 39F742E83; Mon, 20 Aug 2018 15:34:55 +0200 (CEST) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30055.outbound.protection.outlook.com [40.107.3.55]) by dpdk.org (Postfix) with ESMTP id 2E8FC2BC1 for ; Mon, 20 Aug 2018 15:34:54 +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=kfFLDV+YN2MUymwIcDzZcyPZt7iyfukFZCXbir39RwQ=; b=ctAYMxAugYi9i9nFNSp1pp3hMl5V77Q4zk0shjEtv1fXGysdu3UaGgUGcSsyRxWb4ctlgYIdCCjdcACLDzeGA1JQ+qeRc2IHmcWrGZ1443cjDax+9A3kp9LVkdq26nv3doIGsDPsGL8nzeIJquXiFCBtKxHSCpkxFHD9RPFfZ8c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=viacheslavo@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR05MB3280.eurprd05.prod.outlook.com (2603:10a6:802:1c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.24; Mon, 20 Aug 2018 13:34:51 +0000 From: viacheslavo To: dev@dpdk.org, adrien.mazarguil@6wind.com, thomas@monjalon.net, ferruh.yigit@intel.com, shahafs@mellanox.com Cc: orika@mellanox.com, viacheslavo Date: Mon, 20 Aug 2018 13:34:39 +0000 Message-Id: <1534772079-6514-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1P189CA0001.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::14) To VI1PR05MB3280.eurprd05.prod.outlook.com (2603:10a6:802:1c::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 551e1af0-b835-446d-cfeb-08d606a1b585 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB3280; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3280; 3:JHThpRDibqaeU0kijXhT8TRQ3mW3lj290+kWx0jk9eJbV0Sp69eQmvtGbzVt7Vrxyk5sQsaXO81A4jhZkdC/ZvtlwcCITnZra1f3jOYawDDHIaBtdbpba5A6pr58PlgQNw4B+/pzc3oH/qa8zKQgwAAhZHDVSWSf78SUqf43mCda1K8i9AtOExwyWcHMX1EO0qoiU4zB43DBu3gVjVbWCv0MRoCXCenk6JxY9KocvbJwJzhq68SQFRON2RSbxZ6V; 25:4JuaAAsVT5csL1iDlgkv/XJ5tF7fdGC1AsFMc6UKHHEPRwyvmu4Y9Lz9nEJ+zzzScDNPvQtKxl6TkfP0uD8Xbpx9WheyBUDyIFgFmPbWGyLcyEO2z0zBZRqC/MiZr0coV+5Bx1fsDxOS29D8lYK/JOIPisjQI58x56oIr+KboQI1aKQos5MDhBGqtHqp85KDOi4pKt3Zwl5WVgkTUI840qJyELoav21k9AP2abJaktS4YabDaWSK9f/DFQnkrpfXF63s0DZXGKkzSj61zpXETIyHWXADgLnAx6rq9WjxF+CQTa7uSmmIao6uspbnvGMmbeRQnSs63cYVtDjp0a2uVA==; 31:iXcXx9WFL2K54zRvHIPjUSHcor03CGnAWRTfNtDcwNgzHHiXESArjl8UAv6JXtM0oPnTP+oLi21mE9ITjiW+u4Zs1VkVSaQ9C3hsuMV+4J52z0ClWjnsnY11Khck3K0aIS7FkJyINpWPIBP5vT57btserIUBrKg9iW0hZF87lpp8I/IYYuSoRIxczKVmgQkfT8idtRFfPlV/jRR720etaSTbG+xMmEtowAwg9Qco7ZA= X-MS-TrafficTypeDiagnostic: VI1PR05MB3280: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3280; 20:tXko3/DQOxn4yO7TeL6Bdiile8TxO7YkJkNoycu9GPKoebUa3BKBdzTBWJJEeQGUl6GYvdqRNHjSGw2ycdpG0iZx2694Lydnm4++8Je+0tKK8K9a6ueuDqHd1FzDhVfZTeFDhnkRa6n8zE31jY508TDPza/onJ+uLsTckDFFX2Xt4Chax+aWoJFz3HNymqzlLYAEAz3bUNJ/QXe/yvIhMNATUIs7GrmJ25UYLc+98BYpED5AVYbiSiEjempQcXQDO5uYLrzvP906R0josqN7zLe4ufF/78AOlqm57YkNqU8YzT38q99rINFNGMvv1I8gAD1rEjTvSYempTtiX3xzKCP6LKtTwIpJzNZo9sMEmmZT1oRAHQac/EsvbJbdEnHIzqU4fSyU4cnKjg1tGWco4bLG3QUkpsR9qwVoWoqSOT32u+f4X8XHaqmbIdqKOBVpspjLRLqE1wmfa3u4DG2Q6E6wgWwpQdaiidinzKys4MTiEQ36DtHtxRCH+XsXZOE/; 4:3uxtuvTRbcjuOzq6nVNKgE3fKoIJnLJccCjpe9ZiMDtEI0wXvFCQlknwYBuY2OyNsfu2q3FRSC0zXr+iVKPEoIV5cfcidpPo1cB80vD5YbM0PdrcHyX/D3HGW7qdEVs2BL7qsATDiZ2RqzSCkSb1XUzbw8d94IjGvcFYmTF9B0m9l2cxWF+Ye5Q2eUJ1VQolJHtin7SGkqs4kmeprTA5EFvkGMQM7g8pCRBPeeqsNEfjOoZiuMHCPSgjJeUfZxfLM/lKMb46fx5oGDDxqc0kag== 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)(823301075)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699016); SRVR:VI1PR05MB3280; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB3280; X-Forefront-PRVS: 0770F75EA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(376002)(346002)(136003)(39860400002)(189003)(199004)(81156014)(16586007)(14444005)(97736004)(5024004)(2616005)(956004)(81166006)(476003)(478600001)(2906002)(486006)(316002)(47776003)(66066001)(36756003)(68736007)(16526019)(8936002)(186003)(33026002)(50226002)(50466002)(26005)(48376002)(8676002)(6666003)(53936002)(7736002)(386003)(52116002)(51416003)(7696005)(21086003)(69596002)(305945005)(4326008)(25786009)(5660300001)(106356001)(107886003)(4720700003)(55016002)(3846002)(6116002)(105586002)(86152003)(86362001)(6636002)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3280; H:mellanox.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-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB3280; 23:oVdCi2ER/J2DDciLv7IVTC8nLulbcV1qZ/aOY65r9?= R35ADhYtnx12uEyKzDAs5TZNyrIYms/8jRXYyWTnpM00wZTJFc7J9nI3AdD1ODi2KSIvSZX5zOEWarof9jUtzCLU8x0gq+0ln/VAfvZ6qg2HavC1gnUbBO1+wTIUnpABDWNksCcyIWrWEF2OsXkh6D/h/cVqzwn+aY1gM3WfGw8lDc4r1JVYx+Nn0FxcVCLTVoSFll7RsCKKtAx89NnRSsxN7PEEM0NV319AUmof85gGWIT+S0bMotYdCdxuwT0IoTWSAMnnE4c4OGquu1N9AwjX7NScQZryCbAB/pdcnTkOlRPEoxeEU+aWZKGO/gSRN26CvJk9T1PJbGx2iRjZ5q6u/F84rHHso2MtYTNus28RY7t0X6hMa99QHe3LKI7YRLTVkwWtoBE4bF2MJOnTx+wcdFv71O2xVPIuGa9fTBL9lx98CbPw1beP9b4MhaIxziSftmczlp2pdKSczBxCP3KRoxfnynxPsZupiq1jE0gKR47K6AlJQrKMtgGxbpzuvZkIOzS7QNOEzn1qWpwupzvCPNtTWN1KLYAs+njCQ/3cD/rvcM60OHeL/ND4FfHBgRosyw4vvIuvSXdrusYc31+wEnABifyaQCLa4Kt1m/UjrM4yh/hk6/TCh92NV8otPEILTRqQOHWLwiheCBLWhhEMIA9AMX+VxSMogzjUFPqpSNwxBq2eCKbSjCvMESdeLT8ioGUh93FU15mE51PXcSYf6ViPe0+4Gjkak7YJP/+iZiwsTfLB6Mt43ICl+xh/awc4+bXT1nLU9Z+9bY9kG31ehZr5pz1AdGsrqc9MkTcfentYq10lxxKvvvpUt05TMTv5nPIv405SoB0l3j5sBRTMMSngVMCkK+mnsY0hhrE5j81dA1Q7qMImPPA+LVBYNY7d/Kw5J5gDzfP7FsWbPN9qeMtnNqSi/0zW9RvRJMepUmS61vfSWvrxySxRT9aNdc3YibAgh2qR5/29iXYetI06DCCgEhQGb2pnJ3rYfiyeQ+LGUnmA/7zEJQW6w3q/Sc0ihoNn1oVm0mgKuQUTGUTl4WnQp83u7eqbA+tGrRvfIB1/fVSqaT82nDIoTsi30+qHKzae72B+Pi594oqQMhyujdmRJskV2uOALT30iSK49nhiEZWKUKUMhB/oHyxmCFGFGmOEyvlgsoK3EJjrxdlG3RPCthCQZMa4lHGdZPkkvRWSg+fRI2/LRq5j5GQ4QHHhV5FLrDOeVetmSkcuRbRalK+5pbh3QoktV+x+AVXTw== X-Microsoft-Antispam-Message-Info: 6ILp6B+5KkQ7BqU7mni4JC0PdA//IopZT8LPivX8sx+VmvIwDI1D68WmRn0A1WXFhq74z8ud6n6lk/SfQNRlXLJiEIDbjqBHIy325irhsgiKAsN1lv6kstI75yrg3R7UTaz/TfPXWClHHbJFieblExOPWajmkcxQQRRNIsu2lIcsasfztZFn9r1krJbjt/UcmTZDDiBefVKaq1TVzwRXImGng5S/GljOoyTPEpzTf3QohnJhZpUEUBvXjrt/FHN2rzxKshSD8+i+NdIzWMB6VDCDtF7OXQ2rSRpbj0ArXkgwFabxNOOIxyh9ChREaT5d7SOl+Nh7TpXdjHTL/ydt5hIS3c/yGNcpQSFXI4VKzsg= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3280; 6:Nf5VjZlLP009yrR0tJTCmI7syu9jstjmkmLOx08PJZxIobVyvQoIQweDdVYTS77d5e0v6odntcV1ES05EGPL53zW8gqt6DpK+URZ8E52jp12XRON4+MZywJNr1OADjOVIPbBOOk6EKDO+g90yMv/A/KeidR696FAuDOkpxk+th/MBQI5NJT8xq6d647ym4ofyMyoHJiETX0masIdbTuTziItHILyMUquk0MqxF6mGybOCQDMVEqEBd2/GR0GNFgbVgUfAvTt0wvQEhoXvoE+pTKfcXrlEEL8w7BgQXRMZoXsEYzX2K2eenba0uznIk0YlrEwOiNTZCtNXb97gRWpga+ygSq2OIpW7z7gILZmMs46BRl5lQm/YDEVUsP2rpn3yf0PCHW8lGbV0WHXLS+eHBEMcIRx4PD0D0rkXvBNf11y7jOVu6D1WV2nepklSdNq3N4JMcUNTlqb8VuvEylxkA==; 5:0Gk+a/AJ3w3NfF+rCdrrtY2q5ZqZGecmOFIss2TMUY0M5ilmEsILk1toSiyoWbRVSDN8GdFNVkm6e8tJRMh1IY6NidXf0m95ysIxBhQFrN1Ac65Bj6ivy/igL/wil6iahSOs+7rnXvPPOXnPUQETl1fG0AIg9z414eiDZixuhhQ=; 7:ZtTinz7EFI43vasXIHw6POurdc+Ty+ZdWZKAcfckXhQNKh1vgvNyQ75D+KhXJxJg/HAy/QmEQthuqxjwg+nsT5g/G7+ZltgovSF6nvV+Aj41G6Qb9HcMt0lBhvEJ8uQiMTZizn9xBluj+K2h9XUcO0f5O7Ir3hbUyg65t5BLvqtRobdObSeRE6pf+1hIGxU6h2FdPhjE0VAtnaTzPm7bxg0AaFAnLT7fq83YmcSNFFLqQaaICE0sOUgT7Yo5YAGI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2018 13:34:51.4313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 551e1af0-b835-446d-cfeb-08d606a1b585 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3280 Subject: [dpdk-dev] [RFC] mlx5: flow counters support on the linux-rdma v19 base 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Mellanox mlx5 PMD supports Flow Counters via Verbs library. The current implementation is based on the Mellanox proprietary Verbs library included in MLNX OFED packages. The Flow Counter support is recently added into linux-rdma release (v19), so the mlx5 PMD update is needed to provide Counter feature on the base of linux-rdma. mlx5 PMD can be compiled with MLNX OFED or linux-rdma v19 and provide flow counters for both. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/Makefile | 10 +++++++ drivers/net/mlx5/mlx5.c | 6 ++++ drivers/net/mlx5/mlx5_flow.c | 67 ++++++++++++++++++++++++++++++++++++-------- drivers/net/mlx5/mlx5_glue.c | 41 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_glue.h | 16 +++++++++++ 5 files changed, 128 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 2e70dec..ca4c143 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -155,6 +155,16 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh type 'struct ibv_counter_set_init_attr' \ $(AUTOCONF_OUTPUT) $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT \ + infiniband/verbs.h \ + type 'struct ibv_counters_init_attr' \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ + HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 \ + infiniband/verbs.h \ + type 'struct ibv_counters_init_attr' \ + $(AUTOCONF_OUTPUT) + $Q sh -- '$<' '$@' \ HAVE_RDMA_NL_NLDEV \ rdma/rdma_netlink.h \ enum RDMA_NL_NLDEV \ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index ec63bc6..ad289f0 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -730,8 +730,10 @@ unsigned int mprq_min_stride_num_n = 0; unsigned int mprq_max_stride_num_n = 0; #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 struct ibv_counter_set_description cs_desc = { .counter_type = 0 }; #endif +#endif struct ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id = 0; @@ -1001,11 +1003,15 @@ DRV_LOG(DEBUG, "checksum offloading is %ssupported", (config.hw_csum ? "" : "not ")); #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 config.flow_counter_en = !!attr.max_counter_sets; mlx5_glue->describe_counter_set(ctx, 0, &cs_desc); DRV_LOG(DEBUG, "counter type = %d, num of cs = %ld, attributes = %d", cs_desc.counter_type, cs_desc.num_of_cs, cs_desc.attributes); +#else + config.flow_counter_en = 1; +#endif #endif config.ind_table_max_size = attr.rss_caps.max_rwq_indirection_table_size; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ca4625b..4d762dd 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -290,7 +290,11 @@ struct mlx5_flow_counter { uint32_t shared:1; /**< Share counter ID with other flow rules. */ uint32_t ref_cnt:31; /**< Reference counter. */ uint32_t id; /**< Counter ID. */ - struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 +struct ibv_counters *cs; /**< Holds the counters for the rule. */ +#else +struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ +#endif uint64_t hits; /**< Number of packets matched by the rule. */ uint64_t bytes; /**< Number of bytes matched by the rule. */ }; @@ -519,27 +523,32 @@ struct mlx5_flow_tunnel_info { static struct mlx5_flow_counter * mlx5_flow_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id) { +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT struct priv *priv = dev->data->dev_private; struct mlx5_flow_counter *cnt; - LIST_FOREACH(cnt, &priv->flow_counters, next) { - if (!cnt->shared || cnt->shared != shared) - continue; - if (cnt->id != id) - continue; - cnt->ref_cnt++; - return cnt; + if (shared) { + LIST_FOREACH(cnt, &priv->flow_counters, next) + if (cnt->shared && cnt->id == id) { + cnt->ref_cnt++; + return cnt; + } } -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT struct mlx5_flow_counter tmpl = { .shared = shared, .id = id, +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 + .cs = mlx5_glue->create_counter_set + (priv->ctx, + &(struct ibv_counters_init_attr){0}), +#else .cs = mlx5_glue->create_counter_set (priv->ctx, &(struct ibv_counter_set_init_attr){ .counter_set_id = id, }), +#endif .hits = 0, .bytes = 0, }; @@ -548,17 +557,40 @@ struct mlx5_flow_tunnel_info { rte_errno = errno; return NULL; } + +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 + struct ibv_counter_attach_attr attach_attr = {0}; + int ret; + + attach_attr.counter_desc = IBV_COUNTER_PACKETS; + attach_attr.index = 0; + ret = ibv_attach_counters_point_flow(tmpl.cs, &attach_attr, NULL); + if (!ret) { + attach_attr.counter_desc = IBV_COUNTER_BYTES; + attach_attr.index = 1; + ret = ibv_attach_counters_point_flow(tmpl.cs, + &attach_attr, + NULL); + } + if (ret) { + claim_zero(mlx5_glue->destroy_counter_set(tmpl.cs)); + rte_errno = ret; + return NULL; + } +#endif cnt = rte_calloc(__func__, 1, sizeof(*cnt), 0); if (!cnt) { + claim_zero(mlx5_glue->destroy_counter_set(tmpl.cs)); rte_errno = ENOMEM; return NULL; } *cnt = tmpl; LIST_INSERT_HEAD(&priv->flow_counters, cnt, next); return cnt; -#endif +#else rte_errno = ENOTSUP; return NULL; +#endif } /** @@ -2307,7 +2339,7 @@ struct mlx5_flow_tunnel_info { flow->counter = mlx5_flow_counter_new(dev, count->shared, count->id); if (!flow->counter) - return rte_flow_error_set(error, ENOTSUP, + return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_ACTION, action, "cannot get counter" @@ -2320,7 +2352,11 @@ struct mlx5_flow_tunnel_info { "flow counters are not supported."); flow->modifier |= MLX5_FLOW_MOD_COUNT; #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 + counter.counters = flow->counter->cs; +#else counter.counter_set_handle = flow->counter->cs->handle; +#endif if (size <= flow_size) mlx5_flow_spec_verbs_add(flow, &counter, size); return size; @@ -3373,6 +3409,13 @@ struct rte_flow * if (flow->modifier & MLX5_FLOW_MOD_COUNT) { struct rte_flow_query_count *qc = data; uint64_t counters[2] = {0, 0}; +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 + int err = mlx5_glue->query_counter_set( + flow->counter->cs, + counters, + RTE_DIM(counters), + IBV_READ_COUNTERS_ATTR_PREFER_CACHED); +#else struct ibv_query_counter_set_attr query_cs_attr = { .cs = flow->counter->cs, .query_flags = IBV_COUNTER_SET_FORCE_UPDATE, @@ -3383,7 +3426,7 @@ struct rte_flow * }; int err = mlx5_glue->query_counter_set(&query_cs_attr, &query_out); - +#endif if (err) return rte_flow_error_set (error, err, diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c index 84f9492..b2b39ad 100644 --- a/drivers/net/mlx5/mlx5_glue.c +++ b/drivers/net/mlx5/mlx5_glue.c @@ -211,6 +211,39 @@ return ibv_dereg_mr(mr); } +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 +static struct ibv_counters * +mlx5_glue_create_counters(struct ibv_context *context, + struct ibv_counters_init_attr *init_attr) +{ + return ibv_create_counters(context, init_attr); +} + +static int +mlx5_glue_destroy_counters(struct ibv_counters *counters) +{ + return ibv_destroy_counters(counters); +} + +static int +mlx5_glue_attach_counters(struct ibv_counters *counters, + struct ibv_counter_attach_attr *attr, + struct ibv_flow *flow) +{ + return ibv_attach_counters_point_flow(counters, attr, flow); +} + +static int +mlx5_glue_query_counters(struct ibv_counters *counters, + uint64_t *counters_value, + uint32_t ncounters, + uint32_t flags) +{ + return ibv_read_counters(counters, counters_value, ncounters, flags); +} +#endif + +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 static struct ibv_counter_set * mlx5_glue_create_counter_set(struct ibv_context *context, struct ibv_counter_set_init_attr *init_attr) @@ -262,6 +295,7 @@ return ibv_query_counter_set(query_attr, cs_data); #endif } +#endif static void mlx5_glue_ack_async_event(struct ibv_async_event *event) @@ -378,10 +412,17 @@ .modify_qp = mlx5_glue_modify_qp, .reg_mr = mlx5_glue_reg_mr, .dereg_mr = mlx5_glue_dereg_mr, +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 + .create_counter_set = mlx5_glue_create_counters, + .destroy_counter_set = mlx5_glue_destroy_counters, + .attach_counter_set = mlx5_glue_attach_counters, + .query_counter_set = mlx5_glue_query_counters, +#else .create_counter_set = mlx5_glue_create_counter_set, .destroy_counter_set = mlx5_glue_destroy_counter_set, .describe_counter_set = mlx5_glue_describe_counter_set, .query_counter_set = mlx5_glue_query_counter_set, +#endif .ack_async_event = mlx5_glue_ack_async_event, .get_async_event = mlx5_glue_get_async_event, .port_state_str = mlx5_glue_port_state_str, diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h index e584d36..c5ff3cb 100644 --- a/drivers/net/mlx5/mlx5_glue.h +++ b/drivers/net/mlx5/mlx5_glue.h @@ -89,6 +89,21 @@ struct mlx5_glue { struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr, size_t length, int access); int (*dereg_mr)(struct ibv_mr *mr); +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT_V45 + struct ibv_counters *(*create_counter_set) + (struct ibv_context *context, + struct ibv_counters_init_attr *init_attr); + int (*destroy_counter_set)(struct ibv_counters *cs); + int (*attach_counter_set) + (struct ibv_counters *cs, + struct ibv_counter_attach_attr *attr, + struct ibv_flow *flow); + int (*query_counter_set) + (struct ibv_counters *cs, + uint64_t *counters_value, + uint32_t ncounters, + uint32_t flags); +#else struct ibv_counter_set *(*create_counter_set) (struct ibv_context *context, struct ibv_counter_set_init_attr *init_attr); @@ -99,6 +114,7 @@ struct mlx5_glue { struct ibv_counter_set_description *cs_desc); int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr, struct ibv_counter_set_data *cs_data); +#endif void (*ack_async_event)(struct ibv_async_event *event); int (*get_async_event)(struct ibv_context *context, struct ibv_async_event *event);