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 50F77A0C43; Wed, 12 May 2021 14:10:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2365410F8; Wed, 12 May 2021 14:10:13 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061.outbound.protection.outlook.com [40.107.236.61]) by mails.dpdk.org (Postfix) with ESMTP id 4C6F7410F8; Wed, 12 May 2021 14:10:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMvXmfKjBOH6nVTgPFGfXOC/psEO2HAyKf3VaYuriwnjje8QdImuF7OicJMr/5P1T0VdQqDebdVx6NsGNXvwPqA4aUqPWoq8coK6WFCncO5EZ/4VDgSKtO1M8+zhbJHxRnISIguj4R8mJkQS4EX1G6Aw/LwqhV8XlrxUzWYSUObrPguyEcfSCNRLJ/Jzy/N5PuWqoxhaNyh+5EEFqHj/fb/G7edYEHoX+y2ybCkhg87aPZy1dvzLmv1ACoDSoRmhthBF9wyMVKFu4kQet3+ibzImvQOobrALJzK81pkP5SJYcDPvR8NbAmiul3zTv4cjzXUVd9M5ScrGxx68HhA7gQ== 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=lWHqV1Eg9UPF13IAZsKx3JoLSZyIj/ItImagB3f4U5HZi2dLX261utjFc6nRiNFEH6KLFKmK2cBAMDqvyys4z3ktoli744oEwSOUOQPDSdXxX1lGvEhP1rFOHmhuRUhAwjIhSZhIPXQ+tGvfRPdSDFHdqwWnHUzuJwmJ4syEXkBBQX13D/TGaH2waSGr5FGyhiA0YVyufSESBTvTEncFtR6bt1LKwpVyB3YdiDKzNRoatM9Z+0wWIpxsLKZ/vH5P8YfYX80HqSpwSOBtNiYloRl4Qj6tLHvFKEQjs7Zuh8p0Enk5enOnZ0RSfsuo2V87HRUp+F/0Htd07ihuPM83EQ== 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=G6wyowGPCvX991LGv042RKoQEs+FY/Bnk71ycOpFOVEyhqX0ESmgpQrWA2wwfdnHRylgcmRzvvjRtglC218rBtWHJcTttmbcFiSeP7PRAw1gS/AJVaYB4BmztobQ6pRS9hT3D/L0FRo001KRP3slBeClMGIFWUIZ4JS0UuiS4Of42TwXZBTZW73F04K7T0UwJAW9jQfg9OpM/Oa9+xANc8PCz533wUHzF74fnDDfZcb005/qcAOzIHZU7SbPSRGoVdY3Bdn/3F0oLfG39iUkcnk9mLaIMbDQu87SC9b/bOO0S2N/wDNG1YyB6dKF1mJCDREVyILcaoCxGYupo2uHaQ== Received: from MWHPR1601CA0024.namprd16.prod.outlook.com (2603:10b6:300:da::34) by BL1PR12MB5144.namprd12.prod.outlook.com (2603:10b6:208:316::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.30; Wed, 12 May 2021 12:10:11 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:300:da:cafe::34) by MWHPR1601CA0024.outlook.office365.com (2603:10b6:300:da::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.50 via Frontend Transport; Wed, 12 May 2021 12:10:10 +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 CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) 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 12:10:10 +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 12:10:07 +0000 From: Jiawei Wang To: , , , , , Shahaf Shuler , Dekel Peled CC: , , Date: Wed, 12 May 2021 15:09:51 +0300 Message-ID: <20210512120951.14982-2-jiaweiw@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210512120951.14982-1-jiaweiw@nvidia.com> References: <20210511042407.5742-1-jiaweiw@nvidia.com> <20210512120951.14982-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: 01e41397-de44-4498-1d13-08d9153ee408 X-MS-TrafficTypeDiagnostic: BL1PR12MB5144: 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: uLrKLyCKkgulT7BbBimYmz8/10DJINBcQwiZAMEJEN2zNHr2YTdZyKRgMaJQ4L779/sNdulLZxL1xLzfP2uQDwCJZzFoLCxslj2jKzTtMZq96/orM/vmLyduBH4RHmXfOKiitE6PtrS19sJXegoIdha8ojT00ftpyxEUwFLg6ooCRLO7ZDCiZPdG8IblgmvPtel36eX++pbpXMza5g/EMcMjOCsdQ3TBH/lQqgd/G5IHKXDRDDOva7D2weIibYlmqETB2CbwKnVyV4xaAyX8x5+Q4NaPwGmEDIo/LGbm/dFGOgfp3LGHiN9aOyB9mteK7FIhxdaeZyWEGB43joVq0nF920W6C1GfXKLTQMKsIT0YyxpiBg+MBybLUuDAVR15LuZcWQT+ETXl+J6eEskHrFhzmFmrRUHMCce8dSMurN1aW4182X2+olupbmkSvV8DFD4ZtjwVmqg2hMbE15luO8oXFvJ4E4gDJFNwVMpBpdkDZFV8zfxUBG5gNVOvaRm8L/3xPXikNy6vfohI+QfHpdGk9qnbMlDQsy1tsd0YpkC/kH3lIj6J/1qVbn+kAvk+cEG1Y0duhvt/wicTbOyUo0Y/htkQhxxV2He86c4Un+bdue9tZM/uRxZ4xMVBFbS7bvqcE55iiqf2vt4sv3gQiJrCQGQZ03Pr1MxQMvf5u48= 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)(396003)(136003)(39860400002)(346002)(376002)(36840700001)(46966006)(54906003)(86362001)(316002)(6286002)(186003)(7636003)(2906002)(70586007)(1076003)(6636002)(7696005)(110136005)(6666004)(8936002)(336012)(356005)(8676002)(83380400001)(2616005)(26005)(426003)(55016002)(47076005)(16526019)(70206006)(82740400003)(5660300002)(36756003)(4326008)(478600001)(36906005)(36860700001)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2021 12:10:10.6389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01e41397-de44-4498-1d13-08d9153ee408 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: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5144 Subject: [dpdk-dev] [PATCH v3 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