0002-include-cache-copy-of-can.h-and-can-netlink.h.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. From 46e6d487f9406001318e97d0349bcda07f923908 Mon Sep 17 00:00:00 2001
  2. From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
  3. Date: Sat, 20 May 2023 10:22:52 +0200
  4. Subject: [PATCH] include: cache copy of can.h and can/netlink.h
  5. Ensure that rtnl-link-can example compiles in any installation. These
  6. headers are not installed in the system.
  7. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
  8. Upstream: https://git.netfilter.org/libmnl/commit/?id=0b242d346dddba85384dd784759fe2b77f063e12
  9. ---
  10. configure.ac | 2 +-
  11. include/linux/Makefile.am | 4 +-
  12. include/linux/can.h | 298 ++++++++++++++++++++++++++++++++++
  13. include/linux/can/Makefile.am | 1 +
  14. include/linux/can/netlink.h | 185 +++++++++++++++++++++
  15. 5 files changed, 487 insertions(+), 3 deletions(-)
  16. create mode 100644 include/linux/can.h
  17. create mode 100644 include/linux/can/Makefile.am
  18. create mode 100644 include/linux/can/netlink.h
  19. diff --git a/configure.ac b/configure.ac
  20. index 314481dae87e..c8a56c6d0550 100644
  21. --- a/configure.ac
  22. +++ b/configure.ac
  23. @@ -27,7 +27,7 @@ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
  24. -Wformat=2 -pipe"
  25. AC_SUBST([regular_CPPFLAGS])
  26. AC_SUBST([regular_CFLAGS])
  27. -AC_CONFIG_FILES([Makefile src/Makefile include/Makefile include/libmnl/Makefile include/linux/Makefile include/linux/netfilter/Makefile examples/Makefile examples/genl/Makefile examples/kobject/Makefile examples/netfilter/Makefile examples/rtnl/Makefile libmnl.pc doxygen.cfg doxygen/Makefile])
  28. +AC_CONFIG_FILES([Makefile src/Makefile include/Makefile include/libmnl/Makefile include/linux/Makefile include/linux/can/Makefile include/linux/netfilter/Makefile examples/Makefile examples/genl/Makefile examples/kobject/Makefile examples/netfilter/Makefile examples/rtnl/Makefile libmnl.pc doxygen.cfg doxygen/Makefile])
  29. AC_ARG_WITH([doxygen], [AS_HELP_STRING([--with-doxygen],
  30. [create doxygen documentation])],
  31. diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
  32. index 08c600b5fa42..ee0993dae186 100644
  33. --- a/include/linux/Makefile.am
  34. +++ b/include/linux/Makefile.am
  35. @@ -1,2 +1,2 @@
  36. -SUBDIRS = netfilter
  37. -noinst_HEADERS = netlink.h socket.h
  38. +SUBDIRS = can netfilter
  39. +noinst_HEADERS = can.h netlink.h socket.h
  40. diff --git a/include/linux/can.h b/include/linux/can.h
  41. new file mode 100644
  42. index 000000000000..2c6a3ee7d32d
  43. --- /dev/null
  44. +++ b/include/linux/can.h
  45. @@ -0,0 +1,298 @@
  46. +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
  47. +/*
  48. + * linux/can.h
  49. + *
  50. + * Definitions for CAN network layer (socket addr / CAN frame / CAN filter)
  51. + *
  52. + * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  53. + * Urs Thuermann <urs.thuermann@volkswagen.de>
  54. + * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  55. + * All rights reserved.
  56. + *
  57. + * Redistribution and use in source and binary forms, with or without
  58. + * modification, are permitted provided that the following conditions
  59. + * are met:
  60. + * 1. Redistributions of source code must retain the above copyright
  61. + * notice, this list of conditions and the following disclaimer.
  62. + * 2. Redistributions in binary form must reproduce the above copyright
  63. + * notice, this list of conditions and the following disclaimer in the
  64. + * documentation and/or other materials provided with the distribution.
  65. + * 3. Neither the name of Volkswagen nor the names of its contributors
  66. + * may be used to endorse or promote products derived from this software
  67. + * without specific prior written permission.
  68. + *
  69. + * Alternatively, provided that this notice is retained in full, this
  70. + * software may be distributed under the terms of the GNU General
  71. + * Public License ("GPL") version 2, in which case the provisions of the
  72. + * GPL apply INSTEAD OF those given above.
  73. + *
  74. + * The provided data structures and external interfaces from this code
  75. + * are not restricted to be used by modules with a GPL compatible license.
  76. + *
  77. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  78. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  79. + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  80. + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  81. + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  82. + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  83. + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  84. + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  85. + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  86. + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  87. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  88. + * DAMAGE.
  89. + */
  90. +
  91. +#ifndef _UAPI_CAN_H
  92. +#define _UAPI_CAN_H
  93. +
  94. +#include <linux/types.h>
  95. +#include <linux/socket.h>
  96. +#include <linux/stddef.h> /* for offsetof */
  97. +
  98. +/* controller area network (CAN) kernel definitions */
  99. +
  100. +/* special address description flags for the CAN_ID */
  101. +#define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
  102. +#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
  103. +#define CAN_ERR_FLAG 0x20000000U /* error message frame */
  104. +
  105. +/* valid bits in CAN ID for frame formats */
  106. +#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
  107. +#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
  108. +#define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
  109. +#define CANXL_PRIO_MASK CAN_SFF_MASK /* 11 bit priority mask */
  110. +
  111. +/*
  112. + * Controller Area Network Identifier structure
  113. + *
  114. + * bit 0-28 : CAN identifier (11/29 bit)
  115. + * bit 29 : error message frame flag (0 = data frame, 1 = error message)
  116. + * bit 30 : remote transmission request flag (1 = rtr frame)
  117. + * bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
  118. + */
  119. +typedef __u32 canid_t;
  120. +
  121. +#define CAN_SFF_ID_BITS 11
  122. +#define CAN_EFF_ID_BITS 29
  123. +#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
  124. +
  125. +/*
  126. + * Controller Area Network Error Message Frame Mask structure
  127. + *
  128. + * bit 0-28 : error class mask (see include/uapi/linux/can/error.h)
  129. + * bit 29-31 : set to zero
  130. + */
  131. +typedef __u32 can_err_mask_t;
  132. +
  133. +/* CAN payload length and DLC definitions according to ISO 11898-1 */
  134. +#define CAN_MAX_DLC 8
  135. +#define CAN_MAX_RAW_DLC 15
  136. +#define CAN_MAX_DLEN 8
  137. +
  138. +/* CAN FD payload length and DLC definitions according to ISO 11898-7 */
  139. +#define CANFD_MAX_DLC 15
  140. +#define CANFD_MAX_DLEN 64
  141. +
  142. +/*
  143. + * CAN XL payload length and DLC definitions according to ISO 11898-1
  144. + * CAN XL DLC ranges from 0 .. 2047 => data length from 1 .. 2048 byte
  145. + */
  146. +#define CANXL_MIN_DLC 0
  147. +#define CANXL_MAX_DLC 2047
  148. +#define CANXL_MAX_DLC_MASK 0x07FF
  149. +#define CANXL_MIN_DLEN 1
  150. +#define CANXL_MAX_DLEN 2048
  151. +
  152. +/**
  153. + * struct can_frame - Classical CAN frame structure (aka CAN 2.0B)
  154. + * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
  155. + * @len: CAN frame payload length in byte (0 .. 8)
  156. + * @can_dlc: deprecated name for CAN frame payload length in byte (0 .. 8)
  157. + * @__pad: padding
  158. + * @__res0: reserved / padding
  159. + * @len8_dlc: optional DLC value (9 .. 15) at 8 byte payload length
  160. + * len8_dlc contains values from 9 .. 15 when the payload length is
  161. + * 8 bytes but the DLC value (see ISO 11898-1) is greater then 8.
  162. + * CAN_CTRLMODE_CC_LEN8_DLC flag has to be enabled in CAN driver.
  163. + * @data: CAN frame payload (up to 8 byte)
  164. + */
  165. +struct can_frame {
  166. + canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
  167. + union {
  168. + /* CAN frame payload length in byte (0 .. CAN_MAX_DLEN)
  169. + * was previously named can_dlc so we need to carry that
  170. + * name for legacy support
  171. + */
  172. + __u8 len;
  173. + __u8 can_dlc; /* deprecated */
  174. + } __attribute__((packed)); /* disable padding added in some ABIs */
  175. + __u8 __pad; /* padding */
  176. + __u8 __res0; /* reserved / padding */
  177. + __u8 len8_dlc; /* optional DLC for 8 byte payload length (9 .. 15) */
  178. + __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
  179. +};
  180. +
  181. +/*
  182. + * defined bits for canfd_frame.flags
  183. + *
  184. + * The use of struct canfd_frame implies the FD Frame (FDF) bit to
  185. + * be set in the CAN frame bitstream on the wire. The FDF bit switch turns
  186. + * the CAN controllers bitstream processor into the CAN FD mode which creates
  187. + * two new options within the CAN FD frame specification:
  188. + *
  189. + * Bit Rate Switch - to indicate a second bitrate is/was used for the payload
  190. + * Error State Indicator - represents the error state of the transmitting node
  191. + *
  192. + * As the CANFD_ESI bit is internally generated by the transmitting CAN
  193. + * controller only the CANFD_BRS bit is relevant for real CAN controllers when
  194. + * building a CAN FD frame for transmission. Setting the CANFD_ESI bit can make
  195. + * sense for virtual CAN interfaces to test applications with echoed frames.
  196. + *
  197. + * The struct can_frame and struct canfd_frame intentionally share the same
  198. + * layout to be able to write CAN frame content into a CAN FD frame structure.
  199. + * When this is done the former differentiation via CAN_MTU / CANFD_MTU gets
  200. + * lost. CANFD_FDF allows programmers to mark CAN FD frames in the case of
  201. + * using struct canfd_frame for mixed CAN / CAN FD content (dual use).
  202. + * Since the introduction of CAN XL the CANFD_FDF flag is set in all CAN FD
  203. + * frame structures provided by the CAN subsystem of the Linux kernel.
  204. + */
  205. +#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
  206. +#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
  207. +#define CANFD_FDF 0x04 /* mark CAN FD for dual use of struct canfd_frame */
  208. +
  209. +/**
  210. + * struct canfd_frame - CAN flexible data rate frame structure
  211. + * @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
  212. + * @len: frame payload length in byte (0 .. CANFD_MAX_DLEN)
  213. + * @flags: additional flags for CAN FD
  214. + * @__res0: reserved / padding
  215. + * @__res1: reserved / padding
  216. + * @data: CAN FD frame payload (up to CANFD_MAX_DLEN byte)
  217. + */
  218. +struct canfd_frame {
  219. + canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
  220. + __u8 len; /* frame payload length in byte */
  221. + __u8 flags; /* additional flags for CAN FD */
  222. + __u8 __res0; /* reserved / padding */
  223. + __u8 __res1; /* reserved / padding */
  224. + __u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
  225. +};
  226. +
  227. +/*
  228. + * defined bits for canxl_frame.flags
  229. + *
  230. + * The canxl_frame.flags element contains two bits CANXL_XLF and CANXL_SEC
  231. + * and shares the relative position of the struct can[fd]_frame.len element.
  232. + * The CANXL_XLF bit ALWAYS needs to be set to indicate a valid CAN XL frame.
  233. + * As a side effect setting this bit intentionally breaks the length checks
  234. + * for Classical CAN and CAN FD frames.
  235. + *
  236. + * Undefined bits in canxl_frame.flags are reserved and shall be set to zero.
  237. + */
  238. +#define CANXL_XLF 0x80 /* mandatory CAN XL frame flag (must always be set!) */
  239. +#define CANXL_SEC 0x01 /* Simple Extended Content (security/segmentation) */
  240. +
  241. +/**
  242. + * struct canxl_frame - CAN with e'X'tended frame 'L'ength frame structure
  243. + * @prio: 11 bit arbitration priority with zero'ed CAN_*_FLAG flags
  244. + * @flags: additional flags for CAN XL
  245. + * @sdt: SDU (service data unit) type
  246. + * @len: frame payload length in byte (CANXL_MIN_DLEN .. CANXL_MAX_DLEN)
  247. + * @af: acceptance field
  248. + * @data: CAN XL frame payload (CANXL_MIN_DLEN .. CANXL_MAX_DLEN byte)
  249. + *
  250. + * @prio shares the same position as @can_id from struct can[fd]_frame.
  251. + */
  252. +struct canxl_frame {
  253. + canid_t prio; /* 11 bit priority for arbitration (canid_t) */
  254. + __u8 flags; /* additional flags for CAN XL */
  255. + __u8 sdt; /* SDU (service data unit) type */
  256. + __u16 len; /* frame payload length in byte */
  257. + __u32 af; /* acceptance field */
  258. + __u8 data[CANXL_MAX_DLEN];
  259. +};
  260. +
  261. +#define CAN_MTU (sizeof(struct can_frame))
  262. +#define CANFD_MTU (sizeof(struct canfd_frame))
  263. +#define CANXL_MTU (sizeof(struct canxl_frame))
  264. +#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
  265. +#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
  266. +#define CANXL_MAX_MTU CANXL_MTU
  267. +
  268. +/* particular protocols of the protocol family PF_CAN */
  269. +#define CAN_RAW 1 /* RAW sockets */
  270. +#define CAN_BCM 2 /* Broadcast Manager */
  271. +#define CAN_TP16 3 /* VAG Transport Protocol v1.6 */
  272. +#define CAN_TP20 4 /* VAG Transport Protocol v2.0 */
  273. +#define CAN_MCNET 5 /* Bosch MCNet */
  274. +#define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */
  275. +#define CAN_J1939 7 /* SAE J1939 */
  276. +#define CAN_NPROTO 8
  277. +
  278. +#define SOL_CAN_BASE 100
  279. +
  280. +/*
  281. + * This typedef was introduced in Linux v3.1-rc2
  282. + * (commit 6602a4b net: Make userland include of netlink.h more sane)
  283. + * in <linux/socket.h>. It must be duplicated here to make the CAN
  284. + * headers self-contained.
  285. + */
  286. +typedef unsigned short __kernel_sa_family_t;
  287. +
  288. +/**
  289. + * struct sockaddr_can - the sockaddr structure for CAN sockets
  290. + * @can_family: address family number AF_CAN.
  291. + * @can_ifindex: CAN network interface index.
  292. + * @can_addr: protocol specific address information
  293. + */
  294. +struct sockaddr_can {
  295. + __kernel_sa_family_t can_family;
  296. + int can_ifindex;
  297. + union {
  298. + /* transport protocol class address information (e.g. ISOTP) */
  299. + struct { canid_t rx_id, tx_id; } tp;
  300. +
  301. + /* J1939 address information */
  302. + struct {
  303. + /* 8 byte name when using dynamic addressing */
  304. + __u64 name;
  305. +
  306. + /* pgn:
  307. + * 8 bit: PS in PDU2 case, else 0
  308. + * 8 bit: PF
  309. + * 1 bit: DP
  310. + * 1 bit: reserved
  311. + */
  312. + __u32 pgn;
  313. +
  314. + /* 1 byte address */
  315. + __u8 addr;
  316. + } j1939;
  317. +
  318. + /* reserved for future CAN protocols address information */
  319. + } can_addr;
  320. +};
  321. +
  322. +/**
  323. + * struct can_filter - CAN ID based filter in can_register().
  324. + * @can_id: relevant bits of CAN ID which are not masked out.
  325. + * @can_mask: CAN mask (see description)
  326. + *
  327. + * Description:
  328. + * A filter matches, when
  329. + *
  330. + * <received_can_id> & mask == can_id & mask
  331. + *
  332. + * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
  333. + * filter for error message frames (CAN_ERR_FLAG bit set in mask).
  334. + */
  335. +struct can_filter {
  336. + canid_t can_id;
  337. + canid_t can_mask;
  338. +};
  339. +
  340. +#define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
  341. +#define CAN_RAW_FILTER_MAX 512 /* maximum number of can_filter set via setsockopt() */
  342. +
  343. +#endif /* !_UAPI_CAN_H */
  344. diff --git a/include/linux/can/Makefile.am b/include/linux/can/Makefile.am
  345. new file mode 100644
  346. index 000000000000..2d0288766894
  347. --- /dev/null
  348. +++ b/include/linux/can/Makefile.am
  349. @@ -0,0 +1 @@
  350. +noinst_HEADERS = netlink.h
  351. diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h
  352. new file mode 100644
  353. index 000000000000..02ec32d69474
  354. --- /dev/null
  355. +++ b/include/linux/can/netlink.h
  356. @@ -0,0 +1,185 @@
  357. +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  358. +/*
  359. + * linux/can/netlink.h
  360. + *
  361. + * Definitions for the CAN netlink interface
  362. + *
  363. + * Copyright (c) 2009 Wolfgang Grandegger <wg@grandegger.com>
  364. + *
  365. + * This program is free software; you can redistribute it and/or modify
  366. + * it under the terms of the version 2 of the GNU General Public License
  367. + * as published by the Free Software Foundation
  368. + *
  369. + * This program is distributed in the hope that it will be useful,
  370. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  371. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  372. + * GNU General Public License for more details.
  373. + */
  374. +
  375. +#ifndef _UAPI_CAN_NETLINK_H
  376. +#define _UAPI_CAN_NETLINK_H
  377. +
  378. +#include <linux/types.h>
  379. +
  380. +/*
  381. + * CAN bit-timing parameters
  382. + *
  383. + * For further information, please read chapter "8 BIT TIMING
  384. + * REQUIREMENTS" of the "Bosch CAN Specification version 2.0"
  385. + * at http://www.semiconductors.bosch.de/pdf/can2spec.pdf.
  386. + */
  387. +struct can_bittiming {
  388. + __u32 bitrate; /* Bit-rate in bits/second */
  389. + __u32 sample_point; /* Sample point in one-tenth of a percent */
  390. + __u32 tq; /* Time quanta (TQ) in nanoseconds */
  391. + __u32 prop_seg; /* Propagation segment in TQs */
  392. + __u32 phase_seg1; /* Phase buffer segment 1 in TQs */
  393. + __u32 phase_seg2; /* Phase buffer segment 2 in TQs */
  394. + __u32 sjw; /* Synchronisation jump width in TQs */
  395. + __u32 brp; /* Bit-rate prescaler */
  396. +};
  397. +
  398. +/*
  399. + * CAN hardware-dependent bit-timing constant
  400. + *
  401. + * Used for calculating and checking bit-timing parameters
  402. + */
  403. +struct can_bittiming_const {
  404. + char name[16]; /* Name of the CAN controller hardware */
  405. + __u32 tseg1_min; /* Time segment 1 = prop_seg + phase_seg1 */
  406. + __u32 tseg1_max;
  407. + __u32 tseg2_min; /* Time segment 2 = phase_seg2 */
  408. + __u32 tseg2_max;
  409. + __u32 sjw_max; /* Synchronisation jump width */
  410. + __u32 brp_min; /* Bit-rate prescaler */
  411. + __u32 brp_max;
  412. + __u32 brp_inc;
  413. +};
  414. +
  415. +/*
  416. + * CAN clock parameters
  417. + */
  418. +struct can_clock {
  419. + __u32 freq; /* CAN system clock frequency in Hz */
  420. +};
  421. +
  422. +/*
  423. + * CAN operational and error states
  424. + */
  425. +enum can_state {
  426. + CAN_STATE_ERROR_ACTIVE = 0, /* RX/TX error count < 96 */
  427. + CAN_STATE_ERROR_WARNING, /* RX/TX error count < 128 */
  428. + CAN_STATE_ERROR_PASSIVE, /* RX/TX error count < 256 */
  429. + CAN_STATE_BUS_OFF, /* RX/TX error count >= 256 */
  430. + CAN_STATE_STOPPED, /* Device is stopped */
  431. + CAN_STATE_SLEEPING, /* Device is sleeping */
  432. + CAN_STATE_MAX
  433. +};
  434. +
  435. +/*
  436. + * CAN bus error counters
  437. + */
  438. +struct can_berr_counter {
  439. + __u16 txerr;
  440. + __u16 rxerr;
  441. +};
  442. +
  443. +/*
  444. + * CAN controller mode
  445. + */
  446. +struct can_ctrlmode {
  447. + __u32 mask;
  448. + __u32 flags;
  449. +};
  450. +
  451. +#define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
  452. +#define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
  453. +#define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
  454. +#define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
  455. +#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
  456. +#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
  457. +#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
  458. +#define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
  459. +#define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */
  460. +#define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calculates TDCV */
  461. +#define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user */
  462. +
  463. +/*
  464. + * CAN device statistics
  465. + */
  466. +struct can_device_stats {
  467. + __u32 bus_error; /* Bus errors */
  468. + __u32 error_warning; /* Changes to error warning state */
  469. + __u32 error_passive; /* Changes to error passive state */
  470. + __u32 bus_off; /* Changes to bus off state */
  471. + __u32 arbitration_lost; /* Arbitration lost errors */
  472. + __u32 restarts; /* CAN controller re-starts */
  473. +};
  474. +
  475. +/*
  476. + * CAN netlink interface
  477. + */
  478. +enum {
  479. + IFLA_CAN_UNSPEC,
  480. + IFLA_CAN_BITTIMING,
  481. + IFLA_CAN_BITTIMING_CONST,
  482. + IFLA_CAN_CLOCK,
  483. + IFLA_CAN_STATE,
  484. + IFLA_CAN_CTRLMODE,
  485. + IFLA_CAN_RESTART_MS,
  486. + IFLA_CAN_RESTART,
  487. + IFLA_CAN_BERR_COUNTER,
  488. + IFLA_CAN_DATA_BITTIMING,
  489. + IFLA_CAN_DATA_BITTIMING_CONST,
  490. + IFLA_CAN_TERMINATION,
  491. + IFLA_CAN_TERMINATION_CONST,
  492. + IFLA_CAN_BITRATE_CONST,
  493. + IFLA_CAN_DATA_BITRATE_CONST,
  494. + IFLA_CAN_BITRATE_MAX,
  495. + IFLA_CAN_TDC,
  496. + IFLA_CAN_CTRLMODE_EXT,
  497. +
  498. + /* add new constants above here */
  499. + __IFLA_CAN_MAX,
  500. + IFLA_CAN_MAX = __IFLA_CAN_MAX - 1
  501. +};
  502. +
  503. +/*
  504. + * CAN FD Transmitter Delay Compensation (TDC)
  505. + *
  506. + * Please refer to struct can_tdc_const and can_tdc in
  507. + * include/linux/can/bittiming.h for further details.
  508. + */
  509. +enum {
  510. + IFLA_CAN_TDC_UNSPEC,
  511. + IFLA_CAN_TDC_TDCV_MIN, /* u32 */
  512. + IFLA_CAN_TDC_TDCV_MAX, /* u32 */
  513. + IFLA_CAN_TDC_TDCO_MIN, /* u32 */
  514. + IFLA_CAN_TDC_TDCO_MAX, /* u32 */
  515. + IFLA_CAN_TDC_TDCF_MIN, /* u32 */
  516. + IFLA_CAN_TDC_TDCF_MAX, /* u32 */
  517. + IFLA_CAN_TDC_TDCV, /* u32 */
  518. + IFLA_CAN_TDC_TDCO, /* u32 */
  519. + IFLA_CAN_TDC_TDCF, /* u32 */
  520. +
  521. + /* add new constants above here */
  522. + __IFLA_CAN_TDC,
  523. + IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1
  524. +};
  525. +
  526. +/*
  527. + * IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters
  528. + */
  529. +enum {
  530. + IFLA_CAN_CTRLMODE_UNSPEC,
  531. + IFLA_CAN_CTRLMODE_SUPPORTED, /* u32 */
  532. +
  533. + /* add new constants above here */
  534. + __IFLA_CAN_CTRLMODE,
  535. + IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1
  536. +};
  537. +
  538. +/* u16 termination range: 1..65535 Ohms */
  539. +#define CAN_TERMINATION_DISABLED 0
  540. +
  541. +#endif /* !_UAPI_CAN_NETLINK_H */
  542. --
  543. 2.32.0