Netdev List
 help / color / mirror / Atom feed
* Update for CAN LTP tests
From: Oliver Hartkopp @ 2011-07-10 12:18 UTC (permalink / raw)
  To: Subrata Modak
  Cc: Oliver Hartkopp, Wolfgang Grandegger, ltp-list, socketcan-users,
	netdev
In-Reply-To: <20090512094631.26592.81609.sendpatchset@subratamodak.linux.ibm.com>

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

Subrata Modak wrote:

> Would you also like to send a patch to update the testcases for CAN in LTP
> (http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/network/can/filter-tests/) ?
> These tests were originally picked up from:
> http://svn.berlios.de/wsvn/socketcan/trunk/test/?rev=877&amp;sc=1

Dear Subrata,

attached you'll find a major update for the LTP tests dealing with CAN filters
and the CAN frame flow down to the CAN netdevice and vice versa.

The patch removes all the obsolete stuff from the source code directory you
originally picked the tests from. I added two new tools that also reside on
the referenced SVN:

tst-filter: New filter test tool in *one* programm (easy to use & handle)
tst-rcv-own-msgs: Checks the CAN frame flow inside the networking stack

Additionally the virtual CAN driver needs to be loaded with a special
commandline option to perform the CAN frame flow test correctly.

The tests & the scripts are much clearer to me now. If it meets your
requirements consider to apply this patch to the LTP repository.

Best regards,
Oliver


