]> rtime.felk.cvut.cz Git - socketcan-devel.git/blob - kernel/2.6/include/socketcan/can/netlink.h
5ff322d6d1f8f87e7929f4851f2f841a0e85c097
[socketcan-devel.git] / kernel / 2.6 / include / socketcan / can / netlink.h
1 /*
2  * socketcan/can/netlink.h
3  *
4  * Definitions for the CAN netlink interface
5  *
6  * $Id: dev.h 939 2009-02-14 14:30:19Z wolf $
7  *
8  * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
9  *
10  * Send feedback to <socketcan-users@lists.berlios.de>
11  *
12  */
13
14 #ifndef CAN_NETLINK_H
15 #define CAN_NETLINK_H
16
17 #include <linux/types.h>
18
19 /*
20  * CAN bit-timing parameters
21  *
22  * For futher information, please read chapter "8 BIT TIMING
23  * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
24  * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
25  */
26 struct can_bittiming {
27         __u32 bitrate;          /* Bit-rate in bits/second */
28         __u32 sample_point;     /* Sample point in one-tenth of a percent */
29         __u32 tq;               /* Time quanta (TQ) in nanoseconds */
30         __u32 prop_seg;         /* Propagation segment in TQs */
31         __u32 phase_seg1;       /* Phase buffer segment 1 in TQs */
32         __u32 phase_seg2;       /* Phase buffer segment 2 in TQs */
33         __u32 sjw;              /* Synchronisation jump width in TQs */
34         __u32 brp;              /* Bit-rate prescaler */
35 };
36
37 /*
38  * CAN harware-dependent bit-timing constant
39  *
40  * Used for calculating and checking bit-timing parameters
41  */
42 struct can_bittiming_const {
43         char name[16];          /* Name of the CAN controller hardware */
44         __u32 tseg1_min;        /* Time segement 1 = prop_seg + phase_seg1 */
45         __u32 tseg1_max;
46         __u32 tseg2_min;        /* Time segement 2 = phase_seg2 */
47         __u32 tseg2_max;
48         __u32 sjw_max;          /* Synchronisation jump width */
49         __u32 brp_min;          /* Bit-rate prescaler */
50         __u32 brp_max;
51         __u32 brp_inc;
52 };
53
54 /*
55  * CAN clock parameters
56  */
57 struct can_clock {
58         __u32 freq;             /* CAN system clock frequency in Hz */
59 };
60
61 /*
62  * CAN operational and error states
63  */
64 enum can_state {
65         CAN_STATE_ERROR_ACTIVE = 0,     /* RX/TX error count < 96 */
66         CAN_STATE_ERROR_WARNING,        /* RX/TX error count < 128 */
67         CAN_STATE_ERROR_PASSIVE,        /* RX/TX error count < 256 */
68         CAN_STATE_BUS_OFF,              /* RX/TX error count >= 256 */
69         CAN_STATE_STOPPED,              /* Device is stopped */
70         CAN_STATE_SLEEPING,             /* Device is sleeping */
71         CAN_STATE_MAX
72 };
73
74 /*
75  * CAN bus error counters
76  */
77 struct can_berr_counter {
78         __u16 txerr;
79         __u16 rxerr;
80 };
81
82 /*
83  * CAN controller mode
84  */
85 struct can_ctrlmode {
86         __u32 mask;
87         __u32 flags;
88 };
89
90 #define CAN_CTRLMODE_LOOPBACK           0x01    /* Loopback mode */
91 #define CAN_CTRLMODE_LISTENONLY         0x02    /* Listen-only mode */
92 #define CAN_CTRLMODE_3_SAMPLES          0x04    /* Triple sampling mode */
93 #define CAN_CTRLMODE_ONE_SHOT           0x08    /* One-Shot mode */
94 #define CAN_CTRLMODE_BERR_REPORTING     0x10    /* Bus-error reporting */
95
96 /*
97  * CAN device statistics
98  */
99 struct can_device_stats {
100         __u32 bus_error;        /* Bus errors */
101         __u32 error_warning;    /* Changes to error warning state */
102         __u32 error_passive;    /* Changes to error passive state */
103         __u32 bus_off;          /* Changes to bus off state */
104         __u32 arbitration_lost; /* Arbitration lost errors */
105         __u32 restarts;         /* CAN controller re-starts */
106 };
107
108 /*
109  * CAN netlink interface
110  */
111 enum {
112         IFLA_CAN_UNSPEC,
113         IFLA_CAN_BITTIMING,
114         IFLA_CAN_BITTIMING_CONST,
115         IFLA_CAN_CLOCK,
116         IFLA_CAN_STATE,
117         IFLA_CAN_CTRLMODE,
118         IFLA_CAN_RESTART_MS,
119         IFLA_CAN_RESTART,
120         IFLA_CAN_BERR_COUNTER,
121         __IFLA_CAN_MAX
122 };
123
124 #define IFLA_CAN_MAX    (__IFLA_CAN_MAX - 1)
125
126 #endif /* CAN_NETLINK_H */