From patchwork Fri Jul 2 06:18:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 95170 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 8DBC6A0A0C; Fri, 2 Jul 2021 08:20:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF11941399; Fri, 2 Jul 2021 08:19:05 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2055.outbound.protection.outlook.com [40.107.237.55]) by mails.dpdk.org (Postfix) with ESMTP id 1D6E141397 for ; Fri, 2 Jul 2021 08:19:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dHH68ogAU6wFo186euZqVOTp7dYwxWvhW1x1TDGUw0+jAI46OdHU8u7C/Bhhjky88UR4bUwEhjsmj0aSgRyQokKduKr2GTt2F+PYz1oTX8Xyor1/e2FqagNB8GlAIvzPkXtcBCc0AxaY51OLTBh5ULlKXiyKy+3uB09AdSK08CFErnOdfH7szLE7MGPll7WAd12AwdW2zpzQe0OYf2yUCtbDKJKngJXfmoU1UaaX7Zy+Sv+grlG7rtXWw07x655YSjohCXTGNWAZ2VvWaHEGTGcjYIx1aoiQTZ3jaWECgMSajcsVn3H0WS0Wu83rsCG/ziZB5rWMgLsiKq1wts0p4A== 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=Dftkb3cHFwcYUXNoV0SGA1XfAJJSGTD5LlIc7jxBqvw=; b=S7zdn+aBSHB3pHAXffUU/lio3wj2c8p2FXPfnjukeL0GI+55u1dicXpG3S5AqqmH9+Oqb4Qmtcmnk38ziAKiJaj6BPEp0GEY+Eu2sUkf900byXGZIloU1Z5auXgdwgTD3eMGOU/VKR3RtcwRhlCi3606asx5Q9FO7zalr9gou/dEdY0XcheJpwB6bfvIdR3TbSCzuKBInuhL2Pq7QMQxkWI0lZPh/i9Qmscnfn1aNvTVe7Wpa2DtH0H1/BFAo746PyovKRlUlg58ZN674AljJbplc9hs7I8Cy7WkZRCHu56u+7wOxz8JsxqDotJAeT0oXYBTrn2C4X8esE6r2D8Bhw== 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=Dftkb3cHFwcYUXNoV0SGA1XfAJJSGTD5LlIc7jxBqvw=; b=kxnS06SKhndHdbyHlLOLsv7thqZR/izjbaor2uqPrTlqWJGxj6entaEU819+CNbqCJR91yL/SwtPHRGrQJQRv3uJtYbEhm9CdRiBvpvl7+3Bzk4Fzhw8BxeOh2lWmxmcAxYyeVhrvDLhDOaI3NG7++L9dNh1i/WYSsNDGCQdLI+K3wxgXxKK+ReyEAqd1AaQZEdL5fugY4/BkDciQ4vWgMoBO55fITgFWlX/m2Z3TqT9YGsbfZb5sYdkIUOhKPOX/iOHY+7wLx2sqyaLp1/FvaheF2JP2vs0rwR5sn+462fGdDqD8Wc594sb+xf7k6rzzW0MXXgu6tk7rul9C+WF5w== Received: from BN0PR04CA0156.namprd04.prod.outlook.com (2603:10b6:408:eb::11) by DM6PR12MB4252.namprd12.prod.outlook.com (2603:10b6:5:211::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Fri, 2 Jul 2021 06:19:01 +0000 Received: from BN8NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::ba) by BN0PR04CA0156.outlook.office365.com (2603:10b6:408:eb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23 via Frontend Transport; Fri, 2 Jul 2021 06:19:01 +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 BN8NAM11FT059.mail.protection.outlook.com (10.13.177.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Fri, 2 Jul 2021 06:19:01 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jul 2021 06:18:59 +0000 From: Suanming Mou To: , CC: , , Date: Fri, 2 Jul 2021 09:18:11 +0300 Message-ID: <20210702061816.10454-18-suanmingm@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210702061816.10454-1-suanmingm@nvidia.com> References: <20210527093403.1153127-1-suanmingm@nvidia.com> <20210702061816.10454-1-suanmingm@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] 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: 84ed67e9-1fbb-45c2-808d-08d93d2148f7 X-MS-TrafficTypeDiagnostic: DM6PR12MB4252: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fpCHU863PtgQrJk2TyHUZmBhBmJ3fMxS03UxjVJWEHw00MqBgxOTgRQokYRYIzX1vo1V41SvySrDYGX/DuxU7CEqe3UfpajhQd4kuBOIOWRZ9SW0OBRskD+dtx7vUTLaKVOLxu4crZcapXbdr/tB5reSMhbZFa0Pmdzk8yg1fi8khUId4fPJ7gA5bBdn+mvwve2vzp8/oOsSLZLGNkSu0OlnWtbmQUy/kkHXHcmaD7vfqbAd0cqvrWTY1fumJuWsmWf3VICI4wSWDjnK1aQmfPisM9tS0VqYVQhCzk49fVAee9lYvPgFE9dIsaXNfEtbQ5gk6y08Z+UxY3K5LMJc1NwvJxgJ73/7wje5hvOb5s8EkBISr9VFKX91xVbP1PPcbe0sX1LMSBXKDFhHSffzagJ1/9oPDdCHubVBN22/wmrSDnm6NTg9Dtey6bdYGHu1fzMxqaZpsmLlsHNMaDSKlQMj2C1oHSv2GJ5NseBVdOXZ+vynE58JAB4X9B9cSxQYJtQLNAthqNqbOc0BsB7wzoHNBRCU7S0Mvd0Wh3AJlnBRqLzH/gM8RObsCenlBiavqUrKSYrwpJBOkZ6qtIa27tVxe1AId4jcirMilkgQIHmG7hyOBnDWnDjbpTIxdGI7SiqcRTH9Mx+NFecgEzQsHQ5eziiAdp/TNGCtUIGmY5bcrFL5HRrrI1GkMpYGJrLnyUZsD+6KVaX541aoSMekmQ== 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)(376002)(39860400002)(36840700001)(46966006)(356005)(36756003)(83380400001)(478600001)(7696005)(2906002)(36906005)(336012)(110136005)(6286002)(6666004)(82310400003)(55016002)(47076005)(54906003)(316002)(1076003)(82740400003)(36860700001)(7636003)(86362001)(4326008)(186003)(8676002)(26005)(5660300002)(6636002)(70586007)(16526019)(8936002)(70206006)(2616005)(426003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2021 06:19:01.5291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84ed67e9-1fbb-45c2-808d-08d93d2148f7 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: BN8NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4252 Subject: [dpdk-dev] [PATCH v3 17/22] net/mlx5: optimize hash list table allocate on demand 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" Currently, all the hash list tables are allocated during start up. Since different applications may only use dedicated limited actions, optimized the hash list table allocate on demand will save initial memory. This commit optimizes hash list table allocate on demand. Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 44 +---------------- drivers/net/mlx5/mlx5_defs.h | 6 +++ drivers/net/mlx5/mlx5_flow_dv.c | 79 ++++++++++++++++++++++++++++-- drivers/net/mlx5/windows/mlx5_os.c | 2 - 4 files changed, 82 insertions(+), 49 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index a82dc4db00..75324e35d8 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -50,8 +50,6 @@ #include "mlx5_nl.h" #include "mlx5_devx.h" -#define MLX5_TAGS_HLIST_ARRAY_SIZE (1 << 15) - #ifndef HAVE_IBV_MLX5_MOD_MPW #define MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED (1 << 2) #define MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW (1 << 3) @@ -312,46 +310,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb); if (!sh->dest_array_list) goto error; - /* Create tags hash list table. */ - snprintf(s, sizeof(s), "%s_tags", sh->ibdev_name); - sh->tag_table = mlx5_hlist_create(s, MLX5_TAGS_HLIST_ARRAY_SIZE, false, - false, sh, flow_dv_tag_create_cb, - flow_dv_tag_match_cb, - flow_dv_tag_remove_cb, - flow_dv_tag_clone_cb, - flow_dv_tag_clone_free_cb); - if (!sh->tag_table) { - DRV_LOG(ERR, "tags with hash creation failed."); - err = ENOMEM; - goto error; - } - snprintf(s, sizeof(s), "%s_hdr_modify", sh->ibdev_name); - sh->modify_cmds = mlx5_hlist_create(s, MLX5_FLOW_HDR_MODIFY_HTABLE_SZ, - true, false, sh, - flow_dv_modify_create_cb, - flow_dv_modify_match_cb, - flow_dv_modify_remove_cb, - flow_dv_modify_clone_cb, - flow_dv_modify_clone_free_cb); - if (!sh->modify_cmds) { - DRV_LOG(ERR, "hdr modify hash creation failed"); - err = ENOMEM; - goto error; - } - snprintf(s, sizeof(s), "%s_encaps_decaps", sh->ibdev_name); - sh->encaps_decaps = mlx5_hlist_create(s, - MLX5_FLOW_ENCAP_DECAP_HTABLE_SZ, - true, true, sh, - flow_dv_encap_decap_create_cb, - flow_dv_encap_decap_match_cb, - flow_dv_encap_decap_remove_cb, - flow_dv_encap_decap_clone_cb, - flow_dv_encap_decap_clone_free_cb); - if (!sh->encaps_decaps) { - DRV_LOG(ERR, "encap decap hash creation failed"); - err = ENOMEM; - goto error; - } #endif #ifdef HAVE_MLX5DV_DR void *domain; @@ -396,7 +354,7 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) goto error; } #endif - if (!sh->tunnel_hub) + if (!sh->tunnel_hub && priv->config.dv_miss_info) err = mlx5_alloc_tunnel_hub(sh); if (err) { DRV_LOG(ERR, "mlx5_alloc_tunnel_hub failed err=%d", err); diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index ca67ce8213..fe86bb40d3 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -188,6 +188,12 @@ /* Size of the simple hash table for encap decap table. */ #define MLX5_FLOW_ENCAP_DECAP_HTABLE_SZ (1 << 12) +/* Size of the hash table for tag table. */ +#define MLX5_TAGS_HLIST_ARRAY_SIZE (1 << 15) + +/* Size fo the hash table for SFT table. */ +#define MLX5_FLOW_SFT_HLIST_ARRAY_SIZE 4096 + /* Hairpin TX/RX queue configuration parameters. */ #define MLX5_HAIRPIN_QUEUE_STRIDE 6 #define MLX5_HAIRPIN_JUMBO_LOG_SIZE (14 + 2) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f84a2b1a5d..bb70e8557f 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -310,6 +310,41 @@ mlx5_flow_tunnel_ip_check(const struct rte_flow_item *item __rte_unused, } } +static inline struct mlx5_hlist * +flow_dv_hlist_prepare(struct mlx5_dev_ctx_shared *sh, struct mlx5_hlist **phl, + const char *name, uint32_t size, bool direct_key, + bool lcores_share, void *ctx, + mlx5_list_create_cb cb_create, + mlx5_list_match_cb cb_match, + mlx5_list_remove_cb cb_remove, + mlx5_list_clone_cb cb_clone, + mlx5_list_clone_free_cb cb_clone_free) +{ + struct mlx5_hlist *hl; + struct mlx5_hlist *expected = NULL; + char s[MLX5_NAME_SIZE]; + + hl = __atomic_load_n(phl, __ATOMIC_SEQ_CST); + if (likely(hl)) + return hl; + snprintf(s, sizeof(s), "%s_%s", sh->ibdev_name, name); + hl = mlx5_hlist_create(s, size, direct_key, lcores_share, + ctx, cb_create, cb_match, cb_remove, cb_clone, + cb_clone_free); + if (!hl) { + DRV_LOG(ERR, "%s hash creation failed", name); + rte_errno = ENOMEM; + return NULL; + } + if (!__atomic_compare_exchange_n(phl, &expected, hl, false, + __ATOMIC_SEQ_CST, + __ATOMIC_SEQ_CST)) { + mlx5_hlist_destroy(hl); + hl = __atomic_load_n(phl, __ATOMIC_SEQ_CST); + } + return hl; +} + /* Update VLAN's VID/PCP based on input rte_flow_action. * * @param[in] action @@ -3724,8 +3759,20 @@ flow_dv_encap_decap_resource_register .error = error, .data = resource, }; + struct mlx5_hlist *encaps_decaps; uint64_t key64; + encaps_decaps = flow_dv_hlist_prepare(sh, &sh->encaps_decaps, + "encaps_decaps", + MLX5_FLOW_ENCAP_DECAP_HTABLE_SZ, + true, true, sh, + flow_dv_encap_decap_create_cb, + flow_dv_encap_decap_match_cb, + flow_dv_encap_decap_remove_cb, + flow_dv_encap_decap_clone_cb, + flow_dv_encap_decap_clone_free_cb); + if (unlikely(!encaps_decaps)) + return -rte_errno; resource->flags = dev_flow->dv.group ? 0 : 1; key64 = __rte_raw_cksum(&encap_decap_key.v32, sizeof(encap_decap_key.v32), 0); @@ -3733,7 +3780,7 @@ flow_dv_encap_decap_resource_register MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2 && resource->size) key64 = __rte_raw_cksum(resource->buf, resource->size, key64); - entry = mlx5_hlist_register(sh->encaps_decaps, key64, &ctx); + entry = mlx5_hlist_register(encaps_decaps, key64, &ctx); if (!entry) return -rte_errno; resource = container_of(entry, typeof(*resource), entry); @@ -5705,8 +5752,20 @@ flow_dv_modify_hdr_resource_register .error = error, .data = resource, }; + struct mlx5_hlist *modify_cmds; uint64_t key64; + modify_cmds = flow_dv_hlist_prepare(sh, &sh->modify_cmds, + "hdr_modify", + MLX5_FLOW_HDR_MODIFY_HTABLE_SZ, + true, false, sh, + flow_dv_modify_create_cb, + flow_dv_modify_match_cb, + flow_dv_modify_remove_cb, + flow_dv_modify_clone_cb, + flow_dv_modify_clone_free_cb); + if (unlikely(!modify_cmds)) + return -rte_errno; resource->root = !dev_flow->dv.group; if (resource->actions_num > flow_dv_modify_hdr_action_max(dev, resource->root)) @@ -5714,7 +5773,7 @@ flow_dv_modify_hdr_resource_register RTE_FLOW_ERROR_TYPE_ACTION, NULL, "too many modify header items"); key64 = __rte_raw_cksum(&resource->ft_type, key_len, 0); - entry = mlx5_hlist_register(sh->modify_cmds, key64, &ctx); + entry = mlx5_hlist_register(modify_cmds, key64, &ctx); if (!entry) return -rte_errno; resource = container_of(entry, typeof(*resource), entry); @@ -10493,8 +10552,20 @@ flow_dv_tag_resource_register .error = error, .data = &tag_be24, }; - - entry = mlx5_hlist_register(priv->sh->tag_table, tag_be24, &ctx); + struct mlx5_hlist *tag_table; + + tag_table = flow_dv_hlist_prepare(priv->sh, &priv->sh->tag_table, + "tags", + MLX5_TAGS_HLIST_ARRAY_SIZE, + false, false, priv->sh, + flow_dv_tag_create_cb, + flow_dv_tag_match_cb, + flow_dv_tag_remove_cb, + flow_dv_tag_clone_cb, + flow_dv_tag_clone_free_cb); + if (unlikely(!tag_table)) + return -rte_errno; + entry = mlx5_hlist_register(tag_table, tag_be24, &ctx); if (entry) { resource = container_of(entry, struct mlx5_flow_dv_tag_resource, entry); diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index af2f684648..0e6f7003b0 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -30,8 +30,6 @@ #include "mlx5_flow.h" #include "mlx5_devx.h" -#define MLX5_TAGS_HLIST_ARRAY_SIZE 8192 - static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data"; /* Spinlock for mlx5_shared_data allocation. */