]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/Documentation/networking/can.txt
Fix common misspellings
[socketcan-devel.git] / kernel / 2.6 / Documentation / networking / can.txt
index 715b44d28639c27f0407f8ad50008ce9eab5552e..e74386efef56bcece1dae45d9fbc9ea4e0735591 100644 (file)
@@ -12,7 +12,7 @@ This file contains
 
   3 Socket CAN concept
     3.1 receive lists
-    3.2 loopback
+    3.2 local loopback of sent frames
     3.3 network security issues (capabilities)
     3.4 network problem notifications
 
@@ -22,23 +22,31 @@ This file contains
       4.1.2 RAW socket option CAN_RAW_ERR_FILTER
       4.1.3 RAW socket option CAN_RAW_LOOPBACK
       4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS
+      4.1.5 RAW socket returned message flags
     4.2 Broadcast Manager protocol sockets (SOCK_DGRAM)
     4.3 connected transport protocols (SOCK_SEQPACKET)
     4.4 unconnected transport protocols (SOCK_DGRAM)
+    4.5 Timestamps
 
   5 Socket CAN core module
-    5.1 can.ko module params 
+    5.1 can.ko module params
     5.2 procfs content
     5.3 writing own CAN protocol modules
 
   6 CAN network drivers
     6.1 general settings
-    6.2 loopback
+    6.2 local loopback of sent frames
     6.3 CAN controller hardware filters
-    6.4 currently supported CAN hardware
-    6.5 todo
+    6.4 The virtual CAN driver (vcan)
+    6.5 The CAN network device driver interface
+      6.5.1 Netlink interface to set/get devices properties
+      6.5.2 Setting the CAN bit-timing
+      6.5.3 Starting and stopping the CAN network device
+    6.6 supported CAN hardware
 
-  7 Credits
+  7 Socket CAN resources
+
+  8 Credits
 
 ============================================================================
 
@@ -47,7 +55,7 @@ This file contains
 
 The socketcan package is an implementation of CAN protocols
 (Controller Area Network) for Linux.  CAN is a networking technology
-which has wide-spread use in automation, embedded devices, and
+which has widespread use in automation, embedded devices, and
 automotive fields.  While there have been other CAN implementations
 for Linux based on character devices, Socket CAN uses the Berkeley
 socket API, the Linux network stack and implements the CAN device
@@ -77,15 +85,15 @@ new driver's API.
 Socket CAN was designed to overcome all of these limitations.  A new
 protocol family has been implemented which provides a socket interface
 to user space applications and which builds upon the Linux network
-layer, so to use all of the provided queueing functionality.  Device
-drivers for CAN controller hardware register itself with the Linux
+layer, so to use all of the provided queueing functionality.  A device
+driver for CAN controller hardware registers itself with the Linux
 network layer as a network device, so that CAN frames from the
 controller can be passed up to the network layer and on to the CAN
 protocol family module and also vice-versa.  Also, the protocol family
 module provides an API for transport protocol modules to register, so
 that any number of transport protocols can be loaded or unloaded
 dynamically.  In fact, the can core module alone does not provide any
-protocol and can not be used without loading at least one additional
+protocol and cannot be used without loading at least one additional
 protocol module.  Multiple sockets can be opened at the same time,
 on different or the same protocol module and they can listen/send
 frames on different or the same CAN IDs.  Several sockets listening on
@@ -97,7 +105,7 @@ write application data byte streams, without having to deal with
 CAN-IDs, frames, etc.
 
 Similar functionality visible from user-space could be provided by a
-character decive, too, but this would lead to a technically inelegant
+character device, too, but this would lead to a technically inelegant
 solution for a couple of reasons:
 
 * Intricate usage.  Instead of passing a protocol argument to
@@ -111,7 +119,7 @@ solution for a couple of reasons:
 * Abstraction.  In most existing character-device implementations, the
   hardware-specific device driver for a CAN controller directly
   provides the character device for the application to work with.
-  This is at least very unusual in Unix systems, for both, char and
+  This is at least very unusual in Unix systems for both, char and
   block devices.  For example you don't have a character device for a
   certain UART of a serial interface, a certain sound chip in your
   computer, a SCSI or IDE controller providing access to your hard
@@ -123,12 +131,12 @@ solution for a couple of reasons:
   and IDE subsystems for the devices mentioned above.
 
   The easiest way to implement a CAN device driver is as a character
-  without such a (complete) abstraction layer, as is done by most
+  device without such a (complete) abstraction layer, as is done by most
   existing drivers.  The right way, however, would be to add such a
   layer with all the functionality like registering for certain CAN
