All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Queries on CAN frame work
       [not found] <DM6PR02MB538645C4ECE3BBBD3CE92A17AF539@DM6PR02MB5386.namprd02.prod.outlook.com>
@ 2022-01-13 20:30 ` Marc Kleine-Budde
  2022-01-13 21:10   ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-01-13 20:30 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad, linux-can

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

Hello Srinivas Neeli,

On 13.01.2022 18:14:06, Srinivas Neeli wrote:
> This mail is regarding to understand more on CAN Frame work for CANFD
> networks.

let's discuss this on the CAN mailing list (Cc'ed). Feel free to
subscribe (http://vger.kernel.org/vger-lists.html#linux-can). Please
post non HTML mail.

> Recently we did few experiments with our CANFD network. Stuff error
> observed with different Nominal and Dataphase prescaler configuration
> values, which we get from the frame work.
> 
> 
> For lower baud rates separate prescalers are working good, but when we
> switch to high baud rates(like 4Mbps and 5Mbps) observed the BUSOFF
> state(Due to stuff errors) on IP(Xilinx).
> 
> With shared prescaler(low prescalers) we are not seeing the issue..
> 
> In Iso spec also mentioned to avoid tolerance, we have to maintain
> common TQ for Nominal and Data phase.
> 
> Spec: ISO 11898-1:2015(E)  page no :50
> 
> " If the same time quantum length is used in the nominal bit time and
> in the data bit time and the positions of the sample points in the
> nominal bit time are the same in all CAN nodes of a network, then
> optimum clock tolerance is accomplished for networks using FD frames."
> 
> CIA:
> https://can-newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a513712c.pdf
> 
> From above CAN-newsletter also suggested the same in recommendation 2 and 3.
> 
> Recommendation 2: Set the BRPA bit-rate prescaler equal BRPB
> Recommendation 3: Choose BRPA and BRPD as low as possible
> 
> Is there any possibility in framework to use shared prescalars for Nominal and Dataphase?.
> 
> One more question. How to calculate TDCO ?, is there any generic formula for this ?.

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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-01-13 20:30 ` Queries on CAN frame work Marc Kleine-Budde
@ 2022-01-13 21:10   ` Marc Kleine-Budde
  2022-01-14 10:16     ` Vincent MAILHOL
  2022-01-15 23:26     ` Marc Kleine-Budde
  0 siblings, 2 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-01-13 21:10 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 13.01.2022 21:30:04, Marc Kleine-Budde wrote:
> > Recently we did few experiments with our CANFD network. Stuff error
> > observed with different Nominal and Dataphase prescaler configuration
> > values, which we get from the frame work.
> > 
> > For lower baud rates separate prescalers are working good, but when we
> > switch to high baud rates(like 4Mbps and 5Mbps) observed the BUSOFF
> > state(Due to stuff errors) on IP(Xilinx).
> > 
> > With shared prescaler(low prescalers) we are not seeing the issue..
> > 
> > In Iso spec also mentioned to avoid tolerance, we have to maintain
> > common TQ for Nominal and Data phase.

This is a known problem with the current arbitration and data bit rate
calculation. They are done independently of each other, resulting in not
common pre-scalers and thus not common TQ.

> > Spec: ISO 11898-1:2015(E)  page no :50
> > 
> > " If the same time quantum length is used in the nominal bit time and
> > in the data bit time and the positions of the sample points in the
> > nominal bit time are the same in all CAN nodes of a network, then
> > optimum clock tolerance is accomplished for networks using FD frames."
> > 
> > CIA:
> > https://can-newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a513712c.pdf
> > 
> > From above CAN-newsletter also suggested the same in recommendation 2 and 3.

I'll have a look at the newsletter and see what changes need to be done
to the existing algorithm.

> > Recommendation 2: Set the BRPA bit-rate prescaler equal BRPB
> > Recommendation 3: Choose BRPA and BRPD as low as possible
> > 
> > Is there any possibility in framework to use shared prescalars for
> > Nominal and Dataphase?.

Not yet.

> > One more question. How to calculate TDCO ?, is there any generic
> > formula for this ?.

Vincent (Cc'ed) can help you on this.

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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-01-13 21:10   ` Marc Kleine-Budde
@ 2022-01-14 10:16     ` Vincent MAILHOL
  2022-01-17 11:48       ` Marc Kleine-Budde
  2022-01-15 23:26     ` Marc Kleine-Budde
  1 sibling, 1 reply; 21+ messages in thread
From: Vincent MAILHOL @ 2022-01-14 10:16 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Neeli, Srinivas Goud, Naveen Kumar Gaddipati,
	Prasad Beer Prasad, linux-can, Stefan Mätje

Le ven. 14 janv. 2022 à 06:10, Marc Kleine-Budde <mkl@pengutronix.de> a écrit :
>
> On 13.01.2022 21:30:04, Marc Kleine-Budde wrote:
> > > Recently we did few experiments with our CANFD network. Stuff error
> > > observed with different Nominal and Dataphase prescaler configuration
> > > values, which we get from the frame work.
> > >
> > > For lower baud rates separate prescalers are working good, but when we
> > > switch to high baud rates(like 4Mbps and 5Mbps) observed the BUSOFF
> > > state(Due to stuff errors) on IP(Xilinx).
> > >
> > > With shared prescaler(low prescalers) we are not seeing the issue..
> > >
> > > In Iso spec also mentioned to avoid tolerance, we have to maintain
> > > common TQ for Nominal and Data phase.
>
> This is a known problem with the current arbitration and data bit rate
> calculation. They are done independently of each other, resulting in not
> common pre-scalers and thus not common TQ.
>
> > > Spec: ISO 11898-1:2015(E)  page no :50
> > >
> > > " If the same time quantum length is used in the nominal bit time and
> > > in the data bit time and the positions of the sample points in the
> > > nominal bit time are the same in all CAN nodes of a network, then
> > > optimum clock tolerance is accomplished for networks using FD frames."
> > >
> > > CIA:
> > > https://can-newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a513712c.pdf
> > >
> > > From above CAN-newsletter also suggested the same in recommendation 2 and 3.
>
> I'll have a look at the newsletter and see what changes need to be done
> to the existing algorithm.
>
> > > Recommendation 2: Set the BRPA bit-rate prescaler equal BRPB
> > > Recommendation 3: Choose BRPA and BRPD as low as possible
> > >
> > > Is there any possibility in framework to use shared prescalars for
> > > Nominal and Dataphase?.
>
> Not yet.

Well, technically, skipping the full calculation and providing all
bittiming parameters will allow you to use shared prescalers. But
indeed, there is nothing to automatically calculate it nor to check the
sanity of manually provided bittiming parameters.

> > > One more question. How to calculate TDCO ?, is there any generic
> > > formula for this ?.
>
> Vincent (Cc'ed) can help you on this.

It is implemented in the kernel here:
https://elixir.bootlin.com/linux/latest/source/drivers/net/can/dev/bittiming.c#L178

You can refer to the patch description for additional info.
 * Original patch:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c25cc7993243fdc00ab7e608e3764819538015ab
 * Amended by:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39f66c9e229797a58a12ea78388cbbad1f81aec9

N.B.: the comments of the original patch related to iproute2 are outdated.

If you follow the links in the patches you will find even more discussions
on this topic in the mailing list archives. But I guess that the commit
description is enough to answer your questions.

Also, please note that the xilinx driver does not yet implement TDC.
Actually, TDC netlink framework was introduced recently in the kernel and
as of today only the etas_es58x does support it.

By the way, Marc, did you get an answer from Microchip on the relative
TDCO topic for the mcp25xxfd?
c.f. https://lore.kernel.org/all/20210817094306.iyezzml6m7nlznri@pengutronix.de/


Yours sincerely,
Vincent Mailhol

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

* Re: Queries on CAN frame work
  2022-01-13 21:10   ` Marc Kleine-Budde
  2022-01-14 10:16     ` Vincent MAILHOL
@ 2022-01-15 23:26     ` Marc Kleine-Budde
  2022-02-21 14:43       ` Srinivas Neeli
  1 sibling, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-01-15 23:26 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 13.01.2022 22:10:18, Marc Kleine-Budde wrote:
> On 13.01.2022 21:30:04, Marc Kleine-Budde wrote:
> > > Recently we did few experiments with our CANFD network. Stuff error
> > > observed with different Nominal and Dataphase prescaler configuration
> > > values, which we get from the frame work.
> > > 
> > > For lower baud rates separate prescalers are working good, but when we
> > > switch to high baud rates(like 4Mbps and 5Mbps) observed the BUSOFF
> > > state(Due to stuff errors) on IP(Xilinx).
> > > 
> > > With shared prescaler(low prescalers) we are not seeing the
> > > issue..

Can you please provide me:
- the bit timing constants of the IP core for the arbitration and data
  phase
- the bit rate for the arbitration and data phase
  (especially where the framework calculates not common prescalers)
- the clock rate of the CAN bus clock

Can you also provide the hand calculated bit timing parameters for the
above scenarios?

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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-01-14 10:16     ` Vincent MAILHOL
@ 2022-01-17 11:48       ` Marc Kleine-Budde
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-01-17 11:48 UTC (permalink / raw)
  To: Vincent MAILHOL
  Cc: Srinivas Neeli, Srinivas Goud, Naveen Kumar Gaddipati,
	Prasad Beer Prasad, linux-can

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

On 14.01.2022 19:16:02, Vincent MAILHOL wrote:
> By the way, Marc, did you get an answer from Microchip on the relative
> TDCO topic for the mcp25xxfd?
> c.f. https://lore.kernel.org/all/20210817094306.iyezzml6m7nlznri@pengutronix.de/

IIRC the datasheet you found:

| http://ww1.microchip.com/downloads/en/DeviceDoc/Section_56_Controller_Area_Network_with_Flexible_Data_rate_DS60001549A.pdf

is correct:

| 10 = Auto; measure delay and add CFDxDBTCFG.TSEG1; add TDCO

But back when I asked by contact was on holidays, and currently he's on
holidays, too. I'll refresh my mind next month, when he's back.

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] 21+ messages in thread

* RE: Queries on CAN frame work
  2022-01-15 23:26     ` Marc Kleine-Budde
