All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 v2 0/3] CAN Filter/Classifier
@ 2012-07-27 10:02 Marc Kleine-Budde
  2012-07-27 10:02 ` [PATCH iproute2 v2 1/3] Add missing can.h Marc Kleine-Budde
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2012-07-27 10:02 UTC (permalink / raw)
  To: netdev; +Cc: linux-can, lartc, pisa, sojkam1, lisovy

Hello,

I'm reposting Rostislav's iproute2 patches, as Stephen requested,
during the v3.6 merge window with the corresponding kernel patches
already applied.

Changes since v1:
- use can.h generated by 'make headers_install' (tnx Stephen)
- remove some trailing whitespace

Now Rostislav original introduction message:

---

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

---

The following changes since commit fa1f7441a94670ecf5cbf8eb2ee19173437b5127:

  Remove reference to multipath algorithms in usage (2012-07-26 16:12:20 -0700)

are available in the git repository at:

  git://gitorious.org/linux-can/iproute2.git for-stephen

for you to fetch changes up to 1a83c82569763968200d2cabdf8f5bcbe7940f9b:

  CAN Filter/Classifier -- Documentation (2012-07-27 11:26:06 +0200)

----------------------------------------------------------------
Rostislav Lisovy (3):
      Add missing can.h
      CAN Filter/Classifier -- Source code
      CAN Filter/Classifier -- Documentation

 include/linux/can.h     |  161 ++++++++++++++++++++++++++++++++
 include/linux/pkt_cls.h |   10 ++
 man/man8/tc-can.8       |   97 +++++++++++++++++++
 tc/Makefile             |    1 +
 tc/f_can.c              |  237 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 506 insertions(+)
 create mode 100644 include/linux/can.h
 create mode 100644 man/man8/tc-can.8
 create mode 100644 tc/f_can.c



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH iproute2 v2 1/3] Add missing can.h
  2012-07-27 10:02 [PATCH iproute2 v2 0/3] CAN Filter/Classifier Marc Kleine-Budde
@ 2012-07-27 10:02 ` Marc Kleine-Budde
  2012-07-27 10:02 ` [PATCH iproute2 v2 2/3] CAN Filter/Classifier -- Source code Marc Kleine-Budde
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2012-07-27 10:02 UTC (permalink / raw)
  To: netdev; +Cc: linux-can, lartc, pisa, sojkam1, lisovy, Marc Kleine-Budde

From: Rostislav Lisovy <lisovy@gmail.com>

This patch imports the can.h generated from linux kernel (v3.6 merge
window - v3.5-6970-g25918f9) with 'make headers_install'. It contains
defines necessary for working with AF_CAN packets.

Signed-off-by: Rostislav Lisovy <lisovy@gmail.com>
[mkl: use 'make headers_install' in current kernel]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Changes since v1:
- use can.h generated by 'make headers_install' (tnx Stephen)

 include/linux/can.h |  161 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 include/linux/can.h

diff --git a/include/linux/can.h b/include/linux/can.h
new file mode 100644
index 0000000..018055e
--- /dev/null
+++ b/include/linux/can.h
@@ -0,0 +1,161 @@
+/*
+ * linux/can.h
+ *
+ * Definitions for CAN network layer (socket addr / CAN frame / CAN filter)
+ *
+ * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
+ *          Urs Thuermann   <urs.thuermann@volkswagen.de>
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ */
+
+#ifndef CAN_H
+#define CAN_H
+
+#include <linux/types.h>
+#include <linux/socket.h>
+
+/* controller area network (CAN) kernel definitions */
+
+/* special address description flags for the CAN_ID */
+#define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
+#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
+#define CAN_ERR_FLAG 0x20000000U /* error message frame */
+
+/* valid bits in CAN ID for frame formats */
+#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
+#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
+#define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
+
+/*
+ * Controller Area Network Identifier structure
+ *
+ * bit 0-28	: CAN identifier (11/29 bit)
+ * bit 29	: error message frame flag (0 = data frame, 1 = error message)
+ * bit 30	: remote transmission request flag (1 = rtr frame)
+ * bit 31	: frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
+ */
+typedef __u32 canid_t;
+
+#define CAN_SFF_ID_BITS		11
+#define CAN_EFF_ID_BITS		29
+
+/*
+ * Controller Area Network Error Message Frame Mask structure
+ *
+ * bit 0-28	: error class mask (see include/linux/can/error.h)
+ * bit 29-31	: set to zero
+ */
+typedef __u32 can_err_mask_t;
+
+/* CAN payload length and DLC definitions according to ISO 11898-1 */
+#define CAN_MAX_DLC 8
+#define CAN_MAX_DLEN 8
+
+/* CAN FD payload length and DLC definitions according to ISO 11898-7 */
+#define CANFD_MAX_DLC 15
+#define CANFD_MAX_DLEN 64
+
+/**
+ * struct can_frame - basic CAN frame structure
+ * @can_id:  CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
+ * @can_dlc: frame payload length in byte (0 .. 8) aka data length code
+ *           N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1
+ *           mapping of the 'data length code' to the real payload length
+ * @data:    CAN frame payload (up to 8 byte)
+ */
+struct can_frame {
+	canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
+	__u8    can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
+	__u8    data[CAN_MAX_DLEN] __attribute__((aligned(8)));
+};
+
+/*
+ * defined bits for canfd_frame.flags
+ *
+ * As the default for CAN FD should be to support the high data rate in the
+ * payload section of the frame (HDR) and to support up to 64 byte in the
+ * data section (EDL) the bits are only set in the non-default case.
+ * Btw. as long as there's no real implementation for CAN FD network driver
+ * these bits are only preliminary.
+ *
+ * RX: NOHDR/NOEDL - info about received CAN FD frame
+ *     ESI         - bit from originating CAN controller
+ * TX: NOHDR/NOEDL - control per-frame settings if supported by CAN controller
+ *     ESI         - bit is set by local CAN controller
+ */
+#define CANFD_NOHDR 0x01 /* frame without high data rate */
+#define CANFD_NOEDL 0x02 /* frame without extended data length */
+#define CANFD_ESI   0x04 /* error state indicator */
+
+/**
+ * struct canfd_frame - CAN flexible data rate frame structure
+ * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
+ * @len:    frame payload length in byte (0 .. CANFD_MAX_DLEN)
+ * @flags:  additional flags for CAN FD
+ * @__res0: reserved / padding
+ * @__res1: reserved / padding
+ * @data:   CAN FD frame payload (up to CANFD_MAX_DLEN byte)
+ */
+struct canfd_frame {
+	canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
+	__u8    len;     /* frame payload length in byte */
+	__u8    flags;   /* additional flags for CAN FD */
+	__u8    __res0;  /* reserved / padding */
+	__u8    __res1;  /* reserved / padding */
+	__u8    data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
+};
+
+#define CAN_MTU		(sizeof(struct can_frame))
+#define CANFD_MTU	(sizeof(struct canfd_frame))
+
+/* particular protocols of the protocol family PF_CAN */
+#define CAN_RAW		1 /* RAW sockets */
+#define CAN_BCM		2 /* Broadcast Manager */
+#define CAN_TP16	3 /* VAG Transport Protocol v1.6 */
+#define CAN_TP20	4 /* VAG Transport Protocol v2.0 */
+#define CAN_MCNET	5 /* Bosch MCNet */
+#define CAN_ISOTP	6 /* ISO 15765-2 Transport Protocol */
+#define CAN_NPROTO	7
+
+#define SOL_CAN_BASE 100
+
+/**
+ * struct sockaddr_can - the sockaddr structure for CAN sockets
+ * @can_family:  address family number AF_CAN.
+ * @can_ifindex: CAN network interface index.
+ * @can_addr:    protocol specific address information
+ */
+struct sockaddr_can {
+	__kernel_sa_family_t can_family;
+	int         can_ifindex;
+	union {
+		/* transport protocol class address information (e.g. ISOTP) */
+		struct { canid_t rx_id, tx_id; } tp;
+
+		/* reserved for future CAN protocols address information */
+	} can_addr;
+};
+
+/**
+ * struct can_filter - CAN ID based filter in can_register().
+ * @can_id:   relevant bits of CAN ID which are not masked out.
+ * @can_mask: CAN mask (see description)
+ *
+ * Description:
+ * A filter matches, when
+ *
+ *          <received_can_id> & mask == can_id & mask
+ *
+ * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
+ * filter for error message frames (CAN_ERR_FLAG bit set in mask).
+ */
+struct can_filter {
+	canid_t can_id;
+	canid_t can_mask;
+};
+
+#define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
+
+#endif /* CAN_H */
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH iproute2 v2 2/3] CAN Filter/Classifier -- Source code
  2012-07-27 10:02 [PATCH iproute2 v2 0/3] CAN Filter/Classifier Marc Kleine-Budde
  2012-07-27 10:02 ` [PATCH iproute2 v2 1/3] Add missing can.h Marc Kleine-Budde