-  IDs, supporting several open file descriptors and (de)multplexing
+  IDs, supporting several open file descriptors and (de)multiplexing
   CAN frames between them, (sophisticated) queueing of CAN frames, and
-  providing an API for device driver to register with.  However, then
+  providing an API for device drivers to register with.  However, then
   it would be no more difficult, or may be even easier, to use the
   networking framework provided by the Linux kernel, and this is what
   Socket CAN does.
@@ -141,18 +149,18 @@ solution for a couple of reasons:
 
   As described in chapter 2 it is the main goal of Socket CAN to
   provide a socket interface to user space applications which builds
-  upon the Linux networklayer. In opposite to the commonly known
-  TCP/IP and ethernet networking the CAN bus is a broadcast-only(!)
-  medium that has no MAC-layer adressing like ethernet. The CAN-identifier
+  upon the Linux network layer. In contrast to the commonly known
+  TCP/IP and ethernet networking, the CAN bus is a broadcast-only(!)
+  medium that has no MAC-layer addressing like ethernet. The CAN-identifier
   (can_id) is used for arbitration on the CAN-bus. Therefore the CAN-IDs
-  have to be choosen unique on the bus. When designing a CAN-ECU
-  network the CAN-IDs are mapped to be sent by a specific ECU. 
-  For this reason a CAN-ID can be treatened best as a kind of source address. 
+  have to be chosen uniquely on the bus. When designing a CAN-ECU
+  network the CAN-IDs are mapped to be sent by a specific ECU.
+  For this reason a CAN-ID can be treated best as a kind of source address.
 
   3.1 receive lists
 
   The network transparent access of multiple applications leads to the
-  problem that different applications may be interrested in the same
+  problem that different applications may be interested in the same
   CAN-IDs from the same CAN network interface. The Socket CAN core
   module - which implements the protocol family CAN - provides several
   high efficient receive lists for this reason. If e.g. a user space
@@ -164,39 +172,40 @@ solution for a couple of reasons:
   CAN protocol modules by the SocketCAN core (see chapter 5).
   To optimize the CPU usage at runtime the receive lists are split up
   into several specific lists per device that match the requested
-  filter complexity for a given use-case. 
+  filter complexity for a given use-case.
 
-  3.2 loopback
+  3.2 local loopback of sent frames
 
   As known from other networking concepts the data exchanging
   applications may run on the same or different nodes without any
-  change (except if the according addressing information):
+  change (except for the according addressing information):
 
-         ___   ___   ___                   _______   ___ 
-        | _ | | _ | | _ |                 | _   _ | | _ | 
-        ||A|| ||B|| ||C||                 ||A| |B|| ||C|| 
-        |___| |___| |___|                 |_______| |___| 
+         ___   ___   ___                   _______   ___
+        | _ | | _ | | _ |                 | _   _ | | _ |
+        ||A|| ||B|| ||C||                 ||A| |B|| ||C||
+        |___| |___| |___|                 |_______| |___|
           |     |     |                       |       |
         -----------------(1)- CAN bus -(2)---------------
 
   To ensure that application A receives the same information in the
-  expample (2) as it would receive in example (1) there is need for
-  some kind of local loopback on the appropriate node. 
+  example (2) as it would receive in example (1) there is need for
+  some kind of local loopback of the sent CAN frames on the appropriate
+  node.
 
   The Linux network devices (by default) just can handle the
-  transmission and receiption of media dependend frames. Due to the
-  arbritration on the CAN bus the transmission of a low prio CAN-ID
-  may be delayed from the receipition of a high prio CAN frame. To
+  transmission and reception of media dependent frames. Due to the
+  arbitration on the CAN bus the transmission of a low prio CAN-ID
+  may be delayed by the reception of a high prio CAN frame. To
   reflect the correct* traffic on the node the loopback of the sent
   data has to be performed right after a successful transmission. If
-  the CAN network interface is not capable to perform the loopback for
-  some reason the SocketCAN core can do this task as a fallback solution.    
+  the CAN network interface is not capable of performing the loopback for
+  some reason the SocketCAN core can do this task as a fallback solution.
   See chapter 6.2 for details (recommended).
 
   The loopback functionality is enabled by default to reflect standard
   networking behaviour for CAN applications. Due to some requests from
   the RT-SocketCAN group the loopback optionally may be disabled for each
-  seperate socket. See sockopts from the CAN RAW sockets in chapter 4.1 .
+  separate socket. See sockopts from the CAN RAW sockets in chapter 4.1.
 
   * = you really like to have this when you're running analyser tools
       like 'candump' or 'cansniffer' on the (same) node.
