demikernel 1.5.13

Kernel-Bypass LibOS Architecture
Documentation
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

mod config;
pub mod consts;
mod manager;
mod mempool;

//======================================================================================================================
// Exports
//======================================================================================================================

pub use self::manager::MemoryManager;

//======================================================================================================================
// Imports
//======================================================================================================================

use crate::{
    catnip::runtime::SharedDPDKRuntime,
    runtime::{
        fail::Fail,
        memory::{
            DemiBuffer,
            MemoryRuntime,
        },
        types::demi_sgarray_t,
    },
};

//======================================================================================================================
// Trait Implementations
//======================================================================================================================

/// Memory Runtime Trait Implementation for DPDK Runtime
impl MemoryRuntime for SharedDPDKRuntime {
    /// Casts a [DPDKBuf] into an [demi_sgarray_t].
    fn into_sgarray(&self, buf: DemiBuffer) -> Result<demi_sgarray_t, Fail> {
        self.mm.into_sgarray(buf)
    }

    /// Allocates a [demi_sgarray_t].
    fn sgaalloc(&self, size: usize) -> Result<demi_sgarray_t, Fail> {
        self.mm.alloc_sgarray(size)
    }

    /// Releases a [demi_sgarray_t].
    fn sgafree(&self, sga: demi_sgarray_t) -> Result<(), Fail> {
        self.mm.free_sgarray(sga)
    }

    /// Clones a [demi_sgarray_t].
    fn clone_sgarray(&self, sga: &demi_sgarray_t) -> Result<DemiBuffer, Fail> {
        self.mm.clone_sgarray(sga)
    }
}