can: Add constants containing length of CAN identifiers
Subsystems (4)
PATCH 1/2 can: Add constants containing length of CAN identifiers
The necessary information might be determined out of the CAN_*_MASK, however it is undesirable to misuse masks for such purpose.
--- include/linux/can.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/can.h +3 -0
@@ -38,6 +38,9 @@*/ typedef __u32 canid_t ; +#define CAN_SFF_ID_BITS 11 +#define CAN_EFF_ID_BITS 29 +/* * Controller Area Network Error Frame Mask structure *
Signature · 1 line
1.7.9.5
PATCH 2/2 net/sched: CAN Filter/Classifier
This classifier classifies CAN frames (AF_CAN) according to their identifiers. This functionality can not be easily achieved with existing classifiers, such as u32. This classifier can be used with any available qdisc and it is able to classify both SFF or EFF frames.
The filtering rules for EFF frames are stored in an array, which is traversed during classification. A bitmap is used to store SFF rules -- one bit for each ID.
More info about the project:
http://rtime.felk.cvut.cz/can/socketcan-qdisc-final.pdf
--- net/sched/Kconfig | 10 + net/sched/Makefile | 1 + net/sched/cls_can.c | 572 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 583 insertions(+) create mode 100644 net/sched/cls_can.c
net/sched/Kconfig +10 -0
@@ -323,6 +323,16 @@ config NET_CLS_BASIC To compile this code as a module, choose M here: the module will be called cls_basic. +config NET_CLS_CAN + tristate "Controller Area Network classifier (CAN)" + select NET_CLS + ---help--- + Say Y here if you want to be able to classify CAN frames according + to their CAN identifiers (can_id). + + To compile this code as a module, choose M here: the + module will be called cls_can. + config NET_CLS_TCINDEX tristate "Traffic-Control Index (TCINDEX)" select NET_CLS
net/sched/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_NET_CLS_RSVP) += cls_rsvp.o obj-$(CONFIG_NET_CLS_TCINDEX) += cls_tcindex.o obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o obj-$(CONFIG_NET_CLS_BASIC) += cls_basic.o +obj-$(CONFIG_NET_CLS_CAN) += cls_can.o obj-$(CONFIG_NET_CLS_FLOW) += cls_flow.o obj-$(CONFIG_NET_CLS_CGROUP) += cls_cgroup.o obj-$(CONFIG_NET_EMATCH) += ematch.o
net/sched/cls_can.c new file +572 -0
572 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] net/sched: CAN Filter/Classifier
Quoted 13 lines · Rostislav Lisovy
This classifier classifies CAN frames (
AF_CAN) according to their identifiers. This functionality can not be easily achieved with existing classifiers, such as u32. This classifier can be used with any available qdisc and it is able to classify both SFF or EFF frames.The filtering rules for EFF frames are stored in an array, which is traversed during classification. A bitmap is used to store SFF rules -- one bit for each ID.
More info about the project:
http://rtime.felk.cvut.cz/can/socketcan-qdisc-final.pdf
Quoted 7 lines
Signed-off-by Rostislav Lisovy <[email protected]>--- net/sched/Kconfig | 10 + net/sched/Makefile | 1 + net/sched/cls_can.c | 572 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 583 insertions(+) create mode 100644 net/sched/cls_can.c
It seems a huge amount of code, and before reviewing it I would like to ask :
1) Did you try to extend cls_flow somehow ?
2) Adding a cls_filter (or extend cls_flow to be able to use a bpf), could be more generic, and thanks to bpf jit could be way faster.
3) sfq/fq_codel could be CAN aware if you adapt skb_flow_dissect() ?
Re: [PATCH 2/2] net/sched: CAN Filter/Classifier
Quoted 22 lines · Eric Dumazet
Quoted 13 lines · Rostislav Lisovy
This classifier classifies CAN frames (
AF_CAN) according to their identifiers. This functionality can not be easily achieved with existing classifiers, such as u32. This classifier can be used with any available qdisc and it is able to classify both SFF or EFF frames.The filtering rules for EFF frames are stored in an array, which is traversed during classification. A bitmap is used to store SFF rules -- one bit for each ID.
More info about the project:
http://rtime.felk.cvut.cz/can/socketcan-qdisc-final.pdfQuoted 7 lines
Signed-off-by Rostislav Lisovy <[email protected]>--- net/sched/Kconfig | 10 + net/sched/Makefile | 1 + net/sched/cls_can.c | 572 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 583 insertions(+) create mode 100644 net/sched/cls_can.c
Quoted 4 lines
It seems a huge amount of code, and before reviewing it I would like to ask :
1) Did you try to extend
cls_flowsomehow ?
I did not. If I understand it right, cls_flow is intended to be mainly used with SFQ qdisc (which tries to ensure fairness among different flows).
My intention was to make a simple and deterministic filter (which may be used with any available qdisc).
However, after thoroughly going through cls_flow I realized that implementing an ematch function (to be used with cls_basic or others) will preserve the functionality and save some code at the same time. Therefore I tend to implement a new ematch function and resubmit the patch later if it turns to be a good approach. What do you think?
Command syntax proposed in this patch was
tc filter add ... can sffid 0x123 sffid 0x500:0x700 effid 0x00:0xff ... An ematch could look like
tc filter add ... basic match 'canid(sff 0x123 sff 0x124:0x7f0 \
eff 0x1234)' ...
Quoted 2 lines
2) Adding a
cls_filter(or extendcls_flowto be able to use a bpf), could be more generic, and thanks to bpf jit could be way faster.
What do you mean with 'adding a cls_filter'?
BPF is useful only for filtering incoming data, isn't it?
Quoted 2 lines
3) sfq/fq_codel could be CAN aware if you adapt
skb_flow_dissect()?
I will try to implement "deterministic ematch" filter in the first place.
I may extend skb_flow_dissect() later.
Regards;
Rostislav Lisovy