Skip to contentSkip to conversation

Introducing new CAN FD bittiming parameters: Transmission Delay Compensation (TDC)

PATCH In review Vincent Mailhol 2 participants 3 messages Mar 21, 2021 – Mar 22, 2021 CAN network drivers

lore
Share & tools
lore
#0 lore raw

v4 cover Introducing new CAN FD bittiming parameters: Transmission Delay Compensation (TDC)

I made a silly mistake which cause the automatic tdco calculation not to work and failed to catch it during my testing (I probably was to focussed to test the netlink interface, and forget to test the most obvious use case...)

One incremental patch to be applied on the v3. The patch contains detailed instruction after the "---" scissors.

Changes from v3:
- do tdco calculation after data bittiming is copied to can_priv.

Changes from v2:
- Reorder the IFLA_CAN_TDC* entries in can_policy structure
- Increase readability of the TDCO formula by introducing a temporary variable.

Changes from v1:
- Changed the commit message of the first patch of the serie to clarify the condition of when TDC is active.
- Changed the alignment style from tabulations to single space in drivers/net/can/dev/netlink.c
- Remove duplicated [IFLA_CAN_TERMINATION] entry in drivers/net/can/dev/netlink.c

Changes from the RFC:
- The RFC was a single e-mail with all comments in bulk, made this a proper patch series.
- Added the netlink interface.
- Rename the function can_set_tdc to can_calc_tdco (the formula is the same, everything around it was reworked).
- Other small miscellaneous changes.

Vincent Mailhol (1):
can: netlink: do tdco calculation after data bittiming is copied to
can_priv

 drivers/net/can/dev/netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v4 1/1 can: netlink: do tdco calculation after data bittiming is copied to can_priv

The call to can_calc_tdco() is done too early. The data_bittiming field of can_priv is not yet updated.

Moving the call after tdco is memcopied solves the issue.

---
Hi Marc,

Please squash this into below commit:
2b3d40020eca ("can: bittiming: add calculation for CAN FD Transmitter Delay Compensation (TDC)")

---
 drivers/net/can/dev/netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/can/dev/netlink.c +2 -1
index 88dc56268670..18f7beeaf7d8 100644
@@ -177,7 +177,6 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
 					priv->data_bitrate_const_cnt);
 		if (err)
 			return err;
-		can_calc_tdco(dev);
 
 		if (priv->bitrate_max && dbt.bitrate > priv->bitrate_max) {
 			netdev_err(dev, "canfd data bitrate surpasses transceiver capabilities of %d bps\n",
@@ -187,6 +186,8 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
 
 		memcpy(&priv->data_bittiming, &dbt, sizeof(dbt));
 
+		can_calc_tdco(dev);
+
 		if (priv->do_set_data_bittiming) {
 			/* Finally, set the bit-timing registers */
 			err = priv->do_set_data_bittiming(dev);
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH v4 1/1] can: netlink: do tdco calculation after data bittiming is copied to can_priv

Quoted 11 lines · Vincent Mailhol

The call to can_calc_tdco() is done too early. The data_bittiming field of can_priv is not yet updated.

Moving the call after tdco is memcopied solves the issue.

---
Hi Marc,

Please squash this into below commit:
2b3d40020eca ("can: bittiming: add calculation for CAN FD Transmitter Delay Compensation (TDC)")

done

regards,
Marc

Signature · 4 lines
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 |