From nobody Fri Nov 22 16:31:48 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 From nobody Fri Nov 22 16:31:48 2024 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 0B4F31953B0 for ; Sat, 16 Nov 2024 18:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780193; cv=none; b=k9AQyalZ1+laEl37mH2KhV9yoUXMf7DrzDoMB5jAU1m+HucCSLGWVLebJhl9aTVldJSMB75wWVXDHVwsusPEN3gL/XdqocbQVUlKg8lw3TBl1jhTQ15ZYZM+bB908xx/RVhsDu8esbUTpQ2qyS0pFc9NSD3Fl31D4G6TFasp7Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780193; c=relaxed/simple; bh=A34sGZ1LJl0UqZM4Ywby3Ot5AJSBqH2ddrj3nuGd0os=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H2ocRcEQcV1TCtFgCGdG9me1E7PO5U6NCZjKyUjnVGinoGSMf3R0Jibl2X6wMWMTkVrGNKAxCHyUxj5cclAFfFs4oRDVU5KqZ7ZnDKoUeeL9ku7CMmx65MOq3f5JQqcL83oSTH9FVlZApbV2xtBIUVHB+fXlA2ZPJM5bDBYNIz8= 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=IOzwUli6; arc=none smtp.client-ip=209.85.218.46 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="IOzwUli6" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a9ec267b879so313829766b.2 for ; Sat, 16 Nov 2024 10:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780190; x=1732384990; 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=MKS1He5MRcB9KzHlUh7sCjUXRUA/E/nSRL0TriRLZjg=; b=IOzwUli6lxoPfAGdmsommEzymo7E/Gf2QmVx3z6spbZionuPtyq/b4yhuTeQ0HNc9M CHm9ugJCn0br6/wHKUyWoIdLDThfLAE/S2xu5eXHAlrd1Ne+zb4Xrpqb5dQ1edjq+aiG bZCorLoEnlEIReD3DCEMYzXo7Re0hGvtmFMr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780190; x=1732384990; 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=MKS1He5MRcB9KzHlUh7sCjUXRUA/E/nSRL0TriRLZjg=; b=SQdxfXeBor5a0fzhK3M/iaQq7B8gkCICwTETNMp2JPpPtoh4RjyaGlK7brfkTsPMH6 5/FihLCjmrqkDAFgHWDJXTui91WtE2ERpMt3oYwKo2w7ngD7cOrkeg/ybGHMm1BArltI vzlYvUtvJ4oJcfzfIw4iSWhFNLOwXqTvle7AZw+KpHckEOCEKqxffEALjXCe36I25qqa XfGqZXNhZrCERfV9v/vEgkXBQDhp0Kws0FaC32Jr128TH6Yag5m3PK4zPB6qwe3e0xOG m9r2HkpU8PX4OePpZ46qjjyBrtRp9obBReBSXNsX0JKmD5j7zacjvLt9bLHYSvTio1yP 15XA== X-Gm-Message-State: AOJu0YxEmm0YkA36ju7l3J0qcbtNCsMWf2PlAoBWp5FltqmeIl2GiIoi M2BhzkNiBZcNc4UWZ8zgidfJsZ5pKQzIy8vplnqHMT8Iy4DljJvUBkOdsWl8N30/Yvbfk0jZnAs 0 X-Google-Smtp-Source: AGHT+IFQitaQvnvCpjPNTAPjRJikCJXH/36A9a4AKWk86qEm3fbIuRU18rHtQaOlozEwQjJKTxS63g== X-Received: by 2002:a17:906:d542:b0:a99:f887:ec1d with SMTP id a640c23a62f3a-aa48354c913mr613773866b.49.1731780189884; Sat, 16 Nov 2024 10:03:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:09 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Marek Vasut , Paolo Abeni , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 2/7] can: ifi_canfd: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:31 +0100 Message-ID: <20241116180301.3935879-3-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 ifi_canfd_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: 5bbd655a8bd0 ("can: ifi: Add more detailed error reporting") Signed-off-by: Dario Binacchi --- drivers/net/can/ifi_canfd/ifi_canfd.c | 29 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_ca= nfd/ifi_canfd.c index d32b10900d2f..3944821303fc 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -390,7 +390,6 @@ static int ifi_canfd_handle_lec_err(struct net_device *= ndev) return 0; =20 priv->can.can_stats.bus_error++; - stats->rx_errors++; =20 /* Propagate the error condition to the CAN stack. */ skb =3D alloc_can_err_skb(ndev, &cf); @@ -400,26 +399,40 @@ static int ifi_canfd_handle_lec_err(struct net_device= *ndev) /* Read the error counter register and check for new errors. */ cf->can_id |=3D CAN_ERR_PROT | CAN_ERR_BUSERROR; =20 - if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) { cf->data[2] |=3D CAN_ERR_PROT_OVERLOAD; + stats->rx_errors++; + } =20 - if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) { cf->data[3] =3D CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; + } =20 - if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) { cf->data[2] |=3D CAN_ERR_PROT_BIT0; + stats->tx_errors++; + } =20 - if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) { cf->data[2] |=3D CAN_ERR_PROT_BIT1; + stats->tx_errors++; + } =20 - if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) { cf->data[2] |=3D CAN_ERR_PROT_STUFF; + stats->rx_errors++; + } =20 - if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) { cf->data[3] =3D CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; + } =20 - if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) { cf->data[2] |=3D CAN_ERR_PROT_FORM; + stats->rx_errors++; + } =20 /* Reset the error counter, ack the IRQ and re-enable the counter. */ writel(IFI_CANFD_ERROR_CTR_ER_RESET, priv->base + IFI_CANFD_ERROR_CTR); --=20 2.43.0 From nobody Fri Nov 22 16:31:48 2024 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 59D9419E982 for ; Sat, 16 Nov 2024 18:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780195; cv=none; b=ht4FjIhU9WJF7r3gzKOIDVHiR2ZduwdXxFQxqEgLcGgjEhZpQjnq5WeOfonVd9HQLn0lkWFTdCIPms/2Y1740Ddd2YmIVNv8u6vd/BH4jWvw7ACVI+BcWTb2qxhufMaLMjFxP2Q5rypPLttUeESOJB2sQl9EIHShp5I5bkqRkN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780195; c=relaxed/simple; bh=iVOkbe1eRnWeGsTAkh+kyxSnjEZFWE6KQVh2hr3CkMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sCtU8RmJzQ8VxBmVDLciNIcKbsgJQd3GmE6Jnev+QY/OfpIjBQz+vwn0Q6tu3H439XPPAxzXgn6fsPkEfUfxW+60C1izKZkxrkyToyLXWnBSuoTCPwFb8ILsdo4XEdAD0IgshUtPNLlHEPI4lySjhQYXbISUgpI+vbL5KBE2mkQ= 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=KC447fUs; arc=none smtp.client-ip=209.85.218.49 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="KC447fUs" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a9ec86a67feso539944866b.1 for ; Sat, 16 Nov 2024 10:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780192; x=1732384992; 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=u1KN5qU2y25n0Oin8u2W01ajVRL3l5JZUYgBLtna1CA=; b=KC447fUsL8LwnpmfucdTwo0WlrEG83Da74tIB5BsC7E8xWn47ZcNLNSUbsGSztvXdU zsX07uTScA+wf3aZ7U2hOhW1k+StezN0wcUHaHR9JCpEIWtrHhTkrybJszUDRj9Qf8x+ y2YULSNNzJphGose2I52z8dYmXnv6EHq5pUJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780192; x=1732384992; 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=u1KN5qU2y25n0Oin8u2W01ajVRL3l5JZUYgBLtna1CA=; b=VFRj1gFYKL8JA0UiYaJXuphr4MhrRbEfLEl9s85VxZojVdFQNeFpNl49QFSmWgvM5O LAg8OniCJQS0Nyd479gOCpXNr59oDaGK5FnDQmoZRHHMSqlrYIjHtHsNXxwzn9wTLFA7 nwlfYgn5GmikjYlF22PXpBfkkdiD7XIe91jBsko/2fdcOgi91LVzH1BYI4rgi1Xgmr95 CfrkfU+OW9X6PUconepYCDV0pf7dqJTQZnmd30Ky0k0MrzA91+2Oms9/6kIEHCxDeQLg hOgs3UQyVk3dOxZdfIcYB8VeyAbRC4EbCGyhI+pWM7za3g1r0K3r5Kmz3a6pGp5BAllH OlTQ== X-Gm-Message-State: AOJu0Yz81kxCaTIyvMVIBofPGlSmGzuqu92nZ8Yz7q64ZNrwDvNB9n1/ h16kmENG2Whvif4ukE85P1+pgOuZ/qeBUpSkKDYb9YQQFfTRLBetm+GZ0vZyWgb4rg35B0S5wcg + X-Google-Smtp-Source: AGHT+IES+ynBAJVqc7eTqNBNioplQ+TxFxR95t5P1e/kKOcra0XnT3EiiSNrB4CCUflAKPlc0RxwSg== X-Received: by 2002:a17:907:3689:b0:a9e:8612:eeca with SMTP id a640c23a62f3a-aa48352b54bmr627153166b.48.1731780192655; Sat, 16 Nov 2024 10:03:12 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:11 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Akshay Bhat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Krzysztof Kozlowski , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 3/7] can: hi311x: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:32 +0100 Message-ID: <20241116180301.3935879-4-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 hi3110_can_ist() 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: 57e83fb9b746 ("can: hi311x: Add Holt HI-311x CAN driver") Signed-off-by: Dario Binacchi --- drivers/net/can/spi/hi311x.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c index 148d974ebb21..7a4d98037cd3 100644 --- a/drivers/net/can/spi/hi311x.c +++ b/drivers/net/can/spi/hi311x.c @@ -701,17 +701,22 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_= id) =20 cf->can_id |=3D CAN_ERR_PROT | CAN_ERR_BUSERROR; priv->can.can_stats.bus_error++; - priv->net->stats.rx_errors++; - if (eflag & HI3110_ERR_BITERR) + if (eflag & HI3110_ERR_BITERR) { cf->data[2] |=3D CAN_ERR_PROT_BIT; - else if (eflag & HI3110_ERR_FRMERR) + priv->net->stats.tx_errors++; + } else if (eflag & HI3110_ERR_FRMERR) { cf->data[2] |=3D CAN_ERR_PROT_FORM; - else if (eflag & HI3110_ERR_STUFERR) + priv->net->stats.rx_errors++; + } else if (eflag & HI3110_ERR_STUFERR) { cf->data[2] |=3D CAN_ERR_PROT_STUFF; - else if (eflag & HI3110_ERR_CRCERR) + priv->net->stats.rx_errors++; + } else if (eflag & HI3110_ERR_CRCERR) { cf->data[3] |=3D CAN_ERR_PROT_LOC_CRC_SEQ; - else if (eflag & HI3110_ERR_ACKERR) + priv->net->stats.rx_errors++; + } else if (eflag & HI3110_ERR_ACKERR) { cf->data[3] |=3D CAN_ERR_PROT_LOC_ACK; + priv->net->stats.tx_errors++; + } =20 cf->data[6] =3D hi3110_read(spi, HI3110_READ_TEC); cf->data[7] =3D hi3110_read(spi, HI3110_READ_REC); --=20 2.43.0 From nobody Fri Nov 22 16:31:48 2024 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 19A801B0F10 for ; Sat, 16 Nov 2024 18:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780198; cv=none; b=osdyzm0rOXs0uYkhkkWmTO0iEfOoBQmfTawFPOtNyue5X57nPYeluFigdO/+Lw6tV9T+55jaZYYkH6+MZ40bsBxsOjduRfV3eYJJUqctrtiDSewCtzYjc1aiUVLVOOubAng5uxocIoKYLh2UqH6rdCmB41ZEDn7dX/VgQo6KgsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780198; c=relaxed/simple; bh=b+NraIsUClYsl+LKVbalvzNKBzSiT/wtutwKCT3G2ao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TuDE7Raq35dYTd4XZtEAfzawhbJxNnb/Da1ZNWOEEOr+ml2DcTLf6qDTsZibLQO13UeG6GiUa/MWvw+AdeIPbsH7XnRGKZXRFiZBvXX0musCvh1ATEmg/MQFIt93dgxS59j/f7KYXmEjkB/Pla8CXbJdflzPJVOimg3GaNv61Fw= 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=asoGproX; arc=none smtp.client-ip=209.85.218.46 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="asoGproX" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-aa20944ce8cso526220666b.0 for ; Sat, 16 Nov 2024 10:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780195; x=1732384995; 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=IPi0av2xe0jC0J5HdvNkCxIcsg4iO3imVdR2/hegefY=; b=asoGproXuz1ZNgmEjSgCPF6L9Vv8f07KkLdTa0sETtE3Xsy1+7ZCsAMGhxDV6/VdJj WZg/Vq6znz40fyTgL24alMigYmclmtdnurp9jvan3a3yxsO+B6GMGD9dpCF8kjqeLITW yR7Le4s+AX/pKt5G0XvK0X3VmmrXGCxP01pHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780195; x=1732384995; 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=IPi0av2xe0jC0J5HdvNkCxIcsg4iO3imVdR2/hegefY=; b=opWm6udguygPa9Vu3kEhdTbLSNguyqSkKnb2GWgKOcq1jsfVJUO7F77ZBJKrOCu41o 7uqOKyWuOKjE2GHMudhViaXQePi+7mwppNGpt8mfbcfM8SWII38GwyL9mwwkxCIqxLdu L04uPWZkMlW9x04ef1dYjXnSrd0C+co/Jj1c6G5+Ny9EJXRhqJC33wnK+hzmvTmmCkQS OOBkwHVhGXXrR57Dft31JVpJbxYRN4szm41H4yIsx9CN64UGNUX3IZuft2Val2De7jR1 fMdCT81PPdjpAUeoGpjuPAdKDB4Pq0vWmUW2RlStVOKLQOY9nNcwwtbcK5frDXNU0ua+ Frqw== X-Gm-Message-State: AOJu0YweKpDLzZ6nXbnzUnfnIh/qdnE05vroA5uijHVNsOs9IyuArkTT QWSB6n9TM6p+/utacqggXkCJposBw6OmkVY5Z3seigI2FJT+trtc5FlvbmwWP2VctUD6ouhhVsi v X-Google-Smtp-Source: AGHT+IGiCGpsd+G1WFq5UxLc4I4k8txDJ+JeMk91+wJgoZFiUor+BpmbVpSQLk7uJcDP3qphPmkBiw== X-Received: by 2002:a17:907:9813:b0:a9e:c266:4e82 with SMTP id a640c23a62f3a-aa48185c694mr772769266b.6.1731780195092; Sat, 16 Nov 2024 10:03:15 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:14 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Oliver Hartkopp , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 4/7] can: sja1000: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:33 +0100 Message-ID: <20241116180301.3935879-5-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 sja1000_err() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 429da1cc841b ("can: Driver for the SJA1000 CAN controller") Signed-off-by: Dario Binacchi --- drivers/net/can/sja1000/sja1000.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sj= a1000.c index ddb3247948ad..706ee8f6b7db 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c @@ -460,7 +460,6 @@ static int sja1000_err(struct net_device *dev, uint8_t = isrc, uint8_t status) if (isrc & IRQ_BEI) { /* bus error interrupt */ priv->can.can_stats.bus_error++; - stats->rx_errors++; =20 ecc =3D priv->read_reg(priv, SJA1000_ECC); =20 @@ -485,8 +484,12 @@ static int sja1000_err(struct net_device *dev, uint8_t= isrc, uint8_t status) cf->data[3] =3D ecc & ECC_SEG; =20 /* Error occurred during transmission? */ - if ((ecc & ECC_DIR) =3D=3D 0) + if ((ecc & ECC_DIR) =3D=3D 0) { cf->data[2] |=3D CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } } if (isrc & IRQ_EPI) { /* error passive interrupt */ --=20 2.43.0 From nobody Fri Nov 22 16:31:48 2024 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 C21DA1AF0D4 for ; Sat, 16 Nov 2024 18:03:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780200; cv=none; b=BsxP44Wgh8IxihaK+vjxmMzBIDih8xJdmfi4iRGDT5Oigy92AZ+aqhPSEhCZy9dr/1WpEMg3NaSAc3cndibB8HroXeAxkl7vkk9LGWJ8kVAOreRs96SVjgs+mtxiTh93cN5v2S4Q3wk6oNBINYbLn07ukHK7Hg8X/IYrPvNGsrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780200; c=relaxed/simple; bh=0jjERzUdBGaOyD8hozmGujUsFYfwS4ojvocwRF0u2o4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oGtXIj+ob325VYnM8/YIxdvEZc89czMNn2pOA90lnCtNmxhAWHSAPjF3UWYxM90JjfW444SDauuJPlCOu/33e4sDykpzujgN3QY+CifzMSe1ZMHD2+nlemCr2gDmGdkM3NeXbU5kvIxfxBqoMDQmsC3zCOxrKyyDG9kgY407m9A= 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=ZP6OPMMs; arc=none smtp.client-ip=209.85.218.42 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="ZP6OPMMs" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa3a79d4d59so472925066b.3 for ; Sat, 16 Nov 2024 10:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780197; x=1732384997; 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=ZZp2LLELhHXaHE6P8yqyIkdBBd7fnVylmpcd4GsYhTg=; b=ZP6OPMMsPSoEV5qC2gEQ7Vdexb32aL/+XTdBRD+FQe+DqscjXa8xQNi7wKBD+mmPXN +BQHugUbzoNseK5FjndAgnnwzOLTNsLDOPwgW3Zy/vZx0Lp0Cs9lg6Ampx5a/6DQ7UED fDNDmlNRNpGTU7m8OSzldHPIagdwe+gfDwr98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780197; x=1732384997; 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=ZZp2LLELhHXaHE6P8yqyIkdBBd7fnVylmpcd4GsYhTg=; b=fpys57fRMkYP9YZjKtV2L5hx8GAvIO3axhNk1SRGDrrJ9eUHZISxjOstCrMpFUNhwk giOFVZnE4snmq5InrPX5Ry87ds2twOQMafjFt4yaXcN/bo2ZSx9QQdZV8Y9lEvUM0Nnr 38wX2NIrOFEISg5o4tjrRyD4BY99CLRBYw6GGW42TEYxW8afWZn1xqf8X5jW2ryeWbzy x+8RcXBbRa+GqjXe/az0f2CaiBVNMelB7xLBrpDzZTopCXASUv8IJKN7l/InU+gu6bl3 dkuKmzlDr73y26nANFcjQ9Fbip9FZguKbFy6kOZvg1jhqSX7Okea7vs2yDkYkDIby/WL 21Eg== X-Gm-Message-State: AOJu0Yx8ZhB51BkkSKhAqZ6ePVHkkq/9ZBdJwTBOYi9uiQg+wqxn88A0 /XeYDlZ6evEkeu+1BpNgEm2Xpddq21gRcbUet9s6bwGL7zwTQXPZCd1P6gT44p1Bkyj6/CoaUmt R X-Google-Smtp-Source: AGHT+IHco/HhB19U8GRhXEYmlvtasr6hZ6h72SXfmIX9BAE4Ibve8haYdY+6mq7whoM3rHFNs0pSVA== X-Received: by 2002:a17:907:d24:b0:a9a:bbcd:e63 with SMTP id a640c23a62f3a-aa483421c58mr612801466b.14.1731780196892; Sat, 16 Nov 2024 10:03:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:16 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , Chen-Yu Tsai , "David S. Miller" , Eric Dumazet , Gerhard Bertelsmann , Jakub Kicinski , Jernej Skrabec , Marc Kleine-Budde , Maxime Ripard , Paolo Abeni , Samuel Holland , Vincent Mailhol , linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-sunxi@lists.linux.dev, netdev@vger.kernel.org Subject: [PATCH 5/7] can: sun4i_can: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:34 +0100 Message-ID: <20241116180301.3935879-6-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 sun4i_can_err() function only incremented the receive error counter and never the transmit error counter, even if the STA_ERR_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the STA_ERR_DIR flag. Fixes: 0738eff14d81 ("can: Allwinner A10/A20 CAN Controller support - Kerne= l module") Signed-off-by: Dario Binacchi --- drivers/net/can/sun4i_can.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c index 360158c295d3..40939141749d 100644 --- a/drivers/net/can/sun4i_can.c +++ b/drivers/net/can/sun4i_can.c @@ -579,7 +579,6 @@ static int sun4i_can_err(struct net_device *dev, u8 isr= c, u8 status) /* bus error interrupt */ netdev_dbg(dev, "bus error interrupt\n"); priv->can.can_stats.bus_error++; - stats->rx_errors++; =20 if (likely(skb)) { ecc =3D readl(priv->base + SUN4I_REG_STA_ADDR); @@ -602,8 +601,12 @@ static int sun4i_can_err(struct net_device *dev, u8 is= rc, u8 status) break; } /* error occurred during transmission? */ - if ((ecc & SUN4I_STA_ERR_DIR) =3D=3D 0) + if ((ecc & SUN4I_STA_ERR_DIR) =3D=3D 0) { cf->data[2] |=3D CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } } } if (isrc & SUN4I_INT_ERR_PASSIVE) { --=20 2.43.0 From nobody Fri Nov 22 16:31:48 2024 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 EF90D1B2195 for ; Sat, 16 Nov 2024 18:03:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780202; cv=none; b=asAQgr7tsTAJNXuI1ieU4s5qedkPcLErMcecvxu8wPDcG/p5xv5wfqhXdGInDcxie839qAeFnwwunE6dj8LIuA7SyGwTZ86swtbD2nrMVjl/qI1Fng7pnyktMjs8Psdo6h+/f+J8GeBt5v15WhFKr6dgcqpqY8JCgJIRWncBm1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780202; c=relaxed/simple; bh=nrpSX80iZEgD1tyuub9lydq0DIRCuLzTN3EI9VOm5RQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BVFQKCCVtNcKzuuu/cWCIUSunz5TZQsdQY+GGj0h+j8TGWSoSPvs6KyZsZur7ttpyszWr3DhhqWBkfCvKBJ2ffGv7R0EBa1EEkkBM4j1gmApL3CvVh9HXWeYPVgLwrD+PJ17XntySYWA0Eamhby47ptN75J5NaeC3DQZH2KgJsc= 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=M/o9Or9q; arc=none smtp.client-ip=209.85.221.45 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="M/o9Or9q" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3821c81f165so872892f8f.3 for ; Sat, 16 Nov 2024 10:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780199; x=1732384999; 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=qzqc0qf43o4g73YzOl/3Mk2ZcRlSoSU0wYKvIRYgWeY=; b=M/o9Or9qDKQO6Miry9Q2iBYlM2DRWw4iWxL35GLPW+3oyJe99RrGwrcCcPLoO1XQtd 8SumikWdm0I/2B1NJc+EQODXwn9UC3hbItUiDFsnjNMrMKFPlKHbT+dVgNcsQg7ytnPF dgudLLpLriV8soznxDZ9UYOUlg43oMldjBi2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780199; x=1732384999; 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=qzqc0qf43o4g73YzOl/3Mk2ZcRlSoSU0wYKvIRYgWeY=; b=klqWaAfgEtUno2fWmahLFLGqJaqsFBu5y7NQM9QaK95kdhDQNe2BMDbEPlvEHY7w9r gljfSDtLS9657weRWDDbHQstsQkQPXm8mWaV9l6HV4aWknSFsvj0bY4AstYoUGYdYLjl bC4f24C40/D8Nl4C+dfXu7JD2jjUyFDlp1KqWf5HB21Ef5xsKC1fwn6ohnFLxybtBgV+ 5bcmLKohE/gOyXhj8Jsy9rI3oq2HsTH5uzMnBKp/wU2ARFKQW0OJEMEToHtSfNbAb60r yD7Pd3eNyk1yRvXDzd1aA+YPMmoIuWDvH7hogYbzgK20eIu91kc/8xeX/5Xt1RYHDzRL 4fcA== X-Gm-Message-State: AOJu0Yx8ZvR9j7z6Rk3XrlXSncLizwda5IGaLBd/nZHlylITXaSn6RZE 9FaPh9v25+QiCI1Y8MgSaJB8UsE2DPJb000AfVYz/Uoz84dXDAzplu2JV/NIPe9TGoUMpVDMV/E n X-Google-Smtp-Source: AGHT+IGkyP3qGN+tINbIZ4XNnyhPqXqEDpgjVb/byBCp6YrVMvdl+zOjNIxpY2yrRpZDbbYKagylow== X-Received: by 2002:a05:6000:4213:b0:37d:5042:c8de with SMTP id ffacd0b85a97d-38225a45297mr6503959f8f.22.1731780199189; Sat, 16 Nov 2024 10:03:19 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:18 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Sebastian Haas , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 6/7] can: ems_usb: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:35 +0100 Message-ID: <20241116180301.3935879-7-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 ems_usb_rx_err() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB i= nterface") Signed-off-by: Dario Binacchi --- drivers/net/can/usb/ems_usb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index 050c0b49938a..98a70a2fe189 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -361,7 +361,6 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct = ems_cpc_msg *msg) =20 /* bus error interrupt */ dev->can.can_stats.bus_error++; - stats->rx_errors++; =20 cf->can_id |=3D CAN_ERR_PROT | CAN_ERR_BUSERROR; =20 @@ -381,8 +380,12 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct= ems_cpc_msg *msg) } =20 /* Error occurred during transmission? */ - if ((ecc & SJA1000_ECC_DIR) =3D=3D 0) + if ((ecc & SJA1000_ECC_DIR) =3D=3D 0) { cf->data[2] |=3D CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } =20 if (dev->can.state =3D=3D CAN_STATE_ERROR_WARNING || dev->can.state =3D=3D CAN_STATE_ERROR_PASSIVE) { --=20 2.43.0 From nobody Fri Nov 22 16:31:48 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 72A9C1BC073 for ; Sat, 16 Nov 2024 18:03:22 +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=1731780204; cv=none; b=cl3nnqWbMuhnfYYKl13M288GOd7d9463ueI8cXVnzb8PrAQ2lzE+Q+zTaaG21JWK80v5ACsodAKqejd54LsVnAbuH+LAM7utozz3WBTw7Yfdz0FxS9gOKHOLQZGOUfOIYwitHzsvHQjqul8TIKy+31YkiQhPcXvPC4QWXaMvPaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731780204; c=relaxed/simple; bh=x191pU5csUjNf+5eLZ0Nmib7//JKYxHIAn9GWqpsWYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bM77XPn3oYktWMncpRc0OLXX1XJ4cTnuvEj46SnlkeaGS9XB6hQsOuzuN7vtPNcUxvYSDXrvv6jamVWWGN9NGZK4g6kQXBFu0v97aMLskQiUINadk33VAx1a2DwDdd/XWPmiC+dRzpgcZyxbIkS0KOcr1XtuHJsnvXKq0qw8Us8= 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=N+rTDxhl; 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="N+rTDxhl" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aa20c733e92so255637966b.0 for ; Sat, 16 Nov 2024 10:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1731780201; x=1732385001; 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=2C7d9rxCEuHbUF9PXUs12JGZsS1zAdEa4j4i3gKpHM4=; b=N+rTDxhlx1q4v15tAgZKM0KDGpBxYrwrgaFir8eweP96Afo3FpVUhddFdnqylXfM1w OLg7xk4w911T5x3IBX/9uUxizVUmvpjS7z9+0BjaIapAYh8EDgQ8ni2Fv8evL+qn6C61 SFvoCbarlWTAvvqzw1lgHmhnNgLWn2TY7jakQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780201; x=1732385001; 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=2C7d9rxCEuHbUF9PXUs12JGZsS1zAdEa4j4i3gKpHM4=; b=eq6mH7mrkXT6Bkjbw234LOtx+NTz7YUoLH7vzAPMHOAphboR5MdxZZ7dQFHxd0zJZ1 xKygBLqwTnTAXhNsHMiSIHIChWlHfeT6nUBqqMNOM5ycTCysKdvWGUyCaENBGEv1t78j nxdNPE7Qo6jSadC/xYEtdc+tT0XFh2FRExkBqXAIjbdGGMCp+2s9edzL5/160DCjQrZK Si9ZEEs8oVwpatVeJrHakksh9McQpbD/0kG5xWAoflX+T2wS75lsCtoK52GsJs29gPq9 MUI27k8fG0IHjfKZJmIssmLVQWuXdBGdW8vMQFfN/ja9r+FNJw7iUIRrr9OwIW+Nww8w nciQ== X-Gm-Message-State: AOJu0YwKUfdzaoj/04meVIB7KPeaxXmD2Xq/P++p7aHlsyqnOyKkkKdU hgtzhSPPCnfW4oH7EWDwNSlAbTGr0P3cbhSvntnxK2zLancNJ0JuXd0an1wMb4mG7ZjidTcnCtk 3 X-Google-Smtp-Source: AGHT+IHL/EwOUuvDKou6kklzDzL1Ir/aKMiYpZiijN1w+hmbgwaSQwKLBVtSh5AFMY3NeE8czlFetQ== X-Received: by 2002:a17:906:5ad2:b0:a9f:508:592a with SMTP id a640c23a62f3a-aa4a28a3bd6mr104955266b.46.1731780200732; Sat, 16 Nov 2024 10:03:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 10:03:20 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , "Ji-Ze Hong (Peter Hong)" , Marc Kleine-Budde , Paolo Abeni , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 7/7] can: f81604: fix {rx,tx}_errors statistics Date: Sat, 16 Nov 2024 19:02:36 +0100 Message-ID: <20241116180301.3935879-8-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 f81604_handle_can_bus_errors() function only incremented the receive error counter and never the transmit error counter, even if the ECC_DIR flag reported that an error had occurred during transmission. The patch increments the receive/transmit error counter based on the value of the ECC_DIR flag. Fixes: 88da17436973 ("can: usb: f81604: add Fintek F81604 support") Signed-off-by: Dario Binacchi --- drivers/net/can/usb/f81604.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c index bc0c8903fe77..8463e00517c9 100644 --- a/drivers/net/can/usb/f81604.c +++ b/drivers/net/can/usb/f81604.c @@ -526,7 +526,6 @@ static void f81604_handle_can_bus_errors(struct f81604_= port_priv *priv, netdev_dbg(netdev, "bus error interrupt\n"); =20 priv->can.can_stats.bus_error++; - stats->rx_errors++; =20 if (skb) { cf->can_id |=3D CAN_ERR_PROT | CAN_ERR_BUSERROR; @@ -550,8 +549,12 @@ static void f81604_handle_can_bus_errors(struct f81604= _port_priv *priv, cf->data[3] =3D data->ecc & F81604_SJA1000_ECC_SEG; =20 /* Error occurred during transmission? */ - if ((data->ecc & F81604_SJA1000_ECC_DIR) =3D=3D 0) + if ((data->ecc & F81604_SJA1000_ECC_DIR) =3D=3D 0) { cf->data[2] |=3D CAN_ERR_PROT_TX; + stats->tx_errors++; + } else { + stats->rx_errors++; + } } =20 set_bit(F81604_CLEAR_ECC, &priv->clear_flags); --=20 2.43.0