Skip to content

Commit

Permalink
move AF_XDP structs and constants to linux/mod.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-alpaca committed Nov 27, 2024
1 parent 8075133 commit 9e358a7
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 276 deletions.
24 changes: 0 additions & 24 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ SOL_PPPOL2TP
SOL_RAW
SOL_RDS
SOL_RXRPC
SOL_XDP
STATX_ALL
STATX_ATIME
STATX_ATTR_APPEND
Expand Down Expand Up @@ -478,31 +477,8 @@ UDF_SUPER_MAGIC
UNAME26
USBDEVICE_SUPER_MAGIC
USER_PROCESS
XDP_COPY
XDP_MMAP_OFFSETS
XDP_OPTIONS
XDP_OPTIONS_ZEROCOPY
XDP_PGOFF_RX_RING
XDP_PGOFF_TX_RING
XDP_PKT_CONTD
XDP_RING_NEED_WAKEUP
XDP_RX_RING
XDP_SHARED_UMEM
XDP_STATISTICS
XDP_TX_RING
XDP_UMEM_COMPLETION_RING
XDP_UMEM_FILL_RING
XDP_UMEM_PGOFF_COMPLETION_RING
XDP_UMEM_PGOFF_FILL_RING
XDP_UMEM_REG
XDP_UMEM_UNALIGNED_CHUNK_FLAG
XDP_USE_NEED_WAKEUP
XDP_USE_SG
XDP_ZEROCOPY
XENFS_SUPER_MAGIC
XFS_SUPER_MAGIC
XSK_UNALIGNED_BUF_ADDR_MASK
XSK_UNALIGNED_BUF_OFFSET_SHIFT
_CS_GNU_LIBC_VERSION
_CS_GNU_LIBPTHREAD_VERSION
_CS_V6_ENV
Expand Down
24 changes: 0 additions & 24 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,7 @@ RWF_DSYNC
RWF_HIPRI
RWF_NOWAIT
RWF_SYNC
SOL_XDP
USER_PROCESS
XDP_COPY
XDP_MMAP_OFFSETS
XDP_OPTIONS
XDP_OPTIONS_ZEROCOPY
XDP_PGOFF_RX_RING
XDP_PGOFF_TX_RING
XDP_PKT_CONTD
XDP_RING_NEED_WAKEUP
XDP_RX_RING
XDP_SHARED_UMEM
XDP_STATISTICS
XDP_TX_RING
XDP_UMEM_COMPLETION_RING
XDP_UMEM_FILL_RING
XDP_UMEM_PGOFF_COMPLETION_RING
XDP_UMEM_PGOFF_FILL_RING
XDP_UMEM_REG
XDP_UMEM_UNALIGNED_CHUNK_FLAG
XDP_USE_NEED_WAKEUP
XDP_USE_SG
XDP_ZEROCOPY
XSK_UNALIGNED_BUF_ADDR_MASK
XSK_UNALIGNED_BUF_OFFSET_SHIFT
_CS_V6_ENV
_CS_V7_ENV
adjtimex
Expand Down
24 changes: 24 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,7 @@ SOL_TIPC
SOL_TLS
SOL_UDP
SOL_X25
SOL_XDP
SOMAXCONN
SO_BINDTODEVICE
SO_BUSY_POLL
Expand Down Expand Up @@ -3400,11 +3401,34 @@ W_EXITCODE
W_STOPCODE
XATTR_CREATE
XATTR_REPLACE
XDP_COPY
XDP_MMAP_OFFSETS
XDP_OPTIONS
XDP_OPTIONS_ZEROCOPY
XDP_PGOFF_RX_RING
XDP_PGOFF_TX_RING
XDP_PKT_CONTD
XDP_RING_NEED_WAKEUP
XDP_RX_RING
XDP_SHARED_UMEM
XDP_STATISTICS
XDP_TXMD_FLAGS_CHECKSUM
XDP_TXMD_FLAGS_TIMESTAMP
XDP_TX_METADATA
XDP_TX_RING
XDP_UMEM_COMPLETION_RING
XDP_UMEM_FILL_RING
XDP_UMEM_PGOFF_COMPLETION_RING
XDP_UMEM_PGOFF_FILL_RING
XDP_UMEM_REG
XDP_UMEM_TX_METADATA_LEN
XDP_UMEM_TX_SW_CSUM
XDP_UMEM_UNALIGNED_CHUNK_FLAG
XDP_USE_NEED_WAKEUP
XDP_USE_SG
XDP_ZEROCOPY
XSK_UNALIGNED_BUF_ADDR_MASK
XSK_UNALIGNED_BUF_OFFSET_SHIFT
XTABS
YESEXPR
YESSTR
Expand Down
111 changes: 0 additions & 111 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,84 +311,6 @@ s! {
pub u: __c_anonymous_ptrace_syscall_info_data,
}