[-- Attachment #2: can-ltp-update.patch --]
[-- Type: text/x-patch, Size: 157350 bytes --]

diff -u -N -r filter-tests/canecho.c filter-tests-new/canecho.c
--- filter-tests/canecho.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/canecho.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,164 +0,0 @@
-/*
- *  $Id: canecho.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * canecho.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <libgen.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-
-extern int optind, opterr, optopt;
-
-static int      s = -1;
-static int      running = 1;
-
-void print_usage(char *prg)
-{
-        fprintf(stderr, "Usage: %s [can-interface]\n", prg);
-}
-
-void sigterm(int signo)
-{
-        printf("got signal %d\n", signo);
-        running = 0;
-}
-
-int main(int argc, char **argv)
-{
-        int family = PF_CAN, type = SOCK_RAW, proto = CAN_RAW;
-        int opt;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-        struct can_frame frame;
-        int nbytes, i;
-        int verbose = 0;
-
-        signal(SIGTERM, sigterm);
-        signal(SIGHUP, sigterm);
-
-        while ((opt = getopt(argc, argv, "f:t:p:v")) != -1) {
-                switch (opt) {
-                case 'f':
-                        family = atoi(optarg);
-                        break;
-
-                case 't':
-                        type = atoi(optarg);
-                        break;
-
-                case 'p':
-                        proto = atoi(optarg);
-                        break;
-
-                case 'v':
-                        verbose = 1;
-                        break;
-
-                case '?':
-                        break;
-
-                default:
-                        fprintf(stderr, "Unknown option %c\n", opt);
-                        break;
-                }
-        }
-
-        if (optind == argc) {
-                print_usage(basename(argv[0]));
-                exit(0);
-        }
-        
-        printf("interface = %s, family = %d, type = %d, proto = %d\n",
-               argv[optind], family, type, proto);
-        if ((s = socket(family, type, proto)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = family;
-        strcpy(ifr.ifr_name, argv[optind]);
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        while (running) {
-                if ((nbytes = read(s, &frame, sizeof(frame))) < 0) {
-                        perror("read");
-                        return 1;
-                }
-                if (verbose) {
-                        printf("%03X: ", frame.can_id & CAN_EFF_MASK);
-                        if (frame.can_id & CAN_RTR_FLAG) {
-                                printf("remote request");
-                        } else {
-                                printf("[%d]", frame.can_dlc);
-                                for (i = 0; i < frame.can_dlc; i++) {
-                                        printf(" %02X", frame.data[i]);
-                                }
-                        }
-                        printf("\n");
-                }
-                frame.can_id++;
-                write(s, &frame, sizeof(frame));
-        }
-
-        return 0;
-}
-
diff -u -N -r filter-tests/Makefile filter-tests-new/Makefile
--- filter-tests/Makefile	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/Makefile	2011-07-10 13:17:01.447711796 +0200
@@ -1,43 +1,6 @@
 #
 #  $Id: Makefile,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
 #
-#  Copyright (c) 2002-2007 Volkswagen Group Electronic Research
-#  All rights reserved.
-#
-#  Redistribution and use in source and binary forms, with or without
-#  modification, are permitted provided that the following conditions
-#  are met:
-#  1. Redistributions of source code must retain the above copyright
-#     notice, this list of conditions, the following disclaimer and
-#     the referenced file 'COPYING'.
-#  2. Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#  3. Neither the name of Volkswagen nor the names of its contributors
-#     may be used to endorse or promote products derived from this software
-#     without specific prior written permission.
-#
-#  Alternatively, provided that this notice is retained in full, this
-#  software may be distributed under the terms of the GNU General
-#  Public License ("GPL") version 2 as distributed in the 'COPYING'
-#  file from the main directory of the linux kernel source.
-#
-#  The provided data structures and external interfaces from this code
-#  are not restricted to be used by modules with a GPL compatible license.
-#
-#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-#  DAMAGE.
-#
 #  Send feedback to <socketcan-users@lists.berlios.de>
 
 CFLAGS    = -O2 -Wall -Wno-parentheses \
@@ -46,25 +9,7 @@
 	-DPF_CAN=29 \
 	-DAF_CAN=PF_CAN
 
-PROGRAMS =      tst-raw           \
-                tst-raw-filter    \
-                tst-err           \
-                tst-raw-sendto    \
-                tst-packet        \
-                tst-filter-master \
-                tst-filter-server \
-                tst-bcm-cycle     \
-                tst-bcm-server    \
-                tst-bcm-tx_read   \
-                tst-bcm-rtr       \
-                tst-bcm-single    \
-                tst-bcm-filter    \
-                tst-bcm-throttle  \
-                tst-bcm-rx-sendto \
-                tst-bcm-tx-sendto \
-                tst-bcm-dump      \
-                tst-proc          \
-                canecho
+PROGRAMS =      tst-filter tst-rcv-own-msgs
 
 all: $(PROGRAMS)
 
@@ -72,8 +17,8 @@
 	cp -f $(PROGRAMS) /usr/local/bin
 
 clean:
-	rm -f $(PROGRAMS) output_ltp-can.txt output_ltp-can-verify.txt /etc/modprobe.d/vcan
+	rm -f $(PROGRAMS)
 
 distclean:
-	rm -f $(PROGRAMS) *~ output_ltp-can.txt output_ltp-can-verify.txt /etc/modprobe.d/vcan
+	rm -f $(PROGRAMS) *~
 
diff -u -N -r filter-tests/run_ltp-can_tests.sh filter-tests-new/run_ltp-can_tests.sh
--- filter-tests/run_ltp-can_tests.sh	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/run_ltp-can_tests.sh	2011-07-10 13:51:44.839639383 +0200
@@ -1,6 +1,6 @@
 #!/bin/sh
 ################################################################################
-## Copyright (c) Oliver Hartkopp <oliver.hartkopp@volkswagen.de>, 2009        ##
+## Copyright (c) Oliver Hartkopp <oliver.hartkopp@volkswagen.de>, 2011        ##
 ## Copyright (c) International Business Machines  Corp., 2009                 ##
 ##                                                                            ##
 ## This program is free software;  you can redistribute it and#or modify      ##
@@ -24,25 +24,34 @@
      exit 1
 fi
 
-cat <<-EOF > /etc/modprobe.d/vcan
-# protocol family PF_CAN
-alias net-pf-29 can
-# protocols in PF_CAN
-alias can-proto-1 can-raw
-alias can-proto-2 can-bcm
-alias can-proto-3 can-tp16
-alias can-proto-4 can-tp20
-alias can-proto-5 can-mcnet
-alias can-proto-6 can-isotp
-EOF
-
+# load needed CAN networklayer modules
 modprobe -f can
 modprobe -f can_raw
-modprobe -f vcan
-ip link add dev vcan0 type vcan
-ifconfig vcan0 up
 
-./tst-filter-server > output_ltp-can.txt &
-./tst-filter-master | tee output_ltp-can-verify.txt
+# ensure the vcan driver to perform the ECHO on driver level
+modprobe -r vcan
+modprobe -f vcan echo=1
+
+VCAN=vcan0
+
+# create virtual CAN device
+ip link add dev $VCAN type vcan || exit 1
+ifconfig $VCAN up
+
+# check precondition for CAN frame flow test
+HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
+
+if [ $HAS_ECHO -ne 1 ]
+then
+    exit 1
+fi
+
+# test of CAN filters on af_can.c 
+./tst-filter $VCAN || exit 1
+
+# test of CAN frame flow down to the netdevice and up again
+./tst-rcv-own-msgs $VCAN || exit 1
+
+exit 0
 
 
diff -u -N -r filter-tests/tst-bcm-cycle.c filter-tests-new/tst-bcm-cycle.c
--- filter-tests/tst-bcm-cycle.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-cycle.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,138 +0,0 @@
-/*
- *  $Id: tst-bcm-cycle.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-cycle.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame[4];
-        } msg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        msg.msg_head.opcode  = TX_SETUP;
-        msg.msg_head.can_id  = 0x42;
-        msg.msg_head.flags   = SETTIMER|STARTTIMER;
-        msg.msg_head.nframes = 1;
-        msg.msg_head.count = 10;
-        msg.msg_head.ival1.tv_sec = 1;
-        msg.msg_head.ival1.tv_usec = 0;
-        msg.msg_head.ival2.tv_sec = 0;
-        msg.msg_head.ival2.tv_usec = 0;
-        msg.frame[0].can_id    = 0x42;
-        msg.frame[0].can_dlc   = 8;
-        U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        printf("Press any key to stop the cycle ...\n");
-
-        getchar();
-
-        msg.msg_head.opcode  = TX_SETUP;
-        msg.msg_head.can_id  = 0x42;
-        msg.msg_head.flags   = SETTIMER|STARTTIMER;
-        msg.msg_head.nframes = 1;
-        msg.msg_head.count = 0;
-        msg.msg_head.ival1.tv_sec = 0;
-        msg.msg_head.ival1.tv_usec = 0;
-        msg.msg_head.ival2.tv_sec = 0;
-        msg.msg_head.ival2.tv_usec = 0;
-        msg.frame[0].can_id    = 0x42;
-        msg.frame[0].can_dlc   = 8;
-        U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        printf("Press any key to close the socket ...\n");
-
-        getchar();
-
-        close(s);
-
-        printf("Press any key to end the program ...\n");
-
-        getchar();
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-dump.c filter-tests-new/tst-bcm-dump.c
--- filter-tests/tst-bcm-dump.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-dump.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,202 +0,0 @@
-/*
- *  $Id: tst-bcm-dump.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-dump.c
- *
- * Copyright (c) 2008 Oliver Hartkopp
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the version 2 of the GNU General Public License
- * as published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <time.h>
-#include <libgen.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define DEFAULT_IFACE "vcan0"
-#define DEFAULT_CANID 0x42
-
-void print_usage(char *prg)
-{
-        fprintf(stderr, "\nUsage: %s [options]\n", prg);
-        fprintf(stderr, "Options: -i <interface> (CAN interface. Default: '%s')\n", DEFAULT_IFACE);
-        fprintf(stderr, "         -c <can_id>    (used CAN ID. Default: 0x%03X)\n", DEFAULT_CANID);
-        fprintf(stderr, "         -o <timeout>   (Timeout value in nsecs. Default: 0)\n");
-        fprintf(stderr, "         -t <throttle>  (Throttle value in nsecs. Default: 0)\n");
-        fprintf(stderr, "         -q <msgs>      (Quit after receiption of #msgs)\n");
-        fprintf(stderr, "         -s             (set STARTTIMER flag. Default: off)\n");
-        fprintf(stderr, "\n");
-}
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        int nbytes;
-        int i;
-        struct ifreq ifr;
-        char *ifname = DEFAULT_IFACE;
-        canid_t canid = DEFAULT_CANID;
-        int opt;
-        struct timeval tv;
-        unsigned long starttimer = 0;
-        unsigned long long timeout = 0;
-        unsigned long long throttle = 0;
-        unsigned long msgs = 0;
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame;
-        } msg;
-
-        while ((opt = getopt(argc, argv, "i:c:o:t:q:s")) != -1) {
-                switch (opt) {
-
-                case 'i':
-                        ifname = optarg;
-                        break;
-
-                case 'c':
-                        canid = strtoul(optarg, (char **)NULL, 16);
-                        break;
-
-                case 'o':
-                        timeout = strtoull(optarg, (char **)NULL, 10);
-                        break;
-
-                case 't':
-                        throttle = strtoull(optarg, (char **)NULL, 10);
-                        break;
-
-                case 'q':
-                        msgs = strtoul(optarg, (char **)NULL, 10);
-                        break;
-
-                case 's':
-                        starttimer = STARTTIMER;
-                        break;
-
-                case '?':
-                default:
-                        print_usage(basename(argv[0]));
-                        exit(1);
-                        break;
-                }
-        }
-
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        if (strcmp(ifname, "any") == 0)
-                addr.can_ifindex = 0;
-        else {
-                strcpy(ifr.ifr_name, ifname);
-                if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
-                        perror("SIOCGIFINDEX");
-                        return 1;
-                }
-                addr.can_ifindex = ifr.ifr_ifindex;
-        }
-
-        addr.can_family = PF_CAN;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        msg.msg_head.opcode             = RX_SETUP;
-        msg.msg_head.can_id             = canid;
-        msg.msg_head.flags              = SETTIMER|RX_FILTER_ID|starttimer;
-        msg.msg_head.ival1.tv_sec       = timeout / 1000000;
-        msg.msg_head.ival1.tv_usec      = timeout % 1000000;
-        msg.msg_head.ival2.tv_sec       = throttle / 1000000;
-        msg.msg_head.ival2.tv_usec      = throttle % 1000000;
-        msg.msg_head.nframes    = 0;
-
-        gettimeofday(&tv, NULL);
-        printf("[%ld.%06ld] ", tv.tv_sec, tv.tv_usec);
-        printf("Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
-               msg.msg_head.can_id);
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        while (1) {
-
-                nbytes = read(s, &msg, sizeof(msg));
-                if (nbytes < 0) {
-                        perror("read");
-                        return 1;
-                }
-                gettimeofday(&tv, NULL);
-                printf("[%ld.%06ld] ", tv.tv_sec, tv.tv_usec);
-
-                if (nbytes == sizeof(msg)) {
-
-                        if (ioctl(s, SIOCGSTAMP, &tv) < 0)
-                                perror("SIOCGSTAMP");
-                        else
-                                printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
-                        if (msg.msg_head.opcode != RX_CHANGED) {
-                                printf("missing RX_CHANGED.\n");
-                                return 1;
-                        }
-
-                        printf("RX_CHANGED ");
-
-                        for (i=0; i < msg.frame.can_dlc; i++)
-                                printf("%02X ", msg.frame.data[i]);
-
-                } else {
-
-                        if (msg.msg_head.opcode != RX_TIMEOUT) {
-                                printf("missing RX_TIMEOUT.\n");
-                                return 1;
-                        }
-
-                        printf("RX_TIMEOUT");
-                }
-
-                printf("\n");
-                fflush(stdout);
-
-                if (msgs && !(--msgs))
-                        break;
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-filter.c filter-tests-new/tst-bcm-filter.c
--- filter-tests/tst-bcm-filter.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-filter.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,517 +0,0 @@
-/*
- *  $Id: tst-bcm-filter.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-filter.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
-        int s,nbytes;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct timeval tv;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame[4];
-        } txmsg, rxmsg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_FILTER_ID;
-        txmsg.msg_head.ival1.tv_sec = 1;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 0;
-
-        printf("<*>Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        /* test for RX_DELETE */
-        txmsg.msg_head.opcode  = RX_DELETE;
-        txmsg.msg_head.can_id  = 0x042; /* everything we need for RX_DELETE */
-
-        printf("<*>Writing RX_DELETE for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_FILTER_ID;
-        txmsg.msg_head.ival1.tv_sec = 1;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 0;
-
-        printf("<*>Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        /* obsolete for TX_SEND ... */
-#if 0
-        txmsg.msg_head.can_id  = 0x43;
-        txmsg.msg_head.flags   = SETTIMER|STARTTIMER|TX_CP_CAN_ID;
-        txmsg.msg_head.count = 0;
-        txmsg.msg_head.ival1.tv_sec = 0;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-#endif
-        txmsg.frame[0].can_id    = 0x43;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<2>Writing TX_SEND with wrong can_id <%03X>\n",
-               txmsg.frame[0].can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<3>Writing TX_SEND with correct can_id <%03X>\n",
-               txmsg.frame[0].can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-    
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<3>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        /* growing number of nframes => RX_DELETE instead of simple update */
-        txmsg.msg_head.opcode  = RX_DELETE;
-        txmsg.msg_head.can_id  = 0x042; /* everything we need for RX_DELETE */
-
-        printf("<*>Writing RX_DELETE for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_CHECK_DLC;
-        txmsg.msg_head.ival1.tv_sec = 1;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 1;
-        /* txmsg.frame[0].can_dlc   = 8; obsolete for RX_SETUP */
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
-
-        printf("<*>Writing simple RX_SETUP for can_id <%03X> with msgbits 0x%016llX\n",
-               txmsg.msg_head.can_id, U64_DATA(&txmsg.frame[0]));
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<5>Writing TX_SEND with correct can_id <%03X>\n",
-               txmsg.frame[0].can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<5>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<6>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("no changed data\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        /* no change here */
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<7>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("changed relevant msgbits\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<7>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<8>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("changed irrelevant msgbits\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 7;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<9>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("changed Data Length Code DLC\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<9>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = RX_DELETE;
-        txmsg.msg_head.can_id  = 0x042; /* everything we need for RX_DELETE */
-
-        printf("<*>Writing RX_DELETE for can_id <%03X> for RX_SETUP with growing nframes\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        /* no problems ;-) but NOW we try MUX messages ... and timeouts */
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_CHECK_DLC;
-        txmsg.msg_head.ival1.tv_sec = 1;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.nframes = 3;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
-        U64_DATA(&txmsg.frame[1]) = (__u64) 0x01000000000000FFULL;
-        U64_DATA(&txmsg.frame[2]) = (__u64) 0x02000000000000FFULL;
-
-        printf("<*>Writing multiplex RX_SETUP for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x4200000000000000ULL;
-
-        printf("<A>Writing TX_SEND with wrong MUX ID 42\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
-        printf("<B>Writing TX_SEND with correct MUX ID 01\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<B>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
-        printf("<C>Writing TX_SEND with correct MUX ID 01 but no data change\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567800ULL;
-
-        printf("<D>Writing TX_SEND with correct MUX ID 01 but no relevant data change\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567801ULL;
-
-        printf("<E>Writing TX_SEND with correct MUX ID 01 with relevant data change\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<E>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000000ULL;
-
-        printf("<F>Writing TX_SEND with correct MUX ID 02\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<F>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
-        printf("<10>Writing TX_SEND with correct MUX ID 02 with relevant data change\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<10>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 7;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
-        printf("<11>Writing TX_SEND with correct MUX ID 02 no data change but DLC\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<11>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 7;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0300000000000001ULL;
-
-        printf("<12>Writing TX_SEND with wrong MUX ID 03\n");
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        ioctl(s, SIOCGSTAMP, &tv);
-        printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-        if (rxmsg.msg_head.opcode == RX_TIMEOUT &&
-            nbytes == sizeof(struct bcm_msg_head) &&
-            rxmsg.msg_head.can_id == 0x42) {
-                printf("<-->Received correct RX_TIMEOUT message for can_id <%03X> >> OK!\n",
-                       rxmsg.msg_head.can_id);
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-rtr.c filter-tests-new/tst-bcm-rtr.c
--- filter-tests/tst-bcm-rtr.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-rtr.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,146 +0,0 @@
-/*
- *  $Id: tst-bcm-rtr.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-rtr.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define RTR_SETUP
-
-int main(int argc, char **argv)
-{
-        int s,nbytes;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct timeval tv;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame;
-        } txmsg, rxmsg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-#ifdef RTR_SETUP
-        /* specify CAN-Frame to send as reply to a RTR-request */
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x359 | CAN_RTR_FLAG;
-        txmsg.msg_head.flags   = RX_RTR_FRAME; /* | TX_CP_CAN_ID */;
-        txmsg.msg_head.ival1.tv_sec = 0; /* no timers in RTR-mode */
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 1; /* exact 1 */
-
-        /* the frame to send as reply ... */
-        txmsg.frame.can_id = 0x359; /* 'should' be the same */
-        txmsg.frame.can_dlc = 3;
-        txmsg.frame.data[0] = 0x12;
-        txmsg.frame.data[1] = 0x34;
-        txmsg.frame.data[2] = 0x56;
-
-#else
-        /* normal receiption of RTR-frames in Userspace */
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x359 | CAN_RTR_FLAG;
-        txmsg.msg_head.flags   = RX_FILTER_ID;
-        txmsg.msg_head.ival1.tv_sec = 0;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 0;
-#endif
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        while (1) {
-
-                if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                        perror("read");
-    
-                ioctl(s, SIOCGSTAMP, &tv);
-                printf("(%ld.%06ld)   ", tv.tv_sec, tv.tv_usec);
-
-                if (rxmsg.msg_head.opcode == RX_CHANGED &&
-                    nbytes == sizeof(struct bcm_msg_head) + sizeof(struct can_frame) &&
-                    (rxmsg.msg_head.can_id & CAN_SFF_MASK) == 0x359 &&
-                    (rxmsg.frame.can_id & CAN_SFF_MASK) == 0x359) {
-                        printf("RX_CHANGED message for can_id <%03X> RTR = %d\n",
-                               rxmsg.frame.can_id, (rxmsg.frame.can_id & CAN_RTR_FLAG)?1:0);
-                }
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-rx-sendto.c filter-tests-new/tst-bcm-rx-sendto.c
--- filter-tests/tst-bcm-rx-sendto.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-rx-sendto.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,163 +0,0 @@
-/*
- *  $Id: tst-bcm-rx-sendto.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-rx-sendto.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-int main(int argc, char **argv)
-{
-        int s,nbytes;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct timeval tv;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame;
-        } txmsg, rxmsg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        addr.can_ifindex = 0; /* bind to 'any' device */
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        memset(&txmsg, 0, sizeof(txmsg)); /* clear timers, nframes, etc. */
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x123;
-        txmsg.msg_head.flags   = RX_FILTER_ID;
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x321;
-        txmsg.msg_head.flags   = RX_FILTER_ID;
-
-        if (sendto(s, &txmsg, sizeof(txmsg), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0)
-                perror("sendto");
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan1");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x424;
-        txmsg.msg_head.flags   = RX_FILTER_ID;
-
-        if (sendto(s, &txmsg, sizeof(txmsg), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0)
-                perror("sendto");
-
-        while (1) {
-                socklen_t len = sizeof(addr);
-                nbytes = recvfrom(s, &rxmsg, sizeof(rxmsg),
-                                  0, (struct sockaddr*)&addr, &len);
-                if (nbytes < 0) {
-                        perror("recvfrom");
-                        return 1;
-                } else if (nbytes < sizeof(rxmsg)) {
-                        fprintf(stderr, "recvfrom: incomplete BCM message from iface %d\n",
-                                addr.can_ifindex);
-                        return 1;
-                } else {
-                        int i;
-
-                        ioctl(s, SIOCGSTAMP, &tv);
-                        printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
-                        ifr.ifr_ifindex = addr.can_ifindex;
-                        ioctl(s, SIOCGIFNAME, &ifr);
-
-                        printf(" %-5s ", ifr.ifr_name);
-                        if (rxmsg.frame.can_id & CAN_EFF_FLAG)
-                                printf("%8X  ", rxmsg.frame.can_id & CAN_EFF_MASK);
-                        else
-                                printf("%3X  ", rxmsg.frame.can_id & CAN_SFF_MASK);
-            
-                        printf("[%d] ", rxmsg.frame.can_dlc);
-            
-                        for (i = 0; i < rxmsg.frame.can_dlc; i++) {
-                                printf("%02X ", rxmsg.frame.data[i]);
-                        }
-                        if (rxmsg.frame.can_id & CAN_RTR_FLAG)
-                                printf("remote request");
-                        printf("\n");
-                        fflush(stdout);
-                }
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-server.c filter-tests-new/tst-bcm-server.c
--- filter-tests/tst-bcm-server.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-server.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,265 +0,0 @@
-/*
- *  $Id: tst-bcm-server.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-server.c
- *
- * Test programm that implements a socket server which understands ASCII
- * messages for simple broadcast manager frame send commands.
- *
- * < interface command ival_s ival_us can_id can_dlc [data]* >
- *
- * The commands are 'A'dd, 'U'pdate, 'D'elete and 'S'end.
- * e.g.
- *
- * Send the CAN frame 123#1122334455667788 every second on vcan1
- * < vcan1 A 1 0 123 8 11 22 33 44 55 66 77 88 >
- *
- * Send the CAN frame 123#1122334455667788 every 10 usecs on vcan1
- * < vcan1 A 0 10 123 8 11 22 33 44 55 66 77 88 >
- *
- * Send the CAN frame 123#42424242 every 20 msecs on vcan1
- * < vcan1 A 0 20000 123 4 42 42 42 42 >
- *
- * Update the CAN frame 123#42424242 with 123#112233 - no change of timers
- * < vcan1 U 0 0 123 3 11 22 33 >
- *
- * Delete the cyclic send job from above
- * < vcan1 D 0 0 123 0 >
- *
- * Send a single CAN frame without cyclic transmission
- * < can0 S 0 0 123 0 >
- *
- * When the socket is closed the cyclic transmissions are terminated.
- *
- * Authors:
- * Andre Naujoks (the socket server stuff)
- * Oliver Hartkopp (the rest)
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-#include <netinet/in.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-void readmsg(int sock, char *buf, int maxlen) {
-
-        int ptr = 0;
-
-        while (read(sock, buf+ptr, 1) == 1) {
-
-                if (ptr) {
-                        if (*(buf+ptr) == '>') {
-                                *(buf+ptr+1) = 0;
-                                return;
-                        }
-                        if (++ptr > maxlen-2)
-                                ptr = 0;
-                }
-                else
-                        if (*(buf+ptr) == '<')
-                                ptr++;
-        }
-
-        *buf = 0;
-}
-
-
-int main(int argc, char **argv)
-{
-
-        int sl, sa, sc;
-        struct sockaddr_in  saddr, clientaddr;
-        struct sockaddr_can caddr;
-        struct ifreq ifr;
-        socklen_t sin_size = sizeof(clientaddr);
-
-        char buf[100];
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame;
-        } msg;
-
-        if((sl = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
-                perror("inetsocket");
-                exit(1);
-        }
-
-        saddr.sin_family = AF_INET;
-        saddr.sin_addr.s_addr = htonl(INADDR_ANY);
-        saddr.sin_port = htons(28600);
-
-        while(bind(sl,(struct sockaddr*)&saddr, sizeof(saddr)) < 0) {
-                printf(".");fflush(NULL);
-                usleep(100000);
-        }
-
-        if (listen(sl,3) != 0) {
-                perror("listen");
-                exit(1);
-        }
-
-        while (1) { 
-                sa = accept(sl,(struct sockaddr *)&clientaddr, &sin_size);
-                if (sa > 0 ){
-
-                        if (fork())
-                                close(sa);
-                        else
-                                break;
-                }
-                else {
-                        if (errno != EINTR) {
-                                /*
-                                 * If the cause for the error was NOT the signal from
-                                 * a dying child, than give an error
-                                 */
-                                perror("accept");
-                                exit(1);
-                        }
-                }
-        }
-
-        /* open BCM socket */
-
-        if ((sc = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("bcmsocket");
-                return 1;
-        }
-
-        caddr.can_family = PF_CAN;
-        caddr.can_ifindex = 0; /* any device => need for sendto() */
-
-        if (connect(sc, (struct sockaddr *)&caddr, sizeof(caddr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        /* prepare stable settings */
-        msg.msg_head.nframes       = 1;
-        msg.msg_head.count         = 0;
-        msg.msg_head.ival1.tv_sec  = 0;
-        msg.msg_head.ival1.tv_usec = 0;
-
-        while (1) {
-
-                char cmd;
-                int items;
-
-                readmsg(sa, buf, sizeof(buf));
-
-                // printf("read '%s'\n", buf);
-
-                items = sscanf(buf, "< %6s %c %lu %lu %x %hhu "
-                               "%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx >",
-                               ifr.ifr_name,
-                               &cmd, 
-                               &msg.msg_head.ival2.tv_sec,
-                               &msg.msg_head.ival2.tv_usec,
-                               &msg.msg_head.can_id,
-                               &msg.frame.can_dlc,
-                               &msg.frame.data[0],
-                               &msg.frame.data[1],
-                               &msg.frame.data[2],
-                               &msg.frame.data[3],
-                               &msg.frame.data[4],
-                               &msg.frame.data[5],
-                               &msg.frame.data[6],
-                               &msg.frame.data[7]);
-
-                if (items < 6)
-                        break;
-                if (msg.frame.can_dlc > 8)
-                        break;
-                if (items != 6 + msg.frame.can_dlc)
-                        break;
-
-                msg.frame.can_id = msg.msg_head.can_id;
-
-                switch (cmd) {
-                case 'S':
-                        msg.msg_head.opcode = TX_SEND;
-                        break;
-                case 'A':
-                        msg.msg_head.opcode = TX_SETUP;
-                        msg.msg_head.flags |= SETTIMER|STARTTIMER;
-                        break;
-                case 'U':
-                        msg.msg_head.opcode = TX_SETUP;
-                        msg.msg_head.flags  = 0;
-                        break;
-                case 'D':
-                        msg.msg_head.opcode = TX_DELETE;
-                        break;
-
-                default:
-                        printf("unknown command '%c'.\n", cmd);
-                        exit(1);
-                }
-
-                if (!ioctl(sc, SIOCGIFINDEX, &ifr)) {
-                        caddr.can_ifindex = ifr.ifr_ifindex;
-                        sendto(sc, &msg, sizeof(msg), 0,
-                               (struct sockaddr*)&caddr, sizeof(caddr));
-                }
-
-        }
-
-        close(sc);
-        close(sa);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-single.c filter-tests-new/tst-bcm-single.c
--- filter-tests/tst-bcm-single.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-single.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,112 +0,0 @@
-/*
- *  $Id: tst-bcm-single.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-single.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame;
-        } msg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        msg.msg_head.opcode  = TX_SEND;
-        msg.msg_head.can_id  = 0x760;
-        msg.msg_head.flags   = 0;
-        msg.msg_head.nframes = 1;
-        msg.msg_head.count = 0;
-        msg.msg_head.ival1.tv_sec = 0;
-        msg.msg_head.ival1.tv_usec = 0;
-        msg.msg_head.ival2.tv_sec = 0;
-        msg.msg_head.ival2.tv_usec = 0;
-        msg.frame.can_id    = 0x760;
-        msg.frame.can_dlc   = 6;
-        msg.frame.data[0] = 0xA1;
-        msg.frame.data[1] = 0x0F;
-        msg.frame.data[2] = 0x10;
-        msg.frame.data[3] = 0x00;
-        msg.frame.data[4] = 0x00;
-        msg.frame.data[5] = 0x00;
-
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-throttle.c filter-tests-new/tst-bcm-throttle.c
--- filter-tests/tst-bcm-throttle.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-throttle.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,466 +0,0 @@
-/*
- *  $Id: tst-bcm-throttle.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-throttle.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-#define BCM_1FRAME_LEN (sizeof(struct bcm_msg_head) + sizeof(struct can_frame))
-int main(int argc, char **argv)
-{
-        int s,nbytes;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame[3];
-        } txmsg, rxmsg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_FILTER_ID;
-        txmsg.msg_head.ival1.tv_sec = 4;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 2;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 0;
-
-        printf("<*>Writing RX_SETUP with RX_FILTER_ID for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(struct bcm_msg_head)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        /* obsolete for TX_SEND ... */
-#if 0
-        txmsg.msg_head.can_id  = 0x43;
-        txmsg.msg_head.flags   = SETTIMER|STARTTIMER|TX_CP_CAN_ID;
-        txmsg.msg_head.count = 0;
-        txmsg.msg_head.ival1.tv_sec = 0;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-#endif
-        txmsg.frame[0].can_id    = 0x43;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<2>Writing TX_SEND with wrong can_id <%03X>\n",
-               txmsg.frame[0].can_id);
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<3>Writing TX_SEND with correct can_id <%03X>\n",
-               txmsg.frame[0].can_id);
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<3>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        /* growing number of nframes => RX_DELETE instead of simple update */
-        txmsg.msg_head.opcode  = RX_DELETE;
-        txmsg.msg_head.can_id  = 0x042; /* everything we need for RX_DELETE */
-
-        printf("<*>Writing RX_DELETE for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(struct bcm_msg_head)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_CHECK_DLC;
-        txmsg.msg_head.ival1.tv_sec = 4;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 2;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 1;
-        /* txmsg.frame[0].can_dlc   = 8; obsolete for RX_SETUP */
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
-
-        printf("<*>Writing simple RX_SETUP for can_id <%03X> with msgbits 0x%016llX\n",
-               txmsg.msg_head.can_id, U64_DATA(&txmsg.frame[0]));
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<5>Writing TX_SEND with correct can_id <%03X>\n",
-               txmsg.frame[0].can_id);
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<5>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<6>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("no changed data\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        /* no change here */
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<7>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("changed relevant msgbits\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<7>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<8>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("changed irrelevant msgbits\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 7;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        printf("<9>Writing TX_SEND with correct can_id <%03X> ",
-               txmsg.frame[0].can_id);
-        printf("changed Data Length Code DLC\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<9>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        /* no problems ;-) but NOW we try MUX messages ... and timeouts */
-
-        /* growing number of nframes => RX_DELETE instead of simple update */
-        txmsg.msg_head.opcode  = RX_DELETE;
-        txmsg.msg_head.can_id  = 0x042; /* everything we need for RX_DELETE */
-
-        printf("<*>Writing RX_DELETE for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(struct bcm_msg_head)) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = RX_SETUP;
-        txmsg.msg_head.can_id  = 0x042;
-        txmsg.msg_head.flags   = SETTIMER|RX_CHECK_DLC;
-        txmsg.msg_head.ival1.tv_sec = 4;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 2;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.msg_head.nframes = 3;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0xFF00000000000000ULL;
-        U64_DATA(&txmsg.frame[1]) = (__u64) 0x01000000000000FFULL;
-        U64_DATA(&txmsg.frame[2]) = (__u64) 0x02000000000000FFULL;
-
-        printf("<*>Writing multiplex RX_SETUP for can_id <%03X>\n",
-               txmsg.msg_head.can_id);
-
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x4200000000000000ULL;
-
-        printf("<A>Writing TX_SEND with wrong MUX ID 42\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
-        printf("<B>Writing TX_SEND with correct MUX ID 01\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<B>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100000000000000ULL;
-
-        printf("<C>Writing TX_SEND with correct MUX ID 01 but no data change\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567800ULL;
-
-        printf("<D>Writing TX_SEND with correct MUX ID 01 but no relevant data change\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0100001234567801ULL;
-
-        printf("<E>Writing TX_SEND with correct MUX ID 01 with relevant data change\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<E>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000000ULL;
-
-        printf("<F>Writing TX_SEND with correct MUX ID 02\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<F>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 8;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
-        printf("<10>Writing TX_SEND with correct MUX ID 02 with relevant data change\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<10>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 7;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0200000000000001ULL;
-
-        printf("<11>Writing TX_SEND with correct MUX ID 02 no data change but DLC\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_CHANGED &&
-            nbytes == BCM_1FRAME_LEN &&
-            rxmsg.msg_head.can_id == 0x42 && rxmsg.frame[0].can_id == 0x42) {
-                printf("<11>Received correct RX_CHANGED message for can_id <%03X> >> OK!\n",
-                       rxmsg.frame[0].can_id);
-        }
-
-        txmsg.msg_head.opcode  = TX_SEND;
-        txmsg.msg_head.nframes = 1;
-        txmsg.frame[0].can_id    = 0x42;
-        txmsg.frame[0].can_dlc   = 7;
-        U64_DATA(&txmsg.frame[0]) = (__u64) 0x0300000000000001ULL;
-
-        printf("<12>Writing TX_SEND with wrong MUX ID 03\n");
-
-        if (write(s, &txmsg, BCM_1FRAME_LEN) < 0)
-                perror("write");
-
-        if ((nbytes = read(s, &rxmsg, sizeof(rxmsg))) < 0)
-                perror("read");
-
-        if (rxmsg.msg_head.opcode == RX_TIMEOUT &&
-            nbytes == sizeof(struct bcm_msg_head) &&
-            rxmsg.msg_head.can_id == 0x42) {
-                printf("<-->Received correct RX_TIMEOUT message for can_id <%03X> >> OK!\n",
-                       rxmsg.msg_head.can_id);
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-tx_read.c filter-tests-new/tst-bcm-tx_read.c
--- filter-tests/tst-bcm-tx_read.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-tx_read.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,159 +0,0 @@
-/*
- *  $Id: tst-bcm-tx_read.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-tx_read.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
-        int s,i,nbytes;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame[4];
-        } msg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        msg.msg_head.opcode  = TX_SETUP;
-        msg.msg_head.can_id  = 0x42;
-        msg.msg_head.flags   = SETTIMER|STARTTIMER|TX_CP_CAN_ID|TX_COUNTEVT;
-        msg.msg_head.nframes = 1;
-        msg.msg_head.count = 2;
-        msg.msg_head.ival1.tv_sec = 3;
-        msg.msg_head.ival1.tv_usec = 0;
-        msg.msg_head.ival2.tv_sec = 5;
-        msg.msg_head.ival2.tv_usec = 0;
-        msg.frame[0].can_id    = 0xAA;
-        msg.frame[0].can_dlc   = 8;
-        U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        printf("Press any key to stop the cycle ...\n");
-
-        getchar();
-
-        msg.msg_head.opcode  = TX_SETUP;
-        msg.msg_head.can_id  = 0x42;
-        msg.msg_head.flags   = SETTIMER|STARTTIMER|TX_CP_CAN_ID;
-        msg.msg_head.nframes = 1;
-        msg.msg_head.count = 0;
-        msg.msg_head.ival1.tv_sec = 0;
-        msg.msg_head.ival1.tv_usec = 0;
-        msg.msg_head.ival2.tv_sec = 0;
-        msg.msg_head.ival2.tv_usec = 0;
-        msg.frame[0].can_id    = 0xAA;
-        msg.frame[0].can_dlc   = 8;
-        U64_DATA(&msg.frame[0]) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        printf("Press any key to read the entry ...\n");
-
-        getchar();
-
-        msg.msg_head.opcode  = TX_READ;
-        msg.msg_head.can_id  = 0x42;
-        msg.msg_head.nframes = 0;
-
-        if (write(s, &msg, sizeof(msg)) < 0)
-                perror("write");
-
-        printf("Press any key to read from the socket ...\n");
-
-        getchar();
-
-        if ((nbytes = read(s, &msg, sizeof(msg))) < 0)
-                perror("read");
-        for (i = 0; i < nbytes; i++)
-                printf(" %02x", ((unsigned char*)&msg)[i]);
-        putchar('\n');
-
-        printf("Press any key to close the socket ...\n");
-
-        getchar();
-
-        close(s);
-
-        printf("Press any key to end the program ...\n");
-
-        getchar();
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-bcm-tx-sendto.c filter-tests-new/tst-bcm-tx-sendto.c
--- filter-tests/tst-bcm-tx-sendto.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-bcm-tx-sendto.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,123 +0,0 @@
-/*
- *  $Id: tst-bcm-tx-sendto.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-bcm-tx-sendto.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/bcm.h>
-
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-
-        struct {
-                struct bcm_msg_head msg_head;
-                struct can_frame frame;
-        } txmsg;
-
-        if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        addr.can_family = PF_CAN;
-        addr.can_ifindex = 0; /* bind to 'any' device */
-
-        if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("connect");
-                return 1;
-        }
-
-        txmsg.msg_head.opcode  = TX_SETUP;
-        txmsg.msg_head.can_id  = 0x42;
-        txmsg.msg_head.flags   = SETTIMER|STARTTIMER;
-        txmsg.msg_head.nframes = 1;
-        txmsg.msg_head.count = 10;
-        txmsg.msg_head.ival1.tv_sec = 1;
-        txmsg.msg_head.ival1.tv_usec = 0;
-        txmsg.msg_head.ival2.tv_sec = 0;
-        txmsg.msg_head.ival2.tv_usec = 0;
-        txmsg.frame.can_id    = 0x42;
-        txmsg.frame.can_dlc   = 8;
-        U64_DATA(&txmsg.frame) = (__u64) 0xdeadbeefdeadbeefULL;
-
-        /* should cause an error due to ifindex = 0 */
-        if (write(s, &txmsg, sizeof(txmsg)) < 0)
-                perror("write");
-
-        printf("Press any key to send on valid device ...\n");
-        getchar();
-
-        addr.can_family = PF_CAN;
-        strcpy(ifr.ifr_name, "vcan2");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        addr.can_ifindex = ifr.ifr_ifindex;
-
-        if (sendto(s, &txmsg, sizeof(txmsg), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0)
-                perror("sendto");
-
-        printf("Press any key to close the socket ...\n");
-        getchar();
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-err.c filter-tests-new/tst-err.c
--- filter-tests/tst-err.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-err.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,168 +0,0 @@
-/*
- *  $Id: tst-err.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-err.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-#include <linux/can/error.h>
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct can_filter rfilter;
-        struct can_frame frame;
-        can_err_mask_t err_mask = CAN_ERR_MASK; /* all */
-        int nbytes;
-        struct ifreq ifr;
-        char *ifname = "vcan2";
-        int ifindex;
-        int opt;
-        struct timeval tv;
-
-        while ((opt = getopt(argc, argv, "i:m:")) != -1) {
-                switch (opt) {
-                case 'i':
-                        ifname = optarg;
-                        break;
-                case 'm':
-                        err_mask = strtoul(optarg, (char **)NULL, 16);
-                        break;
-                default:
-                        fprintf(stderr, "Unknown option %c\n", opt);
-                        break;
-                }
-        }
-
-
-        if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        rfilter.can_id   = CAN_INV_FILTER; /* no normal CAN frames */
-        rfilter.can_mask = 0; /* all: INV(all) == nothing */
-        setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
-        setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &err_mask, sizeof(err_mask));
-
-        strcpy(ifr.ifr_name, ifname);
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        ifindex = ifr.ifr_ifindex;
-
-        addr.can_family = AF_CAN;
-        addr.can_ifindex = ifindex;
-
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        while (1) {
-
-                if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
-                        perror("read");
-                        return 1;
-                } else if (nbytes < sizeof(struct can_frame)) {
-                        fprintf(stderr, "read: incomplete CAN frame\n");
-                        return 1;
-                } else {
-                        if (ioctl(s, SIOCGSTAMP, &tv) < 0)
-                                perror("SIOCGSTAMP");
-                        else
-                                printf("(%ld.%06ld) ", tv.tv_sec, tv.tv_usec);
-
-                        if (frame.can_id & CAN_ERR_BUSOFF)
-                                printf("(bus off) ");
-
-                        if (frame.can_id & CAN_ERR_TX_TIMEOUT)
-                                printf("(tx timeout) ");
-
-                        if (frame.can_id & CAN_ERR_ACK)
-                                printf("(ack) ");
-
-                        if (frame.can_id & CAN_ERR_LOSTARB) {
-                                printf("(lost arb)");
-                                if (frame.data[0])
-                                        printf("[%d]", frame.data[0]);
-                                printf(" ");
-                        }
-
-                        if (frame.can_id & CAN_ERR_CRTL) {
-                                printf("(crtl)");
-                                if (frame.data[1] & CAN_ERR_CRTL_RX_OVERFLOW)
-                                        printf("[RX buffer overflow]");
-                                if (frame.data[1] & CAN_ERR_CRTL_TX_OVERFLOW)
-                                        printf("[TX buffer overflow]");
-                                if (frame.data[1] & CAN_ERR_CRTL_RX_WARNING)
-                                        printf("[RX warning]");
-                                if (frame.data[1] & CAN_ERR_CRTL_TX_WARNING)
-                                        printf("[TX warning]");
-                                printf(" ");
-                        }
-
-                        /* to be continued */
-
-                        printf("\n");
-                        fflush(stdout);
-                }
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-filter.c filter-tests-new/tst-filter.c
--- filter-tests/tst-filter.c	1970-01-01 01:00:00.000000000 +0100
+++ filter-tests-new/tst-filter.c	2011-07-10 13:17:38.035710992 +0200
@@ -0,0 +1,244 @@
+/*
+ *  $Id: tst-filter.c 1263 2011-07-09 18:00:41Z hartkopp $
+ */
+
+/*
+ * tst-filter.c
+ *
+ * Copyright (c) 2011 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-users@lists.berlios.de>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#define ID 0x123
+#define TC 18 /* # of testcases */
+
+const int rx_res[TC] = {4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1};
+const int rxbits_res[TC] = {4369, 4369, 4369, 4369, 17, 4352, 17, 4352, 257, 257, 4112, 4112, 1, 256, 16, 4096, 1, 256};
+
+canid_t calc_id(int testcase)
+{
+	canid_t id = ID;
+
+	if (testcase & 1)
+		id |= CAN_EFF_FLAG;
+	if (testcase & 2)
+		id |= CAN_RTR_FLAG;
+
+	return id;
+}
+
+canid_t calc_mask(int testcase)
+{
+	canid_t mask = CAN_SFF_MASK;
+
+	if (testcase > 15)
+		return (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);
+
+	if (testcase & 4)
+		mask |= CAN_EFF_FLAG;
+	if (testcase & 8)
+		mask |= CAN_RTR_FLAG;
+
+	return mask;
+}
+
+int main(int argc, char **argv)
+{
+	fd_set rdfs;
+        struct timeval tv;
+	int s;
+	struct sockaddr_can addr;
+	struct can_filter rfilter;
+	struct can_frame frame;
+	int testcase;
+	int have_rx;
+	int rx;
+	int rxbits, rxbitval;
+	int ret;
+	int recv_own_msgs = 1;
+	struct ifreq ifr;
+
+	/* check command line options */
+	if (argc != 2) {
+		fprintf(stderr, "Usage: %s <device>\n", argv[0]);
+		return 1;
+	}
+
+	if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+		perror("socket");
+		return 1;
+	}
+
+	strcpy(ifr.ifr_name, argv[1]);
+	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
+		perror("SIOCGIFINDEX");
+		return 1;
+	}
+	addr.can_family = AF_CAN;
+	addr.can_ifindex = ifr.ifr_ifindex;
+
+	setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
+		   &recv_own_msgs, sizeof(recv_own_msgs));
+
+	if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+		perror("bind");
+		return 1;
+	}
+
+	printf("---\n");
+
+	for (testcase = 0; testcase < TC; testcase++) {
+		
+		rfilter.can_id   = calc_id(testcase);
+		rfilter.can_mask = calc_mask(testcase);
+		setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER,
+			   &rfilter, sizeof(rfilter));
+
+		printf("testcase %2d filters : can_id = 0x%08X can_mask = 0x%08X\n",
+		       testcase, rfilter.can_id, rfilter.can_mask);
+
+		printf("testcase %2d sending patterns ... ", testcase);
+
+		frame.can_dlc = 1;
+		frame.data[0] = testcase;
+
+		frame.can_id = ID;
+		if (write(s, &frame, sizeof(frame)) < 0) {
+			perror("write");
+			exit(1);
+		}
+		frame.can_id = (ID | CAN_RTR_FLAG);
+		if (write(s, &frame, sizeof(frame)) < 0) {
+			perror("write");
+			exit(1);
+		}
+		frame.can_id = (ID | CAN_EFF_FLAG);
+		if (write(s, &frame, sizeof(frame)) < 0) {
+			perror("write");
+			exit(1);
+		}
+		frame.can_id = (ID | CAN_EFF_FLAG | CAN_RTR_FLAG);
+		if (write(s, &frame, sizeof(frame)) < 0) {
+			perror("write");
+			exit(1);
+		}
+
+		printf("ok\n");
+
+		have_rx = 1;
+		rx = 0;
+		rxbits = 0;
+
+		while (have_rx) {
+
+			have_rx = 0;
+			FD_ZERO(&rdfs);
+			FD_SET(s, &rdfs);
+			tv.tv_sec = 0;
+			tv.tv_usec = 50000; /* 50ms timeout */
+
+			ret = select(s+1, &rdfs, NULL, NULL, &tv);
+			if (ret < 0) {
+				perror("select");
+				exit(1);
+			}
+
+			if (FD_ISSET(s, &rdfs)) {
+				have_rx = 1;
+				ret = read(s, &frame, sizeof(struct can_frame));
+				if (ret < 0) {
+					perror("read");
+					exit(1);
+				}
+				if ((frame.can_id & CAN_SFF_MASK) != ID) {
+					fprintf(stderr, "received wrong can_id!\n");
+					exit(1);
+				}
+				if (frame.data[0] != testcase) {
+					fprintf(stderr, "received wrong testcase!\n");
+					exit(1);
+				}
+
+				/* test & calc rxbits */
+				rxbitval = 1 << ((frame.can_id & (CAN_EFF_FLAG|CAN_RTR_FLAG|CAN_ERR_FLAG)) >> 28);
+
+				/* only receive a rxbitval once */
+				if ((rxbits & rxbitval) == rxbitval) {
+					fprintf(stderr, "received rxbitval %d twice!\n", rxbitval);
+					exit(1);
+				}
+				rxbits |= rxbitval;
+				rx++;
+
+				printf("testcase %2d rx : can_id = 0x%08X rx = %d rxbits = %d\n",
+				       testcase, frame.can_id, rx, rxbits);
+			}
+		}
+		/* rx timed out -> check the received results */
+		if (rx_res[testcase] != rx) {
+			fprintf(stderr, "wrong rx value in testcase %d : %d (expected %d)\n",
+				testcase, rx, rx_res[testcase]);
+			exit(1);
+		}
+		if (rxbits_res[testcase] != rxbits) {
+			fprintf(stderr, "wrong rxbits value in testcase %d : %d (expected %d)\n",
+				testcase, rxbits, rxbits_res[testcase]);
+			exit(1);
+		}
+		printf("testcase %2d ok\n---\n", testcase);
+	}
+
+	close(s);
+
+	return 0;
+}
diff -u -N -r filter-tests/tst-filter-master.c filter-tests-new/tst-filter-master.c
--- filter-tests/tst-filter-master.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-filter-master.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,167 +0,0 @@
-/*
- *  $Id: tst-filter-master.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-filter-master.c
- *
- * Copyright (c) 2008 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct can_filter rfilter;
-        struct can_frame frame;
-        int testcase;
-        int nbytes;
-        struct ifreq ifr;
-        int ifindex;
-
-
-        if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        strcpy(ifr.ifr_name, "vcan0");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        ifindex = ifr.ifr_ifindex;
-
-        addr.can_family = AF_CAN;
-        addr.can_ifindex = ifindex;
-
-        rfilter.can_id   = 0xFA; /* receive only the filter ack */
-        rfilter.can_mask = CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG;
-        setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        /* send testcases 0 .. 17 and a terminating 18 to quit */
-        for (testcase = 0; testcase < 19; testcase++) {
-
-                printf("Sending testcase %2d ... ", testcase);
-                frame.can_id = 0x0F;
-                frame.can_dlc = 1;
-                frame.data[0] = testcase;
-
-                if (write(s, &frame, sizeof(frame)) < 0) {
-                        perror("write");
-                        exit(1);
-                }
-
-                /* wait for ACK from server */
-                if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
-                        perror("read");
-                        exit(1);
-                }
-
-                if (nbytes < sizeof(struct can_frame)) {
-                        fprintf(stderr, "read: incomplete CAN frame\n");
-                        exit(1);
-                }
-
-                if ((frame.can_id != 0xFA) || (frame.can_dlc != 1) ||
-                    (frame.data[0] != testcase)) {
-                        fprintf(stderr, "\nWrong answer from server!\n");
-                        exit(1);
-                }
-
-                printf("acked. ");
-                if (testcase > 17)
-                        break;
-
-                /* interactive mode, when there is any commandline option */
-                if (argc == 2) {
-                        printf("[press enter] ");
-                        getchar();
-                }
-
-                printf("Sending patterns ... ");
-
-                frame.can_dlc = 0;
-
-                frame.can_id = 0x123;
-                if (write(s, &frame, sizeof(frame)) < 0) {
-                        perror("write");
-                        exit(1);
-                }
-                frame.can_id = (0x123 | CAN_RTR_FLAG);
-                if (write(s, &frame, sizeof(frame)) < 0) {
-                        perror("write");
-                        exit(1);
-                }
-                frame.can_id = (0x123 | CAN_EFF_FLAG);
-                if (write(s, &frame, sizeof(frame)) < 0) {
-                        perror("write");
-                        exit(1);
-                }
-                frame.can_id = (0x123 | CAN_EFF_FLAG | CAN_RTR_FLAG);
-                if (write(s, &frame, sizeof(frame)) < 0) {
-                        perror("write");
-                        exit(1);
-                }
-
-                printf("ok\n");
-        }
-
-        printf("Filtertest done.\n");
-
-        close(s);
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-filter-server.c filter-tests-new/tst-filter-server.c
--- filter-tests/tst-filter-server.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-filter-server.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,212 +0,0 @@
-/*
- *  $Id: tst-filter-server.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-filter-server.c
- *
- * Copyright (c) 2008 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define ID  0x123
-#define FIL 0x7FF
-#define EFF CAN_EFF_FLAG
-#define RTR CAN_RTR_FLAG
-
-canid_t calc_id(int testcase)
-{
-        canid_t id = ID;
-
-        if (testcase & 1)
-                id |= EFF;
-        if (testcase & 2)
-                id |= RTR;
-
-        return id;
-}
-
-canid_t calc_mask(int testcase)
-{
-        canid_t mask = FIL;
-
-        if (testcase > 15)
-                return (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG);
-
-        if (testcase & 4)
-                mask |= EFF;
-        if (testcase & 8)
-                mask |= RTR;
-
-        return mask;
-}
-
-int main(int argc, char **argv)
-{
-        fd_set rdfs;
-        int s, t;
-        struct sockaddr_can addr;
-        struct can_filter rfilter;
-        struct can_frame frame;
-        int testcase = 0;
-        int nbytes, ret;
-        struct ifreq ifr;
-        int ifindex;
-
-
-        if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-        if ((t = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        strcpy(ifr.ifr_name, "vcan0");
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        ifindex = ifr.ifr_ifindex;
-
-        addr.can_family = AF_CAN;
-        addr.can_ifindex = ifindex;
-
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-        if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        rfilter.can_id   = 0xF; /* receive only the filter requests */
-        rfilter.can_mask = CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG;
-        setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
-        /* disable default receive filter on the test socket */
-        setsockopt(t, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
-
-        while (1) {
-                
-                FD_ZERO(&rdfs);
-                FD_SET(s, &rdfs);
-                FD_SET(t, &rdfs);
-
-                if ((ret = select(t+1, &rdfs, NULL, NULL, NULL)) < 0) {
-                        perror("select");
-                        break;
-                }
-
-                if (FD_ISSET(s, &rdfs)) {
-
-                        if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
-                                perror("read");
-                                exit(1);
-                        }
-
-                        if (nbytes < sizeof(struct can_frame)) {
-                                fprintf(stderr, "read: incomplete CAN frame\n");
-                                exit(1);
-                        }
-
-                        if ((frame.can_id != 0xF) || (frame.can_dlc != 1)) {
-                                fprintf(stderr, "\nWrong request from master!\n");
-                                exit(1);
-                        }
-
-                        testcase = frame.data[0];
-
-                        if (testcase < 18) {
-                                rfilter.can_id   = calc_id(testcase);
-                                rfilter.can_mask = calc_mask(testcase);
-                                setsockopt(t, SOL_CAN_RAW, CAN_RAW_FILTER,
-                                           &rfilter, sizeof(rfilter));
-
-                                printf("testcase %2d : can_id = 0x%08X can_mask = 0x%08X\n",
-                                       testcase, rfilter.can_id, rfilter.can_mask);
-                        }
-
-                        frame.can_id = 0xFA; /* filter ack */
-
-                        if (write(s, &frame, sizeof(frame)) < 0) {
-                                perror("write");
-                                exit(1);
-                        }
-
-                        if (testcase > 17)
-                                break;
-                }
-
-                if (FD_ISSET(t, &rdfs)) {
-
-                        if ((nbytes = read(t, &frame, sizeof(struct can_frame))) < 0) {
-                                perror("read");
-                                exit(1);
-                        }
-
-                        if (nbytes < sizeof(struct can_frame)) {
-                                fprintf(stderr, "read: incomplete CAN frame\n");
-                                exit(1);
-                        }
-                        
-                        printf ("%08X\n", frame.can_id);
-                }
-        }
-
-        printf("testcase %2d : Filtertest done.\n", testcase);
-
-        close(s);
-        close(t);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-packet.c filter-tests-new/tst-packet.c
--- filter-tests/tst-packet.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-packet.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,168 +0,0 @@
-/*
- *  $Id: tst-packet.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-packet.c - send and receive CAN frames via PF_PACKET sockets
- *
- * Remark: The sending of CAN frames via PF_PACKET does not work for
- * virtual CAN devices (vcan) as the packet type is not set to
- * PACKET_LOOPBACK by the packet socket, so you'll never get something
- * back (btw the outgoing vcan packet counters are updated correctly).
- *
- * Copyright (c) 2002-2009 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <netinet/in.h>         /* for htons() */
-
-#include <linux/if_packet.h>
-#include <linux/if_ether.h>     /* for ETH_P_CAN */
-#include <linux/can.h>          /* for struct can_frame */
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct can_frame frame;
-        int nbytes, i;
-        static struct ifreq ifr;
-        static struct sockaddr_ll sll;
-        char *ifname = "vcan2";
-        int ifindex;
-        int opt;
-        int send_one_frame = 0;
-
-        while ((opt = getopt(argc, argv, "i:s")) != -1) {
-                switch (opt) {
-
-                case 'i':
-                        ifname = optarg;
-                        break;
-
-                case 's':
-                        send_one_frame = 1;
-                        break;
-
-                default:
-                        fprintf(stderr, "Unknown option %c\n", opt);
-                        break;
-                }
-        }
-
-        s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_CAN));
-        if (s < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        if (strcmp(ifname, "any") == 0)
-                ifindex = 0;
-        else {
-                strcpy(ifr.ifr_name, ifname);
-                ioctl(s, SIOCGIFINDEX, &ifr);
-                ifindex = ifr.ifr_ifindex;
-        }
-
-        sll.sll_family   = AF_PACKET;
-        sll.sll_ifindex  = ifindex;
-        sll.sll_protocol = htons(ETH_P_CAN);
-
-        if (bind(s, (struct sockaddr *)&sll, sizeof(sll)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        if(send_one_frame) {
-
-                frame.can_id  = 0x123;
-                frame.can_dlc = 2;
-                frame.data[0] = 0x11;
-                frame.data[1] = 0x22;
-
-                nbytes = write(s, &frame, sizeof(struct can_frame));
-                if (nbytes < 0) {
-                        perror("write");
-                        return 1;
-                }
-                if (nbytes != sizeof(struct can_frame)) {
-                        perror("write_len");
-                        return 1;
-                }
-        }
-
-        while (1) {
-
-                if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
-                        perror("read");
-                        return 1;
-                } else if (nbytes < sizeof(struct can_frame)) {
-                        fprintf(stderr, "read: incomplete CAN frame\n");
-                        return 1;
-                } else {
-                        if (frame.can_id & CAN_EFF_FLAG)
-                                printf("%8X  ", frame.can_id & CAN_EFF_MASK);
-                        else
-                                printf("%3X  ", frame.can_id & CAN_SFF_MASK);
-            
-                        printf("[%d] ", frame.can_dlc);
-            
-                        for (i = 0; i < frame.can_dlc; i++) {
-                                printf("%02X ", frame.data[i]);
-                        }
-                        if (frame.can_id & CAN_RTR_FLAG)
-                                printf("remote request");
-                        printf("\n");
-                        fflush(stdout);
-                }
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-proc.c filter-tests-new/tst-proc.c
--- filter-tests/tst-proc.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-proc.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,121 +0,0 @@
-/*
- *  $Id: tst-proc.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-proc.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define MAX_RAW 800
-
-int main(int argc, char **argv)
-{
-        int s[MAX_RAW];
-        struct sockaddr_can addr;
-        struct ifreq ifr;
-        int i,numsock;
-
-        if (argc != 2) {
-                fprintf(stderr, "Error: Wrong number of arguments. Try %s <number of created sockets>.\n", argv[0]);
-                exit(1);
-        }
-
-        numsock = atoi(argv[1]);
-
-        if (numsock >= MAX_RAW) {
-                fprintf(stderr, "Error: more than %d sockets to open (see #define MAX_RAW).\n", MAX_RAW);
-                exit(1);
-        }
-
-        printf("\ncreating %d raw sockets ... ", numsock);
-
-        if (numsock) {
-                for (i=0; i < numsock; i++) {
-                        if ((s[i] = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                                perror("socket");
-                                return 1;
-                        }
-
-                        addr.can_family = PF_CAN;
-                        strcpy(ifr.ifr_name, "vcan2");
-                        ioctl(s[i], SIOCGIFINDEX, &ifr);
-                        addr.can_ifindex = ifr.ifr_ifindex;
-
-                        if (bind(s[i], (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                                perror("connect");
-                                return 1;
-                        }
-                }
-        }
-
-        printf("done.\n");
-
-        printf("Waiting for keyboard input ...");
-
-        getchar();
-
-        printf("closing %d raw sockets ... ", numsock);
-
-        if (numsock)
-                for (i=0; i < numsock; i++)
-                        close(s[i]);
-
-        printf("done.\n\n");
-
-        return 0;
-
-}
-
diff -u -N -r filter-tests/tst-raw.c filter-tests-new/tst-raw.c
--- filter-tests/tst-raw.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-raw.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,188 +0,0 @@
-/*
- *  $Id: tst-raw.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-raw.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct can_filter rfilter[4];
-        struct can_frame frame;
-        int nbytes, i;
-        struct ifreq ifr;
-        char *ifname = "vcan2";
-        int ifindex;
-        int opt;
-
-        /* sockopt test */
-        int loopback = 0;
-        int set_loopback = 0;
-        int recv_own_msgs = 0;
-        int set_recv_own_msgs = 0;
-        int send_one_frame = 0;
-        int ignore_errors = 0;
-
-        while ((opt = getopt(argc, argv, "i:l:r:se")) != -1) {
-                switch (opt) {
-
-                case 'i':
-                        ifname = optarg;
-                        break;
-
-                case 'l':
-                        loopback = atoi(optarg);
-                        set_loopback = 1;
-                        break;
-
-                case 'r':
-                        recv_own_msgs = atoi(optarg);
-                        set_recv_own_msgs = 1;
-                        break;
-
-                case 's':
-                        send_one_frame = 1;
-                        break;
-
-                case 'e':
-                        ignore_errors = 1;
-                        break;
-
-                default:
-                        fprintf(stderr, "Unknown option %c\n", opt);
-                        break;
-                }
-        }
-
-
-        if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        rfilter[0].can_id   = 0x123;
-        rfilter[0].can_mask = CAN_SFF_MASK;
-        rfilter[1].can_id   = 0x200;
-        rfilter[1].can_mask = 0x700;
-        rfilter[2].can_id   = 0x80123456;
-        rfilter[2].can_mask = 0x1FFFF000;
-        rfilter[3].can_id   = 0x80333333;
-        rfilter[3].can_mask = CAN_EFF_MASK;
-
-        setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
-
-        if(set_loopback)
-                setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback, sizeof(loopback));
-
-        if(set_recv_own_msgs)
-                setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, &recv_own_msgs, sizeof(recv_own_msgs));
-
-        strcpy(ifr.ifr_name, ifname);
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        ifindex = ifr.ifr_ifindex;
-
-        addr.can_family = AF_CAN;
-        addr.can_ifindex = ifindex;
-
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        if(send_one_frame) {
-
-                frame.can_id  = 0x123;
-                frame.can_dlc = 2;
-                frame.data[0] = 0x11;
-                frame.data[1] = 0x22;
-
-                nbytes = write(s, &frame, sizeof(struct can_frame));
-        }
-
-        while (1) {
-
-                if ((nbytes = read(s, &frame, sizeof(struct can_frame))) < 0) {
-                        perror("read");
-                        if (!ignore_errors)
-                                return 1;
-                } else if (nbytes < sizeof(struct can_frame)) {
-                        fprintf(stderr, "read: incomplete CAN frame\n");
-                        return 1;
-                } else {
-                        if (frame.can_id & CAN_EFF_FLAG)
-                                printf("%8X  ", frame.can_id & CAN_EFF_MASK);
-                        else
-                                printf("%3X  ", frame.can_id & CAN_SFF_MASK);
-            
-                        printf("[%d] ", frame.can_dlc);
-            
-                        for (i = 0; i < frame.can_dlc; i++) {
-                                printf("%02X ", frame.data[i]);
-                        }
-                        if (frame.can_id & CAN_RTR_FLAG)
-                                printf("remote request");
-                        printf("\n");
-                        fflush(stdout);
-                }
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-raw-filter.c filter-tests-new/tst-raw-filter.c
--- filter-tests/tst-raw-filter.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-raw-filter.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,179 +0,0 @@
-/*
- *  $Id: tst-raw-filter.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-raw-filter.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#define MAXFILTERS 32
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct can_filter rfilter[MAXFILTERS];
-        struct can_frame frame;
-        int nbytes, i;
-        struct ifreq ifr;
-        char *ifname = "any";
-        int ifindex;
-        int opt;
-        int peek = 0;
-        int nfilters = 0;
-        int deflt = 0;
-
-        while ((opt = getopt(argc, argv, "i:p:f:d")) != -1) {
-                switch (opt) {
-                case 'i': /* specify different interface than default */
-                        ifname = optarg;
-                        break;
-                case 'p': /* MSG_PEEK 'p' times before consuming the frame */
-                        peek = atoi(optarg);
-                        break;
-                case 'd': /* use default settings from CAN_RAW socket */ 
-                        deflt = 1;
-                        break;
-                case 'f': /* add this filter can_id:can_mask */
-                        if (nfilters >= MAXFILTERS) {
-                                fputs("too many filters\n", stderr);
-                                break;
-                        }
-                        rfilter[nfilters].can_id = strtoul(strtok(optarg, ":"), NULL, 16);
-                        rfilter[nfilters].can_mask = strtoul(strtok(NULL, ":"), NULL, 16);
-                        nfilters++;
-                        break;
-                default:
-                        fprintf(stderr, "Unknown option %c\n", opt);
-                        break;
-                }
-        }
-
-
-        if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        if (deflt) {
-                printf("%s: using CAN_RAW socket default filter.\n", argv[0]);
-        } else {
-                printf("%s: setting %d CAN filter(s).\n", argv[0], nfilters);
-                setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter,
-                           sizeof(*rfilter) * nfilters);
-        }
-
-        if (strcmp(ifname, "any") == 0)
-                ifindex = 0;
-        else {
-                strcpy(ifr.ifr_name, ifname);
-                ioctl(s, SIOCGIFINDEX, &ifr);
-                ifindex = ifr.ifr_ifindex;
-        }
-
-        addr.can_family = AF_CAN;
-        addr.can_ifindex = ifindex;
-
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-        while (1) {
-                socklen_t len = sizeof(addr);
-                int flags;
-
-                if (peek && peek--)
-                        flags = MSG_PEEK;
-                else
-                        flags = 0;
-
-                nbytes = recvfrom(s, &frame, sizeof(struct can_frame),
-                                  flags, (struct sockaddr*)&addr, &len);
-                if (nbytes < 0) {
-                        perror("read");
-                        return 1;
-                } else if (nbytes < sizeof(struct can_frame)) {
-                        fprintf(stderr, "read: incomplete CAN frame from iface %d\n",
-                                addr.can_ifindex);
-                        return 1;
-                } else {
-                        ifr.ifr_ifindex = addr.can_ifindex;
-                        ioctl(s, SIOCGIFNAME, &ifr);
-                        printf(" %-5s ", ifr.ifr_name);
-                        if (frame.can_id & CAN_EFF_FLAG)
-                                printf("%8X  ", frame.can_id & CAN_EFF_MASK);
-                        else
-                                printf("%3X  ", frame.can_id & CAN_SFF_MASK);
-            
-                        printf("[%d] ", frame.can_dlc);
-            
-                        for (i = 0; i < frame.can_dlc; i++) {
-                                printf("%02X ", frame.data[i]);
-                        }
-                        if (frame.can_id & CAN_RTR_FLAG)
-                                printf("remote request");
-                        if (flags & MSG_PEEK)
-                                printf(" (MSG_PEEK)");
-                        printf("\n");
-                        fflush(stdout);
-                }
-        }
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-raw-sendto.c filter-tests-new/tst-raw-sendto.c
--- filter-tests/tst-raw-sendto.c	2010-03-01 15:58:28.000000000 +0100
+++ filter-tests-new/tst-raw-sendto.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,118 +0,0 @@
-/*
- *  $Id: tst-raw-sendto.c,v 1.1 2009/03/02 15:33:55 subrata_modak Exp $
- */
-
-/*
- * tst-raw-sendto.c
- *
- * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Volkswagen nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * Alternatively, provided that this notice is retained in full, this
- * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2, in which case the provisions of the
- * GPL apply INSTEAD OF those given above.
- *
- * The provided data structures and external interfaces from this code
- * are not restricted to be used by modules with a GPL compatible license.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * Send feedback to <socketcan-users@lists.berlios.de>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-int main(int argc, char **argv)
-{
-        int s;
-        struct sockaddr_can addr;
-        struct can_frame frame;
-        int nbytes;
-        struct ifreq ifr;
-        char *ifname = "vcan2";
-        int ifindex;
-        int opt;
-
-        while ((opt = getopt(argc, argv, "i:")) != -1) {
-                switch (opt) {
-                case 'i':
-                        ifname = optarg;
-                        break;
-                default:
-                        fprintf(stderr, "Unknown option %c\n", opt);
-                        break;
-                }
-        }
-
-
-        if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-                perror("socket");
-                return 1;
-        }
-
-        strcpy(ifr.ifr_name, ifname);
-        ioctl(s, SIOCGIFINDEX, &ifr);
-        ifindex = ifr.ifr_ifindex;
-
-        addr.can_family  = AF_CAN;
-        addr.can_ifindex = 0; /* bind to all interfaces */
- 
-        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-                perror("bind");
-                return 1;
-        }
-
-
-        /* fill CAN frame */
-        frame.can_id  = 0x123;
-        frame.can_dlc = 3;
-        frame.data[0] = 0x11;
-        frame.data[1] = 0x22;
-        frame.data[2] = 0x33;
-
-        addr.can_family  = AF_CAN;
-        addr.can_ifindex = ifindex; /* send via this interface */
- 
-        nbytes = sendto(s, &frame, sizeof(struct can_frame), 0, (struct sockaddr*)&addr, sizeof(addr));
-
-        close(s);
-
-        return 0;
-}
-
diff -u -N -r filter-tests/tst-rcv-own-msgs.c filter-tests-new/tst-rcv-own-msgs.c
--- filter-tests/tst-rcv-own-msgs.c	1970-01-01 01:00:00.000000000 +0100
+++ filter-tests-new/tst-rcv-own-msgs.c	2011-07-10 13:17:47.059710684 +0200
@@ -0,0 +1,247 @@
+/*
+ *  $Id: tst-rcv-own-msgs.c 1193 2010-08-09 14:00:21Z hartkopp $
+ */
+
+/*
+ * tst-rcv-own-msgs.c
+ *
+ * Copyright (c) 2010 Volkswagen Group Electronic Research
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Volkswagen nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * The provided data structures and external interfaces from this code
+ * are not restricted to be used by modules with a GPL compatible license.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Send feedback to <socketcan-users@lists.berlios.de>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <net/if.h>
+
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+
+#define max(a,b) (a > b ? a : b)
+
+struct rxs {
+	int s;
+	int t;
+};
+
+struct rxs test_sockets(int s, int t, canid_t can_id)
+{
+	fd_set rdfs;
+	struct timeval tv;
+	int m = max(s,t)+1;
+	int have_rx = 1;
+	struct can_frame frame;
+	struct rxs rx;
+	int ret;
+
+	frame.can_id = can_id;
+	frame.can_dlc = 0;
+	if (write(s, &frame, sizeof(frame)) < 0) {
+		perror("write");
+		exit(1);
+	}
+
+	rx.s = rx.t = 0;
+
+	while (have_rx) {
+
+		FD_ZERO(&rdfs);
+		FD_SET(s, &rdfs);
+		FD_SET(t, &rdfs);
+		tv.tv_sec = 0;
+		tv.tv_usec = 50000; /* 50ms timeout */
+		have_rx = 0;
+
+		ret = select(m, &rdfs, NULL, NULL, &tv);
+		if (ret < 0) {
+			perror("select");
+			exit(1);
+		}
+
+		if (FD_ISSET(s, &rdfs)) {
+
+			have_rx = 1;
+			ret = read(s, &frame, sizeof(struct can_frame));
+			if (ret < 0) {
+				perror("read");
+				exit(1);
+			}
+			if (frame.can_id != can_id) {
+				fprintf(stderr, "received wrong can_id!\n");
+				exit(1);
+			}
+			rx.s++;
+		}
+
+		if (FD_ISSET(t, &rdfs)) {
+
+			have_rx = 1;
+			ret = read(t, &frame, sizeof(struct can_frame));
+			if (ret < 0) {
+				perror("read");
+				exit(1);
+			}
+			if (frame.can_id != can_id) {
+				fprintf(stderr, "received wrong can_id!\n");
+				exit(1);
+			}
+			rx.t++;
+		}
+	}
+
+	/* timeout */
+
+	return rx;
+}
+
+void setopts(int s, int loopback, int recv_own_msgs)
+{
+	setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK,
+		   &loopback, sizeof(loopback));
+	setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
+		   &recv_own_msgs, sizeof(recv_own_msgs));
+
+	printf("check loopback %d recv_own_msgs %d ... ",
+	       loopback, recv_own_msgs);
+}
+
+
+int main(int argc, char **argv)
+{
+	int s, t;
+	struct sockaddr_can addr;
+	struct ifreq ifr;
+	struct rxs rx;
+
+	/* check command line options */
+	if (argc != 2) {
+		fprintf(stderr, "Usage: %s <device>\n", argv[0]);
+		return 1;
+	}
+
+	if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+		perror("socket");
+		return 1;
+	}
+	if ((t = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+		perror("socket");
+		return 1;
+	}
+
+	strcpy(ifr.ifr_name, argv[1]);
+	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
+		perror("SIOCGIFINDEX");
+		return 1;
+	}
+	addr.can_ifindex = ifr.ifr_ifindex;
+	addr.can_family = AF_CAN;
+
+	if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+		perror("bind");
+		return 1;
+	}
+	if (bind(t, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+		perror("bind");
+		return 1;
+	}
+
+	printf("Starting PF_CAN frame flow test.\n");
+	printf("checking socket default settings ... ");
+	rx = test_sockets(s, t, 0x340);
+	if (rx.s == 0 && rx.t == 1)
+		printf("ok.\n");
+	else {
+		printf("failure!\n");
+		return 1;
+	}
+
+	/* check loopback 0 recv_own_msgs 0 */
+	setopts(s, 0, 0);
+	rx = test_sockets(s, t, 0x341);
+	if (rx.s == 0 && rx.t == 0)
+		printf("ok.\n");
+	else {
+		printf("failure!\n");
+		return 1;
+	}
+
+	/* check loopback 0 recv_own_msgs 1 */
+	setopts(s, 0, 1);
+	rx = test_sockets(s, t, 0x342);
+	if (rx.s == 0 && rx.t == 0)
+		printf("ok.\n");
+	else {
+		printf("failure!\n");
+		return 1;
+	}
+
+	/* check loopback 1 recv_own_msgs 0 */
+	setopts(s, 1, 0);
+	rx = test_sockets(s, t, 0x343);
+	if (rx.s == 0 && rx.t == 1)
+		printf("ok.\n");
+	else {
+		printf("failure!\n");
+		return 1;
+	}
+
+	/* check loopback 1 recv_own_msgs 1 */
+	setopts(s, 1, 1);
+	rx = test_sockets(s, t, 0x344);
+	if (rx.s == 1 && rx.t == 1)
+		printf("ok.\n");
+	else {
+		printf("failure!\n");
+		return 1;
+	}
+
+	printf("PF_CAN frame flow test was successful.\n");
+
+	close(s);
+	close(t);
+
+	return 0;
+}

^ permalink raw reply

* Re: [PATCH] natsemi: silence dma-debug warnings
From: David Miller @ 2011-07-10 14:07 UTC (permalink / raw)
  To: fujita.tomonori; +Cc: jim.cromie, thockin, netdev
In-Reply-To: <20110710.102039.1305564732068163396.fujita.tomonori@lab.ntt.co.jp>

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Date: Sun, 10 Jul 2011 10:20:39 +0900 (JST)

> On Sat, 9 Jul 2011 14:11:25 -0600
> Jim Cromie <jim.cromie@gmail.com> wrote:
> 
>> On Sun, Jul 3, 2011 at 11:34 PM, David Miller <davem@davemloft.net> wrote:
>>> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>> Date: Mon, 4 Jul 2011 14:30:19 +0900
>>>
>>>> This silences dma-debug warnings:
>>>>
>>>> https://lkml.org/lkml/2011/6/30/341
>>>  ...
>>>> Reported-by: Jim Cromie <jim.cromie@gmail.com>
>>>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
>>>> Tested-by: Jim Cromie <jim.cromie@gmail.com>
>>>
>>> Applied, thanks!
>>>
>> 
>> I have since seen a similar warning on shutdown,
>> heres a patch for it.
> 
> Oops, I noticed this too but I forgot to send a patch.
> 
> The patch looks good to me.

I'll apply this, thanks.

^ permalink raw reply

* Re: [PATCH 00/21] clean up rx_copybreak handling [split version]
From: Joe Perches @ 2011-07-10 15:11 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: netdev, Steffen Klassert, Santiago Leon, Tim Hockin, Don Fry,
	Francois Romieu, Ion Badulescu, Matt Carlson, Michael Chan,
	Grant Grundler, David Dillow, Roger Luethi, David S. Miller
In-Reply-To: <20110710115206.GA24395@rere.qmqm.pl>

On Sun, 2011-07-10 at 13:52 +0200, Michał Mirosław wrote:
> On Sun, Jul 10, 2011 at 01:28:18PM +0200, Michał Mirosław wrote:
> > On Sat, Jul 09, 2011 at 11:20:32AM -0700, Joe Perches wrote:
> > > where almost all other uses throughout drivers/net
> > > align arguments to open parenthesis instead.
> > > +			skb = dev_skb_finish_rx_dma(&np->rx_skbuff[entry],
> > > +						    pkt_len, rx_copybreak,
> > > +						    &np->pci_dev->dev,
> > > +						    le32_to_cpu(desc->frag[0].addr),
> > > +						    np->rx_buf_sz);
> > I'll fix that in v2 where the style differs.
> I modified patches where surrounding code had been consistent. I'm now
> convinced I don't like this style, especially when combined with 80-column
> limit and no limit on indentation levels.

Heh.

It truly can be a bad form when combined with
long variable or function names or multiple
indirections or string constants, etc.

I chose to ignore 80 columns on the
"le32_to_cpu(desc->frag[0].addr)," argument to
dev_skb_finish_rx_dma.

It can look hideous when slavish to 80 columns.

Feel free to ignore those checkpatch warnings
when you think appropriate.

cheers, Joe


^ permalink raw reply

* [PATCH] iproute2: fix minor typo in comments
From: Gilles Espinasse @ 2011-07-10 15:45 UTC (permalink / raw)
  To: netdev, shemminger; +Cc: Gilles Espinasse

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
---
 README       |    2 +-
 README.devel |    2 +-
 configure    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 0ed0372..528b539 100644
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ database routines.  Often this is in the db-devel package.
 
 2. make
 
-The makefile will automatically build a file Config which
+The makefile will automatically build a Config file which
 contains whether or not ATM is available, etc.
 
 3. To make documentation, cd to doc/ directory , then
diff --git a/README.devel b/README.devel
index 2022869..9b7d11e 100644
--- a/README.devel
+++ b/README.devel
@@ -1,7 +1,7 @@
 Iproute2 development is closely tied to Linux kernel networking
 development. Most new features require a kernel and a utility component.
 
-Please submit both the the Linux networking mailing list
+Please submit both to the Linux networking mailing list
    <netdev@vger.kernel.org>
 
 The current source is in the git repository:
diff --git a/configure b/configure
index 600fa96..69797ab 100755
--- a/configure
+++ b/configure
@@ -65,7 +65,7 @@ then
 	return
 fi
 
-#check if we need dont our internal header ..
+#check if we dont need our internal header ..
 cat >/tmp/ipttest.c <<EOF
 #include <xtables.h>
 char *lib_dir;
-- 
1.5.6.5


^ permalink raw reply related

* [PATCH] iproute2: fix implicit declaration of function '__ALIGN_KERNEL'
From: Gilles Espinasse @ 2011-07-10 15:46 UTC (permalink / raw)
  To: netdev, shemminger; +Cc: Gilles Espinasse

Warning seen with 2.6.32 kernel headers
 m_xt.c:85: warning: implicit declaration of function '__ALIGN_KERNEL'

Declaration lines borrowed from iptables-1.4.11.1

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
---
 include/linux/netfilter/x_tables.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 4120970..a6614b0 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -96,6 +96,8 @@ struct _xt_align {
 	__u64 u64;
 };
 
+#define __ALIGN_KERNEL(x, a)	__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL_MASK(x, mask)	(((x) + (mask)) & ~(mask))
 #define XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _xt_align))
 
 /* Standard return verdict, or do jump. */
-- 
1.5.6.5


^ permalink raw reply related

* Re: [PATCH] bridge: mask forwarding of IEEE 802 local multicast groups
From: Nick Carter @ 2011-07-10 16:04 UTC (permalink / raw)
  To: netdev, Michał Mirosław, David Lamparter,
	Stephen Hemminger; +Cc: davem
In-Reply-To: <BANLkTi=jnxBu6WzAOTxHD+e_O1qYKE2m=g@mail.gmail.com>

Updated diffs so they apply to net-next (Original diffs were based off 2.6.38).

Any chance of getting these diffs applied?  The default behaviour of
the bridge code is unchanged.  They solve the problem of
authenticating a virtual 802.1x supplicant machine against an external
802.1X authenticator.  It is also a general solution that allows the
forwarding of any combination of the IEEE 802 local multicast groups.

Signed-off-by: Nick Carter <ncarter100@gmail.com>
Reviewed-by: David Lamparter <equinox@diac24.net>

 net/bridge/br_device.c   |    1 +
 net/bridge/br_input.c    |    3 +++
 net/bridge/br_private.h  |    8 ++++++++
 net/bridge/br_sysfs_br.c |   23 +++++++++++++++++++++++
 4 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 32b8f9f..573ed8c 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -366,6 +366,7 @@ void br_dev_setup(struct net_device *dev)
 	br->bridge_hello_time = br->hello_time = 2 * HZ;
 	br->bridge_forward_delay = br->forward_delay = 15 * HZ;
 	br->ageing_time = 300 * HZ;
+	br->group_fwd_mask = 0;

 	br_netfilter_rtable_init(br);
 	br_stp_timer_init(br);
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index f06ee39..3bee262 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -170,6 +170,9 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 		if (p->br->stp_enabled == BR_NO_STP && dest[5] == 0)
 			goto forward;

+		if (p->br->group_fwd_mask & (1 << dest[5]))
+			goto forward;
+
 		if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
 			    NULL, br_handle_local_finish)) {
 			return RX_HANDLER_CONSUMED; /* consumed by filter */
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 54578f2..413fcec 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -244,6 +244,14 @@ struct net_bridge
 	struct timer_list		multicast_query_timer;
 #endif

+	/* Each bit used to match the least significant nibble of the
+	 * IEEE 802.1D group address.
+	 * 01-80-C2-00-00-00 bit 0
+	 * ..
+	 * 01-80-C2-00-00-0F bit 15
+	 */
+	u16				group_fwd_mask;
+
 	struct timer_list		hello_timer;
 	struct timer_list		tcn_timer;
 	struct timer_list		topology_change_timer;
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 68b893e..d77f681 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -646,6 +646,28 @@ static DEVICE_ATTR(nf_call_arptables, S_IRUGO | S_IWUSR,
 		   show_nf_call_arptables, store_nf_call_arptables);
 #endif

+static ssize_t show_group_fwd_mask(struct device *d,
+				   struct device_attribute *attr, char *buf)
+{
+	struct net_bridge *br = to_bridge(d);
+	return sprintf(buf, "%d\n", br->group_fwd_mask);
+}
+
+static int set_group_fwd_mask(struct net_bridge *br, unsigned long val)
+{
+	br->group_fwd_mask = (u16)val;
+	return 0;
+}
+
+static ssize_t store_group_fwd_mask(struct device *d,
+				    struct device_attribute *attr,
+				    const char *buf, size_t len)
+{
+	return store_bridge_parm(d, buf, len, set_group_fwd_mask);
+}
+static DEVICE_ATTR(group_fwd_mask, S_IRUGO | S_IWUSR, show_group_fwd_mask,
+		   store_group_fwd_mask);
+
 static struct attribute *bridge_attrs[] = {
 	&dev_attr_forward_delay.attr,
 	&dev_attr_hello_time.attr,
@@ -665,6 +687,7 @@ static struct attribute *bridge_attrs[] = {
 	&dev_attr_gc_timer.attr,
 	&dev_attr_group_addr.attr,
 	&dev_attr_flush.attr,
+	&dev_attr_group_fwd_mask.attr,
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 	&dev_attr_multicast_router.attr,
 	&dev_attr_multicast_snooping.attr,

On 1 July 2011 22:21, Nick Carter <ncarter100@gmail.com> wrote:
> Introduce sysfs ../bridge/group_fwd_mask attribute so users can
> configure which group mac addresses are forwarded.
>
> These diffs do not change the default behaviour of bridge.ko.  By
> changing the group_fwd_mask value users can select any combination of
> the 01-80-C2-00-00-00 - 01-80-C2-00-00-0F addresses to be forwarded.
>
> Signed-off-by: Nick Carter <ncarter100@gmail.com>
>
> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
> index d9d1e2b..bb25e49 100644
> --- a/net/bridge/br_if.c
> +++ b/net/bridge/br_if.c
> @@ -214,6 +214,7 @@ static struct net_device *new_bridge_dev(struct
> net *net, const char *name)
>        br->topology_change = 0;
>        br->topology_change_detected = 0;
>        br->ageing_time = 300 * HZ;
> +       br->group_fwd_mask = 0;
>
>        br_netfilter_rtable_init(br);
>
> diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
> index 90e985b..80b94f4 100644
> --- a/net/bridge/br_input.c
> +++ b/net/bridge/br_input.c
> @@ -166,6 +166,9 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb)
>                if (p->br->stp_enabled == BR_NO_STP && dest[5] == 0)
>                        goto forward;
>
> +               if (p->br->group_fwd_mask & (1 << dest[5]))
> +                       goto forward;
> +
>                if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
>                            NULL, br_handle_local_finish))
>                        return NULL;    /* frame consumed by filter */
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 4e1b620..d5aa164 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -244,6 +244,13 @@ struct net_bridge
>        struct timer_list               multicast_query_timer;
>  #endif
>
> +       /* Each bit used to match the LSB of the IEEE 802.1D group address
> +        * 01-80-C2-00-00-00 bit 0
> +        * ..
> +        * 01-80-C2-00-00-0F bit 15
> +        */
> +       u16                             group_fwd_mask;
> +
>        struct timer_list               hello_timer;
>        struct timer_list               tcn_timer;
>        struct timer_list               topology_change_timer;
> diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
> index 5c1e555..f3cced5 100644
> --- a/net/bridge/br_sysfs_br.c
> +++ b/net/bridge/br_sysfs_br.c
> @@ -679,6 +679,28 @@ static DEVICE_ATTR(nf_call_arptables, S_IRUGO | S_IWUSR,
>                   show_nf_call_arptables, store_nf_call_arptables);
>  #endif
>
> +static ssize_t show_group_fwd_mask(struct device *d, struct
> device_attribute *attr,
> +                               char *buf)
> +{
> +       struct net_bridge *br = to_bridge(d);
> +       return sprintf(buf, "%d\n", br->group_fwd_mask);
> +}
> +
> +static int set_group_fwd_mask(struct net_bridge *br, unsigned long val)
> +{
> +       br->group_fwd_mask = (u16)val;
> +       return 0;
> +}
> +
> +static ssize_t store_group_fwd_mask(struct device *d,
> +                                struct device_attribute *attr, const char *buf,
> +                                size_t len)
> +{
> +       return store_bridge_parm(d, buf, len, set_group_fwd_mask);
> +}
> +static DEVICE_ATTR(group_fwd_mask, S_IRUGO | S_IWUSR, show_group_fwd_mask,
> +                  store_group_fwd_mask);
> +
>  static struct attribute *bridge_attrs[] = {
>        &dev_attr_forward_delay.attr,
>        &dev_attr_hello_time.attr,
> @@ -698,6 +720,7 @@ static struct attribute *bridge_attrs[] = {
>        &dev_attr_gc_timer.attr,
>        &dev_attr_group_addr.attr,
>        &dev_attr_flush.attr,
> +       &dev_attr_group_fwd_mask.attr,
>  #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
>        &dev_attr_multicast_router.attr,
>        &dev_attr_multicast_snooping.attr,
>

^ permalink raw reply related

* [PATCH] slip: fix wrong SLIP6 ifdef-endif placing
From: Matvejchikov Ilya @ 2011-07-10 18:32 UTC (permalink / raw)
  To: netdev

SLIP6 have nothing to do with CSLIP so placing a block of
SLIP6-related code within a CSLIP ifdef-endif block is incorrect.

Signed-off-by: Ilya Matvejchikov <matvejchikov@gmail.com>
---
 drivers/net/slip.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 8ec1a9a..1ce6e08 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -182,11 +182,11 @@ static int sl_alloc_bufs(struct slip *sl, int mtu)
 #ifdef SL_INCLUDE_CSLIP
 	cbuff = xchg(&sl->cbuff, cbuff);
 	slcomp = xchg(&sl->slcomp, slcomp);
+#endif
 #ifdef CONFIG_SLIP_MODE_SLIP6
 	sl->xdata    = 0;
 	sl->xbits    = 0;
 #endif
-#endif
 	spin_unlock_bh(&sl->lock);
 	err = 0;

@@ -194,8 +194,7 @@ static int sl_alloc_bufs(struct slip *sl, int mtu)
 err_exit:
 #ifdef SL_INCLUDE_CSLIP
 	kfree(cbuff);
-	if (slcomp)
-		slhc_free(slcomp);
+	slhc_free(slcomp);
 #endif
 	kfree(xbuff);
 	kfree(rbuff);
-- 
1.7.4.1

^ permalink raw reply related

* Re: [PATCH] slip: fix wrong SLIP6 ifdef-endif placing
From: David Miller @ 2011-07-10 18:37 UTC (permalink / raw)
  To: matvejchikov; +Cc: netdev
In-Reply-To: <CAKh5nabf9OBG7yb5r=v0bhJLjNJgVrw-hVx9quJ9cwcOXSva=Q@mail.gmail.com>

From: Matvejchikov Ilya <matvejchikov@gmail.com>
Date: Sun, 10 Jul 2011 22:32:55 +0400

> SLIP6 have nothing to do with CSLIP so placing a block of
> SLIP6-related code within a CSLIP ifdef-endif block is incorrect.
> 
> Signed-off-by: Ilya Matvejchikov <matvejchikov@gmail.com>
 ...
> @@ -194,8 +194,7 @@ static int sl_alloc_bufs(struct slip *sl, int mtu)
>  err_exit:
>  #ifdef SL_INCLUDE_CSLIP
>  	kfree(cbuff);
> -	if (slcomp)
> -		slhc_free(slcomp);
> +	slhc_free(slcomp);
>  #endif

The change in this hunk has nothing to do with what you
claim to be doing in your commit message.

Don't mix unrelated changes together.

^ permalink raw reply

* irlap_frame.c: Duplicate set?
From: Joe Perches @ 2011-07-10 18:43 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: netdev

frame->caddr is consecutively set to multiple values.
The first set can probably be removed.

net/irda/irlap_frame.c
[...]
void irlap_send_rd_frame(struct irlap_cb *self)
{
	struct sk_buff *tx_skb;
	struct rd_frame *frame;

	tx_skb = alloc_skb(sizeof(struct rd_frame), GFP_ATOMIC);
	if (!tx_skb)
		return;

	frame = (struct rd_frame *)skb_put(tx_skb, 2);

	frame->caddr = self->caddr;
	frame->caddr = RD_RSP | PF_BIT;

	irlap_queue_xmit(self, tx_skb);
}



^ permalink raw reply

* Re: [PATCH] slip: fix wrong SLIP6 ifdef-endif placing
From: Matvejchikov Ilya @ 2011-07-10 18:49 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20110710.113741.2147626275846755476.davem@davemloft.net>

SLIP6 have nothing to do with CSLIP so placing a block of
SLIP6-related code within a CSLIP ifdef-endif block is incorrect.

Signed-off-by: Ilya Matvejchikov <matvejchikov@gmail.com>
---
 drivers/net/slip.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 8ec1a9a..2f110fb 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -182,11 +182,11 @@ static int sl_alloc_bufs(struct slip *sl, int mtu)
 #ifdef SL_INCLUDE_CSLIP
 	cbuff = xchg(&sl->cbuff, cbuff);
 	slcomp = xchg(&sl->slcomp, slcomp);
+#endif
 #ifdef CONFIG_SLIP_MODE_SLIP6
 	sl->xdata    = 0;
 	sl->xbits    = 0;
 #endif
-#endif
 	spin_unlock_bh(&sl->lock);
 	err = 0;

-- 
1.7.4.1

^ permalink raw reply related

* Re: ipv4: Simplify ARP hash function.
From: David Miller @ 2011-07-10 19:07 UTC (permalink / raw)
  To: roland; +Cc: johnwheffner, mj, netdev
In-Reply-To: <CAL1RGDUzN_B0of0Ly6PxxaHM+A+E_1ZA0NTcC6jMmcrcoy0DxQ@mail.gmail.com>

From: Roland Dreier <roland@purestorage.com>
Date: Fri, 8 Jul 2011 16:11:00 -0700

> Maybe * of hash key with a random odd value is good enough?

Yes, from what I've read over the past few days it should
be.  More precisely:

	(key * hash_rnd) >> (32 - hash_table_size_log2)

where "hash_rnd" is odd.

The reason we want the top bits is because multiplies intrinsically
work such that bits in the inputs can only effect the same or higher
bits in the result.

^ permalink raw reply

* Re: [RFC 43/72] a2065/ariadne: Move the a2065/ariadne drivers
From: Geert Uytterhoeven @ 2011-07-10 19:34 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: davem@davemloft.net, netdev@vger.kernel.org
In-Reply-To: <1310221836.26989.11.camel@jtkirshe-mobl>

On Sat, Jul 9, 2011 at 16:30, Jeff Kirsher <jeffrey.t.kirsher@intel.com> wrote:
> On Tue, 2011-06-28 at 13:33 -0700, Geert Uytterhoeven wrote:
>> And (in some other patch) 82596.c is an Intel driver, not a Motorola driver.
>
> 82596.c is not an Intel driver, it is an Intel part.  The driver was

Sorry, I meant "driver for an Intel part".

> written and support by someone other than Intel.  I am looking at how to

Sure. But I'm strongly against classifying drivers based on who wrote them ;-)

> better organize the 82596.c, lasi_82596.c, lib82596.c, and sni_82596.c
> which all use an Intel Ethernet chip but were written and supported by
> someone other than Intel.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* Re: [RFC 43/72] a2065/ariadne: Move the a2065/ariadne drivers
From: Christoph Hellwig @ 2011-07-10 19:56 UTC (permalink / raw)
  To: Jeff Kirsher
  Cc: Geert Uytterhoeven, davem@davemloft.net, netdev@vger.kernel.org
In-Reply-To: <1310221836.26989.11.camel@jtkirshe-mobl>

On Sat, Jul 09, 2011 at 07:30:26AM -0700, Jeff Kirsher wrote:
> 82596.c is not an Intel driver, it is an Intel part.  The driver was
> written and support by someone other than Intel.

Which doesn't matter at all.


^ permalink raw reply

* Re: [RFC 43/72] a2065/ariadne: Move the a2065/ariadne drivers
From: Jeff Kirsher @ 2011-07-11  0:48 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: davem@davemloft.net, netdev@vger.kernel.org
In-Reply-To: <CAMuHMdVHRNk4arc75QKrzDmHYE+86NixPk6v9uGwOAPkUTCgJw@mail.gmail.com>

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

On Sun, 2011-07-10 at 12:34 -0700, Geert Uytterhoeven wrote:
> On Sat, Jul 9, 2011 at 16:30, Jeff Kirsher
> <jeffrey.t.kirsher@intel.com> wrote:
> > On Tue, 2011-06-28 at 13:33 -0700, Geert Uytterhoeven wrote:
> >> And (in some other patch) 82596.c is an Intel driver, not a
> Motorola driver.
> >
> > 82596.c is not an Intel driver, it is an Intel part.  The driver was
> 
> Sorry, I meant "driver for an Intel part".
> 
> > written and support by someone other than Intel.  I am looking at
> how to
> 
> Sure. But I'm strongly against classifying drivers based on who wrote
> them ;-)

I agree to some extent, because if that were the case, we would have a
donald_becker/ directory for several of the drivers. :)

Here is one of the problem's I keep running into and there is no simple
answer.  While most of the drivers can be grouped together by the
hardware they use, that does not work "logically" for every driver.

In addition, if vendor 'A' makes a part and vendor 'B' uses same part in
a device/system/NIC and vendor 'B' creates the driver, supports the
driver and maintains the driver.  Should the part be categorized under
vendor 'A'?  IMHO, I think it should be categorized as a vendor 'B'
driver.

I started this work with the idea of trying to organize the drivers in
the same way that the drivers were to be in the Kconfig, which tended to
be drivers/net/ethernet/<manufacturer>.

One of the problems that arise in this organization is what do we do
when vendor A is bought by vendor B, and vendor B takes on the support
of all the old vendor A parts/drivers?

So I am open to suggestions.  The process I have using to organize the
drivers has been to group drivers that use common libraries and/or code
first, then group by either manufacturer, maintainer, or common
platform.

I would like to keep the lasi_82506.c, sni_82596.c, 82506.c and similar
drivers out of the intel/ directory because we would not be supporting
the drivers and they are not similar to our drivers that we do support
that would be in the intel/ directory.

Again, I open to suggestions on how to best organize these types of
drivers.  Maybe create a misc/ or <bus_type>/ for these types of
drivers? 

> 
> > better organize the 82596.c, lasi_82596.c, lib82596.c, and
> sni_82596.c
> > which all use an Intel Ethernet chip but were written and supported
> by
> > someone other than Intel. 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* [PATCH v2 03/46] net drivers: remove unnecessary dma_sync_to_device(DMA_FROM_DEVICE)
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev
  Cc: linux-wireless, Eilon Greenstein, Gary Zambrano,
	Stephen Hemminger, Stefano Brivio, e1000-devel, Matt Carlson,
	Jesse Brandeburg, Francois Romieu, Realtek linux nic maintainers,
	John W. Linville, Ron Mercer, Michael Chan, Jitendra Kalsaria,
	Divy Le Ray, Bruce Allan, Hartley Sweeten, John Ronciak,
	Jon Mason, linux-driver, Larry Finger
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

dma_sync_to_device() is not needed when only device modifies the buffer.
See: DMA-API.txt, part. Id, DMA_FROM_DEVICE description.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/arm/ep93xx_eth.c         |    3 ---
 drivers/net/b44.c                    |    4 ----
 drivers/net/bnx2.c                   |    4 ----
 drivers/net/bnx2x/bnx2x_cmn.h        |    5 -----
 drivers/net/cassini.c                |   12 ------------
 drivers/net/cxgb3/sge.c              |    3 ---
 drivers/net/e100.c                   |    3 ---
 drivers/net/e1000e/netdev.c          |    4 +---
 drivers/net/mlx4/en_rx.c             |    2 --
 drivers/net/qlge/qlge_main.c         |   11 -----------
 drivers/net/r8169.c                  |    1 -
 drivers/net/s2io.c                   |    6 +-----
 drivers/net/skge.c                   |    3 ---
 drivers/net/sky2.c                   |    2 --
 drivers/net/tg3.c                    |    1 -
 drivers/net/tokenring/olympic.c      |    6 ------
 drivers/net/vxge/vxge-main.c         |    3 ---
 drivers/net/wireless/b43legacy/dma.c |   19 -------------------
 18 files changed, 2 insertions(+), 90 deletions(-)

diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 4317af8..ba3bf43 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -289,9 +289,6 @@ static int ep93xx_rx(struct net_device *dev, int processed, int budget)
 			dma_sync_single_for_cpu(dev->dev.parent, rxd->buf_addr,
 						length, DMA_FROM_DEVICE);
 			skb_copy_to_linear_data(skb, ep->rx_buf[entry], length);
-			dma_sync_single_for_device(dev->dev.parent,
-						   rxd->buf_addr, length,
-						   DMA_FROM_DEVICE);
 			skb_put(skb, length);
 			skb->protocol = eth_type_trans(skb, dev);
 
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 6c4ef96..033029f 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -739,10 +739,6 @@ static void b44_recycle_rx(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
 		b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma,
 					     dest_idx * sizeof(*dest_desc),
 					     DMA_BIDIRECTIONAL);
-
-	dma_sync_single_for_device(bp->sdev->dma_dev, dest_map->mapping,
-				   RX_PKT_BUF_SZ,
-				   DMA_FROM_DEVICE);
 }
 
 static int b44_rx(struct b44 *bp, int budget)
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 7915d14..d627886 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2927,10 +2927,6 @@ bnx2_reuse_rx_skb(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
 	cons_rx_buf = &rxr->rx_buf_ring[cons];
 	prod_rx_buf = &rxr->rx_buf_ring[prod];
 
-	dma_sync_single_for_device(&bp->pdev->dev,
-		dma_unmap_addr(cons_rx_buf, mapping),
-		BNX2_RX_OFFSET + BNX2_RX_COPY_THRESH, PCI_DMA_FROMDEVICE);
-
 	rxr->rx_prod_bseq += bp->rx_buf_use_size;
 
 	prod_rx_buf->skb = skb;
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index c016e20..c9e49a0 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -923,16 +923,11 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp,
 static inline void bnx2x_reuse_rx_skb(struct bnx2x_fastpath *fp,
 				      u16 cons, u16 prod)
 {
-	struct bnx2x *bp = fp->bp;
 	struct sw_rx_bd *cons_rx_buf = &fp->rx_buf_ring[cons];
 	struct sw_rx_bd *prod_rx_buf = &fp->rx_buf_ring[prod];
 	struct eth_rx_bd *cons_bd = &fp->rx_desc_ring[cons];
 	struct eth_rx_bd *prod_bd = &fp->rx_desc_ring[prod];
 
-	dma_sync_single_for_device(&bp->pdev->dev,
-				   dma_unmap_addr(cons_rx_buf, mapping),
-				   RX_COPY_THRESH, DMA_FROM_DEVICE);
-
 	dma_unmap_addr_set(prod_rx_buf, mapping,
 			   dma_unmap_addr(cons_rx_buf, mapping));
 	prod_rx_buf->skb = cons_rx_buf->skb;
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index b414f5a..788ab13 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -1997,8 +1997,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 				    PCI_DMA_FROMDEVICE);
 		addr = cas_page_map(page->buffer);
 		memcpy(p, addr + off, i);
-		pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
-				    PCI_DMA_FROMDEVICE);
 		cas_page_unmap(addr);
 		RX_USED_ADD(page, 0x100);
 		p += hlen;
@@ -2032,8 +2030,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 		if (p == (char *) skb->data) { /* not split */
 			addr = cas_page_map(page->buffer);
 			memcpy(p, addr + off, RX_COPY_MIN);
-			pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
-					PCI_DMA_FROMDEVICE);
 			cas_page_unmap(addr);
 			off += RX_COPY_MIN;
 			swivel = RX_COPY_MIN;
@@ -2063,9 +2059,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 			pci_dma_sync_single_for_cpu(cp->pdev, page->dma_addr,
 					    hlen + cp->crc_size,
 					    PCI_DMA_FROMDEVICE);
-			pci_dma_sync_single_for_device(cp->pdev, page->dma_addr,
-					    hlen + cp->crc_size,
-					    PCI_DMA_FROMDEVICE);
 
 			skb_shinfo(skb)->nr_frags++;
 			skb->data_len += hlen;
@@ -2106,8 +2099,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 				    PCI_DMA_FROMDEVICE);
 		addr = cas_page_map(page->buffer);
 		memcpy(p, addr + off, i);
-		pci_dma_sync_single_for_device(cp->pdev, page->dma_addr + off, i,
-				    PCI_DMA_FROMDEVICE);
 		cas_page_unmap(addr);
 		if (p == (char *) skb->data) /* not split */
 			RX_USED_ADD(page, cp->mtu_stride);
@@ -2124,9 +2115,6 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
 					    PCI_DMA_FROMDEVICE);
 			addr = cas_page_map(page->buffer);
 			memcpy(p, addr, dlen + cp->crc_size);
-			pci_dma_sync_single_for_device(cp->pdev, page->dma_addr,
-					    dlen + cp->crc_size,
-					    PCI_DMA_FROMDEVICE);
 			cas_page_unmap(addr);
 			RX_USED_ADD(page, dlen + cp->crc_size);
 		}
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 76bf589..3196fdd 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -517,9 +517,6 @@ nomem:				q->alloc_failed++;
 			dma_unmap_addr_set(sd, dma_addr, mapping);
 
 			add_one_rx_chunk(mapping, d, q->gen);
-			pci_dma_sync_single_for_device(adap->pdev, mapping,
-						q->buf_size - SGE_PG_RSVD,
-						PCI_DMA_FROMDEVICE);
 		} else {
 			void *buf_start;
 
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index c1352c6..73034af 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1944,9 +1944,6 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 
 			if (ioread8(&nic->csr->scb.status) & rus_no_res)
 				nic->ru_running = RU_SUSPENDED;
-		pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr,
-					       sizeof(struct rfd),
-					       PCI_DMA_FROMDEVICE);
 		return -ENODATA;
 	}
 
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index ed7a93d..f9b16cf 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1172,12 +1172,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
 			 * very long
 			 */
 			dma_sync_single_for_cpu(&pdev->dev, ps_page->dma,
-						PAGE_SIZE, DMA_FROM_DEVICE);
+						l1, DMA_FROM_DEVICE);
 			vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ);
 			memcpy(skb_tail_pointer(skb), vaddr, l1);
 			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
-			dma_sync_single_for_device(&pdev->dev, ps_page->dma,
-						   PAGE_SIZE, DMA_FROM_DEVICE);
 
 			/* remove the CRC */
 			if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 5197b50..ee15295 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -483,8 +483,6 @@ static struct sk_buff *mlx4_en_rx_skb(struct mlx4_en_priv *priv,
 		dma_sync_single_for_cpu(&mdev->pdev->dev, dma, length,
 					DMA_FROM_DEVICE);
 		skb_copy_to_linear_data(skb, va, length);
-		dma_sync_single_for_device(&mdev->pdev->dev, dma, length,
-					   DMA_FROM_DEVICE);
 		skb->tail += length;
 	} else {
 
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 68fbfac..48dd59b 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -1195,9 +1195,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
 					rx_ring->lbq_buf_size);
 				*lbq_desc->addr = cpu_to_le64(map);
 
-			pci_dma_sync_single_for_device(qdev->pdev, map,
-						rx_ring->lbq_buf_size,
-						PCI_DMA_FROMDEVICE);
 			clean_idx++;
 			if (clean_idx == rx_ring->lbq_len)
 				clean_idx = 0;
@@ -1801,14 +1798,6 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
 						    PCI_DMA_FROMDEVICE);
 			memcpy(skb_put(skb, length),
 			       sbq_desc->p.skb->data, length);
-			pci_dma_sync_single_for_device(qdev->pdev,
-						       dma_unmap_addr
-						       (sbq_desc,
-							mapaddr),
-						       dma_unmap_len
-						       (sbq_desc,
-							maplen),
-						       PCI_DMA_FROMDEVICE);
 		} else {
 			netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev,
 				     "%d bytes in a single small buffer.\n",
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index ef1a43d..e2c2884 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -5005,7 +5005,6 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data,
 	skb = netdev_alloc_skb_ip_align(tp->dev, pkt_size);
 	if (skb)
 		memcpy(skb->data, data, pkt_size);
-	dma_sync_single_for_device(d, addr, pkt_size, DMA_FROM_DEVICE);
 
 	return skb;
 }
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 043850b..acf7105 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2636,11 +2636,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, struct ring_info *ring,
 				if (pci_dma_mapping_error(nic->pdev,
 							  rxdp3->Buffer0_ptr))
 					goto pci_map_failed;
-			} else
-				pci_dma_sync_single_for_device(ring->pdev,
-							       (dma_addr_t)rxdp3->Buffer0_ptr,
-							       BUF0_LEN,
-							       PCI_DMA_FROMDEVICE);
+			}
 
 			rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
 			if (ring->rxd_mode == RXD_MODE_3B) {
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 98ec614..11e5229 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -3031,9 +3031,6 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
 					    dma_unmap_addr(e, mapaddr),
 					    len, PCI_DMA_FROMDEVICE);
 		skb_copy_from_linear_data(e->skb, skb->data, len);
-		pci_dma_sync_single_for_device(skge->hw->pdev,
-					       dma_unmap_addr(e, mapaddr),
-					       len, PCI_DMA_FROMDEVICE);
 		skge_rx_reuse(e, skge->rx_buf_size);
 	} else {
 		struct sk_buff *nskb;
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 57339da..5f720b9 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -2422,8 +2422,6 @@ static struct sk_buff *receive_copy(struct sky2_port *sky2,
 		skb_copy_from_linear_data(re->skb, skb->data, length);
 		skb->ip_summed = re->skb->ip_summed;
 		skb->csum = re->skb->csum;
-		pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr,
-					       length, PCI_DMA_FROMDEVICE);
 		re->skb->ip_summed = CHECKSUM_NONE;
 		skb_put(skb, length);
 	}
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 8211b9a..b43d473 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -5002,7 +5002,6 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 			skb_put(copy_skb, len);
 			pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
 			skb_copy_from_linear_data(skb, copy_skb->data, len);
-			pci_dma_sync_single_for_device(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
 
 			/* We'll reuse the original ring buffer. */
 			skb = copy_skb;
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index e3855ae..30fb6e8 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -837,9 +837,6 @@ static void olympic_rx(struct net_device *dev)
 							skb_copy_from_linear_data(olympic_priv->rx_ring_skb[rx_ring_last_received],
 								      skb_put(skb,length - 4),
 								      length - 4);
-							pci_dma_sync_single_for_device(olympic_priv->pdev,
-								le32_to_cpu(olympic_priv->olympic_rx_ring[rx_ring_last_received].buffer),
-								olympic_priv->pkt_buf_sz,PCI_DMA_FROMDEVICE) ;
 							skb->protocol = tr_type_trans(skb,dev) ; 
 							netif_rx(skb) ; 
 						} 
@@ -856,9 +853,6 @@ static void olympic_rx(struct net_device *dev)
 							skb_copy_from_linear_data(olympic_priv->rx_ring_skb[rx_ring_last_received],
 								      skb_put(skb, cpy_length),
 								      cpy_length);
-							pci_dma_sync_single_for_device(olympic_priv->pdev,
-								le32_to_cpu(olympic_priv->olympic_rx_ring[rx_ring_last_received].buffer),
-								olympic_priv->pkt_buf_sz,PCI_DMA_FROMDEVICE) ;
 						} while (--i) ; 
 						skb_trim(skb,skb->len-4) ; 
 						skb->protocol = tr_type_trans(skb,dev);
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index 15d878b..00d435d 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -323,9 +323,6 @@ vxge_rx_complete(struct vxge_ring *ring, struct sk_buff *skb, u16 vlan,
 static inline void vxge_re_pre_post(void *dtr, struct vxge_ring *ring,
 				    struct vxge_rx_priv *rx_priv)
 {
-	pci_dma_sync_single_for_device(ring->pdev,
-		rx_priv->data_dma, rx_priv->data_size, PCI_DMA_FROMDEVICE);
-
 	vxge_hw_ring_rxd_1b_set(dtr, rx_priv->data_dma, rx_priv->data_size);
 	vxge_hw_ring_rxd_pre_post(ring->handle, dtr);
 }
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index c33934a..11839be 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -433,17 +433,6 @@ void sync_descbuffer_for_cpu(struct b43legacy_dmaring *ring,
 }
 
 static inline
-void sync_descbuffer_for_device(struct b43legacy_dmaring *ring,
-				dma_addr_t addr,
-				size_t len)
-{
-	B43legacy_WARN_ON(ring->tx);
-
-	dma_sync_single_for_device(ring->dev->dev->dma_dev,
-				   addr, len, DMA_FROM_DEVICE);
-}
-
-static inline
 void free_descriptor_buffer(struct b43legacy_dmaring *ring,
 			    struct b43legacy_dmadesc_meta *meta,
 			    int irq_context)
@@ -1556,8 +1545,6 @@ static void dma_rx(struct b43legacy_dmaring *ring,
 		}
 		b43legacy_handle_hwtxstatus(ring->dev, hw);
 		/* recycle the descriptor buffer. */
-		sync_descbuffer_for_device(ring, meta->dmaaddr,
-					   ring->rx_buffersize);
 
 		return;
 	}