@ 2012-07-27 10:02 ` Marc Kleine-Budde
  2012-07-27 10:02 ` [PATCH iproute2 v2 3/3] CAN Filter/Classifier -- Documentation Marc Kleine-Budde
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2012-07-27 10:02 UTC (permalink / raw)
  To: netdev; +Cc: linux-can, lartc, pisa, sojkam1, lisovy, Marc Kleine-Budde

From: Rostislav Lisovy <lisovy@gmail.com>

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

Signed-off-by: Rostislav Lisovy <lisovy@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Changes since v1:
- remove black line at end of file

 include/linux/pkt_cls.h |   10 ++
 tc/Makefile             |    1 +
 tc/f_can.c              |  237 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+)
 create mode 100644 tc/f_can.c

diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index defbde2..83f9241 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -375,6 +375,16 @@ enum {
 
 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
 
+/* CAN filter */
+
+enum {
+	TCA_CANFLTR_UNSPEC,
+	TCA_CANFLTR_CLASSID,
+	TCA_CANFLTR_RULES,
+	__TCA_CANFLTR_MAX
+};
+
+#define TCA_CANFLTR_MAX (__TCA_CANFLTR_MAX - 1)
 
 /* Cgroup classifier */
 
diff --git a/tc/Makefile b/tc/Makefile
index 64d93ad..1281568 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -22,6 +22,7 @@ TCMODULES += f_u32.o
 TCMODULES += f_route.o
 TCMODULES += f_fw.o
 TCMODULES += f_basic.o
+TCMODULES += f_can.o
 TCMODULES += f_flow.o
 TCMODULES += f_cgroup.o
 TCMODULES += q_dsmark.o
diff --git a/tc/f_can.c b/tc/f_can.c
new file mode 100644
index 0000000..531cf91
--- /dev/null
+++ b/tc/f_can.c
@@ -0,0 +1,237 @@
+/*
+ * f_can.c  Filter for CAN packets
+ *
+ *		This program is free software; you can distribute it and/or
+ *		modify it under the terms of the GNU General Public License
+ *		as published by the Free Software Foundation; either version
+ *		2 of the License, or (at your option) any later version.
+ *
+ * Idea:       Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
+ * Copyright:  (c) 2011 Czech Technical University in Prague
+ *             (c) 2011 Volkswagen Group Research
+ * Authors:    Michal Sojka <sojkam1@fel.cvut.cz>
+ *             Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ *             Rostislav Lisovy <lisovy@gmail.cz>
+ * Funded by:  Volkswagen Group Research
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <linux/if.h>
+#include <limits.h>
+#include <inttypes.h>
+#include "utils.h"
+#include "tc_util.h"
+#include "linux/can.h"
+
+#define RULES_SIZE		128 /* Maximum number of rules sent via the
+				netlink message during creation/configuration */
+
+
+static void canfltr_explain(void)
+{
+	fprintf(stderr, "Usage: ... can [ MATCHSPEC ] [ flowid FLOWID ]\n"
+			"\n"
+			"Where: MATCHSPEC := { sffid FILTERID | effid FILTERID |\n"
+			"                   MATCHSPEC ... }\n"
+			"       FILTERID := CANID[:MASK]\n"
+			"\n"
+			"NOTE: CLASSID, CANID, MASK is parsed as hexadecimal input.\n");
+}
+
+static int canfltr_parse_opt(struct filter_util *qu, char *handle,
+			 int argc, char **argv, struct nlmsghdr *n)
+{
+	struct tcmsg *t = NLMSG_DATA(n);
+	struct rtattr *tail;
+	struct can_filter canfltr_rules[RULES_SIZE];
+	int rules_count = 0;
+	long h = 0;
+	canid_t can_id;
+	canid_t can_mask;
+
+	if (!argc)
+		return 0;
+
+	if (handle) {
+		h = strtol(handle, NULL, 0);
+		if (h == LONG_MIN || h == LONG_MAX) {
+			fprintf(stderr, "Illegal handle \"%s\", must be numeric.\n",
+				handle);
+			return -1;
+		}
+	}
+
+	t->tcm_handle = h;
+
+	tail = NLMSG_TAIL(n);
+	addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
+
+	while (argc > 0) {
+		if (matches(*argv, "sffid") == 0) {
+			/* parse SFF CAN ID optionally with mask */
+			if (rules_count >= RULES_SIZE) {
+				fprintf(stderr, "Too much rules on input. "
+					"Maximum number of rules is: %d\n",
+					RULES_SIZE);
+				return -1;
+			}
+
+			NEXT_ARG();
+
+			if (sscanf(*argv, "%"SCNx32 ":" "%"SCNx32,
+				&can_id, &can_mask) != 2) {
+				if (sscanf(*argv, "%"SCNx32, &can_id) != 1) {
+					fprintf(stderr, "Improperly formed CAN "
+						"ID & mask '%s'\n", *argv);
+					return -1;
+				} else
+					can_mask = CAN_SFF_MASK;
+			}
+
+			/* we do not support extra handling for RTR frames
+			due to the bitmap approach */
+			if (can_id & ~CAN_SFF_MASK) {
+				fprintf(stderr, "ID 0x%lx exceeded standard CAN ID range.\n",
+					(unsigned long)can_id);
+				return -1;
+			}
+
+			canfltr_rules[rules_count].can_id = can_id;
+			canfltr_rules[rules_count].can_mask =
+				(can_mask & CAN_SFF_MASK);
+			rules_count++;
+
+		} else if (matches(*argv, "effid") == 0) {
+			/* parse EFF CAN ID optionally with mask */
+			if (rules_count >= RULES_SIZE) {
+				fprintf(stderr, "Too much rules on input. "
+					"Maximum number of rules is: %d\n",
+					RULES_SIZE);
+				return -1;
+			}
+
+			NEXT_ARG();
+
+			if (sscanf(*argv, "%"SCNx32 ":" "%"SCNx32, &can_id, &can_mask) != 2) {
+				if (sscanf(*argv, "%"SCNx32, &can_id) != 1) {
+					fprintf(stderr, "Improperly formed CAN ID & mask '%s'\n", *argv);
+					return -1;
+				} else
+					can_mask = CAN_EFF_MASK;
+			}
+
+			if (can_id & ~CAN_EFF_MASK) {
+				fprintf(stderr, "ID 0x%lx exceeded extended CAN ID range.",
+					(unsigned long)can_id);
+				return -1;
+			}
+
+			canfltr_rules[rules_count].can_id =
+				can_id | CAN_EFF_FLAG;
+			canfltr_rules[rules_count].can_mask =
+				(can_mask & CAN_EFF_MASK) | CAN_EFF_FLAG;
+			rules_count++;
+
+		} else if (matches(*argv, "classid") == 0 || strcmp(*argv, "flowid") == 0) {
+			unsigned handle;
+			NEXT_ARG();
+			if (get_tc_classid(&handle, *argv)) {
+				fprintf(stderr, "Illegal \"classid\"\n");
+				return -1;
+			}
+			addattr_l(n, MAX_MSG, TCA_CANFLTR_CLASSID, &handle, 4);
+
+		} else if (strcmp(*argv, "help") == 0) {
+			canfltr_explain();
+			return -1;
+
+		} else {
+			fprintf(stderr, "What is \"%s\"?\n", *argv);
+			canfltr_explain();
+			return -1;
+		}
+		argc--; argv++;
+	}
+
+	addattr_l(n, MAX_MSG, TCA_CANFLTR_RULES, &canfltr_rules,
+		sizeof(struct can_filter) * rules_count);
+
+	tail->rta_len = (void *)NLMSG_TAIL(n) - (void *)tail;
+	return 0;
+}
+
+/* When "tc filter show dev XY" is executed, function canfltr_walk() (in
+ * kernel) is called (which calls canfltr_dump() for each instance of a
+ * filter) which sends information about each instance of a filter to
+ * userspace -- to this function which parses the message and prints it.
+ */
+static int canfltr_print_opt(struct filter_util *qu, FILE *f,
+			struct rtattr *opt, __u32 handle)
+{
+	struct rtattr *tb[TCA_CANFLTR_MAX+1];
+	struct can_filter *canfltr_rules = NULL;
+	int rules_count = 0;
+	int i;
+
+	if (opt == NULL)
+		return 0;
+
+	parse_rtattr_nested(tb, TCA_CANFLTR_MAX, opt);
+
+	if (handle)
+		fprintf(f, "handle 0x%x ", handle);
+
+
+	if (tb[TCA_BASIC_CLASSID]) {
+		SPRINT_BUF(b1); /* allocates buffer b1 */
+		fprintf(f, "flowid %s ",
+			sprint_tc_classid(*(__u32 *)RTA_DATA(tb[TCA_BASIC_CLASSID]), b1));
+	}
+
+	if (tb[TCA_CANFLTR_RULES]) {
+		if (RTA_PAYLOAD(tb[TCA_CANFLTR_RULES]) < sizeof(struct can_filter))
+			return -1;
+
+		canfltr_rules = RTA_DATA(tb[TCA_CANFLTR_RULES]);
+		rules_count = (RTA_PAYLOAD(tb[TCA_CANFLTR_RULES]) /
+			sizeof(struct can_filter));
+
+		for (i = 0; i < rules_count; i++) {
+			struct can_filter *pcfltr = &canfltr_rules[i];
+
+			if (pcfltr->can_id & CAN_EFF_FLAG) {
+				if (pcfltr->can_mask == (CAN_EFF_FLAG|CAN_EFF_MASK))
+					fprintf(f, "effid 0x%"PRIX32" ",
+						pcfltr->can_id & CAN_EFF_MASK);
+				else
+					fprintf(f, "effid 0x%"PRIX32":0x%"PRIX32" ",
+						pcfltr->can_id & CAN_EFF_MASK,
+						pcfltr->can_mask & CAN_EFF_MASK);
+			} else {
+				if (pcfltr->can_mask == CAN_SFF_MASK)
+					fprintf(f, "sffid 0x%"PRIX32" ",
+						pcfltr->can_id);
+				else
+					fprintf(f, "sffid 0x%"PRIX32":0x%"PRIX32" ",
+						pcfltr->can_id,
+						pcfltr->can_mask);
+			}
+		}
+	}
+
+	return 0;
+}
+
+struct filter_util can_filter_util = {
+	.id = "can",
+	.parse_fopt = canfltr_parse_opt,
+	.print_fopt = canfltr_print_opt,
+};
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH iproute2 v2 3/3] CAN Filter/Classifier -- Documentation
  2012-07-27 10:02 [PATCH iproute2 v2 0/3] CAN Filter/Classifier Marc Kleine-Budde
  2012-07-27 10:02 ` [PATCH iproute2 v2 1/3] Add missing can.h Marc Kleine-Budde
  2012-07-27 10:02 ` [PATCH iproute2 v2 2/3] CAN Filter/Classifier -- Source code Marc Kleine-Budde