@ 2022-02-21 14:43       ` Srinivas Neeli
  2022-02-21 20:27         ` Marc Kleine-Budde
                           ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Srinivas Neeli @ 2022-02-21 14:43 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL, linux-can

Hi marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: Sunday, January 16, 2022 4:56 AM
> To: Srinivas Neeli <sneeli@xilinx.com>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: Re: Queries on CAN frame work
> 
> On 13.01.2022 22:10:18, Marc Kleine-Budde wrote:
> > On 13.01.2022 21:30:04, Marc Kleine-Budde wrote:
> > > > Recently we did few experiments with our CANFD network. Stuff
> > > > error observed with different Nominal and Dataphase prescaler
> > > > configuration values, which we get from the frame work.
> > > >
> > > > For lower baud rates separate prescalers are working good, but
> > > > when we switch to high baud rates(like 4Mbps and 5Mbps) observed
> > > > the BUSOFF state(Due to stuff errors) on IP(Xilinx).
> > > >
> > > > With shared prescaler(low prescalers) we are not seeing the
> > > > issue..
> 
> Can you please provide me:
> - the bit timing constants of the IP core for the arbitration and data
>   phase
> - the bit rate for the arbitration and data phase
>   (especially where the framework calculates not common prescalers)
> - the clock rate of the CAN bus clock
> 
> Can you also provide the hand calculated bit timing parameters for the
> above scenarios?

Baud rate 1/5Mbps
================
root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000 dbitrate 5000000 fd on   
[   26.837057] xilinx_can ff070000.can can6: bitrate error 0.0%
[   26.842731] xilinx_can ff070000.can can6: bitrate error 0.0%
 can6 txqroot@xilinx-vck190-2021_1:~# ifconfig can6 txqueuelen 1000
 root@xilinx-vck190-2021_1:~# ip link set can6 up
[   27.340880] IPv6: ADDRCONF(NETDEV_CHANGE): can6: link becomes ready
root@xilinx-vck190-2021_1:~# ip -d -s link show can6
 can6: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
	  bitrate 999999 sample-point 0.750 
	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
	  dbitrate 4999999 dsample-point 0.750 
	  dtq 50 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1
	  clock 79999999 
	  re-started bus-errors arbit-lost error-warn error-pass bus-off
	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0       
root@xilinx-vck190-2021_1:~# 

Parameters
BPRA -20, TS1 = 2, TS2 =1,sjw =1,
BPRD - 4, TS1 = 2, Ts2 = 1,sjw =1,
Clock ~80Mhz(79999999)

Hand configuration:
--------------------------- 
ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1 dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 dsjw 1 fd on  (A/D: 1/5Mbps, Sample point=75%)

Baud rate 1/4Mbps
================
root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000 dbitrate 4000000 fd on   
[  209.572938] xilinx_can ff070000.can can6: bitrate error 0.0%
[  209.578627] xilinx_can ff070000.can can6: bitrate error 0.0%
root@xilinx-vck190-2021_1:~# 
root@xilinx-vck190-2021_1:~# ip -d -s link show can6
9: can6: <NOARP,ECHO> mtu 72 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can <FD> state STOPPED (berr-counter tx 0 rx 0) restart-ms 0 
	  bitrate 999999 sample-point 0.750 
	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
	  dbitrate 3999999 dsample-point 0.750 
	  dtq 62 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1
	  clock 79999999 
	  re-started bus-errors arbit-lost error-warn error-pass bus-off
	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0       
root@xilinx-vck190-2021_1:~# 

Parameters
BPRA -20, TS1 = 2, TS2 =1,sjw =1,
BPRD - 5 , TS1 = 2, Ts2 = 1,sjw =1,
Clock ~80Mhz(79999999)

Hand configuration:
--------------------------
ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1 dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1 fd on (A/D: 1/4Mbps, Sample point=75%)
Reference:
https://www.kvaser.com/support/calculators/can-fd-bit-timing-calculator/

is there any plan to implement newsletter recommendations in frame work ?
https://can-newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a


> 
> 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 |

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

* Re: Queries on CAN frame work
  2022-02-21 14:43       ` Srinivas Neeli
@ 2022-02-21 20:27         ` Marc Kleine-Budde
  2022-02-22  0:40           ` Srinivas Neeli
  2022-03-17 22:00         ` Marc Kleine-Budde
  2022-03-17 22:50         ` Marc Kleine-Budde
  2 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-02-21 20:27 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > Can you please provide me:
> > - the bit timing constants of the IP core for the arbitration and data
> >   phase
> > - the bit rate for the arbitration and data phase
> >   (especially where the framework calculates not common prescalers)
> > - the clock rate of the CAN bus clock
> > 
> > Can you also provide the hand calculated bit timing parameters for the
> > above scenarios?
> 
> Baud rate 1/5Mbps
> ================
> root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000 dbitrate 5000000 fd on   
> [   26.837057] xilinx_can ff070000.can can6: bitrate error 0.0%
> [   26.842731] xilinx_can ff070000.can can6: bitrate error 0.0%
>  can6 txqroot@xilinx-vck190-2021_1:~# ifconfig can6 txqueuelen 1000
>  root@xilinx-vck190-2021_1:~# ip link set can6 up
> [   27.340880] IPv6: ADDRCONF(NETDEV_CHANGE): can6: link becomes ready
> root@xilinx-vck190-2021_1:~# ip -d -s link show can6
>  can6: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
>     link/can  promiscuity 0 minmtu 0 maxmtu 0 
>     can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
> 	  bitrate 999999 sample-point 0.750 
> 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> 	  dbitrate 4999999 dsample-point 0.750 
> 	  dtq 50 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1
> 	  clock 79999999 
> 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> 	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
>     RX: bytes  packets  errors  dropped overrun mcast   
>     0          0        0       0       0       0       
>     TX: bytes  packets  errors  dropped carrier collsns 
>     0          0        0       0       0       0       
> root@xilinx-vck190-2021_1:~# 
> 
> Parameters
> BPRA -20, TS1 = 2, TS2 =1,sjw =1,
> BPRD - 4, TS1 = 2, Ts2 = 1,sjw =1,
> Clock ~80Mhz(79999999)
> 
> Hand configuration:
> --------------------------- 
> ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1 dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 dsjw 1 fd on  (A/D: 1/5Mbps, Sample point=75%)
> 
> Baud rate 1/4Mbps
> ================
> root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000 dbitrate 4000000 fd on   
> [  209.572938] xilinx_can ff070000.can can6: bitrate error 0.0%
> [  209.578627] xilinx_can ff070000.can can6: bitrate error 0.0%
> root@xilinx-vck190-2021_1:~# 
> root@xilinx-vck190-2021_1:~# ip -d -s link show can6
> 9: can6: <NOARP,ECHO> mtu 72 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
>     link/can  promiscuity 0 minmtu 0 maxmtu 0 
>     can <FD> state STOPPED (berr-counter tx 0 rx 0) restart-ms 0 
> 	  bitrate 999999 sample-point 0.750 
> 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> 	  dbitrate 3999999 dsample-point 0.750 
> 	  dtq 62 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1
> 	  clock 79999999 
> 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> 	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
>     RX: bytes  packets  errors  dropped overrun mcast   
>     0          0        0       0       0       0       
>     TX: bytes  packets  errors  dropped carrier collsns 
>     0          0        0       0       0       0       
> root@xilinx-vck190-2021_1:~# 
> 
> Parameters
> BPRA -20, TS1 = 2, TS2 =1,sjw =1,
> BPRD - 5 , TS1 = 2, Ts2 = 1,sjw =1,
> Clock ~80Mhz(79999999)
> 
> Hand configuration:
> --------------------------
> ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1 dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1 fd on (A/D: 1/4Mbps, Sample point=75%)
> Reference:
> https://www.kvaser.com/support/calculators/can-fd-bit-timing-calculator/
> 
> is there any plan to implement newsletter recommendations in frame work ?
> https://can-newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a

Thanks those parameters. I think I have everything I need and I'll try
to reproduce the problem here.

I want to add the clock rate to the can-bit-timing user space tool.
Which SoC uses this 79999999 Hz Clock?

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] 21+ messages in thread

* RE: Queries on CAN frame work
  2022-02-21 20:27         ` Marc Kleine-Budde
@ 2022-02-22  0:40           ` Srinivas Neeli
  2022-03-06 14:30             ` Srinivas Neeli
  0 siblings, 1 reply; 21+ messages in thread
From: Srinivas Neeli @ 2022-02-22  0:40 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