@@ -1573,8 +1560,6 @@ static void dma_rx(struct b43legacy_dmaring *ring,
 		} while (len == 0 && i++ < 5);
 		if (unlikely(len == 0)) {
 			/* recycle the descriptor buffer. */
-			sync_descbuffer_for_device(ring, meta->dmaaddr,
-						   ring->rx_buffersize);
 			goto drop;
 		}
 	}
@@ -1590,8 +1575,6 @@ static void dma_rx(struct b43legacy_dmaring *ring,
 		while (1) {
 			desc = ops->idx2desc(ring, *slot, &meta);
 			/* recycle the descriptor buffer. */
-			sync_descbuffer_for_device(ring, meta->dmaaddr,
-						   ring->rx_buffersize);
 			*slot = next_slot(ring, *slot);
 			cnt++;
 			tmp -= ring->rx_buffersize;
@@ -1609,8 +1592,6 @@ static void dma_rx(struct b43legacy_dmaring *ring,
 	if (unlikely(err)) {
 		b43legacydbg(ring->dev->wl, "DMA RX: setup_rx_descbuffer()"
 			     " failed\n");
-		sync_descbuffer_for_device(ring, dmaaddr,
-					   ring->rx_buffersize);
 		goto drop;
 	}
 
-- 
1.7.5.4


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

^ permalink raw reply related

* [PATCH v2 07/46] net/wireless: ath9k: fix DMA API usage
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Luis R. Rodriguez, Jouni Malinen, Vasanthakumar Thiagarajan,
	Senthil Balasubramanian, linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ
In-Reply-To: <cover.1310339688.git.mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>

Also constify buf_addr for ath9k_hw_process_rxdesc_edma() to verify
assumptions --- dma_sync_single_for_device() call can be removed.

Signed-off-by: Michał Mirosław <mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>
---
 drivers/net/wireless/ath/ath9k/ar9003_mac.c |    4 ++--
 drivers/net/wireless/ath/ath9k/ar9003_mac.h |    2 +-
 drivers/net/wireless/ath/ath9k/recv.c       |   10 +++-------
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index 575e185..2d211b6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -524,9 +524,9 @@ void ath9k_hw_addrxbuf_edma(struct ath_hw *ah, u32 rxdp,
 EXPORT_SYMBOL(ath9k_hw_addrxbuf_edma);
 
 int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
-				 void *buf_addr)
+				 const void *buf_addr)
 {
-	struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr;
+	const struct ar9003_rxs *rxsp = buf_addr;
 	unsigned int phyerr;
 
 	/* TODO: byte swap on big endian for ar9300_10 */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.h b/drivers/net/wireless/ath/ath9k/ar9003_mac.h
index c504493..c310edc 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.h
@@ -114,7 +114,7 @@ void ath9k_hw_addrxbuf_edma(struct ath_hw *ah, u32 rxdp,
 
 int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah,
 				 struct ath_rx_status *rxs,
-				 void *buf_addr);
+				 const void *buf_addr);
 void ath9k_hw_reset_txstatus_ring(struct ath_hw *ah);
 void ath9k_hw_setup_statusring(struct ath_hw *ah, void *ts_start,
 			       u32 ts_paddr_start,
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 70dc8ec..c5f46d5 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -156,7 +156,7 @@ static bool ath_rx_edma_buf_link(struct ath_softc *sc,
 	ATH_RXBUF_RESET(bf);
 	memset(skb->data, 0, ah->caps.rx_status_len);
 	dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
-				ah->caps.rx_status_len, DMA_TO_DEVICE);
+				ah->caps.rx_status_len, DMA_BIDIRECTIONAL);
 
 	SKB_CB_ATHBUF(skb) = bf;
 	ath9k_hw_addrxbuf_edma(ah, bf->bf_buf_addr, qtype);
@@ -684,15 +684,11 @@ static bool ath_edma_get_buffers(struct ath_softc *sc,
 	BUG_ON(!bf);
 
 	dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
-				common->rx_bufsize, DMA_FROM_DEVICE);
+				common->rx_bufsize, DMA_BIDIRECTIONAL);
 
 	ret = ath9k_hw_process_rxdesc_edma(ah, NULL, skb->data);
-	if (ret == -EINPROGRESS) {
-		/*let device gain the buffer again*/
-		dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
-				common->rx_bufsize, DMA_FROM_DEVICE);
+	if (ret == -EINPROGRESS)
 		return false;
-	}
 
 	__skb_unlink(skb, &rx_edma->rx_fifo);
 	if (ret == -EINVAL) {
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH v2 04/46] net/wireless: p54: remove useless dma_sync_single_for_device(DMA_FROM_DEVICE)
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev; +Cc: Christian Lamparter, John W. Linville, linux-wireless
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