@ 2012-07-27 10:02 ` Marc Kleine-Budde
  2012-07-27 13:56 ` [PATCH iproute2 v2 0/3] CAN Filter/Classifier Oliver Hartkopp
  2012-08-20 20:06 ` Stephen Hemminger
  4 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2012-07-27 10:02 UTC (permalink / raw)
  To: netdev; +Cc: linux-can, lartc, pisa, sojkam1, lisovy, Marc Kleine-Budde

From: Rostislav Lisovy <lisovy@gmail.com>

Manpage describing usage of CAN Filter.

Signed-off-by: Rostislav Lisovy <lisovy@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Changes since v1:
- remove trailing whitespace

 man/man8/tc-can.8 |   97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 man/man8/tc-can.8

diff --git a/man/man8/tc-can.8 b/man/man8/tc-can.8
new file mode 100644
index 0000000..d60e872
--- /dev/null
+++ b/man/man8/tc-can.8
@@ -0,0 +1,97 @@
+.TH CAN 8 "8 May 2012" "iproute2" "Linux"
+.SH NAME
+CAN \- Controller Area Network classifier
+.SH SYNOPSIS
+.B tc filter ... dev
+DEV
+.B parent
+CLASSID
+.B [ prio
+PRIORITY
+.B ] [ protocol can ] [ handle
+HANDLE
+.B ] can [
+MATCHSPEC
+.B ] [ flowid
+FLOWID
+.B ]
+
+.B CLASSID := major:minor
+.br
+.B FLOWID := major:minor
+.br
+.B MATCHSPEC := { sffid
+FILTERID
+.B | effid
+FILTERID
+.B | MATCHSPEC ... }
+.br
+.B FILTERID := canid[:mask]
+
+.BR CLASSID ,
+.BR FLOWID ,
+.BR canid
+and
+.B mask
+are parsed as hexadecimal input.
+
+
+.SH DESCRIPTION
+The CAN classifier may be used with any available
+.B qdisc
+on Controller Area Network (CAN) frames passed through AF_CAN
+networking subsystem. The classifier classifies CAN frames according
+to their identifiers. It can be used on CAN frames with both SFF or
+EFF identifiers.
+
+It is possible to add CAN classifier to any qdisc configured on any networking
+device, however it will ignore non-CAN packets.
+
+
+.SH CLASSIFICATION
+The filtering rules for EFF frames are stored in an array, which is traversed
+during classification. This means that the worst-case time needed for
+classification of EFF frames increases with the number of configured rules.
+
+The filter implements an optimization for matching SFF frames using a bitmap
+with one bit for every ID. With this optimization, the classification time
+for SFF frames is nearly constant independently of the number of rules.
+
+.SH EXAMPLE
+This example shows how to set
+.B prio qdisc
+with
+.B CAN
+classifier.
+
+.nf
+tc qdisc add dev can0 root handle 1: prio
+
+tc filter add dev can0 parent 1:0 prio 1 handle 0xa \\
+    can sffid 0x7ff:0xf flowid 1:1
+tc filter add dev can0 parent 1:0 prio 2 handle 0xb \\
+    can sffid 0xC0:0x7ff effid 0x80:0x7ff flowid 1:2
+tc filter add dev can0 parent 1:0 prio 3 \\
+    can sffid 0x80:0x7ff flowid 1:2
+tc filter add dev can0 parent 1:0 prio 4 \\
+    can sffid 0x0:0x0 effid 0x0:0x0 flowid 1:3
+.fi
+
+
+.SH BUGS
+The maximum number or rules passed from
+.BR tc(8)
+utility to CAN classifier is fixed. The limit is set at compilation time
+(default is 128).
+
+
+.SH SEE ALSO
+.BR tc(8)
+
+
+.SH AUTHORS
+Michal Sojka <sojkam1@fel.cvut.cz>, Pavel Pisa <pisa@cmp.felk.cvut.cz>,
+Rostislav Lisovy <lisovy@gmail.cz>.
+
+This manpage maintained by Rostislav Lisovy <lisovy@gmail.com>
+
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 10:02 [PATCH iproute2 v2 0/3] CAN Filter/Classifier Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2012-07-27 10:02 ` [PATCH iproute2 v2 3/3] CAN Filter/Classifier -- Documentation Marc Kleine-Budde
@ 2012-07-27 13:56 ` Oliver Hartkopp
  2012-07-27 13:58   ` Marc Kleine-Budde
  2012-07-27 14:09   ` Rostislav Lisovy
  2012-08-20 20:06 ` Stephen Hemminger
  4 siblings, 2 replies; 12+ messages in thread
