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 A3B6243238; Sun, 29 Oct 2023 17:35:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9353342D83; Sun, 29 Oct 2023 17:33:36 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by mails.dpdk.org (Postfix) with ESMTP id 64126410F2 for ; Sun, 29 Oct 2023 17:33:34 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k4j9YYIzK4E8eGWsav7SaVj5mICTi4OKxtMFwnvRjZHdC4D+Aj0sVGASXcIolVN7nsWIZr9xcpgREC6R4gJFnpkGBA69EQNCOoVMFQnUfXbWnRDAn3mkmVDZ3xJ7b85uOAWk9GqyW9wzmnOE9q/1blxxQiTrksao9BzgETHz9l4+RYXfdNwA/1HRvW8nj9S/Pnn6shOOlBdinSqZGS5oCc+P9WEXzUE4VgHedbMFQ3UnMeAjqOHLXVHzC4iuBUHYYqqOYYsic6Pv0DjU56S4cLuKJiFh3aDaufvuPtHQTZYmyU/+yJJBdMGcGJAmu50a1gb4SsQuHHE3F4pYa7qBXA== 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=5dntY21ugXECwUGC9A0jJuC9ftkHw/K+gvNm6HOzklk=; b=RP3D4jkbp/wtjZVxWs086wjLef5zprt+Iq1Jlui9vsI2ryLDy/m+RtxVtEuSboEg0VczOsMrt7H0LDuBgZtp6ZW5kdYeEzYK7nZLgd4C0+nGI2eOYd7WkF8JdCbdzCI543vEFvjwSk6WhY6i0uG3+PEy7O2qzKjReyqRMmTDK65jKerVbbN8jKj4MWmVhps+FxH5kHjlmNRpA/zcwS7GzvH8XS0TZbqgWB9GShYcK8PlJ09vtylkLLWBSvMEUS5I4TyETZOuHsDs6d+JxDeEKOWKL3Hqz5Qnt9m7S0A279dI0ZJmkq7+YypJryi95Z/itmu0oskcx6AND2csIdmmQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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 (0) 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=5dntY21ugXECwUGC9A0jJuC9ftkHw/K+gvNm6HOzklk=; b=ouV5eTqqE7WAsHB/ut3iCIArvffx8QCEx+E6B/KXo0XF2tngJ9eysTRTGi/u7WyTiLmenHiEGA3rIgC9fUsTk8bj049c4bamL2Ncrhl7i6tBVH8kH5l6YL+gQsAguasRFKgnK8ia9zztbDTYA4R5avYEJ4jPn/JHYnJc3OoZ04AgNJb7iTveQjMwjae+MYcxzX8STg/qCbbnclvPxWo0MbFS1keuymniM5vmdCMHat9c/2kkNpIZIj01ufUPA8LZbcYSA1i4taPrqoLTq1+eVhM/34qg+YcMnv1EzKul09TYSEll4Qe+dO6UeSY7FdTlXBANM1mn4O2Qs6X295/FWA== Received: from BYAPR02CA0043.namprd02.prod.outlook.com (2603:10b6:a03:54::20) by SN7PR12MB6932.namprd12.prod.outlook.com (2603:10b6:806:260::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Sun, 29 Oct 2023 16:33:32 +0000 Received: from CO1PEPF000044F4.namprd05.prod.outlook.com (2603:10b6:a03:54:cafe::ce) by BYAPR02CA0043.outlook.office365.com (2603:10b6:a03:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.27 via Frontend Transport; Sun, 29 Oct 2023 16:33:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1PEPF000044F4.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22 via Frontend Transport; Sun, 29 Oct 2023 16:33:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 29 Oct 2023 09:33:18 -0700 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.41; Sun, 29 Oct 2023 09:33:15 -0700 From: Gregory Etelson To: CC: , , , "Hamdan Igbaria" , Alex Vesker , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH 19/30] net/mlx5/hws: support ASO first hit action Date: Sun, 29 Oct 2023 18:31:51 +0200 Message-ID: <20231029163202.216450-19-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231029163202.216450-1-getelson@nvidia.com> References: <20231029163202.216450-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.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-TrafficTypeDiagnostic: CO1PEPF000044F4:EE_|SN7PR12MB6932:EE_ X-MS-Office365-Filtering-Correlation-Id: 894bad3e-d25c-4fad-0806-08dbd89cc9ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3EcQlFp5ucAxZDVbGtMLYKvir1PuHsdS2/Qf/FOW6olc3Lb4TsxycwZreMSR5o4DxA9fxXPTuvHHKbb9PpY1iKdyiG6RcginnPWW5hiTZTF4nw07Ab1hZc8PMPHmrsBxAURBBR8vuc4+rRNueVIj/gkTEm71fRYm0I6aFNw6eePVkeaS6z3TC7WrX0AZ8Z/Xt3qZA3uu9DIaYkXId0MzmIqvgCg2vqdQdRcZhUIsy6xrcGrdcetk+MycmfENw0Cssw0BQIlqcpUv0gLM0xlJu4RP0FK8Q+jP9OrDzUaBbrKCjflCKh7XrUnoPX2DEpCxwF08jBn+9T2RawTIN1FA3tfQ9zmNmlmR5yVa3dQ32zfyX7qP1H3ICWzgiK2+UKHrlmpdDqDxwSjgvYobeLoaXgmOBB5BivSzvciOeQDgu1mEEbEIUN6Gzi2dXSJti6cL/7FicCty7PtR0pWDFE9rdFrCuil/FMWQ/42iPElvDtA6y955l148IZ11LMHxfpOod9b6aqCijYgt9F5Ir5Qk6xD5TZmiGwbiv2syuqxmYSWReyJxujVVJ5kX00OCFiTN03w8B7re3Ka8P4KfTgXbvvQ80Tr/a2XC92F8InWyQnC0qN/7Oh+sGHQPCCrI2BtOhx+zCj8X9D+ewjCIFwtN/P0B18ZgnWOSg917kHXFrVZAQxyA5Bf+eNbD/GYTaR+ky/d4JuHX6rAJnQe+ehJLwsRDO93ZH8TtVnuQiJY+8rRWmVgLU8BjXETGkArzrkZ0 X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(40470700004)(46966006)(2906002)(86362001)(41300700001)(4326008)(8676002)(8936002)(5660300002)(40460700003)(36756003)(478600001)(55016003)(40480700001)(47076005)(7696005)(6666004)(1076003)(107886003)(7636003)(6916009)(54906003)(316002)(16526019)(6286002)(26005)(70206006)(336012)(426003)(70586007)(82740400003)(83380400001)(36860700001)(2616005)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:31.6306 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 894bad3e-d25c-4fad-0806-08dbd89cc9ec X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6932 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 From: Hamdan Igbaria Support ASO first hit action. This action allows tracking if a rule gets hit by a packet. Signed-off-by: Hamdan Igbaria Reviewed-by: Alex Vesker Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 5 +++++ drivers/net/mlx5/hws/mlx5dr.h | 25 +++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 33 ++++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + 4 files changed, 64 insertions(+) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 793fc1a674..40e461cb82 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -3541,6 +3541,7 @@ enum { MLX5_ASO_CT_NUM_PER_OBJ = 1, MLX5_ASO_METER_NUM_PER_OBJ = 2, MLX5_ASO_IPSEC_NUM_PER_OBJ = 1, + MLX5_ASO_FIRST_HIT_NUM_PER_OBJ = 512, }; struct mlx5_ifc_stc_ste_param_execute_aso_bits { @@ -5371,6 +5372,10 @@ enum { MLX5_FLOW_COLOR_UNDEFINED, }; +enum { + MLX5_ASO_FIRST_HIT_SET = 1, +}; + /* Maximum value of srTCM & trTCM metering parameters. */ #define MLX5_SRTCM_XBS_MAX (0xFF * (1ULL << 0x1F)) #define MLX5_SRTCM_XIR_MAX (8 * (1ULL << 30) * 0xFF) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index e425a8803a..e7d89ad7ec 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -47,6 +47,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_ASO_METER, MLX5DR_ACTION_TYP_ASO_CT, MLX5DR_ACTION_TYP_ASO_IPSEC, + MLX5DR_ACTION_TYP_ASO_FIRST_HIT, MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT, MLX5DR_ACTION_TYP_CRYPTO_DECRYPT, MLX5DR_ACTION_TYP_DEST_ROOT, @@ -256,6 +257,11 @@ struct mlx5dr_rule_action { uint32_t offset; } aso_ipsec; + struct { + uint32_t offset; + bool set; + } aso_first_hit; + struct { uint32_t offset; } crypto; @@ -714,6 +720,25 @@ mlx5dr_action_create_aso_ipsec(struct mlx5dr_context *ctx, uint8_t return_reg_id, uint32_t flags); +/* Create direct rule ASO FIRST HIT action. + * + * @param[in] ctx + * The context in which the new action will be created. + * @param[in] devx_obj + * The DEVX ASO object. + * @param[in] return_reg_id + * When a packet hits a flow connected to this object, a flag is set indicating this event, + * copy the original value of this flag into this reg_id. + * @param[in] flags + * Action creation flags. (enum mlx5dr_action_flags) + * @return pointer to mlx5dr_action on success NULL otherwise. + */ +struct mlx5dr_action * +mlx5dr_action_create_aso_first_hit(struct mlx5dr_context *ctx, + struct mlx5dr_devx_obj *devx_obj, + uint8_t return_reg_id, + uint32_t flags); + /* Create direct rule pop vlan action. * @param[in] ctx * The context in which the new action will be created. diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index f8de3d8d98..fe9c39b207 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -7,6 +7,7 @@ #define WIRE_PORT 0xFFFF #define MLX5DR_ACTION_METER_INIT_COLOR_OFFSET 1 +#define MLX5DR_ACTION_ASO_FIRST_HIT_SET_OFFSET 9 /* This is the maximum allowed action order for each table type: * TX: POP_VLAN, CTR, ASO, PUSH_VLAN, MODIFY, ENCAP, TRAILER, ENCRYPT, @@ -29,6 +30,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_ASO_METER), BIT(MLX5DR_ACTION_TYP_ASO_CT), BIT(MLX5DR_ACTION_TYP_ASO_IPSEC), + BIT(MLX5DR_ACTION_TYP_ASO_FIRST_HIT), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), @@ -49,6 +51,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_ASO_METER), BIT(MLX5DR_ACTION_TYP_ASO_CT), BIT(MLX5DR_ACTION_TYP_ASO_IPSEC), + BIT(MLX5DR_ACTION_TYP_ASO_FIRST_HIT), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), @@ -73,6 +76,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_ASO_METER), BIT(MLX5DR_ACTION_TYP_ASO_CT), BIT(MLX5DR_ACTION_TYP_ASO_IPSEC), + BIT(MLX5DR_ACTION_TYP_ASO_FIRST_HIT), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), @@ -672,6 +676,13 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->aso.devx_obj_id = obj->id; attr->aso.return_reg_id = action->aso.return_reg_id; break; + case MLX5DR_ACTION_TYP_ASO_FIRST_HIT: + attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; + attr->action_type = MLX5_IFC_STC_ACTION_TYPE_ASO; + attr->aso.aso_type = ASO_OPC_MOD_FLOW_HIT; + attr->aso.devx_obj_id = obj->id; + attr->aso.return_reg_id = action->aso.return_reg_id; + break; case MLX5DR_ACTION_TYP_VPORT: attr->action_offset = MLX5DR_ACTION_OFFSET_HIT; attr->action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_VPORT; @@ -1123,6 +1134,16 @@ mlx5dr_action_create_aso_ipsec(struct mlx5dr_context *ctx, devx_obj, return_reg_id, flags); } +struct mlx5dr_action * +mlx5dr_action_create_aso_first_hit(struct mlx5dr_context *ctx, + struct mlx5dr_devx_obj *devx_obj, + uint8_t return_reg_id, + uint32_t flags) +{ + return mlx5dr_action_create_aso(ctx, MLX5DR_ACTION_TYP_ASO_FIRST_HIT, + devx_obj, return_reg_id, flags); +} + struct mlx5dr_action * mlx5dr_action_create_counter(struct mlx5dr_context *ctx, struct mlx5dr_devx_obj *obj, @@ -2185,6 +2206,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) case MLX5DR_ACTION_TYP_ASO_METER: case MLX5DR_ACTION_TYP_ASO_CT: case MLX5DR_ACTION_TYP_ASO_IPSEC: + case MLX5DR_ACTION_TYP_ASO_FIRST_HIT: case MLX5DR_ACTION_TYP_PUSH_VLAN: case MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT: case MLX5DR_ACTION_TYP_CRYPTO_DECRYPT: @@ -2601,6 +2623,15 @@ mlx5dr_action_setter_aso(struct mlx5dr_actions_apply_data *apply, offset = rule_action->aso_ipsec.offset / MLX5_ASO_IPSEC_NUM_PER_OBJ; exe_aso_ctrl = 0; break; + case MLX5DR_ACTION_TYP_ASO_FIRST_HIT: + /* exe_aso_ctrl FIRST HIT format: + * [STC only and reserved bits 22b][set 1b][offset 9b] + */ + offset = rule_action->aso_first_hit.offset / MLX5_ASO_FIRST_HIT_NUM_PER_OBJ; + exe_aso_ctrl = rule_action->aso_first_hit.offset % MLX5_ASO_FIRST_HIT_NUM_PER_OBJ; + exe_aso_ctrl |= rule_action->aso_first_hit.set << + MLX5DR_ACTION_ASO_FIRST_HIT_SET_OFFSET; + break; default: DR_LOG(ERR, "Unsupported ASO action type: %d", rule_action->action->type); rte_errno = ENOTSUP; @@ -2803,6 +2834,8 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) case MLX5DR_ACTION_TYP_ASO_METER: case MLX5DR_ACTION_TYP_ASO_CT: case MLX5DR_ACTION_TYP_ASO_IPSEC: + case MLX5DR_ACTION_TYP_ASO_FIRST_HIT: + /* Double ASO action */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE); setter->flags |= ASF_DOUBLE; setter->set_double = &mlx5dr_action_setter_aso; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index 976a1993e3..552dba5e63 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -24,6 +24,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_ASO_METER] = "ASO_METER", [MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT", [MLX5DR_ACTION_TYP_ASO_IPSEC] = "ASO_IPSEC", + [MLX5DR_ACTION_TYP_ASO_FIRST_HIT] = "ASO_FIRST_HIT", [MLX5DR_ACTION_TYP_DEST_ROOT] = "DEST_ROOT", [MLX5DR_ACTION_TYP_DEST_ARRAY] = "DEST_ARRAY", [MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT] = "CRYPTO_ENCRYPT", -- 2.39.2