Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is auto-generated. Modifications will be lost. |
| 3 | * |
| 4 | * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ |
| 5 | * for more information. |
| 6 | */ |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 7 | #ifndef _UAPI_CAN_H |
| 8 | #define _UAPI_CAN_H |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 9 | #include <linux/types.h> |
| 10 | #include <linux/socket.h> |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 11 | #include <linux/stddef.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 12 | #define CAN_EFF_FLAG 0x80000000U |
| 13 | #define CAN_RTR_FLAG 0x40000000U |
| 14 | #define CAN_ERR_FLAG 0x20000000U |
| 15 | #define CAN_SFF_MASK 0x000007FFU |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 16 | #define CAN_EFF_MASK 0x1FFFFFFFU |
| 17 | #define CAN_ERR_MASK 0x1FFFFFFFU |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 18 | #define CANXL_PRIO_MASK CAN_SFF_MASK |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 19 | typedef __u32 canid_t; |
| 20 | #define CAN_SFF_ID_BITS 11 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 21 | #define CAN_EFF_ID_BITS 29 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 22 | #define CANXL_PRIO_BITS CAN_SFF_ID_BITS |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 23 | typedef __u32 can_err_mask_t; |
| 24 | #define CAN_MAX_DLC 8 |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 25 | #define CAN_MAX_RAW_DLC 15 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 26 | #define CAN_MAX_DLEN 8 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 27 | #define CANFD_MAX_DLC 15 |
| 28 | #define CANFD_MAX_DLEN 64 |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 29 | #define CANXL_MIN_DLC 0 |
| 30 | #define CANXL_MAX_DLC 2047 |
| 31 | #define CANXL_MAX_DLC_MASK 0x07FF |
| 32 | #define CANXL_MIN_DLEN 1 |
| 33 | #define CANXL_MAX_DLEN 2048 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 34 | struct can_frame { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 35 | canid_t can_id; |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 36 | union { |
| 37 | __u8 len; |
| 38 | __u8 can_dlc; |
Christopher Ferris | a9750ed | 2021-05-03 14:02:49 -0700 | [diff] [blame] | 39 | } __attribute__((packed)); |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 40 | __u8 __pad; |
| 41 | __u8 __res0; |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 42 | __u8 len8_dlc; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 43 | __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8))); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 44 | }; |
| 45 | #define CANFD_BRS 0x01 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 46 | #define CANFD_ESI 0x02 |
Christopher Ferris | 3a39c0b | 2021-09-02 00:03:38 +0000 | [diff] [blame] | 47 | #define CANFD_FDF 0x04 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 48 | struct canfd_frame { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 49 | canid_t can_id; |
| 50 | __u8 len; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 51 | __u8 flags; |
| 52 | __u8 __res0; |
| 53 | __u8 __res1; |
| 54 | __u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8))); |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 55 | }; |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 56 | #define CANXL_XLF 0x80 |
| 57 | #define CANXL_SEC 0x01 |
| 58 | struct canxl_frame { |
| 59 | canid_t prio; |
| 60 | __u8 flags; |
| 61 | __u8 sdt; |
| 62 | __u16 len; |
| 63 | __u32 af; |
| 64 | __u8 data[CANXL_MAX_DLEN]; |
| 65 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 66 | #define CAN_MTU (sizeof(struct can_frame)) |
| 67 | #define CANFD_MTU (sizeof(struct canfd_frame)) |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 68 | #define CANXL_MTU (sizeof(struct canxl_frame)) |
| 69 | #define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data)) |
| 70 | #define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64) |
| 71 | #define CANXL_MAX_MTU CANXL_MTU |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 72 | #define CAN_RAW 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 73 | #define CAN_BCM 2 |
| 74 | #define CAN_TP16 3 |
| 75 | #define CAN_TP20 4 |
| 76 | #define CAN_MCNET 5 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 77 | #define CAN_ISOTP 6 |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 78 | #define CAN_J1939 7 |
| 79 | #define CAN_NPROTO 8 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 80 | #define SOL_CAN_BASE 100 |
| 81 | struct sockaddr_can { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 82 | __kernel_sa_family_t can_family; |
| 83 | int can_ifindex; |
| 84 | union { |
| 85 | struct { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 86 | canid_t rx_id, tx_id; |
| 87 | } tp; |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 88 | struct { |
| 89 | __u64 name; |
| 90 | __u32 pgn; |
| 91 | __u8 addr; |
| 92 | } j1939; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 93 | } can_addr; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 94 | }; |
| 95 | struct can_filter { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 96 | canid_t can_id; |
| 97 | canid_t can_mask; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 98 | }; |
| 99 | #define CAN_INV_FILTER 0x20000000U |
| 100 | #endif |