// linux/if_xdp.h

pub struct sockaddr_xdp {
pub sxdp_family: crate::__u16,
pub sxdp_flags: crate::__u16,
pub sxdp_ifindex: crate::__u32,
pub sxdp_queue_id: crate::__u32,
pub sxdp_shared_umem_fd: crate::__u32,
}

pub struct xdp_ring_offset {
pub producer: crate::__u64,
pub consumer: crate::__u64,
pub desc: crate::__u64,
pub flags: crate::__u64,
}

pub struct xdp_mmap_offsets {
pub rx: xdp_ring_offset,
pub tx: xdp_ring_offset,
pub fr: xdp_ring_offset,
pub cr: xdp_ring_offset,
}

pub struct xdp_ring_offset_v1 {
pub producer: crate::__u64,
pub consumer: crate::__u64,
pub desc: crate::__u64,
}

pub struct xdp_mmap_offsets_v1 {
pub rx: xdp_ring_offset_v1,
pub tx: xdp_ring_offset_v1,
pub fr: xdp_ring_offset_v1,
pub cr: xdp_ring_offset_v1,
}

pub struct xdp_umem_reg {
pub addr: crate::__u64,
pub len: crate::__u64,
pub chunk_size: crate::__u32,
pub headroom: crate::__u32,
pub flags: crate::__u32,
pub tx_metadata_len: crate::__u32,
}

pub struct xdp_umem_reg_v1 {
pub addr: crate::__u64,
pub len: crate::__u64,
pub chunk_size: crate::__u32,
pub headroom: crate::__u32,
}

pub struct xdp_statistics {
pub rx_dropped: crate::__u64,
pub rx_invalid_descs: crate::__u64,
pub tx_invalid_descs: crate::__u64,
pub rx_ring_full: crate::__u64,
pub rx_fill_ring_empty_descs: crate::__u64,
pub tx_ring_empty_descs: crate::__u64,
}

pub struct xdp_statistics_v1 {
pub rx_dropped: crate::__u64,
pub rx_invalid_descs: crate::__u64,
pub tx_invalid_descs: crate::__u64,
}

pub struct xdp_options {
pub flags: crate::__u32,
}

pub struct xdp_desc {
pub addr: crate::__u64,
pub len: crate::__u32,
pub options: crate::__u32,
}