@@ -213,7 +222,7 @@ solution for a couple of reasons:
   security of others networks to allow all users to access the CAN.
   To enable non-root users to access CAN_RAW and CAN_BCM protocol
   sockets the Kconfig options CAN_RAW_USER and/or CAN_BCM_USER may be
-  selected at kernel compile time. 
+  selected at kernel compile time.
 
   3.4 network problem notifications
 
@@ -222,16 +231,18 @@ solution for a couple of reasons:
   layer problems is a vital requirement for CAN users to identify
   hardware issues on the physical transceiver layer as well as
   arbitration problems and error frames caused by the different
-  ECUs. The occurance of detected errors are important for diagnosis
+  ECUs. The occurrence of detected errors are important for diagnosis
   and have to be logged together with the exact timestamp. For this
   reason the CAN interface driver can generate so called Error Frames
-  that can optionally be passed to the user application on the same
-  way like other CAN frames. Whenever an error on the physical layer
+  that can optionally be passed to the user application in the same
+  way as other CAN frames. Whenever an error on the physical layer
   or the MAC layer is detected (e.g. by the CAN controller) the driver
   creates an appropriate error frame. Error frames can be requested by
   the user application using the common CAN filter mechanisms. Inside
-  this filter definition the (interrested) type of errors may be
-  selected. The receiption of error frames is disabled by default.
+  this filter definition the (interested) type of errors may be
+  selected. The reception of error frames is disabled by default.
+  The format of the CAN error frame is briefly described in the Linux
+  header file "include/linux/can/error.h".
 
 4. How to use Socket CAN
 ------------------------
@@ -251,7 +262,7 @@ solution for a couple of reasons:
 
   respectively.  After the successful creation of the socket, you would
   normally use the bind(2) system call to bind the socket to a CAN
