af_xdp tryout
This commit is contained in:
@@ -40,6 +40,8 @@ struct ST2110ReceiverConfig {
|
||||
int framebuff_cnt = 3;
|
||||
int mxl_latency_frames = 2;
|
||||
std::string mxl_index_mode = "rtp";
|
||||
std::string backend = "kernel";
|
||||
bool af_xdp_zero_copy = true;
|
||||
|
||||
bool direct_v210() const { return depth == 10; }
|
||||
enum st20_fmt transport_fmt() const {
|
||||
@@ -232,6 +234,8 @@ inline ST2110ReceiverConfig parse_st2110_receiver_config(const nlohmann::json& c
|
||||
out.framebuff_cnt = cfg.value("framebuff_cnt", out.framebuff_cnt);
|
||||
out.mxl_latency_frames = cfg.value("mxl_latency_frames", out.mxl_latency_frames);
|
||||
out.mxl_index_mode = cfg.value("mxl_index_mode", out.mxl_index_mode);
|
||||
out.backend = cfg.value("backend", out.backend);
|
||||
out.af_xdp_zero_copy = cfg.value("af_xdp_zero_copy", out.af_xdp_zero_copy);
|
||||
|
||||
if (out.width <= 0 || out.height <= 0) {
|
||||
throw std::runtime_error("width and height must be positive");
|
||||
@@ -257,6 +261,9 @@ inline ST2110ReceiverConfig parse_st2110_receiver_config(const nlohmann::json& c
|
||||
if (out.mxl_index_mode != "rtp" && out.mxl_index_mode != "live") {
|
||||
throw std::runtime_error("mxl_index_mode must be 'rtp' or 'live'");
|
||||
}
|
||||
if (out.backend != "kernel" && out.backend != "af_xdp") {
|
||||
throw std::runtime_error("backend must be 'kernel' or 'af_xdp'");
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -267,16 +274,25 @@ public:
|
||||
mtl_init_params params{};
|
||||
params.num_ports = 1;
|
||||
|
||||
port_name_ = "kernel:" + cfg.ifname;
|
||||
if (cfg.backend == "kernel") {
|
||||
port_name_ = "kernel:" + cfg.ifname;
|
||||
params.pmd[MTL_PORT_P] = MTL_PMD_KERNEL_SOCKET;
|
||||
} else if (cfg.backend == "af_xdp") {
|
||||
port_name_ = "native_af_xdp:" + cfg.ifname;
|
||||
params.pmd[MTL_PORT_P] = MTL_PMD_NATIVE_AF_XDP;
|
||||
if (!cfg.af_xdp_zero_copy) {
|
||||
params.flags |= MTL_FLAG_AF_XDP_ZC_DISABLE;
|
||||
}
|
||||
}
|
||||
|
||||
std::snprintf(params.port[MTL_PORT_P], sizeof(params.port[MTL_PORT_P]), "%s",
|
||||
port_name_.c_str());
|
||||
|
||||
params.pmd[MTL_PORT_P] = MTL_PMD_KERNEL_SOCKET;
|
||||
params.net_proto[MTL_PORT_P] = MTL_PROTO_STATIC;
|
||||
params.rx_queues_cnt[MTL_PORT_P] = 1;
|
||||
params.tx_queues_cnt[MTL_PORT_P] = 0;
|
||||
params.log_level = MTL_LOG_LEVEL_INFO;
|
||||
params.flags = MTL_FLAG_DEV_AUTO_START_STOP;
|
||||
params.flags |= MTL_FLAG_DEV_AUTO_START_STOP;
|
||||
st2110_set_ip(params.sip_addr[MTL_PORT_P], cfg.local_ip);
|
||||
|
||||
handle_ = mtl_init(¶ms);
|
||||
|
||||
Reference in New Issue
Block a user