From patchwork Mon Oct 23 12:42:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Etelson X-Patchwork-Id: 133181 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6D032431E2; Mon, 23 Oct 2023 14:43:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CFB742D0B; Mon, 23 Oct 2023 14:43:21 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by mails.dpdk.org (Postfix) with ESMTP id 34E8842D7B for ; Mon, 23 Oct 2023 14:43:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=So+hrKtNwbWljHcnDq32geX76ShUjN3pO9plUaAzHI7JP1TyjhTKfWVHPieP+rka6b5Sv7Rbqyiv/QoddKOjzPiQStaN+cBpTotNzGzHVJYkY2xRGZj3gXuJ3vv2F3CUIfIBawjCoMk2QrlTSrIfVMn48xt2OaQcyTtX1gepgaCf+BVf7VzruGiRclVXR2jd2DFhJkd3yyBnCYJVIAd1GB1yWBoh6SIdI2rmNAMXRwp90ddeyhBuyEXrKW1Q1tBm+ZN8j9AOZ/A9k0wh3Py7kOzjNreKQtgz1Gl8lE372SP1Yjos+C7E3b0lvjif006Z9yXKYVKGmbb5E5baojnQVw== 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=VifmeEaqxdYlB6YEG3BIpkoLB7u4GDEuIyKAA9F2SSM=; b=GRA3NZO24w7WuUuvP+w0JSBB65Kax16L/nqsNEkNJ3cvc3Tsak1H2W3PCnYr2OST81ccC2GJkCmfnrOxvXRZ7QWp3hibOtn2nwPuBFxBKFPR4f8nvONkr04qXS8beD4spL4YYw3yxOtEsojV/S+yCkg4RccrSqeNLXZMZlqnlIuayJWpiqBLQScAhChqk60ElrOsttLCaOWk0H9TAQjtuP+9y07YqXbjaI8KcJz2ylQoKxwN92cw658UFioGJYj3zhMmjf8E64zCiZAjKAJd7Ejuj1Nxo1d7ZV9BA9Q1RDCiFNkhpcu3LVGxJqqhCqsHi9IWit+7a7deBAmUIa4fmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=VifmeEaqxdYlB6YEG3BIpkoLB7u4GDEuIyKAA9F2SSM=; b=uneF9E3rkut28iVOoUBq8t9D+Jtyb+AWySYZxmJLsEi5UpZoMCv/ObHLg0jEpK4ukPJaUVDlKlq158vkuNebFcvPkJRGoTWoqrJtS5vw3xQCRQ33cxkIa8aar/8RCBKVcJjXPAGM8UWJ3EgjigSavz/srYgqJTOPIq0RMsziqNVL5+mnS8LUvb8Oj4sE6l1W8LRdrSuqLnNh7gonFGl5pgyLW1L+6Q/zB9vz5u26DhnDpscwaPreJmJVxMg23yOZS9iBz7TdqAYGPnvw1XPRNYNiDOmZSTjz5JfMUERTxVqqVpqiLeYPGsY5J4i7x+iCb6+K1pKTpjWyomf62u65iw== Received: from MW4PR04CA0204.namprd04.prod.outlook.com (2603:10b6:303:86::29) by BL1PR12MB5255.namprd12.prod.outlook.com (2603:10b6:208:315::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Mon, 23 Oct 2023 12:43:18 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:303:86:cafe::c3) by MW4PR04CA0204.outlook.office365.com (2603:10b6:303:86::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33 via Frontend Transport; Mon, 23 Oct 2023 12:43:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Mon, 23 Oct 2023 12:43:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 23 Oct 2023 05:43:12 -0700 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.41; Mon, 23 Oct 2023 05:43:09 -0700 From: Gregory Etelson To: CC: , =?utf-8?b?wqA=?= , , Suanming Mou , Matan Azrad , Viacheslav Ovsiienko , Ori Kam Subject: [PATCH v4 07/10] net/mlx5: reformat HWS code for HWS mirror action Date: Mon, 23 Oct 2023 15:42:22 +0300 Message-ID: <20231023124225.141461-8-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231023124225.141461-1-getelson@nvidia.com> References: <20231017080928.30454-1-getelson@nvidia.com> <20231023124225.141461-1-getelson@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.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-TrafficTypeDiagnostic: CO1PEPF000044F3:EE_|BL1PR12MB5255:EE_ X-MS-Office365-Filtering-Correlation-Id: c5eca92f-8c73-4207-50a1-08dbd3c5a1f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x1CSa6TOtuY1TTBs3yRmvQPsf00noxQ8KbsSw9xsFUmTEzqJyrC+OY1mDRKD8z9dPE0h0o6zCi/j3C8rwPIYihqjryCMZBC7eaee8dTjNI7mcs4QiuMVE30fOLdVK7/NPWK4HXG1625jNlxJvZef1tnDkkOg8XXzbeEEW2P6RTpNYQyk6AUkBdL2VyFhHkfE8kboVMw4fi/78cagZ9S8ogW422caoTC/hB8Bvb5G6t62kNI3zxv9w8M0MKTC5nib5P2PM6OOJHSjz4RruBqcy30XGUss6Vrnez6v81/o4ckSKmDbTqHo4/EqePRHnpvQyDY2vxAZpn23WdsgmxQLVft6ze6NN2Cq33qxFMna4gz+EcYLaLpMOV3/F8FFgRON7rKJdHXFaCzZMnWN36bDV7PNBk4LjqBiliH7g9ZVM41cQ9H+3uxO4OhxckggdVGLVc8we82dERRAoFKaAv/5hsrwNcZ9T2fFD+H+A+YlE1LM537stBFEodiEtmok/IbH6RpfWyVsnHdjuuOaZi7hhSWUC98jWpQTCMydOZ6A+25SAM8c3SBW9ggD3EXlbDjpiVVHfg/n2o1BvRZyBMY6+yxnOHR4n0UI+/OkA3ySyW0j4MmCe2lK3zM8D7sQs87CpJDKurDUeyuqZdlahe3/pdl5+h9n+P9BbPyHr8KlucC2flt18b0uqkJv5X2/TxbE7EdNC5OYvinGF8/w4Ow8tO4wVAGnoENJWVdUN5RtG9I= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(376002)(136003)(346002)(230922051799003)(82310400011)(186009)(1800799009)(451199024)(64100799003)(36840700001)(40470700004)(46966006)(26005)(2906002)(55016003)(41300700001)(40460700003)(5660300002)(86362001)(36756003)(8676002)(8936002)(4326008)(2616005)(478600001)(16526019)(356005)(107886003)(7696005)(1076003)(7636003)(6286002)(6916009)(36860700001)(54906003)(6666004)(70586007)(82740400003)(316002)(70206006)(83380400001)(40480700001)(336012)(426003)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2023 12:43:18.1543 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5eca92f-8c73-4207-50a1-08dbd3c5a1f8 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5255 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 Signed-off-by: Gregory Etelson Acked-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow_hw.c | 70 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 6fcf654e4a..b2215fb5cf 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -4548,6 +4548,17 @@ static enum mlx5dr_action_type mlx5_hw_dr_action_types[] = { [RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL] = MLX5DR_ACTION_TYP_DEST_ROOT, }; +static inline void +action_template_set_type(struct rte_flow_actions_template *at, + enum mlx5dr_action_type *action_types, + unsigned int action_src, uint16_t *curr_off, + enum mlx5dr_action_type type) +{ + at->actions_off[action_src] = *curr_off; + action_types[*curr_off] = type; + *curr_off = *curr_off + 1; +} + static int flow_hw_dr_actions_template_handle_shared(const struct rte_flow_action *mask, unsigned int action_src, @@ -4565,9 +4576,8 @@ flow_hw_dr_actions_template_handle_shared(const struct rte_flow_action *mask, type = mask->type; switch (type) { case RTE_FLOW_ACTION_TYPE_RSS: - at->actions_off[action_src] = *curr_off; - action_types[*curr_off] = MLX5DR_ACTION_TYP_TIR; - *curr_off = *curr_off + 1; + action_template_set_type(at, action_types, action_src, curr_off, + MLX5DR_ACTION_TYP_TIR); break; case RTE_FLOW_ACTION_TYPE_AGE: case RTE_FLOW_ACTION_TYPE_COUNT: @@ -4575,23 +4585,20 @@ flow_hw_dr_actions_template_handle_shared(const struct rte_flow_action *mask, * Both AGE and COUNT action need counter, the first one fills * the action_types array, and the second only saves the offset. */ - if (*cnt_off == UINT16_MAX) { - *cnt_off = *curr_off; - action_types[*cnt_off] = MLX5DR_ACTION_TYP_CTR; - *curr_off = *curr_off + 1; - } + if (*cnt_off == UINT16_MAX) + action_template_set_type(at, action_types, + action_src, curr_off, + MLX5DR_ACTION_TYP_CTR); at->actions_off[action_src] = *cnt_off; break; case RTE_FLOW_ACTION_TYPE_CONNTRACK: - at->actions_off[action_src] = *curr_off; - action_types[*curr_off] = MLX5DR_ACTION_TYP_ASO_CT; - *curr_off = *curr_off + 1; + action_template_set_type(at, action_types, action_src, curr_off, + MLX5DR_ACTION_TYP_ASO_CT); break; case RTE_FLOW_ACTION_TYPE_QUOTA: case RTE_FLOW_ACTION_TYPE_METER_MARK: - at->actions_off[action_src] = *curr_off; - action_types[*curr_off] = MLX5DR_ACTION_TYP_ASO_METER; - *curr_off = *curr_off + 1; + action_template_set_type(at, action_types, action_src, curr_off, + MLX5DR_ACTION_TYP_ASO_METER); break; default: DRV_LOG(WARNING, "Unsupported shared action type: %d", type); @@ -5101,31 +5108,32 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev, at->reformat_off = UINT16_MAX; at->mhdr_off = UINT16_MAX; at->rx_cpy_pos = pos; - /* - * mlx5 PMD hacks indirect action index directly to the action conf. - * The rte_flow_conv() function copies the content from conf pointer. - * Need to restore the indirect action index from action conf here. - */ for (i = 0; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++, masks++, i++) { - if (actions->type == RTE_FLOW_ACTION_TYPE_INDIRECT) { + const struct rte_flow_action_modify_field *info; + + switch (actions->type) { + /* + * mlx5 PMD hacks indirect action index directly to the action conf. + * The rte_flow_conv() function copies the content from conf pointer. + * Need to restore the indirect action index from action conf here. + */ + case RTE_FLOW_ACTION_TYPE_INDIRECT: at->actions[i].conf = actions->conf; at->masks[i].conf = masks->conf; - } - if (actions->type == RTE_FLOW_ACTION_TYPE_MODIFY_FIELD) { - const struct rte_flow_action_modify_field *info = actions->conf; - + break; + case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD: + info = actions->conf; if ((info->dst.field == RTE_FLOW_FIELD_FLEX_ITEM && flow_hw_flex_item_acquire(dev, info->dst.flex_handle, &at->flex_item)) || - (info->src.field == RTE_FLOW_FIELD_FLEX_ITEM && - flow_hw_flex_item_acquire(dev, info->src.flex_handle, - &at->flex_item))) { - rte_flow_error_set(error, rte_errno, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Failed to acquire flex item"); + (info->src.field == RTE_FLOW_FIELD_FLEX_ITEM && + flow_hw_flex_item_acquire(dev, info->src.flex_handle, + &at->flex_item))) goto error; - } + break; + default: + break; } } at->tmpl = flow_hw_dr_actions_template_create(at);