aboutsummaryrefslogtreecommitdiff
path: root/test/performance
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2015-10-30 11:24:59 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-11-03 16:36:06 +0300
commitac4d1b97deb4682a090111043a9515ee829cf2bc (patch)
tree0eae4fe67fe590c62f9544d5bc761fc63310fb0a /test/performance
parentda3bfb3c0641af1bbcd4c57676c17b28e7990f2b (diff)
test: l2fwd: added option to disable error check
Added command line option to disable packet error check. Error check requires full packet parse. Max packet rate measurements should be done with minimal feature set. This change gives +10% packet rate increase in direct recv mode with netmap. Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Nicolas Morey-Chaisemartin <nmorey@kalray.eu> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test/performance')
-rw-r--r--test/performance/odp_l2fwd.c89
1 files changed, 54 insertions, 35 deletions
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 0844f000d..69b67a045 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -69,8 +69,9 @@ typedef struct {
int time; /**< Time in seconds to run. */
int accuracy; /**< Number of seconds to get and print statistics */
char *if_str; /**< Storage for interface names */
- int dst_change; /**< Change destination eth addresses > */
- int src_change; /**< Change source eth addresses > */
+ int dst_change; /**< Change destination eth addresses */
+ int src_change; /**< Change source eth addresses */
+ int error_check; /**< Check packet errors */
} appl_args_t;
static int exit_threads; /**< Break workers loop if set to 1 */
@@ -119,7 +120,7 @@ static odp_barrier_t barrier;
/* helper funcs */
static inline int lookup_dest_port(odp_packet_t pkt);
static inline int find_dest_port(int port);
-static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len);
+static inline int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned num);
static void fill_eth_addrs(odp_packet_t pkt_tbl[], unsigned num,
int dst_port);
static void parse_args(int argc, char *argv[], appl_args_t *appl_args);
@@ -158,10 +159,12 @@ static void *pktio_queue_thread(void *arg)
continue;
pkt = odp_packet_from_event(ev);
- /* Drop packets with errors */
- if (odp_unlikely(drop_err_pkts(&pkt, 1) == 0)) {
- stats->drops += 1;
- continue;
+ if (gbl_args->appl.error_check) {
+ /* Drop packets with errors */
+ if (odp_unlikely(drop_err_pkts(&pkt, 1))) {
+ stats->drops += 1;
+ continue;
+ }
}
dst_port = lookup_dest_port(pkt);
@@ -232,7 +235,7 @@ static void *pktio_direct_recv_thread(void *arg)
{
int thr;
thread_args_t *thr_args;
- int pkts, pkts_ok;
+ int pkts;
odp_packet_t pkt_tbl[MAX_PKT_BURST];
int src_idx, dst_idx;
odp_pktio_t pktio_src, pktio_dst;
@@ -258,33 +261,42 @@ static void *pktio_direct_recv_thread(void *arg)
/* Loop packets */
while (!exit_threads) {
+ int sent, i;
+ unsigned tx_drops;
+ int rx_drops = 0;
+
pkts = odp_pktio_recv(pktio_src, pkt_tbl, MAX_PKT_BURST);
- if (pkts <= 0)
+ if (odp_unlikely(pkts <= 0))
continue;
- /* Drop packets with errors */
- pkts_ok = drop_err_pkts(pkt_tbl, pkts);
- if (pkts_ok > 0) {
- fill_eth_addrs(pkt_tbl, pkts_ok, dst_idx);
+ if (gbl_args->appl.error_check) {
+ /* Drop packets with errors */
+ rx_drops = drop_err_pkts(pkt_tbl, pkts);
- int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok);
-
- sent = sent > 0 ? sent : 0;
- if (odp_unlikely(sent < pkts_ok)) {
- stats->drops += pkts_ok - sent;
- do
- odp_packet_free(pkt_tbl[sent]);
- while (++sent < pkts_ok);
+ if (odp_unlikely(rx_drops)) {
+ if (pkts == rx_drops) {
+ stats->drops += rx_drops;
+ continue;
+ }
+ pkts -= rx_drops;
}
}
- if (odp_unlikely(pkts_ok != pkts))
- stats->drops += pkts - pkts_ok;
+ fill_eth_addrs(pkt_tbl, pkts, dst_idx);
- if (pkts_ok == 0)
- continue;
+ sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts);
- stats->packets += pkts_ok;
+ sent = odp_unlikely(sent < 0) ? 0 : sent;
+ tx_drops = pkts - sent;
+
+ if (odp_unlikely(tx_drops)) {
+ /* Drop rejected packets */
+ for (i = sent; i < pkts; i++)
+ odp_packet_free(pkt_tbl[i]);
+ }
+
+ stats->drops += rx_drops + tx_drops;
+ stats->packets += pkts;
}
free(stats);
@@ -589,29 +601,29 @@ int main(int argc, char *argv[])
* Frees packets with error and modifies pkt_tbl[] to only contain packets with
* no detected errors.
*
- * @param pkt_tbl Array of packet
- * @param len Length of pkt_tbl[]
+ * @param pkt_tbl Array of packets
+ * @param num Number of packets in pkt_tbl[]
*
- * @return Number of packets with no detected error
+ * @return Number of packets dropped
*/
-static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len)
+static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned num)
{
odp_packet_t pkt;
- unsigned pkt_cnt = len;
+ unsigned dropped = 0;
unsigned i, j;
- for (i = 0, j = 0; i < len; ++i) {
+ for (i = 0, j = 0; i < num; ++i) {
pkt = pkt_tbl[i];
if (odp_unlikely(odp_packet_has_error(pkt))) {
odp_packet_free(pkt); /* Drop */
- pkt_cnt--;
+ dropped++;
} else if (odp_unlikely(i != j++)) {
pkt_tbl[j-1] = pkt;
}
}
- return pkt_cnt;
+ return dropped;
}
/**
@@ -666,6 +678,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"mode", required_argument, NULL, 'm'},
{"dst_change", required_argument, NULL, 'd'},
{"src_change", required_argument, NULL, 's'},
+ {"error_check", required_argument, NULL, 'e'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
@@ -673,9 +686,10 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
appl_args->time = 0; /* loop forever if time to run is 0 */
appl_args->accuracy = 1; /* get and print pps stats second */
appl_args->src_change = 1; /* change eth src address by default */
+ appl_args->error_check = 0; /* don't check packet errors by default */
while (1) {
- opt = getopt_long(argc, argv, "+c:+t:+a:i:m:d:s:h",
+ opt = getopt_long(argc, argv, "+c:+t:+a:i:m:d:s:e:h",
longopts, &long_index);
if (opt == -1)
@@ -748,6 +762,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
case 's':
appl_args->src_change = atoi(optarg);
break;
+ case 'e':
+ appl_args->error_check = atoi(optarg);
+ break;
case 'h':
usage(argv[0]);
exit(EXIT_SUCCESS);
@@ -835,6 +852,8 @@ static void usage(char *progname)
" 1: Change packets' dst eth addresses\n"
" -s, --src_change 0: Don't change packets' src eth addresses\n"
" 1: Change packets' src eth addresses (default)\n"
+ " -e, --error_check 0: Don't check packet errors (default)\n"
+ " 1: Check packet errors\n"
" -h, --help Display help and exit.\n\n"
" environment variables: ODP_PKTIO_DISABLE_NETMAP\n"
" ODP_PKTIO_DISABLE_SOCKET_MMAP\n"