From: Cunming Liang <cunming.liang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 2/4] app/test: measure standalone rx or tx cycles/packet
Date: Fri, 10 Oct 2014 20:29:59 +0800 [thread overview]
Message-ID: <1412944201-30703-3-git-send-email-cunming.liang@intel.com> (raw)
In-Reply-To: <1412944201-30703-1-git-send-email-cunming.liang@intel.com>
The unit test to support measure rx or tx only.
Usage Example:
1. Run unit test app in interactive mode
app/test -c f -n 4 -- -i
2. Choose rx or tx standalone, default is both
set_rxtx_anchor [rxtx|rxonly|txonly]
3. Run and wait for the result
pmd_perf_autotest
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test/commands.c | 38 ++++++++++
app/test/test.h | 1 +
app/test/test_pmd_perf.c | 175 ++++++++++++++++++++++++++++++++++++++--------
3 files changed, 185 insertions(+), 29 deletions(-)
diff --git a/app/test/commands.c b/app/test/commands.c
index f1e746e..7c5d812 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -346,6 +346,43 @@ cmdline_parse_inst_t cmd_set_rxtx = {
/****************/
+/****************/
+
+struct cmd_set_rxtx_anchor {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t type;
+};
+
+static void
+cmd_set_rxtx_anchor_parsed(void *parsed_result,
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_set_rxtx_anchor *res = parsed_result;
+ if (test_set_rxtx_anchor(res->type) < 0)
+ cmdline_printf(cl, "Cannot find such anchor\n");
+}
+
+cmdline_parse_token_string_t cmd_set_rxtx_anchor_set =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_anchor, set,
+ "set_rxtx_anchor");
+
+cmdline_parse_token_string_t cmd_set_rxtx_anchor_type =
+ TOKEN_STRING_INITIALIZER(struct cmd_set_rxtx_anchor, type, NULL);
+
+cmdline_parse_inst_t cmd_set_rxtx_anchor = {
+ .f = cmd_set_rxtx_anchor_parsed, /* function to call */
+ .data = NULL, /* 2nd arg of func */
+ .help_str = "set rxtx anchor: "
+ "set_rxtx_anchor <type>",
+ .tokens = { /* token list, NULL terminated */
+ (void *)&cmd_set_rxtx_anchor_set,
+ (void *)&cmd_set_rxtx_anchor_type,
+ NULL,
+ },
+};
+
+/****************/
cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_autotest,
@@ -354,6 +391,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_set_ring,
(cmdline_parse_inst_t *)&cmd_quit,
(cmdline_parse_inst_t *)&cmd_set_rxtx,
+ (cmdline_parse_inst_t *)&cmd_set_rxtx_anchor,
NULL,
};
diff --git a/app/test/test.h b/app/test/test.h
index 76033a8..68ae4bf 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -141,6 +141,7 @@ int test_mp_secondary(void);
int test_ivshmem(void);
int test_set_rxtx_conf(cmdline_fixed_string_t mode);
+int test_set_rxtx_anchor(cmdline_fixed_string_t type);
typedef int (test_callback)(void);
TAILQ_HEAD(test_commands_list, test_command);
diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index bca4a9a..a6d6ea7 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -364,6 +364,125 @@ signal_handler(int signum)
#define MAX_TRAFIC_BURST (4096)
struct rte_mbuf *tx_burst[MAX_TRAFIC_BURST];
+uint64_t (*do_measure)(struct lcore_conf *conf,
+ struct rte_mbuf *pkts_burst[],
+ uint64_t total_pkts);
+
+static uint64_t
+measure_rxtx(struct lcore_conf *conf,
+ struct rte_mbuf *pkts_burst[],
+ uint64_t total_pkts)
+{
+ unsigned i, portid, nb_rx, nb_tx;
+ uint64_t prev_tsc, cur_tsc;
+
+ prev_tsc = rte_rdtsc();
+
+ while (likely(!stop)) {
+ for (i = 0; i < conf->nb_ports; i++) {
+ portid = conf->portlist[i];
+ nb_rx = rte_eth_rx_burst((uint8_t) portid, 0,
+ pkts_burst, MAX_PKT_BURST);
+ if (unlikely(nb_rx == 0)) {
+ idle++;
+ continue;
+ }
+
+ count += nb_rx;
+ nb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);
+ if (unlikely(nb_tx < nb_rx)) {
+ drop += (nb_rx - nb_tx);
+ do {
+ rte_pktmbuf_free(pkts_burst[nb_tx]);
+ } while (++nb_tx < nb_rx);
+ }
+ }
+ if (unlikely(count >= total_pkts))
+ break;
+ }
+
+ cur_tsc = rte_rdtsc();
+
+ return cur_tsc - prev_tsc;
+}
+
+static uint64_t
+measure_rxonly(struct lcore_conf *conf,
+ struct rte_mbuf *pkts_burst[],
+ uint64_t total_pkts)
+{
+ unsigned i, portid, nb_rx, nb_tx;
+ uint64_t diff_tsc, cur_tsc;
+
+ diff_tsc = 0;
+ while (likely(!stop)) {
+ for (i = 0; i < conf->nb_ports; i++) {
+ portid = conf->portlist[i];
+
+ cur_tsc = rte_rdtsc();
+ nb_rx = rte_eth_rx_burst((uint8_t) portid, 0,
+ pkts_burst, MAX_PKT_BURST);
+ if (unlikely(nb_rx == 0)) {
+ idle++;
+ continue;
+ }
+ diff_tsc += rte_rdtsc() - cur_tsc;
+
+ count += nb_rx;
+ nb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);
+ if (unlikely(nb_tx < nb_rx)) {
+ drop += (nb_rx - nb_tx);
+ do {
+ rte_pktmbuf_free(pkts_burst[nb_tx]);
+ } while (++nb_tx < nb_rx);
+ }
+ }
+ if (unlikely(count >= total_pkts))
+ break;
+ }
+
+ return diff_tsc;
+}
+
+static uint64_t
+measure_txonly(struct lcore_conf *conf,
+ struct rte_mbuf *pkts_burst[],
+ uint64_t total_pkts)
+{
+ unsigned i, portid, nb_rx, nb_tx;
+ uint64_t diff_tsc, cur_tsc;
+
+ printf("do tx measure\n");
+ diff_tsc = 0;
+ while (likely(!stop)) {
+ for (i = 0; i < conf->nb_ports; i++) {
+ portid = conf->portlist[i];
+ nb_rx = rte_eth_rx_burst((uint8_t) portid, 0,
+ pkts_burst, MAX_PKT_BURST);
+ if (unlikely(nb_rx == 0)) {
+ idle++;
+ continue;
+ }
+
+ count += nb_rx;
+
+ cur_tsc = rte_rdtsc();
+ nb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);
+ if (unlikely(nb_tx < nb_rx)) {
+ drop += (nb_rx - nb_tx);
+ do {
+ rte_pktmbuf_free(pkts_burst[nb_tx]);
+ } while (++nb_tx < nb_rx);
+ }
+ diff_tsc += rte_rdtsc() - cur_tsc;
+ }
+ if (unlikely(count >= total_pkts))
+ break;
+ }
+
+ return diff_tsc;
+}
+
/* main processing loop */
static int
main_loop(__rte_unused void *args)
@@ -375,8 +494,8 @@ main_loop(__rte_unused void *args)
unsigned lcore_id;
unsigned i, portid, nb_rx = 0, nb_tx = 0;
struct lcore_conf *conf;
- uint64_t prev_tsc, cur_tsc;
int pkt_per_port;
+ uint64_t diff_tsc;
uint64_t packets_per_second, total_packets;
lcore_id = rte_lcore_id();
@@ -410,32 +529,7 @@ main_loop(__rte_unused void *args)
printf("Test will stop after at least %"PRIu64" packets received\n",
+ total_packets);
- prev_tsc = rte_rdtsc();
-
- while (likely(!stop)) {
- for (i = 0; i < conf->nb_ports; i++) {
- portid = conf->portlist[i];
- nb_rx = rte_eth_rx_burst((uint8_t) portid, 0,
- pkts_burst, MAX_PKT_BURST);
- if (unlikely(nb_rx == 0)) {
- idle++;
- continue;
- }
-
- count += nb_rx;
- nb_tx = rte_eth_tx_burst(portid, 0, pkts_burst, nb_rx);
- if (unlikely(nb_tx < nb_rx)) {
- drop += (nb_rx - nb_tx);
- do {
- rte_pktmbuf_free(pkts_burst[nb_tx]);
- } while (++nb_tx < nb_rx);
- }
- }
- if (unlikely(count >= total_packets))
- break;
- }
-
- cur_tsc = rte_rdtsc();
+ diff_tsc = do_measure(conf, pkts_burst, total_packets);
for (i = 0; i < conf->nb_ports; i++) {
portid = conf->portlist[i];
@@ -455,7 +549,7 @@ main_loop(__rte_unused void *args)
return -1;
printf("%lu packet, %lu drop, %lu idle\n", count, drop, idle);
- printf("Result: %ld cycles per packet\n", (cur_tsc - prev_tsc) / count);
+ printf("Result: %ld cycles per packet\n", diff_tsc / count);
return 0;
}
@@ -559,6 +653,10 @@ test_pmd_perf(void)
init_traffic(mbufpool[socketid], tx_burst, MAX_TRAFIC_BURST);
+ /* do both rxtx by default */
+ if (NULL == do_measure)
+ do_measure = measure_rxtx;
+
rte_eal_remote_launch(main_loop, NULL, slave_id);
if (rte_eal_wait_lcore(slave_id) < 0)
return -1;
@@ -577,7 +675,7 @@ test_pmd_perf(void)
int
test_set_rxtx_conf(cmdline_fixed_string_t mode)
{
- printf("mode is %s\n", mode);
+ printf("mode switch to %s\n", mode);
if (!strcmp(mode, "vector")) {
/* vector rx, tx */
@@ -619,6 +717,25 @@ test_set_rxtx_conf(cmdline_fixed_string_t mode)
return -1;
}
+int
+test_set_rxtx_anchor(cmdline_fixed_string_t type)
+{
+ printf("type switch to %s\n", type);
+
+ if (!strcmp(type, "rxtx")) {
+ do_measure = measure_rxtx;
+ return 0;
+ } else if (!strcmp(type, "rxonly")) {
+ do_measure = measure_rxonly;
+ return 0;
+ } else if (!strcmp(type, "txonly")) {
+ do_measure = measure_txonly;
+ return 0;
+ }
+
+ return -1;
+}
+
static struct test_command pmd_perf_cmd = {
.command = "pmd_perf_autotest",
.callback = test_pmd_perf,
--
1.7.4.1
next prev parent reply other threads:[~2014-10-10 12:23 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-25 6:12 [dpdk-dev] [PATCH 0/5] app/test: unit test to measure cycles per packet Cunming Liang
2014-08-25 6:12 ` [dpdk-dev] [PATCH 1/5] app/test: unit test for rx and tx cycles/packet Cunming Liang
2014-08-25 6:12 ` [dpdk-dev] [PATCH 2/5] app/test: measure standalone rx or " Cunming Liang
2014-08-25 6:12 ` [dpdk-dev] [PATCH 3/5] ixgbe/vpmd: add fix to store unaligned mbuf point array Cunming Liang
2014-08-25 6:12 ` [dpdk-dev] [PATCH 4/5] app/test: add unit test to measure RX burst cycles Cunming Liang
2014-08-25 6:12 ` [dpdk-dev] [PATCH 5/5] app/test: allow to create packets in different sizes Cunming Liang
2014-09-03 1:46 ` [dpdk-dev] [PATCH 0/5] app/test: unit test to measure cycles per packet Zhan, Zhaochen
2014-10-10 12:29 ` [dpdk-dev] [PATCH v2 0/4] " Cunming Liang
2014-10-10 12:29 ` [dpdk-dev] [PATCH v2 1/4] app/test: unit test for rx and tx cycles/packet Cunming Liang
2014-10-10 17:52 ` Neil Horman
2014-10-12 11:10 ` Liang, Cunming
[not found] ` <E115CCD9D858EF4F90C690B0DCB4D8972262B720@IRSMSX108.ger.corp.intel.com>
2014-10-14 0:54 ` Liang, Cunming
2014-10-21 10:33 ` Neil Horman
2014-10-21 10:43 ` Richardson, Bruce
2014-10-21 13:37 ` Neil Horman
2014-10-21 22:43 ` Ananyev, Konstantin
2014-10-21 13:17 ` Liang, Cunming
2014-10-22 14:03 ` Neil Horman
2014-10-22 14:48 ` Liang, Cunming
2014-10-22 14:53 ` Ananyev, Konstantin
2014-10-22 15:09 ` Richardson, Bruce
2014-10-24 3:06 ` Liang, Cunming
2014-10-10 12:29 ` Cunming Liang [this message]
2014-10-10 12:30 ` [dpdk-dev] [PATCH v2 3/4] app/test: add unit test to measure RX burst cycles Cunming Liang
2014-10-10 12:30 ` [dpdk-dev] [PATCH v2 4/4] app/test: allow to create packets in different sizes Cunming Liang
2014-10-20 8:13 ` [dpdk-dev] [PATCH v3 0/2] app/test: unit test to measure cycles per packet Cunming Liang
2014-10-20 8:13 ` [dpdk-dev] [PATCH v3 1/2] app/test: allow to create packets in different sizes Cunming Liang
2014-10-20 8:13 ` [dpdk-dev] [PATCH v3 2/2] app/test: measure the cost of rx/tx routines by cycle number Cunming Liang
2014-10-21 2:40 ` [dpdk-dev] [PATCH v3 0/2] app/test: unit test to measure cycles per packet Liu, Yong
2014-10-24 5:39 ` [dpdk-dev] [PATCH v4 0/3] " Cunming Liang
2014-10-24 5:39 ` [dpdk-dev] [PATCH v4 1/3] app/test: allow to create packets in different sizes Cunming Liang
2014-10-24 5:39 ` [dpdk-dev] [PATCH v4 2/3] app/test: measure the cost of rx/tx routines by cycle number Cunming Liang
2014-10-24 5:39 ` [dpdk-dev] [PATCH v4 3/3] ethdev: fix wrong error return refer to API definition Cunming Liang
2014-10-24 5:57 ` [dpdk-dev] [PATCH v5 0/3] app/test: unit test to measure cycles per packet Cunming Liang
2014-10-24 5:58 ` [dpdk-dev] [PATCH v5 1/3] app/test: allow to create packets in different sizes Cunming Liang
2014-10-24 5:58 ` [dpdk-dev] [PATCH v5 2/3] app/test: measure the cost of rx/tx routines by cycle number Cunming Liang
2014-10-24 5:58 ` [dpdk-dev] [PATCH v5 3/3] ethdev: fix wrong error return refere to API definition Cunming Liang
2014-10-27 1:20 ` [dpdk-dev] [PATCH v6 0/3] app/test: unit test to measure cycles per packet Cunming Liang
2014-10-27 1:20 ` [dpdk-dev] [PATCH v6 1/3] app/test: allow to create packets in different sizes Cunming Liang
2014-10-27 1:20 ` [dpdk-dev] [PATCH v6 2/3] app/test: measure the cost of rx/tx routines by cycle number Cunming Liang
2014-11-11 23:28 ` Thomas Monjalon
2014-11-12 6:32 ` Liang, Cunming
2014-10-27 1:20 ` [dpdk-dev] [PATCH v6 3/3] ethdev: fix wrong error return refere to API definition Cunming Liang
2014-10-27 16:03 ` Ananyev, Konstantin
2014-10-27 1:45 ` [dpdk-dev] [PATCH v6 0/3] app/test: unit test to measure cycles per packet Liu, Yong
2014-10-29 5:06 ` Liang, Cunming
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 0/7] " Cunming Liang
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 1/7] app/test: allow to create packets in different sizes Cunming Liang
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 2/7] ixgbe:clean scattered_rx configure in dev_stop Cunming Liang
2014-11-12 7:53 ` Thomas Monjalon
2014-11-12 8:21 ` Liang, Cunming
2014-11-12 9:24 ` Thomas Monjalon
2014-11-12 10:29 ` Liang, Cunming
2014-11-12 10:32 ` Thomas Monjalon
2014-11-12 10:42 ` Liang, Cunming
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 3/7] ether: new API to format eth_addr in string Cunming Liang
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 4/7] app/testpmd: cleanup eth_addr print Cunming Liang
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 5/7] examples: " Cunming Liang
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 6/7] app/test: measure the cost of rx/tx routines by cycle number Cunming Liang
2014-11-12 6:24 ` [dpdk-dev] [PATCH v7 7/7] ethdev: fix wrong error return refere to API definition Cunming Liang
2014-11-12 23:50 ` [dpdk-dev] [PATCH v7 0/7] app/test: unit test to measure cycles per packet Thomas Monjalon
2014-10-24 5:59 ` [dpdk-dev] [PATCH v4 0/3] " Liang, Cunming
[not found] ` <1414130090-17910-1-git-send-email-y>
[not found] ` <1414130090-17910-4-git-send-email-y>
2014-10-24 11:04 ` [dpdk-dev] [PATCH v5 3/3] ethdev: fix wrong error return refere to API definition Ananyev, Konstantin
2014-10-27 0:58 ` Liang, Cunming
2014-10-28 12:21 ` [dpdk-dev] [PATCH v2 0/4] app/test: unit test to measure cycles per packet Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412944201-30703-3-git-send-email-cunming.liang@intel.com \
--to=cunming.liang@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).