Also constify pointers used in frame parsers to verify assumptions.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/wireless/p54/p54pci.c |    2 --
 drivers/net/wireless/p54/txrx.c   |   22 +++++++++++-----------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 1b75317..4491d33 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -229,8 +229,6 @@ static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index,
 			desc->host_addr = cpu_to_le32(0);
 		} else {
 			skb_trim(skb, 0);
-			pci_dma_sync_single_for_device(priv->pdev, dma_addr,
-				priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
 			desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
 		}
 
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index 042842e..b7ecd89 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -325,7 +325,7 @@ static void p54_pspoll_workaround(struct p54_common *priv, struct sk_buff *skb)
 
 static int p54_rx_data(struct p54_common *priv, struct sk_buff *skb)
 {
-	struct p54_rx_data *hdr = (struct p54_rx_data *) skb->data;
+	const struct p54_rx_data *hdr = (void *)skb->data;
 	struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
 	u16 freq = le16_to_cpu(hdr->freq);
 	size_t header_len = sizeof(*hdr);
@@ -387,8 +387,8 @@ static int p54_rx_data(struct p54_common *priv, struct sk_buff *skb)
 
 static void p54_rx_frame_sent(struct p54_common *priv, struct sk_buff *skb)
 {
-	struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
-	struct p54_frame_sent *payload = (struct p54_frame_sent *) hdr->data;
+	const struct p54_hdr *hdr = (void *)skb->data;
+	const struct p54_frame_sent *payload = (void *)hdr->data;
 	struct ieee80211_tx_info *info;
 	struct p54_hdr *entry_hdr;
 	struct p54_tx_data *entry_data;
@@ -481,8 +481,8 @@ static void p54_rx_frame_sent(struct p54_common *priv, struct sk_buff *skb)
 static void p54_rx_eeprom_readback(struct p54_common *priv,
 				   struct sk_buff *skb)
 {
-	struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
-	struct p54_eeprom_lm86 *eeprom = (struct p54_eeprom_lm86 *) hdr->data;
+	const struct p54_hdr *hdr = (void *)skb->data;
+	const struct p54_eeprom_lm86 *eeprom = (void *)hdr->data;
 	struct sk_buff *tmp;
 
 	if (!priv->eeprom)
@@ -504,8 +504,8 @@ static void p54_rx_eeprom_readback(struct p54_common *priv,
 
 static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb)
 {
-	struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
-	struct p54_statistics *stats = (struct p54_statistics *) hdr->data;
+	const struct p54_hdr *hdr = (void *)skb->data;
+	const struct p54_statistics *stats = (void *)hdr->data;
 	struct sk_buff *tmp;
 	u32 tsf32;
 
@@ -529,8 +529,8 @@ static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb)
 
 static void p54_rx_trap(struct p54_common *priv, struct sk_buff *skb)
 {
-	struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
-	struct p54_trap *trap = (struct p54_trap *) hdr->data;
+	const struct p54_hdr *hdr = (void *)skb->data;
+	const struct p54_trap *trap = (void *)hdr->data;
 	u16 event = le16_to_cpu(trap->event);
 	u16 freq = le16_to_cpu(trap->frequency);
 
@@ -565,7 +565,7 @@ static void p54_rx_trap(struct p54_common *priv, struct sk_buff *skb)
 
 static int p54_rx_control(struct p54_common *priv, struct sk_buff *skb)
 {
-	struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
+	const struct p54_hdr *hdr = (void *)skb->data;
 
 	switch (le16_to_cpu(hdr->type)) {
 	case P54_CONTROL_TYPE_TXDONE:
@@ -595,7 +595,7 @@ static int p54_rx_control(struct p54_common *priv, struct sk_buff *skb)
 int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
 {
 	struct p54_common *priv = dev->priv;
-	u16 type = le16_to_cpu(*((__le16 *)skb->data));
+	u16 type = le16_to_cpu(*(const __le16 *)skb->data);
 
 	if (type & P54_HDR_FLAG_CONTROL)
 		return p54_rx_control(priv, skb);
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 02/46] net: wrap common patterns of rx handler code
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

Introduce dev_skb_finish_rx_dma() and dev_skb_finish_rx_dma_refill() ---
two common patterns for rx handling as seen in various network drivers
that implement rx_copybreak idea (copying smaller packets, passing larger
ones in original skb).

The common pattern (as implemented in dev_skb_finish_rx_dma()) is:

if (packet len < threshold)
       allocate new, smaller skb
       sync DMA buffer to cpu
       copy packet's data
       give DMA buffer back to device
       pass new skb
       reuse buffer in rx ring
else (or if skb alloc for copy failed)
       unmap DMA buffer
       pass skb
       remove buffer from rx ring
       [refill rx ring later]

This scheme is modified by some drivers to immediately refill rx slot before
passing original rx skb up the stack. Those drivers have also a problem that
they drop packets from the head of the queue when that allocation fails. This
forces unnecessary retransmits and can deadlock if the device is used for
swapping over network.  To mark this case, dev_skb_finish_rx_dma_refill()
implementing it, is marked as deprecated to encourage driver maintainers to
look into the matter.

Those functions are called from rx handler hot path and have a lot of arguments,
and so are inlined. This should allow compiler to better optimize the code with
calling code.

v2:
 - remove unnecessary dma_sync_single_for_device()
   [See: DMA-API.txt, part. Id, DMA_FROM_DEVICE description]
 - check dma_mapping_error() in dev_skb_finish_rx_dma_refill()
 - handle RX_OFFSET (padding inserted by hardware before packet's data)

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/skbuff.h |  142 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 142 insertions(+), 0 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c873897..bf51006 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -29,6 +29,7 @@
 #include <linux/rcupdate.h>
 #include <linux/dmaengine.h>
 #include <linux/hrtimer.h>
+#include <linux/dma-mapping.h>
 
 /* Don't change this without changing skb_csum_unnecessary! */
 #define CHECKSUM_NONE 0
@@ -2310,5 +2311,146 @@ static inline void skb_checksum_none_assert(struct sk_buff *skb)
 
 bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
 
+/**
+ * __dev_skb_finish_rx_dma - finish skb after DMA'd RX
+ * @skb: skb to finish
+ * @len: packet data length
+ * @copybreak: maximum packet size to copy
+ * @rx_offset: count of bytes prepended to packet's data by hardware
+ * @dma_dev: device used for DMA
+ * @dma_buf: DMA mapping address
+ * @dma_len: DMA mapping length
+ *
+ * This function finishes DMA mapping (sync for copied, unmap otherwise) for
+ * a packet and copies it to new skb if its size is at or below @copybreak
+ * threshold.
+ *
+ * Returns new skb or NULL if the copy wasn't made.
+ */
+static inline struct sk_buff *__dev_skb_finish_rx_dma(struct sk_buff *skb,
+	unsigned int len, unsigned int copybreak, unsigned int rx_offset,
+	struct device *dma_dev, dma_addr_t dma_buf, size_t dma_len)
+{
+	if (len < copybreak) {
+		struct sk_buff *skb2 = netdev_alloc_skb_ip_align(skb->dev, len);
+		if (likely(skb2)) {
+			dma_sync_single_for_cpu(dma_dev, dma_buf,
+				len + rx_offset, DMA_FROM_DEVICE);
+			skb_copy_to_linear_data(skb2, skb->data, len);
+			return skb2;
+		}
+	}
+
+	/* else or copy failed */
+
+	dma_unmap_single(dma_dev, dma_buf, dma_len, DMA_FROM_DEVICE);
+	return NULL;
+}
+
+/**
+ * dev_skb_finish_rx_dma - finish skb after DMA'd RX
+ * @pskb: pointer to variable holding skb to finish
+ * @len: packet data length
+ * @copybreak: maximum packet size to copy
+ * @rx_offset: count of bytes prepended to packet's data by hardware
+ * @dma_dev: device used for DMA
+ * @dma_buf: DMA mapping address
+ * @dma_len: DMA mapping length
+ *
+ * This function finishes DMA mapping (sync for copied, unmap otherwise) for
+ * a packet and copies it to new skb if its size is at or below @copybreak
+ * threshold.  Like __dev_skb_finish_rx_dma().
+ *
+ * Returns the skb - old or copied. *pskb is cleared if the skb wasn't copied.
+ */
+static inline struct sk_buff *dev_skb_finish_rx_dma(struct sk_buff **pskb,
+	unsigned int len, unsigned int copybreak, unsigned int rx_offset,
+	struct device *dma_dev, dma_addr_t dma_buf, size_t dma_len)
+{
+	struct sk_buff *skb2;
+
+	skb2 = __dev_skb_finish_rx_dma(*pskb, len, copybreak, rx_offset,
+		dma_dev, dma_buf, dma_len);
+
+	if (!skb2) {
+		/* not copied */
+		skb2 = *pskb;
+		*pskb = NULL;
+	}
+
+	skb_put(skb2, len);
+	return skb2;
+}
+
+/**
+ * dev_skb_finish_rx_dma_refill - finish skb after DMA'd RX and refill the slot
+ * @pskb: pointer to variable holding skb to finish
+ * @len: packet data length
+ * @copybreak: maximum packet size to copy
+ * @ip_align: new skb's alignment offset
+ * @rx_offset: count of bytes prepended by HW before packet's data
+ * @dma_dev: device used for DMA
+ * @dma_buf: DMA mapping address
+ * @dma_len: DMA mapping length
+ * @dma_align: required DMA buffer alignment for new skbs
+ *
+ * This function finishes DMA mapping (sync for copied, unmap otherwise) for
+ * a packet and copies it to new skb if its size is at or below @copybreak
+ * threshold.  Like __dev_skb_finish_rx_dma().
+ *
+ * *pskb is filled with new mapped skb if the skb wasn't copied.
+ * Returns the skb - old or copied, or NULL if refill failed.
+ *
+ * NOTE:
+ * This will effectively drop the packet in case of memory pressure. This
+ * might not be wanted when swapping over network. It's better to throttle
+ * the receiver queue (refill later) as the packet might be needed to
+ * reclaim some memory.
+ */
+static inline __deprecated struct sk_buff *dev_skb_finish_rx_dma_refill(
+	struct sk_buff **pskb, unsigned int len, unsigned int copybreak,
+	unsigned int ip_align, unsigned int rx_offset,
+	struct device *dma_dev, dma_addr_t *dma_buf, size_t dma_len,
+	size_t dma_align)
+{
+	struct sk_buff *skb;
+
+	skb = __dev_skb_finish_rx_dma(*pskb, len, copybreak, rx_offset,
+		dma_dev, *dma_buf, dma_len);
+
+	if (!skb) {
+		/* not copied */
+		skb = *pskb;
+		/* netdev_alloc_skb_ip_align() */
+		*pskb = __netdev_alloc_skb_aligned(skb->dev, dma_len + ip_align,
+			dma_align, GFP_ATOMIC);
+		if (likely(*pskb))
+			skb_reserve(*pskb, ip_align + rx_offset);
+		else {
+			/* no memory - drop packet */
+			*pskb = skb;
+			skb = NULL;
+		}
+
+		*dma_buf = dma_map_single(dma_dev, (*pskb)->data - rx_offset,
+			dma_len, DMA_FROM_DEVICE);
+		if (dma_mapping_error(dma_dev, *dma_buf)) {
+			BUG_ON(!skb);	/* caller can't handle this case */
+			kfree_skb(*pskb);
+			*pskb = skb;
+			skb = NULL;
+			*dma_buf = dma_map_single(dma_dev,
+				(*pskb)->data - rx_offset, dma_len,
+				DMA_FROM_DEVICE);
+			BUG_ON(dma_mapping_error(dma_dev, *dma_buf));
+		}
+	}
+
+	if (likely(skb))
+		skb_put(skb, len);
+
+	return skb;
+}
+
 #endif	/* __KERNEL__ */
 #endif	/* _LINUX_SKBUFF_H */
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 00/46] Clean up RX copybreak and DMA handling
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev

Quick rx_copybreak cleaning turned out to rise more dust around...

Most drivers use dma_sync_single_to_device() for buffers that are
written only by device. That's probably because of bad example in
current Documentation/DMA-API-HOWTO.txt. Why is it bad? It unnecessarily
flushes cachelines and CPU write buffers for memory that is not used
by the hardware. Documentation/DMA-API.txt (part Id) describes exactly
when streaming DMA buffers should be synced and in which direction.
Syncing DMA_FROM_DEVICE mappings for device is not among them.

A lot of drivers drop packets already DMA'd in on memory pressure. This
is suboptimal:
  1. under packet storm and memory pressure NIC keeps generating interrupts
     (if non-NAPI) and indicating new buffers because it always has free
     RX buffers --- this only wastes CPU and bus bandwidth transferring
     data that is going to be immediately discarded;
  2. for users of swap over network (NBD, NFS - assumming those get
     fixed, or maybe FCoE?) this can cause deadlock if the packets
     (acks maybe?) are needed to reclaim memory.

It unlikely that you'll ever hit the dark scenarios above, but if you do
you'll have a hard time debugging.

Menu:
 1..2:
	wrap code commonly used in drivers into generic functions
 3..4:
	remove dma_sync_to_device(DMA_FROM_DEVICE) from drivers not
	converted to common rx handling functions
 5..10:
	fix various DMA API usage bugs in rx handling code
 11..14:
	clean up rx buffer allocation in sun* drivers
 15:
	b43: use kfree_skb() if the skb is known not to have been used
 16:
	cxgb3: remove code dropping packets on memory pressure in driver
 46:
	mark some drivers that drop packets from rx queue head when under
	memory pressure

Left out for later:
 17..34:
	convert multiple drivers to common rx_copybreak handling
 35..45:
	convert multiple drivers to common rx_copybreak handling; those
	drivers drop rxed packets when under memory pressure

Patches 17..45 are more-or-less templated and in the same spirit as
the earlier version.
[davem: I plan send them after/if you agree to take patch 2. Or earlier,
if you want them all at once anyway.]

Best Regards,
Michał Mirosław

---

Michał Mirosław (46):
  net: introduce __netdev_alloc_skb_aligned()
  net: wrap common patterns of rx handler code
  net drivers: remove unnecessary dma_sync_to_device(DMA_FROM_DEVICE)
  net/wireless: p54: remove useless
    dma_sync_single_for_device(DMA_FROM_DEVICE)
  net: bnx2x: fix DMA sync direction
  net/tokenring: 3c359: fix DMA API usage
  net/wireless: ath9k: fix DMA API usage
  net/wireless: b43: fix DMA direction for RX buffers
  net: octeon_mgmt: fix DMA unmap size
  net: jme: convert to generic DMA API
  net: sungem: cleanup RX skb allocation
  net: sunhme: cleanup RX skb allocation
  net: sunbmac: cleanup RX skb allocation
  net: sunbmac: cleanup magic '34'
  net/wireless: b43: use kfree_skb() for untouched skbs
  net: cxgb3: don't drop packets on memory pressure in driver
  net: 3c59x: use common rx_copybreak handling
  net: epic100: use common rx_copybreak handling
  net: fealnx: use common rx_copybreak handling
  net: hamachi: use common rx_copybreak handling
  net: bcm63xx: use common rx_copybreak handling
  net: chelsio: use common rx_copybreak handling
  net: cxgb3: use common rx_copybreak handling
  net: dl2k: use common rx_copybreak handling
  net: natsemi: use common rx_copybreak handling
  net: sis190: use common rx_copybreak handling
  net: starfire: use common rx_copybreak handling
  net: sundance: use common rx_copybreak handling
  net: tulip/interrupt: use common rx_copybreak handling
  net: tulip/winbond-840: use common rx_copybreak handling
  net: typhoon: use common rx_copybreak handling
  net: via-rhine: use common rx_copybreak handling
  net: via-velocity: use common rx_copybreak handling
  net: yellowfin: use common rx_copybreak handling
  net: lib82596: use common rx_copybreak handling [strict refill!]
  net: pcnet32: use common rx_copybreak handling [strict refill!]
  net: sgiseeq: use common rx_copybreak handling [strict refill!]
  net: tulip/de2104x: use common rx_copybreak handling [strict refill!]
  net: sunhme: use common rx_copybreak handling [strict refill!]
  net: sunbmac: use common rx_copybreak handling [strict refill!]
  net: rrunner: use common rx_copybreak handling [strict refill!]
  net: greth: use common rx_copybreak handling [strict refill!]
  net: sunbmac: use common rx_copybreak handling [strict refill!]
  net: tokenring/3c359: use common rx_copybreak handling [strict
    refill!]
  net/wireless: adm8211: use common rx_copybreak handling [strict
    refill!]
  net: mark drivers that drop packets from rx queue head under memory
    pressure

 drivers/net/3c59x.c                         |   23 +---
 drivers/net/arm/ep93xx_eth.c                |    6 +-
 drivers/net/b44.c                           |    4 -
 drivers/net/bcm63xx_enet.c                  |   28 +----
 drivers/net/bnx2.c                          |    7 +-
 drivers/net/bnx2x/bnx2x_cmn.c               |    5 +-
 drivers/net/bnx2x/bnx2x_cmn.h               |    5 -
 drivers/net/bnx2x/bnx2x_ethtool.c           |    2 +-
 drivers/net/cassini.c                       |   15 +--
 drivers/net/chelsio/sge.c                   |   42 +------
 drivers/net/cxgb3/sge.c                     |   57 ++-------
 drivers/net/dl2k.c                          |   28 +----
 drivers/net/e100.c                          |    3 -
 drivers/net/e1000e/netdev.c                 |    4 +-
 drivers/net/epic100.c                       |   32 ++----
 drivers/net/fealnx.c                        |   40 ++-----
 drivers/net/greth.c                         |   67 ++++-------
 drivers/net/hamachi.c                       |   42 +------
 drivers/net/jme.c                           |   40 +++----
 drivers/net/lib82596.c                      |   70 +++--------
 drivers/net/mlx4/en_rx.c                    |    8 +-
 drivers/net/natsemi.c                       |   37 ++-----
 drivers/net/octeon/octeon_mgmt.c            |    9 +-
 drivers/net/pcnet32.c                       |   53 ++-------
 drivers/net/qlge/qlge_main.c                |   11 --
 drivers/net/r8169.c                         |    4 +-
 drivers/net/rrunner.c                       |   66 +++--------
 drivers/net/s2io.c                          |    6 +-
 drivers/net/sgiseeq.c                       |   42 +++-----
 drivers/net/sis190.c                        |   40 +------
 drivers/net/skge.c                          |    6 +-
 drivers/net/sky2.c                          |    4 +-
 drivers/net/starfire.c                      |   28 ++---
 drivers/net/sunbmac.c                       |   78 +++----------
 drivers/net/sunbmac.h                       |   18 +---
 drivers/net/sundance.c                      |   26 +---
 drivers/net/sungem.c                        |   84 +++----------
 drivers/net/sungem.h                        |    4 +-
 drivers/net/sunhme.c                        |   61 ++--------
 drivers/net/sunhme.h                        |   14 +--
 drivers/net/tg3.c                           |    3 +-
 drivers/net/tokenring/3c359.c               |   74 ++++++------
 drivers/net/tokenring/3c359.h               |    4 +-
 drivers/net/tokenring/olympic.c             |    8 +-
 drivers/net/tulip/de2104x.c                 |   39 ++-----
 drivers/net/tulip/interrupt.c               |   77 +++----------
 drivers/net/tulip/winbond-840.c             |   28 +----
 drivers/net/typhoon.c                       |   26 +---
 drivers/net/via-rhine.c                     |   38 +-----
 drivers/net/via-velocity.c                  |   61 ++--------
 drivers/net/vxge/vxge-main.c                |    6 +-
 drivers/net/wireless/adm8211.c              |   41 +------
 drivers/net/wireless/ath/ath9k/ar9003_mac.c |    4 +-
 drivers/net/wireless/ath/ath9k/ar9003_mac.h |    2 +-
 drivers/net/wireless/ath/ath9k/recv.c       |   10 +-
 drivers/net/wireless/b43/dma.c              |   15 ++-
 drivers/net/wireless/b43legacy/dma.c        |   19 ---
 drivers/net/wireless/p54/p54pci.c           |    2 -
 drivers/net/wireless/p54/txrx.c             |   22 ++--
 drivers/net/yellowfin.c                     |   27 +----
 include/linux/skbuff.h                      |  169 +++++++++++++++++++++++++++
 61 files changed, 586 insertions(+), 1208 deletions(-)

-- 
1.7.5.4


^ permalink raw reply

* [PATCH v2 01/46] net: introduce __netdev_alloc_skb_aligned()
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

Introduce __netdev_alloc_skb_aligned() to return skb with skb->data
aligned at specified 2^n multiple.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/skbuff.h |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 32ada53..c873897 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1561,6 +1561,33 @@ extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
 		unsigned int length, gfp_t gfp_mask);
 
 /**
+ *	__netdev_alloc_skb_aligned - allocate an skbuff for rx on a specific device
+ *	@dev: network device to receive on
+ *	@length: length to allocate
+ *	@align: required skb->data alignment
+ *	@gfp_mask: get_free_pages mask, passed to alloc_skb
+ *
+ *	Allocate a new &sk_buff and assign it a usage count of one. The
+ *	buffer has unspecified headroom built in. Users should allocate
+ *	the headroom they think they need without accounting for the
+ *	built in space. The built in space is used for optimisations.
+ *
+ *	%NULL is returned if there is no free memory.
+ */
+static inline struct sk_buff *__netdev_alloc_skb_aligned(struct net_device *dev,
+		unsigned int length, unsigned int align, gfp_t gfp_mask)
+{
+	struct sk_buff *skb;
+
+	skb = __alloc_skb(length + NET_SKB_PAD + align, gfp_mask, 0, NUMA_NO_NODE);
+	if (likely(skb)) {
+		skb_reserve(skb, PTR_ALIGN(skb->data + NET_SKB_PAD, align) - skb->data);
+		skb->dev = dev;
+	}
+	return skb;
+}
+
+/**
  *	netdev_alloc_skb - allocate an skbuff for rx on a specific device
  *	@dev: network device to receive on
  *	@length: length to allocate
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 08/46] net/wireless: b43: fix DMA direction for RX buffers
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev; +Cc: Stefano Brivio, linux-wireless
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/wireless/b43/dma.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 7a09a46..15b11f0 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -336,8 +336,9 @@ static inline
 		dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
 					 buf, len, DMA_TO_DEVICE);
 	} else {
+		/* DMA_BIDIRECTIONAL because of b43_poison_rx_buffer() */
 		dmaaddr = dma_map_single(ring->dev->dev->dma_dev,
-					 buf, len, DMA_FROM_DEVICE);
+					 buf, len, DMA_BIDIRECTIONAL);
 	}
 
 	return dmaaddr;
@@ -352,7 +353,7 @@ static inline
 				 addr, len, DMA_TO_DEVICE);
 	} else {
 		dma_unmap_single(ring->dev->dev->dma_dev,
-				 addr, len, DMA_FROM_DEVICE);
+				 addr, len, DMA_BIDIRECTIONAL);
 	}
 }
 
