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);