Hi Marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: Tuesday, February 22, 2022 1:58 AM
> To: Srinivas Neeli <sneeli@xilinx.com>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: Re: Queries on CAN frame work
> 
> On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > > Can you please provide me:
> > > - the bit timing constants of the IP core for the arbitration and data
> > >   phase
> > > - the bit rate for the arbitration and data phase
> > >   (especially where the framework calculates not common prescalers)
> > > - the clock rate of the CAN bus clock
> > >
> > > Can you also provide the hand calculated bit timing parameters for
> > > the above scenarios?
> >
> > Baud rate 1/5Mbps
> > ================
> > root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000
> dbitrate 5000000 fd on
> > [   26.837057] xilinx_can ff070000.can can6: bitrate error 0.0%
> > [   26.842731] xilinx_can ff070000.can can6: bitrate error 0.0%
> >  can6 txqroot@xilinx-vck190-2021_1:~# ifconfig can6 txqueuelen 1000
> > root@xilinx-vck190-2021_1:~# ip link set can6 up
> > [   27.340880] IPv6: ADDRCONF(NETDEV_CHANGE): can6: link becomes
> ready
> > root@xilinx-vck190-2021_1:~# ip -d -s link show can6
> >  can6: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP
> mode DEFAULT group default qlen 1000
> >     link/can  promiscuity 0 minmtu 0 maxmtu 0
> >     can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
> > 	  bitrate 999999 sample-point 0.750
> > 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> > 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> > 	  dbitrate 4999999 dsample-point 0.750
> > 	  dtq 50 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> > 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc
> 1
> > 	  clock 79999999
> > 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> > 	  0          0          0          0          0          0         numtxqueues 1
> numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
> >     RX: bytes  packets  errors  dropped overrun mcast
> >     0          0        0       0       0       0
> >     TX: bytes  packets  errors  dropped carrier collsns
> >     0          0        0       0       0       0
> > root@xilinx-vck190-2021_1:~#
> >
> > Parameters
> > BPRA -20, TS1 = 2, TS2 =1,sjw =1,
> > BPRD - 4, TS1 = 2, Ts2 = 1,sjw =1,
> > Clock ~80Mhz(79999999)
> >
> > Hand configuration:
> > ---------------------------
> > ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2
> > 20 sjw 1 dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 dsjw 1 fd on
> > (A/D: 1/5Mbps, Sample point=75%)
> >
> > Baud rate 1/4Mbps
> > ================
> > root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000
> dbitrate 4000000 fd on
> > [  209.572938] xilinx_can ff070000.can can6: bitrate error 0.0% [
> > 209.578627] xilinx_can ff070000.can can6: bitrate error 0.0%
> > root@xilinx-vck190-2021_1:~# root@xilinx-vck190-2021_1:~# ip -d -s
> > link show can6
> > 9: can6: <NOARP,ECHO> mtu 72 qdisc pfifo_fast state DOWN mode
> DEFAULT group default qlen 1000
> >     link/can  promiscuity 0 minmtu 0 maxmtu 0
> >     can <FD> state STOPPED (berr-counter tx 0 rx 0) restart-ms 0
> > 	  bitrate 999999 sample-point 0.750
> > 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> > 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> > 	  dbitrate 3999999 dsample-point 0.750
> > 	  dtq 62 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> > 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc
> 1
> > 	  clock 79999999
> > 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> > 	  0          0          0          0          0          0         numtxqueues 1
> numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
> >     RX: bytes  packets  errors  dropped overrun mcast
> >     0          0        0       0       0       0
> >     TX: bytes  packets  errors  dropped carrier collsns
> >     0          0        0       0       0       0
> > root@xilinx-vck190-2021_1:~#
> >
> > Parameters
> > BPRA -20, TS1 = 2, TS2 =1,sjw =1,
> > BPRD - 5 , TS1 = 2, Ts2 = 1,sjw =1,
> > Clock ~80Mhz(79999999)
> >
> > Hand configuration:
> > --------------------------
> > ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2
> > 20 sjw 1 dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1 fd on
> > (A/D: 1/4Mbps, Sample point=75%)
> > Reference:
> > https://www.kvaser.com/support/calculators/can-fd-bit-timing-calculato
> > r/
> >
> > is there any plan to implement newsletter recommendations in frame
> work ?
> > https://can-
> newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a
> 
> Thanks those parameters. I think I have everything I need and I'll try to
> reproduce the problem here.
> 
> I want to add the clock rate to the can-bit-timing user space tool.
> Which SoC uses this 79999999 Hz Clock?

Versal ACAP SOC we are observing 7999999Hz Clock.
https://www.xilinx.com/support/documentation/architecture-manuals/am011-versal-acap-trm.pdf

> 
> 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 |

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

* RE: Queries on CAN frame work
  2022-02-22  0:40           ` Srinivas Neeli
@ 2022-03-06 14:30             ` Srinivas Neeli
  2022-03-06 14:47               ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Srinivas Neeli @ 2022-03-06 14:30 UTC (permalink / raw)
  To: Srinivas Neeli, Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

Hi Marc,

> -----Original Message-----
> From: Srinivas Neeli <sneeli@xilinx.com>
> Sent: Tuesday, February 22, 2022 6:11 AM
> To: Marc Kleine-Budde <mkl@pengutronix.de>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: RE: Queries on CAN frame work
> 
> Hi Marc,
> 
> > -----Original Message-----
> > From: Marc Kleine-Budde <mkl@pengutronix.de>
> > Sent: Tuesday, February 22, 2022 1:58 AM
> > To: Srinivas Neeli <sneeli@xilinx.com>
> > Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> > <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>;
> > linux- can <linux-can@vger.kernel.org>; Stefan Mätje
> > <stefan.maetje@esd.eu>; Vincent MAILHOL
> <mailhol.vincent@wanadoo.fr>
> > Subject: Re: Queries on CAN frame work
> >
> > On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > > > Can you please provide me:
> > > > - the bit timing constants of the IP core for the arbitration and data
> > > >   phase
> > > > - the bit rate for the arbitration and data phase
> > > >   (especially where the framework calculates not common
> > > > prescalers)
> > > > - the clock rate of the CAN bus clock
> > > >
> > > > Can you also provide the hand calculated bit timing parameters for
> > > > the above scenarios?
> > >
> > > Baud rate 1/5Mbps
> > > ================
> > > root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate
> > > 1000000
> > dbitrate 5000000 fd on
> > > [   26.837057] xilinx_can ff070000.can can6: bitrate error 0.0%
> > > [   26.842731] xilinx_can ff070000.can can6: bitrate error 0.0%
> > >  can6 txqroot@xilinx-vck190-2021_1:~# ifconfig can6 txqueuelen 1000
> > > root@xilinx-vck190-2021_1:~# ip link set can6 up
> > > [   27.340880] IPv6: ADDRCONF(NETDEV_CHANGE): can6: link becomes
> > ready
> > > root@xilinx-vck190-2021_1:~# ip -d -s link show can6
> > >  can6: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP
> > mode DEFAULT group default qlen 1000
> > >     link/can  promiscuity 0 minmtu 0 maxmtu 0
> > >     can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
> > > 	  bitrate 999999 sample-point 0.750
> > > 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> > > 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> > > 	  dbitrate 4999999 dsample-point 0.750
> > > 	  dtq 50 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> > > 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256
> > > dbrp-inc
> > 1
> > > 	  clock 79999999
> > > 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> > > 	  0          0          0          0          0          0         numtxqueues 1
> > numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
> > >     RX: bytes  packets  errors  dropped overrun mcast
> > >     0          0        0       0       0       0
> > >     TX: bytes  packets  errors  dropped carrier collsns
> > >     0          0        0       0       0       0
> > > root@xilinx-vck190-2021_1:~#
> > >
> > > Parameters
> > > BPRA -20, TS1 = 2, TS2 =1,sjw =1,
> > > BPRD - 4, TS1 = 2, Ts2 = 1,sjw =1,
> > > Clock ~80Mhz(79999999)
> > >
> > > Hand configuration:
> > > ---------------------------
> > > ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2
> > > 20 sjw 1 dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 dsjw 1 fd on
> > > (A/D: 1/5Mbps, Sample point=75%)
> > >
> > > Baud rate 1/4Mbps
> > > ================
> > > root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate
> > > 1000000
> > dbitrate 4000000 fd on
> > > [  209.572938] xilinx_can ff070000.can can6: bitrate error 0.0% [
> > > 209.578627] xilinx_can ff070000.can can6: bitrate error 0.0%
> > > root@xilinx-vck190-2021_1:~# root@xilinx-vck190-2021_1:~# ip -d -s
> > > link show can6
> > > 9: can6: <NOARP,ECHO> mtu 72 qdisc pfifo_fast state DOWN mode
> > DEFAULT group default qlen 1000
> > >     link/can  promiscuity 0 minmtu 0 maxmtu 0
> > >     can <FD> state STOPPED (berr-counter tx 0 rx 0) restart-ms 0
> > > 	  bitrate 999999 sample-point 0.750
> > > 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> > > 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> > > 	  dbitrate 3999999 dsample-point 0.750
> > > 	  dtq 62 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> > > 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256
> > > dbrp-inc
> > 1
> > > 	  clock 79999999
> > > 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> > > 	  0          0          0          0          0          0         numtxqueues 1
> > numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
> > >     RX: bytes  packets  errors  dropped overrun mcast
> > >     0          0        0       0       0       0
> > >     TX: bytes  packets  errors  dropped carrier collsns
> > >     0          0        0       0       0       0
> > > root@xilinx-vck190-2021_1:~#
> > >
> > > Parameters
> > > BPRA -20, TS1 = 2, TS2 =1,sjw =1,
> > > BPRD - 5 , TS1 = 2, Ts2 = 1,sjw =1,
> > > Clock ~80Mhz(79999999)
> > >
> > > Hand configuration:
> > > --------------------------
> > > ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2
> > > 20 sjw 1 dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1 fd on
> > > (A/D: 1/4Mbps, Sample point=75%)
> > > Reference:
> > > https://www.kvaser.com/support/calculators/can-fd-bit-timing-calcula
> > > to
> > > r/
> > >
> > > is there any plan to implement newsletter recommendations in frame
> > work ?
> > > https://can-
> > newsletter.org/uploads/media/raw/f6a36d1461371a2f86ef0011a
> >
> > Thanks those parameters. I think I have everything I need and I'll try
> > to reproduce the problem here.
> >
> > I want to add the clock rate to the can-bit-timing user space tool.
> > Which SoC uses this 79999999 Hz Clock?
> 
> Versal ACAP SOC we are observing 7999999Hz Clock.
> https://www.xilinx.com/support/documentation/architecture-
> manuals/am011-versal-acap-trm.pdf


Did you get time to reproduce the issue? 
Is there any changes planning in CAN frame work(based on CIA newsletter) ?.


> 
> >
> > 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 |

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

