• Vincent Mailhol's avatar
    can: bittiming: add calculation for CAN FD Transmitter Delay Compensation (TDC) · c25cc799
    Vincent Mailhol authored
    The logic for the tdco calculation is to just reuse the normal sample
    point: tdco = sp. Because the sample point is expressed in tenth of
    percent and the tdco is expressed in time quanta, a conversion is
    needed.
    
    At the end,
         ssp = tdcv + tdco
             = tdcv + sp.
    
    Another popular method is to set tdco to the middle of the bit:
         tdc->tdco = can_bit_time(dbt) / 2
    During benchmark tests, we could not find a clear advantages for one
    of the two methods.
    
    The tdco calculation is triggered each time the data_bittiming is
    changed so that users relying on automated calculation can use the
    netlink interface the exact same way without need of new parameters.
    For example, a command such as:
    	ip link set canX type can bitrate 500000 dbitrate 4000000 fd on
    would trigger the calculation.
    
    The user using CONFIG_CAN_CALC_BITTIMING who does not want automated
    calculation needs to manually set tdco to zero.
    For example with:
    	ip link set canX type can tdco 0 bitrate 500000 dbitrate 4000000 fd on
    (if the tdco parameter is provided in a previous command, it will be
    overwritten).
    
    If tdcv is set to zero (default), it is automatically calculated by
    the transiver for each frame. As such, there is no code in the kernel
    to calculate it.
    
    tdcf has no automated calculation functions because we could not
    figure out a formula for this parameter.
    
    Link: https://lore.kernel.org/r/20210224002008.4158-6-mailhol.vincent@wanadoo.frSigned-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
    Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
    c25cc799
netlink.c 10.9 KB