From patchwork Tue Oct 29 08:44:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3603 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6E0FD3F360 for ; Tue, 29 Oct 2024 09:46:27 +0100 (CET) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c9452d6321sf3781097a12.3 for ; Tue, 29 Oct 2024 01:46:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730191587; cv=pass; d=google.com; s=arc-20240605; b=GzOnTlaNR5tkvltg36yzu/XwU9RUz+v5GcbanVNWFST5FIkn9IdqoKZ48oo4A1Ku+6 BWPcCrbgySyiZpwFwlKVLIfVTnV/hEErqtbSdyFWV7dXAqvWCV3/x5puEOxy0b52yoy4 yZCsd1itR7jXpwtR1E2a8g1nJys59TJYObjbjjHWqfhMIdTyLr/nXwKuU+MUbnqEUztp B0P/YN1lHlzLtKPbHECqE7OMVfXH8Cg6LoYqLAl8b8UIuOygb8pH1uVTpgU0PkftA0PZ lKu7fRkY/GXtGEaEI60x0UE8XHlTMc7Hg2D6dUapk0MKDgEaOAzSQEiB+6ObvOjAzCz8 QdWw== 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=HQsCXBIlvezkKhqkM9RWVaVb2iiSTABHmcD4r4ilE+0=; fh=tPc/hxcTAtjSQUikGbELCbvtErE7V14C0AMkrIAFbXU=; b=f1U8njaxp9R609nc50y9pkmNToIUK/xlt7JeVFguOrHFa7Ebp3CJ90RvrDfkh/oe+l ZML5cRJncW/isX5x6XCebBzQbl3fXZFT+hT892ZSnCU3ye32ysRi7ZT7I1pDOoJyQYal Ood7lwdChdUUeuf0Ty2qKDuLSpJMhcElzdkq9t9qKo2tbh2DhIHaGkSLmSo60xMWfGMI Chcq/rEKuK337Wd0wqzjgKEITZiuAXSxdL7wOfQH9eikBNgf9MwHxhFT5lhnSWfdE2h8 p8DP5GfBXwxdugD8EWKbuVZIob4I0Gql6HGI3wzPiaAVun51hhlozr2kRkfLu74rVHpB anRA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aVgLC8MH; 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=1730191587; x=1730796387; 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=HQsCXBIlvezkKhqkM9RWVaVb2iiSTABHmcD4r4ilE+0=; b=Naq5v5m3Zfi7AFsy+TWmSaWpF0qEA+P1ZOWoC6A57HYDZLCBqso1u85SlXmSQTSzmh oqMvMBbajVe1vXuhE8EHFHTM9xeoNqoGIsfesoYmbOv35VPcekyR/wYn8CQz9LeYoOt4 74+aYdK4RuFruJ5mzPBDit4thEZY0AZ7xaNsI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730191587; x=1730796387; 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=HQsCXBIlvezkKhqkM9RWVaVb2iiSTABHmcD4r4ilE+0=; b=r8r2ksYVRAoutDWmD/ZnATPGw7LRnlaBkk1ENrxhKvPLs0u6+wMh7+HVG+eEE0TLzS FH/y4qgBsEE1WU7gSjJmdgUyQ01YdIE+UtWLJjXsnl+tSzpqBcljLbCM/BzpxpwYhIuK s35/pqeISjz7StkDej8RH1fwk6r8F0K2ZUz0LI17uXjPvOTXJp/Urw/s5vjSPYmprMsW tPobKTtDFTnJJ1wUfrKlHeWcVWOy2M4pfR/2QlMH9O3wkwZF2viAmZfxWOZeN49EAJhS nBOIVQID28NhjqDrxl7ILiKSl0Zm6u4/OO24D8HRQj6pFCJ3Gb8SHwcErqqNPN+Tle9/ nkew== X-Forwarded-Encrypted: i=2; AJvYcCWmb7vTKueTTv/g9RwRUhttprrkbKtMakjpZHwYSnFKXO2JubwNpuqI1ydDNzGk84ggZH4tN4Ry+Wh19h1q@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxrDkkOA7gcwkVZaLMjA5IpMgj3bk/ZZHXgQy4vlaDanSClsgPb 6Brm6RqQZmP+YDg1xoiv84coNr5TOLHzSaE8jq6fJTsTGYtGWBp4eoY0EoaeaGEvgA== X-Google-Smtp-Source: AGHT+IG+vJYF3519c+4+TOsNoz7l6nqDYKAOuO1FIWjwy2J6vN4HpL7Gw4+eUevy8T5Ee4anTfy74Q== X-Received: by 2002:a05:6402:268a:b0:5c3:cd88:a0a with SMTP id 4fb4d7f45d1cf-5cbbf8c3928mr8973321a12.18.1730191586819; Tue, 29 Oct 2024 01:46:26 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:1645:b0:5cb:dcf8:ff45 with SMTP id 4fb4d7f45d1cf-5cbdcf900c8ls163831a12.1.-pod-prod-04-eu; Tue, 29 Oct 2024 01:46:24 -0700 (PDT) X-Received: by 2002:a17:907:97c6:b0:a9a:4158:494a with SMTP id a640c23a62f3a-a9de615bc4emr971705166b.41.1730191584104; Tue, 29 Oct 2024 01:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730191584; cv=none; d=google.com; s=arc-20240605; b=Uboi6EYK20DUKD2iWi3cYzX3B0I2IdFCPCqasObsMhwcao1cRHi4OCDTPwCZxMYf5H KsceFE6FRQWPc/DGb3BZ8FZK1xbAuRHdf9Dk2DNHB+W5XFr6nPqWY3400KdQKfJyTx8M 87/o0FkNb3IvJWTVniWNSUPJBj1VY3ZuzmPKdSVCSjJuVBwAc7RPM3lwtfP/gtbR8qEJ WV2hEJicsqvRHLfikTOyQ9W6P8Aa+QmlgQC9dcO/4NywT3db8rWaffO3YOBhzOm/cknM R56nXJa7h69viIBgjx17wmwBrOZugJV2oJybjL9iDMyD8jxTfndT8Im36/vr8xGxxZJf 48RA== 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=zDcquMlQbBV3XN4Io8qW6xdqDAgSIub1vLoIuhz6Z10=; fh=ToPqDL27+92lHdmiCPBOvKBiGHlqSsm18pRt+HBl4X4=; b=DVVpilN3VhmppBXCgHvRH7b9aVzdjLejujgmgQn8JInbjn5a5e26hqMy8oQFh40/Wj 8bQ9BDF4kIUFlpQIILmgUqbtUny759fGIeGpKfLk9TANo0VCtfGsg1Z0QmdcrqNqYAXd Krc3yzrBPNQaqiVeX45IdGAcvfJectrhHoTB1otGZ5LEMISfTDo5K80/wPc7mb4K7G5s 9mqZqwcP0CbPHrH70+s9cvydbxuezLyZQkt6lMCFgDafAIFTg9m5gc5cxwGDkNSdPXQ3 Xy2s8xF8MVnAeHEso9inwq6bnFmRc0yRkrNWY2PflSGnSxd2fh+wT+9fTOnycEuoTird c9yQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=aVgLC8MH; 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-a9b1dec772csor353434366b.4.2024.10.29.01.46.24 for (Google Transport Security); Tue, 29 Oct 2024 01:46:24 -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-Received: by 2002:a17:906:c10d:b0:a9a:37fe:e7d0 with SMTP id a640c23a62f3a-a9de6199186mr1046662666b.64.1730191583525; Tue, 29 Oct 2024 01:46:23 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-68-117.business.telecomitalia.it. [79.40.68.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 01:46:23 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Gal Pressman , Jakub Kicinski , Kory Maincent , Marc Kleine-Budde , Paolo Abeni , Sabrina Dubroca , Shannon Nelson , Simon Horman , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v2 1/6] can: dev: add generic function can_update_bus_error_stats() Date: Tue, 29 Oct 2024 09:44:45 +0100 Message-ID: <20241029084525.2858224-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com> References: <20241029084525.2858224-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=aVgLC8MH; 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 function aims to generalize the statistics update by centralizing the related code, thus avoiding code duplication. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/dev/dev.c | 30 ++++++++++++++++++++++++++++++ include/linux/can/dev.h | 1 + 2 files changed, 31 insertions(+) diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c index 6792c14fd7eb..0a3b1aad405b 100644 --- a/drivers/net/can/dev/dev.c +++ b/drivers/net/can/dev/dev.c @@ -16,6 +16,36 @@ #include #include +void can_update_bus_error_stats(struct net_device *dev, struct can_frame *cf) +{ + struct can_priv *priv = netdev_priv(dev); + bool rx_errors = false, tx_errors = false; + + if (!cf || !(cf->can_id & (CAN_ERR_PROT | CAN_ERR_BUSERROR))) + return; + + priv = netdev_priv(dev); + priv->can_stats.bus_error++; + + if ((cf->can_id & CAN_ERR_ACK) && cf->data[3] == CAN_ERR_PROT_LOC_ACK) + tx_errors = true; + else if (cf->data[2] & (CAN_ERR_PROT_BIT1 | CAN_ERR_PROT_BIT0)) + tx_errors = true; + + if (cf->data[2] & (CAN_ERR_PROT_FORM | CAN_ERR_PROT_STUFF)) + rx_errors = true; + else if ((cf->data[2] & CAN_ERR_PROT_BIT) && + (cf->data[3] == CAN_ERR_PROT_LOC_CRC_SEQ)) + rx_errors = true; + + if (rx_errors) + dev->stats.rx_errors++; + + if (tx_errors) + dev->stats.tx_errors++; +} +EXPORT_SYMBOL_GPL(can_update_bus_error_stats); + static void can_update_state_error_stats(struct net_device *dev, enum can_state new_state) { diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 23492213ea35..0977656b366d 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -201,6 +201,7 @@ void can_state_get_by_berr_counter(const struct net_device *dev, enum can_state *rx_state); void can_change_state(struct net_device *dev, struct can_frame *cf, enum can_state tx_state, enum can_state rx_state); +void can_update_bus_error_stats(struct net_device *dev, struct can_frame *cf); #ifdef CONFIG_OF void of_can_transceiver(struct net_device *dev); From patchwork Tue Oct 29 08:44:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3604 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9DEBF3F360 for ; Tue, 29 Oct 2024 09:46:47 +0100 (CET) Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-539e0fa6f3dsf3749132e87.1 for ; Tue, 29 Oct 2024 01:46:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730191607; cv=pass; d=google.com; s=arc-20240605; b=bB8JQdtz1cT4yfeAL5L6DDAZuk/yzyLnXp43SNql5yI85x32YfaZCWSJwBBIIXPYtk 5HBpoR/4NfKX6De9mLabILnGzwbi4lBgqRN2LbJeIyxcbPrJghRbKLmXXVMEipUaGUoV mesHfAgT6N+UO0rm0h4JwWi5zTxG2djA7sM6cD9zb1oYkOVyYBr+/0qkefXhw+DGNUit XtZkGZ6FtvYHg5LY3vxtp6L28ALTBtDT5d1Ga5ERzKk8W3zrET/OPnPQlPhwHGIet+MC e1qC7PYqO7vBjKNmnXAB9xzFm7ih32wv2JtSC8TjQrYvcbLI+E6AV+h1G/Z58PAcYxqM DpFA== 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=Qpl0mGtgJDii3xR5XaMhpYCW2lMoVPHTeu0luako5MU=; fh=l0QXdq+YW9fLZtQVSYBJzbWPIdKkNsXpxRRbWlVS+eU=; b=CSaWfoH9u8nOQJjSr7SVa8Oc+l5O3U9bOHhf0DWpkoUyvIlRXNzJr7kfNedyuM9PoH JwU0tXlAdoBCPZrB+aAehPJP430gzVFZu+LzxRyhjcONPi97YPcMaDVK/tVtxb1u0xEc h0yFZfpC2BDUyYoR+zZN3vP0d/4CRsywE2Var34m5ugj+vPJNwIOvfhGM+2uzfbivdMo KkcKRw3hWJrGt618WG503Kh3M+lpmQttPapNhPUDIeT/yaOYGcsKMuwYCWSA7mQa/k0I nEvnavwDQH2Yor01esYA4ezVez1KU69Vw3Po42osxKBsuc5mYf0cwdzUi5jLZIP3bi7A QUHw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mPo5Zzym; 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=1730191607; x=1730796407; 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=Qpl0mGtgJDii3xR5XaMhpYCW2lMoVPHTeu0luako5MU=; b=argENxYPhrRTA3ANDmR53Jc2NUM2y1C4LuBzPCzhx9Hf1zaw/GtY/sLjNzOUaTcExM byGYnCWm0YygxQvJ/Co2xuZ5DHS93x7oxwft02lw6TDKO81027FrW0zmWCcfoJy4XfyT 4dU2FOSNyPQ46jzpidAUqK42rW2uhs0bwKAmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730191607; x=1730796407; 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=Qpl0mGtgJDii3xR5XaMhpYCW2lMoVPHTeu0luako5MU=; b=TTpZFkF5GLNBTPdShCdz4OZ2U6z+pPQ72ZkupYM4aUB+oj3NKm0QM1bTDRExLPejke JG0gbYWiMUimf+xlI8NlMIN1TgZLKJS6uGvSWhacgxz5dUzFub+WHLJIHEfw8tUr1Bur wksxdpghw0gBGY7vCWEO1y9GHOq+8Qyly1EySRyLLAZhS3jCnGPJongccHSMQKdh8478 Puv9LEp5GkHuVI2WvKXStZyFkvwBaGHLUN7vi0gahwZK1MajpuHwOj4ot05m41VcyC3p etqOz4xfYig0fS/vvMh9qVmMQ65nnfe/E8M6CslL/E0oHL6KRvMip1oLFvGt/5FacG7Z KeaQ== X-Forwarded-Encrypted: i=2; AJvYcCUPxgHmZJNOSvTt0OD7+/vcQ0BMlD9fkfYs4keyPq2Rzkqpf7R5PF/H1NShyHEUBur98c9xvzguD/0PYEPu@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzeNzebAKuwIMcs+u6iHYWDnDRhMBk9d0JB66OB6gPK4gR4VyrH DljEj3dx5RwoOiAvT5gnR1w/6ERZZbJKa9i9sPsFPcde6QPcyePQH3hystpzOtvFAQ== X-Google-Smtp-Source: AGHT+IFYVe/cTMBiP9qAY72oAh6f8GSQ6EtTMCfCi2nxn/MiVwryzoKJ9HQCIqFtXjczEaI65jdd7Q== X-Received: by 2002:a05:6512:31d3:b0:539:8fbd:5218 with SMTP id 2adb3069b0e04-53b34a3515fmr9349196e87.56.1730191606733; Tue, 29 Oct 2024 01:46:46 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:1111:b0:53a:99:8b36 with SMTP id 2adb3069b0e04-53b2147b7a5ls862515e87.2.-pod-prod-05-eu; Tue, 29 Oct 2024 01:46:45 -0700 (PDT) X-Received: by 2002:a05:6512:1149:b0:53a:64:6818 with SMTP id 2adb3069b0e04-53b3491e2e8mr9249423e87.47.1730191605016; Tue, 29 Oct 2024 01:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730191605; cv=none; d=google.com; s=arc-20240605; b=Aasm2BHAik6DY+0Q2SlJo3lqIj43pnUjQAs7z1qKSZrNB7bSuXM+ELuyfyJhUrvKhh PXM08+4DnLvWNkyX6L5ROccxZH+Ss4IIGL5tM8/++IdR59DFV9DNROUkmZVfNrdsehdp j+OUYNRae3JaZdKfDnUdOJQ10SwvgpQnliqsQ0sE1YvRIHOWX3YSLrUKSktDXm3LE+ZW NUpoytCALvF5hbWTxaELNQPT2O6PySNjMb7zTZz52xGeECwMXUszpN72uXB+74LyIkUG CRkOvdUn9djijK/aXtv4GTFPm/0sJMesDBhyoxdmsmZzT4Np3uCCnKsqjAPxWYsHo8px 4hnQ== 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=rwyMMsHa5HEUfO6bt7mbb/5lMim+t5T1aF2qtApwxpM=; fh=dHQIR6tcWkOVGkCzk8Kn2gtw7JyT+sGePYbjyt/VztE=; b=BA7H4VPlXuj/cFxCSF2q+LGWvDPZQR0PE/xAnrV/9g5LG8OVSu5uGVZwaCzURghYde E3nHqnDMRVP258462S5BpVptJeoFWbCPxTcC4TgxT2u3iZLndPyF3kjg1VLMkePTyBhL A2Mq2cK/LD3FfPxy2KhsjsTabdo7mJemjTw52Kzy4wPHa1+i+YnkyC0hsvsa+5pHmCVH TwrUqKc3PkDBHjKIWjbgs5uRLi1bhi6cjHQN23my6FIExveDmBW60Um1fge9SW9pbzAC lDGwLrzx+ucmWD4Nh1UAOXcC7S9GcT7GiigtmrI8einXEUJ63nZ5lfYb+dPlIn1MZV95 OrHg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mPo5Zzym; 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 2adb3069b0e04-53b2df6ee0asor3277006e87.0.2024.10.29.01.46.44 for (Google Transport Security); Tue, 29 Oct 2024 01:46:44 -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-Received: by 2002:a05:6512:1252:b0:536:a4f1:d214 with SMTP id 2adb3069b0e04-53b348cc55cmr9003984e87.19.1730191604452; Tue, 29 Oct 2024 01:46:44 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-68-117.business.telecomitalia.it. [79.40.68.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 01:46:44 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Haibo Chen , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Rob Herring , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v2 2/6] can: flexcan: use can_update_bus_error_stats() Date: Tue, 29 Oct 2024 09:44:46 +0100 Message-ID: <20241029084525.2858224-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com> References: <20241029084525.2858224-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=mPo5Zzym; 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 patch delegates the statistics update in case of bus error to the can_update_bus_error_stats(). Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/flexcan/flexcan-core.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index ac1a860986df..790b8e162d73 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -819,7 +819,6 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) struct flexcan_regs __iomem *regs = priv->regs; struct sk_buff *skb; struct can_frame *cf; - bool rx_errors = false, tx_errors = false; u32 timestamp; int err; @@ -834,41 +833,31 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) if (reg_esr & FLEXCAN_ESR_BIT1_ERR) { netdev_dbg(dev, "BIT1_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_BIT1; - tx_errors = true; } if (reg_esr & FLEXCAN_ESR_BIT0_ERR) { netdev_dbg(dev, "BIT0_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_BIT0; - tx_errors = true; } if (reg_esr & FLEXCAN_ESR_ACK_ERR) { netdev_dbg(dev, "ACK_ERR irq\n"); cf->can_id |= CAN_ERR_ACK; cf->data[3] = CAN_ERR_PROT_LOC_ACK; - tx_errors = true; } if (reg_esr & FLEXCAN_ESR_CRC_ERR) { netdev_dbg(dev, "CRC_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_BIT; cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; - rx_errors = true; } if (reg_esr & FLEXCAN_ESR_FRM_ERR) { netdev_dbg(dev, "FRM_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_FORM; - rx_errors = true; } if (reg_esr & FLEXCAN_ESR_STF_ERR) { netdev_dbg(dev, "STF_ERR irq\n"); cf->data[2] |= CAN_ERR_PROT_STUFF; - rx_errors = true; } - priv->can.can_stats.bus_error++; - if (rx_errors) - dev->stats.rx_errors++; - if (tx_errors) - dev->stats.tx_errors++; + can_update_bus_error_stats(dev, cf); err = can_rx_offload_queue_timestamp(&priv->offload, skb, timestamp); if (err) From patchwork Tue Oct 29 08:44:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3605 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 779883F360 for ; Tue, 29 Oct 2024 09:46:59 +0100 (CET) Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c938ae4152sf6584098a12.1 for ; Tue, 29 Oct 2024 01:46:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730191619; cv=pass; d=google.com; s=arc-20240605; b=lk3fVPtaHQz4jLSitkf08inwxrjbbPIl2r2wf3J2860RAw3lZZVM3QF/AZ+lfBVHtG I68zqBuoF24BWl4upYrlcfWrReR/mNwxol9aoyWdzF8mn75I3Al6x9x4AdGmQwgLSlOB z9tTY7O2EXR/wRpyI1lvwzz8CivdsGnlKiHbNXlaLEDHYk9Hjte/8tk+xOWV1/F/OIPc B64Bk/dI/urE5oRu8/pxYJ9cEnaUDjQxswZ58DzyUy2zIsk8RoCRUZZ3WQqSqPBd79kA EOzpygLIO6+vGC3/afiQCSEpx8zp/g8nglp3tjxxSFGb7YEiS/k2jbi68vmcdqqlUuZ+ Gkxg== 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=C/TJUlXOJbY6IHwLqAROP3mVTyTGnaN79qm3nxTj4A0=; fh=DHJWMnaJsuT7R+ifGUr+75DT5GO90G4xQvcSj0TMb+E=; b=HGxX0fgvnEll0gxLotF1PA/kRU7rRaw4mA0pe7Lk/lu+S/lRQzHZ75RESbO4sUaY9d BodSZlqasSBDXb1AaENTJN1NYanZDtN9m7F/8E/qTerCjBJoTyCAXAfG8Vg4H7X1ekij hvSkDJCeryRRrv+Y71msznkFtrnbw2+0vCU3QWAa7PprvA0kr8Mr7rUQzp/fpCQ863DK llV0IO5qVDmzzVS1RIYD5v5bKNhQZRvtJzIsQGETdlMcui6X+6d6xXEd+Y6Uz8K2d0dV ZKA2ux/pPEAPrAb2cJUUe9tz9x9/dwhoFTAHyG539phMdx20xPQKEHrCwKG0Kr4XsQ7s /siQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JnV+Q3yh; 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=1730191619; x=1730796419; 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=C/TJUlXOJbY6IHwLqAROP3mVTyTGnaN79qm3nxTj4A0=; b=UuU1z8CjEpBxl2q8vUuSXAs4/s/K46iQNfmKtuV74iS+wA+JE/kWBqv2vPKBHeE9j8 8WR7rjZJExFw5SD+rU7DeHIKgJAui3z3K7Yvo80HlXmbKfGyB3oxXPv4HiNP61HwpALG SxhHDNUn8HyBqKbc7UUIItO8e6vm3N/zVe8fk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730191619; x=1730796419; 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=C/TJUlXOJbY6IHwLqAROP3mVTyTGnaN79qm3nxTj4A0=; b=Zm48ZyIhHVBHDn/Pf4L5GBJq8cXVSptwVZiCd4AY3u1HExM4nF5Dq6ywjSLbP/qJ6G ZDkfp/xF1TGFqMfrks+vVCqLI2Ja5anVa8XfBhnKpYjzn18VJoWimOe5IuRHDVoqBT+3 NEin20v0joJdmR6yLqddzBst9Hf2YTRnMAT/NcwgX8zA5GWS8aS2+FkQe6r+hJ9pWHxJ 6EK1jkxql2X0BUITvmtStZIJNkdCPTRJ2scYb9ljDupAqJIiIDUOxRQkNxnzlS6vH802 MKTt1irZqvfybtKKN3w8nuBe0Iqg6nrxmU5yBG46nqYoo+KRvCaEvmsM6iBgO7syqRmu bTGA== X-Forwarded-Encrypted: i=2; AJvYcCV5pfn8MvhmJXrwmBCnCGzQPq4QCzUoUuIo8xT5cLslr6eellZVieNqec75DMaDdvpkR0JY9AJ/7I9FjGEw@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yy+od9ge775CKhlWqgVPLPg5qWy210ZWIQrElpwer54uF4BF69d cNjOE7OFLeyazuKoAodML2VDXFvbTpCLcU31p2HXMSIQKwxcyo2bomZe7Yz/WByInw== X-Google-Smtp-Source: AGHT+IGW2L1GyMwwrL5/Fd1IcGqy9EjiFsTM86KwE2qqZS9C9we3pvS9Q10xpVAKwnGgSZDmoNbYCQ== X-Received: by 2002:a05:6402:520f:b0:5c8:a2b8:cab3 with SMTP id 4fb4d7f45d1cf-5cd28fffc2dmr1168287a12.4.1730191619062; Tue, 29 Oct 2024 01:46:59 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:549:b0:5cb:b66f:8fd with SMTP id 4fb4d7f45d1cf-5cbb66f0b48ls75263a12.1.-pod-prod-00-eu; Tue, 29 Oct 2024 01:46:57 -0700 (PDT) X-Received: by 2002:a17:907:2dab:b0:a9a:7b3d:705 with SMTP id a640c23a62f3a-a9e2b01618bmr111167166b.30.1730191617616; Tue, 29 Oct 2024 01:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730191617; cv=none; d=google.com; s=arc-20240605; b=Qoi9XARc6dsK6I5fDmBftqeLoeFDx36M6mVrU285BdZEtZEch/ciY+UWH+R2lBevHq XDIK3ZbCDyM1zkbxmrPxEjCG9Kom5Prnd5OxrmC2HSCQlXKMJGW5DbZ9S4ZuRZ2yWh9z Nq/dW3PVDGCF5SsDty01FO/Sl1NptJPFXzVlLoEtbrbbI1y+YWGGLK30U3GDuhLcQktq 4g/XjhLfqRK+UR5WrilI+xtfG7e6ueKapqYnOdflVVkCFoZ5roC5YT4o+bBCmTgNGeZF CqFJbxJaKUSsGR+kHc7X3W/IPxxWXViyKxTTcJXDEX9ictiacvCKdvnhDB7utrsNlgZ6 I2yg== 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=qZlCPcUtK7nW0/9iHLjxsFqERMJTARHO2kYU3JNPHEY=; fh=ljoFiwPup6gC9YG4NMWOEWNdgUd1CKjWIIwpUvYy39c=; b=gSuIatyBiRZZuu41E896TgNl0L6QZlcpYbIotdCIMOyMCQIyA7QJkwTHqOqtKePqT6 DQ+b1nMT1WsQj1ojZEnMaF+ULj6JRKzPzh/HMbFh+v/4Oi4bf41TswqG1lDFCUGhMSVw 7bfJBbjS4wzPCoqJ8mJr3DOOk2fJ62xr1yX7SY/6Te0iB8JkL4dQtknI6M3tUK8PWgdi a6geCAbzULEkweeoV7mApZepGgqlqbzdDsoZdHKterrZWC5CIGnmuxFvschsteSn9ebJ LO1CnsZn/EhwC46mBQfj5BQPXZ9XKZ05gSDsrV2OfFQPlomdPedl4rBS9/5Ogf/pjjAV TzVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=JnV+Q3yh; 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-a9afaa7a791sor406366966b.9.2024.10.29.01.46.57 for (Google Transport Security); Tue, 29 Oct 2024 01:46:57 -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-Received: by 2002:a17:907:9814:b0:a9a:ca:4436 with SMTP id a640c23a62f3a-a9e2ad15f3fmr140074766b.13.1730191617226; Tue, 29 Oct 2024 01:46:57 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-68-117.business.telecomitalia.it. [79.40.68.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 01:46:56 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH v2 3/6] can: dev: add helpers to setup an error frame Date: Tue, 29 Oct 2024 09:44:47 +0100 Message-ID: <20241029084525.2858224-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com> References: <20241029084525.2858224-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=JnV+Q3yh; 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: , These helpers can prevent errors and code duplication when setting up a CAN error frame. Signed-off-by: Dario Binacchi --- Changes in v2: - Replace macros with static inline functions - Update the commit message include/linux/can/dev.h | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 0977656b366d..1b09d30dae32 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -168,6 +168,52 @@ static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *s return can_dropped_invalid_skb(dev, skb); } +static inline void can_frame_error_init(struct can_frame *cf) +{ + if (cf) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; +} + +static inline void can_frame_set_err_bit0(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_BIT0; +} + +static inline void can_frame_set_err_bit1(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_BIT1; +} + +static inline void can_frame_set_err_ack(struct can_frame *cf) +{ + if (cf) { + cf->can_id |= CAN_ERR_ACK; + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + } +} + +static inline void can_frame_set_err_crc(struct can_frame *cf) +{ + if (cf) { + cf->data[2] |= CAN_ERR_PROT_BIT; + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + } +} + +static inline void can_frame_set_err_form(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_FORM; +} + +static inline void can_frame_set_err_stuff(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_STUFF; +} + void can_setup(struct net_device *dev); struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, From patchwork Tue Oct 29 08:44:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3606 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C1F043F360 for ; Tue, 29 Oct 2024 09:47:30 +0100 (CET) Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a9e0574854dsf148334066b.2 for ; Tue, 29 Oct 2024 01:47:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730191650; cv=pass; d=google.com; s=arc-20240605; b=YlEmX3Ff2q4IP2so9FI3fEExO89yPICyeZzWS6/xWv4Lxxh3/JYjtolfNxfJan5jBY ktXuuVuxuzCicaC6A6NflHDdSDXuYHZA2YAqVCKdHQPOFVbazdsciqQcacG2kNbPIJJC yh8Um0AX4qEmPJhgwaNO35EOJqaMmUXGKobLAW7jGdEW9d+8x2eNm4e31dIGB4+W7SPU kFf4sclJkzLXse9TSXciWjFFyAjsPlAa/92pxg6tnHZUUM2F6jHLdDb+wRxxeMoktt/b 0XzzVxj7Xa8WpCEvIoSsNxXN6SvYXgk4sErzdbSb11CM7g30SxH2FcnmtypsUZheyEKq VN3Q== 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=gg+MJ+TSXe+D38k4ka9t8hLRXdWlGTxIx1sYbRyRMV8=; fh=kAcwznDRUVf6+LptFR3mlCYT+/f9OsGTubZEGKRcruw=; b=EwnR+w3DoRPwANiflbrozAI7IUDBfSVnnTEWGNQxYzUsfNhCg82IaiSXV5a4ot5nQo 3dRq6JWCkV92k4zGcwlK7EfXkeN9Vf4hOXCOr3zS6XYLdKOAkmWChMoKTJ4E5JlFt/qZ QBuJ4VHWf5j/MuIW/EXCZ8ynR/3DBEYCy1rnUTKE0hv5/w3wiln65nsjELzVZXDMBYJL rHveAOdVG2rAr9y/9NQNO2ushp+cbejVDJcxLEYDhiqH++LPpNdwXl8I+iRqReKRHMJ6 eqjO9Lo7XI3JgPRpUmTJ5wuLd/GQeNm7wQRKzU+Z9m0UmbMEkNXCJgq/zTf327yFkh1g 7pXQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T4fI6TK4; 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=1730191650; x=1730796450; 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=gg+MJ+TSXe+D38k4ka9t8hLRXdWlGTxIx1sYbRyRMV8=; b=K7slLe6oeke2A2j/qrsWbafHZcQmMEjtj5sKoHzSlKRtFbhJz2MHzbYjEV3cSL6Z6w Tcyz+IpifDzABUYGsTJYZ5mNtEq8Y11n9JBLUUtTSBRWnw9tBT9sSaHfI/B8JZ2sgCD7 bJ6mWSZUiDL3nEiox9WxJEa8jjiaYJmVl/Pwg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730191650; x=1730796450; 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=gg+MJ+TSXe+D38k4ka9t8hLRXdWlGTxIx1sYbRyRMV8=; b=GE7KJ4Sj5ll9N2/UpmTz+10wQbXlFvMw77QBhdXtrkrZNwLXrbOSmgBjEKxvITf/TB zAnVI63RG9hpxRTUMy4KV5yp/D7famDh1yfGDxPlOd2TZOv6oQWeLHiI2WcM6+A/W09Q yCMIz8EGhYwh6Ih6sN9pcJ1k0kuINkm/ynM7fyCE2PIAdv6JKzZpVC2+c68D3Ah/DUHN dCRWf/ONn94KHB92PUWP+66jJpfYmUCy1Tx+0ERE+dNa4QtuDt8sfU7YF0P1bso95tQ1 NsTW0LxHc/L69ITjYCV01UM30q81xWvfG7DHiH0aT4QZIHgRGZ0vypU7aRq9rErhW2Vs KWKw== X-Forwarded-Encrypted: i=2; AJvYcCUQK7gJHZj2NgGTrG+Uig/tmB4a7qRnbPHzoLGvbMA/oL/nTjRYyixnUBmUxD1ld7cZgHI/NGRe9wZAh+2I@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxXwylhFz+P1P8dGAOLP1Kar3uWTj40MMulCZjdbi9S7gRMLkh+ z8/ddi4XE+EnaSqVwVSvtyORWOnfsNVFv1ldfZxKdXI8Cy2hZ10B6mmGmCX3R3kXqA== X-Google-Smtp-Source: AGHT+IE4+iEmRrrxmEqdbiLnxyzQLeWZT3zbKmkra+9nsN/YX2wGes8H+sW9k2BqqrP4EmazeJNELw== X-Received: by 2002:a17:906:dace:b0:a9a:38e6:2fdf with SMTP id a640c23a62f3a-a9de619bb45mr1071787866b.64.1730191650264; Tue, 29 Oct 2024 01:47:30 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:34d1:b0:5c8:acf3:1296 with SMTP id 4fb4d7f45d1cf-5cb999fd8e0ls531828a12.2.-pod-prod-03-eu; Tue, 29 Oct 2024 01:47:29 -0700 (PDT) X-Received: by 2002:a17:906:6a1d:b0:a9a:4f78:b8 with SMTP id a640c23a62f3a-a9de5c922c6mr984904666b.2.1730191648728; Tue, 29 Oct 2024 01:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730191648; cv=none; d=google.com; s=arc-20240605; b=h3r3SPdCUw/irN1yqbp/O2S10aY94MWJF8TvyEmiYAb/GNPZAw1WIsBH8h3684nh8I 7YBYCKh1ya/1Yv08mC1LgzYhuc2esEkYdosX/1pV9iF/LcmkRS8kzlLYy12TZzpHr8Sx 3pjqxDxWU/4zmG45EzRS9dNCx1NedcDPnXSq0fE63LCVZujVHnjdrUFwuW6k1TwJbj5a uDTUN82QGj5u6Ej/dihJnAVgKFSWd0moZZ2D+LBAsWSOmYVvqYTNdWcYCJrzjDdX/EP+ 7/usV48cY/mUz+d4u4f5Sg2sdXf3D09skTwkh517XW317ioQ7V373j3uTZEJWU1YxwWJ gKxg== 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=CK//WN8U4xdL+REXrdvFlQyVdfbEwHB2hFl4Gz57z6E=; fh=FeUWJrdb2mnsUU1M2Yj5gKiGdZHsuZcwDxPV0cEnyco=; b=KFLki/T3t9HrV18Uq0HaqS5pixn2p+H0QQM6eofVKNJjec7lDU8TLt+2M3OPECDIdK kyQC/CgC0UXcRQLss+dEE+itQZNSXVJzwx8ioqlgvX0xhaMBHKF48BgHkRzJHfm0yIIi B1+zf3D/S7oNWl/9FLH2BSeZ/Pm60AfsqwIybEz3/qwQKhZ/dSow7/y256nDhPvVBN/F JBEALvcOJG/jKASbaKWbBxWqbMq+UVdDTEIuqKvTE1iF/K0OjwlNz/i+qho3BjIq20Sl 3UABrukJlSuE6JDHYTLG0cjpqOu0y5VN+AVRIRBvnm/igh7OFHa1sGT8wXw6RdPFtV6v 8ZlA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=T4fI6TK4; 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-a9b1f0679d3sor366180166b.12.2024.10.29.01.47.28 for (Google Transport Security); Tue, 29 Oct 2024 01:47:28 -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-Received: by 2002:a17:907:2d93:b0:a9a:3f9d:62f8 with SMTP id a640c23a62f3a-a9de5ce1831mr1160141666b.19.1730191648241; Tue, 29 Oct 2024 01:47:28 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-68-117.business.telecomitalia.it. [79.40.68.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 01:47:27 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Frank Li , Haibo Chen , Han Xu , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Rob Herring , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v2 4/6] can: flexcan: use helpers to setup the error frame Date: Tue, 29 Oct 2024 09:44:48 +0100 Message-ID: <20241029084525.2858224-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com> References: <20241029084525.2858224-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=T4fI6TK4; 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 patch replaces the code that directly accesses cf->data[] for setting up the CAN error frame with the appropriate helpers. Signed-off-by: Dario Binacchi --- Changes in v2: - Replace the macros with static inline funcions calls. - Update the commit message drivers/net/can/flexcan/flexcan-core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index 790b8e162d73..85a124a31752 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -828,33 +828,31 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr) if (unlikely(!skb)) return; - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + can_frame_error_init(cf); if (reg_esr & FLEXCAN_ESR_BIT1_ERR) { netdev_dbg(dev, "BIT1_ERR irq\n"); - cf->data[2] |= CAN_ERR_PROT_BIT1; + can_frame_set_err_bit1(cf); } if (reg_esr & FLEXCAN_ESR_BIT0_ERR) { netdev_dbg(dev, "BIT0_ERR irq\n"); - cf->data[2] |= CAN_ERR_PROT_BIT0; + can_frame_set_err_bit0(cf); } if (reg_esr & FLEXCAN_ESR_ACK_ERR) { netdev_dbg(dev, "ACK_ERR irq\n"); - cf->can_id |= CAN_ERR_ACK; - cf->data[3] = CAN_ERR_PROT_LOC_ACK; + can_frame_set_err_ack(cf); } if (reg_esr & FLEXCAN_ESR_CRC_ERR) { netdev_dbg(dev, "CRC_ERR irq\n"); - cf->data[2] |= CAN_ERR_PROT_BIT; - cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + can_frame_set_err_crc(cf); } if (reg_esr & FLEXCAN_ESR_FRM_ERR) { netdev_dbg(dev, "FRM_ERR irq\n"); - cf->data[2] |= CAN_ERR_PROT_FORM; + can_frame_set_err_form(cf); } if (reg_esr & FLEXCAN_ESR_STF_ERR) { netdev_dbg(dev, "STF_ERR irq\n"); - cf->data[2] |= CAN_ERR_PROT_STUFF; + can_frame_set_err_stuff(cf); } can_update_bus_error_stats(dev, cf); From patchwork Tue Oct 29 08:44:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3607 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3D12C3F380 for ; Tue, 29 Oct 2024 09:47:44 +0100 (CET) Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2fb56e144absf31063391fa.0 for ; Tue, 29 Oct 2024 01:47:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730191663; cv=pass; d=google.com; s=arc-20240605; b=P/5VOgU10ktiqDndIrHhqrAg9ov1Y/AMOevmU2Czd/2+y/8JrUYIDn80Wn8PG6kFTj XAulWW9saOR5nHCtNO+ZLE215MsNzeD2NFSzScCPzU7OLUdHkbqAAUC75UHYLLYQSDQX tCl9YqkcFdWazd7rgobrZbaH+HWdyHOxvI7RW88VkPkf4VAFlCwUW+rQrc/FohmDrwbU 7KXAGXOylMQkcOLjyS28uegDXyep+r6AZKMvXa6gA0nW91zpO7p8zHV6QESk4pSz+ZqH gCWD0bnD6qnf0/UXbiggmmuavSog0ia1dqzv7sBRDAB0+bgnaBuTaCqh8A7/g6vbkxJr nuQQ== 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=pBqcR74t88TkOcrBKCSZZrPxiIj2zvFwFkHe0eEMBvI=; fh=7w3EfI5A76T7dlSwwe6I7peaZ6BHVUSnZR6ncXUbcdU=; b=KTCVAKBlDpEL+mZVNI098cqh3p/Zeay90blJKLzc32tDOMRjN0vVSlP48L81O6Caj/ CGKN/d+zCADdwzQ9a9ZDv2SlyrpYWLeUxZUujsKr7RmnFZCEIjYPdhZ21wI+7DtFY9mE yMcfHXI31qZr/7UhGLa8EUxWHPqSiTjhO8ShGSJ1aOvWZNGIcDNPhkU8US/iZjpetmsS 7P4mbfgsMnXGCNUdp83eYm+OXNpBDLGA7ng2dNEjfBM9KJPT44I9T2Q85swsQI9Q4miU GAWdTHViMgSIVfMa7UIN/bwM+Gob19T0HBdVCCWFgZkGaCVPM8KjgWpwOL7qcMwb61T2 xW1Q==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jqcxoSNl; 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=1730191663; x=1730796463; 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=pBqcR74t88TkOcrBKCSZZrPxiIj2zvFwFkHe0eEMBvI=; b=LDQuJa0Y5H4GPceFvtyZWkvZTRWpKfGlOvdsSl7rVuEGhP3p6/DlcneahOTQtvaMmP I/i++Zrw5CCQ644TgBlXMTbw9v1OkVF7meEhZEZeyz4KPAi8TaMqqPwQ7JN52CsZhKdT 9w1f2cvNax0VlCw95umr3v59NeF0I7vUY8AhU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730191663; x=1730796463; 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=pBqcR74t88TkOcrBKCSZZrPxiIj2zvFwFkHe0eEMBvI=; b=HkMIydjBn69bKy5WZUTunYvEhKKvPfIX6Qwgy9C8OICu7HB+sLGJ961qWC+nLPpufc dcnVo5T5Yv2J1R3Cs0wSXcYMaJJtqJrVlBHuT/js/IplJMVyn0kJD9GB1L/hzMjJyUc5 2jzkDBjrC+3uMIExoTXTQ7kRPnSDK25zDAS7XLLpw4YqZaVtyUV/XShfzsFzBHBVOkef YFczRSPbi2QwO5vYVtFUUvdwBRjG2Yv/kW0X7dws4y5whDcIxXuM3HGU0kZVCeVN2OMz FJnw8WdNJQoDReXbpbymXE0bCdmBaIwqBk20W8VkfrbmcX3fif7VzLxsGubQnDZyTzhR 9QKQ== X-Forwarded-Encrypted: i=2; AJvYcCWsZvEyI+3Ee9YE7n/lmmVJtCBkn8LPZnp6XfqjHnaZVyJwJuXc01oUXvnwHTiilaOFXOXCFBS3oRgQKGtQ@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwKAAProlr/A5MzCGz3TB7kgRIagD38F3oleUOWMM0Bm8SXVeWq Tmh53cd9+kKijNkbj9tYn0Bfl6xaYmDDafkgRlGBFogUU6ih9vwSfTR0SJPDyvD2Rw== X-Google-Smtp-Source: AGHT+IEPDJHl7cld7JIMrnCkhAmc5xGMyzoL+lBNjj2/dMFgf5RaZwcIkXCo1Yr7dZKtzVl84QFlhA== X-Received: by 2002:a2e:b53b:0:b0:2fb:6110:c5d5 with SMTP id 38308e7fff4ca-2fcbe096067mr35623891fa.43.1730191663412; Tue, 29 Oct 2024 01:47:43 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:4416:b0:5c9:1f95:5130 with SMTP id 4fb4d7f45d1cf-5cb999fb662ls86851a12.1.-pod-prod-07-eu; Tue, 29 Oct 2024 01:47:42 -0700 (PDT) X-Received: by 2002:a17:907:940e:b0:a9a:8034:3644 with SMTP id a640c23a62f3a-a9de5ec96e3mr1119020066b.14.1730191661942; Tue, 29 Oct 2024 01:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730191661; cv=none; d=google.com; s=arc-20240605; b=ITJ8ypJkb09w0LpVtUm7vonu+w8OdaefxyyLnzh+3zgJ3rjnfCDIcU6x3NR+Fk1770 94mZGT/dHYfHvqfGZgTM5/biZvyq793n9mG3ve5gmAINlLQ6h9nQfSDmJBlUAWXU2rIU VdIoSbYKZICS124qJLFAIrh0tnlxX/bHvcIBxsNOLDr9EvOqs7g/nYkDisxGapxUYGh0 RgBRm1DDF2Ewmce1SJkONUxxc6MjN8OLNLlopw3XWNwdLL3O/CWAm3Gd0jsRtCVgKgBH 9hxVC8/byFthywnhylNCo7VLlT1obCrrqAoUdFvmjTijfYJLLjBhSOIyN+yY4RwBPi9+ rMqA== 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=+TS+cafYkOpOnfMipNar/zvOqT/SxcL5voxlp49ONDY=; fh=ljoFiwPup6gC9YG4NMWOEWNdgUd1CKjWIIwpUvYy39c=; b=kjZSroGQKtOqljTeoOvd8iCHFTq4PMmIVHB3Jf9W2oN0PpxbUjjxc3BkyNtaP9E/1Y aaCzyBDKw/aok4MNVGAVT0Iec4JB39LpraeXyBoV05e5CvZXV7ZGi56VzALvVM2aQsfm FeERgRSLN3s786BZU85oCvkjiB073n0OX2FE6i9ElswAqYqie67U0pQhBQuT1EzA0a20 U7k9CYnrktGzZ35dJ39F8rhUfHlNuccGvB4RVXvsMdN3r8zCDXOD2bXrRMRO1eSLg1b4 SIPlhQYNvrD+n/m/eNSRoB/qmxKZTsYz0zpQHgjQG562Vud8B5d75myyHfAaJjRMYGdc AvIA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jqcxoSNl; 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-a9b1ea3cf37sor354960166b.1.2024.10.29.01.47.41 for (Google Transport Security); Tue, 29 Oct 2024 01:47:41 -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-Received: by 2002:a17:907:9604:b0:a99:f4be:7a6a with SMTP id a640c23a62f3a-a9de61ce626mr916455666b.47.1730191661380; Tue, 29 Oct 2024 01:47:41 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-68-117.business.telecomitalia.it. [79.40.68.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 01:47:41 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH v2 5/6] can: netlink: extend stats to the error types (ack, CRC, form, ...) Date: Tue, 29 Oct 2024 09:44:49 +0100 Message-ID: <20241029084525.2858224-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com> References: <20241029084525.2858224-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=jqcxoSNl; 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 CAN bus protocol specifies 5 CAN error types: - Bit Error [Transmitter] - Bit Stuffing Error [Receiver] - Form Error [Receiver] - ACK Error (Acknowledgment) [Transmitter] - CRC Error (Cyclic Redundancy Check) [Receiver] The patch also adds the corresponding counters to the statistics. Since each device/driver can determine which of these errors has occurred, why not export this information along with the more general counters? Signed-off-by: Dario Binacchi --- (no changes since v1) include/uapi/linux/can/netlink.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h index 02ec32d69474..8b33549e7e19 100644 --- a/include/uapi/linux/can/netlink.h +++ b/include/uapi/linux/can/netlink.h @@ -114,6 +114,12 @@ struct can_device_stats { __u32 bus_off; /* Changes to bus off state */ __u32 arbitration_lost; /* Arbitration lost errors */ __u32 restarts; /* CAN controller re-starts */ + __u32 bit_error; /* Bit error */ + __u32 stuff_error; /* Bit stuffing error */ + __u32 form_error; /* form error */ + __u32 ack_error; /* ack error */ + __u32 crc_error; /* CRC error */ + __u32 pad; }; /* From patchwork Tue Oct 29 08:44:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3608 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6661F3F380 for ; Tue, 29 Oct 2024 09:47:59 +0100 (CET) Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a99fd71e777sf441305466b.2 for ; Tue, 29 Oct 2024 01:47:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730191679; cv=pass; d=google.com; s=arc-20240605; b=Go4rrN5PIsbi+c3sf53JMpckIsswWhvuSdgRL2f/fUQ1HqijdUyANJHvEIMzXIo1iK omXOAFQDhcgQfFFYUeaWAHg65cRxhnoJHJJgvFJXS8mc3Z8b0ADtDRe8PEiYkYj8en1q H3/bUvqmqoM5PLvqSId4Ql+fze6hiZ/6UWh2Ekbfm3I/c6eCQrPybh4P4R+G+3aVK/5q 7chT1K0bWs+SuFK5rvaW1S1k+Y09N5GULFt9d8o8lPHIVZYzKxOFoh4TMvmLiwb+WTdB x67kCfzxB7rMY+ky1On8sdMu4XPGpN+bm5jy+JpXsVk/5jQmeYjm1M4+7RDUy4iMK9y+ +nMw== 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=7gBW5K3Qg5wxB4bdKujCe36PeFs/WYuct8dXQ2iu1Rg=; fh=2x6IpNuUWhIeAatJFQNi2y1MltAwB/Q9b7qdReUgW18=; b=EJYExzIBubhv6Jb9XFms18uyf0/My5+sx0kKFAzCZC+KRxowH6uPoKyRRF9+I9dDMh ukRy+JfInRVpcPEUt6ffwGRR1bGXdw4pJU4F29UMW7bNxYllzSkh2SGsIPM+ZLPYSkn6 vFBGeWPNEN7DBMM2okSC1Pl8WwRHq0tQ9KigpRo99HYzjGnLAcQBPnAJtiTS4fdyuzUE d2qptT9lQo/N7JfhmKhxk1Di2tLjUfspGm9pZH7XcgflRpYe/0IydQRt0JPJzGyTESVc uACZ+1Eux++d2d2FH2flrFjdiJYmG3i0yOdzIHDzVV5+KkdPlEZsEMZwJ+yEh6GuH+mR h1Ng==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=J69aS4wM; 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=1730191679; x=1730796479; 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=7gBW5K3Qg5wxB4bdKujCe36PeFs/WYuct8dXQ2iu1Rg=; b=ZquhNY9q1qXOSPn/NCK23jAMmrT3VVPxjlD5G4SqMoBaDZS8Hubsm5SEs94543ywin xK6gPFv4cPko3RBKOLSyh3fGEwnp1VgiTjqIWcqOtFnUZLu+fFHJI7cLZhySIJhE9e0Y RpPiiFdiDpfwM02QhftyAVILRzt67mS0RxHGU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730191679; x=1730796479; 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=7gBW5K3Qg5wxB4bdKujCe36PeFs/WYuct8dXQ2iu1Rg=; b=mF1/LAQ944YJON3rEM+PW14lMhpICRblUnpNuXrlVaxcjxzA9V94ON0cT/+LNhG/He 39RMJsgoaXY+WQbGud0bOcEtQT3HcsWDKvlFyZOGx97zEN+6sv2v0DbnFsot1HyjBSY1 +acz+vTS3VXfF1bMbHLZmUv24y0PWNhvJsgQ7M7WhoSfrDcf7gvzXp3kIBsoMe12PSAu cBpIMLTheuO8H7LzaiRO6to3diEC/WxlXbU2o7vg02AllrJq6SbgBYI1XB3UV6kP5BNG qluMgcRpZwOS2eGXRUsGtemAL70T0CS8Llll57W/sIipwRs6d3R0mkLVCdqk6aVNGugH kduA== X-Forwarded-Encrypted: i=2; AJvYcCXtRX2vNyloxrj5IPzwMPhaXECNyJilPtWV34uDnE6iyfcvNoo4K2Zlp0mvHBB2yrlG0frstDu/LSkdTnmF@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yw9+GWLGlChLsXxXTrF1jklSR6nwaaQMewi0JVzQfZhtxxP9ZyR +PmDjOi7jwVJBu5vzoMqq7GMc1gJs9H/Mm8dx4JsAlMdwUEzPKgZXeQs8SrugsYwRg== X-Google-Smtp-Source: AGHT+IGJrrDrdXFQDVF03hGLRIuFRr6MfuJcG3Zpa1WC0L0cv8oB5gvpDUkSufO9dE1QQdSETzZXYg== X-Received: by 2002:a17:907:e92:b0:a99:f861:ebd with SMTP id a640c23a62f3a-a9de5d94315mr1046166666b.14.1730191678362; Tue, 29 Oct 2024 01:47:58 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:510d:b0:5c4:6c19:f742 with SMTP id 4fb4d7f45d1cf-5cbf05e44bbls487678a12.2.-pod-prod-02-eu; Tue, 29 Oct 2024 01:47:57 -0700 (PDT) X-Received: by 2002:a17:907:608a:b0:a9a:4120:c107 with SMTP id a640c23a62f3a-a9de61e8deamr835060466b.60.1730191676748; Tue, 29 Oct 2024 01:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730191676; cv=none; d=google.com; s=arc-20240605; b=YfGt2uOZqbThI5hk4EkC9kBkyvsDtkA2qE/3+Pug8eBPYRgQiQBXtxqBHznQ7egahV Edfias0t9e4JVq5//cVeNPNHzr9yBLeocUdfwtUM3EGBl6qMwa2GscQgcIcQk6/QIMcA 2NPwMoVQcMISk8lmTTHRQ+maM1y/WnFbq5IztYtPQc4/0d7xMtyp45F8pBzF0tzQLcsY Ow+6LD6JRsr30bVPUXelpPXLuGSswDOeCbwh/7RrGWTth+P1eJgEYnmsmqrXIqvyLDU3 o2POiCtyB/2H+fh18F+bgljeXpOaRXvV09Yqztl+5UOFFgygVv5hZI1PkIV7dybzoIhX hqmw== 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=0pG46qvNdim+YSCFTrvSFA2E8sjhumHv8Kb1b4NjRqM=; fh=PjxMd3bFjy42ndOBsdK2kW7LKvq95NBfuaPfvxNPOj4=; b=LWthVSRapfNNUgzl2BzoRYlk/8xcy4BbE/YmeGH0OfMsCnluSCtAh39CTNyXCHdS8G zEs5TWctCs6AdF1mt7Zx/tnmiawr2+RSFnAWezOV77qmIo88qrHdihZMZNf1f+sBpH2w S4dqDl4WNLGReS/9RnBCLNX3LukfLVhmlLWuhVV7pEXgm24EBvoNakxsbYc8WmEFDqLq K/TKglCH+JVC5IZmzYlrP/j2ouaoKinKLyrBt4cHDVNKf5QBHGFkghQ3xMrPU1pw/w7o HR4J8RpsTA5WpSMw3qyAn8LfC3lBDAt0txzQQNpJlOD4wV+fsTcr/gVnxleYyUSKBEJo 1eYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=J69aS4wM; 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-a9b27b81343sor352034866b.19.2024.10.29.01.47.56 for (Google Transport Security); Tue, 29 Oct 2024 01:47:56 -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-Received: by 2002:a17:907:7d87:b0:a99:fba0:e135 with SMTP id a640c23a62f3a-a9de619ee32mr1052955866b.46.1730191676268; Tue, 29 Oct 2024 01:47:56 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-40-68-117.business.telecomitalia.it. [79.40.68.117]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 01:47:56 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Alexandra Winter , Andrew Lunn , "David S. Miller" , Eric Dumazet , Gal Pressman , Jakub Kicinski , Kory Maincent , Marc Kleine-Budde , Paolo Abeni , Shannon Nelson , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v2 6/6] can: dev: update the error types stats (ack, CRC, form, ...) Date: Tue, 29 Oct 2024 09:44:50 +0100 Message-ID: <20241029084525.2858224-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com> References: <20241029084525.2858224-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=J69aS4wM; 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 patch modifies can_update_bus_error_stats() by also updating the counters related to the types of CAN errors. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/net/can/dev/dev.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c index 0a3b1aad405b..f035e68044b3 100644 --- a/drivers/net/can/dev/dev.c +++ b/drivers/net/can/dev/dev.c @@ -27,16 +27,31 @@ void can_update_bus_error_stats(struct net_device *dev, struct can_frame *cf) priv = netdev_priv(dev); priv->can_stats.bus_error++; - if ((cf->can_id & CAN_ERR_ACK) && cf->data[3] == CAN_ERR_PROT_LOC_ACK) + if ((cf->can_id & CAN_ERR_ACK) && cf->data[3] == CAN_ERR_PROT_LOC_ACK) { + priv->can_stats.ack_error++; tx_errors = true; - else if (cf->data[2] & (CAN_ERR_PROT_BIT1 | CAN_ERR_PROT_BIT0)) + } + + if (cf->data[2] & (CAN_ERR_PROT_BIT1 | CAN_ERR_PROT_BIT0)) { + priv->can_stats.bit_error++; tx_errors = true; + } - if (cf->data[2] & (CAN_ERR_PROT_FORM | CAN_ERR_PROT_STUFF)) + if (cf->data[2] & CAN_ERR_PROT_FORM) { + priv->can_stats.form_error++; rx_errors = true; - else if ((cf->data[2] & CAN_ERR_PROT_BIT) && - (cf->data[3] == CAN_ERR_PROT_LOC_CRC_SEQ)) + } + + if (cf->data[2] & CAN_ERR_PROT_STUFF) { + priv->can_stats.stuff_error++; rx_errors = true; + } + + if ((cf->data[2] & CAN_ERR_PROT_BIT) && + cf->data[3] == CAN_ERR_PROT_LOC_CRC_SEQ) { + priv->can_stats.crc_error++; + rx_errors = true; + } if (rx_errors) dev->stats.rx_errors++;