]> rtime.felk.cvut.cz Git - sojka/can-utils.git/commitdiff
Update includes to Linux 3.6 with CAN FD support.
authorOliver Hartkopp <socketcan@hartkopp.net>
Wed, 14 Nov 2012 17:52:01 +0000 (18:52 +0100)
committerOliver Hartkopp <socketcan@hartkopp.net>
Wed, 14 Nov 2012 17:52:01 +0000 (18:52 +0100)
There has been a change with __kernel_sa_family_t in Linux 3.1 which was not
adopted in this update so far to be backward compatible with old environments.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
include/socketcan/can.h
include/socketcan/can/bcm.h
include/socketcan/can/error.h
include/socketcan/can/gw.h
include/socketcan/can/netlink.h
include/socketcan/can/raw.h

index 00a3f76731d0fe6c6899285428053a0a338bec25..8452f0ea8fca734c685bc491048dd46331428dd3 100644 (file)
@@ -3,15 +3,11 @@
  *
  * Definitions for CAN network layer (socket addr / CAN frame / CAN filter)
  *
- * $Id$
- *
  * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  *          Urs Thuermann   <urs.thuermann@volkswagen.de>
  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
- * Send feedback to <linux-can@vger.kernel.org>
- *
  */
 
 #ifndef CAN_H
@@ -26,7 +22,7 @@
 /* special address description flags for the CAN_ID */
 #define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
 #define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
-#define CAN_ERR_FLAG 0x20000000U /* error frame */
+#define CAN_ERR_FLAG 0x20000000U /* error message frame */
 
 /* valid bits in CAN ID for frame formats */
 #define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
  * Controller Area Network Identifier structure
  *
  * bit 0-28    : CAN identifier (11/29 bit)
- * bit 29      : error frame flag (0 = data frame, 1 = error frame)
+ * bit 29      : error message frame flag (0 = data frame, 1 = error message)
  * bit 30      : remote transmission request flag (1 = rtr frame)
  * bit 31      : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
  */
 typedef __u32 canid_t;
 
+#define CAN_SFF_ID_BITS                11
+#define CAN_EFF_ID_BITS                29
+
 /*
- * Controller Area Network Error Frame Mask structure
+ * Controller Area Network Error Message Frame Mask structure
  *
  * bit 0-28    : error class mask (see include/socketcan/can/error.h)
  * bit 29-31   : set to zero
  */
 typedef __u32 can_err_mask_t;
 
+/* CAN payload length and DLC definitions according to ISO 11898-1 */
+#define CAN_MAX_DLC 8
+#define CAN_MAX_DLEN 8
+
+/* CAN FD payload length and DLC definitions according to ISO 11898-7 */
+#define CANFD_MAX_DLC 15
+#define CANFD_MAX_DLEN 64
+
 /**
  * struct can_frame - basic CAN frame structure
- * @can_id:  the CAN ID of the frame and CAN_*_FLAG flags, see above.
- * @can_dlc: the data length field of the CAN frame
- * @data:    the CAN frame payload.
+ * @can_id:  CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
+ * @can_dlc: frame payload length in byte (0 .. 8) aka data length code
+ *           N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1
+ *           mapping of the 'data length code' to the real payload length
+ * @data:    CAN frame payload (up to 8 byte)
  */
 struct can_frame {
        canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
-       __u8    can_dlc; /* data length code: 0 .. 8 */
-       __u8    data[8] __attribute__((aligned(8)));
+       __u8    can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
+       __u8    data[CAN_MAX_DLEN] __attribute__((aligned(8)));
+};
+
+/*
+ * defined bits for canfd_frame.flags
+ *
+ * The use of struct canfd_frame implies the Extended Data Length (EDL) bit to
+ * be set in the CAN frame bitstream on the wire. The EDL bit switch turns
+ * the CAN controllers bitstream processor into the CAN FD mode which creates
+ * two new options within the CAN FD frame specification:
+ *
+ * Bit Rate Switch - to indicate a second bitrate is/was used for the payload
+ * Error State Indicator - represents the error state of the transmitting node
+ *
+ * As the CANFD_ESI bit is internally generated by the transmitting CAN
+ * controller only the CANFD_BRS bit is relevant for real CAN controllers when
+ * building a CAN FD frame for transmission. Setting the CANFD_ESI bit can make
+ * sense for virtual CAN interfaces to test applications with echoed frames.
+ */
+#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
+#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
+
+/**
+ * struct canfd_frame - CAN flexible data rate frame structure
+ * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
+ * @len:    frame payload length in byte (0 .. CANFD_MAX_DLEN)
+ * @flags:  additional flags for CAN FD
+ * @__res0: reserved / padding
+ * @__res1: reserved / padding
+ * @data:   CAN FD frame payload (up to CANFD_MAX_DLEN byte)
+ */
+struct canfd_frame {
+       canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
+       __u8    len;     /* frame payload length in byte */
+       __u8    flags;   /* additional flags for CAN FD */
+       __u8    __res0;  /* reserved / padding */
+       __u8    __res1;  /* reserved / padding */
+       __u8    data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
 };
 