* Re: Queries on CAN frame work
  2022-03-06 14:30             ` Srinivas Neeli
@ 2022-03-06 14:47               ` Marc Kleine-Budde
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-06 14:47 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 06.03.2022 14:30:43, Srinivas Neeli wrote:
> > Versal ACAP SOC we are observing 7999999Hz Clock.
> > https://www.xilinx.com/support/documentation/architecture-
> > manuals/am011-versal-acap-trm.pdf
> 
> Did you get time to reproduce the issue?

Yes, reproduction is not that hard.

> Is there any changes planning in CAN frame work(based on CIA
> newsletter) ?.

Yes, but I can't give you a time frame for this, unfortunately.

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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-02-21 14:43       ` Srinivas Neeli
  2022-02-21 20:27         ` Marc Kleine-Budde
@ 2022-03-17 22:00         ` Marc Kleine-Budde
  2022-03-18  6:12           ` Srinivas Neeli
  2022-03-17 22:50         ` Marc Kleine-Budde
  2 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-17 22:00 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > Can you please provide me:
> > - the bit timing constants of the IP core for the arbitration and data
> >   phase
> > - the bit rate for the arbitration and data phase
> >   (especially where the framework calculates not common prescalers)
> > - the clock rate of the CAN bus clock
> > 
> > Can you also provide the hand calculated bit timing parameters for the
> > above scenarios?
> 
> Baud rate 1/5Mbps
> ================
> root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000 dbitrate 5000000 fd on   
> [   26.837057] xilinx_can ff070000.can can6: bitrate error 0.0%
> [   26.842731] xilinx_can ff070000.can can6: bitrate error 0.0%
>  can6 txqroot@xilinx-vck190-2021_1:~# ifconfig can6 txqueuelen 1000
>  root@xilinx-vck190-2021_1:~# ip link set can6 up
> [   27.340880] IPv6: ADDRCONF(NETDEV_CHANGE): can6: link becomes ready
> root@xilinx-vck190-2021_1:~# ip -d -s link show can6
>  can6: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
>     link/can  promiscuity 0 minmtu 0 maxmtu 0 
>     can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
> 	  bitrate 999999 sample-point 0.750 
> 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> 	  dbitrate 4999999 dsample-point 0.750 
> 	  dtq 50 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1
> 	  clock 79999999 
> 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> 	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
>     RX: bytes  packets  errors  dropped overrun mcast   
>     0          0        0       0       0       0       
>     TX: bytes  packets  errors  dropped carrier collsns 
>     0          0        0       0       0       0

Are you using the mainline xilinx_can driver? The "ip" command says,
you're using:

>  sjw 1..128  brp 1..256
> dsjw 1..16  dbrp 1..256

Looking at the mainline xilinx driver, we have:

| /* CAN Bittiming constants as per Xilinx CAN specs */
| static const struct can_bittiming_const xcan_bittiming_const = {
| 	.name = DRIVER_NAME,
| 	.tseg1_min = 1,
| 	.tseg1_max = 16,
| 	.tseg2_min = 1,
| 	.tseg2_max = 8,
| 	.sjw_max = 4,
                   ^
Does not match due to "sjw 1..128".

| 	.brp_min = 1,
| 	.brp_max = 256,
| 	.brp_inc = 1,
| };
| 
| /* AXI CANFD Arbitration Bittiming constants as per AXI CANFD 1.0 spec */
| static const struct can_bittiming_const xcan_bittiming_const_canfd = {
| 	.name = DRIVER_NAME,
| 	.tseg1_min = 1,
| 	.tseg1_max = 64,
| 	.tseg2_min = 1,
| 	.tseg2_max = 16,
| 	.sjw_max = 16,
                   ^^
Does not match due to "sjw 1..128".

| 	.brp_min = 1,
| 	.brp_max = 256,
| 	.brp_inc = 1,
| };
| 
| /* AXI CANFD Data Bittiming constants as per AXI CANFD 1.0 specs */
| static struct can_bittiming_const xcan_data_bittiming_const_canfd = {
| 	.name = DRIVER_NAME,
| 	.tseg1_min = 1,
| 	.tseg1_max = 16,
| 	.tseg2_min = 1,
| 	.tseg2_max = 8,
| 	.sjw_max = 8,
                   ^
Does not match due to "dsjw 1..16"

| 	.brp_min = 1,
| 	.brp_max = 256,
| 	.brp_inc = 1,
| };
| 
| /* AXI CANFD 2.0 Arbitration Bittiming constants as per AXI CANFD 2.0 spec */
| static const struct can_bittiming_const xcan_bittiming_const_canfd2 = {
| 	.name = DRIVER_NAME,
| 	.tseg1_min = 1,
| 	.tseg1_max = 256,
| 	.tseg2_min = 1,
| 	.tseg2_max = 128,
| 	.sjw_max = 128,
| 	.brp_min = 2,
                   ^
Does not match due to "brp 1..256".

| 	.brp_max = 256,
| 	.brp_inc = 1,
| };
| 
| /* AXI CANFD 2.0 Data Bittiming constants as per AXI CANFD 2.0 spec */
| static struct can_bittiming_const xcan_data_bittiming_const_canfd2 = {
| 	.name = DRIVER_NAME,
| 	.tseg1_min = 1,
| 	.tseg1_max = 32,
| 	.tseg2_min = 1,
| 	.tseg2_max = 16,
| 	.sjw_max = 16,
| 	.brp_min = 2,
                   ^
Does not match due to "dbrp 1..256".

| 	.brp_max = 256,
| 	.brp_inc = 1,
| };

Can you send patches to update the xilinx CAN driver?

I'm continue working on the CAN bittiming 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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-02-21 14:43       ` Srinivas Neeli
  2022-02-21 20:27         ` Marc Kleine-Budde
  2022-03-17 22:00         ` Marc Kleine-Budde
@ 2022-03-17 22:50         ` Marc Kleine-Budde
  2022-03-18  6:55           ` Srinivas Neeli
  2 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-17 22:50 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > Can you also provide the hand calculated bit timing parameters for
> > the above scenarios?
> 
> Baud rate 1/5Mbps
> ================
> 
> Hand configuration:
> --------------------------- 
> ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1 dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 dsjw 1 fd on  (A/D: 1/5Mbps, Sample point=75%)
> 
> Baud rate 1/4Mbps
> ================
> 
> Hand configuration:
> --------------------------
> ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1 dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1 fd on (A/D: 1/4Mbps, Sample point=75%)

I've updated the algorithm to prefer lower brp values. Can you check if
these values make sense to you?

| $ ./can-calc-bit-timing --alg=can-next xilinx_dwnstrm -c 79999999
| Bit timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock (cmd-line) using algo 'can-next'
|  nominal                                  real  Bitrt    nom   real  SampP
|  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error   
|  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%   
|   800000     12  39   40   20   1   1   799999   0.0%  80.0%  80.0%   0.0%   
|   666666     12  47   48   24   1   1   666666   0.0%  80.0%  80.0%   0.0%   
|   500000     12  69   70   20   1   1   499999   0.0%  87.5%  87.5%   0.0%   
|   250000     25  69   70   20   1   2   249999   0.0%  87.5%  87.5%   0.0%   
|   125000     50  69   70   20   1   4   124999   0.0%  87.5%  87.5%   0.0%   
|   100000     50  87   87   25   1   4    99999   0.0%  87.5%  87.5%   0.0%   
|    83333     50 104  105   30   1   4    83333   0.0%  87.5%  87.5%   0.0%   
|    50000    100  87   87   25   1   8    49999   0.0%  87.5%  87.5%   0.0%   
|    33333    125 104  105   30   1  10    33333   0.0%  87.5%  87.5%   0.0%   
|    20000    250  87   87   25   1  20    19999   0.0%  87.5%  87.5%   0.0%   
|    10000    500  87   87   25   1  40     9999   0.0%  87.5%  87.5%   0.0%   
| 
| Bit timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock (cmd-line) using algo 'can-next'
|  nominal                                  real  Bitrt    nom   real  SampP
|  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error   
| 12000000     12   2    2    2   1   1 11428571   4.8%  75.0%  71.4%   4.8%   
| 10000000     12   2    3    2   1   1  9999999   0.0%  75.0%  75.0%   0.0%   
|  8000000     12   3    3    3   1   1  7999999   0.0%  75.0%  70.0%   6.7%   
|  5000000     12   5    6    4   1   1  4999999   0.0%  75.0%  75.0%   0.0%   
|  4000000     12   7    7    5   1   1  3999999   0.0%  75.0%  75.0%   0.0%   
|  2000000     12  14   15   10   1   1  1999999   0.0%  75.0%  75.0%   0.0%   
|  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%   

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] 21+ messages in thread

* RE: Queries on CAN frame work
  2022-03-17 22:00         ` Marc Kleine-Budde
@ 2022-03-18  6:12           ` Srinivas Neeli
  2022-03-18  8:30             ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Srinivas Neeli @ 2022-03-18  6:12 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

Hi Marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: Friday, March 18, 2022 3:31 AM
> To: Srinivas Neeli <sneeli@xilinx.com>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: Re: Queries on CAN frame work
> 
> On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > > Can you please provide me:
> > > - the bit timing constants of the IP core for the arbitration and data
> > >   phase
> > > - the bit rate for the arbitration and data phase
> > >   (especially where the framework calculates not common prescalers)
> > > - the clock rate of the CAN bus clock
> > >
> > > Can you also provide the hand calculated bit timing parameters for
> > > the above scenarios?
> >
> > Baud rate 1/5Mbps
> > ================
> > root@xilinx-vck190-2021_1:~# ip link set can6 type can bitrate 1000000
> dbitrate 5000000 fd on
> > [   26.837057] xilinx_can ff070000.can can6: bitrate error 0.0%
> > [   26.842731] xilinx_can ff070000.can can6: bitrate error 0.0%
> >  can6 txqroot@xilinx-vck190-2021_1:~# ifconfig can6 txqueuelen 1000
> > root@xilinx-vck190-2021_1:~# ip link set can6 up
> > [   27.340880] IPv6: ADDRCONF(NETDEV_CHANGE): can6: link becomes
> ready
> > root@xilinx-vck190-2021_1:~# ip -d -s link show can6
> >  can6: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP
> mode DEFAULT group default qlen 1000
> >     link/can  promiscuity 0 minmtu 0 maxmtu 0
> >     can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
> > 	  bitrate 999999 sample-point 0.750
> > 	  tq 250 prop-seg 1 phase-seg1 1 phase-seg2 1 sjw 1
> > 	  xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
> > 	  dbitrate 4999999 dsample-point 0.750
> > 	  dtq 50 dprop-seg 1 dphase-seg1 1 dphase-seg2 1 dsjw 1
> > 	  xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc
> 1
> > 	  clock 79999999
> > 	  re-started bus-errors arbit-lost error-warn error-pass bus-off
> > 	  0          0          0          0          0          0         numtxqueues 1
> numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
> >     RX: bytes  packets  errors  dropped overrun mcast
> >     0          0        0       0       0       0
> >     TX: bytes  packets  errors  dropped carrier collsns
> >     0          0        0       0       0       0
> 
> Are you using the mainline xilinx_can driver? The "ip" command says, you're
> using:

