From nobody Fri Nov 22 21:42:02 2024 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EB4718EFD4 for ; Sat, 16 Nov 2024 18:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780191; cv=none; b=s+0pvy/Z0flXCGBGVEtHhI/QtkWRXrzNmGeXh+JUDEfMlYjAjsChBRF+ztoHgGgZT+C9vFVt+P/SbaBQvfIoxBFQGH80vitAa5Nz/h67sfve93FnjvYdorNr3AsHC15KTlN16DSDufSKa7wntK+DvbDSns+IpH9C2/6EKVVedmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780191; c=relaxed/simple; bh=6yVXQABDgHQ3YoFzFBc688YaHlYOrV8PMSvT0DmVF0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nGhTFXBq1226qa8l75oglZHgwauh39NSYxtbYysF+F7vFIDWGEB5Q0oEkWwxvxbujcS/6Lj1JSxOSEIVl1dhh2jO96T27gkCDGxhU+p2MtzKnuhS5m40IJDPR/UvDR5S5cWgCoOa3OLwW5pLfus7DnRahy7oz3k4JFMRaR/CJ/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com; spf=pass smtp.mailfrom=amarulasolutions.com; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b=HsKRaCyI; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amarulasolutions.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="HsKRaCyI" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aa2099efdc3so542999466b.1 for ; Sat, 16 Nov 2024 10:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780188; x=1732384988; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CGnFcahEd0eVvjCCPAmskcKVoLg3YmWfRrAxcNnhTVM=; b=HsKRaCyI871iY1l5Qeyc6UDUSwcuGhGMCDevYQ2NGytn58BAQNcVs2Wqyv6d8Il4ZN imRPyozRk+2ElitXM/VyaorxyO4j3/yIH/qXBD6JyvbRKYMHCzd2mOPzq4ttVt3Uzt7t Mhqui6sOmmnYRMuweXVRqMKh/Qo3jn1h+qKek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780188; x=1732384988; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CGnFcahEd0eVvjCCPAmskcKVoLg3YmWfRrAxcNnhTVM=; b=BC8Pjdxh7ue999TErI90vC0S+7c08bM1SFTB8QmSPuJHAef4vfzptrYbwyshl3psi2 UL6btF/bOSObHtu7knP7ataqXv312nxlR6wz6o13IQ6aPDgt5sHEJFUoE8rQ2ENJ6CZm B6Bjoo05QSbYmbtNUhuBud4Fhwrd56zm4m3QfzdAoP4dg3Ces1xstqGJ8GXibWXHJPJ0 yaV227F0KdfWJHpMhSigpP2xmugJE0K05YxFoBKtEeah+TYB/TdM1o28f1w1LzaQokLN Rk+BXk6UX1QJ6qsj00kqBIiy/+xiUAgjQZa9A3sP6OCQaDNtBwTli9HmCSlnTCPo8M1b KfMg== X-Gm-Message-State: AOJu0Yy5WiJtjoSsJFuCrkin8Vy9Nri8xlrq+v2IPqKSP2hBEQx1M67M V4ei1SQYaCjz2ckmD5EM7/Sxp3Ui0ydWWI5cBKGx6R94kPiDYavfpc6HwtCTU71r3F+WW1B7Y7V V X-Google-Smtp-Source: AGHT+IEY6i5r17rHD7AA4pDo0eewtwkaRGniz3NbwzmDUylo6DVU+CLQMsuSqXx2AB1hMg+lZtDO9Q== X-Received: by 2002:a17:907:1c9d:b0:a9e:670f:9485 with SMTP id a640c23a62f3a-aa481a5cecfmr569044566b.30.1731780188249; Sat, 16 Nov 2024 10:03:08 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20dc6d364sm329549066b.0.2024.11.16.10.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:07 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , Chandrasekar Ramakrishnan , "David S. Miller" , Dong Aisheng , Eric Dumazet , Fengguang Wu , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Varka Bhadram , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/7] can: m_can: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:30 +0100 Message-ID: <20241116180301.3935879-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> References: <20241116180301.3935879-1-dario.binacchi@amarulasolutions.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The m_can_handle_lec_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: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support") Signed-off-by: Dario Binacchi --- drivers/net/can/m_can/m_can.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 16e9e7d7527d..337ccfae34fd 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -695,7 +695,6 @@ static int m_can_handle_lec_err(struct net_device *dev, u32 timestamp =3D 0; =20 cdev->can.can_stats.bus_error++; - stats->rx_errors++; =20 /* propagate the error condition to the CAN stack */ skb =3D alloc_can_err_skb(dev, &cf); @@ -711,26 +710,32 @@ static int m_can_handle_lec_err(struct net_device *de= v, case LEC_STUFF_ERROR: netdev_dbg(dev, "stuff error\n"); cf->data[2] |=3D CAN_ERR_PROT_STUFF; + stats->rx_errors++; break; case LEC_FORM_ERROR: netdev_dbg(dev, "form error\n"); cf->data[2] |=3D CAN_ERR_PROT_FORM; + stats->rx_errors++; break; case LEC_ACK_ERROR: netdev_dbg(dev, "ack error\n"); cf->data[3] =3D CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; break; case LEC_BIT1_ERROR: netdev_dbg(dev, "bit1 error\n"); cf->data[2] |=3D CAN_ERR_PROT_BIT1; + stats->tx_errors++; break; case LEC_BIT0_ERROR: netdev_dbg(dev, "bit0 error\n"); cf->data[2] |=3D CAN_ERR_PROT_BIT0; + stats->tx_errors++; break; case LEC_CRC_ERROR: netdev_dbg(dev, "CRC error\n"); cf->data[3] =3D CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; break; default: break; --=20 2.43.0