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 8AC15A0C43; Wed, 12 May 2021 13:54:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E2618410FE; Wed, 12 May 2021 13:54:36 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2040.outbound.protection.outlook.com [40.107.93.40]) by mails.dpdk.org (Postfix) with ESMTP id 6227F4110C; Wed, 12 May 2021 13:54:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BcYJxMs3g0KexXNSmuY4a1QWOQci2mALk2O4argzErE4cKz/Lv9HT73D6Om4wGrSsCIxgxS5dHWzzjGXpBULJhRVcr5c8Er5Sl3MWd0pXa5vQ6zWXbHV2froPWtRCUwfUA7Gybrc8fQRLemIV114DIeg8qpribA7KmRdkRa+DILuuM1IJ3fgrsbiLkNtBmjU0LPuUa129bhD4aHJ907FEzks+x7TWqPkpz6ew8KtiqQGlKAMfIH74wGSOZs6M2Ol16X+0/fAktzQvKHqgV64Gw3exMfIfegRBhW3kgQ1xtyrJ7oCC6SEPqMRultZOy80z2wIAFV6J88LoRsXBUxdug== 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-SenderADCheck; bh=1LtaHnWVSmp7xhO0YcG55+CzzjE11qrCxDHs+udKMHk=; b=Ux6e1uPgMaWqYjYlQq4O80PATkzVCR+P1rM9l6ZFsV5ZD/5TDHPZyGt2ETcztgwkG8QCCSvBxHf8swZLBm+nJJ8Y4nC7KMWDrjrhoSH1OSwZ+Fouc0PBmDxwtNik6AoED6gPjb0f+ihx0oH2Oyjy+Y3ZD14wFUXY4n6cmbca6KHiZEJ0G06fmZKTSFBc2hZHMCYHLtx7ID8kBgjIZr1ZvEgscLFqX3vc6xg5c3vbfZBg0+QWWTXF4oo4zR5i19WgTp9hVVAm5zs5f7ja2kMLW9/atKwTY0ijuRO2J1vvG12ldUif29E+P7gNwEkxYgbIeY6VeAdNS8NA1RX60e6WzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=1LtaHnWVSmp7xhO0YcG55+CzzjE11qrCxDHs+udKMHk=; b=S71LIQk5c4F0pYPdHREan5gMBAPP8lS+fTSNErj2hESWgWuMKaClhy44jJ9HtKp2SSXRHT3fd52tfXYkjo5lIaD6JsPdE6QViBL9RxVLZ2zbT3csW9U+2AzvxBvc9rHxGh90pfuMKq3gLe5hLTty16O05HvTCU3dpGs0symqCG+A4ootHwEKgPn5+Bun9nbehIv0eHzuMe/+U7GcnXe3qfwFOis0Yq5kiW7W3pRD5UefhP070zM+6YOuST2htgFMWMSvxGZGXCOBwKzRALOImYCDIYRmMxJMFPTKYg5P4KR9pD576tebzxLZNZck8jUOySa+0IVidlxoPfufHJfWBA== Received: from BN9PR03CA0561.namprd03.prod.outlook.com (2603:10b6:408:138::26) by CY4PR1201MB0168.namprd12.prod.outlook.com (2603:10b6:910:1d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Wed, 12 May 2021 11:54:34 +0000 Received: from BN8NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::b5) by BN9PR03CA0561.outlook.office365.com (2603:10b6:408:138::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Wed, 12 May 2021 11:54:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT027.mail.protection.outlook.com (10.13.177.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Wed, 12 May 2021 11:54:33 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 12 May 2021 11:54:30 +0000 From: Jiawei Wang To: , , , , , Shahaf Shuler , Dekel Peled CC: , , Date: Wed, 12 May 2021 14:52:39 +0300 Message-ID: <20210512115239.12783-4-jiaweiw@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210512115239.12783-1-jiaweiw@nvidia.com> References: <20210511042407.5742-1-jiaweiw@nvidia.com> <20210512115239.12783-1-jiaweiw@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca8ccda2-d63a-4472-f11b-08d9153cb5ae X-MS-TrafficTypeDiagnostic: CY4PR1201MB0168: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uSBQ1wvLYMjuZEfimVIXzqcfBSqWMTg+IoxXD1Yy53cQWFXJ6Lp4F5YoNmy8slBrA8fbpcfpgeGI0whvEIth9RmVEoEpr059ushsnJiOO17DbiGQYH1Skj7nW+Ueb000upAYKfJZNqn+XGn7FoGYT8uXh5EH/xA+lEoUyWPvKZy3yFPRlRPdc7uRDhqxpsCAuTh2UWrc4YbdKGCtIv+r5faLWZIMchdXSQOCAgH4fHtlCfFkMPmGEM/ynrMrpcNsiNuy8OOVu34b9ZKqjEwcIhLhUDt1tIgyFQ9Ja9ttV2H0YzB3YMBNyQ02P915NL7Ku92nByWoNvcliQBBoXWJrWB7rQWUSX5DKpSdNjCYxf3EdLfQOtzGG/kxt4QU9eNbiC7byJKVm3/BAGrcVwxelzoDRLuwyZV5sfmvasvlHt5n7kYks8Uc9TBsQHjHd/rOTjz194pZadX6bMHMXr8vthYd9lMbdXoaT1HQ8N+k5yC/Qa9vhLUzHZKdakSoLPdPJYxC4KT8RUq6/r/kFXfBHANi99GkazuF+SyywVC/UzuEMErzGUmlpp3utxjBDlkVxoGJzsyKNSJiw1rfMujI5BmrLPTWk4sI5vsO1ARRVk1mbm3qy9a4Ck2+KZY0UMkuFby3XCNizZXaLsPkuDb3/iFzb4TRlcqQuO8A1kbGVbk= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(39860400002)(376002)(136003)(396003)(36840700001)(46966006)(7636003)(356005)(6636002)(54906003)(336012)(82310400003)(83380400001)(70586007)(2906002)(55016002)(8676002)(6286002)(70206006)(8936002)(110136005)(86362001)(36756003)(186003)(5660300002)(82740400003)(316002)(7696005)(36906005)(16526019)(478600001)(26005)(426003)(4326008)(2616005)(1076003)(36860700001)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 11:54:33.8188 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca8ccda2-d63a-4472-f11b-08d9153cb5ae X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0168 Subject: [dpdk-dev] [PATCH v2 2/2] net/mlx5: fix default context in flow age action 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 Sender: "dev" One of the user parameters for the flow AGE action is the action context. This context should be provided back to the user when the action is aged-out. While this context is NULL, a default value should be provided by the PMD: the rte_flow pointer in case of rte_flow_create API and the action pointer in case of the rte_flow_action_handle API. The default for rte_flow_action_handle was set correctly, while in case of rte_flow_create it wrongly remained NULL. This patch set the default value for rte_flow_create case to be the rte_flow pointer. Fixes: f9bc5274a6f9 ("net/mlx5: allow age modes combination") Cc: stable@dpdk.org Signed-off-by: Jiawei Wang Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 81 +++++++++++++++++---------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 1e6cc8d01f..56e6cd3af7 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -11492,38 +11492,35 @@ flow_dv_aso_age_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error) } /** - * Create a age action using ASO mechanism. + * Initialize flow ASO age parameters. * * @param[in] dev * Pointer to rte_eth_dev structure. - * @param[in] age - * Pointer to the aging action configuration. - * @param[out] error - * Pointer to the error structure. + * @param[in] age_idx + * Index of ASO age action. + * @param[in] context + * Pointer to flow counter age context. + * @param[in] timeout + * Aging timeout in seconds. * - * @return - * Index to flow counter on success, 0 otherwise. */ -static uint32_t -flow_dv_translate_create_aso_age(struct rte_eth_dev *dev, - const struct rte_flow_action_age *age, - struct rte_flow_error *error) +static void +flow_dv_aso_age_params_init(struct rte_eth_dev *dev, + uint32_t age_idx, + void *context, + uint32_t timeout) { - uint32_t age_idx = 0; struct mlx5_aso_age_action *aso_age; - age_idx = flow_dv_aso_age_alloc(dev, error); - if (!age_idx) - return 0; aso_age = flow_aso_age_get_by_idx(dev, age_idx); - aso_age->age_params.context = age->context; - aso_age->age_params.timeout = age->timeout; + MLX5_ASSERT(aso_age); + aso_age->age_params.context = context; + aso_age->age_params.timeout = timeout; aso_age->age_params.port_id = dev->data->port_id; __atomic_store_n(&aso_age->age_params.sec_since_last_hit, 0, __ATOMIC_RELAXED); __atomic_store_n(&aso_age->age_params.state, AGE_CANDIDATE, __ATOMIC_RELAXED); - return age_idx; } static void @@ -12629,17 +12626,17 @@ flow_dv_translate(struct rte_eth_dev *dev, break; } if (!flow->age && non_shared_age) { - flow->age = - flow_dv_translate_create_aso_age - (dev, - non_shared_age, - error); + flow->age = flow_dv_aso_age_alloc + (dev, error); if (!flow->age) - return rte_flow_error_set - (error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, - "can't create ASO age action"); + return -rte_errno; + flow_dv_aso_age_params_init + (dev, flow->age, + non_shared_age->context ? + non_shared_age->context : + (void *)(uintptr_t) + (dev_flow->flow_idx), + non_shared_age->timeout); } age_act = flow_aso_age_get_by_idx(dev, flow->age); @@ -14201,9 +14198,10 @@ flow_dv_action_create(struct rte_eth_dev *dev, const struct rte_flow_action *action, struct rte_flow_error *err) { + struct mlx5_priv *priv = dev->data->dev_private; + uint32_t age_idx = 0; uint32_t idx = 0; uint32_t ret = 0; - struct mlx5_priv *priv = dev->data->dev_private; switch (action->type) { case RTE_FLOW_ACTION_TYPE_RSS: @@ -14212,17 +14210,22 @@ flow_dv_action_create(struct rte_eth_dev *dev, MLX5_INDIRECT_ACTION_TYPE_OFFSET) | ret; break; case RTE_FLOW_ACTION_TYPE_AGE: - ret = flow_dv_translate_create_aso_age(dev, action->conf, err); - idx = (MLX5_INDIRECT_ACTION_TYPE_AGE << - MLX5_INDIRECT_ACTION_TYPE_OFFSET) | ret; - if (ret) { - struct mlx5_aso_age_action *aso_age = - flow_aso_age_get_by_idx(dev, ret); - - if (!aso_age->age_params.context) - aso_age->age_params.context = - (void *)(uintptr_t)idx; + age_idx = flow_dv_aso_age_alloc(dev, err); + if (!age_idx) { + ret = -rte_errno; + break; } + idx = (MLX5_INDIRECT_ACTION_TYPE_AGE << + MLX5_INDIRECT_ACTION_TYPE_OFFSET) | age_idx; + flow_dv_aso_age_params_init(dev, age_idx, + ((const struct rte_flow_action_age *) + action->conf)->context ? + ((const struct rte_flow_action_age *) + action->conf)->context : + (void *)(uintptr_t)idx, + ((const struct rte_flow_action_age *) + action->conf)->timeout); + ret = age_idx; break; case RTE_FLOW_ACTION_TYPE_COUNT: ret = flow_dv_translate_create_counter(dev, NULL, NULL, NULL); -- 2.18.1