Skip to content

Commit d1df702

Browse files
authored
Merge pull request #3247 from marcelbuesing/canxl
Add linux canxl constants and canxl frame struct
2 parents fe563a8 + ca85ccb commit d1df702

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

libc-test/build.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -3469,6 +3469,8 @@ fn test_linux(target: &str) {
34693469
"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
34703470
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,
34713471

3472+
// FIXME: requires >= 6.1 kernel headers
3473+
"canxl_frame" => true,
34723474
_ => false,
34733475
}
34743476
});
@@ -3651,7 +3653,22 @@ fn test_linux(target: &str) {
36513653
"FUTEX_LOCK_PI2" => true,
36523654

36533655
// Added in linux 6.1
3654-
"STATX_DIOALIGN" => true,
3656+
"STATX_DIOALIGN"
3657+
| "CAN_RAW_XL_FRAMES"
3658+
| "CANXL_HDR_SIZE"
3659+
| "CANXL_MAX_DLC"
3660+
| "CANXL_MAX_DLC_MASK"
3661+
| "CANXL_MAX_DLEN"
3662+
| "CANXL_MAX_MTU"
3663+
| "CANXL_MIN_DLC"
3664+
| "CANXL_MIN_DLEN"
3665+
| "CANXL_MIN_MTU"
3666+
| "CANXL_MTU"
3667+
| "CANXL_PRIO_BITS"
3668+
| "CANXL_PRIO_MASK"
3669+
| "CANXL_SEC"
3670+
| "CANXL_XLF"
3671+
=> true,
36553672

36563673
// FIXME: Parts of netfilter/nfnetlink*.h require more recent kernel headers:
36573674
| "RTNLGRP_MCTP_IFADDR" // linux v5.17+

libc-test/semver/linux.txt

+15
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,20 @@ CAN_RAW_LOOPBACK
237237
CAN_RAW_RECV_OWN_MSGS
238238
CAN_RAW_FD_FRAMES
239239
CAN_RAW_JOIN_FILTERS
240+
CAN_RAW_XL_FRAMES
241+
CANXL_HDR_SIZE
242+
CANXL_MAX_DLC
243+
CANXL_MAX_DLC_MASK
244+
CANXL_MAX_DLEN
245+
CANXL_MAX_MTU
246+
CANXL_MIN_DLC
247+
CANXL_MIN_DLEN
248+
CANXL_MIN_MTU
249+
CANXL_MTU
250+
CANXL_PRIO_BITS
251+
CANXL_PRIO_MASK
252+
CANXL_SEC
253+
CANXL_XLF
240254
CBAUD
241255
CBAUDEX
242256
CLD_CONTINUED
@@ -3056,6 +3070,7 @@ can_err_mask_t
30563070
can_filter
30573071
can_frame
30583072
canfd_frame
3073+
canxl_frame
30593074
canid_t
30603075
chroot
30613076
clearenv

src/unix/linux_like/linux/align.rs

+11
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ macro_rules! expand_align {
176176
__res1: u8,
177177
pub data: [u8; CANFD_MAX_DLEN],
178178
}
179+
180+
#[repr(align(8))]
181+
#[allow(missing_debug_implementations)]
182+
pub struct canxl_frame {
183+
pub prio: canid_t,
184+
pub flags: u8,
185+
pub sdt: u8,
186+
pub len: u16,
187+
pub af: u32,
188+
pub data: [u8; CANXL_MAX_DLEN],
189+
}
179190
}
180191
};
181192
}

src/unix/linux_like/linux/mod.rs

+19
Original file line numberDiff line numberDiff line change
@@ -3723,9 +3723,11 @@ pub const CAN_ERR_FLAG: canid_t = 0x20000000;
37233723
pub const CAN_SFF_MASK: canid_t = 0x000007FF;
37243724
pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF;
37253725
pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF;
3726+
pub const CANXL_PRIO_MASK: ::canid_t = CAN_SFF_MASK;
37263727

37273728
pub const CAN_SFF_ID_BITS: ::c_int = 11;
37283729
pub const CAN_EFF_ID_BITS: ::c_int = 29;
3730+
pub const CANXL_PRIO_BITS: ::c_int = CAN_SFF_ID_BITS;
37293731

37303732
pub const CAN_MAX_DLC: ::c_int = 8;
37313733
pub const CAN_MAX_DLEN: usize = 8;
@@ -3735,10 +3737,26 @@ pub const CANFD_MAX_DLEN: usize = 64;
37353737
pub const CANFD_BRS: ::c_int = 0x01;
37363738
pub const CANFD_ESI: ::c_int = 0x02;
37373739

3740+
pub const CANXL_MIN_DLC: ::c_int = 0;
3741+
pub const CANXL_MAX_DLC: ::c_int = 2047;
3742+
pub const CANXL_MAX_DLC_MASK: ::c_int = 0x07FF;
3743+
pub const CANXL_MIN_DLEN: usize = 1;
3744+
pub const CANXL_MAX_DLEN: usize = 2048;
3745+
3746+
pub const CANXL_XLF: ::c_int = 0x80;
3747+
pub const CANXL_SEC: ::c_int = 0x01;
3748+
37383749
cfg_if! {
37393750
if #[cfg(libc_align)] {
37403751
pub const CAN_MTU: usize = ::mem::size_of::<can_frame>();
37413752
pub const CANFD_MTU: usize = ::mem::size_of::<canfd_frame>();
3753+
pub const CANXL_MTU: usize = ::mem::size_of::<canxl_frame>();
3754+
// FIXME: use `core::mem::offset_of!` once that is available
3755+
// https://github.com/rust-lang/rfcs/pull/3308
3756+
// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data);
3757+
pub const CANXL_HDR_SIZE: usize = 12;
3758+
pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64;
3759+
pub const CANXL_MAX_MTU: usize = CANXL_MTU;
37423760
}
37433761
}
37443762

@@ -3764,6 +3782,7 @@ pub const CAN_RAW_LOOPBACK: ::c_int = 3;
37643782
pub const CAN_RAW_RECV_OWN_MSGS: ::c_int = 4;
37653783
pub const CAN_RAW_FD_FRAMES: ::c_int = 5;
37663784
pub const CAN_RAW_JOIN_FILTERS: ::c_int = 6;
3785+
pub const CAN_RAW_XL_FRAMES: ::c_int = 7;
37673786

37683787
// linux/can/j1939.h
37693788
pub const SOL_CAN_J1939: ::c_int = SOL_CAN_BASE + CAN_J1939;

0 commit comments

Comments
 (0)