Linux CAN drivers development
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: yewentian395 <yewentian395@gmail.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] can: isotp: implement N_Ar timeout handling for FC transmission
Date: Thu, 3 Sep 2026 12:09:06 +0200	[thread overview]
Message-ID: <6ca3c6f6-91c4-4f0b-9136-9345dbaac1e0@hartkopp.net> (raw)
In-Reply-To: <20260903093809.1894919-1-yewentian395@gmail.com>

Hi Wentian,

On 03.09.26 11:38, yewentian395 wrote:

> Just a gentle ping on the frame_txtime addition to rxtimer you
> mentioned. Happy to help with a patch if that saves you time.

This is my current patch which is sitting on my dev machine:

diff --git a/net/can/isotp.c b/net/can/isotp.c
index 130a0dbec78c..5119afc2f67d 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -125,10 +125,11 @@ MODULE_PARM_DESC(max_pdu_size, "maximum isotp pdu 
size (default "
  #define ISOTP_FC_WT 1		/* wait */
  #define ISOTP_FC_OVFLW 2	/* overflow */

  #define ISOTP_FC_TIMEOUT 1	/* 1 sec */
  #define ISOTP_ECHO_TIMEOUT 2	/* 2 secs */
+#define ISOTP_MAX_FRAME_TXTIME_NS (100 * NSEC_PER_MSEC) /* max N_Ar/N_As */

  /* so->tx_result[so->tx_gen % ISOTP_TX_RESULT_SLOTS] holds the packed 
value
   * (err << ISOTP_TX_RESULT_GEN_BITS | gen) for each tx generation 
slot, so it
   * can be handled with a single READ_ONCE()/WRITE_ONCE() access.
   */
@@ -346,11 +347,12 @@ static int isotp_send_fc(struct sock *sk, int ae, 
u8 flowstatus)

  	/* reset last CF frame rx timestamp for rx stmin enforcement */
  	so->lastrxcf_tstamp = ktime_set(0, 0);

  	/* start rx timeout watchdog */
-	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
+	hrtimer_start(&so->rxtimer,
+		      ktime_set(ISOTP_FC_TIMEOUT, so->frame_txtime),
  		      HRTIMER_MODE_REL_SOFT);
  	return 0;
  }

  static void isotp_rcv_skb(struct sk_buff *skb, struct sock *sk)
@@ -1304,11 +1306,11 @@ static int isotp_sendmsg(struct socket *sock, 
struct msghdr *msg, size_t size)
  		wake_up_interruptible(&so->wait);
  		return -EADDRNOTAVAIL;
  	}
  	/* WAIT_FIRST_FC for standard FF, else stays ISOTP_SENDING */
  	WRITE_ONCE(so->tx.state, new_state);
-	hrtimer_start(tx_hrt, ktime_set(hrtimer_sec, 0),
+	hrtimer_start(tx_hrt, ktime_set(hrtimer_sec, so->frame_txtime),
  		      HRTIMER_MODE_REL_SOFT);
  	spin_unlock_bh(&so->rx_lock);

  	/* send the first or only CAN frame */
  	cf->flags = so->ll.tx_flags;
@@ -1711,10 +1713,12 @@ static int isotp_setsockopt_locked(struct socket 
*sock, int level, int optname,

  		/* check for frame_txtime changes (0 => no changes) */
  		if (so->opt.frame_txtime) {
  			if (so->opt.frame_txtime == CAN_ISOTP_FRAME_TXTIME_ZERO)
  				so->frame_txtime = 0;
+			else if (so->opt.frame_txtime > ISOTP_MAX_FRAME_TXTIME_NS)
+				return -EINVAL;
  			else
  				so->frame_txtime = so->opt.frame_txtime;
  		}
  		break;


But this patch will be part of a big chunk of patches to introduce the 
CAN XL support for ISO 15765-2 Ed.5 here:

https://github.com/hartkopp/canxl-isotp

And the latest patch set is here:
https://github.com/hartkopp/xl-isotp/tree/claude/can-isotp-patches-rebase-v3

There are currently stable fixes on the fly that always have impacts on 
the isotp code. An it is really annoying to rebase and rebase and 
rebase. Especially the code split(!) into different .c and .h files 
always has to be checked by hand. Therefore I'll wait for all the 
current stable patches to be landed in mainline and stable and then add 
this patch here to the series of cleanup and enhancement patches.

Best regards,
Oliver


      reply	other threads:[~2026-09-03 10:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 12:53 [PATCH] qcan: isotp: implement N_Ar timeout handling for FC transmission yewentian395
2026-08-24 18:03 ` Oliver Hartkopp
2026-08-26  6:42   ` [PATCH] can: " yewentian395
2026-09-03  9:38   ` yewentian395
2026-09-03 10:09     ` Oliver Hartkopp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ca3c6f6-91c4-4f0b-9136-9345dbaac1e0@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=yewentian395@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox