Update includes to Linux 3.6 with CAN FD support.

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>
pull/7/head
Oliver Hartkopp 2012-11-14 18:52:01 +01:00
parent 9b99fafe1a
commit a2b13452c7
6 changed files with 73 additions and 36 deletions

View File

@ -3,15 +3,11 @@
* *
* Definitions for CAN network layer (socket addr / CAN frame / CAN filter) * Definitions for CAN network layer (socket addr / CAN frame / CAN filter)
* *
* $Id$
*
* Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Urs Thuermann <urs.thuermann@volkswagen.de> * Urs Thuermann <urs.thuermann@volkswagen.de>
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved. * All rights reserved.
* *
* Send feedback to <linux-can@vger.kernel.org>
*
*/ */
#ifndef CAN_H #ifndef CAN_H
@ -26,7 +22,7 @@
/* special address description flags for the CAN_ID */ /* special address description flags for the CAN_ID */
#define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */ #define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */ #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 */ /* valid bits in CAN ID for frame formats */
#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */ #define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
@ -37,32 +33,85 @@
* Controller Area Network Identifier structure * Controller Area Network Identifier structure
* *
* bit 0-28 : CAN identifier (11/29 bit) * 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 30 : remote transmission request flag (1 = rtr frame)
* bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit) * bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
*/ */
typedef __u32 canid_t; 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 0-28 : error class mask (see include/socketcan/can/error.h)
* bit 29-31 : set to zero * bit 29-31 : set to zero
*/ */
typedef __u32 can_err_mask_t; 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 * struct can_frame - basic CAN frame structure
* @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above. * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
* @can_dlc: the data length field of the CAN frame * @can_dlc: frame payload length in byte (0 .. 8) aka data length code
* @data: the CAN frame payload. * 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 { struct can_frame {
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
__u8 can_dlc; /* data length code: 0 .. 8 */ __u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
__u8 data[8] __attribute__((aligned(8))); __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 */ /* particular protocols of the protocol family PF_CAN */
#define CAN_RAW 1 /* RAW sockets */ #define CAN_RAW 1 /* RAW sockets */
#define CAN_BCM 2 /* Broadcast Manager */ #define CAN_BCM 2 /* Broadcast Manager */
@ -74,6 +123,9 @@ struct can_frame {
#define SOL_CAN_BASE 100 #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 * struct sockaddr_can - the sockaddr structure for CAN sockets
* @can_family: address family number AF_CAN. * @can_family: address family number AF_CAN.
@ -82,6 +134,7 @@ struct can_frame {
*/ */
struct sockaddr_can { struct sockaddr_can {
sa_family_t can_family; sa_family_t can_family;
// __kernel_sa_family_t can_family;
int can_ifindex; int can_ifindex;
union { union {
/* transport protocol class address information (e.g. ISOTP) */ /* transport protocol class address information (e.g. ISOTP) */
@ -102,7 +155,7 @@ struct sockaddr_can {
* <received_can_id> & mask == can_id & mask * <received_can_id> & mask == can_id & mask
* *
* The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can * 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 { struct can_filter {
canid_t can_id; canid_t can_id;

View File

@ -3,19 +3,18 @@
* *
* Definitions for CAN Broadcast Manager (BCM) * Definitions for CAN Broadcast Manager (BCM)
* *
* $Id$
*
* Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved. * All rights reserved.
* *
* Send feedback to <linux-can@vger.kernel.org>
*
*/ */
#ifndef CAN_BCM_H #ifndef CAN_BCM_H
#define 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 * struct bcm_msg_head - head of messages to/from the broadcast manager
* @opcode: opcode, see enum below. * @opcode: opcode, see enum below.

View File

@ -1,22 +1,18 @@
/* /*
* socketcan/can/error.h * socketcan/can/error.h
* *
* Definitions of the CAN error frame to be filtered and passed to the user. * Definitions of the CAN error messages to be filtered and passed to the user.
*
* $Id$
* *
* Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved. * All rights reserved.
* *
* Send feedback to <linux-can@vger.kernel.org>
*
*/ */
#ifndef CAN_ERROR_H #ifndef CAN_ERROR_H
#define 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 */ /* error class (mask) in can_id */
#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */ #define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */

View File

@ -3,14 +3,10 @@
* *
* Definitions for CAN frame Gateway/Router/Bridge * Definitions for CAN frame Gateway/Router/Bridge
* *
* $Id$
*
* Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Copyright (c) 2011 Volkswagen Group Electronic Research * Copyright (c) 2011 Volkswagen Group Electronic Research
* All rights reserved. * All rights reserved.
* *
* Send feedback to <linux-can@vger.kernel.org>
*
*/ */
#ifndef CAN_GW_H #ifndef CAN_GW_H

View File

@ -3,12 +3,8 @@
* *
* Definitions for the CAN netlink interface * 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> * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
* *
* Send feedback to <linux-can@vger.kernel.org>
*
*/ */
#ifndef CAN_NETLINK_H #ifndef CAN_NETLINK_H

View File

@ -3,15 +3,11 @@
* *
* Definitions for raw CAN sockets * Definitions for raw CAN sockets
* *
* $Id$
*
* Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
* Urs Thuermann <urs.thuermann@volkswagen.de> * Urs Thuermann <urs.thuermann@volkswagen.de>
* Copyright (c) 2002-2007 Volkswagen Group Electronic Research * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved. * All rights reserved.
* *
* Send feedback to <linux-can@vger.kernel.org>
*
*/ */
#ifndef CAN_RAW_H #ifndef CAN_RAW_H
@ -27,7 +23,8 @@ enum {
CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */ CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
CAN_RAW_ERR_FILTER, /* set filter for error frames */ CAN_RAW_ERR_FILTER, /* set filter for error frames */
CAN_RAW_LOOPBACK, /* local loopback (default:on) */ 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 #endif