From patchwork Mon Feb 19 10:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 202989 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1185562dyc; Mon, 19 Feb 2024 02:05:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJwTUG8i708e7Mf16HobrPnRsUFe0ndtLHcRmuUzwpYeP4Bb9mf+QIB0iGBeRv5ALO4F5VnGmlU88GTNuW+y224WmfbQ== X-Google-Smtp-Source: AGHT+IEeJGtnvZKR0DU3QZTp4UeXumn3BaUqA9kdCqwUudLS9d4ENRHSX4fD2x6FKNUJdwGQ307M X-Received: by 2002:a05:6e02:370a:b0:365:1578:8c17 with SMTP id ck10-20020a056e02370a00b0036515788c17mr9196820ilb.2.1708337135044; Mon, 19 Feb 2024 02:05:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708337135; cv=pass; d=google.com; s=arc-20160816; b=UCBstsKNqlREB8ieWAvAVEiLj/o9bpKYILSa22mDp/ukQeBAT+Wa3CDfdaeeiz76iZ DXkTo/KkU7jTl8imGVVCU0DJmA+9tjfc6ehh3oFjCCbqa3EXoOnbDrgl5ujkuDImimo7 SLQizh20wk0+NLNpj1J0LKoEGept1anmYVPtN76NFR/WTbhQeWmZp2R8qEnvlJbzmYcc wCisoyR2qB+eODYx5ZAfFxfvp24zzD0s6KiaprE2XyuWIc2IiVnyyE5yxGnNgxH4g93W NgxWGa1rax7aA7q1p/aiTCgXi7DeS4m67HrTbNKKMVEHNl3Ngyv8b2gcDrjQPDjb5IDD SkRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=WqDjuzPL2d5O0HxZkWPyXo16DOcVYM/IP/VvKhulxis=; fh=kMu+pPU1O3WsjAd9X/angPFhuGTg3g6gTgugPYzjI/c=; b=QCwtXxvra5zxby6cD1fecSlbxvMBjzA+sUtefAHQj2Xl6e8lwS+S0TOvbek1WGq01B YM/FyUFW7Ktp87gC2kpRtoHTshJnMJDP4IhxMWbKbC1bZFiJkrLFyMAj6FZkFB9I01dg VBTgbpt4GUg7/umwSED/uCap7qyi+rhHZAIVELu6Oq8naQr5PfVVOKYRp5ucs8q8022P cNfKY1kJfdEPrfeQtX7Gny+fGQXzyKQxOwtQH/gNXUxbxCLRPueO0FlaOEA5uHYiDhML YxnauAjj3Xv8VDPCj3HXZV3T4rrQsszWjDvCpWEy+CRLbhJUHtkHAWgKk/l84RsUHkz2 vEbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K8nSM8rP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71087-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71087-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m28-20020a63711c000000b005e2b0672449si1457818pgc.27.2024.02.19.02.05.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 02:05:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71087-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K8nSM8rP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71087-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71087-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CC6BD282360 for ; Mon, 19 Feb 2024 10:05:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00E7425635; Mon, 19 Feb 2024 10:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K8nSM8rP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9969E210FA; Mon, 19 Feb 2024 10:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708337115; cv=none; b=RVJyAr7PoeFxzZ5h06Xn9moA7nEbHL12HDwdJS3ddLnKqmoRPQDwlN7A+G4NcxCRubKOkGjrRZlg+8Mhr1KF0CrmXvpHSAqEI8Q+XsLR4zWUrqNrMna0UWSl5livgz9KmzCP/Ke2fN8zJd66LSCjAIwRxiWeYPEWuFPM5zqH/oY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708337115; c=relaxed/simple; bh=+vaXQiOlwrlEfVMuL5MnJ8PuL8Zf1ywZS/hJQleg+yk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=LzosekUzcDtm2p3pvf4BGPbkqFRTrkS45iwIix+Oh+yyTAX3Ec/6e1PaaIYVD4QkP51DCP8ZDi3e5wKJ8ACDbcRvL8IrkTU4ZQv++cSYEzwWeaz2acOUSOk4BEMbBUvFrF4/diWJGG9UVV/EP6phmEvETI9jCtP9nZQZqgQ0SAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K8nSM8rP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 054DFC433F1; Mon, 19 Feb 2024 10:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708337115; bh=+vaXQiOlwrlEfVMuL5MnJ8PuL8Zf1ywZS/hJQleg+yk=; h=From:To:Cc:Subject:Date:From; b=K8nSM8rPqaSWjvA9wfBx7VyhGhrgsJjmtKGMBn6eaw3b3gNOhSlXfQ75f73PRfsnH TYr47cZWoNghx0ytHhkuok08LOnJuFqfzsvCs95XwMlBTdEiB2aYPRHv/p+tuV0HpI vKLMp6DwsmMyNDGNb99mzutP+Yiu0XdcJLwwWuCaybGvqOD3a6nPjSlbFcaI6FekuU qhv9VEcezYlFyAT39n7yl4ti9THSaJRdqUpMSkyontHdzmz7T3Jg5EPKAaWy2QnM9V 3CUj9l5NS1XKeIAVbVSeaSu/xBi22luQY0OLnaZj/JTkiw9a44D3ZqK+2IiXOxWaUd FNtoJIN+lgFVA== From: Arnd Bergmann To: Saeed Mahameed , Leon Romanovsky Cc: Zhu Yanjun , Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yevgeny Kliteynik , Alex Vesker , Erez Shitrit , Hamdan Igbaria , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] net/mlx5: pre-initialize sprintf buffers Date: Mon, 19 Feb 2024 11:04:55 +0100 Message-Id: <20240219100506.648089-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791321319484610927 X-GMAIL-MSGID: 1791321319484610927 From: Arnd Bergmann The debugfs files always in this driver all use an extra round-trip through an snprintf() before getting put into a mlx5dr_dbg_dump_buff() rather than the normal seq_printf(). Zhu Yanjun noticed that the buffers are not initialized before being filled or reused and requested them to always be zeroed as a preparation for having more reused between the buffers. Requested-by: Zhu Yanjun Signed-off-by: Arnd Bergmann --- .../mellanox/mlx5/core/steering/dr_dbg.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c index 64f4cc284aea..be7a8481d7d2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c @@ -217,6 +217,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, switch (action->action_type) { case DR_ACTION_TYP_DROP: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx\n", DR_DUMP_REC_TYPE_ACTION_DROP, action_id, @@ -229,6 +230,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_FT: + memset(buff, 0, sizeof(buff)); if (action->dest_tbl->is_fw_tbl) ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,0x%x\n", @@ -250,6 +252,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_CTR: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_CTR, action_id, rule_id, @@ -262,6 +265,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_TAG: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_TAG, action_id, rule_id, @@ -283,6 +287,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, ptrn_arg = !action->rewrite->single_action_opt && ptrn && arg; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,%d,0x%x,0x%x,0x%x", DR_DUMP_REC_TYPE_ACTION_MODIFY_HDR, action_id, @@ -300,6 +305,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, if (ptrn_arg) { for (i = 0; i < action->rewrite->num_of_actions; i++) { + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, ",0x%016llx", be64_to_cpu(((__be64 *)rewrite_data)[i])); @@ -321,6 +327,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, break; } case DR_ACTION_TYP_VPORT: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_VPORT, action_id, rule_id, @@ -333,6 +340,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_TNL_L2_TO_L2: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx\n", DR_DUMP_REC_TYPE_ACTION_DECAP_L2, action_id, @@ -345,6 +353,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_TNL_L3_TO_L2: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_DECAP_L3, action_id, @@ -360,6 +369,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_L2_TO_TNL_L2: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_ENCAP_L2, action_id, @@ -372,6 +382,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_L2_TO_TNL_L3: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_ENCAP_L3, action_id, @@ -384,6 +395,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_POP_VLAN: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx\n", DR_DUMP_REC_TYPE_ACTION_POP_VLAN, action_id, @@ -396,6 +408,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_PUSH_VLAN: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_PUSH_VLAN, action_id, @@ -408,6 +421,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_INSERT_HDR: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,0x%x,0x%x\n", DR_DUMP_REC_TYPE_ACTION_INSERT_HDR, action_id, @@ -422,6 +436,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_REMOVE_HDR: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,0x%x,0x%x\n", DR_DUMP_REC_TYPE_ACTION_REMOVE_HDR, action_id, @@ -436,6 +451,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, return ret; break; case DR_ACTION_TYP_SAMPLER: + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,0x%x,0x%x,0x%llx,0x%llx\n", DR_DUMP_REC_TYPE_ACTION_SAMPLER, action_id, @@ -468,6 +484,7 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, DR_DBG_PTR_TO_ID(action->range->miss_tbl_action->dest_tbl->tbl); } + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,0x%llx,0x%x,0x%llx,0x%x\n", DR_DUMP_REC_TYPE_ACTION_MATCH_RANGE, action_id, @@ -507,6 +524,7 @@ dr_dump_rule_mem(struct seq_file *file, struct mlx5dr_ste *ste, dr_dump_hex_print(hw_ste_dump, (char *)mlx5dr_ste_get_hw_ste(ste), DR_STE_SIZE_REDUCED); + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,%s\n", mem_rec_type, dr_dump_icm_to_idx(mlx5dr_ste_get_icm_addr(ste)), @@ -554,6 +572,7 @@ static int dr_dump_rule(struct seq_file *file, struct mlx5dr_rule *rule) format_ver = rule->matcher->tbl->dmn->info.caps.sw_format_ver; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx\n", DR_DUMP_REC_TYPE_RULE, rule_id, DR_DBG_PTR_TO_ID(rule->matcher)); @@ -593,6 +612,7 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, char dump[DR_HEX_SIZE]; int ret; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,", DR_DUMP_REC_TYPE_MATCHER_MASK, matcher_id); if (ret < 0) @@ -602,6 +622,7 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, if (ret) return ret; + memset(buff, 0, sizeof(buff)); if (criteria & DR_MATCHER_CRITERIA_OUTER) { dr_dump_hex_print(dump, (char *)&mask->outer, sizeof(mask->outer)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, @@ -617,6 +638,7 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, if (ret) return ret; + memset(buff, 0, sizeof(buff)); if (criteria & DR_MATCHER_CRITERIA_INNER) { dr_dump_hex_print(dump, (char *)&mask->inner, sizeof(mask->inner)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, @@ -632,6 +654,7 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, if (ret) return ret; + memset(buff, 0, sizeof(buff)); if (criteria & DR_MATCHER_CRITERIA_MISC) { dr_dump_hex_print(dump, (char *)&mask->misc, sizeof(mask->misc)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, @@ -647,6 +670,7 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, if (ret) return ret; + memset(buff, 0, sizeof(buff)); if (criteria & DR_MATCHER_CRITERIA_MISC2) { dr_dump_hex_print(dump, (char *)&mask->misc2, sizeof(mask->misc2)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, @@ -662,6 +686,7 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, if (ret) return ret; + memset(buff, 0, sizeof(buff)); if (criteria & DR_MATCHER_CRITERIA_MISC3) { dr_dump_hex_print(dump, (char *)&mask->misc3, sizeof(mask->misc3)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, @@ -687,6 +712,7 @@ dr_dump_matcher_builder(struct seq_file *file, struct mlx5dr_ste_build *builder, char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,%d,%d,0x%x\n", DR_DUMP_REC_TYPE_MATCHER_BUILDER, matcher_id, index, @@ -716,6 +742,7 @@ dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx, s_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(matcher_rx_tx->s_htbl->chunk); e_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(matcher_rx_tx->e_anchor->chunk); + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,%d,0x%llx,0x%llx\n", rec_type, DR_DBG_PTR_TO_ID(matcher_rx_tx), @@ -752,6 +779,7 @@ dr_dump_matcher(struct seq_file *file, struct mlx5dr_matcher *matcher) matcher_id = DR_DBG_PTR_TO_ID(matcher); + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,%d\n", DR_DUMP_REC_TYPE_MATCHER, matcher_id, DR_DBG_PTR_TO_ID(matcher->tbl), @@ -816,6 +844,7 @@ dr_dump_table_rx_tx(struct seq_file *file, bool is_rx, DR_DUMP_REC_TYPE_TABLE_TX; s_icm_addr = mlx5dr_icm_pool_get_chunk_icm_addr(table_rx_tx->s_anchor->chunk); + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx\n", rec_type, table_id, dr_dump_icm_to_idx(s_icm_addr)); @@ -836,6 +865,7 @@ static int dr_dump_table(struct seq_file *file, struct mlx5dr_table *table) char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,%d,%d\n", DR_DUMP_REC_TYPE_TABLE, DR_DBG_PTR_TO_ID(table), DR_DBG_PTR_TO_ID(table->dmn), @@ -887,6 +917,7 @@ dr_dump_send_ring(struct seq_file *file, struct mlx5dr_send_ring *ring, char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%llx,0x%x,0x%x\n", DR_DUMP_REC_TYPE_DOMAIN_SEND_RING, @@ -911,6 +942,7 @@ dr_dump_domain_info_flex_parser(struct seq_file *file, char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,%s,0x%x\n", DR_DUMP_REC_TYPE_DOMAIN_INFO_FLEX_PARSER, domain_id, @@ -937,6 +969,7 @@ dr_dump_domain_info_caps(struct seq_file *file, struct mlx5dr_cmd_caps *caps, xa_for_each(&caps->vports.vports_caps_xa, vports_num, vport_caps) ; /* count the number of vports in xarray */ + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,0x%x,0x%llx,0x%llx,0x%x,%lu,%d\n", DR_DUMP_REC_TYPE_DOMAIN_INFO_CAPS, domain_id, caps->gvmi, @@ -952,6 +985,7 @@ dr_dump_domain_info_caps(struct seq_file *file, struct mlx5dr_cmd_caps *caps, xa_for_each(&caps->vports.vports_caps_xa, i, vport_caps) { vport_caps = xa_load(&caps->vports.vports_caps_xa, i); + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,%lu,0x%x,0x%llx,0x%llx\n", DR_DUMP_REC_TYPE_DOMAIN_INFO_VPORT, @@ -1012,6 +1046,7 @@ dr_dump_domain(struct seq_file *file, struct mlx5dr_domain *dmn) u64 domain_id = DR_DBG_PTR_TO_ID(dmn); int ret; + memset(buff, 0, sizeof(buff)); ret = snprintf(buff, MLX5DR_DEBUG_DUMP_BUFF_LENGTH, "%d,0x%llx,%d,0%x,%d,%u.%u.%u,%s,%d,%u,%u,%u\n", DR_DUMP_REC_TYPE_DOMAIN, From patchwork Mon Feb 19 10:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 202990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1185716dyc; Mon, 19 Feb 2024 02:05:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWGuBkrOxBC0X/+KycpU6uKl0lYUlgABExpU2qCtTu/q2Zy/2+0CSKet60PQZsPFBNSGJBdQcIC76sZ0JgRZVZGZReGOQ== X-Google-Smtp-Source: AGHT+IGsrbtJTJiiDkuFKHlcz4xKVVK/85hJ3v4aF0hoK54P49XxMey4K0cjjzzkv3tE5sYGnH/x X-Received: by 2002:a05:6870:8088:b0:21e:8afd:65d0 with SMTP id q8-20020a056870808800b0021e8afd65d0mr5593408oab.52.1708337154852; Mon, 19 Feb 2024 02:05:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708337154; cv=pass; d=google.com; s=arc-20160816; b=IFYNra4AE1U9eq3MuSDwh3AOl8O9bUYaL+PSaAHPCJKAzIHEe3PZjv1yKXpq/6Za// SzMVJywGecZv4t/UxnPMZrRB4QP0t7NfFcnTi/qv1Kh/Ncb2q1kqjJA9hIdClU5d1ZjQ B6AUfqWDB7OW38+T9syd707vwEhfmVWRvACsOO6doIenYAcCXaVQcy9rP725Spl4x+Qb +Sn6/F0mFD4JVoNNfGfk7/VLcKYgN/00BFDHd2puHQmWVnSwLEy5X3YLI033kZFcLB2l dR5XOAFMyWN8AO7gMSnMdD1mZGUPntMiYwPtvVS0hGRmrZN1xslPkgGiXz7Rx8ty9DI9 EHnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0Uad2l0AVWuB9aqej/v0nhGc/FydJXXOx9Bhb0sK66I=; fh=gPrxob0iw/HRY75Ge40cF1Iv8Q+cYGsoEl5Usojwwc8=; b=ZfMhd4C3FiMmIFdawqz1H+O3NtuuIHw4L6B9oTtumB8PnJ+7GOECKyLMQlzdhEqlmV TBUwB4bNxR4DImnrwGdYPixVZ8fJW6nIo7RsHg4RpbsxvnDUjfJdponlX+4Y5yhskv4e cO2TuIFTIdvWWqXLMId4ajm3E1KwYnQrLNxzK9FobpzyZtpuYwBByFDeJFb3aHwiknmY jVY9TgDkY5F7LamXRKohJyA3x8SufQXe9SR+fj+gB7QtURBtJhWSOTvxrh/S59rSOJqF 36WaKV4HSIb3VS3LVWbb5K9hJ6z0Itvo6VgyTmRFk3jhd8BO2dc2QVj+Es4kLbfi2k67 verA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="hIqlK0/x"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71088-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71088-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id cl23-20020a056a02099700b005df459686f7si4001074pgb.446.2024.02.19.02.05.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 02:05:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71088-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="hIqlK0/x"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71088-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71088-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 84721282189 for ; Mon, 19 Feb 2024 10:05:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C15A288CF; Mon, 19 Feb 2024 10:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hIqlK0/x" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9F3C22F13; Mon, 19 Feb 2024 10:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708337130; cv=none; b=VoEE4enWR486j1JxDr5+t7vfDjkOqx9V5qm5tjiXgvunFWWNI8AFJwNNie4mYag3Pgp1xeRMCmRB1Tu3kAkKN00HZv2FwOq9pQdH0QHlDGhq6dIks1nKy3qn+cTKqiJGjfEc7Ah5Dl6da8DqmXBezEeucWj2YL8tkQSBSfZeavA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708337130; c=relaxed/simple; bh=Wp1z8DD4y2npUVyApGi7Hca+cEHUY33+maH5kr1tQf8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M5J0459LtIsBn5CrllFaKzjzjOuEYRcrwl4pxU+OeD3NcskIjR1gnmPYn/dObHNKJ0fajcAXs59iufV31XoXCWOiGluTIV51rX6BHlQMdrX6E8lPR8Ww6t8dVh3vWHq9KZU3wFB0exiaiM7fjiqFJ/dPkm0goPL7+QJPJKkB5Lk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hIqlK0/x; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C83B9C433F1; Mon, 19 Feb 2024 10:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708337129; bh=Wp1z8DD4y2npUVyApGi7Hca+cEHUY33+maH5kr1tQf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hIqlK0/xwDm4hFEwUq+KvV91ubPAyFk5GkmJHR1wz7FaM7mmXgiGrgVUDFpwWgO+U /TyKtGUmQTVguqYNLMBBLlNCE2AhS7bpIDZlo2XgreH1+ZTaPl8AIfh3oyzKAw7nSz YJRiTIQN6azbWHt79KcQ5I02nL5llWFEUfPl6b4I0hSByeeBZYUAUKLSsWhChQ5D+e CFyGm0EOJY2bglrWukdKWfjQe85i958MchkOqaI0O6hM8EX/USA7WSLbVjrcsQWnRO rDYbZFIsQjY5JsTAwLjHjxKa8wiyZG6g03OSL2TEVe72D6jwAhUKeW/pYQcAe5F4Ak Twubf9Tg6Azlw== From: Arnd Bergmann To: Saeed Mahameed , Leon Romanovsky Cc: Zhu Yanjun , Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yevgeny Kliteynik , Alex Vesker , Hamdan Igbaria , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] [v2] net/mlx5: fix possible stack overflows Date: Mon, 19 Feb 2024 11:04:56 +0100 Message-Id: <20240219100506.648089-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219100506.648089-1-arnd@kernel.org> References: <20240219100506.648089-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791321340246689657 X-GMAIL-MSGID: 1791321340246689657 From: Arnd Bergmann A couple of debug functions use a 512 byte temporary buffer and call another function that has another buffer of the same size, which in turn exceeds the usual warning limit for excessive stack usage: drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c:1073:1: error: stack frame size (1448) exceeds limit (1024) in 'dr_dump_start' [-Werror,-Wframe-larger-than] dr_dump_start(struct seq_file *file, loff_t *pos) drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c:1009:1: error: stack frame size (1120) exceeds limit (1024) in 'dr_dump_domain' [-Werror,-Wframe-larger-than] dr_dump_domain(struct seq_file *file, struct mlx5dr_domain *dmn) drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c:705:1: error: stack frame size (1104) exceeds limit (1024) in 'dr_dump_matcher_rx_tx' [-Werror,-Wframe-larger-than] dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx, Rework these so that each of the various code paths only ever has one of these buffers in it, and exactly the functions that declare one have the 'noinline_for_stack' annotation that prevents them from all being inlined into the same caller. Fixes: 917d1e799ddf ("net/mlx5: DR, Change SWS usage to debug fs seq_file interface") Signed-off-by: Arnd Bergmann Reviewed-by: Simon Horman --- [v2] no changes, just based on patch 1/2 but can still be applied independently --- .../mellanox/mlx5/core/steering/dr_dbg.c | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c index be7a8481d7d2..eae04f66b8f4 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_dbg.c @@ -205,12 +205,11 @@ dr_dump_hex_print(char hex[DR_HEX_SIZE], char *src, u32 size) } static int -dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, +dr_dump_rule_action_mem(struct seq_file *file, char *buff, const u64 rule_id, struct mlx5dr_rule_action_member *action_mem) { struct mlx5dr_action *action = action_mem->action; const u64 action_id = DR_DBG_PTR_TO_ID(action); - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; u64 hit_tbl_ptr, miss_tbl_ptr; u32 hit_tbl_id, miss_tbl_id; int ret; @@ -505,10 +504,9 @@ dr_dump_rule_action_mem(struct seq_file *file, const u64 rule_id, } static int -dr_dump_rule_mem(struct seq_file *file, struct mlx5dr_ste *ste, +dr_dump_rule_mem(struct seq_file *file, char *buff, struct mlx5dr_ste *ste, bool is_rx, const u64 rule_id, u8 format_ver) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; char hw_ste_dump[DR_HEX_SIZE]; u32 mem_rec_type; int ret; @@ -540,7 +538,8 @@ dr_dump_rule_mem(struct seq_file *file, struct mlx5dr_ste *ste, } static int -dr_dump_rule_rx_tx(struct seq_file *file, struct mlx5dr_rule_rx_tx *rule_rx_tx, +dr_dump_rule_rx_tx(struct seq_file *file, char *buff, + struct mlx5dr_rule_rx_tx *rule_rx_tx, bool is_rx, const u64 rule_id, u8 format_ver) { struct mlx5dr_ste *ste_arr[DR_RULE_MAX_STES + DR_ACTION_MAX_STES]; @@ -551,7 +550,7 @@ dr_dump_rule_rx_tx(struct seq_file *file, struct mlx5dr_rule_rx_tx *rule_rx_tx, return 0; while (i--) { - ret = dr_dump_rule_mem(file, ste_arr[i], is_rx, rule_id, + ret = dr_dump_rule_mem(file, buff, ste_arr[i], is_rx, rule_id, format_ver); if (ret < 0) return ret; @@ -560,7 +559,8 @@ dr_dump_rule_rx_tx(struct seq_file *file, struct mlx5dr_rule_rx_tx *rule_rx_tx, return 0; } -static int dr_dump_rule(struct seq_file *file, struct mlx5dr_rule *rule) +static noinline_for_stack int +dr_dump_rule(struct seq_file *file, struct mlx5dr_rule *rule) { struct mlx5dr_rule_action_member *action_mem; const u64 rule_id = DR_DBG_PTR_TO_ID(rule); @@ -584,19 +584,19 @@ static int dr_dump_rule(struct seq_file *file, struct mlx5dr_rule *rule) return ret; if (rx->nic_matcher) { - ret = dr_dump_rule_rx_tx(file, rx, true, rule_id, format_ver); + ret = dr_dump_rule_rx_tx(file, buff, rx, true, rule_id, format_ver); if (ret < 0) return ret; } if (tx->nic_matcher) { - ret = dr_dump_rule_rx_tx(file, tx, false, rule_id, format_ver); + ret = dr_dump_rule_rx_tx(file, buff, tx, false, rule_id, format_ver); if (ret < 0) return ret; } list_for_each_entry(action_mem, &rule->rule_actions_list, list) { - ret = dr_dump_rule_action_mem(file, rule_id, action_mem); + ret = dr_dump_rule_action_mem(file, buff, rule_id, action_mem); if (ret < 0) return ret; } @@ -605,10 +605,10 @@ static int dr_dump_rule(struct seq_file *file, struct mlx5dr_rule *rule) } static int -dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, +dr_dump_matcher_mask(struct seq_file *file, char *buff, + struct mlx5dr_match_param *mask, u8 criteria, const u64 matcher_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; char dump[DR_HEX_SIZE]; int ret; @@ -706,10 +706,10 @@ dr_dump_matcher_mask(struct seq_file *file, struct mlx5dr_match_param *mask, } static int -dr_dump_matcher_builder(struct seq_file *file, struct mlx5dr_ste_build *builder, +dr_dump_matcher_builder(struct seq_file *file, char *buff, + struct mlx5dr_ste_build *builder, u32 index, bool is_rx, const u64 matcher_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; memset(buff, 0, sizeof(buff)); @@ -728,11 +728,10 @@ dr_dump_matcher_builder(struct seq_file *file, struct mlx5dr_ste_build *builder, } static int -dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx, +dr_dump_matcher_rx_tx(struct seq_file *file, char *buff, bool is_rx, struct mlx5dr_matcher_rx_tx *matcher_rx_tx, const u64 matcher_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; enum dr_dump_rec_type rec_type; u64 s_icm_addr, e_icm_addr; int i, ret; @@ -758,7 +757,7 @@ dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx, return ret; for (i = 0; i < matcher_rx_tx->num_of_builders; i++) { - ret = dr_dump_matcher_builder(file, + ret = dr_dump_matcher_builder(file, buff, &matcher_rx_tx->ste_builder[i], i, is_rx, matcher_id); if (ret < 0) @@ -768,7 +767,7 @@ dr_dump_matcher_rx_tx(struct seq_file *file, bool is_rx, return 0; } -static int +static noinline_for_stack int dr_dump_matcher(struct seq_file *file, struct mlx5dr_matcher *matcher) { struct mlx5dr_matcher_rx_tx *rx = &matcher->rx; @@ -791,19 +790,19 @@ dr_dump_matcher(struct seq_file *file, struct mlx5dr_matcher *matcher) if (ret) return ret; - ret = dr_dump_matcher_mask(file, &matcher->mask, + ret = dr_dump_matcher_mask(file, buff, &matcher->mask, matcher->match_criteria, matcher_id); if (ret < 0) return ret; if (rx->nic_tbl) { - ret = dr_dump_matcher_rx_tx(file, true, rx, matcher_id); + ret = dr_dump_matcher_rx_tx(file, buff, true, rx, matcher_id); if (ret < 0) return ret; } if (tx->nic_tbl) { - ret = dr_dump_matcher_rx_tx(file, false, tx, matcher_id); + ret = dr_dump_matcher_rx_tx(file, buff, false, tx, matcher_id); if (ret < 0) return ret; } @@ -831,11 +830,10 @@ dr_dump_matcher_all(struct seq_file *file, struct mlx5dr_matcher *matcher) } static int -dr_dump_table_rx_tx(struct seq_file *file, bool is_rx, +dr_dump_table_rx_tx(struct seq_file *file, char *buff, bool is_rx, struct mlx5dr_table_rx_tx *table_rx_tx, const u64 table_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; enum dr_dump_rec_type rec_type; u64 s_icm_addr; int ret; @@ -858,7 +856,8 @@ dr_dump_table_rx_tx(struct seq_file *file, bool is_rx, return 0; } -static int dr_dump_table(struct seq_file *file, struct mlx5dr_table *table) +static noinline_for_stack int +dr_dump_table(struct seq_file *file, struct mlx5dr_table *table) { struct mlx5dr_table_rx_tx *rx = &table->rx; struct mlx5dr_table_rx_tx *tx = &table->tx; @@ -878,14 +877,14 @@ static int dr_dump_table(struct seq_file *file, struct mlx5dr_table *table) return ret; if (rx->nic_dmn) { - ret = dr_dump_table_rx_tx(file, true, rx, + ret = dr_dump_table_rx_tx(file, buff, true, rx, DR_DBG_PTR_TO_ID(table)); if (ret < 0) return ret; } if (tx->nic_dmn) { - ret = dr_dump_table_rx_tx(file, false, tx, + ret = dr_dump_table_rx_tx(file, buff, false, tx, DR_DBG_PTR_TO_ID(table)); if (ret < 0) return ret; @@ -911,10 +910,10 @@ static int dr_dump_table_all(struct seq_file *file, struct mlx5dr_table *tbl) } static int -dr_dump_send_ring(struct seq_file *file, struct mlx5dr_send_ring *ring, +dr_dump_send_ring(struct seq_file *file, char *buff, + struct mlx5dr_send_ring *ring, const u64 domain_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; memset(buff, 0, sizeof(buff)); @@ -933,13 +932,13 @@ dr_dump_send_ring(struct seq_file *file, struct mlx5dr_send_ring *ring, return 0; } -static noinline_for_stack int +static int dr_dump_domain_info_flex_parser(struct seq_file *file, + char *buff, const char *flex_parser_name, const u8 flex_parser_value, const u64 domain_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; int ret; memset(buff, 0, sizeof(buff)); @@ -957,11 +956,11 @@ dr_dump_domain_info_flex_parser(struct seq_file *file, return 0; } -static noinline_for_stack int -dr_dump_domain_info_caps(struct seq_file *file, struct mlx5dr_cmd_caps *caps, +static int +dr_dump_domain_info_caps(struct seq_file *file, char *buff, + struct mlx5dr_cmd_caps *caps, const u64 domain_id) { - char buff[MLX5DR_DEBUG_DUMP_BUFF_LENGTH]; struct mlx5dr_cmd_vport_cap *vport_caps; unsigned long i, vports_num; int ret; @@ -1003,34 +1002,35 @@ dr_dump_domain_info_caps(struct seq_file *file, struct mlx5dr_cmd_caps *caps, } static int -dr_dump_domain_info(struct seq_file *file, struct mlx5dr_domain_info *info, +dr_dump_domain_info(struct seq_file *file, char *buff, + struct mlx5dr_domain_info *info, const u64 domain_id) { int ret; - ret = dr_dump_domain_info_caps(file, &info->caps, domain_id); + ret = dr_dump_domain_info_caps(file, buff, &info->caps, domain_id); if (ret < 0) return ret; - ret = dr_dump_domain_info_flex_parser(file, "icmp_dw0", + ret = dr_dump_domain_info_flex_parser(file, buff, "icmp_dw0", info->caps.flex_parser_id_icmp_dw0, domain_id); if (ret < 0) return ret; - ret = dr_dump_domain_info_flex_parser(file, "icmp_dw1", + ret = dr_dump_domain_info_flex_parser(file, buff, "icmp_dw1", info->caps.flex_parser_id_icmp_dw1, domain_id); if (ret < 0) return ret; - ret = dr_dump_domain_info_flex_parser(file, "icmpv6_dw0", + ret = dr_dump_domain_info_flex_parser(file, buff, "icmpv6_dw0", info->caps.flex_parser_id_icmpv6_dw0, domain_id); if (ret < 0) return ret; - ret = dr_dump_domain_info_flex_parser(file, "icmpv6_dw1", + ret = dr_dump_domain_info_flex_parser(file, buff, "icmpv6_dw1", info->caps.flex_parser_id_icmpv6_dw1, domain_id); if (ret < 0) @@ -1067,12 +1067,12 @@ dr_dump_domain(struct seq_file *file, struct mlx5dr_domain *dmn) if (ret) return ret; - ret = dr_dump_domain_info(file, &dmn->info, domain_id); + ret = dr_dump_domain_info(file, buff, &dmn->info, domain_id); if (ret < 0) return ret; if (dmn->info.supp_sw_steering) { - ret = dr_dump_send_ring(file, dmn->send_ring, domain_id); + ret = dr_dump_send_ring(file, buff, dmn->send_ring, domain_id); if (ret < 0) return ret; }