blob: a913d734817ebef263f8207e026e9fbcc365743a [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 Ferrisba8d4f42014-09-03 19:56:49 -07007#ifndef _UAPI_CAN_H
8#define _UAPI_CAN_H
Ben Cheng655a7c02013-10-16 16:09:24 -07009#include <linux/types.h>
10#include <linux/socket.h>
Christopher Ferris6cd53a52022-12-12 23:39:16 +000011#include <linux/stddef.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070012#define CAN_EFF_FLAG 0x80000000U
13#define CAN_RTR_FLAG 0x40000000U
14#define CAN_ERR_FLAG 0x20000000U
15#define CAN_SFF_MASK 0x000007FFU
Ben Cheng655a7c02013-10-16 16:09:24 -070016#define CAN_EFF_MASK 0x1FFFFFFFU
17#define CAN_ERR_MASK 0x1FFFFFFFU
Christopher Ferris6cd53a52022-12-12 23:39:16 +000018#define CANXL_PRIO_MASK CAN_SFF_MASK
Ben Cheng655a7c02013-10-16 16:09:24 -070019typedef __u32 canid_t;
20#define CAN_SFF_ID_BITS 11
Ben Cheng655a7c02013-10-16 16:09:24 -070021#define CAN_EFF_ID_BITS 29
Christopher Ferris6cd53a52022-12-12 23:39:16 +000022#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
Ben Cheng655a7c02013-10-16 16:09:24 -070023typedef __u32 can_err_mask_t;
24#define CAN_MAX_DLC 8
Christopher Ferris05667cd2021-02-16 16:01:34 -080025#define CAN_MAX_RAW_DLC 15
Ben Cheng655a7c02013-10-16 16:09:24 -070026#define CAN_MAX_DLEN 8
Ben Cheng655a7c02013-10-16 16:09:24 -070027#define CANFD_MAX_DLC 15
28#define CANFD_MAX_DLEN 64
Christopher Ferris6cd53a52022-12-12 23:39:16 +000029#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 Cheng655a7c02013-10-16 16:09:24 -070034struct can_frame {
Tao Baod7db5942015-01-28 10:07:51 -080035 canid_t can_id;
Christopher Ferris05667cd2021-02-16 16:01:34 -080036 union {
37 __u8 len;
38 __u8 can_dlc;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070039 } __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -080040 __u8 __pad;
41 __u8 __res0;
Christopher Ferris05667cd2021-02-16 16:01:34 -080042 __u8 len8_dlc;
Tao Baod7db5942015-01-28 10:07:51 -080043 __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
Ben Cheng655a7c02013-10-16 16:09:24 -070044};
45#define CANFD_BRS 0x01
Ben Cheng655a7c02013-10-16 16:09:24 -070046#define CANFD_ESI 0x02
Christopher Ferris3a39c0b2021-09-02 00:03:38 +000047#define CANFD_FDF 0x04
Ben Cheng655a7c02013-10-16 16:09:24 -070048struct canfd_frame {
Tao Baod7db5942015-01-28 10:07:51 -080049 canid_t can_id;
50 __u8 len;
Tao Baod7db5942015-01-28 10:07:51 -080051 __u8 flags;
52 __u8 __res0;
53 __u8 __res1;
54 __u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
Ben Cheng655a7c02013-10-16 16:09:24 -070055};
Christopher Ferris6cd53a52022-12-12 23:39:16 +000056#define CANXL_XLF 0x80
57#define CANXL_SEC 0x01
Christopher Ferris7f4c8372024-06-03 14:22:19 -070058#define CANXL_VCID_OFFSET 16
59#define CANXL_VCID_VAL_MASK 0xFFUL
60#define CANXL_VCID_MASK (CANXL_VCID_VAL_MASK << CANXL_VCID_OFFSET)
Christopher Ferris6cd53a52022-12-12 23:39:16 +000061struct canxl_frame {
62 canid_t prio;
63 __u8 flags;
64 __u8 sdt;
65 __u16 len;
66 __u32 af;
67 __u8 data[CANXL_MAX_DLEN];
68};
Ben Cheng655a7c02013-10-16 16:09:24 -070069#define CAN_MTU (sizeof(struct can_frame))
70#define CANFD_MTU (sizeof(struct canfd_frame))
Christopher Ferris6cd53a52022-12-12 23:39:16 +000071#define CANXL_MTU (sizeof(struct canxl_frame))
72#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
73#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
74#define CANXL_MAX_MTU CANXL_MTU
Ben Cheng655a7c02013-10-16 16:09:24 -070075#define CAN_RAW 1
Ben Cheng655a7c02013-10-16 16:09:24 -070076#define CAN_BCM 2
77#define CAN_TP16 3
78#define CAN_TP20 4
79#define CAN_MCNET 5
Ben Cheng655a7c02013-10-16 16:09:24 -070080#define CAN_ISOTP 6
Christopher Ferris9584fa42019-12-09 15:36:13 -080081#define CAN_J1939 7
82#define CAN_NPROTO 8
Ben Cheng655a7c02013-10-16 16:09:24 -070083#define SOL_CAN_BASE 100
84struct sockaddr_can {
Tao Baod7db5942015-01-28 10:07:51 -080085 __kernel_sa_family_t can_family;
86 int can_ifindex;
87 union {
88 struct {
Tao Baod7db5942015-01-28 10:07:51 -080089 canid_t rx_id, tx_id;
90 } tp;
Christopher Ferris9584fa42019-12-09 15:36:13 -080091 struct {
92 __u64 name;
93 __u32 pgn;
94 __u8 addr;
95 } j1939;
Tao Baod7db5942015-01-28 10:07:51 -080096 } can_addr;
Ben Cheng655a7c02013-10-16 16:09:24 -070097};
98struct can_filter {
Tao Baod7db5942015-01-28 10:07:51 -080099 canid_t can_id;
100 canid_t can_mask;
Ben Cheng655a7c02013-10-16 16:09:24 -0700101};
102#define CAN_INV_FILTER 0x20000000U
103#endif