Yes , mainline and internal drivers are same.
Xilinx maintains common driver for multiple CAN and CANFD  IP's.
Xilinx supports below CAN IP's:
xlnx,zynq-can-1.0 (zynq platform & zynqmp platform)
xlnx,axi-can-1.00.a ( Soft IP version 1.00)
xlnx,canfd-1.0 (Soft canfd ip version 1.0)
xlnx,canfd-2.0(Soft canfd ip Version 2.0)
xlnx,canfd2.0 equal to versal canfd ip, so using same compatible string for both.

For each ip sjw_max and brp values are different.
Due to this reason created multiple bit timing structures.

> 
> >  sjw 1..128  brp 1..256
> > dsjw 1..16  dbrp 1..256
> 
> Looking at the mainline xilinx driver, we have:
> 
> | /* CAN Bittiming constants as per Xilinx CAN specs */ static const
> | struct can_bittiming_const xcan_bittiming_const = {
> | 	.name = DRIVER_NAME,
> | 	.tseg1_min = 1,
> | 	.tseg1_max = 16,
> | 	.tseg2_min = 1,
> | 	.tseg2_max = 8,
> | 	.sjw_max = 4,
>                    ^
> Does not match due to "sjw 1..128".
> 
> | 	.brp_min = 1,
> | 	.brp_max = 256,
> | 	.brp_inc = 1,
> | };
> |
> | /* AXI CANFD Arbitration Bittiming constants as per AXI CANFD 1.0 spec
> | */ static const struct can_bittiming_const xcan_bittiming_const_canfd = {
> | 	.name = DRIVER_NAME,
> | 	.tseg1_min = 1,
> | 	.tseg1_max = 64,
> | 	.tseg2_min = 1,
> | 	.tseg2_max = 16,
> | 	.sjw_max = 16,
>                    ^^
> Does not match due to "sjw 1..128".
> 
> | 	.brp_min = 1,
> | 	.brp_max = 256,
> | 	.brp_inc = 1,
> | };
> |
> | /* AXI CANFD Data Bittiming constants as per AXI CANFD 1.0 specs */
> | static struct can_bittiming_const xcan_data_bittiming_const_canfd = {
> | 	.name = DRIVER_NAME,
> | 	.tseg1_min = 1,
> | 	.tseg1_max = 16,
> | 	.tseg2_min = 1,
> | 	.tseg2_max = 8,
> | 	.sjw_max = 8,
>                    ^
> Does not match due to "dsjw 1..16"
> 
> | 	.brp_min = 1,
> | 	.brp_max = 256,
> | 	.brp_inc = 1,
> | };
> |
> | /* AXI CANFD 2.0 Arbitration Bittiming constants as per AXI CANFD 2.0
> | spec */ static const struct can_bittiming_const
> xcan_bittiming_const_canfd2 = {
> | 	.name = DRIVER_NAME,
> | 	.tseg1_min = 1,
> | 	.tseg1_max = 256,
> | 	.tseg2_min = 1,
> | 	.tseg2_max = 128,
> | 	.sjw_max = 128,
> | 	.brp_min = 2,
>                    ^
> Does not match due to "brp 1..256".
> 
> | 	.brp_max = 256,
> | 	.brp_inc = 1,
> | };
> |
> | /* AXI CANFD 2.0 Data Bittiming constants as per AXI CANFD 2.0 spec */
> | static struct can_bittiming_const xcan_data_bittiming_const_canfd2 = {
> | 	.name = DRIVER_NAME,
> | 	.tseg1_min = 1,
> | 	.tseg1_max = 32,
> | 	.tseg2_min = 1,
> | 	.tseg2_max = 16,
> | 	.sjw_max = 16,
> | 	.brp_min = 2,
>                    ^
> Does not match due to "dbrp 1..256".

Versal early silicon we observed bit enlarging issue with brp  =1 in side IP using simulaitons(Not observed on software side) , but it fixed in production silicon.
Plan to revert this patch to support TDC feature(To support higher baud rates we need brp =1).

> 
> | 	.brp_max = 256,
> | 	.brp_inc = 1,
> | };
> 
> Can you send patches to update the xilinx CAN driver?
> 
> I'm continue working on the CAN bittiming 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 |

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

* RE: Queries on CAN frame work
  2022-03-17 22:50         ` Marc Kleine-Budde
@ 2022-03-18  6:55           ` Srinivas Neeli
  2022-03-18  9:15             ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Srinivas Neeli @ 2022-03-18  6:55 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

Hi Marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: Friday, March 18, 2022 4:21 AM
> To: Srinivas Neeli <sneeli@xilinx.com>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: Re: Queries on CAN frame work
> 
> On 21.02.2022 14:43:57, Srinivas Neeli wrote:
> > > Can you also provide the hand calculated bit timing parameters for
> > > the above scenarios?
> >
> > Baud rate 1/5Mbps
> > ================
> >
> > Hand configuration:
> > ---------------------------
> > ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2
> > 20 sjw 1 dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 dsjw 1 fd on
> > (A/D: 1/5Mbps, Sample point=75%)
> >
> > Baud rate 1/4Mbps
> > ================
> >
> > Hand configuration:
> > --------------------------
> > ip link set can0 type can tq 12 prop-seg 29 phase-seg1 30 phase-seg2
> > 20 sjw 1 dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1 fd on
> > (A/D: 1/4Mbps, Sample point=75%)
> 
> I've updated the algorithm to prefer lower brp values. Can you check if these
> values make sense to you?

Thanks for update.
Few more changes need to update in algorithm.
1) Choose SJW as large as possible (we can assign " tseg2")

 For CANFD CIA recommendations :
 Recommendation 1: 
    Choose the highest available CAN clock frequency (20 MHz, 40 MHz, 80 MHz) 
Recommendation 2:
    Set the BRPA bit-rate pre-scaler equal BRPD
Recommendation 3:
    Choose BRPA and BRPD as low as possible.
Recommendation 4: 
    Configure all CAN FD nodes to have the same arbitration phase Sample point (SP) and the same data phase SP
Recommendation 5: 
    Choose SJWD and SJWA as large as possible (best is the max possible value)
Recommendation 6: 
    Enable TDC when needed 
     If we enable TDC feature ,please try to configure brp value 1 in algorithm(TDC feature support brp 1/2 but observed good results with 1).
> 
> | $ ./can-calc-bit-timing --alg=can-next xilinx_dwnstrm -c 79999999 Bit
> | timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock (cmd-
> line) using algo 'can-next'
> |  nominal                                  real  Bitrt    nom   real  SampP
> |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error
> |  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%

Observed different BRP values for 1Mbps in here and below list for same sampling point.

> |   800000     12  39   40   20   1   1   799999   0.0%  80.0%  80.0%   0.0%
> |   666666     12  47   48   24   1   1   666666   0.0%  80.0%  80.0%   0.0%
> |   500000     12  69   70   20   1   1   499999   0.0%  87.5%  87.5%   0.0%
> |   250000     25  69   70   20   1   2   249999   0.0%  87.5%  87.5%   0.0%
> |   125000     50  69   70   20   1   4   124999   0.0%  87.5%  87.5%   0.0%
> |   100000     50  87   87   25   1   4    99999   0.0%  87.5%  87.5%   0.0%
> |    83333     50 104  105   30   1   4    83333   0.0%  87.5%  87.5%   0.0%
> |    50000    100  87   87   25   1   8    49999   0.0%  87.5%  87.5%   0.0%
> |    33333    125 104  105   30   1  10    33333   0.0%  87.5%  87.5%   0.0%
> |    20000    250  87   87   25   1  20    19999   0.0%  87.5%  87.5%   0.0%
> |    10000    500  87   87   25   1  40     9999   0.0%  87.5%  87.5%   0.0%
> |
> | Bit timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock
> (cmd-line) using algo 'can-next'
> |  nominal                                  real  Bitrt    nom   real  SampP
> |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error
> | 12000000     12   2    2    2   1   1 11428571   4.8%  75.0%  71.4%   4.8%
> | 10000000     12   2    3    2   1   1  9999999   0.0%  75.0%  75.0%   0.0%
> |  8000000     12   3    3    3   1   1  7999999   0.0%  75.0%  70.0%   6.7%
> |  5000000     12   5    6    4   1   1  4999999   0.0%  75.0%  75.0%   0.0%
> |  4000000     12   7    7    5   1   1  3999999   0.0%  75.0%  75.0%   0.0%
> |  2000000     12  14   15   10   1   1  1999999   0.0%  75.0%  75.0%   0.0%
> |  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%

Here brp =2 and in above list brp =1.

> 
> 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 |

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

