Skip to content

Commit eb2917b

Browse files
committed
packet: Take mbuf struct fromDPDK
Fixes #89
1 parent cfad4ca commit eb2917b

1 file changed

Lines changed: 7 additions & 31 deletions

File tree

framework/src/native/zcsi/mbuf.rs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
1-
#[repr(C)]
2-
pub struct MBuf {
3-
buf_addr: *mut u8,
4-
phys_addr: usize,
5-
data_off: u16,
6-
refcnt: u16,
7-
nb_segs: u8,
8-
port: u8,
9-
ol_flags: u64,
10-
packet_type: u32,
11-
pkt_len: u32,
12-
data_len: u16,
13-
vlan_tci: u16,
14-
hash: u64,
15-
vlan_tci_outer: u32,
16-
buf_len: u16,
17-
timestamp: u64,
18-
userdata: u64,
19-
pool: u64,
20-
next: *mut MBuf,
21-
tx_offload: u64,
22-
priv_size: u16,
23-
timesync: u16,
24-
seqn: u32,
25-
}
1+
use super::super::super::native_include as ldpdk;
2+
pub type MBuf = ldpdk::rte_mbuf;
263

274
// FIXME: Remove this once we start using these functions correctly
285
#[allow(dead_code)]
@@ -55,10 +32,7 @@ impl MBuf {
5532

5633
#[inline]
5734
pub fn data_address(&self, offset: usize) -> *mut u8 {
58-
unsafe {
59-
self.buf_addr
60-
.offset(self.data_off as isize + offset as isize)
61-
}
35+
unsafe { (self.buf_addr as *mut u8).offset(self.data_off as isize + offset as isize) }
6236
}
6337

6438
/// Returns the total allocated size of this mbuf segment.
@@ -142,11 +116,13 @@ impl MBuf {
142116

143117
#[inline]
144118
pub fn refcnt(&self) -> u16 {
145-
self.refcnt
119+
unsafe { self.__bindgen_anon_1.refcnt }
146120
}
147121

148122
#[inline]
149123
pub fn reference(&mut self) {
150-
self.refcnt += 1;
124+
unsafe {
125+
self.__bindgen_anon_1.refcnt += 1;
126+
}
151127
}
152128
}

0 commit comments

Comments
 (0)