+#define CAN_MTU                (sizeof(struct can_frame))
+#define CANFD_MTU      (sizeof(struct canfd_frame))
+
 /* particular protocols of the protocol family PF_CAN */
 #define CAN_RAW                1 /* RAW sockets */
 #define CAN_BCM                2 /* Broadcast Manager */
@@ -74,6 +123,9 @@ struct can_frame {
 
 #define SOL_CAN_BASE 100
 
+// typedef unsigned short __kernel_sa_family_t;
+// introduced in Linux 3.2 commit 6602a4baf4d1a73cc4685a39ef859e1c5ddf654c
+
 /**
  * struct sockaddr_can - the sockaddr structure for CAN sockets
  * @can_family:  address family number AF_CAN.
@@ -82,6 +134,7 @@ struct can_frame {
  */
 struct sockaddr_can {
        sa_family_t can_family;
+//     __kernel_sa_family_t can_family;
        int         can_ifindex;
        union {
                /* transport protocol class address information (e.g. ISOTP) */
@@ -102,7 +155,7 @@ struct sockaddr_can {
  *          <received_can_id> & mask == can_id & mask
  *
  * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
- * filter for error frames (CAN_ERR_FLAG bit set in mask).
+ * filter for error message frames (CAN_ERR_FLAG bit set in mask).
  */
 struct can_filter {
        canid_t can_id;
index d50a0852df615b652385bfa9bc891f6d6d06269a..10185e86a59619b4dad05e24e7ab72eeba233463 100644 (file)
@@ -3,19 +3,18 @@
  *
  * Definitions for CAN Broadcast Manager (BCM)
  *
- * $Id$
- *
  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
- * Send feedback to <linux-can@vger.kernel.org>
- *
  */
 
 #ifndef CAN_BCM_H
 #define CAN_BCM_H
 
+#include <linux/types.h>
+#include <socketcan/can.h>
+
 /**
  * struct bcm_msg_head - head of messages to/from the broadcast manager
  * @opcode:    opcode, see enum below.
index ea6c3811f063c233cd0d9aa06792c936e5e716ca..b65c2317b40a8b8f024c465b575be8cc136c9ccf 100644 (file)
@@ -1,22 +1,18 @@
 /*
  * socketcan/can/error.h
  *
- * Definitions of the CAN error frame to be filtered and passed to the user.
- *
- * $Id$
+ * Definitions of the CAN error messages to be filtered and passed to the user.
  *
  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
- * Send feedback to <linux-can@vger.kernel.org>
- *
  */
 
 #ifndef CAN_ERROR_H
 #define CAN_ERROR_H
 
-#define CAN_ERR_DLC 8 /* dlc for error frames */
+#define CAN_ERR_DLC 8 /* dlc for error message frames */
 
 /* error class (mask) in can_id */
 #define CAN_ERR_TX_TIMEOUT   0x00000001U /* TX timeout (by netdevice driver) */
index f747eb493867e94c16114f37c6e08fafac82fd76..fc428cc1006c34a71f3daed05450e3ece8baae6e 100644 (file)
@@ -3,14 +3,10 @@
  *
  * Definitions for CAN frame Gateway/Router/Bridge
  *
- * $Id$
- *
  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  * Copyright (c) 2011 Volkswagen Group Electronic Research
  * All rights reserved.
  *
- * Send feedback to <linux-can@vger.kernel.org>
- *
  */
 
 #ifndef CAN_GW_H
index aa6a23761d27cee59099e92d3c7f93f5fbfdeb40..9bb47e31748e3123edb3cc215e7ec506fb42ea17 100644 (file)
@@ -3,12 +3,8 @@
  *
  * Definitions for the CAN netlink interface
  *
- * $Id: dev.h 939 2009-02-14 14:30:19Z wolf $
- *
  * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
  *
- * Send feedback to <linux-can@vger.kernel.org>
- *
  */
 
 #ifndef CAN_NETLINK_H
index b7945004be16134af23750bca7a4f27e6d236738..ee683c58412bd22e2a9805fd59c1246c896371b7 100644 (file)
@@ -3,15 +3,11 @@
  *
  * Definitions for raw CAN sockets
  *
- * $Id$
- *
  * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  *          Urs Thuermann   <urs.thuermann@volkswagen.de>
  * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  * All rights reserved.
  *
- * Send feedback to <linux-can@vger.kernel.org>
- *
  */
 
 #ifndef CAN_RAW_H
@@ -27,7 +23,8 @@ enum {
        CAN_RAW_FILTER = 1,     /* set 0 .. n can_filter(s)          */
        CAN_RAW_ERR_FILTER,     /* set filter for error frames       */
        CAN_RAW_LOOPBACK,       /* local loopback (default:on)       */
-       CAN_RAW_RECV_OWN_MSGS   /* receive my own msgs (default:off) */
+       CAN_RAW_RECV_OWN_MSGS,  /* receive my own msgs (default:off) */
+       CAN_RAW_FD_FRAMES,      /* allow CAN FD frames (default:off) */
 };
 
 #endif