Skip to content
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

Various fixes #9

Merged
merged 5 commits into from
Apr 13, 2016
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
10 changes: 4 additions & 6 deletions src/netmap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use libc::{c_int, c_uint, c_ulong, c_char, timeval, ssize_t};
use libc::{c_int, c_uint, c_ulong, c_char, timeval, ssize_t, IF_NAMESIZE};

pub const IF_NAMESIZE: usize = 16;
pub const IFNAMSIZ: usize = IF_NAMESIZE;

pub const NETMAP_API: c_int = 11;
Expand Down Expand Up @@ -47,6 +46,7 @@ pub struct netmap_ring {

pub ts: timeval,

_padding: [u8; 72],
pub sem: [u8; 128], // FIXME __attribute__((__aligned__(NM_CACHE_ALIGN)))

pub slot: [netmap_slot; 0], // FIXME Check struct size/field alignment
Expand Down Expand Up @@ -79,8 +79,6 @@ pub struct netmap_if {

pub const NI_PRIV_MEM: c_int = 0x1;

pub const SIZEOF_NR_NAME: usize = IFNAMSIZ;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct nmreq {
Expand Down Expand Up @@ -142,9 +140,9 @@ pub const NIOCGINFO: c_ulong = 3225184657;
#[cfg(target_os = "linux")]
pub const NIOCREGIF: c_ulong = 3225184658;
#[cfg(target_os = "linux")]
pub const NIOTXSYNC: c_uint = 27028;
pub const NIOCTXSYNC: c_uint = 27028;
#[cfg(target_os = "linux")]
pub const NIORXSYNC: c_uint = 27029;
pub const NIOCRXSYNC: c_uint = 27029;
#[cfg(target_os = "linux")]
pub const NIOCCONFIG: c_ulong = 3239078294;

Expand Down
4 changes: 2 additions & 2 deletions src/netmap_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub unsafe fn NETMAP_IF<U>(_base: *mut U, _ofs: isize) -> *mut netmap_if {
// FIXME It's possible the pointer arithmetic here uses the wrong integer types.
#[inline(always)]
pub unsafe fn NETMAP_TXRING(nifp: *mut netmap_if, index: isize) -> *mut netmap_ring {
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut c_void;
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut isize;
_NETMAP_OFFSET(nifp, *(ptr.offset(index) as *mut isize))
}

#[inline(always)]
pub unsafe fn NETMAP_RXRING(nifp: *mut netmap_if, index: isize) -> *mut netmap_ring {
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut c_void;
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut isize;
_NETMAP_OFFSET(nifp, *(ptr.offset(index + (*nifp).ni_tx_rings as isize + 1) as *mut isize))
}

Expand Down