From patchwork Tue Jul 14 14:20:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 74005 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D4573A0540; Tue, 14 Jul 2020 16:21:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 480DD1D52D; Tue, 14 Jul 2020 16:21:14 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60070.outbound.protection.outlook.com [40.107.6.70]) by dpdk.org (Postfix) with ESMTP id 1E2301D149 for ; Tue, 14 Jul 2020 16:21:11 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XS+oZ/7JMNgrAlLqc7cflGBT2ko2NdwG88xpWiC8R0ZZygtjIRcLtmKTeKnVcAVNN8Xj/V+hddE6Oyl7lEUJfT6s1yuqY/mr/sGIu1CayVmF/FcV0yIzcW8CljqSWUNnxYE5qXrDh9880lOSsWNzTDwXMto9oax+DWm3gtFHkK2uKYb1X8L5eWNQGIX7Q9rkOlzLjOfGHExZrKz2Bvq1dhOjkmSp+ai0GBd7X7uZgjZZPiF0s8+NUOlFEMybRdtcDgNGalEGZoSkxOvUYtrhu0ywxkN7YROzktZvaya2uQMiMg3hUizj6mgs+V/IXq4vhATfF3pBbYOsvkKKP9e3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4cM/NUZXj59kTaJu4rXYSbP7LwY2T9ZRxPkzrMe2/II=; b=EvMb8zC49Ivb29DphdUz32vTKkgNc2ZgljlW69PqgAxGj2/L+wwSGKd+g7IOTrCDDOT3ZJiBBABMkOTBLdOtPs7L0cizjjTAR5/q604TOZnnrscBKy+JkrXxc7b3mBbQGrIehsdKm3b5By3bFLCLK3zl6fIEcwCvbTlvKv+TZ0kuxoCh9+SXujSyAx6iCA5aTmWzGJzMcaO4J1trGVZm4eDNe+gFxy7wePAnWGyWZAoTFeWYjLL03m1bf4WeYzHOgSghKF60RgQ0Ies3X0Ge9lusJ5olHzBvWHgl3Q5UANjl8DcsYun2h9WSIYGWBT9cqh6g6JStr4YF482SawyBPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=4cM/NUZXj59kTaJu4rXYSbP7LwY2T9ZRxPkzrMe2/II=; b=NFA9WKbWSYpH+Lo5G3jWs76I8bQvWA5YPecjO1TqHBB5Fe1NWyG+xXgf1X3GSG3AJ2EZC4BRwjJ9fGR7HeRBUBZaJUPTAkGYSCbjMPudEYmjAJkTv1SduwCIeEqxyRazjmOUyKIOluecapXCnuvLY8Zyk3KtnbrMAj/+uMtwavM= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) by AM0PR05MB4625.eurprd05.prod.outlook.com (2603:10a6:208:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.24; Tue, 14 Jul 2020 14:21:10 +0000 Received: from AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972]) by AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972%7]) with mapi id 15.20.3174.026; Tue, 14 Jul 2020 14:21:10 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Tue, 14 Jul 2020 14:20:55 +0000 Message-Id: <20200714142102.30606-2-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200714142102.30606-1-ophirmu@mellanox.com> References: <20200714142102.30606-1-ophirmu@mellanox.com> X-ClientProxiedBy: AM3PR05CA0100.eurprd05.prod.outlook.com (2603:10a6:207:1::26) To AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by AM3PR05CA0100.eurprd05.prod.outlook.com (2603:10a6:207:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 14:21:09 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b69323c0-4ea0-41d6-b593-08d8280127c6 X-MS-TrafficTypeDiagnostic: AM0PR05MB4625: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PRQQqL0hau3ncN2hJ+J5icZdZL9YkzsMxaJV8ex6UQCcxNftnf+UDauuGxey1SElf4tzhEJOj0+naXcsW6Fe///97asxK+wkACuUe34yE6ksbFg8DW3jLHwCc4MAkk/mJMYnpEWSdwxOVWdezND5AMvNv95EYKesMK7PozpMjki2EnAfHeIegoHS/A/iUVBAuNYZOosvSjqMaLUwsqNy1zFb7khH5HG2NcN7uPjRYUCsOzQBkH1HskBOVFDSNPxyhqQWqTM62/TW1DPGCP/J7+MINU0IST5s4/3AjCzHS13Qo9pFzjZ5+2bo+WqOS3n19O0HJ1drnIyqv4JXFYud+Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(366004)(376002)(39850400004)(346002)(396003)(36756003)(86362001)(1076003)(8886007)(6666004)(66946007)(316002)(66476007)(52116002)(7696005)(5660300002)(26005)(66556008)(54906003)(478600001)(6916009)(83380400001)(16526019)(8676002)(8936002)(4326008)(956004)(2616005)(107886003)(2906002)(55016002)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9co9Ni0yrUlFKtvWHo6y/Kx5RUTTOW4YUBsxPmOcuzqrI/W3XxX7fJJLi7UArJsO1Tl4uX3zmnUVvDTyoCCPX0Fqi21pIO7mfKJexyw6EZ/Dz8PPbizvo/KMcdO2+jDFooUFE5oazGMTBtix4K6lkKZW2JOIaTIZKWxeNwjJaWy8GEvHeILENEOa/e6yboHJ9sJbMhx3zUFesdUfE5YpjB7y1I9YeNDmc/0hDbzMP+d+mGklL1P9JX1au8yZrBgj10UaEjEt3azzojbpV7BeHh2GJidKfR2lPQxNm89rOIxy1M9orAaGb7whj73P6XeuXSQk/cMzNrpe49l8UaPJt4Gxfuc65Tes9xj57UiJb79cAO1iqECcW2T4AKrEuf9saZdEgVRjyKDbJEZrIo4mJ3gkWLxx1zbaxHEu5U45gMmEwmG/dlytIYuDSjihHHVhmzpNhoXL2Yzhz+0xAieBpmmdwlcmJhxRDkJ+MVN1zLN3/8nL61O9CY3ZEz4ScOfi X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: b69323c0-4ea0-41d6-b593-08d8280127c6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 14:21:10.2816 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cDWvRjJszoGP64ejwSOinusISCg72rm6upBZUbD96664vyX3Z62jHvXz2DmaCOsvFpIFOiG1JIA/w2fcqqfyDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4625 Subject: [dpdk-dev] [PATCH v1 1/8] net/mlx5: move flow prio discovery and adjust under verbs 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" Function calls mlx5_flow_adjust_priority() and mlx5_flow_discover_priorities() are verbs based. Move them from file mlx5_flow.c to file mlx5_flow_verbs.c Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow.c | 112 ------------------------------------- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_verbs.c | 112 +++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 113 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 46e66eb..4323e67 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -841,7 +841,6 @@ int mlx5_traffic_restart(struct rte_eth_dev *dev); int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev); bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev); -int mlx5_flow_discover_priorities(struct rte_eth_dev *dev); void mlx5_flow_print(struct rte_flow *flow); int mlx5_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ae5ccc2..5fdf6df 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -266,17 +265,6 @@ struct mlx5_fdir { struct rte_flow_action_queue queue; }; -/* Map of Verbs to Flow priority with 8 Verbs priorities. */ -static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = { - { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 }, -}; - -/* Map of Verbs to Flow priority with 16 Verbs priorities. */ -static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = { - { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, - { 9, 10, 11 }, { 12, 13, 14 }, -}; - /* Tunnel information. */ struct mlx5_flow_tunnel_info { uint64_t tunnel; /**< Tunnel bit (see MLX5_FLOW_*). */ @@ -483,106 +471,6 @@ mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev) } /** - * Discover the maximum number of priority available. - * - * @param[in] dev - * Pointer to the Ethernet device structure. - * - * @return - * number of supported flow priority on success, a negative errno - * value otherwise and rte_errno is set. - */ -int -mlx5_flow_discover_priorities(struct rte_eth_dev *dev) -{ - struct mlx5_priv *priv = dev->data->dev_private; - struct { - struct ibv_flow_attr attr; - struct ibv_flow_spec_eth eth; - struct ibv_flow_spec_action_drop drop; - } flow_attr = { - .attr = { - .num_of_specs = 2, - .port = (uint8_t)priv->dev_port, - }, - .eth = { - .type = IBV_FLOW_SPEC_ETH, - .size = sizeof(struct ibv_flow_spec_eth), - }, - .drop = { - .size = sizeof(struct ibv_flow_spec_action_drop), - .type = IBV_FLOW_SPEC_ACTION_DROP, - }, - }; - struct ibv_flow *flow; - struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev); - uint16_t vprio[] = { 8, 16 }; - int i; - int priority = 0; - - if (!drop) { - rte_errno = ENOTSUP; - return -rte_errno; - } - for (i = 0; i != RTE_DIM(vprio); i++) { - flow_attr.attr.priority = vprio[i] - 1; - flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr); - if (!flow) - break; - claim_zero(mlx5_glue->destroy_flow(flow)); - priority = vprio[i]; - } - mlx5_hrxq_drop_release(dev); - switch (priority) { - case 8: - priority = RTE_DIM(priority_map_3); - break; - case 16: - priority = RTE_DIM(priority_map_5); - break; - default: - rte_errno = ENOTSUP; - DRV_LOG(ERR, - "port %u verbs maximum priority: %d expected 8/16", - dev->data->port_id, priority); - return -rte_errno; - } - DRV_LOG(INFO, "port %u flow maximum priority: %d", - dev->data->port_id, priority); - return priority; -} - -/** - * Adjust flow priority based on the highest layer and the request priority. - * - * @param[in] dev - * Pointer to the Ethernet device structure. - * @param[in] priority - * The rule base priority. - * @param[in] subpriority - * The priority based on the items. - * - * @return - * The new priority. - */ -uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, - uint32_t subpriority) -{ - uint32_t res = 0; - struct mlx5_priv *priv = dev->data->dev_private; - - switch (priv->config.flow_prio) { - case RTE_DIM(priority_map_3): - res = priority_map_3[priority][subpriority]; - break; - case RTE_DIM(priority_map_5): - res = priority_map_5[priority][subpriority]; - break; - } - return res; -} - -/** * Verify the @p item specifications (spec, last, mask) are compatible with the * NIC capabilities. * diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 43cbda8..616c14a 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -919,6 +919,7 @@ int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes, uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc, int tunnel, uint64_t layer_types, uint64_t hash_fields); +int mlx5_flow_discover_priorities(struct rte_eth_dev *dev); uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, uint32_t subpriority); int mlx5_flow_get_reg_id(struct rte_eth_dev *dev, diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 781c97f..9b8ae5b 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -37,6 +37,118 @@ #define VERBS_SPEC_INNER(item_flags) \ (!!((item_flags) & MLX5_FLOW_LAYER_TUNNEL) ? IBV_FLOW_SPEC_INNER : 0) +/* Map of Verbs to Flow priority with 8 Verbs priorities. */ +static const uint32_t priority_map_3[][MLX5_PRIORITY_MAP_MAX] = { + { 0, 1, 2 }, { 2, 3, 4 }, { 5, 6, 7 }, +}; + +/* Map of Verbs to Flow priority with 16 Verbs priorities. */ +static const uint32_t priority_map_5[][MLX5_PRIORITY_MAP_MAX] = { + { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, + { 9, 10, 11 }, { 12, 13, 14 }, +}; + +/** + * Discover the maximum number of priority available. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * + * @return + * number of supported flow priority on success, a negative errno + * value otherwise and rte_errno is set. + */ +int +mlx5_flow_discover_priorities(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct { + struct ibv_flow_attr attr; + struct ibv_flow_spec_eth eth; + struct ibv_flow_spec_action_drop drop; + } flow_attr = { + .attr = { + .num_of_specs = 2, + .port = (uint8_t)priv->dev_port, + }, + .eth = { + .type = IBV_FLOW_SPEC_ETH, + .size = sizeof(struct ibv_flow_spec_eth), + }, + .drop = { + .size = sizeof(struct ibv_flow_spec_action_drop), + .type = IBV_FLOW_SPEC_ACTION_DROP, + }, + }; + struct ibv_flow *flow; + struct mlx5_hrxq *drop = mlx5_hrxq_drop_new(dev); + uint16_t vprio[] = { 8, 16 }; + int i; + int priority = 0; + + if (!drop) { + rte_errno = ENOTSUP; + return -rte_errno; + } + for (i = 0; i != RTE_DIM(vprio); i++) { + flow_attr.attr.priority = vprio[i] - 1; + flow = mlx5_glue->create_flow(drop->qp, &flow_attr.attr); + if (!flow) + break; + claim_zero(mlx5_glue->destroy_flow(flow)); + priority = vprio[i]; + } + mlx5_hrxq_drop_release(dev); + switch (priority) { + case 8: + priority = RTE_DIM(priority_map_3); + break; + case 16: + priority = RTE_DIM(priority_map_5); + break; + default: + rte_errno = ENOTSUP; + DRV_LOG(ERR, + "port %u verbs maximum priority: %d expected 8/16", + dev->data->port_id, priority); + return -rte_errno; + } + DRV_LOG(INFO, "port %u flow maximum priority: %d", + dev->data->port_id, priority); + return priority; +} + +/** + * Adjust flow priority based on the highest layer and the request priority. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] priority + * The rule base priority. + * @param[in] subpriority + * The priority based on the items. + * + * @return + * The new priority. + */ +uint32_t +mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, + uint32_t subpriority) +{ + uint32_t res = 0; + struct mlx5_priv *priv = dev->data->dev_private; + + switch (priv->config.flow_prio) { + case RTE_DIM(priority_map_3): + res = priority_map_3[priority][subpriority]; + break; + case RTE_DIM(priority_map_5): + res = priority_map_5[priority][subpriority]; + break; + } + return res; +} + /** * Get Verbs flow counter by index. *