From patchwork Mon Apr 26 12:42:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 92173 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 73F43A0548; Mon, 26 Apr 2021 14:43:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 85A58411C0; Mon, 26 Apr 2021 14:43:21 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2056.outbound.protection.outlook.com [40.107.220.56]) by mails.dpdk.org (Postfix) with ESMTP id 8E3A1411BF for ; Mon, 26 Apr 2021 14:43:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A7ZOTt7RUcQ9eCFgsyFZhBMg7GujnTA1rHl8CzlzsfeTDZ1sLWkWqFMGO1tdNOX+38sGr/b7U0nNIosX4dXlWTOqDV+oIIJx1+y2iz1DxY8JG8QpZmsDGJln6rjhraI/o0NdUg8OkcuoYw9RS6qW/sZVsq24LYqCSSbyadgW8r3uqFMsyiHyKHNOnceUBZUHL2nveff6G0nMbtYNCfDvaMhShLd1KTFarQqdoaSIzPiSpP9oU+bYYrYHxC6vItDTbgBAxkG6/no2Kdh/Bu/VR6z64DaX+RDfg9P6AADTSjf/oFTrOWdhVp7pBW26J9YZ/O0yS6hS21uYOq/8Hi9f7g== 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=aZfwE6vDSJ6620O1pj5FSD2mSDRJ4Cs6eeSPFvrA8PU=; b=epfI4Up8LWuXL7B1TcOCudmHLuLMadA6Cdihto2Rn3Zc989NG2+a3zHwMhSXIZxggi2WCvotE4uhU5QkGm/1LyZwnnRKhK9Uy8IQZUFYPkH2rk0AHIaTesxVo2u0z3NOIvaVjboRuRyvH7ANJ6zuAautEHZ/Mhv4ILt2QOdaNegEht2zO7DUvB/gsw6PaSRla9VMLP09bAx6VquLknWFBPJYY3lrAp3MUHxWNrYHwOgwYbxSxmC/oJxHLJGS47SPnYWZhqEf3FAqvLG6zFgSAUElDLacLXjD/3ix8kb3ZFosHtrsdkxtML1mTR4lQ2AgeK9ZrZNxeN0Mo82LthfUyg== 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=aZfwE6vDSJ6620O1pj5FSD2mSDRJ4Cs6eeSPFvrA8PU=; b=P6qiwdJkdefJj/EofEiZdpk+Loam3KhEeqH+Jwrfz8txqRRiUtEKOO0LA9RmP6q378cjlwmoSfHeTLeKIN3M2beowruCmiJ6H1iNO6JeHqF0Lgy+cnldlCzei2QD3C3SftGAakURAghlKA++z3Mbe08+L+GnO7LSzHfqyzEwWbJQtIFgvSBDBt/rzImzWR51e99aRByLY644gMY96QPtz7CbFFAykRPYiepwevlvMDJZR7zau7xLGNf51skpErFInMo+8IyOtnM9AsuCSc3v9mfBeb9viN87x7q1bt4AhJI1Z+ABZSCIMtiq/uzuCPDMPcG60g8KgyK0CC1ZUM7RpA== Received: from DM5PR12CA0001.namprd12.prod.outlook.com (2603:10b6:4:1::11) by MN2PR12MB4096.namprd12.prod.outlook.com (2603:10b6:208:1dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Mon, 26 Apr 2021 12:43:18 +0000 Received: from DM6NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:4:1:cafe::c8) by DM5PR12CA0001.outlook.office365.com (2603:10b6:4:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.20 via Frontend Transport; Mon, 26 Apr 2021 12:43:18 +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 DM6NAM11FT028.mail.protection.outlook.com (10.13.173.140) 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:18 +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:16 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Mon, 26 Apr 2021 15:42:46 +0300 Message-ID: <20210426124250.42771-2-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: 2a025129-a4b5-457a-f751-08d908b0de11 X-MS-TrafficTypeDiagnostic: MN2PR12MB4096: 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: eFRp62NftaI+tLJQY0K1xi6C77Db53VMaa7bP6wCGx+IVXQZm/+GM4Q/34Iih/tFgh+3J9ADSHCmSeb0S2uPHNBXpOi0N0YP+J7ikEpkcKusA1iKoy2yC+lNQjt4w8xMom35+aMtQ88qS3qdTg71sMxPvNEas2Kd2yYnP2SXXyhMdRs5+elnwAbI+V4y9xhcYEnTmYIXOqD9GfirrHHv9Nq+ACPufGvK3p30RlYCzZb2gHP7OgtI/Vf+gfP0Cqbc61TS38u4DzhyGsrOk7IEHeqXCaK0rkNgeqPrYQkecKRp0BjLl2HdHlQGKJ9TEx956n19PacTcbNnRhE3ajW3q3UOiajyPdeBW0tE4O1Sc9ryOjz3S7MDciYQ4KnFpV/8o6ATkLZRDkJVnAfOq7NoN2NjSUFYMl/VQM0sRLz5xXJ6EmkunFsMpbLycapqrYHWHkeFqebR/UUZmENAOghuG65/hyBk3DeQ0mr6HvAPlmcDTl56QrnR/r1Dp8CqrOfkk86YSoalKOyhq525lNldm3/rWx/eSgw2XWo28emL6WLymfyj8JrXbYenMPYqPzuiFjuq4KnxxprthjjOavqy7VTHdnMkhqw4HGG8jL5yJ4gAKoTAC6uK0x5HAfXjBS84wHKt+XDWGfwfGfgBAfCzFE3Qm6/RAqQ78lyhJ1bYatZPQwvGFyR+eZbskWjuwc/fNvPpqfeiG3lfNrP/xDlYDLGaWd6Ci3EG0LMUbYm5N0voDTURH6stbyZf/4z3RvjhwBf12g1fPn+LalmhPdaopA== 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)(39860400002)(376002)(396003)(346002)(136003)(46966006)(36840700001)(8936002)(30864003)(336012)(1076003)(966005)(186003)(36860700001)(36756003)(16526019)(8676002)(6916009)(4326008)(316002)(26005)(54906003)(2616005)(107886003)(6666004)(6286002)(478600001)(82740400003)(55016002)(70206006)(5660300002)(86362001)(7636003)(2906002)(82310400003)(7696005)(426003)(36906005)(47076005)(356005)(70586007)(83380400001)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2021 12:43:18.1072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a025129-a4b5-457a-f751-08d908b0de11 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: DM6NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4096 Subject: [dpdk-dev] [PATCH 1/5] net/mlx5: support flow count action handle 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" Existing API supports counter action to count traffic of a single flow. The user can share the count action among different flows using the shared flag and the same counter ID in the count action configuration. Recent patch [1] introduced the indirect action API. Using this API, an action can be created as indirect, unattached to any flow rule. Multiple flows can then be created using the same indirect action. The new API also supports query operation of an indirect action. The new API is more efficient because the driver gets it's own handler for the count action instead of managing a mapping between the user ID to the driver handle. Support create, query and destroy indirect action operations for flow count action. Application will use the indirect action query operation to query this count action. In the meantime the old sharing mechanism (with the sharing flag) continues to be supported, and the user can choose the way he wants to share the counter. The new indirect action API is only supported in DevX, so sharing counter action in Verbs can only be done through the old mechanism. [1] https://mails.dpdk.org/archives/dev/2020-July/174110.html Signed-off-by: Michael Baum Acked-by: Matan Azrad --- doc/guides/nics/mlx5.rst | 13 +- doc/guides/rel_notes/release_21_05.rst | 1 + drivers/net/mlx5/mlx5.h | 7 +- drivers/net/mlx5/mlx5_defs.h | 2 +- drivers/net/mlx5/mlx5_flow.c | 6 + drivers/net/mlx5/mlx5_flow.h | 3 +- drivers/net/mlx5/mlx5_flow_dv.c | 222 ++++++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_verbs.c | 2 +- 8 files changed, 175 insertions(+), 81 deletions(-) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 2bb4f18..b2c357e 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -1692,10 +1692,15 @@ Supported hardware offloads | | | | | rdma-core 33 | | | | | | ConnectX-5 | +-----------------------+-----------------+-----------------+ - | Age | | DPDK 20.11 | | DPDK 20.11 | - | | | OFED 5.2 | | OFED 5.2 | - | | | rdma-core 32 | | rdma-core 32 | - | | | ConnectX-6 Dx| | ConnectX-6 Dx | + | Age | | DPDK 20.11 | | DPDK 20.11 | + | | | OFED 5.2 | | OFED 5.2 | + | | | rdma-core 32 | | rdma-core 32 | + | | | ConnectX-6 Dx | | ConnectX-6 Dx | + +-----------------------+-----------------+-----------------+ + | Count | | DPDK 21.05 | | DPDK 21.05 | + | | | OFED 4.6 | | OFED 4.6 | + | | | rdma-core 24 | | rdma-core 23 | + | | | ConnectX-5 | | ConnectX-5 | +-----------------------+-----------------+-----------------+ Notes for metadata diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index b3224dc..740a729 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -161,6 +161,7 @@ New Features Updated the Mellanox mlx5 driver with new features and improvements, including: * Added support for VXLAN and NVGRE encap as sample actions. + * Added support for flow COUNT action handle. * Support push VLAN on ingress traffic and pop VLAN on egress traffic in E-Switch mode. * Added support for ASO (Advanced Steering Operation) meter. diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 378b68e..626abb4 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -291,7 +291,7 @@ struct mlx5_drop { #define MLX5_MAX_PENDING_QUERIES 4 #define MLX5_CNT_CONTAINER_RESIZE 64 #define MLX5_CNT_SHARED_OFFSET 0x80000000 -#define IS_SHARED_CNT(cnt) (!!((cnt) & MLX5_CNT_SHARED_OFFSET)) +#define IS_LEGACY_SHARED_CNT(cnt) (!!((cnt) & MLX5_CNT_SHARED_OFFSET)) #define IS_BATCH_CNT(cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \ MLX5_CNT_BATCH_OFFSET) #define MLX5_CNT_SIZE (sizeof(struct mlx5_flow_counter)) @@ -353,7 +353,10 @@ struct flow_counter_stats { /* Shared counters information for counters. */ struct mlx5_flow_counter_shared { - uint32_t id; /**< User counter ID. */ + union { + uint32_t refcnt; /* Only for shared action management. */ + uint32_t id; /* User counter ID for legacy sharing. */ + }; }; /* Shared counter configuration. */ diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index 6e9c4b9..906aa43 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -193,7 +193,7 @@ #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2) /* Maximum number of indirect actions supported by rte_flow */ -#define MLX5_MAX_INDIRECT_ACTIONS 2 +#define MLX5_MAX_INDIRECT_ACTIONS 3 /* * Linux definition of static_assert is found in /usr/include/assert.h. diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 34a4bb1..4f8591e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3540,6 +3540,12 @@ struct mlx5_translated_action_handle { translated[handle->index].conf = &shared_rss->origin; break; + case MLX5_INDIRECT_ACTION_TYPE_COUNT: + translated[handle->index].type = + (enum rte_flow_action_type) + MLX5_RTE_FLOW_ACTION_TYPE_COUNT; + translated[handle->index].conf = (void *)(uintptr_t)idx; + break; case MLX5_INDIRECT_ACTION_TYPE_AGE: if (priv->sh->flow_hit_aso_en) { translated[handle->index].type = diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 56908ae..432fd25 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -36,8 +36,8 @@ enum mlx5_rte_flow_action_type { MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS, MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET, MLX5_RTE_FLOW_ACTION_TYPE_AGE, - MLX5_RTE_FLOW_ACTION_TYPE_JUMP, MLX5_RTE_FLOW_ACTION_TYPE_COUNT, + MLX5_RTE_FLOW_ACTION_TYPE_JUMP, }; #define MLX5_INDIRECT_ACTION_TYPE_OFFSET 30 @@ -45,6 +45,7 @@ enum mlx5_rte_flow_action_type { enum { MLX5_INDIRECT_ACTION_TYPE_RSS, MLX5_INDIRECT_ACTION_TYPE_AGE, + MLX5_INDIRECT_ACTION_TYPE_COUNT, }; /* Matches on selected register. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index b07c135..7174e9b 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3147,12 +3147,32 @@ struct field_modify_info modify_tcp[] = { } /** + * Check if action counter is shared by either old or new mechanism. + * + * @param[in] action + * Pointer to the action structure. + * + * @return + * True when counter is shared, false otherwise. + */ +static inline bool +is_shared_action_count(const struct rte_flow_action *action) +{ + const struct rte_flow_action_count *count = + (const struct rte_flow_action_count *)action->conf; + + if ((int)action->type == MLX5_RTE_FLOW_ACTION_TYPE_COUNT) + return true; + return !!(count && count->shared); +} + +/** * Validate count action. * * @param[in] dev * Pointer to rte_eth_dev structure. - * @param[in] action - * Pointer to the action structure. + * @param[in] shared + * Indicator if action is shared. * @param[in] action_flags * Holds the actions detected until now. * @param[out] error @@ -3162,13 +3182,11 @@ struct field_modify_info modify_tcp[] = { * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_dv_validate_action_count(struct rte_eth_dev *dev, - const struct rte_flow_action *action, +flow_dv_validate_action_count(struct rte_eth_dev *dev, bool shared, uint64_t action_flags, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; - const struct rte_flow_action_count *count; if (!priv->config.devx) goto notsup_err; @@ -3176,8 +3194,7 @@ struct field_modify_info modify_tcp[] = { return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "duplicate count actions set"); - count = (const struct rte_flow_action_count *)action->conf; - if (count && count->shared && (action_flags & MLX5_FLOW_ACTION_AGE) && + if (shared && (action_flags & MLX5_FLOW_ACTION_AGE) && !priv->sh->flow_hit_aso_en) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, @@ -5254,7 +5271,7 @@ struct mlx5_hlist_entry * break; case RTE_FLOW_ACTION_TYPE_COUNT: ret = flow_dv_validate_action_count - (dev, act, + (dev, is_shared_action_count(act), *action_flags | sub_action_flags, error); if (ret < 0) @@ -5424,7 +5441,7 @@ struct mlx5_hlist_entry * * @param[in] idx * mlx5 flow counter index in the container. * @param[out] ppool - * mlx5 flow counter pool in the container, + * mlx5 flow counter pool in the container. * * @return * Pointer to the counter, NULL otherwise. @@ -5554,7 +5571,7 @@ struct mlx5_hlist_entry * * * @param[in] dev * Pointer to the Ethernet device structure. - * @param[in] cnt + * @param[in] counter * Index to the flow counter. * @param[out] pkts * The statistics value of packets. @@ -5795,6 +5812,13 @@ struct mlx5_hlist_entry * if (!fallback && !priv->sh->cmng.query_thread_on) /* Start the asynchronous batch query by the host thread. */ mlx5_set_query_alarm(priv->sh); + /* + * When the count action isn't shared (by ID), shared_info field is + * used for indirect action API's refcnt. + * When the counter action is not shared neither by ID nor by indirect + * action API, shared info must be 1. + */ + cnt_free->shared_info.refcnt = 1; return cnt_idx; err: if (cnt_free) { @@ -5941,9 +5965,26 @@ struct mlx5_hlist_entry * return; cnt = flow_dv_counter_get_by_idx(dev, counter, &pool); MLX5_ASSERT(pool); - if (IS_SHARED_CNT(counter) && + /* + * If the counter action is shared by ID, the l3t_clear_entry function + * reduces its references counter. If after the reduction the action is + * still referenced, the function returns here and does not release it. + */ + if (IS_LEGACY_SHARED_CNT(counter) && mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl, cnt->shared_info.id)) return; + /* + * If the counter action is shared by indirect action API, the atomic + * function reduces its references counter. If after the reduction the + * action is still referenced, the function returns here and does not + * release it. + * When the counter action is not shared neither by ID nor by indirect + * action API, shared info is 1 before the reduction, so this condition + * is failed and function doesn't return here. + */ + if (!IS_LEGACY_SHARED_CNT(counter) && + __atomic_sub_fetch(&cnt->shared_info.refcnt, 1, __ATOMIC_RELAXED)) + return; if (pool->is_aged) flow_dv_counter_remove_from_age(dev, counter, cnt); cnt->pool = pool; @@ -5955,7 +5996,6 @@ struct mlx5_hlist_entry * * container counter list. The list changes while query starts. In * this case, lock will not be needed as query callback and release * function both operate with the different list. - * */ if (!priv->sh->cmng.counter_fallback) { rte_spinlock_lock(&pool->csl); @@ -6274,7 +6314,6 @@ struct mlx5_hlist_entry * const struct rte_flow_action_raw_encap *encap; const struct rte_flow_action_rss *rss = NULL; const struct rte_flow_action_rss *sample_rss = NULL; - const struct rte_flow_action_count *count = NULL; const struct rte_flow_action_count *sample_count = NULL; const struct rte_flow_item_tcp nic_tcp_mask = { .hdr = { @@ -6653,6 +6692,7 @@ struct mlx5_hlist_entry * } for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { int type = actions->type; + bool shared_count = false; if (!mlx5_flow_os_action_supported(type)) return rte_flow_error_set(error, ENOTSUP, @@ -6802,13 +6842,14 @@ struct mlx5_hlist_entry * action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; ++actions_n; break; + case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: case RTE_FLOW_ACTION_TYPE_COUNT: - ret = flow_dv_validate_action_count(dev, actions, + shared_count = is_shared_action_count(actions); + ret = flow_dv_validate_action_count(dev, shared_count, action_flags, error); if (ret < 0) return ret; - count = actions->conf; action_flags |= MLX5_FLOW_ACTION_COUNT; ++actions_n; break; @@ -7116,7 +7157,7 @@ struct mlx5_hlist_entry * * mutual exclusion with share counter actions. */ if (!priv->sh->flow_hit_aso_en) { - if (count && count->shared) + if (shared_count) return rte_flow_error_set (error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, @@ -9932,6 +9973,8 @@ struct mlx5_hlist_entry * * * @param[in] dev * Pointer to rte_eth_dev structure. + * @param[in] dev_flow + * Pointer to the mlx5_flow. * @param[out] count * Pointer to the counter action configuration. * @param[in] age @@ -9955,7 +9998,7 @@ struct mlx5_hlist_entry * counter = flow_dv_counter_alloc(dev, !!age); if (!counter || age == NULL) return counter; - age_param = flow_dv_counter_idx_get_age(dev, counter); + age_param = flow_dv_counter_idx_get_age(dev, counter); age_param->context = age->context ? age->context : (void *)(uintptr_t)(dev_flow->flow_idx); age_param->timeout = age->timeout; @@ -11266,12 +11309,12 @@ struct mlx5_cache_entry * const uint8_t *rss_key; struct mlx5_flow_tbl_resource *tbl; struct mlx5_aso_age_action *age_act; + struct mlx5_flow_counter *cnt_act; uint32_t port_id = 0; struct mlx5_flow_dv_port_id_action_resource port_id_resource; int action_type = actions->type; const struct rte_flow_action *found_action = NULL; uint32_t jump_group = 0; - struct mlx5_flow_counter *cnt; if (!mlx5_flow_os_action_supported(action_type)) return rte_flow_error_set(error, ENOTSUP, @@ -11412,6 +11455,15 @@ struct mlx5_cache_entry * dev_flow->dv.actions[actions_n++] = age_act->dr_action; action_flags |= MLX5_FLOW_ACTION_AGE; break; + case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: + flow->counter = (uint32_t)(uintptr_t)(action->conf); + cnt_act = flow_dv_counter_get_by_idx(dev, flow->counter, + NULL); + __atomic_fetch_add(&cnt_act->shared_info.refcnt, 1, + __ATOMIC_RELAXED); + /* 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) { /* @@ -11452,12 +11504,6 @@ struct mlx5_cache_entry * age = action->conf; action_flags |= MLX5_FLOW_ACTION_COUNT; break; - case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: - cnt = flow_dv_counter_get_by_idx(dev, - (uint32_t)(uintptr_t)action->conf, NULL); - MLX5_ASSERT(cnt != NULL); - dev_flow->dv.actions[actions_n++] = cnt->action; - break; case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: dev_flow->dv.actions[actions_n++] = priv->sh->pop_vlan_action; @@ -13329,6 +13375,11 @@ struct mlx5_cache_entry * (void *)(uintptr_t)idx; } break; + case RTE_FLOW_ACTION_TYPE_COUNT: + ret = flow_dv_translate_create_counter(dev, NULL, NULL, NULL); + idx = (MLX5_INDIRECT_ACTION_TYPE_COUNT << + MLX5_INDIRECT_ACTION_TYPE_OFFSET) | ret; + break; default: rte_flow_error_set(err, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "action type not supported"); @@ -13362,11 +13413,25 @@ struct mlx5_cache_entry * uint32_t act_idx = (uint32_t)(uintptr_t)handle; uint32_t type = act_idx >> MLX5_INDIRECT_ACTION_TYPE_OFFSET; uint32_t idx = act_idx & ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1); + struct mlx5_flow_counter *cnt; + uint32_t no_flow_refcnt = 1; int ret; switch (type) { case MLX5_INDIRECT_ACTION_TYPE_RSS: return __flow_dv_action_rss_release(dev, idx, error); + case MLX5_INDIRECT_ACTION_TYPE_COUNT: + cnt = flow_dv_counter_get_by_idx(dev, idx, NULL); + if (!__atomic_compare_exchange_n(&cnt->shared_info.refcnt, + &no_flow_refcnt, 1, false, + __ATOMIC_ACQUIRE, + __ATOMIC_RELAXED)) + return rte_flow_error_set(error, EBUSY, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "Indirect count action has references"); + flow_dv_counter_free(dev, idx); + return 0; case MLX5_INDIRECT_ACTION_TYPE_AGE: ret = flow_dv_aso_age_release(dev, idx); if (ret) @@ -13494,37 +13559,6 @@ struct mlx5_cache_entry * } } -static int -flow_dv_action_query(struct rte_eth_dev *dev, - const struct rte_flow_action_handle *handle, void *data, - struct rte_flow_error *error) -{ - struct mlx5_age_param *age_param; - struct rte_flow_query_age *resp; - uint32_t act_idx = (uint32_t)(uintptr_t)handle; - uint32_t type = act_idx >> MLX5_INDIRECT_ACTION_TYPE_OFFSET; - uint32_t idx = act_idx & ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1); - - switch (type) { - case MLX5_INDIRECT_ACTION_TYPE_AGE: - age_param = &flow_aso_age_get_by_idx(dev, idx)->age_params; - resp = data; - resp->aged = __atomic_load_n(&age_param->state, - __ATOMIC_RELAXED) == AGE_TMOUT ? - 1 : 0; - resp->sec_since_last_hit_valid = !resp->aged; - if (resp->sec_since_last_hit_valid) - resp->sec_since_last_hit = __atomic_load_n - (&age_param->sec_since_last_hit, __ATOMIC_RELAXED); - return 0; - default: - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, - "action type query not supported"); - } -} - /** * Destroy the meter sub policy table rules. * Lock free, (mutex should be acquired by caller). @@ -14076,14 +14110,14 @@ struct mlx5_cache_entry * } /** - * Query a dv flow rule for its statistics via devx. + * Query a DV flow rule for its statistics via DevX. * * @param[in] dev * Pointer to Ethernet device. - * @param[in] flow - * Pointer to the sub flow. + * @param[in] cnt_idx + * Index to the flow counter. * @param[out] data - * data retrieved by the query. + * Data retrieved by the query. * @param[out] error * Perform verbose error reporting if not NULL. * @@ -14091,8 +14125,8 @@ struct mlx5_cache_entry * * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_dv_query_count(struct rte_eth_dev *dev, struct rte_flow *flow, - void *data, struct rte_flow_error *error) +flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data, + struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; struct rte_flow_query_count *qc = data; @@ -14102,19 +14136,16 @@ struct mlx5_cache_entry * RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "counters are not supported"); - if (flow->counter) { + if (cnt_idx) { uint64_t pkts, bytes; struct mlx5_flow_counter *cnt; - - cnt = flow_dv_counter_get_by_idx(dev, flow->counter, - NULL); - int err = _flow_dv_query_count(dev, flow->counter, &pkts, - &bytes); + int err = _flow_dv_query_count(dev, cnt_idx, &pkts, &bytes); if (err) return rte_flow_error_set(error, -err, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot read counters"); + cnt = flow_dv_counter_get_by_idx(dev, cnt_idx, NULL); qc->hits_set = 1; qc->bytes_set = 1; qc->hits = pkts - cnt->hits; @@ -14131,6 +14162,38 @@ struct mlx5_cache_entry * "counters are not available"); } +static int +flow_dv_action_query(struct rte_eth_dev *dev, + const struct rte_flow_action_handle *handle, void *data, + struct rte_flow_error *error) +{ + struct mlx5_age_param *age_param; + struct rte_flow_query_age *resp; + uint32_t act_idx = (uint32_t)(uintptr_t)handle; + uint32_t type = act_idx >> MLX5_INDIRECT_ACTION_TYPE_OFFSET; + uint32_t idx = act_idx & ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1); + + switch (type) { + case MLX5_INDIRECT_ACTION_TYPE_AGE: + age_param = &flow_aso_age_get_by_idx(dev, idx)->age_params; + resp = data; + resp->aged = __atomic_load_n(&age_param->state, + __ATOMIC_RELAXED) == AGE_TMOUT ? + 1 : 0; + resp->sec_since_last_hit_valid = !resp->aged; + if (resp->sec_since_last_hit_valid) + resp->sec_since_last_hit = __atomic_load_n + (&age_param->sec_since_last_hit, __ATOMIC_RELAXED); + return 0; + case MLX5_INDIRECT_ACTION_TYPE_COUNT: + return flow_dv_query_count(dev, idx, data, error); + default: + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "action type query not supported"); + } +} + /** * Query a flow rule AGE action for aging information. * @@ -14200,7 +14263,8 @@ struct mlx5_cache_entry * case RTE_FLOW_ACTION_TYPE_VOID: break; case RTE_FLOW_ACTION_TYPE_COUNT: - ret = flow_dv_query_count(dev, flow, data, error); + ret = flow_dv_query_count(dev, flow->counter, data, + error); break; case RTE_FLOW_ACTION_TYPE_AGE: ret = flow_dv_query_age(dev, flow, data, error); @@ -15242,7 +15306,7 @@ struct mlx5_cache_entry * * @param[in] dev * Pointer to the Ethernet device structure. * @param[in] conf - * Shared action configuration. + * Indirect action configuration. * @param[in] action * The indirect action object to validate. * @param[out] error @@ -15269,22 +15333,36 @@ struct mlx5_cache_entry * * sufficient, it is set to devx_obj_ops. * Otherwise, it is set to ibv_obj_ops. * ibv_obj_ops doesn't support ind_table_modify operation. - * In this case the shared RSS action can't be used. + * In this case the indirect RSS action can't be used. */ if (priv->obj_ops.ind_table_modify == NULL) return rte_flow_error_set (err, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, - "shared RSS action not supported"); + "Indirect RSS action not supported"); return mlx5_validate_action_rss(dev, action, err); case RTE_FLOW_ACTION_TYPE_AGE: if (!priv->sh->aso_age_mng) return rte_flow_error_set(err, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "shared age action not supported"); + "Indirect age action not supported"); return flow_dv_validate_action_age(0, action, dev, err); + case RTE_FLOW_ACTION_TYPE_COUNT: + /* + * There are two mechanisms to share the action count. + * The old mechanism uses the shared field to share, while the + * new mechanism uses the indirect action API. + * This validation comes to make sure that the two mechanisms + * are not combined. + */ + if (is_shared_action_count(action)) + return rte_flow_error_set(err, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "Mix shared and indirect counter is not supported"); + return flow_dv_validate_action_count(dev, true, 0, err); default: return rte_flow_error_set(err, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 0fdafbb..fe96733 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -357,7 +357,7 @@ struct ibv_spec_header { struct mlx5_flow_counter *cnt; cnt = flow_verbs_counter_get_by_idx(dev, counter, &pool); - if (IS_SHARED_CNT(counter) && + if (IS_LEGACY_SHARED_CNT(counter) && mlx5_l3t_clear_entry(priv->sh->cnt_id_tbl, cnt->shared_info.id)) return; #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) From patchwork Mon Apr 26 12:42:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 92174 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 3661CA0548; Mon, 26 Apr 2021 14:43:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E06B411D0; Mon, 26 Apr 2021 14:43:24 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by mails.dpdk.org (Postfix) with ESMTP id A26C9411C2 for ; Mon, 26 Apr 2021 14:43:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cI/Aqd13zdlyWuEqc+uelxp/AzUaiz4BiheBLr2vRevtqIsPpZJKu6+bxQFLMkY3CxG9x5SJmGsEb2vXwFMS+rJDMQKWFFwyr/IBXzNJswqskIsZVll7S49o0uNjyzkctMe8nHZkngwKU/Q7sT+BJhxBR46NjCPyiDSoG8Bscskl0glKDoUgrM63DT0MrfbXNntQ8qSEFY90nsfdRzucgHHsZ1PH2nhqcNsJu9Z+A1LGhBo0balnXJbs04nRq/xRlXQynxu3xMWVESzqRhmrZixzzAMW5AmUQl3mvjfvz4WH4mx+xt7DjD4NzYk6sXabF7p3KMlQED3ZU5SY5jLWoA== 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=oaAY35EzEuSA4b3asjWjd4Lbd0H8BXoThSSlVpvKVVI=; b=ih0g6ZgzAqZjwZs3RgHdC/HUOFSVn9/x9ec4UQ455vIaCoJBa/dbyV12hOXWk1ByeNAuD/82VwH/dXfmGEJbh/TW3wO3QF0ZjzWCv77xI72EBnZ+Jq/sq3Xj49uDmA8JR7ZNnqjxZP0cJ9+YVMfZRMZSyBdMrHo84HRByLGysWnCheH3r/bKBM/+QTeIfSk95DZn93FO0vzbI5DsminLQfVapo3+yBAJI4Dq1zh1qEJDNrKdntgoVdAqtYF2j8E4ERtyx7dXbqEt0YSO5VSY9HbNSRKrPTEjOkRe1318OUWOEpoTDB/S1OTasozHnMVgJ8ym4qPw6uxat/lKLdidNw== 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=oaAY35EzEuSA4b3asjWjd4Lbd0H8BXoThSSlVpvKVVI=; b=hSOPi0wrR5iJCepqlUT9eGYSrk3MoTPVgAdOJobUvgBbUFrNwTQfZ2ufTxSEo8q40+R3LErhSt0x5741TIooLfvC4P8JjK7i1WfmoCsqEpom++YeYYH1YFqdkqXpBsfeeq6cqMkMgpuCmlEd0VA1BEJ8D85LL3nEHX3AGqz2oC9AueYfI7B8rcY3l3scLSfJ7znFsJ9+xMEz+OfSOTI9x5hZ5+RzefYNPqXtYpa7eZM//Dv/sR6oI0MdSGMKMSl65uxOHyfimUw0uPfxO+VKakJKrg2JlT2raieHJkNg/nVAUq0szlOGvgNRwU5GOZbJlfijQCVix787qkAEXVto1Q== Received: from DM5PR12CA0059.namprd12.prod.outlook.com (2603:10b6:3:103::21) by BY5PR12MB3777.namprd12.prod.outlook.com (2603:10b6:a03:1a9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Mon, 26 Apr 2021 12:43:20 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:3:103:cafe::56) by DM5PR12CA0059.outlook.office365.com (2603:10b6:3:103::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Mon, 26 Apr 2021 12:43:19 +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 DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) 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:19 +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:17 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Mon, 26 Apr 2021 15:42:47 +0300 Message-ID: <20210426124250.42771-3-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: 2e7b2158-12bf-4b03-8577-08d908b0def9 X-MS-TrafficTypeDiagnostic: BY5PR12MB3777: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:483; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g4uS0YwBvaoO9gG/IQCbpDyQQ71k2rdUD5X/ecLFF2jSNvQ8pjbfT3h5fdD2py8Esxw/Vj1tcPHrPZh0fTbCe31iWU50fgh4yXGnBMksNZnuXQf40g87h5KyHkXmdJ4R1stvQPK6L/1nGNCOpYWqM/dj6mwexor7YfSRcUVNP4Ma2NRElnqvXLBg/YuoL/nbWclWFClK6B/+G0gUGl8FQjarpkGFjSCLuWpxVeEPPGJeskDEP7KAEwyqDgOjDmqauDMSEVytbzWkN4iYWokMMatUYHJFaP5tzoVvMkb45KzGdyPD1i73IMKoCuRTM1zB2+yAmlW8G3VFWiDnLq60xZV09rCKg4QiSGyuMCCfXQWqaDm1rBB0KP4eNOcnbCIz4uX/po/wSgSeqSMK6uveWcgQBYnq4p2YJa5zHfisYmzp307FmvzWZ7kDNB1pwWJNFo9TVChSwFMISaom4mBtYXIsIzqgZJVbE8fVdzne/z2bmGMLV4zVmb4Hq4S94FOW/g0Ds9L2PUc+s6NoA1tDpsdkRmemRVvizxQz0QAPDd+uVJxNYujvfdd6zUe1VVSvguGRP6khjnBm2bjozWufj2Ei0KVZMkCvT9gFifHDVcKFQm5tF52ofZ84hyA7rs3RveFiuTUPxC0BHXgeUDNhAOQrHhwnWQVuPYf21acSyV4= 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)(376002)(39860400002)(346002)(136003)(46966006)(36840700001)(55016002)(5660300002)(1076003)(2616005)(7696005)(2906002)(47076005)(316002)(6286002)(16526019)(36906005)(70586007)(36860700001)(70206006)(107886003)(426003)(336012)(186003)(26005)(6666004)(54906003)(4326008)(356005)(82310400003)(83380400001)(7636003)(36756003)(6916009)(86362001)(82740400003)(8676002)(8936002)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2021 12:43:19.6757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e7b2158-12bf-4b03-8577-08d908b0def9 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: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3777 Subject: [dpdk-dev] [PATCH 2/5] app/testpmd: remove indirect RSS action query 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 port_action_handle_query function supports query operation for indirect RSS action. No driver currently supports this operation, and this support is unnecessary. Remove it. Signed-off-by: Michael Baum Acked-by: Matan Azrad Acked-by: Ori Kam --- app/test-pmd/config.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index e189062..a9805cc 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1626,7 +1626,6 @@ struct rte_flow_action_handle * if (!pia) return -EINVAL; switch (pia->type) { - case RTE_FLOW_ACTION_TYPE_RSS: case RTE_FLOW_ACTION_TYPE_AGE: data = &default_data; break; @@ -1638,12 +1637,6 @@ struct rte_flow_action_handle * if (rte_flow_action_handle_query(port_id, pia->handle, data, &error)) ret = port_flow_complain(&error); switch (pia->type) { - case RTE_FLOW_ACTION_TYPE_RSS: - if (!ret) - printf("Shared RSS action:\n\trefs:%u\n", - *((uint32_t *)data)); - data = NULL; - break; case RTE_FLOW_ACTION_TYPE_AGE: if (!ret) { struct rte_flow_query_age *resp = data; From patchwork Mon Apr 26 12:42:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 92175 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 0FB88A0548; Mon, 26 Apr 2021 14:43:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7765C411C4; Mon, 26 Apr 2021 14:43:25 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2065.outbound.protection.outlook.com [40.107.236.65]) by mails.dpdk.org (Postfix) with ESMTP id A11F4411C4 for ; Mon, 26 Apr 2021 14:43:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jLuuLNhNzHQGsTpK36su45g4N6BqXxO+MklgHcn9Sr/XpfvdVJ/qN6/XHBytMKWfS4NOKHENluUzgQRfXt5yOGoHzNjOUpj2GBrw92hQU2qo2P3FmZB9SQxo6u/oqmBVjfmjq3p8jevVDl+ThWm0wr1yFfPqKRgePUdfUxfGeHTPBL/1rwCBumpXVvWrS2UCvF0u8mRhPMjGM33uiADrUaVOa2IVYZbd0oXY9LiIK551Q2VkZuDBKLTKyXiToSx0cdazwfdi6ew1B83EQ+3ugWEndDINvAOLG0F4V+7HQkJ7NQcIUoBrTwHhBy7hA8An/2XE3FqpShHlNfbesUc+tA== 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=KmPmZXYLMxXsCp6KvhuuAAdY5Z543NPJGxFfzqRVlyA=; b=OgK3s/XVjcLVAKpAICAzRPUkXoeQ9bXBFFVQT9nUmXCn4EoB0FJfRLfO4EqrskXatn5Bswpg/A1tVkkENHlorte57lz0LTOp7Ht52czpI9vN6dGEfNu4zEhviVVJz1+oQMiP85B6rOCWFqlRlqJ9wJKqg6lNOUTS5gUJpZ+8Q6K8jFzBDh9iaYd4HrVM7p6EuPwMHcJhzY27ptOTjnHx7SL7B/ipaCBTINu0WoGRHLPT4k3AlXF566RAbaf09HZHL1Uj+Xyl4Xdbt2nWJp9EHtMv3XJXR72s/q+KvLM2zt32QKEBVOvLec69TrgRZWjmZY0R2zHNt+EGeUwG+r6Zdg== 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=KmPmZXYLMxXsCp6KvhuuAAdY5Z543NPJGxFfzqRVlyA=; b=FdSmKvmqmjq5V8ituGxHrWN+F7vvqHLNaw411GtWdJlNXZC+pxjqB87mHlny2YvH/WJcwsDG1OylRE81/mqrCWkL1GZNOjOTVUpUMtfXgYiSgZ++GoL/IWMPieVUB6UaptfBN3MDk0ZQPj6cNf546fM4gTZqv2CHqujlHrzsURGnWICFDkz+AqbZFd98awKv6jOnvftnwh8bguXx57DQ8Uh8ibCanQ8yp+uvSqqEZSty/tl1lby5GpzUmh9iXO+wTOAWr0iydVe49DEUYn59fzdCHGALAdalKaQA+7VqLN0VT8XnuDu2QhNN/aX8EP1XGyhIf3z51zt9GCF4wJQjwg== Received: from DM6PR02CA0041.namprd02.prod.outlook.com (2603:10b6:5:177::18) by DM5PR12MB1881.namprd12.prod.outlook.com (2603:10b6:3:10f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Mon, 26 Apr 2021 12:43:21 +0000 Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::fa) by DM6PR02CA0041.outlook.office365.com (2603:10b6:5:177::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.20 via Frontend Transport; Mon, 26 Apr 2021 12:43:21 +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 DM6NAM11FT039.mail.protection.outlook.com (10.13.172.83) 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:21 +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:19 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Mon, 26 Apr 2021 15:42:48 +0300 Message-ID: <20210426124250.42771-4-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: 5390762f-c7ee-434f-f808-08d908b0dff3 X-MS-TrafficTypeDiagnostic: DM5PR12MB1881: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:556; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1zz/1SaLPNvOCln2Cvmgjf5TpHgC81XyhfvxN9AHO2L7tQgmekMV/n0gFwjCYYuVMVZB15J5IhQwgcmjHC8oDlHAjEx/Q78qwSkVtlcX3Q+xNW6MUiij71jXN9BSDWX32Fu93jHW/BQ+Xpgh4tG+ChptpVDgJ5MG64U84hOEgOMNtrxHOA0x292KCZYfV7JQS+/gfZ4zPWP2NrgCpyaJQ30zJ2hWs/X6P4+HM+bcesJza4xEAIGmWJAaCpYDM/+tTQRPV3V4oXYKRngDlMHYPxTroNxRmpXKCRSFqNciKCwSW/GGoGNzYLFDleYjrOOT5cpv2QXfcT0y8aBA2PLI0YCH1KcyVW3J2DKvnsmKa47pP5zzXK3KzZBhzMK5ylqPTua4bEwxlGAzG6h6U915aqES5MHC583d6h91NveaZrh3wOvSoa48fomNADnQePwECJqzk7ZOQ9juxO5vGR/77UlEC4MtbT0BSZ5ZpEK9KTSku+I2y5i1qsfIQ6orO6TaYvrJW+fhGgyXuQtaWNazbRzA6p8evA6TVUmkVKB8E1ctI0PGF/in+s19HY3/rGb9StqZEUIDCHqBcM0V4u1xBMbIigEsM9fmmGSUKSbzYkZ/aky8luXZUW/XIf30ErnzPWFNUjRA7YeMikCH5WSOfG4q8CTbCOY1nql0J1EvreI= 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)(396003)(136003)(39860400002)(376002)(36840700001)(46966006)(336012)(478600001)(70206006)(6666004)(55016002)(7636003)(8936002)(356005)(36756003)(8676002)(82310400003)(82740400003)(26005)(2906002)(54906003)(86362001)(316002)(1076003)(36906005)(6286002)(6916009)(83380400001)(36860700001)(70586007)(47076005)(107886003)(5660300002)(4326008)(2616005)(7696005)(16526019)(186003)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2021 12:43:21.3090 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5390762f-c7ee-434f-f808-08d908b0dff3 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: DM6NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1881 Subject: [dpdk-dev] [PATCH 3/5] app/testpmd: support indirect counter action query 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" Counter action query was implemented as part of flow query, but was not implemented as part of indirect action query. This patch adds the required implementation. Signed-off-by: Michael Baum Acked-by: Matan Azrad Acked-by: Ori Kam --- app/test-pmd/config.c | 145 +++++++++++++++++++++++++++----------------------- 1 file changed, 77 insertions(+), 68 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a9805cc..bedbfcb 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1618,90 +1618,99 @@ struct rte_flow_action_handle * { struct rte_flow_error error; struct port_indirect_action *pia; - uint64_t default_data; - void *data = NULL; - int ret = 0; + union { + struct rte_flow_query_count count; + struct rte_flow_query_age age; + struct rte_flow_action_conntrack ct; + } query; pia = action_get_by_id(port_id, id); if (!pia) return -EINVAL; switch (pia->type) { case RTE_FLOW_ACTION_TYPE_AGE: - data = &default_data; + case RTE_FLOW_ACTION_TYPE_COUNT: break; default: - printf("Indirect action %u (type: %d) on port %u doesn't" - " support query\n", id, pia->type, port_id); - return -1; + printf("Indirect action %u (type: %d) on port %u doesn't support query\n", + id, pia->type, port_id); + return -ENOTSUP; } - if (rte_flow_action_handle_query(port_id, pia->handle, data, &error)) - ret = port_flow_complain(&error); + /* Poisoning to make sure PMDs update it in case of error. */ + memset(&error, 0x55, sizeof(error)); + memset(&query, 0, sizeof(query)); + if (rte_flow_action_handle_query(port_id, pia->handle, &query, &error)) + return port_flow_complain(&error); switch (pia->type) { case RTE_FLOW_ACTION_TYPE_AGE: - if (!ret) { - struct rte_flow_query_age *resp = data; - - printf("AGE:\n" - " aged: %u\n" - " sec_since_last_hit_valid: %u\n" - " sec_since_last_hit: %" PRIu32 "\n", - resp->aged, - resp->sec_since_last_hit_valid, - resp->sec_since_last_hit); - } - data = NULL; + printf("Indirect AGE action:\n" + " aged: %u\n" + " sec_since_last_hit_valid: %u\n" + " sec_since_last_hit: %" PRIu32 "\n", + query.age.aged, + query.age.sec_since_last_hit_valid, + query.age.sec_since_last_hit); + break; + case RTE_FLOW_ACTION_TYPE_COUNT: + printf("Indirect COUNT action:\n" + " hits_set: %u\n" + " bytes_set: %u\n" + " hits: %" PRIu64 "\n" + " bytes: %" PRIu64 "\n", + query.count.hits_set, + query.count.bytes_set, + query.count.hits, + query.count.bytes); break; case RTE_FLOW_ACTION_TYPE_CONNTRACK: - if (!ret) { - struct rte_flow_action_conntrack *ct = data; - - printf("Conntrack Context:\n" - " Peer: %u, Flow dir: %s, Enable: %u\n" - " Live: %u, SACK: %u, CACK: %u\n" - " Packet dir: %s, Liberal: %u, State: %u\n" - " Factor: %u, Retrans: %u, TCP flags: %u\n" - " Last Seq: %u, Last ACK: %u\n" - " Last Win: %u, Last End: %u\n", - ct->peer_port, - ct->is_original_dir ? "Original" : "Reply", - ct->enable, ct->live_connection, - ct->selective_ack, ct->challenge_ack_passed, - ct->last_direction ? "Original" : "Reply", - ct->liberal_mode, ct->state, - ct->max_ack_window, ct->retransmission_limit, - ct->last_index, ct->last_seq, ct->last_ack, - ct->last_window, ct->last_end); - printf(" Original Dir:\n" - " scale: %u, fin: %u, ack seen: %u\n" - " unacked data: %u\n Sent end: %u," - " Reply end: %u, Max win: %u, Max ACK: %u\n", - ct->original_dir.scale, - ct->original_dir.close_initiated, - ct->original_dir.last_ack_seen, - ct->original_dir.data_unacked, - ct->original_dir.sent_end, - ct->original_dir.reply_end, - ct->original_dir.max_win, - ct->original_dir.max_ack); - printf(" Reply Dir:\n" - " scale: %u, fin: %u, ack seen: %u\n" - " unacked data: %u\n Sent end: %u," - " Reply end: %u, Max win: %u, Max ACK: %u\n", - ct->reply_dir.scale, - ct->reply_dir.close_initiated, - ct->reply_dir.last_ack_seen, - ct->reply_dir.data_unacked, - ct->reply_dir.sent_end, ct->reply_dir.reply_end, - ct->reply_dir.max_win, ct->reply_dir.max_ack); - } - data = NULL; + printf("Conntrack Context:\n" + " Peer: %u, Flow dir: %s, Enable: %u\n" + " Live: %u, SACK: %u, CACK: %u\n" + " Packet dir: %s, Liberal: %u, State: %u\n" + " Factor: %u, Retrans: %u, TCP flags: %u\n" + " Last Seq: %u, Last ACK: %u\n" + " Last Win: %u, Last End: %u\n", + query.ct.peer_port, + query.ct.is_original_dir ? "Original" : "Reply", + query.ct.enable, query.ct.live_connection, + query.ct.selective_ack, query.ct.challenge_ack_passed, + query.ct.last_direction ? "Original" : "Reply", + query.ct.liberal_mode, query.ct.state, + query.ct.max_ack_window, query.ct.retransmission_limit, + query.ct.last_index, query.ct.last_seq, + query.ct.last_ack, query.ct.last_window, + query.ct.last_end); + printf(" Original Dir:\n" + " scale: %u, fin: %u, ack seen: %u\n" + " unacked data: %u\n Sent end: %u," + " Reply end: %u, Max win: %u, Max ACK: %u\n", + query.ct.original_dir.scale, + query.ct.original_dir.close_initiated, + query.ct.original_dir.last_ack_seen, + query.ct.original_dir.data_unacked, + query.ct.original_dir.sent_end, + query.ct.original_dir.reply_end, + query.ct.original_dir.max_win, + query.ct.original_dir.max_ack); + printf(" Reply Dir:\n" + " scale: %u, fin: %u, ack seen: %u\n" + " unacked data: %u\n Sent end: %u," + " Reply end: %u, Max win: %u, Max ACK: %u\n", + query.ct.reply_dir.scale, + query.ct.reply_dir.close_initiated, + query.ct.reply_dir.last_ack_seen, + query.ct.reply_dir.data_unacked, + query.ct.reply_dir.sent_end, + query.ct.reply_dir.reply_end, + query.ct.reply_dir.max_win, + query.ct.reply_dir.max_ack); break; default: - printf("Indirect action %u (type: %d) on port %u doesn't" - " support query\n", id, pia->type, port_id); - ret = -1; + printf("Indirect action %u (type: %d) on port %u doesn't support query\n", + id, pia->type, port_id); + break; } - return ret; + return 0; } static struct port_flow_tunnel * From patchwork Mon Apr 26 12:42:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 92177 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 8042BA0548; Mon, 26 Apr 2021 14:43:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 06275411DD; Mon, 26 Apr 2021 14:43:30 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by mails.dpdk.org (Postfix) with ESMTP id 9352C411D7; Mon, 26 Apr 2021 14:43:26 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRnsghlnmy6CoN1R2hLcXaqG7s4w4QAYS+MtJQVHr+Lgb+XmNJG4aYizGsEHc2lY6/vesBdanpDA9lDuuz6QOshqfqaQyvwWkQjjkFXk4YWdgKremdAxBwSWATf3o9ihY0Wh1P+WaVSEpPI2D3YGlawBHn87Gdl8tZ4xzOnNPbDeW8v0wIQ1OxAYDOzEq88o2dN+59bYotL6wUOryW2ByPpaOkH1X1M+lveBrG81e9TMnq4ZKIPbLSKaCFtDBn6ZW9n62yTBDq0Yga/4h0PBF4fgvvJnlyxVM4W0sfBRidkMI6P7B5Aa2Y5Dk+xF3Tx0xa/4jnuXX39zaIYOQFBsqg== 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=wx5F7EF0a+2MIOGVOSlZkKbylY3PU1yvs2Phfs31Ia0=; b=XRvYUthk8yJmcfH9DxNazbpEHBQpWrPFyeC5fN7WEWPYPggj8wg7RySzh1CBCACrPw6WK3lSRpU+2/AADb/8hlE1caVrvgewxu9/8JT5tlJR7ivhj8AOh+lmb5EK2Z3wI5Z2XcHyaSEwqiQybgResQ4OhzBRYU9DCYmXkqBUpUij/zuvSk/dz7HsKgdLsjNzz3+/JdC8IDY3cgttundXVzwLlQJPtzXhi293HBpicS8BS19fp8bvVd6eImTqrmqMs9HMd2AAfIt8KloDo3idmmuaPajwpYRQRVGANvVbYyuhA9DZ2p9bvfEUyvy4fIeCUjJ/Qq7N3jK/e8RhCcRCvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=fraudbuster.mobi 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=wx5F7EF0a+2MIOGVOSlZkKbylY3PU1yvs2Phfs31Ia0=; b=JoWIN6W+lHxvUpfT1p73X7lUidHpmcVAhe4R9ZGUBiwt4PfZzNU5P81hyD4o3rtoDuvNN/k7+h5bli3ZcfLv5zXgasDrXcMWQ1Qn5wcWFuFJYkSuO7nFlS6orCIuGFHQ9Lyv86NtB28pym/rMfktYNB384/uUUJla8wLstWmnwnqnFsc6lYZvPd0GDFbztv7cmecvmejV0CPsVptXXjSqKLTWM+7R+aXwpqp8pV1YCVTb0OikfRXF95h3i6vq2soCE/BiV64MZjjWk0TfKfLuUm8k6cQ1s59Qqk41EhZu7+Eax1+MtxnJfBVri7LOem1rvZM7tt7ofbT9LHk15lyHw== Received: from DM5PR21CA0060.namprd21.prod.outlook.com (2603:10b6:3:129::22) by MN2PR12MB3662.namprd12.prod.outlook.com (2603:10b6:208:164::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Mon, 26 Apr 2021 12:43:23 +0000 Received: from DM6NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:3:129:cafe::bd) by DM5PR21CA0060.outlook.office365.com (2603:10b6:3:129::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.1 via Frontend Transport; Mon, 26 Apr 2021 12:43:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; fraudbuster.mobi; dkim=none (message not signed) header.d=none;fraudbuster.mobi; 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:23 +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:21 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , , "David Bouyeure" Date: Mon, 26 Apr 2021 15:42:49 +0300 Message-ID: <20210426124250.42771-5-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: 6c915b5f-4e13-4d95-f2ba-08d908b0e11a X-MS-TrafficTypeDiagnostic: MN2PR12MB3662: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xLr2WiRwbIcrF3e2ZYK7+FXMFWT6eyhdpennFSx8sI1sfroNZyf5TlRPVXcp+Qz6lrKqujdBb5jPg6dIdPWn7X2k7FIZw6bf5e8M4M93yi4XjlZgEVtbqFYmo/A20IZvTYF+CojXmZG64RGOA7+7okt0awD+SUD1e3BPcV/ZTyndn9ZFdyPJGaUzly4ZQMqQ7/asD6g07jgarnVnS+ZPHyqX+mOHzjUyBW6l7r0TqpKbdR6ql5KeTahuze1AHMgkvxYwYBc1lclTTU4lp9ses1fIBvBmexvhn/kzodBZ87EYJIDfHoPyOLspk9Txto/vqDHlT3zpmnN+MMY3zBDi3TWGuDCZADITzFReTTgNWtwh6BDvMHUfWFIcp+jIW+OBd5NfQQrZlkJqsty2PpwEpqrNU45fqWFEUaa8dDVbYRhf/IMTwmkD01Rpo+0VZ6D6tJ3kiFMEIbGkIM9mCBp3iYtfECvC4cV4vAp2WNsEU6tPSwulo+HCrqwO99ua8+2vWcfoDO4s4mJ6ygS6lnjhN8Eqk1MNT1R4Svguo1e79ARU0k58AkR8tWFOerJ5hlhAIEdB1ANRfEKShy362w8v1k/Th0Ct2nxJTZahKaSHk2EikBu9xVXbwQYepNsdslRP9YOCptoP4w1e52fYmj5SSucLr2kgLVA/1Cwgd7DFmr8= 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)(39860400002)(396003)(346002)(136003)(376002)(46966006)(36840700001)(478600001)(36756003)(36860700001)(1076003)(336012)(8936002)(6916009)(16526019)(356005)(186003)(6286002)(4326008)(86362001)(8676002)(70206006)(26005)(54906003)(2616005)(6666004)(316002)(55016002)(82740400003)(7636003)(5660300002)(2906002)(70586007)(7696005)(82310400003)(36906005)(426003)(47076005)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2021 12:43:23.2392 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c915b5f-4e13-4d95-f2ba-08d908b0e11a 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: MN2PR12MB3662 Subject: [dpdk-dev] [PATCH 4/5] net/mlx5: fix flow age event triggering 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" A FLOW_AGE event should be invoked when a new aged-out flow is detected by the PMD after the last user get-aged query calling. The PMD manages 2 flags for this information and check them in order to decide if an event should be invoked: MLX5_AGE_EVENT_NEW - a new aged-out flow was detected. after the last check. MLX5_AGE_TRIGGER - get-aged query was called after the last aged-out flow. The 2 flags were unset after the event invoking. When the user calls get-aged query from the event callback, the TRIGGER flag was set inside the user callback and unset directly after the callback what may stop the event invoking forever. Unset the TRIGGER flag before the event invoking in order to allow set it by the user callback. Fixes: f935ed4b645a ("net/mlx5: support flow hit action for aging") Cc: stable@dpdk.org Reported-by: David Bouyeure Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5.c | 8 +++++--- drivers/net/mlx5/mlx5.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 19ffa16..10d44c7 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -662,11 +662,13 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list = age_info = &sh->port[i].age_info; if (!MLX5_AGE_GET(age_info, MLX5_AGE_EVENT_NEW)) continue; - if (MLX5_AGE_GET(age_info, MLX5_AGE_TRIGGER)) + MLX5_AGE_UNSET(age_info, MLX5_AGE_EVENT_NEW); + if (MLX5_AGE_GET(age_info, MLX5_AGE_TRIGGER)) { + MLX5_AGE_UNSET(age_info, MLX5_AGE_TRIGGER); rte_eth_dev_callback_process (&rte_eth_devices[sh->port[i].devx_ih_port_id], RTE_ETH_EVENT_FLOW_AGED, NULL); - age_info->flags = 0; + } } } @@ -675,7 +677,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list = * * @param[in] sh * Pointer to mlx5_dev_ctx_shared object. - * @param[in] sh + * @param[in] config * Pointer to user dev config. */ static void diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 626abb4..dfa029c 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -563,6 +563,8 @@ struct mlx5_geneve_tlv_option_resource { #define MLX5_AGE_TRIGGER 2 #define MLX5_AGE_SET(age_info, BIT) \ ((age_info)->flags |= (1 << (BIT))) +#define MLX5_AGE_UNSET(age_info, BIT) \ + ((age_info)->flags &= ~(1 << (BIT))) #define MLX5_AGE_GET(age_info, BIT) \ ((age_info)->flags & (1 << (BIT))) #define GET_PORT_AGE_INFO(priv) \ 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;