From: Oliver Hartkopp @ 2012-07-27 13:56 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, linux-can, lartc, pisa, sojkam1, lisovy

On 27.07.2012 12:02, Marc Kleine-Budde wrote:

> I'm reposting Rostislav's iproute2 patches, as Stephen requested,
> during the v3.6 merge window with the corresponding kernel patches
> already applied.


Hallo Marc,

thanks for tracking these iproute2 patches.

Btw. i think these patches address the original implementation from Rostislav
using the CAN classifier. The review lead to a completely new implementation
using ematch. Therefore this patch series is outdated AFAICS.

@Rostislav: Am i correct here?

Regards,
Oliver

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 13:56 ` [PATCH iproute2 v2 0/3] CAN Filter/Classifier Oliver Hartkopp
@ 2012-07-27 13:58   ` Marc Kleine-Budde
  2012-07-27 14:06     ` Oliver Hartkopp
  2012-07-27 14:09   ` Rostislav Lisovy
  1 sibling, 1 reply; 12+ messages in thread
From: Marc Kleine-Budde @ 2012-07-27 13:58 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: netdev, linux-can, lartc, pisa, sojkam1, lisovy

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

On 07/27/2012 03:56 PM, Oliver Hartkopp wrote:
> On 27.07.2012 12:02, Marc Kleine-Budde wrote:
> 
>> I'm reposting Rostislav's iproute2 patches, as Stephen requested,
>> during the v3.6 merge window with the corresponding kernel patches
>> already applied.
> 
> 
> Hallo Marc,
> 
> thanks for tracking these iproute2 patches.
> 
> Btw. i think these patches address the original implementation from Rostislav
> using the CAN classifier. The review lead to a completely new implementation
> using ematch. Therefore this patch series is outdated AFAICS.
> 
> @Rostislav: Am i correct here?

