From patchwork Sat Nov 16 18:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3636 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1C45140FA3 for ; Sat, 16 Nov 2024 19:03:13 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5cf735604aesf1540034a12.0 for ; Sat, 16 Nov 2024 10:03:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1731780193; cv=pass; d=google.com; s=arc-20240605; b=b6OoAy1F4ANfd+WaEGVUHGbLw0u0uFOmrokG/Jm+QxQGxjPesoqVpGOkBad0duFjey N3Ha3hgFYz1m14imHVbBB6I6DRfg5iJKzfIk/ur5scWnpD73QXDw/ryZbs8088va8Da0 64XyOapdubkxE+sQpLwgdhMNTTz2ci5KQ6fl4r9IQ86F4AZ9KvvCaZElxJ3ROBdDdKRZ I82EtL7sdHFXzRnyA+8n681LMbGMp8NGOoS5qxNEQvjRXveGjHTcBSb4BddVgfzpa7zY SG3D/BtqTpJUBqeCL05nBLZv4kU6ICX5nS0hzo6UxtKO3LBR2VZHhV/xpUckfqugmY8i eXsQ== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=dc+f1SJ7198p4E0wz+dkc9acxmP3Wcxase1OKYtnABI=; fh=B3VPgiaRUBpcfNEfmRv1Sef/bU7Ic5RNuzxPvOmUYIs=; b=A0wh2XqnWds7E3Ab+m+NoUMSKZCKAeCKjOvxq6R/v3x5rq80dCMaAWwb/yv5Y8ptds tG4kcHjhxzyS5MMbZTFpMp8DOaLmxUvUo/R/5a+shzeSJqX1mznwGhDdF0oQqZOtBEna wxrhKFWaridTNOArPN18d9LD5oXqCe32lLlUfS+De4ua9rNMM2MmXUKV2YBplKsjulEj FDMjgwZ1glAMK9bc2XfI/6fIn38iBpDTP2E6/kPPkIDL+rA/M3iaAUZw/Q51xb+gfdYD ul/k97tZsTg6nl8GIDCvVCKGeE6evvkt0jWvx7CKACGg2aoxxClspFyFdzPRkkZbcIx0 3MsQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RCqShqNH; 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=1731780193; x=1732384993; 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:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=dc+f1SJ7198p4E0wz+dkc9acxmP3Wcxase1OKYtnABI=; b=GnAW2Jp7cXu/GnDxBob95YT7CBWPiQLoO0fxH4ObUCfZUn9haFP8K1BEZChTwRPgE9 xd4wcXxIxrxlmTqhPq+4Tgu9jFmVwa7idUTVKtAZrDUeT08G1eND8/W78mceHmnXqaxs ozEU7YCjcIzibmO+JZwFd/daN/7mYZNjWZ/oE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731780193; x=1732384993; 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 :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dc+f1SJ7198p4E0wz+dkc9acxmP3Wcxase1OKYtnABI=; b=g/nRJGPxPfeLq7s3Svo1cf3j2fzNbuxpG6fdFi9aWBtUk6dxDzO3zmhpsgsNoT2fn9 J0Mv/RG33BqwPB12KJaqhBPAviRlA0kWaWLEdYrWXiOgWuXJHcU0vvfrxjeqGWBnv8de 7E22/nFWFMayh0soAezvTE6c9rNc8hCD9dthMhm+fkku7ZtzVq34GGxSxfcKvpsZeLZ/ tAvjYrkGMn75Jb2rKBdCgDKCfH4MJ6Cy3IDAO8aT/0TG3KEFkh4odJ1sqsAr8KiofT4N qfATCuVCmbJMJ2unCH3fm7JSe6LQg7VCtojY9Lr2ZtxOcUFBGTvOqX70UKqiMEzJ9S/+ AjFw== X-Forwarded-Encrypted: i=2; AJvYcCVUzJHHHw7akmlZbsanOKdWCquF5damMd0CgkNEFKg1faf3RmtXJQpFbSmwqRRVK5IPsbu23STSR16eaR0N@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YyBcxJYZQUa4bS9yRvGPB6uWAk2CNzwNg1MK9QCG8NST9w6fC2c nxTYftchVHNg86OlNGCXY5+wyAzs8SMciHJ2HiNwCkN2d322EZ7oXtlfZZozKH1nRQ== X-Google-Smtp-Source: AGHT+IFb0/aB9/PnfVhoWajPhn1W8zpxXdvfuCMKVkK3Fj2BkEIZhcLKtFfy9TWCKjEMbga6/ti8PQ== X-Received: by 2002:a05:6402:234d:b0:5cf:ac34:380a with SMTP id 4fb4d7f45d1cf-5cfac34390amr1126488a12.29.1731780192391; Sat, 16 Nov 2024 10:03:12 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:d513:0:b0:5cf:9005:8b8 with SMTP id 4fb4d7f45d1cf-5cf900509d9ls32917a12.1.-pod-prod-03-eu; Sat, 16 Nov 2024 10:03:10 -0800 (PST) X-Received: by 2002:a17:906:da84:b0:a9a:14fc:9868 with SMTP id a640c23a62f3a-aa4833ec172mr726855466b.4.1731780190592; Sat, 16 Nov 2024 10:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731780190; cv=none; d=google.com; s=arc-20240605; b=QieXoBbnXypDOn7sUwjGMUbAi+5lhsS29F1mUwQUVFCo1WtwrZWk4wz3taPm83bjnh /1UlAf+WuGFt2GVNvx3hixnFkvTA2nDrMUjE7AdI3cjllEgFKf2wQYjQJCrvF6++G9Lo fKIzRele81++UVO5P1275EW2C+OlfoOH+83Q3bi7E5i5qcpQh7oilZ9/qXsfEapywVkO OOxQhuhSwaz3bSx56dBB/O8ywJ2h1AneZ5+5CUwniPOFUyCJLvby/zaoLS/WagJ+cA/s nATNe3oV70WfQrZ9rfPeWheLZmUvCw9OVdVnPKaX84iiIInal2focShdkEEIEo3iQFPU WLNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=MKS1He5MRcB9KzHlUh7sCjUXRUA/E/nSRL0TriRLZjg=; fh=9BOm0FE2iq547O5K8zQAxVLs9TFErhB6P11DltiAR34=; b=SgRmKV8Mc+XtWx7v6d9FakI4crj8Jb0TcuTiR7i/xOAwftH2I0LqzebAxKymUAWtnP gAYgsW4Svk7CFWuAohEDVfRco2KxXcn/NoYOq6wAeUb7u6nA4dpFCq3aNdoQYezxWpCV BvbY1mNEfzidry2VB37mH+Kq+NEv5uBbPT3GxZhpaQ4VAVJru7520UGYAVBslmXm95lm vp5TmN1Uo9eiCvCpj5KOMIjuX71ihDox/2viCVE9wKXiQ3QETwZf9jM/O59mjonjQnaB 4TfDi6E1zWtNJwB9X6NNlbE0l61CNzcwAWw8m+9z4QmHZ4bUV0HpvBeDSU+VIjfKVKJm hwkA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RCqShqNH; 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 a640c23a62f3a-aa20dfeaf70sor245012866b.14.2024.11.16.10.03.10 for (Google Transport Security); Sat, 16 Nov 2024 10:03:10 -0800 (PST) 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-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_Kleine-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> 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=RCqShqNH; 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 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_canfd/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; priv->can.can_stats.bus_error++; - stats->rx_errors++; /* Propagate the error condition to the CAN stack. */ skb = 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 |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) { cf->data[2] |= CAN_ERR_PROT_OVERLOAD; + stats->rx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) { cf->data[3] = CAN_ERR_PROT_LOC_ACK; + stats->tx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_BIT0; + stats->tx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_BIT1; + stats->tx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_STUFF; + stats->rx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) { cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + stats->rx_errors++; + } - if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) + if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) { cf->data[2] |= CAN_ERR_PROT_FORM; + stats->rx_errors++; + } /* 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);