* Re: Queries on CAN frame work
  2022-03-18  6:12           ` Srinivas Neeli
@ 2022-03-18  8:30             ` Marc Kleine-Budde
  2022-03-18  9:54               ` Srinivas Neeli
  0 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-18  8:30 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 18.03.2022 06:12:30, Srinivas Neeli wrote:
> > Are you using the mainline xilinx_can driver? The "ip" command says, you're
> > using:
> 
> Yes , mainline and internal drivers are same.

No, you are not. As explained in my last mail, there's no struct
can_bittiming_const in the mainline driver that matches your "ip"
output.

> Xilinx maintains common driver for multiple CAN and CANFD  IP's.
> Xilinx supports below CAN IP's:
> xlnx,zynq-can-1.0 (zynq platform & zynqmp platform)
> xlnx,axi-can-1.00.a ( Soft IP version 1.00)
> xlnx,canfd-1.0 (Soft canfd ip version 1.0)
> xlnx,canfd-2.0(Soft canfd ip Version 2.0)
> xlnx,canfd2.0 equal to versal canfd ip, so using same compatible string for both.
> 
> For each ip sjw_max and brp values are different.
> Due to this reason created multiple bit timing structures.

ACK. But your driver is obviously different to the mainline driver (see
above).

> > >  sjw 1..128  brp 1..256
> > > dsjw 1..16  dbrp 1..256
> > 
> > Looking at the mainline xilinx driver, we have:
> > 
> > | /* CAN Bittiming constants as per Xilinx CAN specs */ static const
> > | struct can_bittiming_const xcan_bittiming_const = {
> > | 	.name = DRIVER_NAME,
> > | 	.tseg1_min = 1,
> > | 	.tseg1_max = 16,
> > | 	.tseg2_min = 1,
> > | 	.tseg2_max = 8,
> > | 	.sjw_max = 4,
> >                    ^
> > Does not match due to "sjw 1..128".
> > 
> > | 	.brp_min = 1,
> > | 	.brp_max = 256,
> > | 	.brp_inc = 1,
> > | };
> > |
> > | /* AXI CANFD Arbitration Bittiming constants as per AXI CANFD 1.0 spec
> > | */ static const struct can_bittiming_const xcan_bittiming_const_canfd = {
> > | 	.name = DRIVER_NAME,
> > | 	.tseg1_min = 1,
> > | 	.tseg1_max = 64,
> > | 	.tseg2_min = 1,
> > | 	.tseg2_max = 16,
> > | 	.sjw_max = 16,
> >                    ^^
> > Does not match due to "sjw 1..128".
> > 
> > | 	.brp_min = 1,
> > | 	.brp_max = 256,
> > | 	.brp_inc = 1,
> > | };
> > |
> > | /* AXI CANFD Data Bittiming constants as per AXI CANFD 1.0 specs */
> > | static struct can_bittiming_const xcan_data_bittiming_const_canfd = {
> > | 	.name = DRIVER_NAME,
> > | 	.tseg1_min = 1,
> > | 	.tseg1_max = 16,
> > | 	.tseg2_min = 1,
> > | 	.tseg2_max = 8,
> > | 	.sjw_max = 8,
> >                    ^
> > Does not match due to "dsjw 1..16"
> > 
> > | 	.brp_min = 1,
> > | 	.brp_max = 256,
> > | 	.brp_inc = 1,
> > | };
> > |
> > | /* AXI CANFD 2.0 Arbitration Bittiming constants as per AXI CANFD 2.0
> > | spec */ static const struct can_bittiming_const
> > xcan_bittiming_const_canfd2 = {
> > | 	.name = DRIVER_NAME,
> > | 	.tseg1_min = 1,
> > | 	.tseg1_max = 256,
> > | 	.tseg2_min = 1,
> > | 	.tseg2_max = 128,
> > | 	.sjw_max = 128,
> > | 	.brp_min = 2,
> >                    ^
> > Does not match due to "brp 1..256".
> > 
> > | 	.brp_max = 256,
> > | 	.brp_inc = 1,
> > | };
> > |
> > | /* AXI CANFD 2.0 Data Bittiming constants as per AXI CANFD 2.0 spec */
> > | static struct can_bittiming_const xcan_data_bittiming_const_canfd2 = {
> > | 	.name = DRIVER_NAME,
> > | 	.tseg1_min = 1,
> > | 	.tseg1_max = 32,
> > | 	.tseg2_min = 1,
> > | 	.tseg2_max = 16,
> > | 	.sjw_max = 16,
> > | 	.brp_min = 2,
> >                    ^
> > Does not match due to "dbrp 1..256".
> 
> Versal early silicon we observed bit enlarging issue with brp  =1 in
> side IP using simulaitons(Not observed on software side) , but it
> fixed in production silicon.
> 
> Plan to revert this patch to support TDC feature(To support higher
> baud rates we need brp =1).

Ok.

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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-03-18  6:55           ` Srinivas Neeli
@ 2022-03-18  9:15             ` Marc Kleine-Budde
  2022-03-18 10:15               ` Srinivas Neeli
  2022-03-18 13:57               ` Marc Kleine-Budde
  0 siblings, 2 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-18  9:15 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 18.03.2022 06:55:56, Srinivas Neeli wrote:
> > I've updated the algorithm to prefer lower brp values. Can you check
> > if these values make sense to you?
> 
> Thanks for update.
> Few more changes need to update in algorithm.
> 1) Choose SJW as large as possible (we can assign " tseg2")

ACK - changes to SJW needs still to be done.

>  For CANFD CIA recommendations :
>  Recommendation 1: 
>     Choose the highest available CAN clock frequency (20 MHz, 40 MHz, 80 MHz) 
> Recommendation 2:
>     Set the BRPA bit-rate pre-scaler equal BRPD
> Recommendation 3:
>     Choose BRPA and BRPD as low as possible.
> Recommendation 4: 
>     Configure all CAN FD nodes to have the same arbitration phase Sample point (SP) and the same data phase SP
> Recommendation 5: 
>     Choose SJWD and SJWA as large as possible (best is the max possible value)
> Recommendation 6: 
>     Enable TDC when needed 
>      If we enable TDC feature ,please try to configure brp value 1 in algorithm(TDC feature support brp 1/2 but observed good results with 1).
> > 
> > | $ ./can-calc-bit-timing --alg=can-next xilinx_dwnstrm -c 79999999 Bit
> > | timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock (cmd-
> > line) using algo 'can-next'
> > |  nominal                                  real  Bitrt    nom   real  SampP
> > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error
> > |  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%
> 
> Observed different BRP values for 1Mbps in here and below list for
> same sampling point.

Yes. Seems I should update the table to clarify what they output.

The 1st table uses the CAN-2.0 bit timing constants, the 2nd table is
using the CAN-FD data bit timing constants.

> > |   800000     12  39   40   20   1   1   799999   0.0%  80.0%  80.0%   0.0%
> > |   666666     12  47   48   24   1   1   666666   0.0%  80.0%  80.0%   0.0%
> > |   500000     12  69   70   20   1   1   499999   0.0%  87.5%  87.5%   0.0%
> > |   250000     25  69   70   20   1   2   249999   0.0%  87.5%  87.5%   0.0%
> > |   125000     50  69   70   20   1   4   124999   0.0%  87.5%  87.5%   0.0%
> > |   100000     50  87   87   25   1   4    99999   0.0%  87.5%  87.5%   0.0%
> > |    83333     50 104  105   30   1   4    83333   0.0%  87.5%  87.5%   0.0%
> > |    50000    100  87   87   25   1   8    49999   0.0%  87.5%  87.5%   0.0%
> > |    33333    125 104  105   30   1  10    33333   0.0%  87.5%  87.5%   0.0%
> > |    20000    250  87   87   25   1  20    19999   0.0%  87.5%  87.5%   0.0%
> > |    10000    500  87   87   25   1  40     9999   0.0%  87.5%  87.5%   0.0%
> > |
> > | Bit timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock
> > (cmd-line) using algo 'can-next'
> > |  nominal                                  real  Bitrt    nom   real  SampP
> > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error
> > | 12000000     12   2    2    2   1   1 11428571   4.8%  75.0%  71.4%   4.8%
> > | 10000000     12   2    3    2   1   1  9999999   0.0%  75.0%  75.0%   0.0%
> > |  8000000     12   3    3    3   1   1  7999999   0.0%  75.0%  70.0%   6.7%
> > |  5000000     12   5    6    4   1   1  4999999   0.0%  75.0%  75.0%   0.0%
> > |  4000000     12   7    7    5   1   1  3999999   0.0%  75.0%  75.0%   0.0%
> > |  2000000     12  14   15   10   1   1  1999999   0.0%  75.0%  75.0%   0.0%
> > |  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%
> 
> Here brp =2 and in above list brp =1.

According to the "ip" command's output, these are you timing parameters:

| 		.bittiming_const = {
| 			.name = "xilinx_dwnstrm",
| 			.tseg1_min = 1,
| 			.tseg1_max = 256,
| 			.tseg2_min = 1,
| 			.tseg2_max = 128,
| 			.sjw_max = 128,
| 			.brp_min = 1,
| 			.brp_max = 256,
| 			.brp_inc = 1,
| 		},
| 		.data_bittiming_const = {
| 			.name = "xilinx_dwnstrm",
| 			.tseg1_min = 1,
| 			.tseg1_max = 32,
| 			.tseg2_min = 1,
| 			.tseg2_max = 16,
| 			.sjw_max = 16,
| 			.brp_min = 1,
| 			.brp_max = 256,
| 			.brp_inc = 1,
| 		},

Note that for the data bit timing the tseg1_max is 32.

> > |  nominal                                  real  Bitrt    nom   real  SampP
> > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error
> > |  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%        <-- CAN-2.0
> > |  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%        <-- CAN-FD (data)
                       \_____/
                        tseg1

tseg1 = 14 + 15 = 29

With brp == 1 the tseg1 would be 29 + 30 = 59, which means it's too
large.

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] 21+ messages in thread

* RE: Queries on CAN frame work
  2022-03-18  8:30             ` Marc Kleine-Budde