Has someone started working on this, or already new patches?

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 13:58   ` Marc Kleine-Budde
@ 2012-07-27 14:06     ` Oliver Hartkopp
  0 siblings, 0 replies; 12+ messages in thread
From: Oliver Hartkopp @ 2012-07-27 14:06 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, linux-can, lartc, pisa, sojkam1, lisovy

On 27.07.2012 15:58, Marc Kleine-Budde wrote:

> On 07/27/2012 03:56 PM, Oliver Hartkopp wrote:
>> On 27.07.2012 12:02, Marc Kleine-Budde wrote:
>>
>>> I'm reposting Rostislav's iproute2 patches, as Stephen requested,
>>> during the v3.6 merge window with the corresponding kernel patches
>>> already applied.
>>
>>
>> Hallo Marc,
>>
>> thanks for tracking these iproute2 patches.
>>
>> Btw. i think these patches address the original implementation from Rostislav
>> using the CAN classifier. The review lead to a completely new implementation
>> using ematch. Therefore this patch series is outdated AFAICS.
>>
>> @Rostislav: Am i correct here?
> 
> Has someone started working on this, or already new patches?
> 


Yes. Rostislav worked on this iproute2 extension for his own tests:

https://rtime.felk.cvut.cz/gitweb/lisovros/iproute2_canprio.git/shortlog/refs/heads/em_can

I assume there will be some patches posted in the next time.

Regards,
Oliver

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 13:56 ` [PATCH iproute2 v2 0/3] CAN Filter/Classifier Oliver Hartkopp
  2012-07-27 13:58   ` Marc Kleine-Budde
@ 2012-07-27 14:09   ` Rostislav Lisovy
  2012-07-27 16:35     ` Oliver Hartkopp
  1 sibling, 1 reply; 12+ messages in thread
From: Rostislav Lisovy @ 2012-07-27 14:09 UTC (permalink / raw)
  To: Oliver Hartkopp
  Cc: Marc Kleine-Budde, netdev, linux-can, lartc, pisa, sojkam1

On Fri, 2012-07-27 at 15:56 +0200, Oliver Hartkopp wrote: 
> On 27.07.2012 12:02, Marc Kleine-Budde wrote:
> 
> > I'm reposting Rostislav's iproute2 patches, as Stephen requested,
> > during the v3.6 merge window with the corresponding kernel patches
> > already applied.
> 
> 

> Btw. i think these patches address the original implementation from Rostislav
> using the CAN classifier. The review lead to a completely new implementation
> using ematch. Therefore this patch series is outdated AFAICS.
> 
> @Rostislav: Am i correct here?

Hello Oliver;
You are right -- these are the patches for the old "standalone can
filter/classifier" implementation.
I will send correct patches hopefully on Monday/Tuesday.

