From 90f2fc3e155e6643bd21caf1c1ffe354b0422281 Mon Sep 17 00:00:00 2001 From: Lu Qiuwen Date: Sun, 14 Apr 2024 19:30:39 +0800 Subject: delay yellow packets in nanoseconds instead of us. --- app/CMakeLists.txt | 3 +-- app/src/marsio.c | 4 ++-- app/src/monit.c | 7 ------- service/include/sc_devmgr.h | 2 +- service/src/devmgr.c | 3 +-- service/src/node_phydev.c | 12 +++++++++++- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 74cf7de..7246485 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -5,8 +5,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include/internal) include_directories(include) include_directories(../service/include) -add_library(marsio SHARED src/marsio.c src/arp.c src/icmp.c src/neigh.c src/rawio.c src/mrb.c - src/sendpath.c src/monit.c src/tap.c) +add_library(marsio SHARED src/marsio.c src/rawio.c src/mrb.c src/sendpath.c src/monit.c src/tap.c) set_target_properties(marsio PROPERTIES VERSION ${MARSIO_VERSION_MAJOR}.${MARSIO_VERSION_MINOR}) set_target_properties(marsio PROPERTIES SOVERSION ${MARSIO_VERSION_MAJOR}) diff --git a/app/src/marsio.c b/app/src/marsio.c index 00d9345..7ea5c62 100644 --- a/app/src/marsio.c +++ b/app/src/marsio.c @@ -136,10 +136,10 @@ static void mrapp_rx_notify_init(struct mr_instance * instance) } MESA_load_profile_uint_def(instance->g_cfgfile_path, "service", "poll_wait_throttle_usleep_threshold", - &instance->zero_recv_usleep_threshold, 32); + &instance->zero_recv_usleep_threshold, 64); MESA_load_profile_uint_def(instance->g_cfgfile_path, "service", "poll_wait_throttle_usleep_period", - &instance->zero_recv_usleep_period, 5); + &instance->zero_recv_usleep_period, 2); MESA_load_profile_uint_def(instance->g_cfgfile_path, "service", "poll_wait_throttle_notify_threshold", &instance->zero_recv_notify_threshold, 256); diff --git a/app/src/monit.c b/app/src/monit.c index dd9f600..25fe357 100644 --- a/app/src/monit.c +++ b/app/src/monit.c @@ -296,13 +296,6 @@ static cJSON * monit_root(struct mr_instance * instance) cJSON_AddItemToObject(j_root, "appinfo", monit_app_info(instance)); cJSON_AddItemToObject(j_root, "raw", monit_vdev(instance)); cJSON_AddItemToObject(j_root, "appstat", monit_app_stat(instance)); - - if (instance->neigh != NULL) - { - struct cJSON * j_monit_neigh = neighbour_manager_monit(instance->neigh); - cJSON_AddItemToObject(j_root, "neigh", j_monit_neigh); - } - return j_root; } diff --git a/service/include/sc_devmgr.h b/service/include/sc_devmgr.h index d6ad8ee..2f0dd37 100644 --- a/service/include/sc_devmgr.h +++ b/service/include/sc_devmgr.h @@ -188,7 +188,7 @@ struct dpdk_dev uint64_t tx_meter_cir; uint64_t tx_meter_cbs; uint64_t tx_meter_ebs; - unsigned int tx_meter_yellow_pkt_delay_us; + unsigned int tx_meter_yellow_pkt_delay_ns; struct rte_meter_srtcm_profile * tx_meter_profile[MR_SID_MAX]; struct rte_meter_srtcm * tx_meter[MR_SID_MAX]; diff --git a/service/src/devmgr.c b/service/src/devmgr.c index 4bd54d6..d3a6831 100644 --- a/service/src/devmgr.c +++ b/service/src/devmgr.c @@ -1685,8 +1685,7 @@ void dpdk_dev_config_load(struct dpdk_dev * dev_dpdk, const char * cfg) MESA_load_profile_uint_def(cfg, str_section, "tx_meter_cir_in_Kbps", &tx_meter_cir_in_Kbps, 0); MESA_load_profile_uint_def(cfg, str_section, "tx_meter_cbs_in_KB", &tx_meter_cbs_in_KB, 0); MESA_load_profile_uint_def(cfg, str_section, "tx_meter_ebs_in_KB", &tx_meter_ebs_in_KB, 0); - MESA_load_profile_uint_def(cfg, str_section, "tx_meter_yellow_pkt_delay_in_us", - &dev_dpdk->tx_meter_yellow_pkt_delay_us, 1); + MESA_load_profile_uint_def(cfg, str_section, "tx_meter_yellow_pkt_delay_in_ns", &dev_dpdk->tx_meter_yellow_pkt_delay_ns, 250); dev_dpdk->tx_meter_cir = (uint64_t)tx_meter_cir_in_Kbps * 1000 / 8; dev_dpdk->tx_meter_cbs = (uint64_t)tx_meter_cbs_in_KB * 1024; diff --git a/service/src/node_phydev.c b/service/src/node_phydev.c index 155ab02..ba092f5 100644 --- a/service/src/node_phydev.c +++ b/service/src/node_phydev.c @@ -568,6 +568,16 @@ static __rte_always_inline void do_tx_burst(struct rte_graph * graph, struct rte } } +static void delay_ns_block(uint64_t ns) +{ + const uint64_t start = rte_get_timer_cycles(); + const uint64_t ticks = ns * rte_get_timer_hz() / 1E9; + while ((rte_get_timer_cycles() - start) < ticks) + { + rte_pause(); + } +} + static __rte_always_inline uint16_t dpdk_dev_tx_node_process(struct rte_graph * graph, struct rte_node * node, void ** objs, uint16_t cnt) { @@ -615,7 +625,7 @@ static __rte_always_inline uint16_t dpdk_dev_tx_node_process(struct rte_graph * do_tx_burst(graph, node, dev_desc, mbufs_to_send, nr_mbufs_to_send); nr_mbufs_to_send = 0; - rte_delay_us_block(dpdk_dev_desc->tx_meter_yellow_pkt_delay_us); + delay_ns_block(dpdk_dev_desc->tx_meter_yellow_pkt_delay_ns); counter_tx_meter_yellow++; break; -- cgit v1.2.3