blob: 1365dbac9f30ad6989b77cc7b8a5c7c66f4ee411 [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070019#ifndef _UAPI_CAN_H
20#define _UAPI_CAN_H
Ben Cheng655a7c02013-10-16 16:09:24 -070021#include <linux/types.h>
22#include <linux/socket.h>
Christopher Ferris6cd53a52022-12-12 23:39:16 +000023#include <linux/stddef.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070024#define CAN_EFF_FLAG 0x80000000U
25#define CAN_RTR_FLAG 0x40000000U
26#define CAN_ERR_FLAG 0x20000000U
27#define CAN_SFF_MASK 0x000007FFU
Ben Cheng655a7c02013-10-16 16:09:24 -070028#define CAN_EFF_MASK 0x1FFFFFFFU
29#define CAN_ERR_MASK 0x1FFFFFFFU
Christopher Ferris6cd53a52022-12-12 23:39:16 +000030#define CANXL_PRIO_MASK CAN_SFF_MASK
Ben Cheng655a7c02013-10-16 16:09:24 -070031typedef __u32 canid_t;
32#define CAN_SFF_ID_BITS 11
Ben Cheng655a7c02013-10-16 16:09:24 -070033#define CAN_EFF_ID_BITS 29
Christopher Ferris6cd53a52022-12-12 23:39:16 +000034#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
Ben Cheng655a7c02013-10-16 16:09:24 -070035typedef __u32 can_err_mask_t;
36#define CAN_MAX_DLC 8
Christopher Ferris05667cd2021-02-16 16:01:34 -080037#define CAN_MAX_RAW_DLC 15
Ben Cheng655a7c02013-10-16 16:09:24 -070038#define CAN_MAX_DLEN 8
Ben Cheng655a7c02013-10-16 16:09:24 -070039#define CANFD_MAX_DLC 15
40#define CANFD_MAX_DLEN 64
Christopher Ferris6cd53a52022-12-12 23:39:16 +000041#define CANXL_MIN_DLC 0
42#define CANXL_MAX_DLC 2047
43#define CANXL_MAX_DLC_MASK 0x07FF
44#define CANXL_MIN_DLEN 1
45#define CANXL_MAX_DLEN 2048
Ben Cheng655a7c02013-10-16 16:09:24 -070046struct can_frame {
Tao Baod7db5942015-01-28 10:07:51 -080047 canid_t can_id;
Christopher Ferris05667cd2021-02-16 16:01:34 -080048 union {
49 __u8 len;
50 __u8 can_dlc;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070051 } __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -080052 __u8 __pad;
53 __u8 __res0;
Christopher Ferris05667cd2021-02-16 16:01:34 -080054 __u8 len8_dlc;
Tao Baod7db5942015-01-28 10:07:51 -080055 __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
Ben Cheng655a7c02013-10-16 16:09:24 -070056};
57#define CANFD_BRS 0x01
Ben Cheng655a7c02013-10-16 16:09:24 -070058#define CANFD_ESI 0x02
Christopher Ferris3a39c0b2021-09-02 00:03:38 +000059#define CANFD_FDF 0x04
Ben Cheng655a7c02013-10-16 16:09:24 -070060struct canfd_frame {
Tao Baod7db5942015-01-28 10:07:51 -080061 canid_t can_id;
62 __u8 len;
Tao Baod7db5942015-01-28 10:07:51 -080063 __u8 flags;
64 __u8 __res0;
65 __u8 __res1;
66 __u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
Ben Cheng655a7c02013-10-16 16:09:24 -070067};
Christopher Ferris6cd53a52022-12-12 23:39:16 +000068#define CANXL_XLF 0x80
69#define CANXL_SEC 0x01
70struct canxl_frame {
71 canid_t prio;
72 __u8 flags;
73 __u8 sdt;
74 __u16 len;
75 __u32 af;
76 __u8 data[CANXL_MAX_DLEN];
77};
Ben Cheng655a7c02013-10-16 16:09:24 -070078#define CAN_MTU (sizeof(struct can_frame))
79#define CANFD_MTU (sizeof(struct canfd_frame))
Christopher Ferris6cd53a52022-12-12 23:39:16 +000080#define CANXL_MTU (sizeof(struct canxl_frame))
81#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
82#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
83#define CANXL_MAX_MTU CANXL_MTU
Ben Cheng655a7c02013-10-16 16:09:24 -070084#define CAN_RAW 1
Ben Cheng655a7c02013-10-16 16:09:24 -070085#define CAN_BCM 2
86#define CAN_TP16 3
87#define CAN_TP20 4
88#define CAN_MCNET 5
Ben Cheng655a7c02013-10-16 16:09:24 -070089#define CAN_ISOTP 6
Christopher Ferris9584fa42019-12-09 15:36:13 -080090#define CAN_J1939 7
91#define CAN_NPROTO 8
Ben Cheng655a7c02013-10-16 16:09:24 -070092#define SOL_CAN_BASE 100
93struct sockaddr_can {
Tao Baod7db5942015-01-28 10:07:51 -080094 __kernel_sa_family_t can_family;
95 int can_ifindex;
96 union {
97 struct {
Tao Baod7db5942015-01-28 10:07:51 -080098 canid_t rx_id, tx_id;
99 } tp;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800100 struct {
101 __u64 name;
102 __u32 pgn;
103 __u8 addr;
104 } j1939;
Tao Baod7db5942015-01-28 10:07:51 -0800105 } can_addr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700106};
107struct can_filter {
Tao Baod7db5942015-01-28 10:07:51 -0800108 canid_t can_id;
109 canid_t can_mask;
Ben Cheng655a7c02013-10-16 16:09:24 -0700110};
111#define CAN_INV_FILTER 0x20000000U
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800112#define CAN_RAW_FILTER_MAX 512
Ben Cheng655a7c02013-10-16 16:09:24 -0700113#endif