@ 2022-03-18  9:54               ` Srinivas Neeli
  2022-03-18 10:01                 ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Srinivas Neeli @ 2022-03-18  9:54 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

Hi marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: Friday, March 18, 2022 2:01 PM
> To: Srinivas Neeli <sneeli@xilinx.com>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: Re: Queries on CAN frame work
> 
> On 18.03.2022 06:12:30, Srinivas Neeli wrote:
> > > Are you using the mainline xilinx_can driver? The "ip" command says,
> > > you're
> > > using:
> >
> > Yes , mainline and internal drivers are same.
> 
> No, you are not. As explained in my last mail, there's no struct
> can_bittiming_const in the mainline driver that matches your "ip"
> output.

Just cross checked the mainline driver and our internal driver.
I am not seeing difference in struct can_bittiming_const structures.
We are using 5 structures 
CAN - 1 structure
CANFD 1.0 - Arbitration 1, data phase 1
CANFD 2.0 - Arbitration 1, data phase 1
Please check below link once.
https://elixir.bootlin.com/linux/latest/source/drivers/net/can/xilinx_can.c#L216

Could you please let me know if I miss anything?

> 
> > Xilinx maintains common driver for multiple CAN and CANFD  IP's.
> > Xilinx supports below CAN IP's:
> > xlnx,zynq-can-1.0 (zynq platform & zynqmp platform)
> > xlnx,axi-can-1.00.a ( Soft IP version 1.00)
> > xlnx,canfd-1.0 (Soft canfd ip version 1.0) xlnx,canfd-2.0(Soft canfd
> > ip Version 2.0)
> > xlnx,canfd2.0 equal to versal canfd ip, so using same compatible string for
> both.
> >
> > For each ip sjw_max and brp values are different.
> > Due to this reason created multiple bit timing structures.
> 
> ACK. But your driver is obviously different to the mainline driver (see above).
> 
> > > >  sjw 1..128  brp 1..256
> > > > dsjw 1..16  dbrp 1..256
> > >
> > > Looking at the mainline xilinx driver, we have:
> > >
> > > | /* CAN Bittiming constants as per Xilinx CAN specs */ static const
> > > | struct can_bittiming_const xcan_bittiming_const = {
> > > | 	.name = DRIVER_NAME,
> > > | 	.tseg1_min = 1,
> > > | 	.tseg1_max = 16,
> > > | 	.tseg2_min = 1,
> > > | 	.tseg2_max = 8,
> > > | 	.sjw_max = 4,
> > >                    ^
> > > Does not match due to "sjw 1..128".
> > >
> > > | 	.brp_min = 1,
> > > | 	.brp_max = 256,
> > > | 	.brp_inc = 1,
> > > | };
> > > |
> > > | /* AXI CANFD Arbitration Bittiming constants as per AXI CANFD 1.0
> > > | spec */ static const struct can_bittiming_const
> xcan_bittiming_const_canfd = {
> > > | 	.name = DRIVER_NAME,
> > > | 	.tseg1_min = 1,
> > > | 	.tseg1_max = 64,
> > > | 	.tseg2_min = 1,
> > > | 	.tseg2_max = 16,
> > > | 	.sjw_max = 16,
> > >                    ^^
> > > Does not match due to "sjw 1..128".
> > >
> > > | 	.brp_min = 1,
> > > | 	.brp_max = 256,
> > > | 	.brp_inc = 1,
> > > | };
> > > |
> > > | /* AXI CANFD Data Bittiming constants as per AXI CANFD 1.0 specs
> > > | */ static struct can_bittiming_const xcan_data_bittiming_const_canfd =
> {
> > > | 	.name = DRIVER_NAME,
> > > | 	.tseg1_min = 1,
> > > | 	.tseg1_max = 16,
> > > | 	.tseg2_min = 1,
> > > | 	.tseg2_max = 8,
> > > | 	.sjw_max = 8,
> > >                    ^
> > > Does not match due to "dsjw 1..16"
> > >
> > > | 	.brp_min = 1,
> > > | 	.brp_max = 256,
> > > | 	.brp_inc = 1,
> > > | };
> > > |
> > > | /* AXI CANFD 2.0 Arbitration Bittiming constants as per AXI CANFD
> > > | 2.0 spec */ static const struct can_bittiming_const
> > > xcan_bittiming_const_canfd2 = {
> > > | 	.name = DRIVER_NAME,
> > > | 	.tseg1_min = 1,
> > > | 	.tseg1_max = 256,
> > > | 	.tseg2_min = 1,
> > > | 	.tseg2_max = 128,
> > > | 	.sjw_max = 128,
> > > | 	.brp_min = 2,
> > >                    ^
> > > Does not match due to "brp 1..256".
> > >
> > > | 	.brp_max = 256,
> > > | 	.brp_inc = 1,
> > > | };
> > > |
> > > | /* AXI CANFD 2.0 Data Bittiming constants as per AXI CANFD 2.0
> > > | spec */ static struct can_bittiming_const
> xcan_data_bittiming_const_canfd2 = {
> > > | 	.name = DRIVER_NAME,
> > > | 	.tseg1_min = 1,
> > > | 	.tseg1_max = 32,
> > > | 	.tseg2_min = 1,
> > > | 	.tseg2_max = 16,
> > > | 	.sjw_max = 16,
> > > | 	.brp_min = 2,
> > >                    ^
> > > Does not match due to "dbrp 1..256".
> >
> > Versal early silicon we observed bit enlarging issue with brp  =1 in
> > side IP using simulaitons(Not observed on software side) , but it
> > fixed in production silicon.
> >
> > Plan to revert this patch to support TDC feature(To support higher
> > baud rates we need brp =1).
> 
> Ok.
> 
> 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 |

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

* Re: Queries on CAN frame work
  2022-03-18  9:54               ` Srinivas Neeli
@ 2022-03-18 10:01                 ` Marc Kleine-Budde
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-18 10:01 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 18.03.2022 09:54:37, Srinivas Neeli wrote:
> > No, you are not. As explained in my last mail, there's no struct
> > can_bittiming_const in the mainline driver that matches your "ip"
> > output.
> 
> Just cross checked the mainline driver and our internal driver.
> I am not seeing difference in struct can_bittiming_const structures.
> We are using 5 structures 
> CAN - 1 structure
> CANFD 1.0 - Arbitration 1, data phase 1
> CANFD 2.0 - Arbitration 1, data phase 1
> Please check below link once.
> https://elixir.bootlin.com/linux/latest/source/drivers/net/can/xilinx_can.c#L216

static const struct can_bittiming_const xcan_bittiming_const = {
	.name = DRIVER_NAME,
	.tseg1_min = 1,
	.tseg1_max = 16,
	.tseg2_min = 1,
	.tseg2_max = 8,
	.sjw_max = 4,
	.brp_min = 1,
	.brp_max = 256,
	.brp_inc = 1,
};

Looking at your "ip" output

| https://lore.kernel.org/all/DM6PR02MB538689AA158B340FE287CF05AF3A9@DM6PR02MB5386.namprd02.prod.outlook.com/

it says:

          xilinx_can: tseg1 1..256 tseg2 1..128 sjw 1..128 brp 1..256 brp-inc 1
          xilinx_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..256 dbrp-inc 1

> Could you please let me know if I miss anything?

That does not match to the "struct can_bittiming_const
xcan_bittiming_const" you referenced
(https://elixir.bootlin.com/linux/latest/source/drivers/net/can/xilinx_can.c#L216).

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] 21+ messages in thread

* RE: Queries on CAN frame work
  2022-03-18  9:15             ` Marc Kleine-Budde
