Skip to content

linux: Add devmem constants and structs #4299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4063,6 +4063,10 @@ fn test_linux(target: &str) {
// FIXME(linux): Requires >= 6.9 kernel headers.
"epoll_params" => true,

// FIXME(linux): Requires >= 6.12 kernel headers.
"dmabuf_cmsg" |
"dmabuf_token" => true,

_ => false,
}
});
Expand Down Expand Up @@ -4165,6 +4169,26 @@ fn test_linux(target: &str) {
{
return true;
}
// FIXME(musl): Not in musl yet
if name == "SO_NETNS_COOKIE"
|| name == "SO_BUF_LOCK"
|| name == "SO_RESERVE_MEM"
|| name == "SO_TXREHASH"
|| name == "SO_RCVMARK"
|| name == "SO_PASSPIDFD"
|| name == "SO_PEERPIDFD"
|| name == "SO_DEVMEM_LINEAR"
|| name == "SO_DEVMEM_DMABUF"
|| name == "SO_DEVMEM_DONTNEED"
{
return true;
}
// FIXME(musl): Not in musl yet
if name == "SCM_DEVMEM_LINEAR"
|| name == "SCM_DEVMEM_DMABUF"
{
return true;
}
}
match name {
// These constants are not available if gnu headers have been included
Expand Down Expand Up @@ -4459,6 +4483,13 @@ fn test_linux(target: &str) {
// FIXME(linux): Requires >= 6.12 kernel headers.
"SOF_TIMESTAMPING_OPT_RX_FILTER" => true,

// FIXME(linux): Requires >= 6.12 kernel headers.
"SO_DEVMEM_LINEAR"
| "SO_DEVMEM_DMABUF"
| "SO_DEVMEM_DONTNEED"
| "SCM_DEVMEM_LINEAR"
| "SCM_DEVMEM_DMABUF" => true,

_ => false,
}
});
Expand Down
12 changes: 12 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,8 @@ SCHED_OTHER
SCHED_RESET_ON_FORK
SCHED_RR
SCM_CREDENTIALS
SCM_DEVMEM_DMABUF
SCM_DEVMEM_LINEAR
SCM_J1939_DEST_ADDR
SCM_J1939_DEST_NAME
SCM_J1939_ERRQUEUE
Expand Down Expand Up @@ -2953,8 +2955,12 @@ SOL_X25
SOL_XDP
SOMAXCONN
SO_BINDTODEVICE
SO_BUF_LOCK
SO_BUSY_POLL
SO_BUSY_POLL_BUDGET
SO_DEVMEM_DMABUF
SO_DEVMEM_DONTNEED
SO_DEVMEM_LINEAR
SO_DOMAIN
SO_EE_OFFENDER
SO_EE_ORIGIN_ICMP
Expand All @@ -2968,20 +2974,26 @@ SO_J1939_FILTER
SO_J1939_PROMISC
SO_J1939_SEND_PRIO
SO_MARK
SO_NETNS_COOKIE
SO_ORIGINAL_DST
SO_PASSCRED
SO_PASSPIDFD
SO_PASSSEC
SO_PEEK_OFF
SO_PEERCRED
SO_PEERPIDFD
SO_PEERSEC
SO_PREFER_BUSY_POLL
SO_RCVBUFFORCE
SO_RCVMARK
SO_RESERVE_MEM
SO_REUSEPORT
SO_RXQ_OVFL
SO_SNDBUFFORCE
SO_TIMESTAMP
SO_TIMESTAMPING
SO_TIMESTAMPNS
SO_TXREHASH
SPLICE_F_GIFT
SPLICE_F_MORE
SPLICE_F_MOVE
Expand Down
13 changes: 13 additions & 0 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ cfg_if! {
}
pub const SO_PREFER_BUSY_POLL: c_int = 69;
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
pub const SO_NETNS_COOKIE: c_int = 71;
pub const SO_BUF_LOCK: c_int = 72;
pub const SO_RESERVE_MEM: c_int = 73;
pub const SO_TXREHASH: c_int = 74;
pub const SO_RCVMARK: c_int = 75;
pub const SO_PASSPIDFD: c_int = 76;
pub const SO_PEERPIDFD: c_int = 77;
pub const SO_DEVMEM_LINEAR: c_int = 78;
pub const SO_DEVMEM_DMABUF: c_int = 79;
pub const SO_DEVMEM_DONTNEED: c_int = 80;