-  interface (which is different to TCP/IP due to different addressing
+  interface (which is different from TCP/IP due to different addressing
   - see chapter 3). After binding (CAN_RAW) or connecting (CAN_BCM)
   the socket, you can read(2) and write(2) from/to the socket or use
   send(2), sendto(2), sendmsg(2) and the recv* counterpart operations
@@ -273,22 +284,21 @@ solution for a couple of reasons:
   default. A read(2) system call on a CAN_RAW socket transfers a
   struct can_frame to the user space.
 
-  The sockaddr_can structure has an interface index analogue to the
+  The sockaddr_can structure has an interface index like the
   PF_PACKET socket, that also binds to a specific interface:
 
     struct sockaddr_can {
             sa_family_t can_family;
             int         can_ifindex;
             union {
-                    struct { canid_t rx_id, tx_id; } tp16;
-                    struct { canid_t rx_id, tx_id; } tp20;
-                    struct { canid_t rx_id, tx_id; } mcnet;
-                    struct { canid_t rx_id, tx_id; } isotp;
-                    struct { int     lcu,   type;  } bap;
+                    /* transport protocol class address info (e.g. ISOTP) */
+                    struct { canid_t rx_id, tx_id; } tp;
+
+                    /* reserved for future CAN protocols address information */
             } can_addr;
     };
 
-  To determine the interface index the an appropriate ioctl() has to
+  To determine the interface index an appropriate ioctl() has to
   be used (example for CAN_RAW sockets without error checking):
 
     int s;
@@ -307,28 +317,26 @@ solution for a couple of reasons:
 
     (..)
 
-  To bind a socket to all(!) CAN interfaces the interface index might
+  To bind a socket to all(!) CAN interfaces the interface index must
   be 0 (zero). In this case the socket receives CAN frames from every
   enabled CAN interface. To determine the originating CAN interface
   the system call recvfrom(2) may be used instead of read(2). To send
   on a socket that is bound to 'any' interface sendto(2) is needed to
   specify the outgoing interface.
 
-  4.1 RAW protocol sockets with can_filters (SOCK_RAW)
-
   Reading CAN frames from a bound CAN_RAW socket (see above) consists
   of reading a struct can_frame:
 
     struct can_frame frame;
 
     nbytes = read(s, &frame, sizeof(struct can_frame));
-  
+
     if (nbytes < 0) {
             perror("can raw socket read");
             return 1;
     }
 
-    /* paraniod check ... */
+    /* paranoid check ... */
     if (nbytes < sizeof(struct can_frame)) {
             fprintf(stderr, "read: incomplete CAN frame\n");
             return 1;
@@ -336,19 +344,171 @@ solution for a couple of reasons:
 
     /* do something with the received CAN frame */
 
-  Writing CAN frames can be done analogue with the write(2) system call:
+  Writing CAN frames can be done similarly, with the write(2) system call:
 
     nbytes = write(s, &frame, sizeof(struct can_frame));
 
+  When the CAN interface is bound to 'any' existing CAN interface
+  (addr.can_ifindex = 0) it is recommended to use recvfrom(2) if the
+  information about the originating CAN interface is needed:
+
+    struct sockaddr_can addr;
+    struct ifreq ifr;
+    socklen_t len = sizeof(addr);
+    struct can_frame frame;
+
+    nbytes = recvfrom(s, &frame, sizeof(struct can_frame),
+                      0, (struct sockaddr*)&addr, &len);
+
+    /* get interface name of the received CAN frame */
+    ifr.ifr_ifindex = addr.can_ifindex;
+    ioctl(s, SIOCGIFNAME, &ifr);
+    printf("Received a CAN frame from interface %s", ifr.ifr_name);
+
+  To write CAN frames on sockets bound to 'any' CAN interface the
+  outgoing interface has to be defined certainly.
+
+    strcpy(ifr.ifr_name, "can0");
+    ioctl(s, SIOCGIFINDEX, &ifr);
+    addr.can_ifindex = ifr.ifr_ifindex;
+    addr.can_family  = AF_CAN;
+
+    nbytes = sendto(s, &frame, sizeof(struct can_frame),
+                    0, (struct sockaddr*)&addr, sizeof(addr));
+
+  4.1 RAW protocol sockets with can_filters (SOCK_RAW)
+
+  Using CAN_RAW sockets is extensively comparable to the commonly
+  known access to CAN character devices. To meet the new possibilities
+  provided by the multi user SocketCAN approach, some reasonable
+  defaults are set at RAW socket binding time:
+
+  - The filters are set to exactly one filter receiving everything
+  - The socket only receives valid data frames (=> no error frames)
+  - The loopback of sent CAN frames is enabled (see chapter 3.2)
+  - The socket does not receive its own sent frames (in loopback mode)
+
+  These default settings may be changed before or after binding the socket.
+  To use the referenced definitions of the socket options for CAN_RAW
+  sockets, include <linux/can/raw.h>.
+
   4.1.1 RAW socket option CAN_RAW_FILTER
+
+  The reception of CAN frames using CAN_RAW sockets can be controlled
+  by defining 0 .. n filters with the CAN_RAW_FILTER socket option.
+
+  The CAN filter structure is defined in include/linux/can.h:
+
+    struct can_filter {
+            canid_t can_id;
+            canid_t can_mask;
+    };
+
+  A filter matches, when
+
+    <received_can_id> & mask == can_id & mask
+
+  which is analogous to known CAN controllers hardware filter semantics.
+  The filter can be inverted in this semantic, when the CAN_INV_FILTER
+  bit is set in can_id element of the can_filter structure. In
+  contrast to CAN controller hardware filters the user may set 0 .. n
+  receive filters for each open socket separately:
+
+    struct can_filter rfilter[2];
+
+    rfilter[0].can_id   = 0x123;
+    rfilter[0].can_mask = CAN_SFF_MASK;
+    rfilter[1].can_id   = 0x200;
+    rfilter[1].can_mask = 0x700;
+
+    setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter));
+
+  To disable the reception of CAN frames on the selected CAN_RAW socket:
+
+    setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
+
+  To set the filters to zero filters is quite obsolete as not read
+  data causes the raw socket to discard the received CAN frames. But
+  having this 'send only' use-case we may remove the receive list in the
+  Kernel to save a little (really a very little!) CPU usage.
+
   4.1.2 RAW socket option CAN_RAW_ERR_FILTER
+
+  As described in chapter 3.4 the CAN interface driver can generate so
+  called Error Frames that can optionally be passed to the user
+  application in the same way as other CAN frames. The possible
+  errors are divided into different error classes that may be filtered
+  using the appropriate error mask. To register for every possible
+  error condition CAN_ERR_MASK can be used as value for the error mask.
+  The values for the error mask are defined in linux/can/error.h .
+
+    can_err_mask_t err_mask = ( CAN_ERR_TX_TIMEOUT | CAN_ERR_BUSOFF );
+
+    setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER,
+               &err_mask, sizeof(err_mask));
+
   4.1.3 RAW socket option CAN_RAW_LOOPBACK
+
+  To meet multi user needs the local loopback is enabled by default
+  (see chapter 3.2 for details). But in some embedded use-cases
+  (e.g. when only one application uses the CAN bus) this loopback
+  functionality can be disabled (separately for each socket):
+
+    int loopback = 0; /* 0 = disabled, 1 = enabled (default) */
+
+    setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback, sizeof(loopback));
+
   4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS
 