Regards;
Rostislav

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 14:09   ` Rostislav Lisovy
@ 2012-07-27 16:35     ` Oliver Hartkopp
  2012-07-27 16:42       ` Marc Kleine-Budde
  0 siblings, 1 reply; 12+ messages in thread
From: Oliver Hartkopp @ 2012-07-27 16:35 UTC (permalink / raw)
  To: Rostislav Lisovy
  Cc: Marc Kleine-Budde, netdev, linux-can, lartc, pisa, sojkam1

On 27.07.2012 16:09, Rostislav Lisovy wrote:

> On Fri, 2012-07-27 at 15:56 +0200, Oliver Hartkopp wrote: 
>> On 27.07.2012 12:02, Marc Kleine-Budde wrote:
>>
>>> I'm reposting Rostislav's iproute2 patches, as Stephen requested,
>>> during the v3.6 merge window with the corresponding kernel patches
>>> already applied.
>>
>>
> 
>> Btw. i think these patches address the original implementation from Rostislav
>> using the CAN classifier. The review lead to a completely new implementation
>> using ematch. Therefore this patch series is outdated AFAICS.
>>
>> @Rostislav: Am i correct here?
> 
> Hello Oliver;
> You are right -- these are the patches for the old "standalone can
> filter/classifier" implementation.
> I will send correct patches hopefully on Monday/Tuesday.
> 


No hurry.

I will not have the time next week to check out and test your patches.
But i would like to do so :-)

We have all the time until Linux 3.6 is released somewhere in October.

So getting these things done in August is a good target.

Tnx & best regards,
Oliver


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 16:35     ` Oliver Hartkopp
@ 2012-07-27 16:42       ` Marc Kleine-Budde
  0 siblings, 0 replies; 12+ messages in thread
From: Marc Kleine-Budde @ 2012-07-27 16:42 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: Rostislav Lisovy, linux-can

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

...cleaning up Cc a bit...

On 07/27/2012 06:35 PM, Oliver Hartkopp wrote:
[...]
>> Hello Oliver;
>> You are right -- these are the patches for the old "standalone can
>> filter/classifier" implementation.
>> I will send correct patches hopefully on Monday/Tuesday.

> No hurry.

> I will not have the time next week to check out and test your patches.
> But i would like to do so :-)

I have a test candidate for your patches here, too :) For now I've
squashed and rebased you repo to the v3.4.0 iproute2 repo. I'll
integrate your official patches as soon as I have them.

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-07-27 10:02 [PATCH iproute2 v2 0/3] CAN Filter/Classifier Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2012-07-27 13:56 ` [PATCH iproute2 v2 0/3] CAN Filter/Classifier Oliver Hartkopp
@ 2012-08-20 20:06 ` Stephen Hemminger
  2012-08-21  6:27   ` Oliver Hartkopp
  4 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2012-08-20 20:06 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: netdev, linux-can, lartc, pisa, sojkam1, lisovy