cfg_if! {
if #[cfg(any(
Expand All @@ -169,6 +179,9 @@ cfg_if! {
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;

pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;

// Ioctl Constants

pub const TCGETS: Ioctl = 0x5401;
Expand Down
13 changes: 13 additions & 0 deletions src/unix/linux_like/linux/arch/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ cfg_if! {
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
pub const SO_PREFER_BUSY_POLL: c_int = 69;
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
pub const SO_NETNS_COOKIE: c_int = 71;
pub const SO_BUF_LOCK: c_int = 72;
pub const SO_RESERVE_MEM: c_int = 73;
pub const SO_TXREHASH: c_int = 74;
pub const SO_RCVMARK: c_int = 75;
pub const SO_PASSPIDFD: c_int = 76;
pub const SO_PEERPIDFD: c_int = 77;
pub const SO_DEVMEM_LINEAR: c_int = 78;
pub const SO_DEVMEM_DMABUF: c_int = 79;
pub const SO_DEVMEM_DONTNEED: c_int = 80;

pub const FICLONE: c_ulong = 0x80049409;
pub const FICLONERANGE: c_ulong = 0x8020940D;
Expand All @@ -129,6 +139,9 @@ pub const FICLONERANGE: c_ulong = 0x8020940D;
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;

pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;

// Ioctl Constants

pub const TCGETS: Ioctl = 0x540d;
Expand Down
13 changes: 13 additions & 0 deletions src/unix/linux_like/linux/arch/powerpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ const SO_SNDTIMEO_NEW: c_int = 67;
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
pub const SO_PREFER_BUSY_POLL: c_int = 69;
pub const SO_BUSY_POLL_BUDGET: c_int = 70;
pub const SO_NETNS_COOKIE: c_int = 71;
pub const SO_BUF_LOCK: c_int = 72;
pub const SO_RESERVE_MEM: c_int = 73;
pub const SO_TXREHASH: c_int = 74;
pub const SO_RCVMARK: c_int = 75;
pub const SO_PASSPIDFD: c_int = 76;
pub const SO_PEERPIDFD: c_int = 77;
pub const SO_DEVMEM_LINEAR: c_int = 78;
pub const SO_DEVMEM_DMABUF: c_int = 79;
pub const SO_DEVMEM_DONTNEED: c_int = 80;

pub const FICLONE: c_ulong = 0x80049409;
pub const FICLONERANGE: c_ulong = 0x8020940D;
Expand All @@ -111,6 +121,9 @@ pub const FICLONERANGE: c_ulong = 0x8020940D;
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;

pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;

// Ioctl Constants

cfg_if! {
Expand Down
13 changes: 13 additions & 0 deletions src/unix/linux_like/linux/arch/sparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,25 @@ pub const SO_TIMESTAMPING: c_int = 0x0023;
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 0x0047;
pub const SO_PREFER_BUSY_POLL: c_int = 0x0048;
pub const SO_BUSY_POLL_BUDGET: c_int = 0x0049;
pub const SO_NETNS_COOKIE: c_int = 0x0050;
pub const SO_BUF_LOCK: c_int = 0x0051;
pub const SO_RESERVE_MEM: c_int = 0x0052;
pub const SO_TXREHASH: c_int = 0x0053;
pub const SO_RCVMARK: c_int = 0x0054;
pub const SO_PASSPIDFD: c_int = 0x0055;
pub const SO_PEERPIDFD: c_int = 0x0056;
pub const SO_DEVMEM_LINEAR: c_int = 0x0057;
pub const SO_DEVMEM_DMABUF: c_int = 0x0058;
pub const SO_DEVMEM_DONTNEED: c_int = 0x0059;

// Defined in unix/linux_like/mod.rs
// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING;

pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR;
pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF;

// Ioctl Constants

pub const TCGETS: Ioctl = 0x40245408;
Expand Down
15 changes: 15 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,21 @@ s! {
pub propagation: crate::__u64,
pub userns_fd: crate::__u64,
}

// linux/uio.h

pub struct dmabuf_cmsg {
pub frag_offset: crate::__u64,
pub frag_size: crate::__u32,
pub frag_token: crate::__u32,
pub dmabuf_id: crate::__u32,
pub flags: crate::__u32,
}

pub struct dmabuf_token {
pub token_start: crate::__u32,
pub token_count: crate::__u32,
}
}

cfg_if! {
Expand Down
Loading