]> git.ipfire.org Git - thirdparty/iproute2.git/commit
iplink_can: fix configuration ranges in print_usage() and add unit
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Wed, 3 Nov 2021 16:44:24 +0000 (01:44 +0900)
committerDavid Ahern <dsahern@kernel.org>
Thu, 4 Nov 2021 15:42:23 +0000 (09:42 -0600)
commit8316df6e6db4de2f20b7fa976a6d4f9992dda7b1
tree5534ec0724d75e6c7cdf533eca822820918d1dd5
parent6e15d27aae947510efd824c7ce4bc7ea3b8a5aae
iplink_can: fix configuration ranges in print_usage() and add unit

The configuration ranges in print_usage() are taken from "Table 8 -
Time segments' minimum configuration ranges" in section 11.3.1.2
"Configuration of the bit time parameters" of ISO 11898-1.

The standard clearly specifies that "implementations may allow time
segments that exceed the minimum required configuration ranges
specified in Table 8".

Because no maximum ranges are given in the standard, all given ranges
{ a..b } are simply replaced with { NUMBER }.

The actual ranges are specific to each device and can be confirmed
doing:

$ ip --details link show can0
1: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state STOPPED restart-ms 0
  ES582.1/ES584.1: tseg1 2..256 tseg2 2..128 sjw 1..128 brp 1..512 brp-inc 1
  ES582.1/ES584.1: dtseg1 2..32 dtseg2 1..16 dsjw 1..8 dbrp 1..32 dbrp-inc 1
  clock 80000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

Finally, the unit (bps, tq, ns or ms) are given. The rationale to add
the units is that the TDC parameters (that will be introduced in the
upcoming patches) are measured in a different unit than the other
bittiming parameters: clock period (a.k.a. minimum time quantum)
instead of time quantum. Adding the units disambiguates things.

For reference, before the change:
$ ip link set can0 type can help
Usage: ip link set DEVICE type can
[ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
[ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
    phase-seg2 PHASE-SEG2 [ sjw SJW ] ]

[ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] |
[ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1
    dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ]

[ loopback { on | off } ]
[ listen-only { on | off } ]
[ triple-sampling { on | off } ]
[ one-shot { on | off } ]
[ berr-reporting { on | off } ]
[ fd { on | off } ]
[ fd-non-iso { on | off } ]
[ presume-ack { on | off } ]

[ restart-ms TIME-MS ]
[ restart ]

[ termination { 0..65535 } ]

Where: BITRATE := { 1..1000000 }
  SAMPLE-POINT := { 0.000..0.999 }
  TQ := { NUMBER }
  PROP-SEG := { 1..8 }
  PHASE-SEG1 := { 1..8 }
  PHASE-SEG2 := { 1..8 }
  SJW := { 1..4 }
  RESTART-MS := { 0 | NUMBER }

...and after it:
$ ip link set can0 type can help
Usage: ip link set DEVICE type can
[ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
[ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
    phase-seg2 PHASE-SEG2 [ sjw SJW ] ]

[ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] |
[ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1
    dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ]

[ loopback { on | off } ]
[ listen-only { on | off } ]
[ triple-sampling { on | off } ]
[ one-shot { on | off } ]
[ berr-reporting { on | off } ]
[ fd { on | off } ]
[ fd-non-iso { on | off } ]
[ presume-ack { on | off } ]
[ cc-len8-dlc { on | off } ]

[ restart-ms TIME-MS ]
[ restart ]

[ termination { 0..65535 } ]

Where: BITRATE := { NUMBER in bps }
  SAMPLE-POINT := { 0.000..0.999 }
  TQ := { NUMBER in ns }
  PROP-SEG := { NUMBER in tq }
  PHASE-SEG1 := { NUMBER in tq }
  PHASE-SEG2 := { NUMBER in tq }
  SJW := { NUMBER in tq }
  RESTART-MS := { 0 | NUMBER in ms }

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iplink_can.c