debug: turn ignore_loglevel into an early param
[wrt350n-kernel.git] / include / linux / can.h
blobd18333302cbd0a65fcb62caa13e3505f07aa6dc7
1 /*
2 * linux/can.h
4 * Definitions for CAN network layer (socket addr / CAN frame / CAN filter)
6 * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Urs Thuermann <urs.thuermann@volkswagen.de>
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9 * All rights reserved.
11 * Send feedback to <socketcan-users@lists.berlios.de>
15 #ifndef CAN_H
16 #define CAN_H
18 #include <linux/types.h>
19 #include <linux/socket.h>
21 /* controller area network (CAN) kernel definitions */
23 /* special address description flags for the CAN_ID */
24 #define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
25 #define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
26 #define CAN_ERR_FLAG 0x20000000U /* error frame */
28 /* valid bits in CAN ID for frame formats */
29 #define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
30 #define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
31 #define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
34 * Controller Area Network Identifier structure
36 * bit 0-28 : CAN identifier (11/29 bit)
37 * bit 29 : error frame flag (0 = data frame, 1 = error frame)
38 * bit 30 : remote transmission request flag (1 = rtr frame)
39 * bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
41 typedef __u32 canid_t;
44 * Controller Area Network Error Frame Mask structure
46 * bit 0-28 : error class mask (see include/linux/can/error.h)
47 * bit 29-31 : set to zero
49 typedef __u32 can_err_mask_t;
51 /**
52 * struct can_frame - basic CAN frame structure
53 * @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above.
54 * @can_dlc: the data length field of the CAN frame
55 * @data: the CAN frame payload.
57 struct can_frame {
58 canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
59 __u8 can_dlc; /* data length code: 0 .. 8 */
60 __u8 data[8] __attribute__((aligned(8)));
63 /* particular protocols of the protocol family PF_CAN */
64 #define CAN_RAW 1 /* RAW sockets */
65 #define CAN_BCM 2 /* Broadcast Manager */
66 #define CAN_TP16 3 /* VAG Transport Protocol v1.6 */
67 #define CAN_TP20 4 /* VAG Transport Protocol v2.0 */
68 #define CAN_MCNET 5 /* Bosch MCNet */
69 #define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */
70 #define CAN_NPROTO 7
72 #define SOL_CAN_BASE 100
74 /**
75 * struct sockaddr_can - the sockaddr structure for CAN sockets
76 * @can_family: address family number AF_CAN.
77 * @can_ifindex: CAN network interface index.
78 * @can_addr: protocol specific address information
80 struct sockaddr_can {
81 sa_family_t can_family;
82 int can_ifindex;
83 union {
84 /* transport protocol class address information (e.g. ISOTP) */
85 struct { canid_t rx_id, tx_id; } tp;
87 /* reserved for future CAN protocols address information */
88 } can_addr;
91 /**
92 * struct can_filter - CAN ID based filter in can_register().
93 * @can_id: relevant bits of CAN ID which are not masked out.
94 * @can_mask: CAN mask (see description)
96 * Description:
97 * A filter matches, when
99 * <received_can_id> & mask == can_id & mask
101 * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
102 * filter for error frames (CAN_ERR_FLAG bit set in mask).
104 struct can_filter {
105 canid_t can_id;
106 canid_t can_mask;
109 #define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
111 #endif /* CAN_H */