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 5F53A43204; Thu, 26 Oct 2023 09:13:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 947E842DC1; Thu, 26 Oct 2023 09:13:22 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 6CFFA40EF0 for ; Thu, 26 Oct 2023 09:13:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AfQv2vSZDdJ90aZ2HLH8EY7FloaxUjiIEbzw6IGDyTBqvbvXke1e29NO6w4Ni+vUpuPqe7alt9CMEcM3TeXJbBCzJM2wedyggFdQksfcVOqj2FcP/HdTc+MF1NPQQQwwYs/8XPa+iaeSK/KRMm4ye49cBTJwD3KRsrM14nILi0ryi7kQbeSynF+v1faRWV8AMK8OrBndnlJ8muGWXvv42SFf5Fw6snoxuGAGSwIZ7a37f+dbWGoc6CStK3Bvo+4n5D9jjn9dlCZDuTszMgFUhPes3h8I5g+RwL+WH5BG8RCQ+ePIASazGgp0sq+cSTDe0+hNK/KVK1Iqw8hW3H3j+g== 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=41KmvLZUfRDOPvEREZNK1ZTON50ok9RcxwZLZQ2u5tk=; b=jaHNa86SyKObEtY5nYn4mCerM4/yP3cUpOhI+kfrVrb1SGiuiEY3LPILK7m5ftqN8i+hKButyOpxb6AF7piTts0xnEif/2YLUbl0o09f/vzzTbxOwnXG98aEsYrahhozLHcJAE5F52oNDahT0kQqXi1hKzZPWj6XKkDJ6X9i33kg2ibSbuDdgX2fd5kfibkymg/LrehdxLZBqE6zFmYItdeGRZogSyt7sJKb844fRnwwBrMf1L1cWXZzYocsA7FUgA7iRtkYmsEZRfBVH+glrtD8KZj5Pkud036YptM0E5Kyjo8qZJmFNrbukhDR9WAF6Vwlq3f/GOrkZsUVJhNVJw== 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 (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=41KmvLZUfRDOPvEREZNK1ZTON50ok9RcxwZLZQ2u5tk=; b=NcrWKmH51rP/3I9NbJp6irBdUKDxJmvOi0RwCJf+L8S/n0eqZyaV+KIX2sFkK9lu5VJs23qVyMTWTiMB67xOwv3SR/bFj8yG/POnvq+9umEut6/G6wR5NOsBGHI8KXSb5qDylizMFjr2vMLbDBdSfNHNdOxii7UlS02jtXXuA8piXKsf0io9YrOKAmSEQFxWn2QeNJRtsw7T04gyc901b7qZmDmW30urBjgpoJCi+2ItUG+65K0Q5Wrc3x1umM738BDzPK5F4QFFaLW00RvhJtYJLp7Nf3GOFj5g0PLisPSRnsFvr4ToYtuqeHfUJHs78n41RwJi60bWW2Yk87SYfg== Received: from CYXPR02CA0060.namprd02.prod.outlook.com (2603:10b6:930:cd::7) by DM4PR12MB6208.namprd12.prod.outlook.com (2603:10b6:8:a5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Thu, 26 Oct 2023 07:13:19 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:930:cd:cafe::27) by CYXPR02CA0060.outlook.office365.com (2603:10b6:930:cd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22 via Frontend Transport; Thu, 26 Oct 2023 07:13:19 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Thu, 26 Oct 2023 07:13:19 +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; Thu, 26 Oct 2023 00:13:07 -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; Thu, 26 Oct 2023 00:13:04 -0700 From: Gregory Etelson To: CC: , =?UTF-8?q?=C2=A0?= , , Suanming Mou , Matan Azrad , Viacheslav Ovsiienko , Ori Kam Subject: [PATCH v7 07/10] net/mlx5: reformat HWS code for HWS mirror action Date: Thu, 26 Oct 2023 10:12:26 +0300 Message-ID: <20231026071229.300162-8-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231026071229.300162-1-getelson@nvidia.com> References: <20231017080928.30454-1-getelson@nvidia.com> <20231026071229.300162-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|DM4PR12MB6208:EE_ X-MS-Office365-Filtering-Correlation-Id: 65b3b922-7b2c-4135-4a8c-08dbd5f30806 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nCCKN0S/hHby8Pi0bpIWTLxdYE8ZjJNW35RIEr9s1Tw7ADOKMZY+StdVebbh6dNK0JRbzF/zgCs1rA8g3UOQIC03SxjkkfrxhXJVp6L6lJyBERZ0JsRjiwvPCA0g4IfTj8DxRx7DBe/ODH5AUK9MzEksDpJkGcrPuUnKFnR9gC7+W1T2qe+8+FLU/u54mNB2NKWuEqAJkgp/CAqwMKZ/kE8JW4zv9CoMq1TXtZKUeE2yXx+/QuXqcM2ZdzPI0e3PIo+7jIYAck7lXHper47V6rZKndeRViB5czmLHVr21vwL6yUrjwS/c3EOdJwvJrEKb3cTAED+M4lZ0BWYxJmVibaaOYurmIevotBebeq+5zGFdxi40k37GZE5Nw0j3pjs19g2hzABFL9fY5JHek68mqh2h9R7hANLEI5P0IdC7J6GqQdfBhMe4E/JJXIQl9rTKGEMRRIYgULg791i6+rhq0viJ3i2GuQybclZAPSavoyBhiTq5A5r1Hv7UPrMql2i3ZYW1t7gikbN5yysfqfLJa8NA7ZHVtX12XfeqrxQZkCRaw4EYzovEIeG48zu9bC3Do30xMWEqWJi7gWl0ih3+uCPc3UlAkYBAbSMh8HhCL9Cjxkm+b6XWw5T7G1AYXyu1tcyuYCpoH9Yfs1I4S12bb6IpZXYpIrksYg14ma7gHKDfskbbGyWVk2vHB2Vhh67frNKuwx+14LBHNbSXjm/gOLW/s7n78OtV4xgnOWCJFo= 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)(346002)(396003)(136003)(39860400002)(376002)(230922051799003)(1800799009)(186009)(451199024)(82310400011)(64100799003)(40470700004)(36840700001)(46966006)(55016003)(2906002)(86362001)(36860700001)(41300700001)(107886003)(6916009)(54906003)(356005)(7696005)(478600001)(316002)(1076003)(70586007)(7636003)(70206006)(16526019)(6666004)(426003)(336012)(47076005)(40480700001)(83380400001)(82740400003)(40460700003)(5660300002)(36756003)(2616005)(4326008)(8676002)(8936002)(6286002)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 07:13:19.0362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65b3b922-7b2c-4135-4a8c-08dbd5f30806 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6208 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 Reformat HWS code for HWS mirror action. 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); -- 2.39.2