Linux CAN drivers development
 help / color / mirror / Atom feed
From: Rostislav Lisovy <lisovy@gmail.com>
To: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>,
	Karsten Aalykke Stenzhorn <Karsten.Stenzhorn@marel.com>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Subject: Re: Fwd: Using TC from iproute, unable to match canid
Date: Mon, 25 Nov 2013 18:37:07 +0100	[thread overview]
Message-ID: <1385401027.16954.11.camel@umadbro> (raw)
In-Reply-To: <201311251757.12012.pisa@cmp.felk.cvut.cz>

Hello;
I tried the example from the PDF and it worked for me. I am using Ubuntu
12.10 (Linux kernel 3.5.0-43-generic) with x86 CPU (32-bit Little
Endian).
You have to be careful, that it is necessary to byte-swap the ID used
with the 'u32 match' according to the architecture used.
For CAN ID 0x123 on LE the matching rule is 0x23010000, on BE it should
be 0x00000123.
You can also try to set the mask only for significant bits in the CAN ID
(i.e. 0xff070000 for LE, or 0x000007ff for BE).

The exact commands I used:

modprobe can
modprobe can-raw
modprobe vcan
ip link add dev vcan0 type vcan
ip link set vcan0 up
ifconfig -a

> vcan0     Link encap:UNSPEC  HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
>           NOARP  MTU:16  Metric:1
>           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:0 
>           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tc qdisc add dev vcan0 root handle 1: prio bands 5

tc -s class show dev vcan0
> class prio 1:1 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:2 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:3 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:4 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:5 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 

tc filter add dev vcan0 parent 1:0 prio 1 u32 match u32 0x01000000
0xffffffff at 0 flowid 1:1

cangen -I 0x2 -L 1 vcan0 -n 22 -g 1
tc -s class show dev vcan0
> class prio 1:1 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:2 parent 1: 
>  Sent 352 bytes 22 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:3 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:4 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:5 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 

cangen -I 0x1 -L 1 vcan0 -n 11 -g 1
> class prio 1:1 parent 1: 
>  Sent 176 bytes 11 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:2 parent 1: 
>  Sent 352 bytes 22 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:3 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:4 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 
> class prio 1:5 parent 1: 
>  Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) 
>  backlog 0b 0p requeues 0 


Best regards;
Rostislav Lisovy



On Mon, 2013-11-25 at 17:57 +0100, Pavel Pisa wrote:
> 
> ----------  Forwarded Message  ----------
> 
> Subject: Using TC from iproute, unable to match canid
> Date: Monday 25 of November 2013, 17:49:02
> From: Karsten Aalykke Stenzhorn <Karsten.Stenzhorn@marel.com>
> To: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
> 
> I'm trying to use tc from iproute2 to prioritize packets sent to a canbus.
> 
> Before doing so I read this guide about the 
> issue: http://rtime.felk.cvut.cz/can/socketcan-qdisc-final.pdf
> Even using the exact examples from that pdf, I'm not able get any of the 
> filters to get a match. My current version of kernel and tc only allows me to 
> use the u32 match option.
> 
> Tried (both big and little endian):
> 
> tc filter add dev can0 parent 1:0 prio 1 u32 match u32 0x01000000 0xffffffff 
> at 0 flowid 1:1
> 
> and also:
> 
> tc filter add dev can0 parent 1:0 prio 1 u32 match u8 0x01 0xff at 4 flowid 
> 1:1
> 
> Sending packets to fit those filters does not trigger a match. I'm a bit 
> confused why exact examples from the guide does not seem to work.
> 
> Any hints or experience on this would be much appreciated.
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> -------------------------------------------------------



           reply	other threads:[~2013-11-25 17:37 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <201311251757.12012.pisa@cmp.felk.cvut.cz>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385401027.16954.11.camel@umadbro \
    --to=lisovy@gmail.com \
    --cc=Karsten.Stenzhorn@marel.com \
    --cc=linux-can@vger.kernel.org \
    --cc=pisa@cmp.felk.cvut.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox