From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2A987A0540; Sun, 19 Jul 2020 12:18:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 748A11C0AE; Sun, 19 Jul 2020 12:18:30 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) by dpdk.org (Postfix) with ESMTP id 833C52C38 for ; Sun, 19 Jul 2020 12:18:27 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X6AoU1cNXnomZMlRFXmLntH6sOqocEN7M6UNoDtfbAgc9jXvdhyBbFlM9AE+g+N4ugaP4MTCHzlcyV46R95PzCS7mAydDq28kDIJlR3HvelwyEHsTFweTUxSIHv5ELZrdPpJvAb3w1DwSsapn+enXo2Q7yUHed/6XTpnHp9HA1A6wIbvMtPmIaCaXEuD6oghfShoAZKwwwn21MyGwBpWWPl10zuj2kZoYNLYAi5SeSz54cu33f1Ab3Wn2xIquADwx61yhhsgcMi74EX4Muerad732USuf+cBRQ24pp//x7uERHhefEMPaVT+irsjznHUYddUMmdhk7PIm8AXI4VU6w== 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=Rq6EWtHQbj1UtGqAg+Uh9GR4oDP3dJS+BildkVr2VrE=; b=HvL1mmrfqbjoU3dHxR2obCCw1cuOXqCEMHKKB0kJXNDIPTgCc6k0OtnneZsfLiKzM1Lb0ohJ9n8YFA09Fo3XFdNgf3tmg1Yk+ZSnHIYH4/cAXAOwSogMsVIJojZcnMYH13N+isEMUZ6ul51JK0mZv+rP5m80A/qvZ82Tu3V9e+3Ff6ePKTf1EtRsLmF69U7C7j9DhIBcBwLIjRIkbNEZPqFvTKoWOhRMgUw41MVsW5OLpluBDW1pyFveS4lDvDbdKRcxnQb7BJwEJ7rVgV0jQOVikVRUWldUcEcScINQKCwYogA5JEJ35vyPjiVzrLehFDedMgc0uVGMT/j7j/01Ow== 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=Rq6EWtHQbj1UtGqAg+Uh9GR4oDP3dJS+BildkVr2VrE=; b=goia6GFWdFk6wrQAwFU6IDy5K5N+/khHorwDQuP/gkWw8LBY35+Dxz13PBsBbDK/2Yk4mi+1OQH89Y39IZd88uu4fbTdxIrwsVeQzV5H9UEIRjEI/biLchufMyiRNbdEbNafpxrOayYcJekXuYDhGcyy8F5ecM5xQ0s79q7ls5E= 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 AM0PR05MB6324.eurprd05.prod.outlook.com (2603:10a6:208:143::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.25; Sun, 19 Jul 2020 10:18:26 +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.3195.024; Sun, 19 Jul 2020 10:18:26 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Sun, 19 Jul 2020 10:18:09 +0000 Message-Id: <20200719101816.16406-2-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200719101816.16406-1-ophirmu@mellanox.com> References: <20200719071112.8540-9-ophirmu@mellanox.com> <20200719101816.16406-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR05CA0090.eurprd05.prod.outlook.com (2603:10a6:208:136::30) 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 AM0PR05CA0090.eurprd05.prod.outlook.com (2603:10a6:208:136::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18 via Frontend Transport; Sun, 19 Jul 2020 10:18:26 +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: 700b42ef-8728-4686-e6e0-08d82bcd1345 X-MS-TrafficTypeDiagnostic: AM0PR05MB6324: 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: zhIc1nF1HDGrOm95FTtLTWE+TZLTC5tVLjRQibBwYiMQEKWOCWrlfPAgf4o05riUy+Y1jJLq1GuonAuLNzUg0VxDCfjn1NWPOWMjpeOgGI6xxZJVnDCOUJNwj60JlcZrRb4yi1xLJbc9OayYlnxjdPR2zAW++X5Kpjjcy05u3vSipvSLsknKkcLphvBbO5Q38VvQcnnmZqXMuLgHkr8Q6E1wPxEgJxVKHDUhkfXNBz27YXIZT/xArsB4jx5N+jUJqH0RtR6qzx1C5LSKi1Dkhj/0RpNuY5WVUbC1VWFSZq3KsQRKd4PVxxTrN9ARQZ6k6h72MFTvlso6yw0mNTrh+A== 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)(396003)(346002)(376002)(136003)(39860400002)(366004)(5660300002)(316002)(2906002)(36756003)(54906003)(186003)(2616005)(6666004)(16526019)(4326008)(83380400001)(956004)(6916009)(26005)(478600001)(52116002)(7696005)(107886003)(66556008)(86362001)(66476007)(66946007)(1076003)(55016002)(8936002)(8676002)(8886007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EuwApCurfdJlfGKZLTU6ckVLQ5zG4mhpAZpZmuMhuXfC/ojmHVYGoC6oTQ+RSqTS4TTEIhBpxEBmX9selX6N6Zv4ZCJ7EuLUsU2wTKhIeGicrqf2gcTh/tsIRrEgwmBG6EhT31MmMTqfZlvx8i+YZGAMTu8TVFu3VN3kBErujRhQJSb4HxVJKo2KO1UcQgHBnPVUMF8u44MeKaomaoAxHnZ3mG1RM2s+e1rSYoPDEzWcMYS6GMZ5mW8Dp+1CgvJHdkA08HkuVNhqFtflJ7g2kyUSzfR0JVjXXjkIu6NgHoIVdmbDxU2mWfTxu5QXCwaoT8JCBo1uZEXiXNkTVoiNpOTwHmlkvN/MwhE8Zg8YYy207WE1kxptebympk7+PaBNQhC6ksgh6Tkiol+qPHHDc6KL9LGHEfUuS4Wn+28k7zrnemtQ71OCN8/3MimWpLB0rgRgXUHEBQkKBCCkmlutUnzxYlMBJgDc2kCJxqqGMntS0/69rfdHXL1ipAxClDM3 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 700b42ef-8728-4686-e6e0-08d82bcd1345 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2020 10:18:26.6472 (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: NohAQ5VJ5skVTeSO9eLxbzmkODZTSwPhTgSyEjNurV1MZQ6PK91/Wuik2BRFdweLkJ73JdcG8C0LVXCqI+J41g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6324 Subject: [dpdk-dev] [PATCH v3 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 9722662..3df4149 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -926,7 +926,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 d171ab0..52047db 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -267,17 +266,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_*). */ @@ -484,106 +472,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 6dfeef3..314b5e3 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -922,6 +922,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 72106b4..5d11ba7 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -38,6 +38,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. * -- 2.8.4