pub struct iocb {
pub aio_data: crate::__u64,
#[cfg(target_endian = "little")]
Expand Down Expand Up @@ -814,7 +736,6 @@ pub const SOL_RDS: c_int = 276;
pub const SOL_IUCV: c_int = 277;
pub const SOL_CAIF: c_int = 278;
pub const SOL_NFC: c_int = 280;
pub const SOL_XDP: c_int = 283;

pub const MSG_TRYHARD: c_int = 4;

Expand Down Expand Up @@ -1055,38 +976,6 @@ pub const GENL_UNS_ADMIN_PERM: c_int = 0x10;
pub const GENL_ID_VFS_DQUOT: c_int = crate::NLMSG_MIN_TYPE + 1;
pub const GENL_ID_PMCRAID: c_int = crate::NLMSG_MIN_TYPE + 2;

// linux/if_xdp.h
pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
pub const XDP_COPY: crate::__u16 = 1 << 1;
pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
pub const XDP_USE_SG: crate::__u16 = 1 << 4;

pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;

pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;

pub const XDP_MMAP_OFFSETS: c_int = 1;
pub const XDP_RX_RING: c_int = 2;
pub const XDP_TX_RING: c_int = 3;
pub const XDP_UMEM_REG: c_int = 4;
pub const XDP_UMEM_FILL_RING: c_int = 5;
pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
pub const XDP_STATISTICS: c_int = 7;
pub const XDP_OPTIONS: c_int = 8;

pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;

pub const XDP_PGOFF_RX_RING: off_t = 0;
pub const XDP_PGOFF_TX_RING: off_t = 0x80000000;
pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000;
pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000;

pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48;
pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;

pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;

pub const ELFOSABI_ARM_AEABI: u8 = 64;

// linux/sched.h
Expand Down
120 changes: 115 additions & 5 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,83 @@ s! {
}

// linux/if_xdp.h

pub struct sockaddr_xdp {
pub sxdp_family: crate::__u16,
pub sxdp_flags: crate::__u16,
pub sxdp_ifindex: crate::__u32,
pub sxdp_queue_id: crate::__u32,
pub sxdp_shared_umem_fd: crate::__u32,
}

pub struct xdp_ring_offset {
pub producer: crate::__u64,
pub consumer: crate::__u64,
pub desc: crate::__u64,
pub flags: crate::__u64,
}

pub struct xdp_mmap_offsets {
pub rx: xdp_ring_offset,
pub tx: xdp_ring_offset,
pub fr: xdp_ring_offset,
pub cr: xdp_ring_offset,
}

pub struct xdp_ring_offset_v1 {
pub producer: crate::__u64,
pub consumer: crate::__u64,
pub desc: crate::__u64,
}

pub struct xdp_mmap_offsets_v1 {
pub rx: xdp_ring_offset_v1,
pub tx: xdp_ring_offset_v1,
pub fr: xdp_ring_offset_v1,
pub cr: xdp_ring_offset_v1,
}

pub struct xdp_umem_reg {
pub addr: crate::__u64,
pub len: crate::__u64,
pub chunk_size: crate::__u32,
pub headroom: crate::__u32,
pub flags: crate::__u32,
pub tx_metadata_len: crate::__u32,
}

pub struct xdp_umem_reg_v1 {
pub addr: crate::__u64,
pub len: crate::__u64,
pub chunk_size: crate::__u32,
pub headroom: crate::__u32,
}

pub struct xdp_statistics {
pub rx_dropped: crate::__u64,
pub rx_invalid_descs: crate::__u64,
pub tx_invalid_descs: crate::__u64,
pub rx_ring_full: crate::__u64,
pub rx_fill_ring_empty_descs: crate::__u64,
pub tx_ring_empty_descs: crate::__u64,
}

pub struct xdp_statistics_v1 {
pub rx_dropped: crate::__u64,
pub rx_invalid_descs: crate::__u64,
pub tx_invalid_descs: crate::__u64,
}

pub struct xdp_options {
pub flags: crate::__u32,
}

pub struct xdp_desc {
pub addr: crate::__u64,
pub len: crate::__u32,
pub options: crate::__u32,
}

pub struct xsk_tx_metadata_completion {
pub tx_timestamp: crate::__u64,
}
Expand Down Expand Up @@ -5641,13 +5718,46 @@ pub const SCHED_FLAG_UTIL_CLAMP_MIN: c_int = 0x20;
pub const SCHED_FLAG_UTIL_CLAMP_MAX: c_int = 0x40;

// linux/if_xdp.h
pub const XDP_UMEM_TX_SW_CSUM: __u32 = 1 << 1;
pub const XDP_UMEM_TX_METADATA_LEN: __u32 = 1 << 2;
pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
pub const XDP_COPY: crate::__u16 = 1 << 1;
pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
pub const XDP_USE_SG: crate::__u16 = 1 << 4;

pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;

pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;

pub const XDP_MMAP_OFFSETS: c_int = 1;
pub const XDP_RX_RING: c_int = 2;
pub const XDP_TX_RING: c_int = 3;
pub const XDP_UMEM_REG: c_int = 4;
pub const XDP_UMEM_FILL_RING: c_int = 5;
pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
pub const XDP_STATISTICS: c_int = 7;
pub const XDP_OPTIONS: c_int = 8;

pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;

pub const XDP_PGOFF_RX_RING: crate::off_t = 0;
pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000;
pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000;
pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000;

pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48;
pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;

pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;

pub const XDP_UMEM_TX_SW_CSUM: crate::__u32 = 1 << 1;
pub const XDP_UMEM_TX_METADATA_LEN: crate::__u32 = 1 << 2;

pub const XDP_TXMD_FLAGS_TIMESTAMP: crate::__u32 = 1 << 0;
pub const XDP_TXMD_FLAGS_CHECKSUM: crate::__u32 = 1 << 1;

pub const XDP_TXMD_FLAGS_TIMESTAMP: __u32 = 1 << 0;
pub const XDP_TXMD_FLAGS_CHECKSUM: __u32 = 1 << 1;
pub const XDP_TX_METADATA: crate::__u32 = 1 << 1;

pub const XDP_TX_METADATA: __u32 = 1 << 1;
pub const SOL_XDP: c_int = 283;

// linux/mount.h
pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001;
Expand Down
Loading

0 comments on commit 9e358a7

Please sign in to comment.