+  When the local loopback is enabled, all the sent CAN frames are
+  looped back to the open CAN sockets that registered for the CAN
+  frames' CAN-ID on this given interface to meet the multi user
+  needs. The reception of the CAN frames on the same socket that was
+  sending the CAN frame is assumed to be unwanted and therefore
+  disabled by default. This default behaviour may be changed on
+  demand:
+
+    int recv_own_msgs = 1; /* 0 = disabled (default), 1 = enabled */
+
+    setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS,
+               &recv_own_msgs, sizeof(recv_own_msgs));
+
+  4.1.5 RAW socket returned message flags
+
+  When using recvmsg() call, the msg->msg_flags may contain following flags:
+
+    MSG_DONTROUTE: set when the received frame was created on the local host.
+
+    MSG_CONFIRM: set when the frame was sent via the socket it is received on.
+      This flag can be interpreted as a 'transmission confirmation' when the
+      CAN driver supports the echo of frames on driver level, see 3.2 and 6.2.
+      In order to receive such messages, CAN_RAW_RECV_OWN_MSGS must be set.
+
   4.2 Broadcast Manager protocol sockets (SOCK_DGRAM)
   4.3 connected transport protocols (SOCK_SEQPACKET)
   4.4 unconnected transport protocols (SOCK_DGRAM)
 
+  4.5 Timestamps
+  
+  For applications in the CAN environment it is often of interest an
+  accurate timestamp of the instant a message from CAN bus has been received.
+  Such a timestamp can be read with ioctl(2) after reading a message from
+  the socket. Example:
+
+    struct timeval tv;
+    ioctl(s, SIOCGSTAMP, &tv);
+
+  The timestamp on Linux has a resolution of one microsecond and it is set
+  automatically at the reception of a CAN frame.
+
+  Alternatively the timestamp can be obtained as a control message (cmsg) using
+  the recvmsg() system call. After enabling the timestamps in the cmsg's by
+
+    const int timestamp = 1;
+    setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &timestamp, sizeof(timestamp));  
+
+  the data structures filled by recvmsg() need to be parsed for
+  cmsg->cmsg_type == SO_TIMESTAMP to get the timestamp. See cmsg() manpage.
 
 5. Socket CAN core module
 -------------------------
@@ -357,23 +517,15 @@ solution for a couple of reasons:
   PF_CAN. CAN protocol modules are loaded by the core module at
   runtime. The core module provides an interface for CAN protocol
   modules to subscribe needed CAN IDs (see chapter 3.1).
-  
-  5.1 can.ko module params 
+
+  5.1 can.ko module params
 
   - stats_timer: To calculate the Socket CAN core statistics
     (e.g. current/maximum frames per second) this 1 second timer is
     invoked at can.ko module start time by default. This timer can be
-    disabled giving stattimer=0 on the module comandline.
-
-  - debug: When the Kconfig option CONFIG_CAN_DEBUG_CORE is set at
-    compile time, the debug output code is compiled into the module.
-    debug = 0x01 => print general debug information
-    debug = 0x02 => print content of processed CAN frames
-    debug = 0x04 => print content of processed socket buffers
+    disabled by using stattimer=0 on the module commandline.
 
-    It is possible or have ORed values e.g. 3 or 7 for an output off
-    all available debug information. Using 0x02 and 0x04 may flood
-    your kernel log - so be careful. 
+  - debug: (removed since SocketCAN SVN r546)
 
   5.2 procfs content
 
@@ -383,7 +535,7 @@ solution for a couple of reasons:
   checked in the appropriate receive list. All entries contain the
   device and a protocol module identifier:
 
-    foo@bar:~$ cat /proc/net/can/rcvlist_all 
+    foo@bar:~$ cat /proc/net/can/rcvlist_all
 
     receive list 'rx_all':
       (vcan3: no entry)
@@ -406,7 +558,7 @@ solution for a couple of reasons:
 
     stats       - Socket CAN core statistics (rx/tx frames, match ratios, ...)
     reset_stats - manual statistic reset
-    version     - prints the Socket CAN core version and the ABI version 
+    version     - prints the Socket CAN core version and the ABI version
 
   5.3 writing own CAN protocol modules
 
@@ -414,7 +566,7 @@ solution for a couple of reasons:
   protocol has to be defined in include/linux/can.h .
   The prototypes and definitions to use the Socket CAN core can be
   accessed by including include/linux/can/core.h .
-  Additionally to functions that register the CAN protocol and the
+  In addition to functions that register the CAN protocol and the
   CAN device notifier chain there are functions to subscribe CAN
   frames received by CAN interfaces and to send CAN frames:
 
@@ -429,14 +581,14 @@ solution for a couple of reasons:
 ----------------------
 
   Writing a CAN network device driver is much easier than writing a
-  CAN character device driver. Analogue to other know network device
+  CAN character device driver. Similar to other known network device
   drivers you mainly have to deal with:
 
   - TX: Put the CAN frame from the socket buffer to the CAN controller.
   - RX: Put the CAN frame from the CAN controller to the socket buffer.
 
   See e.g. at Documentation/networking/netdevices.txt . The differences
-  for writing CAN network device driver are described below: 
+  for writing CAN network device driver are described below:
 
   6.1 general settings
 
@@ -448,14 +600,15 @@ solution for a couple of reasons:
   The struct can_frame is the payload of each socket buffer in the
   protocol family PF_CAN.
 
-  6.2 loopback
+  6.2 local loopback of sent frames
 
   As described in chapter 3.2 the CAN network device driver should
-  support a local loopback functionality. If so the driver flag
-  IFF_LOOPBACK has to be set to omit the PF_CAN core to perform the
-  loopback as fallback solution:
+  support a local loopback functionality similar to the local echo
+  e.g. of tty devices. In this case the driver flag IFF_ECHO has to be
+  set to prevent the PF_CAN core from locally echoing sent frames
+  (aka loopback) as fallback solution:
 
-    dev->flags = (IFF_NOARP | IFF_LOOPBACK);
+    dev->flags = (IFF_NOARP | IFF_ECHO);
 
   6.3 CAN controller hardware filters
 
@@ -471,47 +624,235 @@ solution for a couple of reasons:
   Therefore the use of hardware filters goes to the category 'handmade
   tuning on deep embedded systems'. The author is running a MPC603e
   @133MHz with four SJA1000 CAN controllers from 2002 under heavy bus