@@ -362,7 +363,7 @@ static inline
 {
 	B43_WARN_ON(ring->tx);
 	dma_sync_single_for_cpu(ring->dev->dev->dma_dev,
-				    addr, len, DMA_FROM_DEVICE);
+				    addr, len, DMA_BIDIRECTIONAL);
 }
 
 static inline
@@ -371,7 +372,7 @@ static inline
 {
 	B43_WARN_ON(ring->tx);
 	dma_sync_single_for_device(ring->dev->dev->dma_dev,
-				   addr, len, DMA_FROM_DEVICE);
+				   addr, len, DMA_BIDIRECTIONAL);
 }
 
 static inline
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 06/46] net/tokenring: 3c359: fix DMA API usage
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

TX/RX rings should be allocated from DMA coherent memory (driver does
not sync the descriptors in any way).

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/tokenring/3c359.c |   49 +++++++++++++++++++++++++----------------
 drivers/net/tokenring/3c359.h |    4 +-
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index b6162fe..d321640 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -672,21 +672,25 @@ static int xl_open(struct net_device *dev)
 	 * Now to set up the Rx and Tx buffer structures
 	 */
 	/* These MUST be on 8 byte boundaries */
-	xl_priv->xl_tx_ring = kzalloc((sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE) + 7, GFP_DMA | GFP_KERNEL);
+	xl_priv->xl_tx_ring = dma_alloc_coherent(&xl_priv->pdev->dev,
+		sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE,
+		&xl_priv->tx_ring_dma_addr, GFP_KERNEL);
 	if (xl_priv->xl_tx_ring == NULL) {
 		printk(KERN_WARNING "%s: Not enough memory to allocate tx buffers.\n",
 				     dev->name);
-		free_irq(dev->irq,dev);
-		return -ENOMEM;
+		goto err_free_irq;
 	}
