diff options
| author | luwenpeng <[email protected]> | 2023-10-16 17:04:21 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2023-10-23 19:27:59 +0800 |
| commit | a49805a0190f667d98c905290fcef3f487e1308f (patch) | |
| tree | 24757daf8d87f59c116fb6f36cf1eac9ff898ed2 /platform | |
| parent | 8f11f8381d23bffc8395524725e20fde9b004740 (diff) | |
perf: Add min_timeout_ms on marsio_poll_wait(); Add thread local rx_buffs on marsio_recv_burst()
Diffstat (limited to 'platform')
| -rw-r--r-- | platform/src/packet_io.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp index 4619e11..8997553 100644 --- a/platform/src/packet_io.cpp +++ b/platform/src/packet_io.cpp @@ -28,6 +28,7 @@ struct config { int bypass_traffic; int rx_burst_max; + int min_timeout_ms; char app_symbol[256]; char dev_endpoint[256]; char dev_nf_interface[256]; @@ -1137,6 +1138,7 @@ static int packet_io_config(const char *profile, struct config *config) // bypass_traffic:3 bypass decrypted traffic MESA_load_profile_int_def(profile, "PACKET_IO", "bypass_traffic", (int *)&(config->bypass_traffic), 0); MESA_load_profile_int_def(profile, "PACKET_IO", "rx_burst_max", (int *)&(config->rx_burst_max), 1); + MESA_load_profile_int_def(profile, "PACKET_IO", "min_timeout_ms", (int *)&(config->min_timeout_ms), 900); MESA_load_profile_string_nodef(profile, "PACKET_IO", "app_symbol", config->app_symbol, sizeof(config->app_symbol)); MESA_load_profile_string_nodef(profile, "PACKET_IO", "dev_endpoint", config->dev_endpoint, sizeof(config->dev_endpoint)); MESA_load_profile_string_nodef(profile, "PACKET_IO", "dev_nf_interface", config->dev_nf_interface, sizeof(config->dev_nf_interface)); @@ -1170,6 +1172,7 @@ static int packet_io_config(const char *profile, struct config *config) LOG_DEBUG("%s: PACKET_IO->bypass_traffic : %d", LOG_TAG_PKTIO, config->bypass_traffic); LOG_DEBUG("%s: PACKET_IO->rx_burst_max : %d", LOG_TAG_PKTIO, config->rx_burst_max); + LOG_DEBUG("%s: PACKET_IO->min_timeout_ms : %d", LOG_TAG_PKTIO, config->min_timeout_ms); LOG_DEBUG("%s: PACKET_IO->app_symbol : %s", LOG_TAG_PKTIO, config->app_symbol); LOG_DEBUG("%s: PACKET_IO->dev_endpoint : %s", LOG_TAG_PKTIO, config->dev_endpoint); LOG_DEBUG("%s: PACKET_IO->dev_nf_interface : %s", LOG_TAG_PKTIO, config->dev_nf_interface); @@ -1314,11 +1317,19 @@ int packet_io_thread_init(struct packet_io *handle, struct thread_ctx *thread_ct void packet_io_thread_wait(struct packet_io *handle, struct thread_ctx *thread_ctx, int timeout_ms) { - struct mr_vdev *vdevs[] = { + static __thread struct mr_vdev *vdevs[] = { handle->dev_nf_interface.mr_dev, handle->dev_endpoint.mr_dev}; - marsio_poll_wait(handle->instance, vdevs, 2, thread_ctx->thread_index, timeout_ms); + int min_timeout_ms = MIN(handle->config.min_timeout_ms, timeout_ms); + if (min_timeout_ms > 0) + { + marsio_poll_wait(handle->instance, vdevs, 2, thread_ctx->thread_index, min_timeout_ms); + } + else + { + return; + } } int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thread_ctx) @@ -1326,7 +1337,7 @@ int packet_io_thread_polling_nf(struct packet_io *handle, struct thread_ctx *thr struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics; int thread_index = thread_ctx->thread_index; - marsio_buff_t *rx_buffs[RX_BURST_MAX]; + static __thread marsio_buff_t *rx_buffs[RX_BURST_MAX]; int nr_recv = marsio_recv_burst(handle->dev_nf_interface.mr_dev, thread_index, rx_buffs, handle->config.rx_burst_max); if (nr_recv <= 0) { @@ -1389,7 +1400,7 @@ int packet_io_thread_polling_endpoint(struct packet_io *handle, struct thread_ct struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics; int thread_index = thread_ctx->thread_index; - marsio_buff_t *rx_buffs[RX_BURST_MAX]; + static __thread marsio_buff_t *rx_buffs[RX_BURST_MAX]; int nr_recv = marsio_recv_burst(handle->dev_endpoint.mr_dev, thread_index, rx_buffs, handle->config.rx_burst_max); if (nr_recv <= 0) { |
