From 2df282f0f34a6099049feaca8e12ab99d8ebaa99 Mon Sep 17 00:00:00 2001 From: kerwin Date: Wed, 19 Apr 2023 15:54:20 +0800 Subject: [PATCH 1/3] Fix send_one_by_one running logic. * Fix duplicate function in send_one_by_one * Add error handler for xudp_sned_channel * Add packet counting support for alarm_handler --- tools/xudpperf.c | 50 ++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/tools/xudpperf.c b/tools/xudpperf.c index 3c0fba1..3d12ce3 100644 --- a/tools/xudpperf.c +++ b/tools/xudpperf.c @@ -229,6 +229,26 @@ static void handler_recv(struct th *th) } } +static void __handler_send_err(int ret) +{ + g_err_send++; + + if (ret == -XUDP_ERR_CQ_NOSPACE) + g_err_cq++; + + if (ret == -XUDP_ERR_TX_NOSPACE) + g_err_tx++; + + if (ret == -XUDP_ERR_PACKET_TOO_BIG) + g_err_inval++; + + if (ret == -XUDP_ERR_COMMIT_AGAIN) + { + g_err_commit += 1; + sent_n += 1; + } +} + static void __handler_echo(xudp_channel *ch) { int n = 1, i, ret, send = 0, err_cq = 0, err_tx = 0, err_inval = 0; @@ -296,9 +316,12 @@ static int send_one_by_one(struct th *th) while (conf.npkt--) { - xudp_send_channel(ch, buf, conf.msglen, (struct sockaddr *)&conf.dst, 0); - xudp_send_channel(ch, buf, conf.msglen, (struct sockaddr *)&conf.dst, 0); - xudp_send_channel(ch, buf, conf.msglen, (struct sockaddr *)&conf.dst, 0); + ret = xudp_send_channel(ch, buf, conf.msglen, (struct sockaddr *)&conf.dst, 0); + if (ret < 0) + { + __handler_send_err(ret); + } + sent_n += 1; xudp_commit_channel(ch); sleep(1); } @@ -459,25 +482,6 @@ static int flood_send(xudp *x) return 0; } -static void __handler_send_err(int ret) -{ - g_err_send++; - - if (ret == -XUDP_ERR_CQ_NOSPACE) - g_err_cq++; - - if (ret == -XUDP_ERR_TX_NOSPACE) - g_err_tx++; - - if (ret == -XUDP_ERR_PACKET_TOO_BIG) - g_err_inval++; - - if (ret == -XUDP_ERR_COMMIT_AGAIN) { - g_err_commit += 1; - sent_n += 1; - } -} - static int ___handler_pp_flood(xudp_channel *ch) { struct timeval *tp, now; @@ -616,7 +620,7 @@ static void handler_send(struct th *th) { if (-1 != conf.npkt) { send_one_by_one(th); - return; + exit(0); } __handler_send(th); } -- Gitee From efe03d5d735db425851e16b70152e122ff43f198 Mon Sep 17 00:00:00 2001 From: kerwin Date: Wed, 19 Apr 2023 16:08:38 +0800 Subject: [PATCH 2/3] Fix the divide by zero problem when calculating the pp avg. --- tools/xudpperf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/xudpperf.c b/tools/xudpperf.c index 3d12ce3..834e5bb 100644 --- a/tools/xudpperf.c +++ b/tools/xudpperf.c @@ -580,7 +580,11 @@ static int __handler_pp(xudp_channel *ch) usec = (now.tv_sec - start.tv_sec) * 1000 * 1000; usec += now.tv_usec - start.tv_usec; - printf("pp avg usec: %ld\n", usec / num); + if (num != 0){ + printf("pp avg usec: %ld\n", usec / num); + }else { + printf("pp avg usec: 0\n"); + } return 0; } -- Gitee From ac0327a878931cb372ddf4648ecb558dd1b2aa5b Mon Sep 17 00:00:00 2001 From: kerwin Date: Wed, 19 Apr 2023 16:13:19 +0800 Subject: [PATCH 3/3] Add checking --poll flag in PP and PP_Flood mode. --- tools/xudpperf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/xudpperf.c b/tools/xudpperf.c index 834e5bb..e232eac 100644 --- a/tools/xudpperf.c +++ b/tools/xudpperf.c @@ -734,10 +734,12 @@ static void parse_argv(int argc, char **argv) } if (0 == strcmp(k, "pp")) { conf.work_mode = WORK_MODE_PP; + conf.poll = true; continue; } if (0 == strcmp(k, "pp-flood")) { conf.work_mode = WORK_MODE_PP_FLOOD; + conf.poll = true; continue; } printf("Invalid work mode(%s), should be: echo, recv, send, pp.\n", k); -- Gitee