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 179B942B2F; Wed, 17 May 2023 22:25:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7534742D37; Wed, 17 May 2023 22:25:26 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by mails.dpdk.org (Postfix) with ESMTP id 9FBBC42B8B for ; Wed, 17 May 2023 22:25:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QtUXp+QXdlVU9IAyRL0S2X3VzgmPO8hGhRdmAr26MYxXI7755yvrL8voj8/gy+No1SmpzCCvaA4wfSWZbxTwcIQqQ3D5rJ85QMvF883p/hDPX9g92tHzh5BDOw3NTEUrCBYUUeQ8LMPuGx+GuYKwT7vwKVjnu/1aaxqvxEuUi/F15mW0OBaGMWed7L2Gs4A+D/NQaWXTqtJFwoz3xXL0IxWtxriNC1gGBg9QPLUVA/eajwLLDuOx634HKfn665rbn4wGjKihM320/SHEPBDhPCeMxBlDeq6SqvWKkPciTCLlzrJ/zZY/mEZUJ01ZntnOUwcl6Nc2GSqGeFojs43/bg== 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=RdOm7WbiuP2NjXdnSW3FAad+mOODrOl7G4tzJKhsSTE=; b=N/wZKjzNZeakK0llJQzlUVUTCSW2CjIr4i85wbL5S45lmzISL6CFwq0VnZLfE/zYamO2DbcqfvG9JJBA0mEp5LnvXhGkFZN3W6QURqjmJHA3w8vPMK2Sc6kh5Wy3MeMDfXricYiAcIpsuBjGmPgd/F3BkEPOg0N+SGy1TUd8GoTb8VMpG1WRZfHL7tNCAq2r7i8iP7lIAwn436w8EtO0MYpNLalIRQFbMDnhF/9GRYBMb18XdtVuD4plkK4EaqwjBPXdvnN5Y7H9s8GYz+8mqGDZcCBoivEq4Lj64OALv/8jMSTcXBrZW/U2s/6prfyGTMpt+EuaWcWyeldlxmHQMA== 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=RdOm7WbiuP2NjXdnSW3FAad+mOODrOl7G4tzJKhsSTE=; b=CeYfFRZBLxuEhsG/u+HdoPraTEn1UspOGwCvRmLPvZvK58fFMra3WtRwan1l4ctDSYKwKlbZMq+xTfLLRdRM1ZLoxYVrpcLlKknTQ5xZt+7aFUhD0kjtpSG18cnovMRB8aNpS5qj2UoGIqNKyEe9+0r1pdEw0reIcGG9835uDqq0pI7P7mVKlYIfd229aJXcyblGxCXZR5HgmUoUaWYasfD88G0f+ugL+XBvujQSogzKpnRefs6E4rXJky7/3zh4VHUuLI0VjsoFvE007r0ZhMavqAkO6mpr+6KzkgkRqgTBEZ9+e2zwaZRFObuRlG5siw39mgmTTToRSdYpaMtVdQ== Received: from BN9PR03CA0070.namprd03.prod.outlook.com (2603:10b6:408:fc::15) by MN2PR12MB4221.namprd12.prod.outlook.com (2603:10b6:208:1d2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Wed, 17 May 2023 20:25:23 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fc:cafe::c6) by BN9PR03CA0070.outlook.office365.com (2603:10b6:408:fc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Wed, 17 May 2023 20:25:23 +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 BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19 via Frontend Transport; Wed, 17 May 2023 20:25:23 +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.5; Wed, 17 May 2023 13:25:09 -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.37; Wed, 17 May 2023 13:25:07 -0700 From: Dariusz Sosnowski To: Ori Kam , Suanming Mou , "Matan Azrad" , Viacheslav Ovsiienko CC: Subject: [PATCH 2/2] net/mlx5: add modify field actions number validation Date: Wed, 17 May 2023 20:24:46 +0000 Message-ID: <20230517202446.535778-3-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230517202446.535778-1-dsosnowski@nvidia.com> References: <20230517202446.535778-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-TrafficTypeDiagnostic: BN8NAM11FT036:EE_|MN2PR12MB4221:EE_ X-MS-Office365-Filtering-Correlation-Id: f6380ae1-d314-49b3-fc4a-08db5714d7ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bgsXINsY05cch7CfIjwQ73LMY5abNO6tTsbD6h/qNj/fZrSDq2cjMrJEAHcrArCwUiUCDjEmkcHPj3xjPTjkzhyU26Be89OGkNMtw/r7XGH7UDsqvgOdviO+NMBtYGhXOEhH+ufEfl2qu+4ueeoVDbTdURy6D0vKwaKfWWy17fIjMmJUjVxaNlwmoEfayQhaM8nIE1iYAQXvYFndY8Fw6zO1Sz04Q/5sUMc6jpa+FAFiimXqJj2pV3jYOxwzxoaXxKpvXDIjon1BXKnLn0xyhDvnV7or4c6J7oesdbSee8JMPTM8CzwOHBcX9YlY2f8WmlsWJ0cIq+ocuToCdJ5d6zx7jNKsejQ+0pXKHtxJnF4lfL6HyzRchz+zevsXIevNIxO7me1zn+dMr08v3jpcUG6Od1RQbpAV4vUpgF/PWy6VZooSN9sqVYfeTyxM1jXB2HNrRsY/mEqztwqMDfCJB7ka/twqf+74e6Ew6Hn6lTHuYsgLxoWKaqLeKt6EwjUcz9uO4K2vkKTet6d8ssa7Z7a6rYkNsxSquqnse1im4tCbZKi7bTISIfbAPI5VPP4acgb36d8qVE1CaiCFqL+hvhO/yrmgbezqXWdjaHYJaSB1vFLqOoRA9Qg6sy3c8VIGX8NmIEE4fvLjEXd8eyVVJcNy/j2AdkoyFB2rTBv/PPhDgx6ZIshS4RPqw1C2iqqdrC2LBoQ+jOsvuB3jSonYcMqqZu0EGqW+cxFqRnWjMpLyOtuoEhnLe+TWO1sosFBl 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:(13230028)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(36756003)(86362001)(110136005)(70586007)(4326008)(6636002)(70206006)(316002)(478600001)(6666004)(55016003)(82310400005)(40480700001)(8676002)(8936002)(5660300002)(2906002)(41300700001)(356005)(7636003)(82740400003)(426003)(2616005)(36860700001)(6286002)(1076003)(186003)(7696005)(26005)(16526019)(83380400001)(47076005)(336012)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 20:25:23.2967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6380ae1-d314-49b3-fc4a-08db5714d7ce 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: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4221 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 This patch adds validation for the number of modify field actions, when working with HW Steering. If translation of modify field actions generated more HW commands than supported by the FW, then proper error is returned. Additionally, number of generated commands is logged, along with a number of NOP commands added. This validation is only valid for HWS template tables, in groups > 0. Signed-off-by: Dariusz Sosnowski Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_hw.c | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 7e0ee8d883..0a7416c7a1 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -1086,6 +1086,53 @@ flow_hw_modify_field_compile(struct rte_eth_dev *dev, return 0; } +static uint32_t +flow_hw_count_nop_modify_field(struct mlx5_hw_modify_header_action *mhdr) +{ + uint32_t i; + uint32_t nops = 0; + + for (i = 0; i < mhdr->mhdr_cmds_num; ++i) { + struct mlx5_modification_cmd cmd = mhdr->mhdr_cmds[i]; + + cmd.data0 = rte_be_to_cpu_32(cmd.data0); + if (cmd.action_type == MLX5_MODIFICATION_TYPE_NOP) + ++nops; + } + return nops; +} + +static int +flow_hw_validate_compiled_modify_field(struct rte_eth_dev *dev, + const struct mlx5_flow_template_table_cfg *cfg, + struct mlx5_hw_modify_header_action *mhdr, + struct rte_flow_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr; + + /* + * Header modify pattern length limitation is only valid for HWS groups, i.e. groups > 0. + * In group 0, MODIFY_FIELD actions are handled with header modify actions + * managed by rdma-core. + */ + if (cfg->attr.flow_attr.group != 0 && + mhdr->mhdr_cmds_num > hca_attr->max_header_modify_pattern_length) { + uint32_t nops = flow_hw_count_nop_modify_field(mhdr); + + DRV_LOG(ERR, "Too many modify header commands generated from " + "MODIFY_FIELD actions. " + "Generated HW commands = %u (amount of NOP commands = %u). " + "Maximum supported = %u.", + mhdr->mhdr_cmds_num, nops, + hca_attr->max_header_modify_pattern_length); + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "Number of MODIFY_FIELD actions exceeds maximum " + "supported limit of actions"); + } + return 0; +} + static int flow_hw_represented_port_compile(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -1704,6 +1751,10 @@ __flow_hw_actions_translate(struct rte_eth_dev *dev, uint32_t bulk_size; size_t mhdr_len; + if (flow_hw_validate_compiled_modify_field(dev, cfg, &mhdr, error)) { + __flow_hw_action_template_destroy(dev, acts); + return -rte_errno; + } acts->mhdr = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*acts->mhdr), 0, SOCKET_ID_ANY); if (!acts->mhdr) -- 2.25.1