-	xl_priv->xl_rx_ring = kzalloc((sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE) +7, GFP_DMA | GFP_KERNEL);
+	xl_priv->xl_rx_ring = dma_alloc_coherent(&xl_priv->pdev->dev,
+		sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE,
+		&xl_priv->rx_ring_dma_addr, GFP_KERNEL);
 	if (xl_priv->xl_rx_ring == NULL) {
 		printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers.\n",
 				     dev->name);
-		free_irq(dev->irq,dev);
-		kfree(xl_priv->xl_tx_ring);
-		return -ENOMEM;
+		goto err_free_tx;
 	}
+	/* dma_alloc_coherent() should provide for the following */
+	BUG_ON(!IS_ALIGNED((unsigned long)xl_priv->xl_tx_ring, 8));
+	BUG_ON(!IS_ALIGNED((unsigned long)xl_priv->xl_rx_ring, 8));
 
 	 /* Setup Rx Ring */
 	 for (i=0 ; i < XL_RX_RING_SIZE ; i++) { 
@@ -704,10 +708,7 @@ static int xl_open(struct net_device *dev)
 
 	if (i==0) { 
 		printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers. Adapter disabled\n",dev->name);
-		free_irq(dev->irq,dev) ; 
-		kfree(xl_priv->xl_tx_ring);
-		kfree(xl_priv->xl_rx_ring);
-		return -EIO ; 
+		goto err_free_rxtx;
 	} 
 
 	xl_priv->rx_ring_no = i ; 
@@ -722,8 +723,6 @@ static int xl_open(struct net_device *dev)
 	
 	/* Setup Tx Ring */
 	
-	xl_priv->tx_ring_dma_addr = pci_map_single(xl_priv->pdev,xl_priv->xl_tx_ring, sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE,PCI_DMA_TODEVICE) ; 
-	
 	xl_priv->tx_ring_head = 1 ; 
 	xl_priv->tx_ring_tail = 255 ; /* Special marker for first packet */
 	xl_priv->free_ring_entries = XL_TX_RING_SIZE ; 
@@ -752,7 +751,18 @@ static int xl_open(struct net_device *dev)
 
 	netif_start_queue(dev) ; 	
 	return 0;
-	
+
+err_free_rxtx:
+	dma_free_coherent(&xl_priv->pdev->dev,
+		sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE,
+		xl_priv->xl_rx_ring, xl_priv->rx_ring_dma_addr);
+err_free_tx:
+	dma_free_coherent(&xl_priv->pdev->dev,
+		sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE,
+		xl_priv->xl_tx_ring, xl_priv->tx_ring_dma_addr);
+err_free_irq:
+	free_irq(dev->irq,dev);
+	return -ENOMEM;
 }	
 
 static int xl_open_hw(struct net_device *dev) 
