From patchwork Fri Nov 22 22:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3653 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D4B1D41386 for ; Fri, 22 Nov 2024 23:17:04 +0100 (CET) Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-38243a4ba7csf1289150f8f.1 for ; Fri, 22 Nov 2024 14:17:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1732313824; cv=pass; d=google.com; s=arc-20240605; b=P/3wskjPDzlDXC7WPPladJs8Dn5UDKvHHEEoSvArC+xuIUNoqcUUibuwHkGHAZ4j1p nIlrRfxvdUG+mKMpGG89iyUdk8JAmnukl0rMqTqs22HFg9oD4V6pMygyU56uQhhpF2Yd tnL+I3YKylWF98JZRZDr2n5pA2AvsNBWEydu3ujQqk1W2MIiJhOnsjxbBK8wR5OotsTw ilBWNmpWld754/ZxktbqFySccSRXjTu0grytc3S3YX8BkrSd8gOKX3Mqw1SXn89eZ93q 3FDTBhD35fe6SCDLyN8GRFLGFiXiaZqG4utwD1AVvvgiwAS5B1HRJ9AmrfFp8w/1hlsL yueQ== 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=gonCBIvFOWlF1nDkfbrFZzIni2arqdoj7Qey+VF1wYs=; fh=LeZW/T4JeP92gHF2O+TAFtAoolpddrhJRO1+EH968xk=; b=XkXMxOr2pkN98/3VfGwnGWOcHANos1O6g9Rz86C2hZt6MD+IHuXir441vFrM+vMecQ iZEzcTLePVtgr77hZ3agXPMN4muKDYyXyyHILPlATX2jcst0zwVUIkLTgdGZURANCv/f eFHaEm7KiZa2efhBWyk2QYc3torD2i6YRE4RCUU2ys//xYlZvN0CDwRmhkRwe2ZPrQkQ ZkdW/F1XFwh/y4QVCgLeMNhZaWwoZ7a+AlVQnlPAn4JPTJoSkgivpkUUZoCdFAwiA6U9 /xyg9aTZQVYOx+6IXBaqTP882VGBIn4UJxdnt0vtfIw4eveRs9H7oBULuFCss+h6LCl5 lkzw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UN18G0Og; 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=1732313824; x=1732918624; 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=gonCBIvFOWlF1nDkfbrFZzIni2arqdoj7Qey+VF1wYs=; b=jw0SWhK793j9n09HC2nLrIp9S31X/skg5sIYe/idyeUcAYTz92Hn+XFAPznaI2qJVT KGoL/dI2TWUtTUnUqz+cAkaK70mdD+heOEcQ7i10URYMAKELDCns1NtqD9OTdEXLHTsR A0Mql+V9K8//yNPxMRnxbgKiIcwWgEVHaJ28U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732313824; x=1732918624; 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=gonCBIvFOWlF1nDkfbrFZzIni2arqdoj7Qey+VF1wYs=; b=YkV9VU/gHG7/r7q0SugBWLEj6AIn7Y0WE1SNubxtY5OP4oCrh+TL29lzNyjh6oOlFI 9/0AqorHOuXAeqa/J+oBjngzkCZf2dDandZjH/46FQLcMAgLENiKfQX2NYOKnhlrQ5T5 REzrc6ENlmdvWS+DA+5GaQFzbMhL6/0lRiCKkJRAN2nKvQdvP8kv3pkZdWcPihco5aHh ppsF9cKo2LlDTLVCl6LVQ/2YnS8G+C6lqaASOkOEHIhoA/OSzhR5Iy+qTh41pPnM9/v4 t+bs3b0nA6isfPASEuING25wOkEGbIyPC00/n0kV/0uKNqvJwBl75kuM1tyeq8U3TAWF tqsQ== X-Forwarded-Encrypted: i=2; AJvYcCWWKtJeteRtsyCNa57MOCWfDSC3KgTfK4YvwYTTfJjNOv8aSbo02hsjnCjhD1E9ELl6sL9mrbTiFWOrsek0@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzQ6/xDUgM611CuaLLkoM2DEhJ5y+Ptv10F3imzJMUXL+DHCX87 uDMFSoKwOgRdlgo6GnkWfrf0RxSKRsdyOmmSIm8MNJXHlj9qVmmJR+yqz6stVAxCTQ== X-Google-Smtp-Source: AGHT+IH4Ojc/q3ZVh8QUQrWdhHU9MUYYNc1K5oqm7fXMl6AN0oV6+3CrnELZtgUty/reVsDd9CCDbg== X-Received: by 2002:a5d:59a6:0:b0:382:383e:850e with SMTP id ffacd0b85a97d-38260b58a50mr4305049f8f.13.1732313824451; Fri, 22 Nov 2024 14:17:04 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:4305:b0:5d0:e0b:5536 with SMTP id 4fb4d7f45d1cf-5d00e0b5ef7ls318315a12.1.-pod-prod-09-eu; Fri, 22 Nov 2024 14:17:03 -0800 (PST) X-Received: by 2002:a17:907:7785:b0:a9a:1fd2:f668 with SMTP id a640c23a62f3a-aa5099bf60dmr377309866b.19.1732313822614; Fri, 22 Nov 2024 14:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732313822; cv=none; d=google.com; s=arc-20240605; b=HjjxILK6K+GbbxDcZG9w560dH0QbnUJYucEqzZqBRGMkgaSy331zVcQB+tvqBI6BPv qiA4Ns9tMdkVKD22l/fjp0E3vD+hXjT74inK60oEn/J6+Cp/yP0gHYGS/tkfsNqTkNAq dwsjncDYwedzt3q8rlVZuGSuAPlQnZSIbo54wwKOHmSn8s6IwIXRANcKIB8R/jkrqO31 rKrD/plvNvxMBjJjW/a4AMW5o+A9dvIHGUGZhtRguC9epkeH9JN00pPNUGoYoAiYbMRs f15/WyEVHpX2MYE7DjbYS7fBLM6vKVroQ68wQoxSaZxvRdCG479jVx2wzHi6TLK/3oYm JPHQ== 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=hTITGD97t4sTBt1UReGjyzt5Hepohw9TTIeQjkSL1bk=; fh=wehOksc4GmJJCVDEZOemgknpBXE+pBAMfy2IPOPNJ0E=; b=Lz797KD9BD0QYoY3076IOZ99QTkUcDtocE5qZee/Ug1I55EDCWhhz7MtC68xKHNbcV YMQazelFtewX+7HjU1e5NgI+YycRKNVo5p5Hvfksw6EZwD8/Ff+S8rtYvAwZZcIYNrmt IR/SiUEDN2NvwN6/Ly4fWJxuK+CCDQ5AyYtaa5njXpOBH2/Pu2gJF7/c52SZ0FKRnjqS 8amxCm9REzEVxlg1cFOk15w8bN85o+ygjJpVSAb+Z4ux9PHjix1MFNIzVp2SypMqd0gu mOWwgvUUW3Zw+U+lvB3x1bWAYAJkyUWoRRVxy9z5qVgFey62Es2nROPYUOnNoF+NBs+3 C3IQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=UN18G0Og; 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-aa50b58e803sor75423766b.16.2024.11.22.14.17.02 for (Google Transport Security); Fri, 22 Nov 2024 14:17:02 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Gm-Gg: ASbGncvOmdRlx19n5ULEKH5gF2tWrd4irTpk1t49fuhoibWI0RpPE4wnGFOAnlYYFD6 Nf4xA+sad/CjAutbOp4YybD97886NSNrhZBe5IpE4PCinjhXmsZiDmfEsIScut+RYwc8Yktad94 MBhhyggNrJxGJWDEEwf9Ql8SaEtZDNE7yc8LGJccS2WJVVXaijLM93OBbSgzY5gh0MTnADvEcrK CCoNfwoP5dgF8VjTVD4hYfVvou0qx3mKBVivkHsj0Vha8H1r4Nwh6K0z39s7rHspvZ98oiCD09s PAIrnJm7NsEf47NjNRJmBce+/83ezNhBZPdVO+xMyiKdbTXGZJshi02Upt2q04s1nhti+sHpp/l OyXMfPT9LKzEIrO5i X-Received: by 2002:a17:907:7809:b0:aa5:11fa:6271 with SMTP id a640c23a62f3a-aa511fa6405mr324012266b.49.1732313822235; Fri, 22 Nov 2024 14:17:02 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-82-54-94-193.retail.telecomitalia.it. [82.54.94.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa50b52fcebsm148226466b.127.2024.11.22.14.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Nov 2024 14:17:01 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Marek Vasut , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Vincent Mailhol , linux-can@vger.kernel.org Subject: [PATCH v2 07/12] can: ifi_canfd: fix {rx,tx}_errors statistics Date: Fri, 22 Nov 2024 23:15:48 +0100 Message-ID: <20241122221650.633981-8-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241122221650.633981-1-dario.binacchi@amarulasolutions.com> References: <20241122221650.633981-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=UN18G0Og; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The ifi_canfd_handle_lec_err() function was incorrectly incrementing only the receive error counter, even in cases of bit or acknowledgment errors that occur during transmission. The patch fixes the issue by incrementing the appropriate counter based on the type of error. Fixes: 5bbd655a8bd0 ("can: ifi: Add more detailed error reporting") Signed-off-by: Dario Binacchi --- Changes in v2: - Update statistics even if skb allocation fails drivers/net/can/ifi_canfd/ifi_canfd.c | 58 ++++++++++++++++++--------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index d32b10900d2f..c86b57d47085 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -390,36 +390,55 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev) return 0; priv->can.can_stats.bus_error++; - stats->rx_errors++; /* Propagate the error condition to the CAN stack. */ skb = alloc_can_err_skb(ndev, &cf); - if (unlikely(!skb)) - return 0; /* Read the error counter register and check for new errors. */ - cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + if (likely(skb)) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; - if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) - cf->data[2] |= CAN_ERR_PROT_OVERLOAD; + if (errctr & IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_OVERLOAD; + } - if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) - cf->data[3] = CAN_ERR_PROT_LOC_ACK; + if (errctr & IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST) { + stats->tx_errors++; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_BIT0; + if (errctr & IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST) { + stats->tx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT0; + } - if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_BIT1; + if (errctr & IFI_CANFD_ERROR_CTR_BIT1_ERROR_FIRST) { + stats->tx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_BIT1; + } - if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_STUFF; + if (errctr & IFI_CANFD_ERROR_CTR_STUFF_ERROR_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_STUFF; + } - if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) - cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + if (errctr & IFI_CANFD_ERROR_CTR_CRC_ERROR_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + } - if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) - cf->data[2] |= CAN_ERR_PROT_FORM; + if (errctr & IFI_CANFD_ERROR_CTR_FORM_ERROR_FIRST) { + stats->rx_errors++; + if (likely(skb)) + cf->data[2] |= CAN_ERR_PROT_FORM; + } /* Reset the error counter, ack the IRQ and re-enable the counter. */ writel(IFI_CANFD_ERROR_CTR_ER_RESET, priv->base + IFI_CANFD_ERROR_CTR); @@ -427,6 +446,9 @@ static int ifi_canfd_handle_lec_err(struct net_device *ndev) priv->base + IFI_CANFD_INTERRUPT); writel(IFI_CANFD_ERROR_CTR_ER_ENABLE, priv->base + IFI_CANFD_ERROR_CTR); + if (unlikely(!skb)) + return 0; + netif_receive_skb(skb); return 1;