From patchwork Tue Oct 29 11:45:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3610 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id DA41C3F382 for ; Tue, 29 Oct 2024 12:46:31 +0100 (CET) Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5c94a70a3f5sf3688229a12.0 for ; Tue, 29 Oct 2024 04:46:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730202391; cv=pass; d=google.com; s=arc-20240605; b=jvrjL1wXnA4MD3obW8hkXy2+inPGr1Q1QkYz+rb6UZbVeK5pirR8nLblxosTzhih5K p1yT7gxZUcaF6KchWHilpx4cwcDG+dtMDrfHfBgKfBnm22wpxQFlqqL+nE2FkkTSDIn1 uLChbuoiOedC9ymLYcMW61UjZ9ZB5Qp1C0pwD+s/nWh4MFtLywA3/ZHaiSmGdE0jg5xa C22ZxSntXtxZg9NU96aPcZ6zqhokLOqDxhHQ7GHfUJb4Tah5pMIOrGpBKmmU8G3SiGzJ A1/sy5/geKrPC2MRWr98Ri6p/dMV9Q+7SG/MmsXXP7iFvHJO3eBV7UHROUa80pfPdr9A fvwA== 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=6sywNy10mW3ybxaebe3mVFSQccRgKx6T/gQajvn5QXs=; fh=QTBCpPAxyyTsBhOgCl9jJHYyV7HmBM5I8VH3qX5yYf8=; b=avE4/h/IIZgnLYADcQF7lwDBBekKmjCOk/fkVZPZOIVQfAXTw1/E4DbQ44WajvmwSr jWTsD5SWKUMheqY3PwVUxQ0LSY52ArvIANSi/3q9eRPy8yU2FrvPF85O7FzdLN1pKciM huXfuixxTx7IZJC926r8lppLhuoa1LW5pzXRycVgT3Gw+oiaEBfq3Pg8m3mnQMqSpxS/ LWfgXob1pc0sc0JvbOEIet31ljKAKOyruzzoK5g/HsAFK3afs+nUfkfPHiZBZrfpLapv jpH86TOTVt2W5JqKzh6DWF62wTuCOvryIAcWy/2iq7LT5CcEcYGAVn77sqYmxQxHUyaz iI9g==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NDBbY+ix; 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=1730202391; x=1730807191; 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=6sywNy10mW3ybxaebe3mVFSQccRgKx6T/gQajvn5QXs=; b=hoK04VMOSOwqQulYOZEz+ua5xlvduVtpMJV1GW1w5QTszDdO/KXe0sK7e5J/3YnxqF pCRYbuUQOyNI55azucQYubCrflgD6ltMDLBF18AgCwindhS+Vg3418Wdr9ZBlFqrhZC2 nhcF0Jo9cGRcGCbW9lDRdIm4r/mUPwxcwFPOM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730202391; x=1730807191; 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=6sywNy10mW3ybxaebe3mVFSQccRgKx6T/gQajvn5QXs=; b=PlWN5Kxg7EvDDCcTVMfYcLcvrPkk5OfiPY3K93q2J9mtUeNh1M4mHcAT/uDvKApKwz N87JWjnHuT9vOQukcdfeC5gM0rZiAywdk1ErMjjoNEkPKrQ4BUNmhroTb/v9Ux+SnR5Z NfYfQgERwtebpP3Sr5l5V7fN7hW+q/u9kKdKIg1IYgXALSfEVbg0IJdPfCC6yLZggpON hphduhq/xtPZXz5aImilUBtaG7BWSjpya/OXp25uAeHHpQH8fTWv5BW9z1RsJu1mlDFP m8rhczyxcdRJi+8ECzfpMGp92/a1CsA33O1TotyuC80CpjA0q+eYHi4xogF2V031UVfn PRsg== X-Forwarded-Encrypted: i=2; AJvYcCW5dRK1Y+rtwqS+9Gty3W7ljFPCPNkfF8BSsOSvhndyaPIb41W97ThT60wRygVXWa7AML+WY6D4c9kBRQ/U@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yxp4Z0g1hpJm0B0HIb3pBSm0eupgupRftNn9IsoyPE0ZPaKkY9O 6cW35dH49wvrFTFxMndpn/OXGcb1jtCyXwJA2wSixXO4pnsKfv/BRxBjhxzcbv7/cQ== X-Google-Smtp-Source: AGHT+IG6KinGnwxzSHzcBfQFJZiTyr2zznV9L5q7tDyicJqkwooOuxZpQZ/9vRDCKSYVGFKQxcOvKw== X-Received: by 2002:a05:6402:42ca:b0:5cb:dd06:96d6 with SMTP id 4fb4d7f45d1cf-5cbdd06977emr6013014a12.11.1730202391214; Tue, 29 Oct 2024 04:46:31 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:524d:b0:5cb:73a6:e040 with SMTP id 4fb4d7f45d1cf-5cb9987a67els766086a12.0.-pod-prod-03-eu; Tue, 29 Oct 2024 04:46:30 -0700 (PDT) X-Received: by 2002:a05:6402:529b:b0:5c9:5a96:2869 with SMTP id 4fb4d7f45d1cf-5cbbf8b1ceamr8937782a12.10.1730202389683; Tue, 29 Oct 2024 04:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730202389; cv=none; d=google.com; s=arc-20240605; b=Lbig1L/3O3ZxWIVjRn2A6Kzxve/4a5Bl1VTM03pRoyNGpXKkzFLeqGLOaAG9t3Qhjw 50kcZqPltzhh16uJvwtvYufHSdh9MbJH/hutEguna1uXqPX8OHQLeBaJTtFfeLXr8UCA Kg4Kgqd5ZkTVOgaKwoECaul81iMw2qGnZDnY1OtFmmlMNn+yK5ZJY9TI/zmm5dDKTTXY PnF/IiUJIEdAXgzUtZCSOyBHipxosYPap177zQObl/hM7Ku9awdA4nJ0GvTqfqkD5+jr qpwp4x9kOwmf6EFz4hOR3P8c+5VdUmOhIJGt/XJa/GAxQZTCBzp0vaHjoay4Gz/yy22+ LxHg== 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=QeZLl8zUuEL6V9/kOSR2k3pEjiYcKf6aSxS5b01tjs0=; fh=y29f59UM50SX5sXYLtfDcG4k/2fOYCXC2xF+eD0qj1I=; b=HOygobfYlHhSqyCdiiXEK4wqMJ8Cnrs9wPZy4imInK7gbObJUceuNFp8PxNkuOpnWR P+qwvZsbhi9dqrdUb5KuMONnAx5phmLeXHf/pG01Xe9AzRJycflsbEkIYtpVdGeMwsrU RZNcrlSwyYVmIEWREzdNl6Fy3N07EvVz2w4JhX20dMFMZ0ffNerm5sWZro5rZiMcorkd E1qzXgNmrViEfFq9AmpEWooPCXEHsVrjHw8y/WO+PdmxCzSWVRimHSIy8GaoFyjc8rP+ bYlC4QsAX21V3nDW/GUAXGgBk6+IvvOPm8GTBJZaasAChqw1zSO6wccCchdAJkj0AvHZ +33A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=NDBbY+ix; 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 4fb4d7f45d1cf-5cbb621ec81sor2839889a12.3.2024.10.29.04.46.29 for (Google Transport Security); Tue, 29 Oct 2024 04:46:29 -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:6402:5215:b0:5cb:ee14:d08d with SMTP id 4fb4d7f45d1cf-5cbee14d13fmr3714450a12.15.1730202389145; Tue, 29 Oct 2024 04:46:29 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.207]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6297a09sm3869301a12.21.2024.10.29.04.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 04:46:28 -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 , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v3 1/6] can: dev: add generic function can_update_bus_error_stats() Date: Tue, 29 Oct 2024 12:45:25 +0100 Message-ID: <20241029114622.2989827-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029114622.2989827-1-dario.binacchi@amarulasolutions.com> References: <20241029114622.2989827-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=NDBbY+ix; 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 --- Changes in v3: - Drop double assignement of "priv" variable. - Check "dev" parameter is not NULL. 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..4ad0698b0a74 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; + bool rx_errors = false, tx_errors = false; + + if (!dev || !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 11:45:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3611 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 046753F380 for ; Tue, 29 Oct 2024 12:46:34 +0100 (CET) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c94862c3adsf3881463a12.3 for ; Tue, 29 Oct 2024 04:46:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730202393; cv=pass; d=google.com; s=arc-20240605; b=V+jWUboKExOkDtBEsgh6op3TXFmbACmxHYPlKXEbH+NrZk0nfppdSFGHYicVrRHRUs 5s3WzmjE3exRxdyHUGOa0FibFuPMnv0oLk+ZaEWrHRHrhGOqEn1AgYJtRP7hVaOgvs6H w4FaWAsTllmJB7J8ZMfAa5HOi0gnlzNvJFhANsUdmIDRcv3NZMZLdB8wehFehjuM5AbF CGqZr6TO/b8dQYH73a56aDGjMeoZYhf3C896CUtYveuASP0AZkpAStxNF5bEqp/mwA+K ev8nC33H7h7kPBRopLLCO2h1nEw0k5TvtvmANxOiWNcZFMDmzZvTUbK/weJ4zmqeIW9a czYA== 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=jT4X1fJzmBtgIkeIMLKd7lpK5bG/uEmq2GMtE87/95U=; b=G/r+h/Amd4yw7EcYcvdNsG2he0LhbfoXw5ao6GWtworGs9msjTbXueCPsBM16UTN6C jr9RcG9DvBaxqnCpzFLco9W6W+jqtZMzdD4PxeoX1yGs+s3r1Yo7T+fCHoIXUEvyNGup uNeW44MNwn+Uwe2G+GIXyaJ/hOzjQdmhIJTngKPSldjYhwHQ4tDk902pQVMFQvb+EW9a erOc99SSHt5ZODBiBGfdgh4fsACt5+zSytIwrbD26Oux7mQc5oe74PehrF95y5WGRaM2 JS1pdqTPRoS1V3OaB4FwxC91ORr0DwOLoSdLnlpLnMP/n5HAJNNDXoY5F7VrrsNq06u/ K3RQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lWM6E6JK; 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=1730202393; x=1730807193; 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=iWYVKLovD/SVaitdRhnMWleowM9EoI05xh1lmTp7Sof9theDa+9O9woQ9lQA/L8Trh Ki4YGIpAZ7efpo+8Jw00RtonAJ0F6lZCtZUN2FRb81cGNvEgMvXC2wqvHWvZl9oe2Lr7 Dlas6Orsx5OmsVDjGdJC/Rq+4xdtHBVJoUaFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730202393; x=1730807193; 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=bD778f0tiUeu0ra96RpM1CT9XWf5HzcMbJ2Y3LItDGoKKvKyYKlP8hGThIfg81wkDK 7DGgcxl9ffoAA0xL/N0hynskg74Vv+q/ybgv1196+VW5MQrktbR5oa9cxlvaaIZP9HvN rQgC9GNnSBR6XsLKZO1LpL18vjcLJMLbLBfIk1eWPNd1WRlkAZ2Wt9IWZk99DuMLOWuo n59aBhkNftrgm/HiUctQu+B5j0BEhUJwWz5QELkGDaDxPTvHtYTt8hFtWEnG9TLS/kxz Juvj0IY5LErzdPr/tOVMC1OE8MNrxTTG9oN6m8hYjcmgAdSVpsU6KyVNFJuHjgE2qA4C sUyA== X-Forwarded-Encrypted: i=2; AJvYcCU2+w6Up+PLQUJmIScFNnQPvjmsKQ6vnB8uzTXALpylg/uXCs1MWLIPghLeowd/dlkwoc/G4P/Oq+hH6Red@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YyhjqMtKEq0xyaXwBJNV3l9BtKhPfBSrPJ7NL98Fou5kVAvsbki O0milFWcM2POR7SuSCV7CX0RldCyXKpAWduoJ3ccHijQrLTMbT4H/Xts73UEGwiVaQ== X-Google-Smtp-Source: AGHT+IEslR9GSr4c2Sh0k+069SX0JI0jX0Iuc9llKzyrg/YSqd7zNDsvoGm0k2NZCQmeU2TjSjVjwg== X-Received: by 2002:a05:6402:1ed5:b0:5c9:709c:247f with SMTP id 4fb4d7f45d1cf-5cbbf87760amr11062702a12.2.1730202393321; Tue, 29 Oct 2024 04:46:33 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:34ca:b0:5c8:9f3e:a9e1 with SMTP id 4fb4d7f45d1cf-5cb9987a697ls103333a12.0.-pod-prod-01-eu; Tue, 29 Oct 2024 04:46:32 -0700 (PDT) X-Received: by 2002:a05:6402:3514:b0:5c8:84a8:5185 with SMTP id 4fb4d7f45d1cf-5cbbf875e3cmr8778051a12.6.1730202391828; Tue, 29 Oct 2024 04:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730202391; cv=none; d=google.com; s=arc-20240605; b=dyy2kW+3aO6wS47nfoybBmC81V+rGvtKKwmma03u+vrdLLEKM2gbxygOCYCcCP1GqJ Ie+r0/cm0skHw/UhRwLAUkIglanpVHSXa5yWC9WdIdRt2S3CYd8UpUJjBs1ACMVSErjI izfBG6rPMt2vwtFubdejVZjuDy/6x3dbqT+VzpUyqFyu/OY5BRkJquOsInHvlEX6P4vK ++5bn1LPJXUzBqJxESrbIjn94iF32kgeROhQh2CkphpLsP5Z5bSW8SUCuReOREiB0jef WnnRUbG2Q78Cbdly2AKEJ9NB1Aj3Auj1np9voX6ObKkORYU0tvEUsu8wX4UT57e9ys9b pJLw== 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=wYuTwriQNE0msTxJ74bxqM5Abn0Z1otL2URT6XDvkCk=; b=IBfti1V/69DWxFYINNpODTmgHpW0DTA9P0zzom2Ju0UmWMQHt3vUolmZtd1jnq82KW fWlGwh9P5+BEb8eWzWbgKBoAx7Uh4KZfimllZGISpcpCZOAZFp25kuOYfucqVLxypONL dIOSjlfJkCNrD3q3PooGl0PYL/MZ2XFL3bUX3Tup3WFr1pn2ytAFv+SJzPBgvv+2xpKf xhbU63aMgo8MOPT1ZAcmrDMpjWimDkvhyJjNKEwxmxxWvMnIEA9x5yWLfzC7e9n9KSLO oJHPlwNU1dejNuPFP0RbmNCTJja4+zi3Qu4CuJK23/oeUNDOFN3E3X6Tl1jIrZhO0YDB pm9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lWM6E6JK; 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 4fb4d7f45d1cf-5cbb634bae9sor3130548a12.11.2024.10.29.04.46.31 for (Google Transport Security); Tue, 29 Oct 2024 04:46:31 -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:6402:5191:b0:5cb:78b8:7056 with SMTP id 4fb4d7f45d1cf-5cbbfa9b3fbmr7045227a12.33.1730202391375; Tue, 29 Oct 2024 04:46:31 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.207]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6297a09sm3869301a12.21.2024.10.29.04.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 04:46:31 -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 , 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 v3 2/6] can: flexcan: use can_update_bus_error_stats() Date: Tue, 29 Oct 2024 12:45:26 +0100 Message-ID: <20241029114622.2989827-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029114622.2989827-1-dario.binacchi@amarulasolutions.com> References: <20241029114622.2989827-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=lWM6E6JK; 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 11:45:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3612 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4A1283F380 for ; Tue, 29 Oct 2024 12:46:36 +0100 (CET) Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2fb6261384asf37674041fa.0 for ; Tue, 29 Oct 2024 04:46:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730202395; cv=pass; d=google.com; s=arc-20240605; b=JLtIlaCc+PAHPIUOsNHowtlW2rIXKQ5+CVOSxbxo19kTT1JnRfW9bVVHz95kAkY2Gs w87+0QS5EiBUtW+nML31tYE3mq76FqLf+i9Bn/lZIraX3HiFmpiWgcftRSsle8wukqQK 8UyJc6DdPu7CHetrCgZ4sC+WNNRWwX8LLa3Vg5AEUY+4Yh2IigOUnO6yTHNwEtMYbl++ JIGP/R9262/Nn538Rf8yyUVmW2JGOU/n0A+ddu3TV2BPB3ECJf2Oukn52oXmIF5v7EEt WbrIlddObBJxtuopQz05TH0vx2nbARRY0sxbsnJ6W56oJZEdj1n1eBR5GvYqAIprV8XX eyvA== 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=+57Jq/zn+TLooGg2zBbludOM6jzDu3c47Jh7HKSONj8=; fh=rSGpMMEUipcgQPL8rn69J7kvyLCORf0Bg+Q3TbJibC4=; b=htL2aYdMaR40PVxJNYCATddoWAlA2dWsqLvvVgeh9WEFRUbIFHW9xPQe7QEU0jxAiq U3/xdoEbOZWO9hHi0u5ykkqLJv+ro5RdNfbBQYMDze2193Yn+yuS8cf+nCECqIkEa6z7 o4CnFrjtSkNrDVvzv9wrVLXPrILTRapRFAj3Kh/dQ+q1ha93a/F3L83ZrcjNwi1KjFC7 KKwMI5K76LoOCVBZ81ggVXxiRUalK9d3zLE/EYEb+xjuweq5gXbImMKbMSdjMf4qWFUu tA2a5PkLtBUwI+go0ArhmaAB5gezOkhnx1kgRowyyOU/uKKWD4qTY0CX4vvIsruLEozn enmQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ewM15Hv+; 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=1730202395; x=1730807195; 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=+57Jq/zn+TLooGg2zBbludOM6jzDu3c47Jh7HKSONj8=; b=i6C6RmrSHZI5HfU9XxAlAKXdTtkMxDgMP8Co3toiby4D6pvnbN80Y8zOPv6hrcxKrD RwdvpHiyc498lcX5KA9qiq1L8nnWMhWgYzcHD4lgQNsNbMUVv9cHa04hJg9IBNnjD9/S pqg4Or452QrCUC38t9H2Y9UZ4MoVfir8ynUGw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730202395; x=1730807195; 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=+57Jq/zn+TLooGg2zBbludOM6jzDu3c47Jh7HKSONj8=; b=Yn53xdEpz9uNTw2EE3y3o4j4d98G6al2vko+KFLcaOf32mBGQWN4gDYk8LISUAkLBK 8f6Tx3qVyxgOkYn7FJbJE1ghmBiEXJnsrxIbPOSHobxbGK/GPPd89SOdMfklS6MtV1sG nM6fi7TUIEMLM/JZdwoSLJ9gALm6PxjaUMNjdv/NymK0TLqTgTB0b1e9k7Pv8N4DqZqh uo4v9W1yfxHgQ+4RPA4XiKtPMw30qSSV655Dq1TfmjaiOm65DpuVTvnNgXuvyQ5V631r W4K9WrpNk2aGKTmvmk9CWYsUopx4LQBNIxDyyjtmyGBdpopgVUbyVkhBAh6Lb4HsAE40 Wzng== X-Forwarded-Encrypted: i=2; AJvYcCUm3o9Oh01bRxvcF99B3eB94fm28AQb+9Jj6gKmSx3us2aX+LQU6J/0ugjB9M94dYP3cg0+sNXCPoctxZA8@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yz9x7zkX3Dqm0vAZQElIatih9V6drBBnJuKCbg1sRSJGay2Owt3 vsLa1LkciQMZV3wfRMiY+4NWKdP1JiB4VLTZGZNVhmogwBNOR9IvFaTk+JSgHP5//Q== X-Google-Smtp-Source: AGHT+IF3RIkyirmuq56eW7pxZUkTikvipQBbyFOSzxYTJr1UpEbGz4mATo6fwDEZd1/ewTU6o+vNBQ== X-Received: by 2002:a2e:74f:0:b0:2fb:382e:410b with SMTP id 38308e7fff4ca-2fcbe0526a1mr43450731fa.32.1730202395385; Tue, 29 Oct 2024 04:46:35 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a50:8712:0:b0:5cb:def3:f877 with SMTP id 4fb4d7f45d1cf-5cbdef3fd4bls74417a12.1.-pod-prod-01-eu; Tue, 29 Oct 2024 04:46:34 -0700 (PDT) X-Received: by 2002:a17:907:7f14:b0:a9a:6284:91ef with SMTP id a640c23a62f3a-a9de5c94537mr963823766b.2.1730202393740; Tue, 29 Oct 2024 04:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730202393; cv=none; d=google.com; s=arc-20240605; b=Zy3hhDR8o3GEdtZw+FG/lmw9V82F6Lj0b7HMWbL23VNKI+5IZZtv2U4Pjkfg6yK17V KFCuJhfblYhpc/dAHG73+m3gNPJL+HnF5tVwTUIw5BWT6Y2WaTKjJczJNkYo0EFKpJGI oaHTp5ush+pStuIDLs2DRIGQvErDmJXxK/ewYCPOOB3x7VKHiewxCobr5knyAe5gKDmP lgVopM4F283vq8bi1wkMZKrkuNtgdkQcXRITVCT72BIIwRJdA1W1rTYRKwLvSs5Imi0N CIF68Eqsw0UEpTYnHje2t6DpUzgV5xHgVJJwgSK3/W9EX0c/hJFBUUBQQ0GbWDAAWNWS Gz2A== 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=Nbw+NGEXr7m2rV0cbMmuavLOG9IUHHd4c12xVVX95f4=; fh=ljoFiwPup6gC9YG4NMWOEWNdgUd1CKjWIIwpUvYy39c=; b=jpNDrrDhOhbu39iehLi1r6DDQG5LolAQcYSzXdrf5OaGQZqeSH1RuKFuQ5vznLKYzr fNiEvE+Fpkhwtpxr4rPBo6YMVfKRmG/8663/nTv9g0OSwWNwyKQSRUyCsvWF7iyI2uIS J+929ArefXMbXyZMvdQ/9k1xVVAPJ4N6kmuJV0Hva9NOGszP3Q0mCi+tqd8VKjcVD4eW RfxERBX3XttniDEh/GNcgYlnAAEBdBnaS2b2ScOcaj5NFS8qAIelU/ydh1ddPk8AljPP LCGByDG/n/Qvnu9V0at5JzuG1amypJRdSWEmUT4xgxORrFAX4gGkutq9mZS6No+C/stG WPZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ewM15Hv+; 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-a9b1f028910sor377557266b.7.2024.10.29.04.46.33 for (Google Transport Security); Tue, 29 Oct 2024 04:46:33 -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:6402:3787:b0:5c8:95ce:8cc2 with SMTP id 4fb4d7f45d1cf-5cbbf8b20c8mr8968166a12.16.1730202393242; Tue, 29 Oct 2024 04:46:33 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.207]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6297a09sm3869301a12.21.2024.10.29.04.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 04:46:32 -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 v3 3/6] can: dev: add helpers to setup an error frame Date: Tue, 29 Oct 2024 12:45:27 +0100 Message-ID: <20241029114622.2989827-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029114622.2989827-1-dario.binacchi@amarulasolutions.com> References: <20241029114622.2989827-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=ewM15Hv+; 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 v3: - Drop the check of "cf" parameter not NULL Changes in v2: - Replace macros with static inline functions - Update the commit message include/linux/can/dev.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 0977656b366d..da85c44808d5 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -168,6 +168,43 @@ 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) +{ + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; +} + +static inline void can_frame_set_err_bit0(struct can_frame *cf) +{ + cf->data[2] |= CAN_ERR_PROT_BIT0; +} + +static inline void can_frame_set_err_bit1(struct can_frame *cf) +{ + cf->data[2] |= CAN_ERR_PROT_BIT1; +} + +static inline void can_frame_set_err_ack(struct can_frame *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) +{ + 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) +{ + cf->data[2] |= CAN_ERR_PROT_FORM; +} + +static inline void can_frame_set_err_stuff(struct can_frame *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 11:45:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3613 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B1C483F380 for ; Tue, 29 Oct 2024 12:46:37 +0100 (CET) Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2fb652f40f1sf30238811fa.2 for ; Tue, 29 Oct 2024 04:46:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730202397; cv=pass; d=google.com; s=arc-20240605; b=AITulQ0jagjjnNE/rd4vSwgcR1+od2HmNzOW1jkWlAobCGCGpoNGTRkyVU4bdFWqkO 9AZ9l9lIz/CKmUti6tDJr36X0uEwgoYNEAhtkEIH1GbJg13DEtPMpVzhYeR/S73b4jiM Q8ZTvyeV/GcgHukUh6hDiSFEJAiFzsKiqjU6S1KrjthRYUADGm8eyONGFGPitX9/vbvT NapwM/tQi0F2HtyO/Wx01w9Yx+YEjdQUFOwDFkbSNskNSM9ecQuOix8KPsKE89PIBDkb 3EnPeBLEYX8JdZl7w2jif48VXwmHogO4Fx2MN5VGrUhWFPN56kKtdvVjeE75dGrV0GA2 oIMQ== 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=26iPgoH7SqpLp1gxhPmKHGw+jXCTQ+96lwpSps8WP0w=; fh=5r9pV6ubEtCnbA96U+zXSLN5nrK0spgBW+ApfSZEWeM=; b=hUzRkjfI/A50ycHbLXhIrgySHCnKAnWkb6er6CZRBJpKJydqAOOft8memmeZKkNBeF PzjOPubCGro7MoY6dP4WF/7edertUGcqv5TzGlehVoeU+xU1G8mQRqcJ1ghpPPD00NeQ t7P0S/Ww7QLO231lj7Jp9FXdCljWc9aSGt4tJAOMP+QOsxkhTKwFmCgPW/x1iS2sByef zxmt1hzg+nSa0DuhTKHKCppsRcwwKlqZjA7jdoRUgnd/oZlXI47ZLSHBRuJeJfwI7Acb w4GXB0udlfAOCfguPmKeNR8MMToCgFS7C0D9zc5RF6OGwbBNsLolCMTg9KKOSPBxsgpy Uddg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=eixpdWdW; 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=1730202397; x=1730807197; 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=26iPgoH7SqpLp1gxhPmKHGw+jXCTQ+96lwpSps8WP0w=; b=YbVuUqHgn+jDHjuqHfJHWW+suD1UNxGtmGSfEA2rVFcQEsrxcL0il3O9rm3uieSvsS 6jb6XzoxI2lLdDbL+I8feIO/0eNZcS4ey1pmyRwx/E1QPXsX7GFhGDcAhaXLPD5ydenI WWcU11R+MVDm60iY0UCuvxnfLoN8YS+2nDn8U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730202397; x=1730807197; 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=26iPgoH7SqpLp1gxhPmKHGw+jXCTQ+96lwpSps8WP0w=; b=uEbJ9hLOTny8WDwSuj40VRl8xnoIRP9/kespFrMaOSz1Lf/ROQDqAZjSHbDSrKArjK EtUyUfqmN9nZuY/SvGgoeUPrJANn4b9l2p/PpQajB2vMQ+giMtj/RuDpOJ8srEWSUQmP dCUWoph2716+WQuRHCtKV4xXSY2Ejd7SYlzqECBMUjRGCb5Apiqk9N9i9ql7rVZbA3eA 6/VavK2jtRzdW6ZT8g3Rcmtj8nodlguOV/EgR/f4u6UDLBV66XLLnom1WwfoOhVvej5Y 7G5VklP8DcfsTRhqvs4QuE93XT7FkdFvsp2LVY4brI7Lm1fs2HoBk3sql8oB2atrosbF 6iLw== X-Forwarded-Encrypted: i=2; AJvYcCUwLQwBwQPFbjEeSJOXRwrq4W73eL3sGkWbmJ0DinQdii6a+ZOZHmFBDrNCCMmN6HYEIL1TbPIPJqtz76rk@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzAyWdgrEX2zGW9xDOfZgIb/H9xh6c2QTZJ9q42xFnfEajoVSS7 p20AzLeRuAOSs5BgCPbu04Dbq0+o6TtpdAaVkNAlX/wwb26KOZpiHtLZ3Hn3cOXX7Q== X-Google-Smtp-Source: AGHT+IHRGEqaJ6uDqC4QL6wpdLNksOboNO/vgs0hACVOcasulNA7xPBt5C2YrP2oizpUd1LEiJpdJA== X-Received: by 2002:a2e:a555:0:b0:2f7:4cf1:d6b1 with SMTP id 38308e7fff4ca-2fcbdf66b57mr54326941fa.1.1730202396975; Tue, 29 Oct 2024 04:46:36 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:4304:b0:5c9:3fa:8237 with SMTP id 4fb4d7f45d1cf-5cb999db1b8ls223755a12.1.-pod-prod-06-eu; Tue, 29 Oct 2024 04:46:35 -0700 (PDT) X-Received: by 2002:a05:6402:274b:b0:5cb:7318:800d with SMTP id 4fb4d7f45d1cf-5cbbf944389mr9579756a12.32.1730202395276; Tue, 29 Oct 2024 04:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730202395; cv=none; d=google.com; s=arc-20240605; b=atIN1AxClXy9C7v/8VssQLio4PSXIIPgcHkg1zaHGHhEG9ejcKGysMK2xV2U78+OA1 /0nuShInrno1LgYCkCTqIDlJdsu36jB6aA4+3t0XT0+QzFL3gF/H7aqACcnHON4q+rcQ 8xAJDtA7kdPzGU64zQ2caLPq3uFG5/egI5ZA9JHrOlcRx9IHMSWdXEeHqFpb5NrBtGet RmGHMWmKKe8bakuuuK18RSon+rCqPY/bPMVd5AHr6Vg85PRCU7qdugHQ9DOHdTEgWMDF 1DKJPYiatb6VuXhOWveHUIrSnm7QjmH6y+CLJKeIziu6euIchmoaIZxZzxoXqbi3zaIz kaXg== 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=7adbskWkIDNXIMmiplteQ28nVqw9eSy+g9bzGzeRhzI=; fh=AN9L5CoWavkH0m+VViOuW5WBipm7OLsuifxuoqHOyS4=; b=FDxAawv/3w+5gE69y9GgU+jUuxpjPO80cZv+uQF9JsazMv+GVmBAz/5g/+MJLEWXOb G8UwZ0yt//5czrJGzH+YsIUy0gDc2hf8C7+DjUJgG2Qv638Bu3sco9EFi2CZ8oi3ewWe qWlIQs9oqqlKBbdYRyymSxoGW3ByAKU93rk6e/vtKCxygBcRbp11I6XnX6vuY5ruSKr0 wv5Z0+3GjUJ/inYPp4mYgHQUvQFbBWDcpjvy/nvuYkK+2mRwSEDb9BfXvzFmzfnxEmq/ oQTKi/7gJK5U/FkDay57cmw/GwOjYjG9q0gaLJmENYOL7G38ip9CQ12edcycHDNXqWdV zddQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=eixpdWdW; 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 4fb4d7f45d1cf-5cbb630b661sor2969790a12.10.2024.10.29.04.46.35 for (Google Transport Security); Tue, 29 Oct 2024 04:46:35 -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:6402:43cb:b0:5cb:6ca3:af96 with SMTP id 4fb4d7f45d1cf-5cbbf8acc32mr10238323a12.19.1730202394731; Tue, 29 Oct 2024 04:46:34 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.207]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6297a09sm3869301a12.21.2024.10.29.04.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 04:46:34 -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 , 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 v3 4/6] can: flexcan: use helpers to setup the error frame Date: Tue, 29 Oct 2024 12:45:28 +0100 Message-ID: <20241029114622.2989827-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029114622.2989827-1-dario.binacchi@amarulasolutions.com> References: <20241029114622.2989827-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=eixpdWdW; 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 --- (no changes since v2) 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 11:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3614 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0E0CC3F380 for ; Tue, 29 Oct 2024 12:46:39 +0100 (CET) Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2fb6261384asf37674371fa.0 for ; Tue, 29 Oct 2024 04:46:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730202398; cv=pass; d=google.com; s=arc-20240605; b=BUHJOYuV/cYfvmzsS7S1w1/5z2U5aoC5Qvr7dzcjdszHrvpWXBO3tihZvNWdtynwDI 7pTjqTpEXAiNYATnJ3YqLI2fSB9OCOXegn36y/AIBzSy8wR/n4poUGnEaabrzPtppK4D hGDeVk/wIxXns7jZyhEEwYsVsm6rJr2fWl268MBovxQ22K58QyCpSrNeegpp1iDW+FC3 pGEiFEH4B3WVwewWJ0YzKfaeGp5h6yyyU6Hwu9oduix6jHSjz1h9avOwVMEzotj2IeKD MhBp0zoH2f2JxK5nQhxLnPVgcevh0ZoVhsDkGPl4CMzbpoHWNzqqV4JeBHgPyZrJdLsv Y6HA== 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=3RKczPTWVJdhiOZw3GPIut/lrrq63i63H2NqqauekY0=; b=k9PoOESHN4ZtC4xFmdo2jVj7s0RLhxrCOBrDuKQGl9TkTbUohFa7ybSUp5oQ+rOo8u v5xJOhSlivI0nI4dmCFa9aryeFndj7DiOBh5L8thHP9AItJu+4XfHJDVu3TzR3pDApy6 guUg2YasySUIToedvFn2DMyafqCnxTdzrr4byD5hLtf7/bf3i1owwbn12Eo0ma1GW6o1 RxiL+tCcoIOgGifkzLbE3luKTQ8IqpJHQ6xHjdgo98pteuxom9aWtp8zmKLLR7gLUcaz YHWowXtQSg90LfqVBtRkMdDpnw56npB3ngtgubol7Cb3PWw9rSLb0FiwxbQLt5kwdkUS FRGg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CquXmnG3; 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=1730202398; x=1730807198; 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=Ba3SXnh9r2p6id/1QZPf+mUiG1OkkZ8h6qCQaifoYXGANSz9a6YJQcju7JZhewa6q1 luezkAKVSFl1TKOIMxLAds2GayeRfVbGZCFO0QqQIJ6g9S18j2aFZXTSoW44BfaB8zJ5 80vD7hKsUOSJAb/pLJgkjxQGSdAF1DMECJ7DM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730202398; x=1730807198; 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=MQdQpbTpAwq9aGofY+5IhY3wYMMwd+VD3OU8el6olX8q4PNPns3RGYgsUv8AMS3JW0 urmRXXvzFcSrxc47qGOB5rmKMhNTKROQ9IfJjXkX7Dj7o7bAlXJ+tCgScZ9RDm8bPRU+ CgvYZB4mXA92LpdEK8rhqYt0RY8J/JoRCglec+xAXx7jkDFWgr93qQVEHwOE6X5lnQ8Z zubvZc/g4Z/EpEYFgkcmSwiX0xLUeeIkZ/4jbrdeqyWIsLy73ZSA6YvCCFiZNBQLakto cmS5+aPhYE/UeMOtlw0dEFSb0NaMRyfRyD+CB1FnLHyL0jJee2TUEPBY85OhPfkj4ZsI +Atw== X-Forwarded-Encrypted: i=2; AJvYcCUlfHdash58DoWs8znkK0KigY0L6OHjy66A/hI34FruXmLCQjeCwKy+LU0jJVrZ6JGe/v8hpiIx9V1DZbzg@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yyo7g00OuqyDsDxUxC2U3ybu9VpfolTW7Xc+UduGoohcKsPIR6x RQwzvrL2b0GC5QeaL3tZdEN4/8XQoyvYfNVaK9SPgETlnCfZyUPNd5yTJDFaO5DX2w== X-Google-Smtp-Source: AGHT+IHKWjbeUj+8KOUpJym3M2YDeH+Q2mc0nyCoLIbpRnbGcoZH0O1EZTAOp50AiT2T+N3NBHVFZw== X-Received: by 2002:a2e:bc15:0:b0:2fb:4c5c:3f7d with SMTP id 38308e7fff4ca-2fcbdf5ea97mr46751991fa.5.1730202398411; Tue, 29 Oct 2024 04:46:38 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:34ca:b0:5c8:9f3e:a9e1 with SMTP id 4fb4d7f45d1cf-5cb9987a697ls103411a12.0.-pod-prod-01-eu; Tue, 29 Oct 2024 04:46:37 -0700 (PDT) X-Received: by 2002:a17:907:7f8d:b0:a9a:29a9:70bb with SMTP id a640c23a62f3a-a9de5ce021amr1140141866b.14.1730202396987; Tue, 29 Oct 2024 04:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730202396; cv=none; d=google.com; s=arc-20240605; b=ZtWLfElt41ZdVwTXe9jolU3apDBXH8cjrlJgBYc+PQxnNvsxDRromfnJN3GHctS76i qdOcdwlNQjMWuLNEJxKvwGtUIzi+TgV+mKInOnFrTpDyCMHrfrY5Jbt8FHf98rDynnRy q5aq9IRhhgdFqzeu2lcrCWwzQAj6PsxVbduQZLqVkUB66CUkeWm0wXa9FUuVgFcEz0OT eQ38Iqm29LSf4QElyoCpvCpTPtjANWq+sfS63d2x4yi969fNeD8fe3q3pe/8/ZSZEbLA TYOkW1/LOrKbtnZ3UaC8cpo+iyAHa6yv3HoQv+zk/CavRbi2wJWclpDyocLdiJ9Y0Fe1 CLYw== 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=LP3lPraosk0AkQgue4WX3UIFffD6KbEkWvCVxgnBsY611cVHgoK/jh3/k0jpU6dW+D +QcnEVly3ZSjlY999WLgbo4SxQ2GM9XUfxsysSZL1aJPssxQc3aYELbWRhX+Sp9NdKJW /4C0ZZDJkr5F0yXHoH4cJE0xhllztoY9sOr90MxbmjMWzQ96JQzmJaQVBzRNmZOv5d7m P8kYUngZz4fmXa/asbwaxLaOQPXbCbOBA+XzNaFrCAyhBrLVqhUBAcKbhZXHqsicQ8uR wESC5xbenzamwMrRa1oNxa2EWmZXZyhQzOys/Ndhn57WMyFc1dtZQ4ddSa+ZORF9Zxu9 ZtQA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=CquXmnG3; 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-a9b1f27d174sor376834566b.15.2024.10.29.04.46.36 for (Google Transport Security); Tue, 29 Oct 2024 04:46:36 -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:4fcc:b0:a9a:3dc0:8911 with SMTP id a640c23a62f3a-a9de5ce1801mr1152393966b.16.1730202396546; Tue, 29 Oct 2024 04:46:36 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.207]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6297a09sm3869301a12.21.2024.10.29.04.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 04:46:35 -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 v3 5/6] can: netlink: extend stats to the error types (ack, CRC, form, ...) Date: Tue, 29 Oct 2024 12:45:29 +0100 Message-ID: <20241029114622.2989827-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029114622.2989827-1-dario.binacchi@amarulasolutions.com> References: <20241029114622.2989827-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=CquXmnG3; 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 11:45:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3615 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4F1CF3F380 for ; Tue, 29 Oct 2024 12:46:41 +0100 (CET) Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a99ef476aadsf391907466b.3 for ; Tue, 29 Oct 2024 04:46:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730202401; cv=pass; d=google.com; s=arc-20240605; b=BYM4PjQabfvMEfYbtcyknsnS0sfxAmznVgLq9emEh18UhTCbL+KI7ge36XXThXaiEM Ai82FfQ+BNBirenGCuqDadox781GTP3yOzm4olLP+GwQ7Q7ERWQbxyV6gOHf7BfxYixI 8EH1VGezMO9RIcJTFFfOWPxKeeURgheFmo35xW7EwXCK24UFK8O//W07BFCvPN2Xw6ED MGQl+xb71PID+crJHe23t3rbwx1S5mIwzGwTC/a4oHNLWrMc4B/Cv6jp+5bjaUQfafd0 Z0eGfVsSTu6HbjjiDtSKlYOGZsQfUANu+oeSTTIX8pJ2PgmYvzArAVHaCDfmDxJLoQiM H9Fg== 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=NMGySHPiPdyQY8WQnND0JdgFZMppjc5wcHJxzUS3diI=; fh=r5VzwhnQWoE56rbJ4I0kPJnDbtzGKstWWaGQXc0h5F8=; b=E47y9TEv0QN+VExEBelhtVXxag2JkQMrQonHqodlDTU+rN0eAdbCev4puLAsJ46nnU Geks45NDgsGFZAYxkV12ACZKH2iC/8qPJeAVQh5VJrG5xVlZ7BCkXtkLpkuBS7S6d448 3mm1x2aBP4kEc016u5RobIB+fDGvNOfKIFlpSZ+ZMGS+FnF3cUBeHgxqW2VOJXrQnimp 0c73vNgoTYjYXNNnrFlIah17QqobM/5XNvAkj1iwaiwqMDUWQRWE4UMEsTWD+SVvNt0e KdLxBRiPW86Ibn8t/1uMCE30RCPoZQ5AOSzo1oy7IzyINGYuJ09pDgBeG/pG5TxHbcJv Xb/Q==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=M1WlgsQq; 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=1730202401; x=1730807201; 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=NMGySHPiPdyQY8WQnND0JdgFZMppjc5wcHJxzUS3diI=; b=l2jGkOVlEguphSw3YPMyjPL0k/xmUSDmM97yL+iQdozon8aZUXTjSoNga+3M1YnJ+V 00OCEdriMTtJVJOMecJ8xzQXg9ROpWu9SSOsCg09pqwRfRKSF7txRc8EQzDARh8xzSGK r9lHK16QqVjWBzq8Po0sXU5L60hLuMBfNvxgQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730202401; x=1730807201; 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=NMGySHPiPdyQY8WQnND0JdgFZMppjc5wcHJxzUS3diI=; b=BydDlkQGWO72i/912rpW6AmFOO0wFjzXPTVAGopeqHrq/5kzqt4M+H1sLj4Zp+DHVD 71fUxk7A8rVuOlP0MVTy8PnxCEl8ukXnNV3n83Z0bTtZ2e60CeOoRR+HuYUG4MUceI+H KV7gPC/w361Obg5ZmA31ynrNez+SI1U16ZwHu82MPGnxTUPgdMWa31jN02Vgb1ujISB1 6H6OG+3/O9WwWrlMAzWMe9wZwPQHzhRAyLpVcTCL9xqaHjsgPJO8GByKNDzQ5wSZv3RU FtUCw+WZMk57E1M3RoDB2npKBmXp/4dFWjcsP0dFbc9maj5FQCtvrYa2J+I3+sRHzM7z 7ZNg== X-Forwarded-Encrypted: i=2; AJvYcCUalc+fM1wgrkxS4qGRySWVNLxjrWpYRUgzDNEW4HHaiZxdRie4ATCZjLOT5q8v5WFGnE3VfJiSuwNRfDxn@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzjH99jjdGeu/7JKaXQzaUT7Y5uqa5nhrR4+TQatm1q0zDHocUQ gxkpX2JhZBmA1HV7OJEpys4wNvp8Mo9pF8UCIkhPdzdmQfWMjxhQTNptLjvSbt43SQ== X-Google-Smtp-Source: AGHT+IHrl7MMx2BYmD28NlOOccoYCbcTmclPfx8jZzHmgFqG4+bSUAj9ijZ7qj2762IVhHrXcg12gA== X-Received: by 2002:a17:907:7ea0:b0:a9a:17fb:4c40 with SMTP id a640c23a62f3a-a9de5d6e1e7mr1049138266b.26.1730202400946; Tue, 29 Oct 2024 04:46:40 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:2685:b0:5c9:393c:c093 with SMTP id 4fb4d7f45d1cf-5cb99892356ls324951a12.0.-pod-prod-04-eu; Tue, 29 Oct 2024 04:46:39 -0700 (PDT) X-Received: by 2002:a17:907:1c9d:b0:a9a:5b8d:68ad with SMTP id a640c23a62f3a-a9de615abc0mr1167097066b.48.1730202399311; Tue, 29 Oct 2024 04:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730202399; cv=none; d=google.com; s=arc-20240605; b=FCqioo/hpoLeuxE6TBL2jtZ37E+oCk8AUTeJpN40BdLiNaUN56MsPL4NaKS4E+M4PV yqprnVRBHodZ1FFo6DqamfO1AIif34auAfs9lJcg+VHMB0dbbLq2LmHEIthnMY8ryYCa Ub0V8GYEf6WnBMUxSW339ZjVGZ5/WnbThrHLHyTbsCdbN6hszbn19zZuzjxgVfLbkhD4 Qk8vPXvzu/TLv8i03lt68bcWM4aFZ94go/YJlxOFkQAJmcdkav4NiG9tASViKTItpJIu bAeyb5UDdf1ZniSJJSsM02LYx8XHv/6sycsuiNO+teX26rtz1jFvJ7j1QRPDmvpchVSU 4Okw== 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=I7zf1SxmTLYYJKdIBWggPPFkkyvCdLLyYv8BJT477vU=; fh=XNsyLSFywvcB+sAuzGLclJNyI9UUt5fTbiZ5KzXlvNI=; b=e48VpTuY3HcDvY2rl5gO4FY4ENK7A4jGsp8gR8JmbdEQ8KecUxqjj7lYaGInAU6hUK ikyu1yOvb1l9wA4WvqWmCiNbmWFvtYQOsb8CGl+3ppItIMJK41jbt5f27cVhCrimWymK 45wwuwNpv/8y8J6DUQgqZh/e3PrAWPFlvTrYraQ499BEhfpsXwOpOgnr70AlY4QzQ9fL BryhjhEReB9dKKtaS5yxUVTRDQ36ABl3P2ve5zjB/ASyaOxg2NftMIqwkAYvfbno1Ggn YaOvl5rDha4HDSCZztiJD56S4NfWQ1PiGdNeQF+7/Z94jmf81wDWNWw/7IjZzAwOd+5D JIdg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=M1WlgsQq; 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-a9b1ee3da15sor377503366b.5.2024.10.29.04.46.39 for (Google Transport Security); Tue, 29 Oct 2024 04:46:39 -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:6402:40d5:b0:5c9:4022:872d with SMTP id 4fb4d7f45d1cf-5cbbfa66f3dmr9918447a12.32.1730202398864; Tue, 29 Oct 2024 04:46:38 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.207]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6297a09sm3869301a12.21.2024.10.29.04.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 04:46:38 -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 , Rahul Rameshbabu , Shannon Nelson , Vincent Mailhol , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC PATCH v3 6/6] can: dev: update the error types stats (ack, CRC, form, ...) Date: Tue, 29 Oct 2024 12:45:30 +0100 Message-ID: <20241029114622.2989827-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241029114622.2989827-1-dario.binacchi@amarulasolutions.com> References: <20241029114622.2989827-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=M1WlgsQq; 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 4ad0698b0a74..ed2bdc6fe4a1 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++;