@@ -1060,12 +1070,13 @@ static void xl_freemem(struct net_device *dev)
 	} 
 
 	/* unmap ring */
-	pci_unmap_single(xl_priv->pdev,xl_priv->rx_ring_dma_addr, sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE, PCI_DMA_FROMDEVICE) ; 
-	
-	pci_unmap_single(xl_priv->pdev,xl_priv->tx_ring_dma_addr, sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE, PCI_DMA_TODEVICE) ; 
+	dma_free_coherent(&xl_priv->pdev->dev,
+		sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE,
+		xl_priv->xl_rx_ring, xl_priv->rx_ring_dma_addr);
 
-	kfree(xl_priv->xl_rx_ring) ; 
-	kfree(xl_priv->xl_tx_ring) ; 
+	dma_free_coherent(&xl_priv->pdev->dev,
+		sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE,
+		xl_priv->xl_tx_ring, xl_priv->tx_ring_dma_addr);
 
 	return  ; 
 }
diff --git a/drivers/net/tokenring/3c359.h b/drivers/net/tokenring/3c359.h
index bcb1a6b..baefdd3 100644
--- a/drivers/net/tokenring/3c359.h
+++ b/drivers/net/tokenring/3c359.h
@@ -282,8 +282,8 @@ struct xl_private {
 	unsigned char xl_functional_addr[4] ; 
 	u16 xl_addr_table_addr, xl_parms_addr ; 
 	u8 xl_laa[6] ; 
-	u32 rx_ring_dma_addr ; 
-	u32 tx_ring_dma_addr ; 
+	dma_addr_t rx_ring_dma_addr;
+	dma_addr_t tx_ring_dma_addr;
 
 	/* firmware section */
 	const struct firmware *fw;
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 05/46] net: bnx2x: fix DMA sync direction
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev; +Cc: Eilon Greenstein
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/bnx2x/bnx2x_cmn.c     |    2 +-
 drivers/net/bnx2x/bnx2x_ethtool.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index bb75560..4f9164c 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -658,7 +658,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
 			/* non TPA */
 			len = le16_to_cpu(cqe_fp->pkt_len);
 			pad = cqe_fp->placement_offset;
