From patchwork Mon Apr 26 12:42:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 92176 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 19648A0548; Mon, 26 Apr 2021 14:43:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0997411D7; Mon, 26 Apr 2021 14:43:28 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by mails.dpdk.org (Postfix) with ESMTP id 8DF01411CA for ; Mon, 26 Apr 2021 14:43:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NwWrHUo37lzB3b94+hfwp8AIRPtRIQkuvxrXyWmQ5f9o6x8gRsDjbw6cjyw2sv7z7LVjxtPBhHSz+JLyI9z0No2Tpb5EhnxhfkvpaR21eSPW0aB93RMrJ5B1DNFnGsJWxopRXx8c3drDRt/UMbP44EocKarIiqGVEShrNfY5hlxNlHnvKZCcwRXbCS8fgNxjs+Z0flxhV4nQSbkb/fhYMmxEesw5Hl39K8SQm7LxyekKRewhe2Fiy25nrEtynrU2JWSkCxmEhEJ3tW8WpWtBelFKEHafUgYvDcYosASxVUiml/KZ6sP9+bhTGM4m2KGjFyVHr5WrOIKXheZJlBgCSg== 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=Fcan9LQi1BQoTbq9ck1d+9F0QrvvHeX5caoMJqqSUjY=; b=c5g+Q24Qx5dQDil2F7ozSZvZxGx2Cu3EO/OSQ7Zj65XO0MkA/fgKBwnaLd4tvq+G7G++ed0M6RnPreQadV7YQM+xan5WlP+hGw3MlZ4AJMRZKD3ArbgQgrN4dDCv+3TX1Sfvmhz72gqY8cGnfbGvTJ0RGJnyauQwIXt/AGq4c95qx2lF+oqBXuvPz6h9tF0PmDfM9f0xei8BZFVLK6JUVF6PDgi0PAO9szNaxDX1Rt/4upugyJ02y8LCQJXbKszEw2LKFgpSni3KRsItH1MxvHb/DFOnSDyX1yENhcKwRPRqsMkhWhtlqpqhSRnLsEz5zEguatU5Fe8usBOBvCsb0A== 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=Fcan9LQi1BQoTbq9ck1d+9F0QrvvHeX5caoMJqqSUjY=; b=DGs2byezews1E8CwezQ6cfFVMIU0e4x5X61QkdwJtqaR0Lsz/J44cP5TXnYvduwt0O1QKgGsKPG28f5lOhLonkHhYYqxp7WZz7QaBevhpQOsVCgVRy1a9Hi2Vr1TXzfu4zB8iZge2sywW9sfyFPo91h1P9AbFd+WvylH6FPHR53//Q5Ia7VGGuDkyE6MvsKKJz2taO63yWbUwmazNNLcXo+1EE539M3tRCXQ8l8VFQxYteKFf4bg/LM8adeQPSjjVWFWLxvod8aEn9FRvBHHO+oajRoDdXttVdi2hrQbNuvE6onfhesxZiwvT4TyIMkHVRw0WH6/GAiidSHSS0yrjg== Received: from DM5PR21CA0058.namprd21.prod.outlook.com (2603:10b6:3:129::20) by MWHPR12MB1887.namprd12.prod.outlook.com (2603:10b6:300:111::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Mon, 26 Apr 2021 12:43:24 +0000 Received: from DM6NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:3:129:cafe::84) by DM5PR21CA0058.outlook.office365.com (2603:10b6:3:129::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.2 via Frontend Transport; Mon, 26 Apr 2021 12:43:24 +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 DM6NAM11FT030.mail.protection.outlook.com (10.13.172.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4065.21 via Frontend Transport; Mon, 26 Apr 2021 12:43:24 +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; Mon, 26 Apr 2021 12:43:23 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Mon, 26 Apr 2021 15:42:50 +0300 Message-ID: <20210426124250.42771-6-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210426124250.42771-1-michaelba@nvidia.com> References: <20210426124250.42771-1-michaelba@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f04f63d-9e3a-44cb-b3a0-08d908b0e1ff X-MS-TrafficTypeDiagnostic: MWHPR12MB1887: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uDf6mcCyeJY0Q5w8ECpJ1PX7dxODKtyeIXPVK/vpGefnUtFiRASo3F9gc+YqRn0wDiP7TVmBenne+IjZfWQmDXBl2s38F/2BN21bvXwo7JTJGeylQB0t3zJTzD7fErU0dEfZ6r80CQcXVGpL1x9boKf5isd4LIiI2k/PAydufxUgVlATqMuhifTgY9dtb9ejHLmLf5cSSE865SPZx1C7Z2XRprr8ftMBM4WtRVhzGWxenqk+bNTsGb2Yz3HRaq8KXOkzK99IUtieHQEIh1/dbpIMaAylMDI5b1W/PYkH8T/cdHCnmaVpEuHRfjIrvGNLqNUynLuRK86Mjnj3GJnhi5f3vvHSDHAAApmloYWW1qnKtwDGMk1HV/LKLVnJaI/JXTusiABiCQF9sogcVxyjT4YRuhfrboKuA7LipOwDtIosIPOdJlrwgornvKGogmC5TeMltxr4Yj8GNjKFB1CCAJW/TzXpuK08GwQJUEGjcqQlmkj7Oxk+pE50a67C91mW89lAA8Em9EyP9SSBOzZGqRsQlse0dvOpAYsd6rGH6LXH89Uaeo+UX2PVOk4IvSxlzWOnHNbMjWW6Ic3acWnTRnK2WFxNh82lvYgxxmJOv9b5s1gFaaoyI9HJJuCKHriqeKazb+x+ZSUFgs3rpWhbAhhc/rbfJ/I79/2Lt9uk2VI= 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)(376002)(39860400002)(136003)(346002)(396003)(36840700001)(46966006)(316002)(8676002)(70586007)(36906005)(16526019)(5660300002)(54906003)(70206006)(186003)(1076003)(107886003)(4326008)(26005)(36756003)(2616005)(356005)(8936002)(36860700001)(7696005)(82310400003)(426003)(47076005)(83380400001)(2906002)(6916009)(6286002)(7636003)(82740400003)(336012)(478600001)(55016002)(86362001)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2021 12:43:24.7523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f04f63d-9e3a-44cb-b3a0-08d908b0e1ff 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: DM6NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1887 Subject: [dpdk-dev] [PATCH 5/5] net/mlx5: use aging by counter when counter is existed 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" The driver support 2 mechanisms in order to support AGE action: 1. Aging by counter - HW counter will be configured to the flow traffic, the driver polls the counter values efficiently to detect flow timeout. 2. Aging by ASO flow hit bit - HW ASO flow-hit bit is allocated for the flow, the driver polls the bit efficiently to detect flow timeout. ASO bit is only single bit resource while counter is 16 bytes, hence, it is better to use ASO instead of counter for aging. When a non-shared COUNT action is also configured to the flow, the driver can use the same counter also for AGE action and no need to create more ASO action for it. The current code always uses ASO when it is supported in the device, change it to reuse the non-shared counter if it exists in the flow. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 149 +++++++++++++++++++++++++++------------- 1 file changed, 102 insertions(+), 47 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 7174e9b..9cd1c45 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7143,6 +7143,12 @@ struct mlx5_hlist_entry * RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "Shared ASO age action is not supported for group 0"); + if (action_flags & MLX5_FLOW_ACTION_AGE) + return rte_flow_error_set + (error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "duplicate age actions set"); action_flags |= MLX5_FLOW_ACTION_AGE; ++actions_n; break; @@ -11163,6 +11169,47 @@ struct mlx5_cache_entry * } /** + * Prepares DV flow counter with aging configuration. + * Gets it by index when exists, creates a new one when doesn't. + * + * @param[in] dev + * Pointer to rte_eth_dev structure. + * @param[in] dev_flow + * Pointer to the mlx5_flow. + * @param[in, out] flow + * Pointer to the sub flow. + * @param[in] count + * Pointer to the counter action configuration. + * @param[in] age + * Pointer to the aging action configuration. + * @param[out] error + * Pointer to the error structure. + * + * @return + * Pointer to the counter, NULL otherwise. + */ +static struct mlx5_flow_counter * +flow_dv_prepare_counter(struct rte_eth_dev *dev, + struct mlx5_flow *dev_flow, + struct rte_flow *flow, + const struct rte_flow_action_count *count, + const struct rte_flow_action_age *age, + struct rte_flow_error *error) +{ + if (!flow->counter) { + flow->counter = flow_dv_translate_create_counter(dev, dev_flow, + count, age); + if (!flow->counter) { + rte_flow_error_set(error, rte_errno, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "cannot create counter object."); + return NULL; + } + } + return flow_dv_counter_get_by_idx(dev, flow->counter, NULL); +} + +/** * Fill the flow with DV spec, lock free * (mutex should be acquired by caller). * @@ -11215,7 +11262,7 @@ struct mlx5_cache_entry * } mhdr_dummy; struct mlx5_flow_dv_modify_hdr_resource *mhdr_res = &mhdr_dummy.res; const struct rte_flow_action_count *count = NULL; - const struct rte_flow_action_age *age = NULL; + const struct rte_flow_action_age *non_shared_age = NULL; union flow_dv_attr flow_attr = { .attr = 0 }; uint32_t tag_be; union mlx5_flow_tbl_key tbl_key; @@ -11230,6 +11277,7 @@ struct mlx5_cache_entry * const struct rte_flow_action_sample *sample = NULL; struct mlx5_flow_sub_actions_list *sample_act; uint32_t sample_act_pos = UINT32_MAX; + uint32_t age_act_pos = UINT32_MAX; uint32_t num_of_dest = 0; int tmp_actions_n = 0; uint32_t table; @@ -11452,7 +11500,12 @@ struct mlx5_cache_entry * age_act = flow_aso_age_get_by_idx(dev, flow->age); __atomic_fetch_add(&age_act->refcnt, 1, __ATOMIC_RELAXED); - dev_flow->dv.actions[actions_n++] = age_act->dr_action; + age_act_pos = actions_n++; + action_flags |= MLX5_FLOW_ACTION_AGE; + break; + case RTE_FLOW_ACTION_TYPE_AGE: + non_shared_age = action->conf; + age_act_pos = actions_n++; action_flags |= MLX5_FLOW_ACTION_AGE; break; case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: @@ -11464,31 +11517,6 @@ struct mlx5_cache_entry * /* Save information first, will apply later. */ action_flags |= MLX5_FLOW_ACTION_COUNT; break; - case RTE_FLOW_ACTION_TYPE_AGE: - if (priv->sh->flow_hit_aso_en && attr->group) { - /* - * Create one shared age action, to be used - * by all sub-flows. - */ - if (!flow->age) { - flow->age = - flow_dv_translate_create_aso_age - (dev, action->conf, - error); - if (!flow->age) - return rte_flow_error_set - (error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, - "can't create ASO age action"); - } - dev_flow->dv.actions[actions_n++] = - (flow_aso_age_get_by_idx - (dev, flow->age))->dr_action; - action_flags |= MLX5_FLOW_ACTION_AGE; - break; - } - /* Fall-through */ case RTE_FLOW_ACTION_TYPE_COUNT: if (!dev_conf->devx) { return rte_flow_error_set @@ -11498,10 +11526,7 @@ struct mlx5_cache_entry * "count action not supported"); } /* Save information first, will apply later. */ - if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT) - count = action->conf; - else - age = action->conf; + count = action->conf; action_flags |= MLX5_FLOW_ACTION_COUNT; break; case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: @@ -11801,27 +11826,57 @@ struct mlx5_cache_entry * dev_flow->dv.actions[modify_action_position] = handle->dvh.modify_hdr->action; } + /* + * Handle AGE and COUNT action by single HW counter + * when they are not shared. + */ + if (action_flags & MLX5_FLOW_ACTION_AGE) { + if ((non_shared_age && + count && !count->shared) || + !(priv->sh->flow_hit_aso_en && + attr->group)) { + /* Creates age by counters. */ + cnt_act = flow_dv_prepare_counter + (dev, dev_flow, + flow, count, + non_shared_age, + error); + if (!cnt_act) + return -rte_errno; + dev_flow->dv.actions[age_act_pos] = + cnt_act->action; + break; + } + if (!flow->age && non_shared_age) { + flow->age = + flow_dv_translate_create_aso_age + (dev, + non_shared_age, + error); + if (!flow->age) + return rte_flow_error_set + (error, rte_errno, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "can't create ASO age action"); + } + age_act = flow_aso_age_get_by_idx(dev, + flow->age); + dev_flow->dv.actions[age_act_pos] = + age_act->dr_action; + } if (action_flags & MLX5_FLOW_ACTION_COUNT) { /* * Create one count action, to be used * by all sub-flows. */ - if (!flow->counter) { - flow->counter = - flow_dv_translate_create_counter - (dev, dev_flow, count, - age); - if (!flow->counter) - return rte_flow_error_set - (error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "cannot create counter" - " object."); - } - dev_flow->dv.actions[actions_n] = - (flow_dv_counter_get_by_idx(dev, - flow->counter, NULL))->action; - actions_n++; + cnt_act = flow_dv_prepare_counter(dev, dev_flow, + flow, count, + NULL, error); + if (!cnt_act) + return -rte_errno; + dev_flow->dv.actions[actions_n++] = + cnt_act->action; } default: break;