From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F956A00C2; Fri, 14 Oct 2022 13:51:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D224A42E0A; Fri, 14 Oct 2022 13:50:03 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2062.outbound.protection.outlook.com [40.107.212.62]) by mails.dpdk.org (Postfix) with ESMTP id AF6AF42E3B for ; Fri, 14 Oct 2022 13:50:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=azEPLRbEOyJT43iAqY+wVBCMEkWLdKwFwDYqG7xKQTp5MjpD9DHgneXbrtyONKO+5wvoUJO6EZHQZG9aTkoB/k1mUxZs1gYL6jqYixy6QAeItF0kTGJMvGu0qiav+i8GxFUqcRkrCBPjbrX4lxSlYq/TcCgwli/TCNvsUnUhTv81Tnj+uy447C1eRu7vEz0H+Nq0boEBZtdtCs9003SfW+qVS2GjRagLHlejeDA46mrNvvPhQhE0Fo06H7ntkbbhaxVOeAUFW0b/O3RpNEzfAZUVkPtOM4PYBrT/VkWI8ERsXzCHwuFBpUkhUW96vOg/jAKmpIOSR/RkMytNMtE09Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YBalSvz+k8Rxb97TogcGHAO12dF/GXvtygb+BZqeUCI=; b=B9X6bL4bJYnL0+eNGAYgVhL2S7XQJw3yn/aACHVWE8cfnVq+2KV9ITRyCoTKmkX6GUsb+arb6RVXhJEr7lPncTzkOPOcx0vwnUGaxkBIUz9WGrrCSIEDfZD4Mf6Hy7rXSB2rdMk1lgecCbHUhZ9KVUUVxJ65dxQS85ILNpcK/RyPRhv+TFY+QxjcuUqOmj5NduXTUm9Tmsr04XSIW+l49Foo1eWDb0Ej82G7Vbnyc6WZ4kXaYEj/Ssh2FE5/S6aCdM4l0glpa0PlW0ZQp2RgS2bGCPQ4aAI2G/fyu9Srhd9xXzoxXEi4/nyawhZewN8NsRr/W/aGUosvlBW8QEPMAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=YBalSvz+k8Rxb97TogcGHAO12dF/GXvtygb+BZqeUCI=; b=dm9YP2rQJ3KnWWb/vBMRP50efE1TIkASOJZgzD+PO/LCpUiFXprY6E0ZgBbPqBKlrpSnCz/yPm3n0GQqWQkQLX7dRn1xXchsDy+Z+cAzXmNKfDf/0CQotUcuiB57RAaSZ2mSDo1BtWK1FwURB6+wxo2G301gd4DD+hZ06lxJwvYTXPY0ehkK4GTxIVA8cKuakdQY3mX8NHRk8B1tbq0wuwGfLzGDFyzVRtkAyjVihqKNcbhyJEAohjVJoXP6ZTy8/2giDyJ1l+VjAA6pNQUJ8EvvOoZswwAk5BGxWntRQDiBM4MVjJaJn5lReLNRk59JE7YR+Plo4ft4nuL59oEe8g== Received: from MW4PR03CA0105.namprd03.prod.outlook.com (2603:10b6:303:b7::20) by SA1PR12MB6896.namprd12.prod.outlook.com (2603:10b6:806:24f::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Fri, 14 Oct 2022 11:50:00 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b7:cafe::df) by MW4PR03CA0105.outlook.office365.com (2603:10b6:303:b7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.28 via Frontend Transport; Fri, 14 Oct 2022 11:49:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Fri, 14 Oct 2022 11:49:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 14 Oct 2022 04:49:46 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Fri, 14 Oct 2022 04:49:43 -0700 From: Alex Vesker To: , , , , Matan Azrad CC: , , Hamdan Igbaria Subject: [v3 17/18] net/mlx5/hws: Add HWS debug layer Date: Fri, 14 Oct 2022 14:48:32 +0300 Message-ID: <20221014114833.13389-18-valex@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221014114833.13389-1-valex@nvidia.com> References: <20220922190345.394-1-valex@nvidia.com> <20221014114833.13389-1-valex@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT048:EE_|SA1PR12MB6896:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d12df06-ca4f-4bce-d2f3-08daadda38e7 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mrRIS6iajfZBpiWDPcBhbWbahAsOQW0WYLA2mQCwf13Tt31KerP44Je7wIT/7qW+t0wyXv4dek32SF1XPgJnyToXb969PkTss0ch2aqzMT6t5Grwvm/56ewdjqjd8sOz3doL2oh0fyL/fTrGQcSarTClj4VwZvflXE+TsLw29m1voXxt5jWveT+v+6+TwCTaX/JfRRGUHz/8VEfMdwFH655+Ar+nvv8/2Efytdm4fZLY0CN5RBwnsLoHeSzKesJMJawd+iGOaXo23iCkiTud7BGoeqCw/eybFjuwnzwIiftCgN1L53dAM60oq62inz+Bw64sdzl7kYXlOfRXYqgHQtkZnS58y78r3TtrmaTE1Ns9zMM9JUU7guFwRwxUF/k9qXbDmQCdzbA2GGRt944/hOu4lJGMvOwKk7A9hcSnixHJiAf14jbSKRUlaOE5GdiIgsv9BcPStc0HZQpQ1KqFlnXGPsQN1wI3ritV8ijQ9kSg57E9vQ+LMnRWeZx1SZVYwREfaliimBBuaxeimiE3Kpr42vY9yK+ER2msQGCvRLc3EDS/nrRwESfMPOhm7h4ra7KsfcYJ/mbRs9pEjDzqNRBfIwgb2Yj5qN+KR/XsGbDnjcxUXCmXjCpLfj+0pMN7XYParF5ZJL9Mdysm7+PRL+OnacKKRZHpZFAdjnPGhAwE7iaXfh3w8JNXU3z2RGfvXAL6bJ9IHyvIf1smGBMJ3RntnMWM3/hPI9KCN/YLP54ycqxVCZUQIsLG7PJKP8K9yaOLq7YaxzbdYOFhiN+qMQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199015)(36840700001)(46966006)(40470700004)(107886003)(478600001)(6286002)(6666004)(7696005)(82740400003)(356005)(40480700001)(82310400005)(7636003)(55016003)(26005)(40460700003)(336012)(16526019)(86362001)(47076005)(426003)(2616005)(186003)(1076003)(83380400001)(5660300002)(36860700001)(30864003)(36756003)(110136005)(2906002)(70206006)(70586007)(8676002)(8936002)(41300700001)(6636002)(54906003)(316002)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 11:49:59.4445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d12df06-ca4f-4bce-d2f3-08daadda38e7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6896 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 From: Hamdan Igbaria The debug layer is used to generate a debug CSV file containing details of the context, table, matcher, rules and other useful debug information. Signed-off-by: Hamdan Igbaria Signed-off-by: Alex Vesker --- drivers/net/mlx5/hws/mlx5dr_debug.c | 462 ++++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_debug.h | 28 ++ 2 files changed, 490 insertions(+) create mode 100644 drivers/net/mlx5/hws/mlx5dr_debug.c create mode 100644 drivers/net/mlx5/hws/mlx5dr_debug.h diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c new file mode 100644 index 0000000000..890a761c48 --- /dev/null +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -0,0 +1,462 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 NVIDIA Corporation & Affiliates + */ + +#include "mlx5dr_internal.h" + +const char *mlx5dr_debug_action_type_str[] = { + [MLX5DR_ACTION_TYP_LAST] = "LAST", + [MLX5DR_ACTION_TYP_TNL_L2_TO_L2] = "TNL_L2_TO_L2", + [MLX5DR_ACTION_TYP_L2_TO_TNL_L2] = "L2_TO_TNL_L2", + [MLX5DR_ACTION_TYP_TNL_L3_TO_L2] = "TNL_L3_TO_L2", + [MLX5DR_ACTION_TYP_L2_TO_TNL_L3] = "L2_TO_TNL_L3", + [MLX5DR_ACTION_TYP_DROP] = "DROP", + [MLX5DR_ACTION_TYP_TIR] = "TIR", + [MLX5DR_ACTION_TYP_FT] = "FT", + [MLX5DR_ACTION_TYP_CTR] = "CTR", + [MLX5DR_ACTION_TYP_TAG] = "TAG", + [MLX5DR_ACTION_TYP_MODIFY_HDR] = "MODIFY_HDR", + [MLX5DR_ACTION_TYP_VPORT] = "VPORT", + [MLX5DR_ACTION_TYP_MISS] = "DEFAULT_MISS", + [MLX5DR_ACTION_TYP_POP_VLAN] = "POP_VLAN", + [MLX5DR_ACTION_TYP_PUSH_VLAN] = "PUSH_VLAN", + [MLX5DR_ACTION_TYP_ASO_METER] = "ASO_METER", + [MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT", +}; + +static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX, + "Missing mlx5dr_debug_action_type_str"); + +const char *mlx5dr_debug_action_type_to_str(enum mlx5dr_action_type action_type) +{ + return mlx5dr_debug_action_type_str[action_type]; +} + +static int +mlx5dr_debug_dump_matcher_template_definer(FILE *f, + struct mlx5dr_match_template *mt) +{ + struct mlx5dr_definer *definer = mt->definer; + int i, ret; + + ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,", + MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_DEFINER, + (uint64_t)(uintptr_t)definer, + (uint64_t)(uintptr_t)mt, + definer->obj->id, + definer->type); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + for (i = 0; i < DW_SELECTORS; i++) { + ret = fprintf(f, "0x%x%s", definer->dw_selector[i], + (i == DW_SELECTORS - 1) ? "," : "-"); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + } + + for (i = 0; i < BYTE_SELECTORS; i++) { + ret = fprintf(f, "0x%x%s", definer->byte_selector[i], + (i == BYTE_SELECTORS - 1) ? "," : "-"); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + } + + for (i = 0; i < MLX5DR_JUMBO_TAG_SZ; i++) { + ret = fprintf(f, "%02x", definer->mask.jumbo[i]); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + } + + ret = fprintf(f, "\n"); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + return 0; +} + +static int +mlx5dr_debug_dump_matcher_match_template(FILE *f, struct mlx5dr_matcher *matcher) +{ + bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL; + int i, ret; + + for (i = 0; i < matcher->num_of_mt; i++) { + struct mlx5dr_match_template *mt = matcher->mt[i]; + + ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d\n", + MLX5DR_DEBUG_RES_TYPE_MATCHER_MATCH_TEMPLATE, + (uint64_t)(uintptr_t)mt, + (uint64_t)(uintptr_t)matcher, + is_root ? 0 : mt->fc_sz, + mt->flags); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + if (!is_root) { + ret = mlx5dr_debug_dump_matcher_template_definer(f, mt); + if (ret) + return ret; + } + } + + return 0; +} + +static int +mlx5dr_debug_dump_matcher_action_template(FILE *f, struct mlx5dr_matcher *matcher) +{ + bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL; + enum mlx5dr_action_type action_type; + int i, j, ret; + + for (i = 0; i < matcher->num_of_at; i++) { + struct mlx5dr_action_template *at = matcher->at[i]; + + ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d", + MLX5DR_DEBUG_RES_TYPE_MATCHER_ACTION_TEMPLATE, + (uint64_t)(uintptr_t)at, + (uint64_t)(uintptr_t)matcher, + at->only_term ? 0 : 1, + is_root ? 0 : at->num_of_action_stes, + at->num_actions); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + for (j = 0; j < at->num_actions; j++) { + action_type = at->action_type_arr[j]; + ret = fprintf(f, ",%s", mlx5dr_debug_action_type_to_str(action_type)); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + } + + fprintf(f, "\n"); + } + + return 0; +} + +static int +mlx5dr_debug_dump_matcher_attr(FILE *f, struct mlx5dr_matcher *matcher) +{ + struct mlx5dr_matcher_attr *attr = &matcher->attr; + int ret; + + ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d\n", + MLX5DR_DEBUG_RES_TYPE_MATCHER_ATTR, + (uint64_t)(uintptr_t)matcher, + attr->priority, + attr->mode, + attr->table.sz_row_log, + attr->table.sz_col_log, + attr->optimize_using_rule_idx, + attr->optimize_flow_src); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + return 0; +} + +static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher) +{ + bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL; + enum mlx5dr_table_type tbl_type = matcher->tbl->type; + struct mlx5dr_devx_obj *ste_0, *ste_1 = NULL; + struct mlx5dr_pool_chunk *ste; + struct mlx5dr_pool *ste_pool; + int ret; + + ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,0x%" PRIx64, + MLX5DR_DEBUG_RES_TYPE_MATCHER, + (uint64_t)(uintptr_t)matcher, + (uint64_t)(uintptr_t)matcher->tbl, + matcher->num_of_mt, + is_root ? 0 : matcher->end_ft->id, + matcher->col_matcher ? (uint64_t)(uintptr_t)matcher->col_matcher : 0); + if (ret < 0) + goto out_err; + + ste = &matcher->match_ste.ste; + ste_pool = matcher->match_ste.pool; + if (ste_pool) { + ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste); + if (tbl_type == MLX5DR_TABLE_TYPE_FDB) + ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste); + } else { + ste_0 = NULL; + ste_1 = NULL; + } + + ret = fprintf(f, ",%d,%d,%d,%d", + matcher->match_ste.rtc_0 ? matcher->match_ste.rtc_0->id : 0, + ste_0 ? (int)ste_0->id : -1, + matcher->match_ste.rtc_1 ? matcher->match_ste.rtc_1->id : 0, + ste_1 ? (int)ste_1->id : -1); + if (ret < 0) + goto out_err; + + ste = &matcher->action_ste.ste; + ste_pool = matcher->action_ste.pool; + if (ste_pool) { + ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste); + if (tbl_type == MLX5DR_TABLE_TYPE_FDB) + ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste); + } else { + ste_0 = NULL; + ste_1 = NULL; + } + + ret = fprintf(f, ",%d,%d,%d,%d\n", + matcher->action_ste.rtc_0 ? matcher->action_ste.rtc_0->id : 0, + ste_0 ? (int)ste_0->id : -1, + matcher->action_ste.rtc_1 ? matcher->action_ste.rtc_1->id : 0, + ste_1 ? (int)ste_1->id : -1); + if (ret < 0) + goto out_err; + + ret = mlx5dr_debug_dump_matcher_attr(f, matcher); + if (ret) + return ret; + + ret = mlx5dr_debug_dump_matcher_match_template(f, matcher); + if (ret) + return ret; + + ret = mlx5dr_debug_dump_matcher_action_template(f, matcher); + if (ret) + return ret; + + return 0; + +out_err: + rte_errno = EINVAL; + return rte_errno; +} + +static int mlx5dr_debug_dump_table(FILE *f, struct mlx5dr_table *tbl) +{ + bool is_root = tbl->level == MLX5DR_ROOT_LEVEL; + struct mlx5dr_matcher *matcher; + int ret; + + ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d,%d\n", + MLX5DR_DEBUG_RES_TYPE_TABLE, + (uint64_t)(uintptr_t)tbl, + (uint64_t)(uintptr_t)tbl->ctx, + is_root ? 0 : tbl->ft->id, + tbl->type, + is_root ? 0 : tbl->fw_ft_type, + tbl->level); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + LIST_FOREACH(matcher, &tbl->head, next) { + ret = mlx5dr_debug_dump_matcher(f, matcher); + if (ret) + return ret; + } + + return 0; +} + +static int +mlx5dr_debug_dump_context_send_engine(FILE *f, struct mlx5dr_context *ctx) +{ + struct mlx5dr_send_engine *send_queue; + int ret, i, j; + + for (i = 0; i < (int)ctx->queues; i++) { + send_queue = &ctx->send_queue[i]; + ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d,%d\n", + MLX5DR_DEBUG_RES_TYPE_CONTEXT_SEND_ENGINE, + (uint64_t)(uintptr_t)ctx, + i, + send_queue->used_entries, + send_queue->th_entries, + send_queue->rings, + send_queue->num_entries, + send_queue->err, + send_queue->completed.ci, + send_queue->completed.pi, + send_queue->completed.mask); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + for (j = 0; j < MLX5DR_NUM_SEND_RINGS; j++) { + struct mlx5dr_send_ring *send_ring = &send_queue->send_ring[j]; + struct mlx5dr_send_ring_cq *cq = &send_ring->send_cq; + struct mlx5dr_send_ring_sq *sq = &send_ring->send_sq; + + ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n", + MLX5DR_DEBUG_RES_TYPE_CONTEXT_SEND_RING, + (uint64_t)(uintptr_t)ctx, + j, + i, + cq->cqn, + cq->cons_index, + cq->ncqe_mask, + cq->buf_sz, + cq->ncqe, + cq->cqe_log_sz, + cq->poll_wqe, + cq->cqe_sz, + sq->sqn, + sq->obj->id, + sq->cur_post, + sq->buf_mask); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + } + } + + return 0; +} + +static int mlx5dr_debug_dump_context_caps(FILE *f, struct mlx5dr_context *ctx) +{ + struct mlx5dr_cmd_query_caps *caps = ctx->caps; + int ret; + + ret = fprintf(f, "%d,0x%" PRIx64 ",%s,%d,%d,%d,%d,", + MLX5DR_DEBUG_RES_TYPE_CONTEXT_CAPS, + (uint64_t)(uintptr_t)ctx, + caps->fw_ver, + caps->wqe_based_update, + caps->ste_format, + caps->ste_alloc_log_max, + caps->log_header_modify_argument_max_alloc); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + ret = fprintf(f, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n", + caps->flex_protocols, + caps->rtc_reparse_mode, + caps->rtc_index_mode, + caps->ste_alloc_log_gran, + caps->stc_alloc_log_max, + caps->stc_alloc_log_gran, + caps->rtc_log_depth_max, + caps->format_select_gtpu_dw_0, + caps->format_select_gtpu_dw_1, + caps->format_select_gtpu_dw_2, + caps->format_select_gtpu_ext_dw_0, + caps->nic_ft.max_level, + caps->nic_ft.reparse, + caps->fdb_ft.max_level, + caps->fdb_ft.reparse, + caps->log_header_modify_argument_granularity); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + return 0; +} + +static int mlx5dr_debug_dump_context_attr(FILE *f, struct mlx5dr_context *ctx) +{ + int ret; + + ret = fprintf(f, "%u,0x%" PRIx64 ",%d,%zu,%d\n", + MLX5DR_DEBUG_RES_TYPE_CONTEXT_ATTR, + (uint64_t)(uintptr_t)ctx, + ctx->pd_num, + ctx->queues, + ctx->send_queue->num_entries); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + return 0; +} + +static int mlx5dr_debug_dump_context_info(FILE *f, struct mlx5dr_context *ctx) +{ + int ret; + + ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%s,%s\n", + MLX5DR_DEBUG_RES_TYPE_CONTEXT, + (uint64_t)(uintptr_t)ctx, + ctx->flags & MLX5DR_CONTEXT_FLAG_HWS_SUPPORT, + mlx5_glue->get_device_name(ctx->ibv_ctx->device), + DEBUG_VERSION); + if (ret < 0) { + rte_errno = EINVAL; + return rte_errno; + } + + ret = mlx5dr_debug_dump_context_attr(f, ctx); + if (ret) + return ret; + + ret = mlx5dr_debug_dump_context_caps(f, ctx); + if (ret) + return ret; + + return 0; +} + +static int mlx5dr_debug_dump_context(FILE *f, struct mlx5dr_context *ctx) +{ + struct mlx5dr_table *tbl; + int ret; + + ret = mlx5dr_debug_dump_context_info(f, ctx); + if (ret) + return ret; + + ret = mlx5dr_debug_dump_context_send_engine(f, ctx); + if (ret) + return ret; + + LIST_FOREACH(tbl, &ctx->head, next) { + ret = mlx5dr_debug_dump_table(f, tbl); + if (ret) + return ret; + } + + return 0; +} + +int mlx5dr_debug_dump(struct mlx5dr_context *ctx, FILE *f) +{ + int ret; + + if (!f || !ctx) { + rte_errno = EINVAL; + return -rte_errno; + } + + pthread_spin_lock(&ctx->ctrl_lock); + ret = mlx5dr_debug_dump_context(f, ctx); + pthread_spin_unlock(&ctx->ctrl_lock); + + return -ret; +} diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.h b/drivers/net/mlx5/hws/mlx5dr_debug.h new file mode 100644 index 0000000000..cf00170f7d --- /dev/null +++ b/drivers/net/mlx5/hws/mlx5dr_debug.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 NVIDIA Corporation & Affiliates + */ + +#ifndef MLX5DR_DEBUG_H_ +#define MLX5DR_DEBUG_H_ + +#define DEBUG_VERSION "1.0.DPDK" + +enum mlx5dr_debug_res_type { + MLX5DR_DEBUG_RES_TYPE_CONTEXT = 4000, + MLX5DR_DEBUG_RES_TYPE_CONTEXT_ATTR = 4001, + MLX5DR_DEBUG_RES_TYPE_CONTEXT_CAPS = 4002, + MLX5DR_DEBUG_RES_TYPE_CONTEXT_SEND_ENGINE = 4003, + MLX5DR_DEBUG_RES_TYPE_CONTEXT_SEND_RING = 4004, + + MLX5DR_DEBUG_RES_TYPE_TABLE = 4100, + + MLX5DR_DEBUG_RES_TYPE_MATCHER = 4200, + MLX5DR_DEBUG_RES_TYPE_MATCHER_ATTR = 4201, + MLX5DR_DEBUG_RES_TYPE_MATCHER_MATCH_TEMPLATE = 4202, + MLX5DR_DEBUG_RES_TYPE_MATCHER_ACTION_TEMPLATE = 4204, + MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_DEFINER = 4203, +}; + +const char *mlx5dr_debug_action_type_to_str(enum mlx5dr_action_type action_type); + +#endif /* MLX5DR_DEBUG_H_ */ -- 2.18.1