From patchwork Mon Jan 13 07:30:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 11329725 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 192AD109A for ; Mon, 13 Jan 2020 07:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 011C82073D for ; Mon, 13 Jan 2020 07:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728731AbgAMHbl (ORCPT ); Mon, 13 Jan 2020 02:31:41 -0500 Received: from smtprelay0033.hostedemail.com ([216.40.44.33]:40108 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728646AbgAMHbl (ORCPT ); Mon, 13 Jan 2020 02:31:41 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 0D0DF181D3417; Mon, 13 Jan 2020 07:31:39 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1437:1515:1516:1518:1535:1544:1593:1594:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:2828:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:4225:4321:4419:4605:5007:6119:8660:10004:10848:11026:11657:11658:11914:12043:12296:12297:12438:12555:12760:12986:13019:13148:13230:13439:14181:14394:14659:14721:21080:21627:21990:30054,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: fear63_658d484eb9418 X-Filterd-Recvd-Size: 5014 Received: from XPS-9350.home (unknown [47.151.135.224]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Mon, 13 Jan 2020 07:31:37 +0000 (UTC) Message-ID: <3b91c274164d1ae9d81dce9f3b398d691cc6765e.camel@perches.com> Subject: [PATCH net-next] mlx5: Use proper logging and tracing line terminations From: Joe Perches To: Saeed Mahameed , Leon Romanovsky Cc: "David S. Miller" , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 12 Jan 2020 23:30:43 -0800 User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org netdev_err should use newline termination but mlx5_health_report is used in a trace output function devlink_health_report where no newline should be used. Remove the newlines from a couple formats and add a format string of "%s\n" to the netdev_err call to not directly output the logging string. Also use snprintf to avoid any possible output string overrun. Signed-off-by: Joe Perches --- drivers/net/ethernet/mellanox/mlx5/core/en/health.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c | 9 +++++---- drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c index 3a9756..75a35f1 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c @@ -197,7 +197,7 @@ int mlx5e_health_report(struct mlx5e_priv *priv, struct devlink_health_reporter *reporter, char *err_str, struct mlx5e_err_ctx *err_ctx) { - netdev_err(priv->netdev, err_str); + netdev_err(priv->netdev, "%s\n", err_str); if (!reporter) return err_ctx->recover(&err_ctx->ctx); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c index 6c72b59..67d2f70 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c @@ -110,7 +110,7 @@ void mlx5e_reporter_icosq_cqe_err(struct mlx5e_icosq *icosq) err_ctx.ctx = icosq; err_ctx.recover = mlx5e_rx_reporter_err_icosq_cqe_recover; - sprintf(err_str, "ERR CQE on ICOSQ: 0x%x", icosq->sqn); + snprintf(err_str, sizeof(err_str), "ERR CQE on ICOSQ: 0x%x", icosq->sqn); mlx5e_health_report(priv, priv->rx_reporter, err_str, &err_ctx); } @@ -179,7 +179,7 @@ void mlx5e_reporter_rq_cqe_err(struct mlx5e_rq *rq) err_ctx.ctx = rq; err_ctx.recover = mlx5e_rx_reporter_err_rq_cqe_recover; - sprintf(err_str, "ERR CQE on RQ: 0x%x", rq->rqn); + snprintf(err_str, sizeof(err_str), "ERR CQE on RQ: 0x%x", rq->rqn); mlx5e_health_report(priv, priv->rx_reporter, err_str, &err_ctx); } @@ -210,8 +210,9 @@ void mlx5e_reporter_rx_timeout(struct mlx5e_rq *rq) err_ctx.ctx = rq; err_ctx.recover = mlx5e_rx_reporter_timeout_recover; - sprintf(err_str, "RX timeout on channel: %d, ICOSQ: 0x%x RQ: 0x%x, CQ: 0x%x\n", - icosq->channel->ix, icosq->sqn, rq->rqn, rq->cq.mcq.cqn); + snprintf(err_str, sizeof(err_str), + "RX timeout on channel: %d, ICOSQ: 0x%x RQ: 0x%x, CQ: 0x%x", + icosq->channel->ix, icosq->sqn, rq->rqn, rq->cq.mcq.cqn); mlx5e_health_report(priv, priv->rx_reporter, err_str, &err_ctx); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c index b46854..5ecb986 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c @@ -90,7 +90,7 @@ void mlx5e_reporter_tx_err_cqe(struct mlx5e_txqsq *sq) err_ctx.ctx = sq; err_ctx.recover = mlx5e_tx_reporter_err_cqe_recover; - sprintf(err_str, "ERR CQE on SQ: 0x%x", sq->sqn); + snprintf(err_str, sizeof(err_str), "ERR CQE on SQ: 0x%x", sq->sqn); mlx5e_health_report(priv, priv->tx_reporter, err_str, &err_ctx); } @@ -118,10 +118,10 @@ int mlx5e_reporter_tx_timeout(struct mlx5e_txqsq *sq) err_ctx.ctx = sq; err_ctx.recover = mlx5e_tx_reporter_timeout_recover; - sprintf(err_str, - "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x, usecs since last trans: %u\n", - sq->channel->ix, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc, - jiffies_to_usecs(jiffies - sq->txq->trans_start)); + snprintf(err_str, sizeof(err_str), + "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x, usecs since last trans: %u", + sq->channel->ix, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc, + jiffies_to_usecs(jiffies - sq->txq->trans_start)); return mlx5e_health_report(priv, priv->tx_reporter, err_str, &err_ctx); }