fn build_umem_socket_config(opts: &Opts) -> (UmemConfig, SocketConfig) {
    let n = opts.xdp_queue_size;

    let umem_config = UmemConfigBuilder::new()
        .frame_count(n)
        .comp_queue_size(n / 2)
        .fill_queue_size(n / 2)
        .build()
        .unwrap();

    let mut socket_config_init = SocketConfigBuilder::new()
        .tx_queue_size(n / 2)
        .rx_queue_size(n / 2)
        .clone();

    let socket_config_bind = match opts.bind_option {
        BindOption::ZeroCopy => socket_config_init.bind_flags(BindFlags::XDP_ZEROCOPY),
        BindOption::Copy => socket_config_init.bind_flags(BindFlags::XDP_COPY),
    };

    let socket_config_sk = match opts.socket_option {
        SocketOption::Drv => socket_config_bind.xdp_flags(XdpFlags::XDP_FLAGS_DRV_MODE),
        SocketOption::Skb => socket_config_bind.xdp_flags(XdpFlags::XDP_FLAGS_SKB_MODE),
    };

    let socket_config = socket_config_sk.build().unwrap();
    (umem_config, socket_config)
}
/// Build umem and socket configs based on opts
Build umem and socket configs based on opts
Build umem and socket configs based on opts
fn build_umem_socket_config(opts: &Opts) -> (UmemConfig, SocketConfig) {
    let n = opts.xdp_queue_size;
    let umem_config = UmemConfigBuilder::new()
        .frame_count(n)
        .comp_queue_size(n / 2)
        .fill_queue_size(n / 2)
        .build()
        .unwrap();
    let mut socket_config_init = SocketConfigBuilder::new()
        .tx_queue_size(n / 2)
        .rx_queue_size(n / 2)
        .clone();
    let socket_config_bind = match opts.bind_option {
        BindOption::ZeroCopy => socket_config_init.bind_flags(BindFlags::XDP_ZEROCOPY),
        BindOption::Copy => socket_config_init.bind_flags(BindFlags::XDP_COPY),
    };
    let socket_config_sk = match opts.socket_option {
        SocketOption::Drv => socket_config_bind.xdp_flags(XdpFlags::XDP_FLAGS_DRV_MODE),
        SocketOption::Skb => socket_config_bind.xdp_flags(XdpFlags::XDP_FLAGS_SKB_MODE),
    };
    let socket_config = socket_config_sk.build().unwrap();
    (umem_config, socket_config)
}
fn build_umem_socket_config ( opts : & Opts ) -> ( UmemConfig , SocketConfig ) { let n = opts . xdp_queue_size ; let umem_config = UmemConfigBuilder :: new ( ) . frame_count ( n ) . comp_queue_size ( n / 2 ) . fill_queue_size ( n / 2 ) . build ( ) . unwrap ( ) ; let mut socket_config_init = SocketConfigBuilder :: new ( ) . tx_queue_size ( n / 2 ) . rx_queue_size ( n / 2 ) . clone ( ) ; let socket_config_bind = match opts . bind_option { BindOption :: ZeroCopy => socket_config_init . bind_flags ( BindFlags :: XDP_ZEROCOPY ) , BindOption :: Copy => socket_config_init . bind_flags ( BindFlags :: XDP_COPY ) , } ; let socket_config_sk = match opts . socket_option { SocketOption :: Drv => socket_config_bind . xdp_flags ( XdpFlags :: XDP_FLAGS_DRV_MODE ) , SocketOption :: Skb => socket_config_bind . xdp_flags ( XdpFlags :: XDP_FLAGS_SKB_MODE ) , } ; let socket_config = socket_config_sk . build ( ) . unwrap ( ) ; ( umem_config , socket_config ) }
Build umem and socket configs based on opts
Build umem and socket configs based on opts
opts
&Opts
opts
&Opts