linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] can: mcan: Add support for handling DLEC error on CAN FD
       [not found] <CGME20221018050046epcas5p1ff6339e8394597948f9b26aecb4b51a9@epcas5p1.samsung.com>
@ 2022-10-18  4:33 ` Vivek Yadav
  2022-10-18  6:15   ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Vivek Yadav @ 2022-10-18  4:33 UTC (permalink / raw)
  To: rcsekar, wg, mkl, davem, edumazet, kuba, pabeni, pankaj.dubey,
	ravi.patel
  Cc: linux-can, netdev, linux-kernel, Vivek Yadav

When a frame in CAN FD format has reached the data phase, the next
CAN event (error or valid frame) will be shown in DLEC.

Utilizes the dedicated flag (Data Phase Last Error Code: DLEC flag) to
determine the type of last error that occurred in the data phase
of a CAN FD frame and handle the bus errors.

Signed-off-by: Vivek Yadav <vivek.2311@samsung.com>
---
This patch is dependent on following patch from Marc:
[1]: https://lore.kernel.org/all/20221012074205.691384-1-mkl@pengutronix.de/

 drivers/net/can/m_can/m_can.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 18a138fdfa66..98cc98564ab4 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -156,6 +156,7 @@ enum m_can_reg {
 #define PSR_EW		BIT(6)
 #define PSR_EP		BIT(5)
 #define PSR_LEC_MASK	GENMASK(2, 0)
+#define PSR_DLEC_MASK   GENMASK(8, 10)
 
 /* Interrupt Register (IR) */
 #define IR_ALL_INT	0xffffffff
@@ -868,6 +869,7 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus,
 {
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	int work_done = 0;
+	u8 dlec = 0;
 
 	if (irqstatus & IR_RF0L)
 		work_done += m_can_handle_lost_msg(dev);
@@ -878,6 +880,13 @@ static int m_can_handle_bus_errors(struct net_device *dev, u32 irqstatus,
 
 		if (is_lec_err(lec))
 			work_done += m_can_handle_lec_err(dev, lec);
+
+		dlec = FIELD_GET(PSR_DLEC_MASK, psr);
+
+		if (is_lec_err(dlec)) {
+			netdev_dbg(dev, "Data phase error detected\n");
+			work_done += m_can_handle_lec_err(dev, dlec);
+		}
 	}
 
 	/* handle protocol errors in arbitration phase */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] can: mcan: Add support for handling DLEC error on CAN FD
  2022-10-18  4:33 ` [PATCH v4] can: mcan: Add support for handling DLEC error on CAN FD Vivek Yadav
@ 2022-10-18  6:15   ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2022-10-18  6:15 UTC (permalink / raw)
  To: Vivek Yadav
  Cc: rcsekar, wg, davem, edumazet, kuba, pabeni, pankaj.dubey,
	ravi.patel, linux-can, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

On 18.10.2022 10:03:33, Vivek Yadav wrote:
> When a frame in CAN FD format has reached the data phase, the next
> CAN event (error or valid frame) will be shown in DLEC.
> 
> Utilizes the dedicated flag (Data Phase Last Error Code: DLEC flag) to
> determine the type of last error that occurred in the data phase
> of a CAN FD frame and handle the bus errors.
> 
> Signed-off-by: Vivek Yadav <vivek.2311@samsung.com>

Have you actually compiled this code?

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-18  6:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20221018050046epcas5p1ff6339e8394597948f9b26aecb4b51a9@epcas5p1.samsung.com>
2022-10-18  4:33 ` [PATCH v4] can: mcan: Add support for handling DLEC error on CAN FD Vivek Yadav
2022-10-18  6:15   ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).