From patchwork Tue Oct 23 10:04:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47224 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 425071B1FC; Tue, 23 Oct 2018 12:04:15 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70055.outbound.protection.outlook.com [40.107.7.55]) by dpdk.org (Postfix) with ESMTP id 60D6D1B119; Tue, 23 Oct 2018 12:04:11 +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=1I1/gp05ITbNWr48u+k9oHhwW+5T/VNpGR7M5Gogq30=; b=iDXqLPUPqEeNGg5ibELbVLj8lt27Rmuum0yWQJhJygtHAuT8xY51sEDJbvE0bu2e1z4aVT/3d+kktwgFQH/J5fMOwQmGJ8v0WirSo7KCJP9PQBJYQv70+4oSAzxoQKGUJ69V+zfHjkdssctj8BhrBmbGYRBlBy+NBv1wnOkgMqc= 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:10 +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:10 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH v4 1/8] net/mlx5: fix flow counters creation Thread-Index: AQHUare+Bhz3uSeTjE63OIOzOnUQOA== Date: Tue, 23 Oct 2018 10:04:10 +0000 Message-ID: <1540289032-29628-2-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:RLnGhODNSn2S2gWPexSmMwJ6s00xvjiFd+fCJ/Ot4c3lZAKIffEN1bdzy4PU0i9BXtFnUGmImq4A3Tw6ForDIlRn+uD77W1fuM9L4DlA8RxHMYxRZC0Y0LI5u+khWWLtiWFAk4K2t016d449yTlRBIDjxmiXLZmavYyZVx2VywIvhAXYKsiLDnQFtTBf6Fw9uUKnrRQxq+balgsr33wd1BYz/TyNoO0KJglFoe14Pd4tSkvnOnysvUR4RNd/SnknxDqq7JoWxntkFcctBex0nax0HNinG1ezdcpMhTGRtc/yXcFJNE2zzrKOlP4uCyW3rUu2f2+bXLYhurFIFWb35XcwlI7Tw8X47eQ4QzcZoXFcPrzP0dGQu7xCcNciQ51jl3wWK7+HoGdHRW2m4e4WcQ232mcRZSpcINiBBtCRfm4S80lUAa8NV1SKIEOBU8agEXGLxnzT8/XXbCCAWSmYcg==; 5:YnqYTGOaRiQhKtwI5Kl+fk2K8SZQ52Fmgi3+Ky+oBqIRjE/Dddr4MBgAaOVeXaQ5mbmVqd3tWv0C5vPaphdakOQU9KwxMHPWtZvHlHFkGdnnumg+1izhIsKHOMpTXcAe/fmCJNfGvNKXvijfYCbDHCfl/COm5gJjzfXqiO2zr7A=; 7:u0C+8fT7WwhLc8V094c5IZGTIKg54ztJ2fIYdbltx4Cno0m3l3czIlRaHkMEghzVQ+otFKw9wF1BaRab+wsrdQy5c+uKWczF+jVaCuVpUf/tgJPBd9I/jwi04vmsKV3SQLX7KSxU9wylA8iqvZKlCO8L+IYcUfy6wwRnk0CLLlbWIEjI9FlSDQn1nzYLtK5OkWqsskPOJEiUzY4ZF2DBbCCMR3g6KtAmmxhUJrw7vfoKzfN13LxZugV5PBsU7v0K x-ms-office365-filtering-correlation-id: 5fe7f83a-467b-4f56-6359-08d638cee098 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)(54906003)(86362001)(36756003)(2900100001)(5250100002)(7736002)(305945005)(14444005)(6116002)(6486002)(105586002)(7049001)(316002)(97736004)(68736007)(71190400001)(52116002)(102836004)(4326008)(476003)(25786009)(450100002)(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: y6Wx3pHDwivVkcfle6ZJZfF2Tooyp644nQqFIwHPfTFzIWYM7cHgNHmcsP5IoexWUslTxqSXxMuvhZufhmHfRK9CdGEd6x+RskvD/aP4TRflB2JOOdOAMtXfgFFRCNUhd1B/dnm2FGTgQd21AjWvzw5mFe3BYcpmAYs1Cdi5u1qvkvzoYRMoMoV4JGSr/Iutfs7GiufOMZj9vH5OeeudjrupAPZOqzheZRxyDuc/qqcx78XiIMPXrTgpXwqXz4+NMeWYzRX3aQn14OafzNgcJJA0SSrVx7ZWXWd2phzOM6YmjgvytgfsZc/nT9kyewn2dOJ01NKU/Plx35WyOXWieWyOwajFh8RmG8F0CGQk6mM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fe7f83a-467b-4f56-6359-08d638cee098 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:10.5468 (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 1/8] net/mlx5: fix flow counters creation 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" The Flow counter creation function contains two problems: - Flow counter object in Verbs is not freed in case of memory allocation error. The call of counter Verbs object deallocating function is added to fix. - The initial value of reference counter is set to one in order to provide the correct counter object freeing in the flow_verbs_counter_release() function. The reference counter field should be initialized to one. Fixes: 60bd8c9747e8 ("net/mlx5: add count flow action") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_verbs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 4ae974b..6ddb13b 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -72,6 +72,7 @@ }), .hits = 0, .bytes = 0, + .ref_cnt = 1, }; if (!tmpl.cs) { @@ -80,6 +81,7 @@ } cnt = rte_calloc(__func__, 1, sizeof(*cnt), 0); if (!cnt) { + claim_zero(mlx5_glue->destroy_counter_set(tmpl.cs)); rte_errno = ENOMEM; return NULL; } From patchwork Tue Oct 23 10:04:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47225 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 575351B3E8; Tue, 23 Oct 2018 12:04:26 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40083.outbound.protection.outlook.com [40.107.4.83]) by dpdk.org (Postfix) with ESMTP id C800D1B137 for ; Tue, 23 Oct 2018 12:04:12 +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=sJtPIZ9HKOykGFiDp5Y8heZLVfbhAlmhqGjPtx2MORw=; b=hyLZxCVrsAUVOZjRZCTLe5QD0EWfEf+ttwztyKwg1IlMe/1bSJD8CGqYsE3lsCdIPANjmG1oDSIX9uVezjNsYa7QepQov40rFIbpUlbIu6dpQ9X/juRimsUZPWI3gMx+NNFr1W4sLj4lJRmSIu00PvF2la3pcG5vsu67r1nmohY= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB1619.eurprd05.prod.outlook.com (10.165.245.138) 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:11 +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:11 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 2/8] net/mlx5: rename flow counter configuration macro Thread-Index: AQHUare+bKIUHzQ/cEyKGhyggk3R6g== Date: Tue, 23 Oct 2018 10:04:11 +0000 Message-ID: <1540289032-29628-3-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; AM4PR05MB1619; 6:Fn5iyL5xJQfQNOQZHWXQkLN7hrn0SUvB920jALUixeCJ1LnRxcns0NW0ijOhbnCbXlRuuYSKYpWrZ6pT/0H3wMiep53fL08hgRfCS251rCYvDFduONEgxTN+fxdkWVtu/WEgQ76sZR9zvi5jfWj4TKU0LZ14ffHK0co7NIi5mbtroGVE3244+CiwHPN82yQg/klxjmhQFXc4+8yEtN26TKYk+S8V1oxihEu1Pz0n/g/OYBRG6w+v2OpkkzptjInZQVYKtSsr0dOxaq1waYYrNWO0uBcjzaSBWx3vPbNwYwKY+/ZjoUVuvohsBvnUdENjMDqNxHpdcgR7VYNuGiBMxO13dEJxOWz1Ax0iAnzgwGksW0ls/bL3NszzPpC1tnog+lgbPhkHYK/maCoPugWO1l08SXCC7wPP2oviqdGQ0rseMMZs+FI9HlaLA2e+TLnnMnleXWyeinTTiBMgFvweuVke+WpVqKP5InAYu5af6xw=; 5:b8yLA+LiLdJ8oP8ga2oAThSf9OQRFbK1ABzwcqPFEa56rH/4LShfSBgLoMIy6Mgy5FtT9JwIp9iRY29kh1SQ/W/m/HhDLOu8vzqj+qczEKM8t51XJWCRbUPZvYuQ95FAXPZC9kNX6jr2cjJZP6z13d2wsfTqpsz4NYxtg183BRQ=; 7:v+m9lgkS6Dn5jEcJKIkUukWi1VRx+mk5HCy98IU+K+3bAUGhA4/6KrGWRQR/nDf0/zq9tqr6kow+26ze3+hXY3OMpAh8Q4Ubb6Ce6ZI2hN/VAuBzI6llps8hxln+Gsqscv3nw2jrkT+OfcBQE1Bnn2GSOgzuuXAO1ly8arwWnTTlwD7lu6Hs8oxgD4kztswQ2bUlxCUTssjVY5L7ag0xXeLeYbyLOAqmdtoBq/iVXPQKIGLqj4VY2p2ZndX+57b3 x-ms-office365-filtering-correlation-id: a0baf08e-6cc2-4eb0-0855-08d638cee10f 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:AM4PR05MB1619; x-ms-traffictypediagnostic: AM4PR05MB1619: 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)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB1619; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB1619; x-forefront-prvs: 0834BAF534 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(366004)(376002)(136003)(39860400002)(189003)(199004)(102836004)(6512007)(6116002)(6436002)(53936002)(11346002)(3846002)(99286004)(5250100002)(6200100001)(71200400001)(71190400001)(6486002)(26005)(186003)(66066001)(97736004)(52116002)(37006003)(106356001)(446003)(105586002)(68736007)(7049001)(316002)(6506007)(81166006)(8936002)(81156014)(305945005)(2900100001)(7736002)(386003)(4326008)(256004)(76176011)(8676002)(5660300001)(19627235002)(36756003)(575784001)(478600001)(14454004)(6862004)(476003)(86362001)(486006)(25786009)(2906002)(2616005)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1619; H:AM4PR05MB3265.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: O9+E8vfnb/XEQvWcBa9r7WIvQeJ5cLh55os73075KuW6XFSwxbkcGi/CvdxNAy4eAL0osnXbEa9WYYrbJiMpPPVnjRWfdGBQp4QnPR/mcuIgMB5ejZZePAnvL3p7y+OoeWxmG5ErzTMTV9tT585+TEMW2TuFuU4fcPaL83lWuCMRC+wcYM7TFRoA/iuCvEBkMIqMEDyOkRidtE+1EB5NAJx2uOlZWC6rz+75wFxMuKDfW4NDTKLejLQp3fmGMkUV70P94fRwjqTC1xLrNb4JnTQPQdQo6xdixLs9FqcuOFnJstAkcHeGj/8ZrZglXTm3ZPT7+3weeTh3R1LYy0TpwNg+yQIeyf2tU/L0LrdnrEY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0baf08e-6cc2-4eb0-0855-08d638cee10f X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:11.3633 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1619 Subject: [dpdk-dev] [PATCH v4 2/8] net/mlx5: rename flow counter configuration macro 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" The HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT is replaced with HAVE_IBV_DEVICE_COUNTERS_SET_V42. At this stage it is just macro renaming. This macro is defined if system supports the "old" Flow counters functionality, MLNX_OFED version from 4.2 to 4.4 is required. We need to do this preparation before introducing the new configuration macro (HAVE_IBV_DEVICE_COUNTERS_SET_V45) for the "new" Flow counters support. Both makefile and meson.build are changed. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/Makefile | 2 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 4 ++-- drivers/net/mlx5/mlx5_flow_verbs.c | 10 +++++----- drivers/net/mlx5/mlx5_glue.c | 8 ++++---- drivers/net/mlx5/mlx5_glue.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 1e9c0b4..124ee4e 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -157,7 +157,7 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh enum ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT \ $(AUTOCONF_OUTPUT) $Q sh -- '$<' '$@' \ - HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT \ + HAVE_IBV_DEVICE_COUNTERS_SET_V42 \ infiniband/verbs.h \ type 'struct ibv_counter_set_init_attr' \ $(AUTOCONF_OUTPUT) diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index c192d44..e613a21 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -79,7 +79,7 @@ if build has_member_args = [ [ 'HAVE_IBV_MLX5_MOD_SWP', 'infiniband/mlx5dv.h', 'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ], - [ 'HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT', 'infiniband/verbs.h', + [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h', 'struct ibv_counter_set_init_attr', 'counter_set_id' ], ] # input array for meson symbol search: diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index cfff54e..cb86a69 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -739,7 +739,7 @@ unsigned int mprq_max_stride_size_n = 0; unsigned int mprq_min_stride_num_n = 0; unsigned int mprq_max_stride_num_n = 0; -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 struct ibv_counter_set_description cs_desc = { .counter_type = 0 }; #endif struct ether_addr mac; @@ -1009,7 +1009,7 @@ config.hw_csum = !!(attr.device_cap_flags_ex & IBV_DEVICE_RAW_IP_CSUM); DRV_LOG(DEBUG, "checksum offloading is %ssupported", (config.hw_csum ? "" : "not ")); -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 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", diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 6ddb13b..3d6fedb 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -60,7 +60,7 @@ cnt->ref_cnt++; return cnt; } -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 struct mlx5_flow_counter tmpl = { .shared = shared, @@ -938,7 +938,7 @@ { const struct rte_flow_action_count *count = action->conf; struct rte_flow *flow = dev_flow->flow; -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 unsigned int size = sizeof(struct ibv_flow_spec_counter_action); struct ibv_flow_spec_counter_action counter = { .type = IBV_FLOW_SPEC_ACTION_COUNT, @@ -957,7 +957,7 @@ " context."); } *action_flags |= MLX5_FLOW_ACTION_COUNT; -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 counter.counter_set_handle = flow->counter->cs->handle; flow_verbs_spec_add(dev_flow, &counter, size); #endif @@ -1222,7 +1222,7 @@ detected_actions |= MLX5_FLOW_ACTION_RSS; break; case RTE_FLOW_ACTION_TYPE_COUNT: -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 size += sizeof(struct ibv_flow_spec_counter_action); #endif detected_actions |= MLX5_FLOW_ACTION_COUNT; @@ -1665,7 +1665,7 @@ void *data __rte_unused, struct rte_flow_error *error) { -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#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}; diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c index 48590df..889e074 100644 --- a/drivers/net/mlx5/mlx5_glue.c +++ b/drivers/net/mlx5/mlx5_glue.c @@ -215,7 +215,7 @@ mlx5_glue_create_counter_set(struct ibv_context *context, struct ibv_counter_set_init_attr *init_attr) { -#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42 (void)context; (void)init_attr; return NULL; @@ -227,7 +227,7 @@ static int mlx5_glue_destroy_counter_set(struct ibv_counter_set *cs) { -#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42 (void)cs; return ENOTSUP; #else @@ -240,7 +240,7 @@ uint16_t counter_set_id, struct ibv_counter_set_description *cs_desc) { -#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42 (void)context; (void)counter_set_id; (void)cs_desc; @@ -254,7 +254,7 @@ mlx5_glue_query_counter_set(struct ibv_query_counter_set_attr *query_attr, struct ibv_counter_set_data *cs_data) { -#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42 (void)query_attr; (void)cs_data; return ENOTSUP; diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h index f6e4e38..adee972 100644 --- a/drivers/net/mlx5/mlx5_glue.h +++ b/drivers/net/mlx5/mlx5_glue.h @@ -23,7 +23,7 @@ #define MLX5_GLUE_VERSION "" #endif -#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42 struct ibv_counter_set; struct ibv_counter_set_data; struct ibv_counter_set_description; From patchwork Tue Oct 23 10:04:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47226 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 A97101B217; Tue, 23 Oct 2018 12:04:28 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60060.outbound.protection.outlook.com [40.107.6.60]) by dpdk.org (Postfix) with ESMTP id 3A0A11B146 for ; Tue, 23 Oct 2018 12:04:13 +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=kBCXJjOUyxjyrrLdmoj+vfCBQbkkuFLR0NVbwq06n04=; b=OdNM6aM24Aiyva+eoso2XVxtVxAmZvg4qoKpczuqTIK/wRXZGZlR3/9QQ2fkoNPVZBKzYuVAI4eRerYRicv7kuPnEcDcL8JpEXW6NS1a86lMy6F+YAgLz2U88xolrLPongYn43v0zFEPmgc7SLMn0tbPe9R+NOo63bggqS6R1YY= 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:12 +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:12 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 3/8] net/mlx5: introduce new flow counters configuration macro Thread-Index: AQHUare/A/o5TOk+okGNWqaWOTkY8Q== Date: Tue, 23 Oct 2018 10:04:12 +0000 Message-ID: <1540289032-29628-4-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:pSQcL4cyvs2klcB8Koh1ggzRSLruFcqRclJqjB9n1ayXVeksbRpwDbqyD0B1ixD+nyx6UbFohbHPnKnKe22bh/62uI+U6PMnIJ/0Ee4Y5cqbQSAiGGlKgJWwBfjCq+O8sJhpIoUKSNU1QmIPvWZ2LyW2V6atrBMxCTumC5Ll0co6fNv70nf6qlsoYUoOnVjnL2RAvyh2gisOXoisnEaoCVoitP8MslR1l4+G884+GNu8HQ0dnhGviB5ZAG8cTMvBIGp5m9hDU56R6JPdfnpznS3t15L9DUagxMtEwmW9v0cHEgvu4Tlsyoduo0Nr+Ou9HfEoZ/tJlXrNfpRapxG6WLCq/+H5gIt6/cbkp0Eapmo9xY72YlVqKd+X6uUJ2FEYGXzg4moJNRDNLAg8GVfE26xN8tmUPny8nIL53oPKZ8gYrQP0RoA9ZZO1U2xYbBlSl3k1rxYPMG9tdHMmH+AvxA==; 5:qglIBZmBPJwJWRSAaDmgg3hYySPlB74id5qumv786M6JtDszcHxtstfdG0m/9T+USUrDtpuzWA1rV0+NvTFsDVf7io8FKMO++ea7mUANttHpiBoNNpTqwvEquixr7nXjrlWjK4KYBDEmZVbvfvaoP5QQ3sjcNmH6QP2gXv2vDzU=; 7:UP8AZGUMUPNY2+5/ayb9+2dXhQ5N4nH+dtd28TLuav6TNkWNxaApe+tCbS8dlzcK3qB4JgQTC4z3Q8acqCKsI3e02Zj/UKqwi1UGM+R+DSutJiPDwHPTQQh7me0GcSfAT90BCi3MRIaqF+z9vmjOTb0zcLZngsfhaTiIvyQITtY4hh/8JKwjKGvj1QROk10NKPqZLJh+qNBKX95Sa5XnK2xKmUwSu7Z0GkVXCkj2k+mOdEohvl/qH628gFcOrrf6 x-ms-office365-filtering-correlation-id: 8d168d40-7cb0-4121-3061-08d638cee189 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)(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: u6EUcXpl0LcCdJCna79fYVINPgQL5S2PC8kMDY7mZAf7aS7LC4Pblb7TWcCupagu1SZkjjgMzw3YuQj50nMpCTOLr3nOlmcgW7GdUR5GJwe6ZZ99E8Zlwm4uSOL/lIXAIfKManjcTiVRaM1+3QqLVESxFnUanWaG9gA+jOh2BeInviwN2fbEMIYKQ2y+6uIcVHVEQJwY6X2WhvLzoEqt9L2KrlSYknmk+xziAKs3zRfrJF9N7BG/mqMfSHAwo/gabsAkOU5CZzRPCrLXW+RSPYL/jdK19UqSLrgRHLJ7YAs5tMs+vMyon4tRzHthZFJvu/XebqjHV+RZsOeK0LBnz7gfGkThW9CWyK5l6CxNPQo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d168d40-7cb0-4121-3061-08d638cee189 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:12.2369 (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 3/8] net/mlx5: introduce new flow counters configuration macro 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" The new configuration macro HAVE_IBV_DEVICE_COUNTERS_SET_V45 is introduced. Both makefile and meson.build are changed. Flow counter support code depends on the following configuration macros: - HAVE_IBV_DEVICE_COUNTERS_SET_V42 - is defined if system supports the "old" flow counters functionality, MLNX_OFED version from 4.2 to 4.4 is required. - HAVE_IBV_DEVICE_COUNTERS_SET_V45 - is defined if system supports the "new" flow counters functionality, MLNX_OVED 4.5 (or higher) or Linux rdma-core v19 (or higher) is required. Neither HAVE_IBV_DEVICE_COUNTERS_SET_V42 nor HAVE_IBV_DEVICE_COUNTERS_SET_V45 is defined if there is no counters support. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/Makefile | 5 +++++ drivers/net/mlx5/meson.build | 2 ++ 2 files changed, 7 insertions(+) diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile index 124ee4e..fecb57c 100644 --- a/drivers/net/mlx5/Makefile +++ b/drivers/net/mlx5/Makefile @@ -162,6 +162,11 @@ 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_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/meson.build b/drivers/net/mlx5/meson.build index e613a21..e8cbe3e 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -81,6 +81,8 @@ if build 'struct mlx5dv_sw_parsing_caps', 'sw_parsing_offloads' ], [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V42', 'infiniband/verbs.h', 'struct ibv_counter_set_init_attr', 'counter_set_id' ], + [ 'HAVE_IBV_DEVICE_COUNTERS_SET_V45', 'infiniband/verbs.h', + 'struct ibv_counters_init_attr', 'comp_mask' ], ] # input array for meson symbol search: # [ "MACRO to define if found", "header for the search", From patchwork Tue Oct 23 10:04:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47227 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 898341B471; Tue, 23 Oct 2018 12:04:30 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60087.outbound.protection.outlook.com [40.107.6.87]) by dpdk.org (Postfix) with ESMTP id 28F731B19A for ; Tue, 23 Oct 2018 12:04:14 +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=vXPwAkIkqPRucQ2IlWHVbcv6Te2FtielwA3TQyknt7I=; b=HiEqUaNVNqe3wvzB1EYOgAEgTTryyFprtns40EfF0LeKSVeZ5veV/532schje4YEkAk2dLf+H+mBF/VAucxPSdFk8hhXKptbPeL3d5n6GxC3cUrIujQtWpXC0BVYVS/Mm+jEZhkUVdrk7flBa2/B9sX63/EQCB/G00yez43ppws= 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:13 +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:13 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 4/8] net/mlx5: simplify flow counters support check Thread-Index: AQHUare/O2tIo9kmKkK88sd3BetAyQ== Date: Tue, 23 Oct 2018 10:04:13 +0000 Message-ID: <1540289032-29628-5-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:59NPa8EpNVJLZuiLFnakF/g6KrMKoDiQXu+CjjtCuNW0TUG8Am6w3nMAylVxKC4KyCcEUfS6nmrTQmmuUJvNqAhSaZS9vDimwHQ2Lk0QAOe1kd1Qa7A5AFGj/+GC4GGYGVdNd1G7YY4QsqWqkrthee74gD5e3WH8eXnttM8tdiyWh28M4SR5f822PXL48CQVeX5+1KVdi7x+QUmZ4VrYdKgz2E4/VUHU5eQMtI3XEQmPxgIRw6xGb64EXvF4zk8LG0aoVsJv3GL1uOZDM9WOkPZyaokRoZ8aPjB1Rc5Ge+m8VANYKXc4eMEh3kQrjRVZCUSjcttY/Fco1LwfYOP8UD3LNpKu5i3BTrez2Vip8tOPG9I6FY+hFBV9Lr0EwRDVzNyvv+ffhQFKlXoJGKE/o2b+yCWeYXNMqF4b7U6in2MXHUWU9rweJHSmpjyjkzr4zl5DXAvKZB1rAPtmJb7PVA==; 5:grtQ/muVMBSe+7mQx0yQuruKLT/bYW+VhuWes10ptqXYOmtr0UZTeRe4QIUY5lOjqVDFHwxUQYkDd4fF1SJCMurNkLxyjEwqc3bSatNdyGODosGkz8aKjQygJigoWiXQxxJqlz2GHMaDylid1TLQlpBi5NDdCjonyiKErv5YzpU=; 7:YoR6MKDIjyPePaYu4IVL0EQcekPd0jvOqKM/wh0rkyR76QHQIiqfQ4wFowgwvHzb5/CsdlUxg8+7q4rxqr2FU3k5u+cMO+b6VvOEkBYakAHn1SN3y1F2Y4azaOrf4bT72ItVJo2UOPxSc/DhBFHlzipLBXs/cx/zgznVH+5cmq5ezYDOQt5yPYiclBwUgCY/d1qwh4M182MSsQ76bWzYPUyEc7uQuP8RZcHQxVZjW7IBxcJMZF6cYMS8Puts84zX x-ms-office365-filtering-correlation-id: dd6656a2-bc27-4a50-ddd0-08d638cee20f 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)(309714004); 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: rR+KHAXiq7yM2v5l3WQhJy2xHTeITLse056Y93hUxv3aDgWUZCsKfa7QsBtPXMSssp0qC6Q1uFIICnbaZRiKwZKvn945cDGJ2gGB7RrJ+IlhkTqQ8mIHK1zWyRXcSapYFF7ySTur/uKs8EAjybePgNHqa28/CUfl/ttL5ap8kMp9l71wtQd7wHkOj+MRBUFgwkZ8p1qk5IigsexAG2ceR3c+30lwCdzeVBCOR1V2t0RacgFEx3UjkzzBP2Vk4vJaMn2ARKA1UN2E8c01Shj7g1knOuahlwN8M+Ph0s/VaMpcA0KqcOdu5ubowC2oNnXCKWDtBrwYbZGnwNeJU3HDbGRk3qpGCZ+NiJO/9mivE2k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd6656a2-bc27-4a50-ddd0-08d638cee20f X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:13.0935 (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 4/8] net/mlx5: simplify flow counters support check 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" The redundant check of Flow counters support in runtime is removed. The flag flow_counter_en is eliminated from the code. The Verbs create counter function just returns an error if no counter support presented in the system. If there is no any of Flow counters configuration macro defined the log message is emited, indicating the missing counter support. mlx5_flow_validate_action_count() fuctnion is also updated due to flow_counter_en flag removal. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.c | 12 +++--------- drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow.c | 8 +------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index cb86a69..a6cae69 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -739,9 +739,6 @@ unsigned int mprq_max_stride_size_n = 0; unsigned int mprq_min_stride_num_n = 0; unsigned int mprq_max_stride_num_n = 0; -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 - struct ibv_counter_set_description cs_desc = { .counter_type = 0 }; -#endif struct ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id = 0; @@ -1009,12 +1006,9 @@ config.hw_csum = !!(attr.device_cap_flags_ex & IBV_DEVICE_RAW_IP_CSUM); DRV_LOG(DEBUG, "checksum offloading is %ssupported", (config.hw_csum ? "" : "not ")); -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 - 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); +#if !defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) && \ + !defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) + DRV_LOG(DEBUG, "counters are not supported"); #endif config.ind_table_max_size = attr.rss_caps.max_rwq_indirection_table_size; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index d14239c..74d87c0 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -114,7 +114,6 @@ struct mlx5_dev_config { unsigned int tunnel_en:1; /* Whether tunnel stateless offloads are supported. */ unsigned int mpls_en:1; /* MPLS over GRE/UDP is enabled. */ - unsigned int flow_counter_en:1; /* Whether flow counter is supported. */ unsigned int cqe_comp:1; /* CQE compression is enabled. */ unsigned int tso:1; /* Whether TSO is supported. */ unsigned int tx_vec_en:1; /* Tx vector is enabled. */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index fcabab0..14288e4 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -921,16 +921,10 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, * 0 on success, a negative errno value otherwise and rte_ernno is set. */ int -mlx5_flow_validate_action_count(struct rte_eth_dev *dev, +mlx5_flow_validate_action_count(struct rte_eth_dev *dev __rte_unused, const struct rte_flow_attr *attr, struct rte_flow_error *error) { - struct priv *priv = dev->data->dev_private; - - if (!priv->config.flow_counter_en) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "flow counters are not supported."); if (attr->egress) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL, From patchwork Tue Oct 23 10:04:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47228 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 7DD611B48D; Tue, 23 Oct 2018 12:04:32 +0200 (CEST) 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 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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, From patchwork Tue Oct 23 10:04:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47230 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 018421B4A4; Tue, 23 Oct 2018 12:04:36 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60044.outbound.protection.outlook.com [40.107.6.44]) by dpdk.org (Postfix) with ESMTP id D92981B217 for ; Tue, 23 Oct 2018 12:04:16 +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=JszyqrFvxOqGU1R16gpXW139LvXjdnZz4GOSww/aO0Y=; b=CPSIrf1K2yiDsDbqLszoGSv47tBR+xZIQOF3ALQNrbG3Ikf00D2ZGtKHZV2v/ye8e834vzTg8vJ22eXXbY5aLOQY6IowMJJpRInR8ZaqRSzL9gios2UdW0kXg1k+TBEA/pKqeK8ulgXXQsDjPOSAKbjxPC6Ek7YGMD8kBlU5HzU= 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 6/8] net/mlx5: add new flow counter Verbs API to glue library Thread-Index: AQHUarfAE+MY4Y3LW0GW1E8EiEJHBg== Date: Tue, 23 Oct 2018 10:04:14 +0000 Message-ID: <1540289032-29628-7-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:aRbGAINXP2v+hQUmDA6edE9ftJRJTX2+gMRdMc1xynDONHdlufX97a4uOzwTMLukW4HY1FWx8aqWZ973NXoQK9HIm5lDq9NpjsLFMX4PjdrD3ln/Il1STy4c00quqs0Jc3n/qODoYGyfDfp1xYHhQzLqVBUG8SRUEo1OKpRPjp/BJ3o23lAvgfy1m0JD/kR543JbUIPyDdWF2pYgocV32+EQDiOmtu8hQlRJZAPridoWKsMAo6YN2U7YOSGY+HA3Y4yo6pi2mhKnEZWKwsa3FQmcDglh9mfdI8yMcOm2aB4IsCv4X+YOhs6u8rxcITMyL+NNDl6F+wDZBqEsSCpHD9U6JS1orApiTLyAHWESqBTqf3Z9nwVtD/LmvlLFZRnUfe1yWUQNeNIC+OU0gOUGmkLU3aXTNba4p1we3Ho+v2qzlTJ+HzAYpjK/uZc2zjAtiYMVa6FjmG/9DtRx4vjfuQ==; 5:5r4mXhuc0TFfuyALGuWPTiYqJFj14BJIlD3x2/dfpX8xtbdBykgL6NHlDi8vmSeO51daJM86Q9yB5cJP1OzibOqg6DKAVdCeHBIvyb427qj6lL6Aau+FmyxdZslVD48nj7ZMpK97W41r9BZgdHd/XDSvZNgcfO8vRmzduQ+/XFA=; 7:DevY18A8ADyGF0r5Fswt9Nh8Xx3BbJQS+C654lTPkOL125XLi8+bWWldi/uCRI7ZJSKwXZG3HVyRXuTGdLaxtWxxSDFmKcKGAnrdCRilyD7IJ75f4Uwg19sLcXBAIZjgG5lc3ichUzuT4zsZ2km6C9uPHbZH7Eu25ikmZXZSWNySm0MXusYIax1SnczVihbWKRtjnbDwzRVR60HTI/mMcAoRgVOGqAfyZ4gEaX22CXWSZJtEu4fqk7SA4IRl1+aa x-ms-office365-filtering-correlation-id: f2d0d086-6580-4f07-9f59-08d638cee306 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)(5024004)(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: 78PT5RdOsgCYugP+5L058zLj5dtquX/NoqT/D/QbI0fTMgbB6qqYRq6NBcIrWg1KrnnAtDL0cbG9o3mT3A5VkTxDWlaXDCWnAWzXWG7Ciaa7D1eiBOMmeXTgmAGBnSM80lZ1qh6bUmR27dGTEdF14cvd5ru5qLVTLcTRPjuRQfPRLcFlUJDdTJRW38FmNT/0jQxMb71BBccqTUep01q7YsX8zsu0hLnen6RU4HuuYMOp1/kJBf6UgouR4KKu4IQ8hanT64XPHQEzqtwP/bVyGUFtIC065abdtnW7tDyfM0D9F649TWdoEZk2JBMLZ7Ja/xgNJhXUoGKHfMYi9FTMe05evdBD8uzYCvLPSBAv7Ms= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2d0d086-6580-4f07-9f59-08d638cee306 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:14.6466 (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 6/8] net/mlx5: add new flow counter Verbs API to glue library 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" This patch updates the mlx5 glue library, new counter support Verbs function pointers are added to the glue linking structure mlx5_glue. This structure now contains the pointers to the both versions of counter supporting functions due to compatibility issues. Depending on configuration macros the functions perform actual Verbs library calls or return an error with meaning "feature is not supported" (NULL or ENOTSUP). Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_glue.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_glue.h | 17 +++++++++++++ 2 files changed, 77 insertions(+) diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c index 889e074..1afb114 100644 --- a/drivers/net/mlx5/mlx5_glue.c +++ b/drivers/net/mlx5/mlx5_glue.c @@ -263,6 +263,62 @@ #endif } +static struct ibv_counters * +mlx5_glue_create_counters(struct ibv_context *context, + struct ibv_counters_init_attr *init_attr) +{ +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45 + (void)context; + (void)init_attr; + return NULL; +#else + return ibv_create_counters(context, init_attr); +#endif +} + +static int +mlx5_glue_destroy_counters(struct ibv_counters *counters) +{ +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45 + (void)counters; + return ENOTSUP; +#else + return ibv_destroy_counters(counters); +#endif +} + +static int +mlx5_glue_attach_counters(struct ibv_counters *counters, + struct ibv_counter_attach_attr *attr, + struct ibv_flow *flow) +{ +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45 + (void)counters; + (void)attr; + (void)flow; + return ENOTSUP; +#else + return ibv_attach_counters_point_flow(counters, attr, flow); +#endif +} + +static int +mlx5_glue_query_counters(struct ibv_counters *counters, + uint64_t *counters_value, + uint32_t ncounters, + uint32_t flags) +{ +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45 + (void)counters; + (void)counters_value; + (void)ncounters; + (void)flags; + return ENOTSUP; +#else + return ibv_read_counters(counters, counters_value, ncounters, flags); +#endif +} + static void mlx5_glue_ack_async_event(struct ibv_async_event *event) { @@ -424,6 +480,10 @@ .destroy_counter_set = mlx5_glue_destroy_counter_set, .describe_counter_set = mlx5_glue_describe_counter_set, .query_counter_set = mlx5_glue_query_counter_set, + .create_counters = mlx5_glue_create_counters, + .destroy_counters = mlx5_glue_destroy_counters, + .attach_counters = mlx5_glue_attach_counters, + .query_counters = mlx5_glue_query_counters, .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 adee972..44bfefe 100644 --- a/drivers/net/mlx5/mlx5_glue.h +++ b/drivers/net/mlx5/mlx5_glue.h @@ -31,6 +31,12 @@ struct ibv_query_counter_set_attr; #endif +#ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45 +struct ibv_counters; +struct ibv_counters_init_attr; +struct ibv_counter_attach_attr; +#endif + #ifndef HAVE_IBV_DEVICE_TUNNEL_SUPPORT struct mlx5dv_qp_init_attr; #endif @@ -106,6 +112,17 @@ 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); + struct ibv_counters *(*create_counters) + (struct ibv_context *context, + struct ibv_counters_init_attr *init_attr); + int (*destroy_counters)(struct ibv_counters *counters); + int (*attach_counters)(struct ibv_counters *counters, + struct ibv_counter_attach_attr *attr, + struct ibv_flow *flow); + int (*query_counters)(struct ibv_counters *counters, + uint64_t *counters_value, + uint32_t ncounters, + uint32_t flags); void (*ack_async_event)(struct ibv_async_event *event); int (*get_async_event)(struct ibv_context *context, struct ibv_async_event *event); From patchwork Tue Oct 23 10:04:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47229 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 691541B49E; Tue, 23 Oct 2018 12:04:34 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60044.outbound.protection.outlook.com [40.107.6.44]) by dpdk.org (Postfix) with ESMTP id 04F671B3A7 for ; Tue, 23 Oct 2018 12:04:17 +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=5A01UPa8+FGL1QPKfOmUuEYdOJcRMc/8T7YIyB114wM=; b=tjuJ6aEE4aqD9lnoSrYZAbcNR/EuO//dAH9V4Ezf8JKI6bFK9NQwxL2beb6A+ibLDfT2NPIsAJPxQCOjztiKTX4rPhPFSHEsUIcgENRwXVpyTaLgBbv35wHo2tnwvA2cSDqlhoukXIFKAuqZ+2z1Qx6y23yxf7DGope/nMeUbsE= 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:16 +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:16 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 7/8] net/mlx5: remove unnecessary structure initializers Thread-Index: AQHUarfBnoBYh6MKF0Kf7/JS2mRAwg== Date: Tue, 23 Oct 2018 10:04:15 +0000 Message-ID: <1540289032-29628-8-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:L7p8V5N5TtpOPKSaFNtEqojc9RS0IE7SjiAyE3E0YH5z3/ROakCQ8zv8t5+j8YKyRiK8gbeUOfHmDVWmjBMq0RX6SW/0hYIVjUgelChZs0SdhyLl5DzdEIPE15rKKYXxzcybir+7U+Yhc6/234CDeMITxlr8o+osu+wGspV70nsRvFROvTwM0VDSBfTV5ODm/CDbLkXfgoKvfrcb+5dd05CIrn+n6Z4rtGBKYEZZ+Knzpci0CUbzXLUrVNJ/oAiClTEohG5TY5bq1nqshDAZ8gbZwaBx7Z7zeUyd5zfktMmIaq76YFv5+BRKtIehA5u8FR62E9t1GuQqnxldVNoIhnFVG1ZVtRSDifKIzdtAeBoz5+/Ywun8iOkEslh9GgcfNwVWB1oy3TLLyBwNNhrm3Ce303G7soSByWP5WOI1MXCsIApEphdGupLuDXyCQxxsUw1cMcewpUqetoXQxkP2Mg==; 5:vmCM3Q8uhnjlP5L2KCDcvCB6KsNumHkx2ygaKBmLwE/yZkR5Ts1mh0ZwZDaTf3L3FcnRnpTjSRKHGTwJMaqw86yMs3JBx5RPKyPH/Guz7wF3t7qUwvEfEmi7XgHx7+Iv7DxkRhV9FxBUymJq6UlM+DgI1KrYxJtlDOTsuGCofTA=; 7:iVZUM1EPTm0BgfUbYPFhKS3AGSpYIcAQ93HPlWPSlJyUX1JiUzp6D7iSVIj/AbIN9dvgo+wMErBZReNmGngHgtFBukGHFHHdGN9ZLc904Fbt4OTHmCdnpWwrt4YxsaQTDcqk4ID9J+AabVDXrSK5QfRAcO5MlpSgyMNyNelquOh4o3BgBiDawYQem39r0rbDlIuFAAn1wce4VBEwti+HqlrTBa3bobKFir3XuYgIZ3DfpBSSn0fqEYqR7ke87/ij x-ms-office365-filtering-correlation-id: 60333d63-3fce-4c45-e0b6-08d638cee37d 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)(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: dP48aFihHIAV0a+dr2saNkai9QfSXgsJCI9mzJ5oCDjEt0EQ7izxHv0Fc4I4pdTx12QPSuo01r0iAw+2qfYDuD56svLa/oiyZQclVn9MbHtEX7WBnP0nDYCDEN30NZxBM3X4EXDhQ0wq7QZwFCp0RFvX+X7lEkCXHbUrn5vnvqR0zxGTWG72P5huudHLPWfnz/pUv32LrYugfjza1DH0B2Hzn8spu/qdjR6rHMi8XRFUusElqs8MHP2gRdVn3o7jveELcprRkyN1It1jd+d05PC7PmHa1dWuAtkzOswfwQp9kN6DoGDBta3rvXLrfYVLh9a9+3yr5i0dRgq18tGOXV2VpLyGreusm5Mfkp9+i5o= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60333d63-3fce-4c45-e0b6-08d638cee37d X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:15.4902 (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 7/8] net/mlx5: remove unnecessary structure initializers 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" The unnecessary structure filed initializers to zero are removed. We need to do this minor preparation before the following mlx5 counter structure modification. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_tcf.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index a0680af..4076400 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -399,11 +399,6 @@ struct pedit_parser { */ struct mlx5_flow_counter tmpl = { .ref_cnt = 1, - .shared = 0, - .id = 0, - .cs = NULL, - .hits = 0, - .bytes = 0, }; cnt = rte_calloc(__func__, 1, sizeof(*cnt), 0); if (!cnt) { From patchwork Tue Oct 23 10:04:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slava Ovsiienko X-Patchwork-Id: 47231 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 76E3D1B4A9; Tue, 23 Oct 2018 12:04:37 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) by dpdk.org (Postfix) with ESMTP id 3DC361B3BA for ; Tue, 23 Oct 2018 12:04:19 +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=Yf061I6nkCo9wGSJMu2YCgv/PxrQUt7DAsgo6ziMR6Y=; b=StOdN4SJ8zTvjJWAq6ZF/kOVLOZPYcJ/TJEf1FkM3rIOBktNV+Bah+eu+OV/rfKwuViQVhawL4rs3sREQcDnjaDmhToChHd2bw6qXsmJsglhsC7U2zPPf3kjR7ayU5qQRHbrn/Malj3h25FS4QP/J/Ruh5tW5Tihkbov5leWq7c= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.186.150) by AM4PR05MB1506.eurprd05.prod.outlook.com (10.164.79.148) 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:16 +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:16 +0000 From: Slava Ovsiienko To: Slava Ovsiienko CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 8/8] net/mlx5: support new flow counter API Thread-Index: AQHUarfB8W50QOpHwk6axRxR+W5H2w== Date: Tue, 23 Oct 2018 10:04:16 +0000 Message-ID: <1540289032-29628-9-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; AM4PR05MB1506; 6:rhAnA9+BKQFzVXaswFRcPx+81+ppDCwZUNomSRtha1UFEs1OGv8fySUE/OEE3AuYcMwjSDSazbqXteRnHhjWKHZsFSOS1yr70Dk+77aSMhx9fAZPAQ0IdtAzQEkdjcEFo3JhzL95TA9kxP8+An5WLcqxqQux1xa3BepZBROljZW6EOggVY/lH8suk9nGl9k+rSSWNYwzfdzJMM3wotjbgJyGHbijtS9BkEH1zLoaiM9osiAmwwLck1Ynhht7GBGaahiXjITfWzfu+TWrPwcS9bHrVbtJEwaAI55b/qKXbi4tF/IQNJU+8VoiEV/88mF14p1p/YNBAnG5InhlhdrJZ8eUlF+WT9deo1DiwMZPPLHWGa/yE1lx5HusyEVr5EZBr4DaovRcJasrgAJzPl3RPn0NjbrbF4m9N2wRiNTnr/HZSMcqtLwWrfJRdBOd9j5kon/SFgw5wCSc0zL1Nj7pqw==; 5:FKYcSzW3c4vkeFwzCbfEzi063aiEO3yEprbXA1ViFnWT3B9qYVp1B0e7mpcL0dwoZtalKkLnEUCbEngP4ZXaPjmt0iv8eKbcB2X/rdcj0tgbEVV1pKCE9lLISvlIQiADSZI7Oa9U5odhEG791RobSFS9KuPdm1pqBhlGLdM2JIo=; 7:mKaSi6kTW/2cqV8ZLCPPER/x9v8H8IIPqCFqADCmeL5juHhtT0ULxkRvgGyOPar25WIvGytsGdMrLu23A7fSMLFKK7KvkZ5JgcBvxM5EZ1/HwxNetu6uUNTFXXszlLH0IqojwOU3rWsIaHP4/OjKBLfps+sclx52qVy7C+kBhlOq04hJ1MRB8BllKwJGeMCKdmImJOQur5GMfg9CSz5NkyipPklkOZXxlXpKbkXohoQFgZyf4s5UG/ZwN51LKEHX x-ms-office365-filtering-correlation-id: 6c525036-5d49-470d-e7c4-08d638cee3fe 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:AM4PR05MB1506; x-ms-traffictypediagnostic: AM4PR05MB1506: 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)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:AM4PR05MB1506; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB1506; x-forefront-prvs: 0834BAF534 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(346002)(396003)(39860400002)(136003)(366004)(199004)(189003)(478600001)(386003)(476003)(6512007)(6506007)(256004)(53936002)(5024004)(14444005)(486006)(102836004)(86362001)(575784001)(6200100001)(5660300001)(14454004)(5250100002)(97736004)(71190400001)(6436002)(6486002)(105586002)(66066001)(8676002)(305945005)(2906002)(316002)(81166006)(4326008)(2900100001)(68736007)(8936002)(186003)(81156014)(37006003)(11346002)(99286004)(7049001)(76176011)(6116002)(52116002)(446003)(26005)(7736002)(2616005)(36756003)(106356001)(6862004)(25786009)(3846002)(71200400001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1506; 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: KoP9cqtDh/8K5k4TdKCaFCQbYSVvg7ZCE/0S3u+0HgGp/60UQGov9QcJ8y0T5o9Cwzp0cJbI7bO0LGW8sov0mOYRaGfmKBGU6E78LAJFkZ7W6VEeuzNaJdVVLiikGqntCo8p/HImJHe+Vu3adH06u/JGSxvtEpql6n3bxTNvTLmiIqXDRXorcdzQ7djySK/iJDT2mX+KRegd+Jq62jUH/OOY/mdF6LKH+c/ZdhkuuFG6ghQ8OjXKMqx0/CeQWcXoZKXyEWMhyERRiXGiF9RuV114FAZ6OScR2/JzUdiwcck6Uosbj4u89rwwIE9kSqQbS2Ap7tfRzI2q9CcUDhtSZtPVJFPaDI2BJWuWg3N0uJ8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c525036-5d49-470d-e7c4-08d638cee3fe X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:04:16.2438 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1506 Subject: [dpdk-dev] [PATCH v4 8/8] net/mlx5: support new flow counter API 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" This patch updates the functions performing the Verbs ibrary calls in order to support different versions of the library. The functions: - flow_verbs_counter_new() - flow_verbs_counter_release() - flow_verbs_counter_query() now have the several compilation branches, depending on the counters support found in the system at compile time. The flow_verbs_counter_create() function is introduced as helper for flow_verbs_counter_new(), actually this helper create the counters with Verbs. Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.h | 4 ++ drivers/net/mlx5/mlx5_flow_verbs.c | 135 ++++++++++++++++++++++++++++--------- 2 files changed, 107 insertions(+), 32 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index af0a125..69ef0ef 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -228,7 +228,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. */ +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) struct ibv_counter_set *cs; /**< Holds the counters for the rule. */ +#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) + struct ibv_counters *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. */ }; diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index f720c35..2547fb8 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -34,6 +34,70 @@ #include "mlx5_flow.h" /** + * Create Verbs flow counter with Verbs library. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in, out] counter + * mlx5 flow counter object, contains the counter id, + * handle of created Verbs flow counter is returned + * in cs field (if counters are supported). + * + * @return + * 0 On success else a negative errno value is returned + * and rte_errno is set. + */ +static int +flow_verbs_counter_create(struct rte_eth_dev *dev, + struct mlx5_flow_counter *counter) +{ +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) + struct priv *priv = dev->data->dev_private; + struct ibv_counter_set_init_attr init = { + .counter_set_id = counter->id}; + + counter->cs = mlx5_glue->create_counter_set(priv->ctx, &init); + if (!counter->cs) { + rte_errno = ENOTSUP; + return -ENOTSUP; + } + return 0; +#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) + struct priv *priv = dev->data->dev_private; + struct ibv_counters_init_attr init = {0}; + struct ibv_counter_attach_attr attach = {0}; + int ret; + + counter->cs = mlx5_glue->create_counters(priv->ctx, &init); + if (!counter->cs) { + rte_errno = ENOTSUP; + return -ENOTSUP; + } + attach.counter_desc = IBV_COUNTER_PACKETS; + attach.index = 0; + ret = mlx5_glue->attach_counters(counter->cs, &attach, NULL); + if (!ret) { + attach.counter_desc = IBV_COUNTER_BYTES; + attach.index = 1; + ret = mlx5_glue->attach_counters + (counter->cs, &attach, NULL); + } + if (ret) { + claim_zero(mlx5_glue->destroy_counters(counter->cs)); + counter->cs = NULL; + rte_errno = ret; + return -ret; + } + return 0; +#else + (void)dev; + (void)counter; + rte_errno = ENOTSUP; + return -ENOTSUP; +#endif +} + +/** * Get a flow counter. * * @param[in] dev @@ -51,6 +115,7 @@ { struct priv *priv = dev->data->dev_private; struct mlx5_flow_counter *cnt; + int ret; LIST_FOREACH(cnt, &priv->flow_counters, next) { if (!cnt->shared || cnt->shared != shared) @@ -60,36 +125,25 @@ cnt->ref_cnt++; return cnt; } -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 - - struct mlx5_flow_counter tmpl = { - .shared = shared, - .id = id, - .cs = mlx5_glue->create_counter_set - (priv->ctx, - &(struct ibv_counter_set_init_attr){ - .counter_set_id = id, - }), - .hits = 0, - .bytes = 0, - .ref_cnt = 1, - }; - - if (!tmpl.cs) { - rte_errno = errno; - return NULL; - } 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 - rte_errno = ENOTSUP; + cnt->id = id; + cnt->shared = shared; + cnt->ref_cnt = 1; + cnt->hits = 0; + cnt->bytes = 0; + /* Create counter with Verbs. */ + ret = flow_verbs_counter_create(dev, cnt); + if (!ret) { + LIST_INSERT_HEAD(&priv->flow_counters, cnt, next); + return cnt; + } + /* Some error occurred in Verbs library. */ + rte_free(cnt); + rte_errno = -ret; return NULL; } @@ -103,7 +157,11 @@ flow_verbs_counter_release(struct mlx5_flow_counter *counter) { if (--counter->ref_cnt == 0) { +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) claim_zero(mlx5_glue->destroy_counter_set(counter->cs)); +#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) + claim_zero(mlx5_glue->destroy_counters(counter->cs)); +#endif LIST_REMOVE(counter, next); rte_free(counter); } @@ -117,14 +175,15 @@ */ 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 *flow, void *data, struct rte_flow_error *error) { -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \ + defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) if (flow->actions & MLX5_FLOW_ACTION_COUNT) { struct rte_flow_query_count *qc = data; uint64_t counters[2] = {0, 0}; +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) struct ibv_query_counter_set_attr query_cs_attr = { .cs = flow->counter->cs, .query_flags = IBV_COUNTER_SET_FORCE_UPDATE, @@ -135,7 +194,12 @@ }; int err = mlx5_glue->query_counter_set(&query_cs_attr, &query_out); - +#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) + int err = mlx5_glue->query_counters + (flow->counter->cs, counters, + RTE_DIM(counters), + IBV_READ_COUNTERS_ATTR_PREFER_CACHED); +#endif if (err) return rte_flow_error_set (error, err, @@ -157,6 +221,8 @@ NULL, "flow does not have counter"); #else + (void)flow; + (void)data; return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -993,7 +1059,8 @@ { const struct rte_flow_action_count *count = action->conf; struct rte_flow *flow = dev_flow->flow; -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \ + defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) unsigned int size = sizeof(struct ibv_flow_spec_counter_action); struct ibv_flow_spec_counter_action counter = { .type = IBV_FLOW_SPEC_ACTION_COUNT, @@ -1012,9 +1079,12 @@ " context."); } *action_flags |= MLX5_FLOW_ACTION_COUNT; -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) counter.counter_set_handle = flow->counter->cs->handle; flow_verbs_spec_add(dev_flow, &counter, size); +#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) + counter.counters = flow->counter->cs; + flow_verbs_spec_add(dev_flow, &counter, size); #endif return 0; } @@ -1277,7 +1347,8 @@ detected_actions |= MLX5_FLOW_ACTION_RSS; break; case RTE_FLOW_ACTION_TYPE_COUNT: -#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_V42 +#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \ + defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45) size += sizeof(struct ibv_flow_spec_counter_action); #endif detected_actions |= MLX5_FLOW_ACTION_COUNT;