lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E7B331F.3070801@grandegger.com>
Date:	Thu, 22 Sep 2011 15:07:43 +0200
From:	Wolfgang Grandegger <wg@...ndegger.com>
To:	Oliver Hartkopp <socketcan@...tkopp.net>
CC:	David Miller <davem@...emloft.net>,
	SocketCAN Core Mailing List <socketcan-core@...ts.berlios.de>,
	Linux Netdev List <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next v2] candev: allow SJW user setting for bittiming
 calculation

Hi Oliver,

On 09/22/2011 12:28 PM, Oliver Hartkopp wrote:
> This patch adds support for SJW user settings to not set the synchronization
> jump width (SJW) to 1 in any case when using the in-kernel bittiming
> calculation.
> 
> The ip-tool from iproute2 already supports to pass the user defined SJW
> value. The given SJW value is sanitized with the controller specific sjw_max
> and the calculated tseg2 value. As the SJW can have values up to 4 providing
> this value will lead to the maximum possible SJW automatically. A higher SJW
> allows higher controller oscillator tolerances.
> 
> Signed-off-by: Oliver Hartkopp <socketcan@...tkopp.net>
> 
> ---
> 
> v2: Resend due to wrong mail address header encoding.
> 
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 9bf1116..25695bd 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -150,7 +150,19 @@ static int can_calc_bittiming(struct net_device *dev,
> struct can_bittiming *bt)
>  	bt->prop_seg = tseg1 / 2;
>  	bt->phase_seg1 = tseg1 - bt->prop_seg;
>  	bt->phase_seg2 = tseg2;
> -	bt->sjw = 1;
> +
> +	/* check for sjw user settings */
> +	if (!bt->sjw || !btc->sjw_max)
> +		bt->sjw = 1;
> +	else {
> +		/* bt->sjw is at least 1 -> sanitize upper bound to sjw_max */
> +		if (bt->sjw > btc->sjw_max)
> +			bt->sjw = btc->sjw_max;
> +		/* bt->sjw must not be higher than tseg2 */
> +		if (tseg2 < bt->sjw)
> +			bt->sjw = tseg2;
> +	}
> +

As I already said, I expected "bt->sjw" to be always 0 when
can_calc_bittiming() is called. But the software somehow allows to
preset "bt->sjw", which is not intended as the help of the ip utility shows:

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

I actually hesitate to extend can_calc_bittiming(). I suggest using an
external tool to calculate proper bit-timing parameters and set them
with "ip link set DEVICE type can tq ...".

See also:

http://lxr.linux.no/#linux+v3.0.4/Documentation/networking/can.txt#L742

Wolfgang.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