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 56EB4A0353; Thu, 24 Feb 2022 04:12:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7321426D7; Thu, 24 Feb 2022 04:11:25 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49]) by mails.dpdk.org (Postfix) with ESMTP id 17D3141C25 for ; Thu, 24 Feb 2022 04:11:21 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d/oFaVyy+sBmp3VooBPJZ5gdD520+bS9uSUNMq5doO281TEI/+h5dt4iMu32Q5geminsPnVQXkePLGTstGJ1rAhEOrFwkMMLjgY+qqQmrW4FGosu5UZobtQKorjeWYzxFc7I5tG+6cICGKRAD4qUlZBbLxK6N8mXIhD+Jl/JGkyxwNUPhOUJ9Qq2ZyZ+aG1l0M5Ps+jWYnbbxAUgc7cS87jw8d80UamBiY69EgwhmkbDJhXXu6/M6V0sp0NzmihTotgg5Q5gOip3LzUySXRVXZmJCv3xdrBzQsUKvjW5U8Ho8r/x3LNtlZqeGDzbMTM0yuuKYmAJcuM8cCQSAjGhRA== 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=Gg7Qh216yvQw7qkk6Jw6OnV5+SRsAZv2iDMuX+etyp4=; b=J568a5BA/QDOZQnTky4aby694efu9y/2UTQN+rocsegUePE1q7JLW09KFYU3zHgGS9yjDH8qx2D6A/Om8CJf/g6mXukyyy/chWva9LgRBS1kIVlby9hIoaVmXkDGuLX8tIaghX3Bt4rGe+f0+rjCPH0I6uswSBwOOJEu6l9IGuS+WnCCyrlNfr/LY61+wO4KAOWBXiy1LLdxK2N7dB6HjHfUAS1HojfOVQ6bd1MTV82HwN+VG2i1jEwRSe7WjWmoa+fWtBPlkX6+H1rzvUadN84AS/2Y7tythVmShMLmoyL5Mev3E2ixErTsX13fkflp3MhHsN1/WfdJ5IG0bKIR3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) 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=Gg7Qh216yvQw7qkk6Jw6OnV5+SRsAZv2iDMuX+etyp4=; b=Zytu/jIH0+HzGfSfYvlh9sZmOWIgjhUJdkFAJgN5+++chN0Kd0j7/Mfj8LVSbZG8z2TtQ3sRTNk2KF4OUiWEo0jk3kWEf9VEa5i0Rsg8zI+s9pbQgl8ANaXnOvhdORehIjI0NE1/hmwucQ4zk7UdBbfspha6xiKHcZFfx9JEmt2TUpLS4Fr0UZZwAIyhX0pDxbtap/rD20a6ejrI2MeYX2lzGBGz7sc9R6/SMDGZZZw+pY/Reb6U5dT5VkbVK81PkiFHWRQJl6JR2tHCNt/hXIuozGNqIZMKZUsYZCbmeoPOzvQDdQHQPstCY2fgVCUqh0ay1rzv4UfWzi60CnGwaQ== Received: from DM6PR05CA0056.namprd05.prod.outlook.com (2603:10b6:5:335::25) by LV2PR12MB5774.namprd12.prod.outlook.com (2603:10b6:408:17a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.24; Thu, 24 Feb 2022 03:11:18 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:5:335:cafe::bc) by DM6PR05CA0056.outlook.office365.com (2603:10b6:5:335::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22 via Frontend Transport; Thu, 24 Feb 2022 03:11:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5017.22 via Frontend Transport; Thu, 24 Feb 2022 03:11:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 24 Feb 2022 03:11:08 +0000 Received: from nvidia.com (10.126.231.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; Wed, 23 Feb 2022 19:11:06 -0800 From: Suanming Mou To: , CC: , , Subject: [PATCH v3 12/14] net/mlx5: add mark action Date: Thu, 24 Feb 2022 05:10:27 +0200 Message-ID: <20220224031029.14049-13-suanmingm@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20220224031029.14049-1-suanmingm@nvidia.com> References: <20220210162926.20436-1-suanmingm@nvidia.com> <20220224031029.14049-1-suanmingm@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fcef6ff-7313-4641-a6b5-08d9f7435366 X-MS-TrafficTypeDiagnostic: LV2PR12MB5774:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2MZ187wPG9EnV/aB/N99/HbsB0eDdS7/gITAHQ/wSRhnNn3Gc2505azUqv8m4FJvYQMMHEip120uMI6zoqhiP49BL7ujOLWu25ddW/4qDMWRJ3J44DH4Eah6gtmY3WZ0VIaWPNH/U9XHL0ytft1kNT1Yslu255SSkyFB08WnrlxmlnXYp0g0/s30soZw0zR3QhS1zIEv1CXHRuBYlRspAEBgl61DIiGlT1+eexwZQ+4dVODKhYQKc/+AUURtJK+f5OX7jvuEH02fo0uiZN/Gti80MAs9wLGbabZ2axOh3QFWOAdlqMzmoeEgSouI3/hQ1/73q2HznR+gKwXlLtLZQcTeJuIKn0uLVosxhbtfTvuFFPFV0J0y7JsGUz4cA2uq2prXePjgMuKbAVi0wyo35n/rdC1NzhKOnE/IfE3kFmjU+sJXWU1c1npFheJiQvHM8y03XyQhjmKs7Dd1PQKs89bzsUxIlgWjUgrbeM9S3V3bABZopCglPwy64O/9FtXKvmbtCM9OGBNPsFT8aoezQXQ5aNYn2lXEJOtv0URqZT4rLL3VTrWcnNjvftzpsJCIOzRraRezAmy57HwRic5OsdrDxQNZ+1FceHFv4OU4gHNsYhYFZ9QY/o9Wgyk1NdwAG3Wq2A3AJJw/VXWWfsrExU/Q2SXQPGRihh2QW6eJdQaTckj74FQHMfy3BkRlqUjWAn3BVrAiu9N0U+fAoABrjw== X-Forefront-Antispam-Report: CIP:12.22.5.235; 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)(7696005)(186003)(356005)(55016003)(16526019)(316002)(336012)(26005)(6636002)(54906003)(2616005)(86362001)(6286002)(1076003)(110136005)(82310400004)(426003)(81166007)(508600001)(40460700003)(6666004)(36860700001)(36756003)(83380400001)(8676002)(2906002)(8936002)(70206006)(5660300002)(4326008)(47076005)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2022 03:11:18.2491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fcef6ff-7313-4641-a6b5-08d9f7435366 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.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5774 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 Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 66 ++++++++++++++++++++++++++++++--- 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index f60a40d669..a0f9fbe365 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1531,6 +1531,8 @@ 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]; struct mlx5_indexed_pool *acts_ipool; /* Action data indexed pool. */ #endif }; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 70e6cf633f..c83e73c793 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1077,6 +1077,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 0d49ab0bb2..a28e3c00b3 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -37,6 +37,31 @@ static uint32_t mlx5_hw_act_flag[MLX5_HW_ACTION_FLAG_MAX] }, }; +/** + * Set rxq flag. + * + * @param[in] dev + * Pointer to the rte_eth_dev structure. + * @param[in] enable + * Flag to enable or not. + */ +static void +flow_hw_rxq_flag_set(struct rte_eth_dev *dev, bool enable) +{ + struct mlx5_priv *priv = dev->data->dev_private; + unsigned int i; + + if ((!priv->mark_enabled && !enable) || + (priv->mark_enabled && enable)) + 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 = enable; + } + priv->mark_enabled = enable; +} + /** * Register destination table DR jump action. * @@ -298,6 +323,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]; + flow_hw_rxq_flag_set(dev, true); + break; case RTE_FLOW_ACTION_TYPE_JUMP: if (masks->conf) { uint32_t jump_group = @@ -424,6 +463,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; @@ -435,6 +475,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; @@ -1027,6 +1073,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_set(dev, false); __flow_hw_action_template_destroy(dev, &table->ats[i].acts); __atomic_sub_fetch(&table->ats[i].action_template->refcnt, 1, __ATOMIC_RELAXED); @@ -1561,15 +1609,20 @@ flow_hw_configure(struct rte_eth_dev *dev, if (!priv->hw_drop[i][j]) goto err; } + priv->hw_tag[i] = mlx5dr_action_create_tag + (priv->dr_ctx, mlx5_hw_act_flag[i][0]); + if (!priv->hw_tag[i]) + 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]) + mlx5dr_action_destroy(priv->hw_tag[i]); } if (dr_ctx) claim_zero(mlx5dr_context_close(dr_ctx)); @@ -1615,10 +1668,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]) + mlx5dr_action_destroy(priv->hw_tag[i]); } if (priv->acts_ipool) { mlx5_ipool_destroy(priv->acts_ipool); -- 2.25.1