-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[catpowder] Enhancement: Improve XDP LibOS
- Loading branch information
Showing
12 changed files
with
137 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ mod api; | |
mod buffer; | ||
mod params; | ||
mod program; | ||
mod ring; | ||
mod rule; | ||
mod rx_ring; | ||
mod socket; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
//====================================================================================================================== | ||
// Structures | ||
//====================================================================================================================== | ||
|
||
pub struct XdpRing { | ||
ring: xdp_rs::XSK_RING, | ||
} | ||
|
||
//====================================================================================================================== | ||
// Implementations | ||
//====================================================================================================================== | ||
|
||
impl XdpRing { | ||
pub fn ring_initialize(info: &xdp_rs::XSK_RING_INFO) -> Self { | ||
let ring = unsafe { | ||
let mut ring: xdp_rs::XSK_RING = std::mem::zeroed(); | ||
xdp_rs::_XskRingInitialize(&mut ring, info); | ||
ring | ||
}; | ||
Self { ring } | ||
} | ||
|
||
pub fn ring_consumer_reserve(&mut self, count: u32, idx: *mut u32) -> u32 { | ||
unsafe { xdp_rs::_XskRingConsumerReserve(&mut self.ring, count, idx) } | ||
} | ||
|
||
pub fn ring_consumer_release(&mut self, count: u32) { | ||
unsafe { xdp_rs::_XskRingConsumerRelease(&mut self.ring, count) } | ||
} | ||
|
||
pub fn ring_producer_reserve(&mut self, count: u32, idx: *mut u32) -> u32 { | ||
unsafe { xdp_rs::_XskRingProducerReserve(&mut self.ring, count, idx) } | ||
} | ||
|
||
pub fn ring_producer_submit(&mut self, count: u32) { | ||
unsafe { xdp_rs::_XskRingProducerSubmit(&mut self.ring, count) } | ||
} | ||
|
||
pub fn ring_get_element(&self, idx: u32) -> *mut std::ffi::c_void { | ||
unsafe { xdp_rs::_XskRingGetElement(&self.ring, idx) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.