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 6762DA052A; Sun, 19 Jul 2020 09:11:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BE54D1C02C; Sun, 19 Jul 2020 09:11:31 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by dpdk.org (Postfix) with ESMTP id D90131C012 for ; Sun, 19 Jul 2020 09:11:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aP8B63aZMqy1qvWBerVi7EjEPDvj83ehtDvpdnRU4nA8tVM+LQ49ZHDTlIU16tmixZzT0S37C9Q8wwhpYhkjPEQXmn38n/QjyCHDBm5inEcFgSChPYvzOvnvpeSN8/pLFOXWFJd4YDqTGtxmgSHahBM0kAHnw6yddxBmCMagi/YzzcAFJj+H7ImNZH+ZIID4EBIQiEH4y30t61jjsZGLNhKrup9+c6LHuT1Bk4whIEgOntBnbsk6lzrbzdp0Syk7R+PtwxsngtG2m2K3JBHvSedZuSIEFC53Hu9x9byllPIXk3nK4vhfdTjpx+ryK5/k7cC+w4Tj4ReaQ4YuqXxpXA== 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=cCREOrFzHyQ18v3DqCpb5U45x+tFjyDW33A8DpRvl1M=; b=UYGF789jFboyl4dsKbC9Y0Lg3uAT+8pcpQZESdWdZv2ZByTjbUfh3R7CEP6WlcbTemJh4gp+gqk3R1wiScuZvat2AmmFF4zKWKjtU5WKfEjljT7YzGSjRbl+7+RCfFHCJ9qzsbUR2qr/FbZFFKYPMAO419Q6uVqaUsaKE8yvHtYdVcetWqNNTgz3L/84v1zLULEWdSvF8YmQhMeO/Szm001xlySsdJrfLaeOJRn5iAEhsjZu8lBKaalMUGNEl3UPEteR0V5wIOBn39xo0Ip2kP8DBOFALKUwwGjk7/sxFpZ+6O9Kwp1oUw9jgRZDH8NXTSNTGWtcTt+nemSo3eNWwg== 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=cCREOrFzHyQ18v3DqCpb5U45x+tFjyDW33A8DpRvl1M=; b=IBSt+8zUDRt6av+sYudMbYccj/UqNKdUkpUOnrkANbTslXLrxSHYn+cov9fkOd38Abp07w9dbJKJOvVL0DnAuWuYsW46xq8HCRDXR4o4vRJn3SFVtSBFgT+9MbM6hAipJQRCYd+r9Jf66Rc2eRoTMRxveDAm9gGayd+Qi7VS1d0= 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 AM0PR05MB4738.eurprd05.prod.outlook.com (2603:10a6:208:b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 19 Jul 2020 07:11:27 +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 07:11:27 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Sun, 19 Jul 2020 07:11:05 +0000 Message-Id: <20200719071112.8540-2-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200719071112.8540-1-ophirmu@mellanox.com> References: <20200714142102.30606-9-ophirmu@mellanox.com> <20200719071112.8540-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR04CA0024.eurprd04.prod.outlook.com (2603:10a6:208:122::37) 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 AM0PR04CA0024.eurprd04.prod.outlook.com (2603:10a6:208:122::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17 via Frontend Transport; Sun, 19 Jul 2020 07:11: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: ea577fc9-1a4d-415d-7347-08d82bb2f409 X-MS-TrafficTypeDiagnostic: AM0PR05MB4738: 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: m0pLtIOdTtmO75yp+p9rbkgceehmhuFG4A6sUs+SXSuoANDoszIheCnLD4DerZ4YykDv4uWNBeqojSOkaeHUzulxKDo8k0YNr+PievmBX42fciXe7sbbHUkHiCGp+c/EkwKDUKr1U1hNxcDdxpmNZZqCdv51PndsqI/+kl1PB96GItLJBhp1T9DkPn0p1IexlQLfwUAtiPf2jJvzKswXY6CDbX8WIPvaXtE/WJ4ZqSBquunG+LEB+kIUXP6OWvth5KDWqM5Ffziz2eetBp5zSJ6UDgQZyTvd8QBIhqFtIL//wJSpwocidqCHogKZC5D756f1DO94XBXij6WCSE4lng== 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)(376002)(39850400004)(346002)(136003)(366004)(52116002)(107886003)(5660300002)(2906002)(316002)(36756003)(8886007)(6666004)(7696005)(6916009)(55016002)(8676002)(478600001)(2616005)(4326008)(66556008)(66476007)(186003)(26005)(66946007)(54906003)(83380400001)(1076003)(86362001)(16526019)(956004)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YBjRwWOe1matc0FbZWc71ijwaLh18N97tzUcdJ9FiRcBlY5b7v66rLckkEnLQ3+mRfawlZE5/2btHwt1nVr/AEdhh4daAGk/Bz041FTqp8VSJ8W5BsMYKszDTVeSxx0Ptj+WhOseNlwDt3CvOAv5ckR/bUdu9kb1BTwau/+T+78rSvCTPCQgCn0EHROHykIEO3VtLdPPICil7bImUvwethkeJX3mY+J83xOw624rxwZ0LrluxNTN5qWXDQ0dqyVwPNMSiqmlHNiwqYkHOUb20UdgGqnwJuAGEuWYsUxfNvWt5x2Bl4JpIzpgjJ/wFW1183W84GqYoIGjK+4oD6CfQv7dYY8pXKt90l2I4MQkNxqqtf7CoKJb5c8OBNJkOpplaZollPSHOOurA0Eh3NxAPBVFseBaEEh6qBYBsJyki0zQhjj/R3ovQ/kQk4wqv5Ix2fyxmH1Zu7zbEuAZ+RZexKrcywRgjmvvnGm8uMEoXHEbuOW1CiMm1FOJH0X7CmxU X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea577fc9-1a4d-415d-7347-08d82bb2f409 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2020 07:11:27.3017 (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: YJ+nUgZcba+PG3dDipgbJ5gzExx5a4YGEEj8ZfqGmCQbRbUbC4/S90115uRczVDvgVKMPF83uXCICy2atHVPAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4738 Subject: [dpdk-dev] [PATCH v2 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 78ebd19..9179ad3 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -925,7 +925,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