@ 2022-03-18 10:15               ` Srinivas Neeli
  2022-03-18 12:03                 ` Marc Kleine-Budde
  2022-03-18 13:57               ` Marc Kleine-Budde
  1 sibling, 1 reply; 21+ messages in thread
From: Srinivas Neeli @ 2022-03-18 10:15 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

Hi marc,

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: Friday, March 18, 2022 2:45 PM
> To: Srinivas Neeli <sneeli@xilinx.com>
> Cc: Srinivas Goud <sgoud@xilinx.com>; Naveen Kumar Gaddipati
> <naveenku@xilinx.com>; Prasad Beer Prasad <prasadbe@xilinx.com>; linux-
> can <linux-can@vger.kernel.org>; Stefan Mätje <stefan.maetje@esd.eu>;
> Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
> Subject: Re: Queries on CAN frame work
> 
> On 18.03.2022 06:55:56, Srinivas Neeli wrote:
> > > I've updated the algorithm to prefer lower brp values. Can you check
> > > if these values make sense to you?
> >
> > Thanks for update.
> > Few more changes need to update in algorithm.
> > 1) Choose SJW as large as possible (we can assign " tseg2")
> 
> ACK - changes to SJW needs still to be done.
Already we are assigning sjw = tseg2 in manual mode. Automatic we are assigning 1.
https://elixir.bootlin.com/linux/latest/source/drivers/net/can/dev/bittiming.c#L158

> 
> >  For CANFD CIA recommendations :
> >  Recommendation 1:
> >     Choose the highest available CAN clock frequency (20 MHz, 40 MHz,
> > 80 MHz) Recommendation 2:
> >     Set the BRPA bit-rate pre-scaler equal BRPD Recommendation 3:
> >     Choose BRPA and BRPD as low as possible.
> > Recommendation 4:
> >     Configure all CAN FD nodes to have the same arbitration phase
> > Sample point (SP) and the same data phase SP Recommendation 5:
> >     Choose SJWD and SJWA as large as possible (best is the max
> > possible value) Recommendation 6:
> >     Enable TDC when needed
> >      If we enable TDC feature ,please try to configure brp value 1 in
> algorithm(TDC feature support brp 1/2 but observed good results with 1).
> > >
> > > | $ ./can-calc-bit-timing --alg=can-next xilinx_dwnstrm -c 79999999
> > > | Bit timing parameters for xilinx_dwnstrm with 79.999999 MHz ref
> > > | clock (cmd-
> > > line) using algo 'can-next'
> > > |  nominal                                  real  Bitrt    nom   real  SampP
> > > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP
> Error
> > > |  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%
> >
> > Observed different BRP values for 1Mbps in here and below list for
> > same sampling point.
> 
> Yes. Seems I should update the table to clarify what they output.
> 
> The 1st table uses the CAN-2.0 bit timing constants, the 2nd table is using
> the CAN-FD data bit timing constants.
> 
> > > |   800000     12  39   40   20   1   1   799999   0.0%  80.0%  80.0%   0.0%
> > > |   666666     12  47   48   24   1   1   666666   0.0%  80.0%  80.0%   0.0%
> > > |   500000     12  69   70   20   1   1   499999   0.0%  87.5%  87.5%   0.0%
> > > |   250000     25  69   70   20   1   2   249999   0.0%  87.5%  87.5%   0.0%
> > > |   125000     50  69   70   20   1   4   124999   0.0%  87.5%  87.5%   0.0%
> > > |   100000     50  87   87   25   1   4    99999   0.0%  87.5%  87.5%   0.0%
> > > |    83333     50 104  105   30   1   4    83333   0.0%  87.5%  87.5%   0.0%
> > > |    50000    100  87   87   25   1   8    49999   0.0%  87.5%  87.5%   0.0%
> > > |    33333    125 104  105   30   1  10    33333   0.0%  87.5%  87.5%   0.0%
> > > |    20000    250  87   87   25   1  20    19999   0.0%  87.5%  87.5%   0.0%
> > > |    10000    500  87   87   25   1  40     9999   0.0%  87.5%  87.5%   0.0%
> > > |
> > > | Bit timing parameters for xilinx_dwnstrm with 79.999999 MHz ref
> > > | clock
> > > (cmd-line) using algo 'can-next'
> > > |  nominal                                  real  Bitrt    nom   real  SampP
> > > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP
> Error
> > > | 12000000     12   2    2    2   1   1 11428571   4.8%  75.0%  71.4%   4.8%
> > > | 10000000     12   2    3    2   1   1  9999999   0.0%  75.0%  75.0%   0.0%
> > > |  8000000     12   3    3    3   1   1  7999999   0.0%  75.0%  70.0%   6.7%
> > > |  5000000     12   5    6    4   1   1  4999999   0.0%  75.0%  75.0%   0.0%
> > > |  4000000     12   7    7    5   1   1  3999999   0.0%  75.0%  75.0%   0.0%
> > > |  2000000     12  14   15   10   1   1  1999999   0.0%  75.0%  75.0%   0.0%
> > > |  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%
> >
> > Here brp =2 and in above list brp =1.
> 
> According to the "ip" command's output, these are you timing parameters:
> 
> | 		.bittiming_const = {
> | 			.name = "xilinx_dwnstrm",
> | 			.tseg1_min = 1,
> | 			.tseg1_max = 256,
> | 			.tseg2_min = 1,
> | 			.tseg2_max = 128,
> | 			.sjw_max = 128,
> | 			.brp_min = 1,
> | 			.brp_max = 256,
> | 			.brp_inc = 1,
> | 		},
> | 		.data_bittiming_const = {
> | 			.name = "xilinx_dwnstrm",
> | 			.tseg1_min = 1,
> | 			.tseg1_max = 32,
> | 			.tseg2_min = 1,
> | 			.tseg2_max = 16,
> | 			.sjw_max = 16,
> | 			.brp_min = 1,
> | 			.brp_max = 256,
> | 			.brp_inc = 1,
> | 		},
> 
> Note that for the data bit timing the tseg1_max is 32.
> 
> > > |  nominal                                  real  Bitrt    nom   real  SampP
> > > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP
> Error
> > > |  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%
> <-- CAN-2.0
> > > |  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%
> <-- CAN-FD (data)
>                        \_____/
>                         tseg1
> 
> tseg1 = 14 + 15 = 29
> 
> With brp == 1 the tseg1 would be 29 + 30 = 59, which means it's too large.
Accepted, Thanks for clear explanation.
 
> 
> 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 |

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

* Re: Queries on CAN frame work
  2022-03-18 10:15               ` Srinivas Neeli
@ 2022-03-18 12:03                 ` Marc Kleine-Budde
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-18 12:03 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 18.03.2022 10:15:02, Srinivas Neeli wrote:
> > > Few more changes need to update in algorithm.
> > > 1) Choose SJW as large as possible (we can assign " tseg2")
> > 
> > ACK - changes to SJW needs still to be done.
> 
> Already we are assigning sjw = tseg2 in manual mode. Automatic we are assigning 1.
> https://elixir.bootlin.com/linux/latest/source/drivers/net/can/dev/bittiming.c#L158

You can set sjw and dsjw even if using automatic bit rate calculation:

| ip link set peakfd0 type can bitrate 1000000 sjw 2 dbitrate 5000000 dsjw 2 fd on

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] 21+ messages in thread

* Re: Queries on CAN frame work
  2022-03-18  9:15             ` Marc Kleine-Budde
  2022-03-18 10:15               ` Srinivas Neeli
@ 2022-03-18 13:57               ` Marc Kleine-Budde
  1 sibling, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2022-03-18 13:57 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: Srinivas Goud, Naveen Kumar Gaddipati, Prasad Beer Prasad,
	linux-can, Stefan Mätje, Vincent MAILHOL

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

On 18.03.2022 10:15:18, Marc Kleine-Budde wrote:
> > > | $ ./can-calc-bit-timing --alg=can-next xilinx_dwnstrm -c 79999999 Bit
> > > | timing parameters for xilinx_dwnstrm with 79.999999 MHz ref clock (cmd-
> > > line) using algo 'can-next'
> > > |  nominal                                  real  Bitrt    nom   real  SampP
> > > |  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error
> > > |  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%
> > 
> > Observed different BRP values for 1Mbps in here and below list for
> > same sampling point.
> 
> Yes. Seems I should update the table to clarify what they output.

Here's the updated output. It says now "Data" Bit timing parameters in
the 2nd table.

| Bit timing parameters for xilinx_can_fd2i with 79.999999 MHz ref clock (cmd-line) using algo 'can-next'
|  nominal                                  real  Bitrt    nom   real  SampP
|  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error   
|  1000000     12  29   30   20   1   1   999999   0.0%  75.0%  75.0%   0.0%   
|   800000     12  39   40   20   1   1   799999   0.0%  80.0%  80.0%   0.0%   
|   666666     12  47   48   24   1   1   666666   0.0%  80.0%  80.0%   0.0%   
|   500000     12  69   70   20   1   1   499999   0.0%  87.5%  87.5%   0.0%   
|   250000     25  69   70   20   1   2   249999   0.0%  87.5%  87.5%   0.0%   
|   125000     50  69   70   20   1   4   124999   0.0%  87.5%  87.5%   0.0%   
|   100000     50  87   87   25   1   4    99999   0.0%  87.5%  87.5%   0.0%   
|    83333     50 104  105   30   1   4    83333   0.0%  87.5%  87.5%   0.0%   
|    50000    100  87   87   25   1   8    49999   0.0%  87.5%  87.5%   0.0%   
|    33333    125 104  105   30   1  10    33333   0.0%  87.5%  87.5%   0.0%   
|    20000    250  87   87   25   1  20    19999   0.0%  87.5%  87.5%   0.0%   
|    10000    500  87   87   25   1  40     9999   0.0%  87.5%  87.5%   0.0%   
| 
| Data Bit timing parameters for xilinx_can_fd2i with 79.999999 MHz ref clock (cmd-line) using algo 'can-next'
|  nominal                                  real  Bitrt    nom   real  SampP
|  Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP  Bitrate  Error  SampP  SampP  Error   
| 12000000     12   2    2    2   1   1 11428571   4.8%  75.0%  71.4%   4.8%   
| 10000000     12   2    3    2   1   1  9999999   0.0%  75.0%  75.0%   0.0%   
|  8000000     12   3    3    3   1   1  7999999   0.0%  75.0%  70.0%   6.7%   
|  5000000     12   5    6    4   1   1  4999999   0.0%  75.0%  75.0%   0.0%   
|  4000000     12   7    7    5   1   1  3999999   0.0%  75.0%  75.0%   0.0%   
|  2000000     12  14   15   10   1   1  1999999   0.0%  75.0%  75.0%   0.0%   
|  1000000     25  14   15   10   1   2   999999   0.0%  75.0%  75.0%   0.0%   

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] 21+ messages in thread

end of thread, other threads:[~2022-03-18 13:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <DM6PR02MB538645C4ECE3BBBD3CE92A17AF539@DM6PR02MB5386.namprd02.prod.outlook.com>
2022-01-13 20:30 ` Queries on CAN frame work Marc Kleine-Budde
2022-01-13 21:10   ` Marc Kleine-Budde
2022-01-14 10:16     ` Vincent MAILHOL
2022-01-17 11:48       ` Marc Kleine-Budde
2022-01-15 23:26     ` Marc Kleine-Budde
2022-02-21 14:43       ` Srinivas Neeli
2022-02-21 20:27         ` Marc Kleine-Budde
2022-02-22  0:40           ` Srinivas Neeli
2022-03-06 14:30             ` Srinivas Neeli
2022-03-06 14:47               ` Marc Kleine-Budde
2022-03-17 22:00         ` Marc Kleine-Budde
2022-03-18  6:12           ` Srinivas Neeli
2022-03-18  8:30             ` Marc Kleine-Budde
2022-03-18  9:54               ` Srinivas Neeli
2022-03-18 10:01                 ` Marc Kleine-Budde
2022-03-17 22:50         ` Marc Kleine-Budde
2022-03-18  6:55           ` Srinivas Neeli
2022-03-18  9:15             ` Marc Kleine-Budde
2022-03-18 10:15               ` Srinivas Neeli
2022-03-18 12:03                 ` Marc Kleine-Budde
2022-03-18 13:57               ` Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.