On Fri, 27 Jul 2012 12:02:40 +0200
Marc Kleine-Budde <mkl@pengutronix.de> wrote:

> Hello,
> 
> I'm reposting Rostislav's iproute2 patches, as Stephen requested,
> during the v3.6 merge window with the corresponding kernel patches
> already applied.
> 
> Changes since v1:
> - use can.h generated by 'make headers_install' (tnx Stephen)
> - remove some trailing whitespace
> 
> Now Rostislav original introduction message:
> 
> ---
> 
> 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
> 
> ---
> 
> The following changes since commit fa1f7441a94670ecf5cbf8eb2ee19173437b5127:
> 
>   Remove reference to multipath algorithms in usage (2012-07-26 16:12:20 -0700)
> 
> are available in the git repository at:
> 
>   git://gitorious.org/linux-can/iproute2.git for-stephen
> 

If your changes work with 3.6 then please rebase your patches on current iproute2 tree.

Note: do not include changes to include/linux which now includes can.h
and matches 3.6-rc2.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH iproute2 v2 0/3] CAN Filter/Classifier
  2012-08-20 20:06 ` Stephen Hemminger
@ 2012-08-21  6:27   ` Oliver Hartkopp
  0 siblings, 0 replies; 12+ messages in thread
From: Oliver Hartkopp @ 2012-08-21  6:27 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-can, pisa, sojkam1, lisovy

No action required!

On 20.08.2012 22:06, Stephen Hemminger wrote:

>
> If your changes work with 3.6 then please rebase your patches on current iproute2 tree.
>
> Note: do not include changes to include/linux which now includes can.h
> and matches 3.6-rc2.
>


Both updates (can.h and em_canid.c) have been applied properly, see:

http://git.kernel.org/?p=linux/kernel/git/shemminger/iproute2.git;a=summary

Regards,
Oliver

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-08-21  6:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-27 10:02 [PATCH iproute2 v2 0/3] CAN Filter/Classifier Marc Kleine-Budde
2012-07-27 10:02 ` [PATCH iproute2 v2 1/3] Add missing can.h Marc Kleine-Budde
2012-07-27 10:02 ` [PATCH iproute2 v2 2/3] CAN Filter/Classifier -- Source code Marc Kleine-Budde
2012-07-27 10:02 ` [PATCH iproute2 v2 3/3] CAN Filter/Classifier -- Documentation Marc Kleine-Budde
2012-07-27 13:56 ` [PATCH iproute2 v2 0/3] CAN Filter/Classifier Oliver Hartkopp
2012-07-27 13:58   ` Marc Kleine-Budde
2012-07-27 14:06     ` Oliver Hartkopp
2012-07-27 14:09   ` Rostislav Lisovy
2012-07-27 16:35     ` Oliver Hartkopp
2012-07-27 16:42       ` Marc Kleine-Budde
2012-08-20 20:06 ` Stephen Hemminger
2012-08-21  6:27   ` Oliver Hartkopp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.