From patchwork Mon Oct 14 15:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3576 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6E28D3FA1A for ; Mon, 14 Oct 2024 17:24:46 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43114c476c2sf29255385e9.1 for ; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919486; cv=pass; d=google.com; s=arc-20240605; b=Lkp1JgjGUnGhu/aIzxcn4InGxa/daOPclY8eH9lhjuvZVnIZyArBILOAJKEKKQMfz5 DMHGUBMIREeSW2FpjGOW81cB7nLZM6Osv0aoHlb5r4O2Dl8XIKeHib4aaqThLWRavQ0y VqdqzyO8hLXNfQAHKvhvJ5nRUJ0ut6p+t3OozWviT8N1BhLx0l781Gyv/vGne/ca/0Xn LHFvglpITcERBoBFNLaNJkF1aYS5wcqIP4nFk4sM6ZgHNQ1QAzHn4nu3m4/zD9M5W3+Y VVI2S3vl9XMhsjNFi2ADxkVuckeEGXn7uwJDxQVXqSODry5JLbZzNr6muwcHhlixO6l+ CYrg== 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=OtvvQtw9bfKAUQR6uLRUJnqD4YPG6foJ7RuJdWf9byc=; fh=R6+9XWuE1lZjFlcVM8NmM4Ke7LIhkSceirIUqDzSJcA=; b=Q7pejquemh17kJfB9TS4SvzUSwNZPYMEbzgAr0RWPicfkJebh5R7L/xR23qT65Gymq z9vFh5TrK+yFh/tPy9koukpBjmWa9l4BQZIjf8W5gFRTVd4ibUARntltUGB3YkdBq17o BrK5jyrAVlyOLQKtYzlFXtD2tuveK9Ux67yxTbZnHgHegvqCqaT6v4TVPypTfMZqHekI 5Cwhr+uA6N+U6Ns4e48hmyeBVo19ncyiT+IaIYxyIgmpJKgvCVN8i2irHtznmDF4ANH3 SKn/GvGy0WDxnmiZFLdHWj+uWR9Rz8ZSEV0SwssNHHnJtAfeXvW9cGqUbQ8CmYJ0+yk6 DkGA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OdwqQKh2; 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=1728919486; x=1729524286; 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=OtvvQtw9bfKAUQR6uLRUJnqD4YPG6foJ7RuJdWf9byc=; b=axPeQYVIbGn4b8fWSn6wk5lW93kPiKmgnhyMqRWNuG5wLXE8UniMJ54XHPwrnv4s6A hNpAaRIJVST3S1RqU2NTthtQGHiAJYRro+K1hTy5Hs2BE3YprojdwNV9PgEb0L9jHcNr wb4aKCHmGIw39Oc63iqltBA4OmYGSfztbQn+4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919486; x=1729524286; 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=OtvvQtw9bfKAUQR6uLRUJnqD4YPG6foJ7RuJdWf9byc=; b=aIR90qb89BqozYj2g3u6Bz/51+e4jNtywumVdwMs4ImvrGPF56nlbgiyWqzF/VC+5c N05wbeR82FthdR01QTjBmCIpbnW0yDe5kJJR2BBrOT1xGf6X5mdMIHSBq8GkiZMtrmP9 NI5t+F7SkWHQ7ipgaezikpX7M3fg6FdnPTTBDeNxYe/JRYce369fwcZmqFjPoVJVaFzy WpRV1xQ25WlGkIOsYoXayFI+8WtVQ7wB8VUwHEsSap8U4eXUDVuS/La7adBR1yLhlaUH R1eSe1YYdlu21QZPl90Gu/blIO7PDWPHOWR8CBmQ2XUt0irpZiDXEfm1pG59vuzgrObI ORsA== X-Forwarded-Encrypted: i=2; AJvYcCUOCZPYDKgy/cxX1b1sJNMM6jJIuZUlPqZ++S0HpsR474hlGK7JYUFoGr+uCYCwLv8vEDFpDiEkhbxpDbaH@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzEK6LFx+hwhFE7hznpAC/7QTUm07IeaR9cepBocR51/iFxI6Jr GftLGKYvo0BSnl2kf+nEji4QxXE+RegFgxXnXcqfdh4LzR19Ea9ftfoTjMAxdslO0g== X-Google-Smtp-Source: AGHT+IHo7sNTBIERmUDe+Yrd1qJU7jV6qWCgdCPcZ1s2WZfE02q2Eea/qQ2kTKrK/sGWusAIVNR9Zw== X-Received: by 2002:a05:600c:4f8e:b0:42f:8515:e490 with SMTP id 5b1f17b1804b1-4311dea3cebmr123774315e9.5.1728919485864; Mon, 14 Oct 2024 08:24:45 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:1c9f:b0:431:155e:348e with SMTP id 5b1f17b1804b1-43115f179e2ls10747115e9.0.-pod-prod-02-eu; Mon, 14 Oct 2024 08:24:44 -0700 (PDT) X-Received: by 2002:a05:600c:1e07:b0:42c:b950:680b with SMTP id 5b1f17b1804b1-4311dee6f4cmr96448275e9.20.1728919484384; Mon, 14 Oct 2024 08:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919484; cv=none; d=google.com; s=arc-20240605; b=W3988eG7m+6P2Bvwdsb5Md7Jok3MscV13kUhsM5u8N8Luq888f4n1lCfSy6hOvz4/X 3ZDFvX4S7ZqccCdpPToUhmrpBAelqd1V81LaicfoIP5StKXHRUE2cJ4vtJpQfe3QCLSe 2C9JdNVBCQKsyVWs5sE55LWPCJCQ6koV/GB6Mx4PmE100mtQxEP7d1UKZX9NxgQ4l38L NDd/k27dZliIdkvp0q67DJ3/6YLy9zgaH6nZc2gIP+zeqftFC6Vsb9gW+p9MuUKR/qAJ LZ162HOO40b0zhfMFyzqoxfPBMHYSgHNxm9mKIrigOeWZApuiWk0EKvVFL8SmCIKvOK6 9p+Q== 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=gvkSVt8VpmX4gMY6ZJ043PHdZhz1ZoH+BaE3ci1zs5w=; fh=GfKZgcJmDxhv0Km7SY1mUOBGy7WMd5fDMbaQLiwxr+E=; b=Nk4OopLZRCdS+2dEGHLoIPpsKqg8o+ECnqGfBwumM8AIhTDoTYuZJ3g6jvgCatdNtk Kims2T9LQSvURGe3d0oIRwrlGLIq4OckjXKuH7ye8ppcgwmGgNvlCCIz785stF7oXKRa pieU9tJmAmeqAATa3WW2f2eT7OtvqyQBTTJ8YAqDS+2HvLAE0rurEEO3IZT+8WzRNY6c QfjVrFD5JLcxp7z3P3BOBY+ESSmnF3xIVKItJrhcV4bxDUzq/pSLv8Zol/2/CN49tlRE yPdeeEaPLRU4NXJkMk2a8ht+BNK3ZfFv3rdcyzcn+7FfLmL6VsDirghuiVA/lndLs+iz nzOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=OdwqQKh2; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-4311861d607sor30003845e9.12.2024.10.14.08.24.44 for (Google Transport Security); Mon, 14 Oct 2024 08:24: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:adf:e88b:0:b0:37d:4cd6:6f2b with SMTP id ffacd0b85a97d-37d551d2566mr7314184f8f.14.1728919483907; Mon, 14 Oct 2024 08:24:43 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:43 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Alexandra Winter , "David S. Miller" , Eric Dumazet , Gal Pressman , Jakub Kicinski , Kory Maincent , Marc Kleine-Budde , Paolo Abeni , Sabrina Dubroca , Shannon Nelson , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 1/6] can: dev: add generic function can_update_bus_error_stats() Date: Mon, 14 Oct 2024 17:24:16 +0200 Message-ID: <20241014152431.2045377-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=OdwqQKh2; 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 --- 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 Mon Oct 14 15:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3577 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 8D30E3F382 for ; Mon, 14 Oct 2024 17:24:48 +0200 (CEST) Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-539e6837a36sf1248034e87.3 for ; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919488; cv=pass; d=google.com; s=arc-20240605; b=Hiblzi9L1INA7t2NJTQ/W0qQsDS/JP8R1T+vwlyR/DwXgFgn53wnOhwcA/S3a1QTz4 MQ2tZhd9oAsIVdbws6HkPOxjYq71Gc45pj/oj15w/lOloRIqExW1+VQ2w8pFQ44OGa1Q mS6aRMRULH5IlvMKgnMblYzEbhPADfakSIQM4kvw99yKZeAYMONerNTMC+twLqCfS/xL bLRqrUmY7EtYMPFmr/IDOZFS6RflJH07MsP/V5E1CD2OVrhk8/g6Xduw/tPRGDmRaaZj hB2kVbsJ8EwEJ4by3xmbShfm2/8z1nhjqfpOKWmTFIA9MTwX18t0m1FChHpH8tsanFxU 7Otw== 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=wemhzEoE6hMHsXuu3Ea3VNnoNsT8OKq37yydWyW9j7M=; fh=rs8y5oGwQbS5mlB+YSHRizwzQGhAs2AqDWy9liunkqQ=; b=iOBb8Isab3aWpjGHd/P4v2iVBo3Yuv4ZXYjAI6Fdfi/BGBVZTPVAJqr55gvLtOlLUL QESLuTi5td+nLwthtE8N1tsgoYe3X4Widmdp6RMb+p5CHjA27DXraDmkc18h7mp2xzVd T7GPO816ZabJAz8RduPfs55Nt61lcJAFxrZjwgJdzT6Muy8s23C4cCwMGjJaH1GVHGW9 s6HNDyRbDcUzpYF+Svu8Nwks7/v3EY+PiNpoqQivkj3+KqJGFAaIRHcNquw4kENDSgTB XLbjF+xzkqwR7FOLV1kKuS7eJY4L+b6Q+1XD/NfpnHFlkQbf7wk8eJuRX8efNT2oZI9G zQOg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H8NOOJeY; 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=1728919488; x=1729524288; 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=wemhzEoE6hMHsXuu3Ea3VNnoNsT8OKq37yydWyW9j7M=; b=k9lF+TML2BjhJiL2LKs4fWlOMlmPbkS8sCO7D//6xcOEerBIGgddNSekedpm8x9KLK ohprL7V7G3hE25+5VQLHnMNuX+hYtwG3/YWy6ddUYqrbEWJOp1wmPPy75r8UEtl7w2mn Lg0WSaz4kXaGhxlUwxSS+7XnrRhLbHTadPRpw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919488; x=1729524288; 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=wemhzEoE6hMHsXuu3Ea3VNnoNsT8OKq37yydWyW9j7M=; b=v1HtGxk2yxVebfzguVtgAahMIAOQcnBF/UQu+q9zSyaM4/hFpY27IBK/aH7BmZ7eIq AjA0C5N4plc/GXTSEyXp3dZqWQZ3dE9HhHfPcMGOpzyDs+s2XTlUkkWl45zBTfpkfSF8 CsH5dQfdgwNqReB1McDK9ukwqdI0eefyec5hvYNbDVY2WXWyJAhJuXtmC1FQIYghSV3O ZkL9E1ngUDCXUhMYtDVnG3dYGx/h2ITFbzSKVkh2HJUbfSIqnoX5jtS1wAaZ9mWGjkTt hPb4gWZbQ24LsnivzC8MhTISo52ZgKPEQqU0FVMkxxagBKH/1KZfq6mheJvvaBcMz7Qe EBUg== X-Forwarded-Encrypted: i=2; AJvYcCWCDSU0GnwITInFT8700/PYzAnhBZOVZ9Y15a9A2tNYMiLvI4sQ9O04wrwucsYokNVuTjs09TI+W7WLGoZL@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxlLmjxUn77L6nlphViog2RMX7VBEpoQEaMWfRR7pLzjpmNzin3 rGgdAaqUcZHSIwGDah3H+qdroNclq00QW5veQYJJN7zREv2tUEk7xG7vfKdMHv05MA== X-Google-Smtp-Source: AGHT+IGxRsoWb1W13xdpZ9Y3FEPnRIUeXxzLq61msZuwMCRQdhWXIc5JMs8y97CjD4izWwh9GnXrYA== X-Received: by 2002:a05:6512:401a:b0:536:54df:bff2 with SMTP id 2adb3069b0e04-539e574b7e4mr3276828e87.54.1728919487528; Mon, 14 Oct 2024 08:24:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6512:1111:b0:539:f863:bf7a with SMTP id 2adb3069b0e04-539f863c1b5ls152304e87.2.-pod-prod-04-eu; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) X-Received: by 2002:a05:6512:3f12:b0:52e:9e70:d068 with SMTP id 2adb3069b0e04-539e54d8534mr3976392e87.4.1728919485797; Mon, 14 Oct 2024 08:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919485; cv=none; d=google.com; s=arc-20240605; b=cbSmZAtBdkYwr39yRqOf8ji1yU2y/Yhv9lQbxjuefhviAfk8hAJHFfzSaTxgHQ6BP0 UezMuw9hZfcznbrXFgGyx3h2q7dpWsY/kGNs1exKwq/pxr9njdMZZOc5BN1MQs4z/J4l 266o/qVVXmkhA6u1EalKaLfBdnXKHdnfx9Vj1Q9Ef338BBK9yjgK/oOIoBjaR13uXt/D YdS7JdZfXgtyfVEd6HOG+ft2/r4thVqosrSyHPnyOU09US+kysoyVngMuAas+SY5c9xm wqo//CD1hkjjftb3OvJcAKxKHkoJp6ggwd/rRPfDpl1ktJV7lDhlYjCgbzzJtGbBW5e6 pnng== 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=Z1ubGjttmwYd5EYJYtdXhE3bw7ehS4yxQFLk9r6TH7o=; fh=CVOAsvEULqapV/yQZ7v+/Ldps/RaQrxdz0p6eiG3HKo=; b=jJdByyXYnrUHaox5eLCYawHGrLitMZfvoiKHF2k/ZIFIvILCVPrdy5HUdAKvneganN bbJaMW5ftrz9rRAsaCUTuuFEWxxJG7+Pxzpt1/VAmimNuZ8VitL1rMLbl/rQzslR7ESl Wn/xWYI2hT811GKtrgV3vid1IKnS/paHtI0jE7TcT748Jz5gCj4YFxl4axmxYI4Q31jj wo1vlwEJCqHXzzgCtBRNJBwFyR5optGvL1C65xLS+rTddohyEqzi1szLQi7cpnHyS1wB RW01Jkru/Wj9LDriQ0yjzwiDlvUmmg69DrTJfSX45FqlUQGpdgZzgAKU9uLcn7cXnQHY Mgrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=H8NOOJeY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-431184aa2cbsor24816155e9.4.2024.10.14.08.24.45 for (Google Transport Security); Mon, 14 Oct 2024 08:24:45 -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:600c:3b8e:b0:426:6e86:f82 with SMTP id 5b1f17b1804b1-43125609939mr71666065e9.22.1728919485308; Mon, 14 Oct 2024 08:24:45 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:45 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Frank Li , 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 2/6] can: flexcan: use can_update_bus_error_stats() Date: Mon, 14 Oct 2024 17:24:17 +0200 Message-ID: <20241014152431.2045377-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=H8NOOJeY; 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 --- 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 Mon Oct 14 15:24:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3578 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D530C3FA1A for ; Mon, 14 Oct 2024 17:24:48 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d589138a9sf1418301f8f.1 for ; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919488; cv=pass; d=google.com; s=arc-20240605; b=BbBsSx8E+KWA5nAaixTMA/HxSU7u7auHsCCLDD6Cp/0CPBoPsPZBtit/06bXbIRbpU gBQ5a+32v7xDNsF+9XRVXF0/ZLgo1ZXyqnYonJCGqaZAt+d/XOMdkiOpcH+E2dzavSdq cV/rJkEeZ5g1PaXr27kjIiTtKZENov4kjQVyzZeTvDqu6aaknIl/c9h5cPuiAOGIw+S2 cZKixGk3u4goPdhTw1HVc0vlHPqzuEmISL74CrgIrYNOaxAiAVF3cwnM/iLbDma+Y8dN gHSZf1H00lRNHGV0psaN8XBtVcbCywZ4SFqvULQPo3Qnq9u6EUE/21LY9GprKttq/im8 3TkA== 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=d+gbzA0ax/pm1CuK6L/4+sFBzEGWQVfaY0H708xq5/I=; fh=OsYFHN2pZi9POtE5Rac9t0RnB8iW80G9jxQHB4Vx7wc=; b=SgC9QB6gBdF1ezI8JRtm4F+7pckTPBwQEwVmenPaLHkaFGpjxivxKDxHFTrGi0glv5 E+ciLxfW9aYeDFnnY3E00uk0wiHyxDV0GHzGtEJwv45dcFa/Fq6ABlRjqiVQxc0Al1S5 Ir88G4RWILdOAFFH/mdVVJEXXaFcGHbUF6+6fdgdW1qtVFJS2W4cz9Xu+H/m2ikJqUfs BIL3g1Kd+6XI/yTh6mHXsXqMPBBQe1egdrArbX+zxGKMtOY4C5hF7mpkuB2L0SZyHA0n pPCWyjIDAP1W0FdptNl1oWzJ5Bj0iFlHdEj7B+xZQDS6pJ4RvdUJD9aE9cRPDzufxIOf diZw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TRP6rrcz; 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=1728919488; x=1729524288; 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=d+gbzA0ax/pm1CuK6L/4+sFBzEGWQVfaY0H708xq5/I=; b=GcNmZ6fdYL6RCh/0ipujVkaszrdrzzzX4N65ehOn7XWMOuPM6Mg5KbemrbdvVa00aP 2gbHKeGUQ/M79YcejNXhi4IrSy6nUSWCpnflN0uVKVO/hT0kzIrFFDX5dTHZJSLnEimL HYxeWCfHtWpg8VrC3v3vmUrsfbh4+HFT10Bzg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919488; x=1729524288; 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=d+gbzA0ax/pm1CuK6L/4+sFBzEGWQVfaY0H708xq5/I=; b=Uvwep1Iq9lCeJiWmB80tJQFa8JPvG041xNmt2T2lEcp4DZVuhfradl7JkHT7yq+BBt G5iNsvmkDJTGeHM1vbWZrLcvPOOLl8AE4xpWabu5q5NKF0Hm7vHofEC5aV/CYmyh4VOk D/yKf0yZpqiPrc2R97vAopH83MHU4O7aLqO9nbwnpxNNCP0bSp0pMv69nk/IWS05/SLD eZ5vktTuPvdCpw7+MEEJJ9VkYiyxK02iPGzRHfTY9MrYp4nHByves9Mdewtr7hG9lH7G 2PTr/KSJMxN1QCfYovPLVjEQDfN7qQ/01EWHUq4uxtwNGsbte/KbQGDIXQSRZQ++hgPc gy1w== X-Forwarded-Encrypted: i=2; AJvYcCXs/k9xqT79ZYlIAikv+S8wjovtTeIjFWhSmHk0ji5ybc7hM87itSM8flqe1SXP8eUxjGYLooc4jspauF1S@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxcvEM9ooTZsm/pHQCEcDTFUEP/QUD/QfFxZi/ysNdGnbir/+b5 gz32q7r0UG5IyRWpTad2BgRKOCz0zlikJvB0xZ+ccLYzCZIFATHMdaMs4FPqQhjucQ== X-Google-Smtp-Source: AGHT+IGKUBzVy6o/2Qp8cMNB5SrCbDX+0A6SVsQqaKLitCcJrr04H8DKRSH1FRkDlPlcqZ9HKGYXLg== X-Received: by 2002:adf:e78d:0:b0:37d:4894:6895 with SMTP id ffacd0b85a97d-37d551e432cmr8977581f8f.15.1728919488422; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3b8a:b0:42c:af5b:facc with SMTP id 5b1f17b1804b1-43115ff98eals7255085e9.1.-pod-prod-07-eu; Mon, 14 Oct 2024 08:24:47 -0700 (PDT) X-Received: by 2002:a05:600c:1c9e:b0:42c:c28c:e477 with SMTP id 5b1f17b1804b1-4311df1e5camr104444665e9.23.1728919486893; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919486; cv=none; d=google.com; s=arc-20240605; b=b5p2K1l7l1mFegx2pSPJfIPOofdB3Za2x+ua7TzbBtTKCVK1FnvN1SyTtJrGZPKcPp feQQW9ZevMtETlMjXcm3Wch8GTkKxcrkqnA4baPNfl7jmPtcfBpV7I7X8LvsuGG0wTUn 75VGXxotHR2UvNgviJM4f93ZQhR5YwU9feJzsgL6xQ5j37olx9kP8KmTnveymJYUhMkq t+aalxwGKFlnhMZ3aDI9b98kIR6F5Q4SkOSMSCMcXOVuuin3tKhtXI2zE/ex/lfKEwyQ H77Qff2Qe94WRO4727c6dhtL6eU+11nhrivk02+ItqrlE63rgHQ7hNLaiXG7cZoYR4nb YPFg== 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=rl0FvaCWPNne/T/X4eNpX+jzq6AP7zoJV76Sz9wGAY8=; fh=dGLZOKN9V8tcsawm1ur1mnwhvDoTVzbByAl3wpaYkgg=; b=kvg/NLaTsCm4sQKrydvf5pWfMjp+5SFeCMYRMAxWm1kR9s/xKgIHyc05vyXlD2NOi2 Da2w7Pyqf+VcxicOCcBNJ4A1tH9v0wHHybCcptqJIkbdBUyEZ21sJoqPmVvWj5LrQzla em4Wb64H+hor8Gi68J399g249gzVGXJUZ1B2Nav+OZ0+uTJGnGy99SN8OezccOC99ruw BsocI7x5W1c4Vf8MdOxCNzvuZN4JlW8lfnMYZOhTQRXIXZlWYbMaB4El5Gti6Pgqbpfw Tu1uUb6BVSc3zWQDGN/N5eQ+QlYP/9cI4ILredzakvaemp7kYIhvseISXijIXE3gIq4o GwBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TRP6rrcz; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-431184d17c7sor28395515e9.7.2024.10.14.08.24.46 for (Google Transport Security); Mon, 14 Oct 2024 08:24:46 -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:a5d:684b:0:b0:37d:52d0:a59d with SMTP id ffacd0b85a97d-37d551ab465mr9434826f8f.10.1728919486433; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:46 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH 3/6] can: dev: add helper macros to setup an error frame Date: Mon, 14 Oct 2024 17:24:18 +0200 Message-ID: <20241014152431.2045377-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=TRP6rrcz; 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 --- include/linux/can/dev.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 0977656b366d..0202526be6b0 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -23,6 +23,33 @@ #include #include +#define CAN_FRAME_ERROR_INIT(cf) \ + ((cf)->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR) + +#define CAN_FRAME_SET_ERR_BIT0(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_BIT0) + +#define CAN_FRAME_SET_ERR_BIT1(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_BIT1) + +#define CAN_FRAME_SET_ERR_ACK(cf) \ + do { \ + ((cf)->can_id |= CAN_ERR_ACK); \ + ((cf)->data[3] = CAN_ERR_PROT_LOC_ACK); \ + } while (0) + +#define CAN_FRAME_SET_ERR_CRC(cf) \ + do { \ + ((cf)->data[2] |= CAN_ERR_PROT_BIT); \ + ((cf)->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ); \ + } while (0) + +#define CAN_FRAME_SET_ERR_FORM(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_FORM) + +#define CAN_FRAME_SET_ERR_STUFF(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_STUFF) + /* * CAN mode */ From patchwork Mon Oct 14 15:24:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3579 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BF8E73F382 for ; Mon, 14 Oct 2024 17:24:50 +0200 (CEST) Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539e7dc83ecsf1278053e87.2 for ; Mon, 14 Oct 2024 08:24:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919490; cv=pass; d=google.com; s=arc-20240605; b=gHDSQZUrxzKp6Ove8g60rBupZDfMvIGcWr9eiCw5dfaCzJvypx9u0kMJdvvOTJCduo TFD1BYTk806ey6Hi2FUBjr57V1j0NRyVpuA7Q6pyq+4uMZoF33NYAWIhMs3bcEdHu7yY I70EmVuhaGH8Lkep1/5ipDtCle1yTf3cCSx85rwy5q8M97C+pO++INkLOWn7+45WA92n Abe8PmX6sZy3lESnKGT6qU4yTwCrKlyB35qKR3jf8AvChoiwpZPjGixIdFVt+dGIln7u JU8I2jqYHMNDFyrC3JWTTbbF0QTzkvp2zmOdz0a59qrM/OIr8gR72fs6+EvGRw0Zoh3N Mlrg== 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=iwdnFC3vnP41mR9clko7M3+nPlR25BAzxypGIl8ERDU=; fh=AUoyFMw4Om7Z8KdXtKpNlfEidlVe7DoGIfM4QgYoAQI=; b=ZQ2U/hmon0n3yLvR7QdudoUgnBCAM0QMbDukqhObO8MqgV8EAyJ3xM5GM5cGpuLGFN UrSDzDJqQWhaq6FdFen3DQHFMhvArhIlbpQuns9jXllRbT6OpLT1bG2iVoVYtlNKB0pM CTBPiC98r0Lv/bea/BHiZBxEE2qrYi7MsrGjaGHETBonLE1ijx1kJshU2gZ3kQBdHLSu UtNmM3G2wmVVsqJoB0+RHMFExw9P2Z1F7DLAhnSZtsbZUwo58rNGYhRaKaZrVjqIZKIu +tGIRTYYBgsrYzhloWdOowzUEuNmEzrTh3JuYIoM+nuBzJ2hSzhQmaE+4CdqkzjCD1Zh VrRw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gy663W2Z; 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=1728919490; x=1729524290; 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=iwdnFC3vnP41mR9clko7M3+nPlR25BAzxypGIl8ERDU=; b=DOx8npRLCq+MTRXveVvbJ7g1q9UEyisfG1pPL+b+FaeKATW68NhxxWk1ksKH7pZ+YM dGILi2QRQleLEpS8QcRe4FrmIuI8rJngfc2F6eDonu1ZTKxQfNb+Ied/9tJ3IPoLVLPm bA0Jwbfm+tHd2ClS3tBs5pGD/Xv7f0xC/qSI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919490; x=1729524290; 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=iwdnFC3vnP41mR9clko7M3+nPlR25BAzxypGIl8ERDU=; b=By63Sqx0lP1YMOYZR5xGQ7UZUsQLnqycAVBYlF79dnFrSkzC9isMDbxnFnDz066DwT aZV/Ev/2CY7Wi0B502OQhlKX7tLZqV521lHEEec1psxPixA0LFagfUt58DKywxVjmdfx 4WVHL6l2UWk+v3FbtEX3/kGfJHYcOlYYubIrOujPCz0CsN9bkAKuhv5rWu4U+ndkzjBw L6NFHMhrBVmhnvRA44xTYVJU3dLw/uikJlyZdcEfs+GMRLulGTGCAIGduGL44GX5HVfw 7bjKaj8yL9vwBwuzFyOMSEokBjK5YGb0vUMYLr0X89D6aqqzfoTU8Om6weO5/dUOxpBv OJoA== X-Forwarded-Encrypted: i=2; AJvYcCXsvDbVI0b7QqGP7oF5tvEP2j6Y/JFpcoU/x/Ev3hb9R9dYXmdik3vZOiAwpRIwVgy1mahDaWEcgwPUb3dS@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzUXqX4lLgIT6E1lz75OJ13UDu48zoiyvoH2QYAinIVpJAv+GbP ek2PtJC9Dl4ZVixIAdnaUCgk5rGyyU1LLWaERuw3g7XqBvxs4Coihbj+IjmwWoMDCw== X-Google-Smtp-Source: AGHT+IHOB2vWJUwuFuJTK3FXROJC/rMNcCZ9IWqtzn259fm+h/fNuclA7gr/5bXG7oZTFFtP1EM+tg== X-Received: by 2002:ac2:4e10:0:b0:536:9ef0:d829 with SMTP id 2adb3069b0e04-539da565caamr5754029e87.44.1728919489957; Mon, 14 Oct 2024 08:24:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:544e:0:b0:377:2d98:7c90 with SMTP id ffacd0b85a97d-37d4823c5d8ls1091232f8f.2.-pod-prod-09-eu; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) X-Received: by 2002:adf:ea8d:0:b0:37c:ccad:733a with SMTP id ffacd0b85a97d-37d55304285mr8305370f8f.59.1728919488420; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919488; cv=none; d=google.com; s=arc-20240605; b=KCb3kITs/lr0M8H+thWvlQcUWmWPJ35D0o6EpCHNZdMxCF05vt8gzrZ0rJtNCLXX8A 3M2zZt+/HNSc+B9B3hFyIbw4pWfm0yjD/8Zzx0ZyJ2eieZHJlaQcumrDI0LjYKl8Lg7u 0QbymKDY2YERHg/6QSt6iVYid0gSflXW4DngpLiPR5bC1o9lYEwE1CbEVGNj3F4vknfr siZhAgOK2QzmTf4PhQl2QJ4ElQ2efdLrrhGdJJJ2pToN4ukHRiZoPTuKIPuO5Jy7Adin +SxBCT+edoiqSt7+H0bcBNTWAnmERkxY7RUVDQegByyJ9VHAUcL8+F3lMVWOtr42ePUu 0GMQ== 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=aYG5/yu0pXXht36spug+Xg/mIMYx6ohdGwedIw0qEKE=; fh=Jid8/Oyej7OOEmKUXpNOQAkY2aWd+afIoYehnXdDHyQ=; b=P0V04fqLB+pgGSKh81Sej2LqMoqzvYKG9VN0/o7TkvwgeUYqbXtCPyzl5zphEVg1iR TerbwP11ue1GMo70i64CxberQLHAmsQMXVqFRgLtTmA33Hgx7GzMSkrxAPUKAZkbJesc hRW8CZL4989P3lVsKlMbwyRqjYgyZPGjtHk0KOMpCeaJN88nQf77pDH3e52fe8rO4CzL H7gvGC96ChOdAAF39BCu2ZooZMbCXarVko7/V/dpuVAih6j+j1lL+1G6dEoaSH8EL1Df IbKjhU3UDQ4G9RibNHtS+IcJR4ssaCWENDfgW10drYmQ4eHiAvEen8jAbRhVtZLMdtLf 8b4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gy663W2Z; 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 ffacd0b85a97d-37d4b9a73e2sor1947952f8f.9.2024.10.14.08.24.48 for (Google Transport Security); Mon, 14 Oct 2024 08:24:48 -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:a5d:54c2:0:b0:37d:542c:559 with SMTP id ffacd0b85a97d-37d551b6a0fmr8141214f8f.18.1728919487917; Mon, 14 Oct 2024 08:24:47 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:47 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , "David S. Miller" , Eric Dumazet , Frank Li , Haibo Chen , Han Xu , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Rob Herring , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 4/6] can: flexcan: use helper macros to setup the error frame Date: Mon, 14 Oct 2024 17:24:19 +0200 Message-ID: <20241014152431.2045377-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=gy663W2Z; 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 helper macros. Se hai bisogno di ulteriori traduzioni o modifiche, non esitare a chiedere! Signed-off-by: Dario Binacchi --- 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..ca620c8f028c 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 Mon Oct 14 15:24:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3580 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9957E3F382 for ; Mon, 14 Oct 2024 17:24:51 +0200 (CEST) Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-539fbbadca7sf706360e87.3 for ; Mon, 14 Oct 2024 08:24:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919491; cv=pass; d=google.com; s=arc-20240605; b=hpRGuFju3k8iD2X+I3NMxnUFYgO+JrPyy1NfTVEiyUeN0/wKw07BY8UGppQpSnozUi UC2fj8Ednlz9BPI8tPdNxNaBdms6n1PjW7MZR3Xs8mYjS+I9+XaFiXDArwbY5SoZJmBn mHcmgYBVJaBp02hJYlZz9QsJ34EnJAYkTAZ1QKh0hGl21ed9HvWCw854Ahf74Et2h493 qbCBfIdeMEwWl1IrVgO41JSofLVN+aPKTZqEON1mwtxHsBhHD72EkWkIeETQ0AcsL1rR u0H6sl5cXTcUh1J5bdU55rlRFrwR578qyYKaHUtQ4Lz/tE87i6a1x1yZ2waPP7BWQXpx 3EMw== 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=ILLrI3grnj2ipVMC9JWSZcep6oocojxuq1cCmmL1L5o=; fh=+KKY6Bvg8ynWbrPGIuSLHNESsALeJNoaydkztJBZ8Uo=; b=MGRxJgJpsMT3oL8EGBkCoIUzK0BWQDKWDR+S3FV02zbgrSSYtIYJyhX3QZmaXy5AbX jpFvTR4a4DJMlWimHQG9Gww/37bj3zKblL6QAz+lX2maEfAUoi+2vatreV9yK3LYPw0e vRs0C5hI6+pv5w3XExPyD5rQIqEI3abfmzfm6yQP2d4tOyhbzaGzS6fhfWxznQk2V0/S BErU9aRuBub/l9sgXPjoGkyZxXGJdsdYshAMdEuj5cONrxIwKTzq/Ylx2iAvmQuTj6Iu qT+K6phacoLz/iqC4G7/6PrW4/np6oENoWlSK6aC3sNe/+I38MSwyxyaFatDlMTg+bpj zgfg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RhzTiPop; 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=1728919491; x=1729524291; 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=ILLrI3grnj2ipVMC9JWSZcep6oocojxuq1cCmmL1L5o=; b=qPCipFfBIeZmuJ32VThc5CxRQEBop5VG6ZxnujjSfiutY8vnW0FdXiquhElR/7Un3s 0lZvrVwSESIr4leQRY6tjZNYfe4OLfxLTWsfmvJghCl43JAp6/hqLR2+DjJR2hD3xUKG 3gXEwQ4lSmALVzw56PCZAVeG5zuP0LadMC2OA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919491; x=1729524291; 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=ILLrI3grnj2ipVMC9JWSZcep6oocojxuq1cCmmL1L5o=; b=uNLrXCZV9cm5Gox7io6P/yip1WeTqe8rhVGWLKPsr1VV7/WBrzdrB+C9G+FmOV6r2R NDrlkhbn6X7TN/JWucTWbu2UUQ1MCagSFxfTdBPIXCNs9ci9jg6lXXpU2v06zyewI2ba owksscF+MNZRAot5GLYOFq+wCe01ZKjAcjcHqsWdLYx1eYGaoxDEhM3iFfdi+y0oQjDh NNRX8OSJG1tDQu1KeWrNyV2/blc56j1t+3HMFTzboZRbcuUlT8SgzqJ4HHCcF3nsPp7X YXu9e7yOFeC3+MYDZqx8F/+TOPI1sxdiXZ++3qlWMFBsHxRCqY7QiHIC8qleh81I9ISM 1u0Q== X-Forwarded-Encrypted: i=2; AJvYcCU2EDvG9wS0EEmySwX7va63AE0yQh0XptmMOxo6uKHrAh4A94V0coBQgcQ8kfMgGn7MLOlUUBjPfmATwKsm@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yz4C2DBpXsJVvBi7Hy/wl5qpYNRozze9r2GWe1dLydrEreoqwr8 gARKU88j6MhszmNOuOvwBsTeO2Pfdo0Mnz35jWwWh/Xh9pRczJpocWtBgTKrOXAMyQ== X-Google-Smtp-Source: AGHT+IFom3u1GRbE4N8uFZANAoK/L4DW5mOlmtJVyylCdwsGDyyawlI5DQRDaQsgruMvn9naNj7E1Q== X-Received: by 2002:a05:6512:280a:b0:539:f6c4:c29d with SMTP id 2adb3069b0e04-539f6c4c3cfmr1726413e87.54.1728919490922; Mon, 14 Oct 2024 08:24:50 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:1c9f:b0:431:155e:348e with SMTP id 5b1f17b1804b1-43115f179e2ls10747345e9.0.-pod-prod-02-eu; Mon, 14 Oct 2024 08:24:49 -0700 (PDT) X-Received: by 2002:a05:600c:138a:b0:42c:b74c:d8c3 with SMTP id 5b1f17b1804b1-4311df5c5b0mr118197315e9.32.1728919489444; Mon, 14 Oct 2024 08:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919489; cv=none; d=google.com; s=arc-20240605; b=Q5pnLyje8VC/t+8+JNURmd8m1WD3DDjK/1ulb11G24krhiYNCaXjoB/ELWM8Vm+GYH HfX0x4Rv3TLjeop9ZG9NIhm8TyTObJr/R42LGeDPP94qKxFBAnMS4P5cjGOYjZCAgxzH 5vPeoPHCRoTaA7RGyNkLI+CxAWVR2pKP7RzgWmVnv84xyAgGW8sutnYkQFQV7Zj2yIR6 AxieX4GPINzGGqBW9ZiGrccpB6EtixzjtgUVeJq/ZYmD2ho/0ZUMmAUeFAZySyfcTT76 bYw9K3p4+kZfEg2it1dyp3wl13ZIBhEqoZSyx10Zxlqul/muCCNU0mlhY06Xkq1jFgMN gwwQ== 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=pO1UlU+Kdbb/WHWYgWNeRFcofykWy+kMnflMuEIHEjY=; fh=dGLZOKN9V8tcsawm1ur1mnwhvDoTVzbByAl3wpaYkgg=; b=W45dYAZ1NoJvKq+6bG5oSvipgmjWjrThXnPiXY0PHJ5z3sPUgQBnN7oqr8L3S8VOPK YKU6iN6kGyZc6nwGG9XZQMkUbuno/TgInl8u8Cy3WEUOsHoJV06YNMSXxEQOYdpqg0Ba 6AgpRX598azqSvOZtxksa0L7CEHztZPVbPfuK88/hfiLovYiieH+Mb5Fv7dcPPY9X0hO Gcf4hn3M5ZAJldNLHp0sCtvSYi4DhmSRi0/0hoDxHP3tMyPnkrMxzHnfwz4Olx97RWW9 MCKofMGaZzSuUjDCMpNRQytb2V0V7WtwosjM+mvVLK5sfKFss/iALB+4h7b3v7KM4nVR yD6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RhzTiPop; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-43118489f8csor30031495e9.3.2024.10.14.08.24.49 for (Google Transport Security); Mon, 14 Oct 2024 08:24:49 -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:600c:3b0d:b0:428:10d7:a4b1 with SMTP id 5b1f17b1804b1-4311df56e7bmr106900825e9.25.1728919488976; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:48 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH 5/6] can: netlink: extend stats to the error types (ack, CRC, form, ...) Date: Mon, 14 Oct 2024 17:24:20 +0200 Message-ID: <20241014152431.2045377-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=RhzTiPop; 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 --- 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 Mon Oct 14 15:24:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3581 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 694643F382 for ; Mon, 14 Oct 2024 17:24:53 +0200 (CEST) Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539fbf73a2fsf657525e87.2 for ; Mon, 14 Oct 2024 08:24:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919493; cv=pass; d=google.com; s=arc-20240605; b=WBJHb+LnMv5rYGvCxu+OWCrnAlHASO+FUQX03MzMDjv/5+0g5AKp1jAXIvA2VBfRKX KPOsGmGoGWERj5mFwxGRo1OKnh1ZU53sd2RV7wLNh0TwLkj6AjMH/uO4/z0dNCrbt2xA gnap7LHqapEUclufySQCprjOLQErR32AaYqZltQVAguG5P8MtHZggbqhgaNgzy7KZ8PF QWQeN8POckFEgV4fY6404nJFvkzraZgGvgsDZTLsU8ygoV+5kAD/rhW/z7Xy5Vf2ORwm d1b4Hr4pZT2VHO+3jK2Y7mvDJVFrKN5iunbNLXcb6Wfo5MHC9e5AEW0XT60nJ1ykrULs 0a9w== 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=eN9vyGxA0TqceSuPI1f3wj1vkWMxPMHts14R34j/VLc=; fh=SADXYkRdPiO01inmuJS/tiEKF20CeyLrmExj7ekbSmM=; b=J16ES68W+TXqE5EK5dsLnOKUXTig7Tt0XTynYxNgRpoFRqhYG9FLSkP96M4p/DaOMg L5EXahEEtikaFQo0S343fviO8gEz5j67Ueuf3vY8C2r2nmSYtUx8fbXi613ptxE7EYt8 /R40FJNJJ6Mxwq3OlG4JPTMDHNtp/PzNQSa3AWx6CRakcu8cn5QuRJ+VSK2Fm6tZnYjb ifOjG8swy4TQJe0JnlsPDXF19csEC/7la1m3c+fW+EEAa9tAwo5IWXndYyZyUjpp9V5N HUXBwcV+jdjTsKzNQwG1EkyJ+N4UvXRFse02zq1VhZIRDSekG9ORjNgUs6x+UIwLpMGC fRbA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CS3XrMCM; 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=1728919493; x=1729524293; 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=eN9vyGxA0TqceSuPI1f3wj1vkWMxPMHts14R34j/VLc=; b=Wt81V6cgl01u2vxAMVUwdiOl8NzigT6xeIos7/1oUkOBWnyquu+Jcv0N3fHZEocQxp ZlrshBk8n77VVqabWConH2Ac0PQM+AGzvC/bAdCLl9zT4UZCeuO7YhLcXH1WZzsYpL38 ZoHWm3zaeIwfcNY/HRJX86XMW4YILObuJqf+E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919493; x=1729524293; 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=eN9vyGxA0TqceSuPI1f3wj1vkWMxPMHts14R34j/VLc=; b=vj6d0jg1WVjeXN0SlZHq7htgpXvNv6dfJXKzOdV8jbg7xlnjkkhAeXAkeyc+5GTNDv FYA2VcAaFZsoYl7vLzXm6PAOIzUR6oW6SmtSPfJ4GS2szJpu1s52KdAM7hrlRIlGzBep Wi+Ik6G6Qw6X3IkHBwtOYlWv45+56U1M2Ydru5F9OS35Noam7K/l8krG5+eBxRbww7eZ Ih2b+zRwmD7ATmvJLQ40klSqJ2DWL82bOSDk5Y1X5+SCvbbS569gTC9or5441DWsmCb7 DBcq7L0/KRoizE/jfgoTC+5bTHeuZODXpNNegJoVN4w7xUMnWxVRqLudCtpQHsowcY+4 P/NA== X-Forwarded-Encrypted: i=2; AJvYcCURsmSV+oOeJHQLjaNeXO0I0mkoBJkZt0DycYQHsmsHa/zjcidEB+3XFRRGnx/8lNxoT8zl4KGVWne1tYf5@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yx71EnyiYa+7ICyqMFJAtL7BVT8XWCa+Bk+IIEstgXAMECzHzw3 xdtch9UkJMH+8y6ym910/Ua8OHfMlSqHoDQgNd4cvhg8wnFQ72MkPmVUasl0/4fvew== X-Google-Smtp-Source: AGHT+IGkvdDd3sronhs+S6eU/zbeWqHuNt8wuNorIY7SEZDgkbnW4fSnP/bChrxcCA9bHy8tP7TLiA== X-Received: by 2002:a05:6512:1598:b0:539:e385:a30c with SMTP id 2adb3069b0e04-539e54e835fmr3456152e87.14.1728919492519; Mon, 14 Oct 2024 08:24:52 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:1c28:b0:42c:cb89:ceb with SMTP id 5b1f17b1804b1-4311600894cls15686645e9.2.-pod-prod-04-eu; Mon, 14 Oct 2024 08:24:51 -0700 (PDT) X-Received: by 2002:adf:fa8d:0:b0:37d:501f:483f with SMTP id ffacd0b85a97d-37d5ff6d6afmr5571514f8f.44.1728919491004; Mon, 14 Oct 2024 08:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919490; cv=none; d=google.com; s=arc-20240605; b=Y1eXSJdYBvtZ0s00OtqhJ8ivyosrdXC1Imf6mwj5UIdGFFSYfiCnqnYKZkazFUx6Oc mu8Ri9j4Y/amvlfHj7i8iQumdbjE+IwuNKqwiATjReCnYyPRfi2AQGxoWOO4gy4bXQdP KgD+H/9qZzsOLqp1Xr6z+d3Go7JYCFCCJ2hbxOnU/3CSQ+g9xuOCm58FMxs69Tc+hgpE TQGZ/iDSofpW/fQhsB4Ap+1f9PiadGsdyHOloTIkZYq9nas3hp5qWrAUifU7r+3IXfFT dJX8M91aPbKTXf7ZhnergN8Sg86sZAvuouyDJInq9/Q8hETCcaDPngirHkGPOuO7yLWP T+gg== 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=QiHw9EzZ4u2R61UsONsymQwt0FhsGds7xVoU4Q9fXYA=; fh=ZsOHiOhTaC3q28QUTzL7dNDygWBRJDC/s9gpaKZ18Lk=; b=FiFVe8VurXAaEtHKB5vUfJ3bleh/IY8oRgBTOH9ttvrfwMrAZgGVj8e7cwuFMy9ll0 FR+sTwuK238E11ngKm6NnSXBcqMpQG0HGGWPKssOdPsOMyG9Y3wjBPQX1nYfMk3pbmmg c4/0MSJP1zFNLrNeH8vZZ6+7+Zzr5WISIiIYRu4HGzj4J1NudYl/Ppga4yim6OthkfnK rUkcBTt0rW4bgirPyqK5MJVA9nCrunD25iARwFdwYNGIlx4WzlhEwyLi9nNvtevEKHdt UYsWpUHOrsDKxIhXvOLOEGxPSW9ahTZSe3kEHwJ75FdBpQSY+RU4tSWQzwVoSbUp9aBX kt8g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CS3XrMCM; 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 ffacd0b85a97d-37d4b6cd79dsor1403289f8f.3.2024.10.14.08.24.50 for (Google Transport Security); Mon, 14 Oct 2024 08:24:50 -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:adf:a407:0:b0:37d:509e:8742 with SMTP id ffacd0b85a97d-37d5fe954c8mr5128907f8f.1.1728919490496; Mon, 14 Oct 2024 08:24:50 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:50 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Carolina Jubran , "David S. Miller" , Eric Dumazet , Gal Pressman , Jakub Kicinski , Kory Maincent , Marc Kleine-Budde , Paolo Abeni , Sabrina Dubroca , Shannon Nelson , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH 6/6] can: dev: update the error types stats (ack, CRC, form, ...) Date: Mon, 14 Oct 2024 17:24:21 +0200 Message-ID: <20241014152431.2045377-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=CS3XrMCM; 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 --- 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++;