From patchwork Mon Oct 14 13:53:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3574 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6331D3F338 for ; Mon, 14 Oct 2024 15:53:26 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43127097727sf12737145e9.0 for ; Mon, 14 Oct 2024 06:53:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728914006; cv=pass; d=google.com; s=arc-20240605; b=ca4HURBHeGbIJ8DLipHgsxWF7qoN1SqFVo1pIy6AbrvHgmAFiFil9/2Z+Bn/bwiVF4 ChDGB/tQihPn7kQEmm2j9sVWF15T2ON6PyWMoclCGGQYfh3yuVhrSU096Y2exbsCE8/K nKhG4E3ADdWjaA66cw6Gcz6hCNfmuEFjzHI2lh1uvBF/guvBSpwF0lk+/6hKAz0jDYR9 Eh89P28k/DnqemRXymdNLFPaNR7DHspJrFF7nxErat1wZEjYZ8LetY6DOjNnrejZoXh+ CkSO5ZnqrMjEW0YluQdCCcY5M+o+xPE++fv3maVDCfFUMaYY4E7TaaOVx7Vu5wIEbqvP qYVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=2G9JlCDeIUUUulprN7lTpsdWe/l25j7hzc15vrGSINg=; fh=OWAKBzwhtkXgqC6cV5HTE4bfRGe/h9bGTJVjsOZEBuo=; b=QGglUUBMw0Oh2zqj2OJkgjRsIlgqxPHrcEY42Z3YBWp69iNyNk+qcUmvDUpBAWTPKZ 1l2xssBnDS2hbu3koFf0KOOko0KUUda2FPBmEqJueHzfjoAOGswdD3Rv4LTIHBsy1cDP owu/fwT+fafGDygJYZpOkFTgsIbW1L4rM3vXppSse3ZhXFdeOo6y3EXT1Wnq18j+Dutd xw+RtHQJLFGLKdwHa82MmTWleV+ETM512aR0DVu3hdBpfApzZBg8LnZNVP2l1MpYk1Nm 48gk7J+HSeaBsW7NwGFtOuGWwKrN6JGiboFpAOXHjOlHpaYZKYIRStzZKerOt5X/tZoN 8YNA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hTw28+Cb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1728914006; x=1729518806; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=2G9JlCDeIUUUulprN7lTpsdWe/l25j7hzc15vrGSINg=; b=H2D26Hk/fI7peXvSPpsUHkzelP2rxnON9ZJLNE2b+uZ2Iz/ryLYNWcg5BgTK83FOdK R2JHCtlruwVLmXSdR9PhAyahPR8pRjUZw8zM6wyi4harev01g4uW0Nx7/KxqGT6pEpBY Xmw38YkPJXMFjlVaFq0M+9QdWgb3QBF4r15jA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728914006; x=1729518806; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2G9JlCDeIUUUulprN7lTpsdWe/l25j7hzc15vrGSINg=; b=TbZZAmEFZ84kS07yGH+RRJLD9f5gxWFMoyWDEmSNe1UpPpqFoP5DFC1lxklwMUdLxN NdtOQyolptbGpENZrwafM3ojRZARR8WLSLOKCappp9SRmIGZhdiJS8n/21VBUdX5o2a+ XI/8u7i9Sx2ISU5z2pkCMUsmVin+5rFZbRRFhwuNc0/iK7f53gxq3tzCUUZxqM0PEss6 juojHJsUlYrYpAcAPDTv+SzHANdsJT2G+xJEohrtwAbhENb29xjbWUgEhu9KcnKmhBTe RyiGY7oFJ5dxJm+mVVwA3qHv2BLSF6SEzRj9TF7pVPHczZPSvM3zzh2r1BnkaJX2yrCy SfZQ== X-Forwarded-Encrypted: i=2; AJvYcCVpIcZpd+8FDab/6BDyT5atksa30Y+BFqVzIZt+5qpzoOhvfxB7mKvKnWcfOh8b6x7tVwha7uyCB6MSGz+I@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yx+7FL6vC5VL1xSWEoH0xXQ5keb7IIIXpSdA9NBwDSYFnJgAgny SXJ6E60P2pgHqUK8pLa0ntcszXWCN5Uf8Tnd+qJ4bqul/QBYF0eUdiM8sC9TA5jG6w== X-Google-Smtp-Source: AGHT+IHdOjlLjoJ/T6WKQeCGB3uK36ZZFsu/rZy49BHldox+3Dp+NH2ytzE3KG7BUfWE1W4NwOUHTg== X-Received: by 2002:a05:600c:1ca6:b0:42c:bd27:4c12 with SMTP id 5b1f17b1804b1-4311ded1fedmr98963275e9.10.1728914005536; Mon, 14 Oct 2024 06:53:25 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3b8a:b0:430:5356:ac93 with SMTP id 5b1f17b1804b1-43115efb007ls1321435e9.0.-pod-prod-03-eu; Mon, 14 Oct 2024 06:53:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVT8TiGn6D5GC1NpIxAKI9X1NxWdOYSrQTs1F3q4ogoQGOtujrrFuxLvBNTCOdU32/++q35f3SYZhbkFtM4@amarulasolutions.com X-Received: by 2002:a05:600c:1d29:b0:430:52ec:1e41 with SMTP id 5b1f17b1804b1-4311defde09mr112646685e9.17.1728914003823; Mon, 14 Oct 2024 06:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728914003; cv=none; d=google.com; s=arc-20240605; b=bpaROAALKF3dFg4VQ71Hb2odAKhm5SJXLKydsKtTtNEyEtqUOqkjb+wHDVh8HIbM2M SXfHSm3CbN4QREchfIp8DGTWMdooE1bQCriJrszoxPQGkPbQVpaRIZC0mL8C8JKUl1Tu Zr7fAq0AaOMbszASNxFBpI+yHjsHbkXLD++wn/FRXNnx9oVrZ1o+LDkwadttOrfd9uLI HEi/jkSbnm4u/RuaRvukChUQHEOezdELgE5UxIYm97pIk8iU7Le9CCbx9pPC0guhjiG7 5LbOmF+4+P+VotrYPNFlfAriTaXVB54r3ujTgCzFcsuvch1jfs/K2oED0xlxqiULUl9k cpNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=6TIk4NNoYSacsyCpliVko137LO9s6zdaj7BCOJzXy4w=; fh=qkH9Xh8GCNpKoX1aVJvZHdTKtEHSnSRZCb1rbmU0hTg=; b=hRACiOhEurwB4bK+KryX5/6mIFwzCxRNMefox4qz2fjMq0vVZVacVxi83EfDOs2GEQ k3U2HKebmUUt/FsxGEtGYbn/o5hOG0Rys0wXytUsJEqGUoJ6SuKAV29BSHt1FJg2ccBk QkaCg3PrSQ1XJV+SI4Dn/wW/HvzSBsvDFMLAFxPmPnx8IPyBB4w0QkelQ+E1QnPHv8Ul cKVa06dw1+ZYItHvEScfJMt3X3g2qfmr9F6ROHXkQ9Qx9ZBpuVNn1Fd3homUCxufvDoZ t2Azn2fDNESL1O87yTfK9XOqvXInLHwSLGVrTqCH/TcaO/vvCxUvRmu0XUxDn25jLB/o YwaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hTw28+Cb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-43118321325sor28654465e9.0.2024.10.14.06.53.23 for (Google Transport Security); Mon, 14 Oct 2024 06:53:23 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCWRofF/zfZd3YIfYu1+9dbFhNUiTk44dO1CQiWkcpyvk3FvDts/dxdgCl2l4VcNij1Fuu87Mp72FE70IR5R@amarulasolutions.com X-Received: by 2002:a5d:43c6:0:b0:37c:cf73:4bf7 with SMTP id ffacd0b85a97d-37d551fca59mr7838791f8f.34.1728914003327; Mon, 14 Oct 2024 06:53:23 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6cff9asm11404402f8f.48.2024.10.14.06.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 06:53:22 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Bhupesh Sharma , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] can: c_can: fix {rx,tx}_errors statistics Date: Mon, 14 Oct 2024 15:53:13 +0200 Message-ID: <20241014135319.2009782-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hTw28+Cb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The c_can_handle_bus_err() function was incorrectly incrementing only the receive error counter, even in cases of bit or acknowledgment errors that occur during transmission. The patch fixes the issue by incrementing the appropriate counter based on the type of error. Fixes: 881ff67ad450 ("can: c_can: Added support for Bosch C_CAN controller") Signed-off-by: Dario Binacchi --- drivers/net/can/c_can/c_can_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/c_can/c_can_main.c b/drivers/net/can/c_can/c_can_main.c index c63f7fc1e691..511615dc3341 100644 --- a/drivers/net/can/c_can/c_can_main.c +++ b/drivers/net/can/c_can/c_can_main.c @@ -1011,7 +1011,6 @@ static int c_can_handle_bus_err(struct net_device *dev, /* common for all type of bus errors */ priv->can.can_stats.bus_error++; - stats->rx_errors++; /* propagate the error condition to the CAN stack */ skb = alloc_can_err_skb(dev, &cf); @@ -1027,26 +1026,32 @@ static int c_can_handle_bus_err(struct net_device *dev, case LEC_STUFF_ERROR: netdev_dbg(dev, "stuff error\n"); cf->data[2] |= CAN_ERR_PROT_STUFF; + stats->rx_errors++; break; case LEC_FORM_ERROR: netdev_dbg(dev, "form error\n"); cf->data[2] |= CAN_ERR_PROT_FORM; + stats->rx_errors++; break; case LEC_ACK_ERROR: netdev_dbg(dev, "ack error\n"); cf->data[3] = CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; break; case LEC_BIT1_ERROR: netdev_dbg(dev, "bit1 error\n"); cf->data[2] |= CAN_ERR_PROT_BIT1; + stats->tx_errors++; break; case LEC_BIT0_ERROR: netdev_dbg(dev, "bit0 error\n"); cf->data[2] |= CAN_ERR_PROT_BIT0; + stats->tx_errors++; break; case LEC_CRC_ERROR: netdev_dbg(dev, "CRC error\n"); cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; break; default: break;