-  load without any problems ...        
-  
-  6.4 currently supported CAN hardware (May 2007)
+  load without any problems ...
+
+  6.4 The virtual CAN driver (vcan)
+
+  Similar to the network loopback devices, vcan offers a virtual local
+  CAN interface. A full qualified address on CAN consists of
+
+  - a unique CAN Identifier (CAN ID)
+  - the CAN bus this CAN ID is transmitted on (e.g. can0)
+
+  so in common use cases more than one virtual CAN interface is needed.
+
+  The virtual CAN interfaces allow the transmission and reception of CAN
+  frames without real CAN controller hardware. Virtual CAN network
+  devices are usually named 'vcanX', like vcan0 vcan1 vcan2 ...
+  When compiled as a module the virtual CAN driver module is called vcan.ko
+
+  Since Linux Kernel version 2.6.24 the vcan driver supports the Kernel
+  netlink interface to create vcan network devices. The creation and
+  removal of vcan network devices can be managed with the ip(8) tool:
+
+  - Create a virtual CAN network interface:
+       $ ip link add type vcan
+
+  - Create a virtual CAN network interface with a specific name 'vcan42':
+       $ ip link add dev vcan42 type vcan
+
+  - Remove a (virtual CAN) network interface 'vcan42':
+       $ ip link del vcan42
+
+  6.5 The CAN network device driver interface
+
+  The CAN network device driver interface provides a generic interface
+  to setup, configure and monitor CAN network devices. The user can then
+  configure the CAN device, like setting the bit-timing parameters, via
+  the netlink interface using the program "ip" from the "IPROUTE2"
+  utility suite. The following chapter describes briefly how to use it.
+  Furthermore, the interface uses a common data structure and exports a
+  set of common functions, which all real CAN network device drivers
+  should use. Please have a look to the SJA1000 or MSCAN driver to
+  understand how to use them. The name of the module is can-dev.ko.
+
+  6.5.1 Netlink interface to set/get devices properties
+
+  The CAN device must be configured via netlink interface. The supported
+  netlink message types are defined and briefly described in
+  "include/linux/can/netlink.h". CAN link support for the program "ip"
+  of the IPROUTE2 utility suite is avaiable and it can be used as shown
+  below:
+
+  - Setting CAN device properties:
+
+    $ ip link set can0 type can help
+    Usage: ip link set DEVICE type can
+       [ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
+       [ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
+         phase-seg2 PHASE-SEG2 [ sjw SJW ] ]
+
+       [ loopback { on | off } ]
+       [ listen-only { on | off } ]
+       [ triple-sampling { on | off } ]
+
+       [ restart-ms TIME-MS ]
+       [ restart ]
+
+       Where: BITRATE       := { 1..1000000 }
+              SAMPLE-POINT  := { 0.000..0.999 }
+              TQ            := { NUMBER }
+              PROP-SEG      := { 1..8 }
+              PHASE-SEG1    := { 1..8 }
+              PHASE-SEG2    := { 1..8 }
+              SJW           := { 1..4 }
+              RESTART-MS    := { 0 | NUMBER }
+
+  - Display CAN device details and statistics:
+
+    $ ip -details -statistics link show can0
+    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP qlen 10
+      link/can
+      can <TRIPLE-SAMPLING> state ERROR-ACTIVE restart-ms 100
+      bitrate 125000 sample_point 0.875
+      tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
+      sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+      clock 8000000
+      re-started bus-errors arbit-lost error-warn error-pass bus-off
+      41         17457      0          41         42         41
+      RX: bytes  packets  errors  dropped overrun mcast
+      140859     17608    17457   0       0       0
+      TX: bytes  packets  errors  dropped carrier collsns
+      861        112      0       41      0       0
+
+  More info to the above output:
+
+    "<TRIPLE-SAMPLING>"
+       Shows the list of selected CAN controller modes: LOOPBACK,
+       LISTEN-ONLY, or TRIPLE-SAMPLING.
+
+    "state ERROR-ACTIVE"
+       The current state of the CAN controller: "ERROR-ACTIVE",
+       "ERROR-WARNING", "ERROR-PASSIVE", "BUS-OFF" or "STOPPED"
+
+    "restart-ms 100"
+       Automatic restart delay time. If set to a non-zero value, a
+       restart of the CAN controller will be triggered automatically
+       in case of a bus-off condition after the specified delay time
+       in milliseconds. By default it's off.
+
+    "bitrate 125000 sample_point 0.875"
+       Shows the real bit-rate in bits/sec and the sample-point in the
+       range 0.000..0.999. If the calculation of bit-timing parameters
+       is enabled in the kernel (CONFIG_CAN_CALC_BITTIMING=y), the
+       bit-timing can be defined by setting the "bitrate" argument.
+       Optionally the "sample-point" can be specified. By default it's
+       0.000 assuming CIA-recommended sample-points.
+
+    "tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1"
+       Shows the time quanta in ns, propagation segment, phase buffer
+       segment 1 and 2 and the synchronisation jump width in units of
+       tq. They allow to define the CAN bit-timing in a hardware
+       independent format as proposed by the Bosch CAN 2.0 spec (see
+       chapter 8 of http://www.semiconductors.bosch.de/pdf/can2spec.pdf).
+
+    "sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+     clock 8000000"
+       Shows the bit-timing constants of the CAN controller, here the
+       "sja1000". The minimum and maximum values of the time segment 1
+       and 2, the synchronisation jump width in units of tq, the
+       bitrate pre-scaler and the CAN system clock frequency in Hz.
+       These constants could be used for user-defined (non-standard)
+       bit-timing calculation algorithms in user-space.
+
+    "re-started bus-errors arbit-lost error-warn error-pass bus-off"
+       Shows the number of restarts, bus and arbitration lost errors,
+       and the state changes to the error-warning, error-passive and
+       bus-off state. RX overrun errors are listed in the "overrun"
+       field of the standard network statistics.
+
+  6.5.2 Setting the CAN bit-timing
+
+  The CAN bit-timing parameters can always be defined in a hardware
+  independent format as proposed in the Bosch CAN 2.0 specification
+  specifying the arguments "tq", "prop_seg", "phase_seg1", "phase_seg2"
+  and "sjw":
+
+    $ ip link set canX type can tq 125 prop-seg 6 \
+                               phase-seg1 7 phase-seg2 2 sjw 1
+
+  If the kernel option CONFIG_CAN_CALC_BITTIMING is enabled, CIA
+  recommended CAN bit-timing parameters will be calculated if the bit-
+  rate is specified with the argument "bitrate":
+
+    $ ip link set canX type can bitrate 125000
+
+  Note that this works fine for the most common CAN controllers with
+  standard bit-rates but may *fail* for exotic bit-rates or CAN system
+  clock frequencies. Disabling CONFIG_CAN_CALC_BITTIMING saves some
+  space and allows user-space tools to solely determine and set the
+  bit-timing parameters. The CAN controller specific bit-timing
+  constants can be used for that purpose. They are listed by the
+  following command:
+
+    $ ip -details link show can0
+    ...
+      sja1000: clock 8000000 tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
+
+  6.5.3 Starting and stopping the CAN network device
+
+  A CAN network device is started or stopped as usual with the command
+  "ifconfig canX up/down" or "ip link set canX up/down". Be aware that
+  you *must* define proper bit-timing parameters for real CAN devices
+  before you can start it to avoid error-prone default settings:
+
+    $ ip link set canX up type can bitrate 125000
+
+  A device may enter the "bus-off" state if too much errors occurred on
+  the CAN bus. Then no more messages are received or sent. An automatic
+  bus-off recovery can be enabled by setting the "restart-ms" to a
+  non-zero value, e.g.:
+
+    $ ip link set canX type can restart-ms 100
+
+  Alternatively, the application may realize the "bus-off" condition
+  by monitoring CAN error frames and do a restart when appropriate with
+  the command:
+
+    $ ip link set canX type can restart
+
+  Note that a restart will also create a CAN error frame (see also
+  chapter 3.4).
 
-  On the project website http://developer.berlios.de/projects/socketcan
-  there are different drivers available:
+  6.6 Supported CAN hardware
 
-    vcan:    Virtual CAN interface driver (if no real hardware is available)
-    sja1000: Philips SJA1000 CAN controller (recommended)
-    i82527:  Intel i82527 CAN controller
-    mscan:   Motorola/Freescale CAN controller (e.g. inside SOC MPC5200)
-    slcan:   For a bunch of CAN adaptors that are attached via a
-             serial line ASCII protocol (for serial / USB adaptors) 
+  Please check the "Kconfig" file in "drivers/net/can" to get an actual
+  list of the support CAN hardware. On the Socket CAN project website
+  (see chapter 7) there might be further drivers available, also for
+  older kernel versions.
 
-  Additionally the different CAN adaptors (ISA/PCI/PCMCIA/USB/Parport)
-  from PEAK Systemtechnik support the CAN netdevice driver modell
-  since Linux driver v6.0: http://www.peak-system.com/linux/index.htm
+7. Socket CAN resources
+-----------------------
 
-  Please check the Mailing Lists on the berlios OSS project website. 
+  You can find further resources for Socket CAN like user space tools,
+  support for old kernel versions, more drivers, mailing lists, etc.
+  at the BerliOS OSS project website for Socket CAN:
 
-  6.5 todo (May 2007)
+    http://developer.berlios.de/projects/socketcan
 
-  The configuration interface for CAN network drivers is still an open
-  issue that has not been finalized in the socketcan project. Also the
-  idea of having a library module (candev.ko) that holds functions
-  that are needed by all CAN netdevices is not ready to ship.
-  Your contribution is welcome.
+  If you have questions, bug fixes, etc., don't hesitate to post them to
+  the Socketcan-Users mailing list. But please search the archives first.
 
-7. Credits
+8. Credits
 ----------
 
-  Oliver Hartkopp (PF_CAN core, filters, drivers, bcm)
+  Oliver Hartkopp (PF_CAN core, filters, drivers, bcm, SJA1000 driver)
   Urs Thuermann (PF_CAN core, kernel integration, socket interfaces, raw, vcan)
   Jan Kizka (RT-SocketCAN core, Socket-API reconciliation)
-  Wolfgang Grandegger (RT-SocketCAN core & drivers)
-  Robert Schwebel (OSELAS integration)
-  Marc Kleine-Budde (Kernel 2.6 cleanups, reviews, drivers)
+  Wolfgang Grandegger (RT-SocketCAN core & drivers, Raw Socket-API reviews,
+                       CAN device driver interface, MSCAN driver)
+  Robert Schwebel (design reviews, PTXdist integration)
+  Marc Kleine-Budde (design reviews, Kernel 2.6 cleanups, drivers)
   Benedikt Spranger (reviews)
   Thomas Gleixner (LKML reviews, coding style, posting hints)
-  Andrey Volkov (kernel subtree structure, ioctls, mscan driver)
+  Andrey Volkov (kernel subtree structure, ioctls, MSCAN driver)
   Matthias Brukner (first SJA1000 CAN netdevice implementation Q2/2003)
   Klaus Hitschler (PEAK driver integration)
   Uwe Koppe (CAN netdevices with PF_PACKET approach)
   Michael Schulze (driver layer loopback requirement, RT CAN drivers review)
+  Pavel Pisa (Bit-timing calculation)
+  Sascha Hauer (SJA1000 platform driver)
+  Sebastian Haas (SJA1000 EMS PCI driver)
+  Markus Plessing (SJA1000 EMS PCI driver)
+  Per Dalen (SJA1000 Kvaser PCI driver)
+  Sam Ravnborg (reviews, coding style, kbuild help)