From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0A011A00BE; Thu, 10 Feb 2022 17:31:52 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D805D41181; Thu, 10 Feb 2022 17:31:13 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by mails.dpdk.org (Postfix) with ESMTP id 4C57541159 for ; Thu, 10 Feb 2022 17:31:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mhnMNiOPl+dFwnzASR5Fd2cKx3DT+iT6uWtiUOULYVhy5XlkML/Se+M5nHzStAj8H9wGBB0uWKXSZqN4FZVNf9mE25JS7ZZjXWBVupfPHkdzkJeZY34xonWsN5mFZl7xHUjHZ+s4bwjdu0CywMLVSSxR6g9Xi09gBDFmdEdxHWUnCagiIlfujewkmudBU5B80kyanOg/1Qv0ayaLrtz5K4Sif5q0KQ3SFp5IGYmGtWN4CFUthUlrhrqgkPaGmdgFDV7hDjqtetP/ENtN6lRZKEqPHocmw04DlqOzw7dZU1QK4R3Q+r6ok5IXb1mKkesVlI1IyDfHBt82P9akofNrvA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LaykgClr2wBy9K4HGX26Gji7LVC/vxlNsrjP1PFN6xk=; b=B4zG6LKVwdLACjC1YWvRZAqZzvhjwN1nvsYkQ16+IX+EudttDcW+UxIrs1VjgRePC1spwdFskhccsspnTvWi3rUTyTUiCDEiigzOL7qYFfZD4jNwCCikg8QVlJvvIdQ1+IyYZzM4BitM7ttSZX2jom9DfOyivAeCv4gj4VkNr68WcTZCyXtjwcea0nAM2z5sBR+lIf36UI+1vjuf2I6LacbV1hWVDGAwukrfXkHddiP3bPXVKYNw/0amqhtcxiqPJ3pOBD1ZQMFsKvfrCFqfw1w2FB3C0VTlpJkBfv9ID4DS2DHrnvvqS3zQBuv3+LqYx8lSumtacQ9MqEOhKgIJWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LaykgClr2wBy9K4HGX26Gji7LVC/vxlNsrjP1PFN6xk=; b=MDx+LMDu2reXoyUpO8lloXwsBjVYymY5TBrFi+uaQU0R41paxgPOaE4OLKqUswNmhZNPshIG5eVutjcl2M81fE0QMcwnux1he/uekbZR2xB6nSOuD+BpyZ+p/h9FpfNk39HIwkLWj2Q1g3AR+KDflkTzmrmz3rQ3CyU2IYSunmyBKRroGhx9UH+Inqafq4NfcY5ph62cT/08HUdEYuS5wi0kqIjUne6Y/EJgmG0SECXoQa+4kymn/bVmD60P/gYuyfsHy552HNRGtnwRZ9Bf2ZBF2tA1e07ET1glgDvxtX/jAtzpt1JXpB8McNftYO5Ca8HZupJgjtFXyd8dpLqgIA== Received: from DM5PR1401CA0003.namprd14.prod.outlook.com (2603:10b6:4:4a::13) by BL0PR12MB2371.namprd12.prod.outlook.com (2603:10b6:207:3e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Thu, 10 Feb 2022 16:31:10 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:4:4a:cafe::19) by DM5PR1401CA0003.outlook.office365.com (2603:10b6:4:4a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 10 Feb 2022 16:31:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Thu, 10 Feb 2022 16:31:10 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 10 Feb 2022 16:30:07 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 10 Feb 2022 08:30:05 -0800 From: Suanming Mou To: , CC: , , Subject: [PATCH 11/13] net/mlx5: add mark action Date: Thu, 10 Feb 2022 18:29:24 +0200 Message-ID: <20220210162926.20436-12-suanmingm@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20220210162926.20436-1-suanmingm@nvidia.com> References: <20220210162926.20436-1-suanmingm@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07be1f1f-0d0d-4d92-28b7-08d9ecb2bf11 X-MS-TrafficTypeDiagnostic: BL0PR12MB2371:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uXdzwju2DiwxdRNFkwumqTaihhimTP4V9+kGPNKfbIRvVtyhrU7T3HokEGhamDlQw3kkYSd5ygHfXgCXtOfAaBSne7Zw7ZJD7IVYy+B80/xsRYmlwnLv0fiI7ZvYlswQkXyGTgZx4yu4JWYgEA4ylFgXNMAnt3KZtkFJCNvRRfx5rpBPn2RkoJhsa7g24j4RJPXJOKzB0tM9x4RVPCm64lx8+eCzCCkazeTXMC2G8rGUKfQZuwdh7vJH3huSSqEGvP1ZBpaMTDqO7LUXiyuxQ8exYDd78kkacKUCnlMUATA4FF+JhID4prif5o613gwkDJdkf1s9lweL5Ua36TCoQ8Z0rMeNyD5Anifp6zuJtHCCJwau3L91Mag1uX9wBDEh74yrapH6vk7O3YYaLu3MEtK8RPIdpBX+jeyzZKg1maA+qZAvYCOUAJltpv4TGUP/mOF1gjC5m4txvqAswsDP5vzcOa2h4EmlDG1zLAV2Zn0e7TXNIuBC6S+4eIr6Vgx6dNM/AVNKpu5cXETSYWztCqQRoW++bjCn4wR0LlmxIOdzFN2BUOlgUF6vl9xUJkUizO3C/RVIJeJpTLJT/SfQyQE03yR6u0HLBhcuClkgckRT2Oh/XoktiUZK40gxF1corFMcKmgW+8ifxrUI290AmD88d+9hbEf550dfQCpYqWdhZR03SgceB+3+3Ha6Ga9gb4q+dvn+j1z1YmDOKAICfA== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(2616005)(83380400001)(5660300002)(508600001)(6286002)(426003)(16526019)(336012)(26005)(186003)(8936002)(1076003)(82310400004)(7696005)(81166007)(6666004)(356005)(47076005)(2906002)(36860700001)(54906003)(110136005)(316002)(86362001)(6636002)(8676002)(4326008)(55016003)(36756003)(70206006)(70586007)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2022 16:31:10.2292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07be1f1f-0d0d-4d92-28b7-08d9ecb2bf11 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2371 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The mark action is covered by tag action internally. While it is added the HW will add a tag to the packet. The mark value can be set as fixed or dynamic as the action mask indicates. Signed-off-by: Suanming Mou --- drivers/net/mlx5/mlx5.h | 3 ++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 87 ++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 6fb82bf1f3..c78dc3c431 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1529,6 +1529,9 @@ struct mlx5_priv { /* HW steering global drop action. */ struct mlx5dr_action *hw_drop[MLX5_HW_ACTION_FLAG_MAX] [MLX5DR_TABLE_TYPE_MAX]; + /* HW steering global drop action. */ + struct mlx5dr_action *hw_tag[MLX5_HW_ACTION_FLAG_MAX] + [MLX5DR_TABLE_TYPE_MAX]; struct mlx5_indexed_pool *acts_ipool; /* Action data indexed pool. */ }; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 33094c8c07..8e65486a1f 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1080,6 +1080,7 @@ struct mlx5_hw_actions { struct mlx5_hw_jump_action *jump; /* Jump action. */ struct mlx5_hrxq *tir; /* TIR action. */ uint32_t acts_num:4; /* Total action number. */ + uint32_t mark:1; /* Indicate the mark action. */ /* Translated DR action array from action template. */ struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS]; }; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index e59d812072..a754cdd084 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -31,6 +31,50 @@ static uint32_t mlx5_hw_act_flag[MLX5_HW_ACTION_FLAG_MAX] }, }; +/** + * Trim rxq flag refcnt. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + */ +static void +flow_hw_rxq_flag_trim(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + unsigned int i; + + if (!priv->mark_enabled) + return; + for (i = 0; i < priv->rxqs_n; ++i) { + struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_ctrl_get(dev, i); + + rxq_ctrl->rxq.mark = 0; + } + priv->mark_enabled = 0; +} + +/** + * Set rxq flag refcnt. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + */ +static void +flow_hw_rxq_flag_set(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + unsigned int i; + + if (priv->mark_enabled) + return; + for (i = 0; i < priv->rxqs_n; ++i) { + struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_ctrl_get(dev, i); + + rxq_ctrl->rxq.mark = 1; + } + priv->mark_enabled = 1; +} + /** * Register destination table DR jump action. * @@ -292,6 +336,20 @@ flow_hw_actions_translate(struct rte_eth_dev *dev, acts->rule_acts[i++].action = priv->hw_drop[!!attr->group][type]; break; + case RTE_FLOW_ACTION_TYPE_MARK: + acts->mark = true; + if (masks->conf) + acts->rule_acts[i].tag.value = + mlx5_flow_mark_set + (((const struct rte_flow_action_mark *) + (masks->conf))->id); + else if (__flow_hw_act_data_general_append(priv, acts, + actions->type, actions - action_start, i)) + goto err; + acts->rule_acts[i++].action = + priv->hw_tag[!!attr->group][type]; + flow_hw_rxq_flag_set(dev); + break; case RTE_FLOW_ACTION_TYPE_JUMP: if (masks->conf) { uint32_t jump_group = @@ -418,6 +476,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, } LIST_FOREACH(act_data, &hw_acts->act_list, next) { uint32_t jump_group; + uint32_t tag; struct mlx5_hw_jump_action *jump; struct mlx5_hrxq *hrxq; @@ -429,6 +488,12 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, break; case RTE_FLOW_ACTION_TYPE_VOID: break; + case RTE_FLOW_ACTION_TYPE_MARK: + tag = mlx5_flow_mark_set + (((const struct rte_flow_action_mark *) + (action->conf))->id); + rule_acts[act_data->action_dst].tag.value = tag; + break; case RTE_FLOW_ACTION_TYPE_JUMP: jump_group = ((const struct rte_flow_action_jump *) action->conf)->group; @@ -998,6 +1063,8 @@ flow_hw_table_destroy(struct rte_eth_dev *dev, __atomic_sub_fetch(&table->its[i]->refcnt, 1, __ATOMIC_RELAXED); for (i = 0; i < table->nb_action_templates; i++) { + if (table->ats[i].acts.mark) + flow_hw_rxq_flag_trim(dev); __flow_hw_action_template_destroy(dev, &table->ats[i].acts); __atomic_sub_fetch(&table->ats[i].action_template->refcnt, 1, __ATOMIC_RELAXED); @@ -1499,15 +1566,21 @@ flow_hw_configure(struct rte_eth_dev *dev, (priv->dr_ctx, mlx5_hw_act_flag[i][j]); if (!priv->hw_drop[i][j]) goto err; + priv->hw_tag[i][j] = mlx5dr_action_create_tag + (priv->dr_ctx, mlx5_hw_act_flag[i][j]); + if (!priv->hw_tag[i][j]) + goto err; } } return 0; err: for (i = 0; i < MLX5_HW_ACTION_FLAG_MAX; i++) { for (j = 0; j < MLX5DR_TABLE_TYPE_MAX; j++) { - if (!priv->hw_drop[i][j]) - continue; - mlx5dr_action_destroy(priv->hw_drop[i][j]); + if (priv->hw_drop[i][j]) + mlx5dr_action_destroy(priv->hw_drop[i][j]); + if (priv->hw_tag[i][j]) + mlx5dr_action_destroy(priv->hw_tag[i][j]); + } } if (dr_ctx) @@ -1556,9 +1629,11 @@ flow_hw_resource_release(struct rte_eth_dev *dev) } for (i = 0; i < MLX5_HW_ACTION_FLAG_MAX; i++) { for (j = 0; j < MLX5DR_TABLE_TYPE_MAX; j++) { - if (!priv->hw_drop[i][j]) - continue; - mlx5dr_action_destroy(priv->hw_drop[i][j]); + if (priv->hw_drop[i][j]) + mlx5dr_action_destroy(priv->hw_drop[i][j]); + if (priv->hw_tag[i][j]) + mlx5dr_action_destroy(priv->hw_tag[i][j]); + } } if (priv->acts_ipool) { -- 2.25.1