-			dma_sync_single_for_device(&bp->pdev->dev,
+			dma_sync_single_for_cpu(&bp->pdev->dev,
 					dma_unmap_addr(rx_buf, mapping),
 						       pad + RX_COPY_THRESH,
 						       DMA_FROM_DEVICE);
diff --git a/drivers/net/bnx2x/bnx2x_ethtool.c b/drivers/net/bnx2x/bnx2x_ethtool.c
index 1a3ed41..9a98b83 100644
--- a/drivers/net/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/bnx2x/bnx2x_ethtool.c
@@ -1751,7 +1751,7 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode)
 		goto test_loopback_rx_exit;
 
 	rx_buf = &fp_rx->rx_buf_ring[RX_BD(fp_rx->rx_bd_cons)];
-	dma_sync_single_for_device(&bp->pdev->dev,
+	dma_sync_single_for_cpu(&bp->pdev->dev,
 				   dma_unmap_addr(rx_buf, mapping),
 				   fp_rx->rx_buf_size, DMA_FROM_DEVICE);
 	skb = rx_buf->skb;
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 10/46] net: jme: convert to generic DMA API
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev; +Cc: Guo-Fu Tseng
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

This also fixes bad pci_dma_map_page() usage and missing RX unmaps.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/jme.c |   37 ++++++++++++-------------------------
 1 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 6b2a5e7..ad69dae 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -759,11 +759,8 @@ jme_make_new_rx_buf(struct jme_adapter *jme, int i)
 
 	rxbi->skb = skb;
 	rxbi->len = skb_tailroom(skb);
-	rxbi->mapping = pci_map_page(jme->pdev,
-					virt_to_page(skb->data),
-					offset_in_page(skb->data),
-					rxbi->len,
-					PCI_DMA_FROMDEVICE);
+	rxbi->mapping = dma_map_single(&jme->pdev->dev, skb->data,
+					rxbi->len, DMA_FROM_DEVICE);
 
 	return 0;
 }
@@ -776,10 +773,10 @@ jme_free_rx_buf(struct jme_adapter *jme, int i)
 	rxbi += i;
 
 	if (rxbi->skb) {
-		pci_unmap_page(jme->pdev,
+		dma_unmap_single(&jme->pdev->dev,
 				 rxbi->mapping,
 				 rxbi->len,
-				 PCI_DMA_FROMDEVICE);
+				 DMA_FROM_DEVICE);
 		dev_kfree_skb(rxbi->skb);
 		rxbi->skb = NULL;
 		rxbi->mapping = 0;
@@ -1022,17 +1019,12 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
 	rxbi += idx;
 
 	skb = rxbi->skb;
-	pci_dma_sync_single_for_cpu(jme->pdev,
-					rxbi->mapping,
-					rxbi->len,
-					PCI_DMA_FROMDEVICE);
+	dma_unmap_single(&jme->pdev->dev, rxbi->mapping, rxbi->len,
+			 DMA_FROM_DEVICE);
 
 	if (unlikely(jme_make_new_rx_buf(jme, idx))) {
-		pci_dma_sync_single_for_device(jme->pdev,
-						rxbi->mapping,
-						rxbi->len,
-						PCI_DMA_FROMDEVICE);
-
+		rxbi->mapping = dma_map_single(&jme->pdev->dev, skb->data,
+						rxbi->len, DMA_FROM_DEVICE);
 		++(NET_STAT(jme).rx_dropped);
 	} else {
 		framesize = le16_to_cpu(rxdesc->descwb.framesize)
@@ -1476,10 +1468,10 @@ jme_tx_clean_tasklet(unsigned long arg)
 				ttxbi = txbi + ((i + j) & (mask));
 				txdesc[(i + j) & (mask)].dw[0] = 0;
 
-				pci_unmap_page(jme->pdev,
+				dma_unmap_page(&jme->pdev->dev,
 						 ttxbi->mapping,
 						 ttxbi->len,
-						 PCI_DMA_TODEVICE);
+						 DMA_TO_DEVICE);
 
 				ttxbi->mapping = 0;
 				ttxbi->len = 0;
@@ -1883,16 +1875,11 @@ jme_fill_tx_map(struct pci_dev *pdev,
 {
 	dma_addr_t dmaaddr;
 
-	dmaaddr = pci_map_page(pdev,
+	dmaaddr = dma_map_page(&pdev->dev,
 				page,
 				page_offset,
 				len,
-				PCI_DMA_TODEVICE);
-
-	pci_dma_sync_single_for_device(pdev,
-				       dmaaddr,
-				       len,
-				       PCI_DMA_TODEVICE);
+				DMA_TO_DEVICE);
 
 	txdesc->dw[0] = 0;
 	txdesc->dw[1] = 0;
-- 
1.7.5.4


^ permalink raw reply related

* [PATCH v2 09/46] net: octeon_mgmt: fix DMA unmap size
From: Michał Mirosław @ 2011-07-11  0:52 UTC (permalink / raw)
  To: netdev
In-Reply-To: <cover.1310339688.git.mirq-linux@rere.qmqm.pl>

Also: use netdev_alloc_skb_ip_align() for readability.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/octeon/octeon_mgmt.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
index 429e08c..dd4a57a 100644
--- a/drivers/net/octeon/octeon_mgmt.c
+++ b/drivers/net/octeon/octeon_mgmt.c
@@ -152,16 +152,15 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
 		struct sk_buff *skb;
 
 		/* CN56XX pass 1 needs 8 bytes of padding.  */
-		size = netdev->mtu + OCTEON_MGMT_RX_HEADROOM + 8 + NET_IP_ALIGN;
+		size = netdev->mtu + OCTEON_MGMT_RX_HEADROOM + 8;
 
-		skb = netdev_alloc_skb(netdev, size);
+		skb = netdev_alloc_skb_ip_align(netdev, size);
 		if (!skb)
 			break;
-		skb_reserve(skb, NET_IP_ALIGN);
 		__skb_queue_tail(&p->rx_list, skb);
 
 		re.d64 = 0;
-		re.s.len = size;
+		re.s.len = size = skb_tailroom(skb);
 		re.s.addr = dma_map_single(p->dev, skb->data,
 					   size,
 					   DMA_FROM_DEVICE);
@@ -297,7 +296,7 @@ static u64 octeon_mgmt_dequeue_rx_buffer(struct octeon_mgmt *p,
 	*pskb = __skb_dequeue(&p->rx_list);
 
 	dma_unmap_single(p->dev, re.s.addr,
-			 ETH_FRAME_LEN + OCTEON_MGMT_RX_HEADROOM,
+			 skb_tailroom(*pskb),
 			 DMA_FROM_DEVICE);
 
 	return re.d64;
-- 
1.7.5.4


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox