From patchwork Mon Dec 4 09:00:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 120494 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4176084qgn; Mon, 4 Dec 2017 01:02:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMaXbgUe95vTDRpk+hwsnkM+r3lzR+0cC8ST8OyI/71Zdd1vt43Rb62pCSl+gSBRP90VjVdE X-Received: by 10.55.108.7 with SMTP id h7mr19175116qkc.111.1512378171179; Mon, 04 Dec 2017 01:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512378171; cv=none; d=google.com; s=arc-20160816; b=qlk+32yt45A89NaX3EaPRQNqNW7ACjY+h+oB+ugINa7vDj7sogMjlGOd2yMkggQkft Kbr/oJLnFfpq5U10uU6E0yIc7Qhr2sxHNef9k7VWUnjwYsjVriDzIQb5G5BSOv8/EPKP NFIVhKSNel75LxZlu01K9Cqn8jRN/L9dLw5ms8nT0lm+O/GNg57udXg5m5hLpCatazML glGkeZBgJKq2SkDXjEUTK0oFvp6wC3nJbxk1wO6zHkUNLe0jT0PeeEayuYFa0eCBLyJj 1c4UE40QYx7DqPrYkSZ3P7EH3RZ8+MlGzOVRHZTZvo/4AWL9AgmrXnnrDrViHGr7XnQ5 ARVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=WG12sythjIBQ+JdWmCsChPRVSA3exFhjQw5HXaj8j4k=; b=ZVCVYCmlPU4Nr+rgYxZL/OuEiwszrIL0rvIHAnAQY/mrk31ZIdtM5BVf7rAHQ6BnjD xyAG6L9mbYwmZJJfONk8C0laf/WRA8wDW3bT2CYMVXPC/Ga418Os3W6BHcD7impcXhN2 Mlrn2utOwElvPxMh5zb8tMSI51eLVj619qdE0MLgnqbvWpco6TXEacaE5uxDqIsWr9Qp 78NT3Mv/4EaD0OBOZO3KNnTVoWqDyeYdqFL6hOpUHu2AoGBKBcQQgpAXbBhr96WtOOBU wuB+R9Qa49cnTJAOiPOLL6xnbneAeUqdsFB+HU3ysZDAnOR0VC/uvref5FjJTaKu4cIQ v7LA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id p7si7163335qki.429.2017.12.04.01.02.50; Mon, 04 Dec 2017 01:02:51 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id CA0F3608BA; Mon, 4 Dec 2017 09:02:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, URIBL_BLOCKED, URIBL_DBL_ABUSE_SPAM autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 431D3608CC; Mon, 4 Dec 2017 09:00:48 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 8FB0A6086D; Mon, 4 Dec 2017 09:00:35 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id EB94E608A8 for ; Mon, 4 Dec 2017 09:00:30 +0000 (UTC) Received: from mxback1o.mail.yandex.net (mxback1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1b]) by forward100j.mail.yandex.net (Yandex) with ESMTP id CC2675D81966 for ; Mon, 4 Dec 2017 12:00:29 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id PYIGaXZ54B-0TkmMK0v; Mon, 04 Dec 2017 12:00:29 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2pKugCeR78-0TH0iIuU; Mon, 04 Dec 2017 12:00:29 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 4 Dec 2017 12:00:23 +0300 Message-Id: <1512378024-15857-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512378024-15857-1-git-send-email-odpbot@yandex.ru> References: <1512378024-15857-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 313 Subject: [lng-odp] [PATCH API-NEXT v2 4/5] test: l2fwd: add checksum offload option X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Added option to enable checksum insertion at packet output. This can be used to test checksum offload in various packet IO combinations. Signed-off-by: Petri Savolainen --- /** Email created from pull request 313 (psavol:next-pktout-config) ** https://github.com/Linaro/odp/pull/313 ** Patch: https://github.com/Linaro/odp/pull/313.patch ** Base sha: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0 ** Merge commit sha: e4a122986c2750ffb044994107b385bd8002cbf4 **/ test/performance/odp_l2fwd.c | 105 +++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 2daf0e2db..0ebb0dd17 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -92,6 +92,7 @@ static inline int sched_mode(pktin_mode_t in_mode) * Parsed command line application arguments */ typedef struct { + int extra_check; /**< Some extra checks have been enabled */ int cpu_count; int if_count; /**< Number of interfaces to be used */ int addr_count; /**< Number of dst addresses to be used */ @@ -106,6 +107,7 @@ typedef struct { int dst_change; /**< Change destination eth addresses */ int src_change; /**< Change source eth addresses */ int error_check; /**< Check packet errors */ + int chksum; /**< Checksum offload */ int sched_mode; /**< Scheduler mode */ int num_groups; /**< Number of scheduling groups */ int verbose; /**< Verbose output */ @@ -293,6 +295,18 @@ static inline int event_queue_send(odp_queue_t queue, odp_packet_t *pkt_tbl, return sent; } +static inline void chksum_insert(odp_packet_t *pkt_tbl, int pkts) +{ + odp_packet_t pkt; + int i; + + for (i = 0; i < pkts; i++) { + pkt = pkt_tbl[i]; + odp_packet_l3_chksum_insert(pkt, 1); + odp_packet_l4_chksum_insert(pkt, 1); + } +} + /** * Packet IO worker thread using scheduled queues * @@ -366,18 +380,23 @@ static int run_worker_sched_mode(void *arg) for (i = 0; i < pkts; i++) pkt_tbl[i] = odp_packet_from_event(ev_tbl[i]); - if (gbl_args->appl.error_check) { - int rx_drops; + if (odp_unlikely(gbl_args->appl.extra_check)) { + if (gbl_args->appl.chksum) + chksum_insert(pkt_tbl, pkts); - /* Drop packets with errors */ - rx_drops = drop_err_pkts(pkt_tbl, pkts); + if (gbl_args->appl.error_check) { + int rx_drops; - if (odp_unlikely(rx_drops)) { - stats->s.rx_drops += rx_drops; - if (pkts == rx_drops) - continue; + /* Drop packets with errors */ + rx_drops = drop_err_pkts(pkt_tbl, pkts); - pkts -= rx_drops; + if (odp_unlikely(rx_drops)) { + stats->s.rx_drops += rx_drops; + if (pkts == rx_drops) + continue; + + pkts -= rx_drops; + } } } @@ -487,18 +506,23 @@ static int run_worker_plain_queue_mode(void *arg) for (i = 0; i < pkts; i++) pkt_tbl[i] = odp_packet_from_event(event[i]); - if (gbl_args->appl.error_check) { - int rx_drops; + if (odp_unlikely(gbl_args->appl.extra_check)) { + if (gbl_args->appl.chksum) + chksum_insert(pkt_tbl, pkts); - /* Drop packets with errors */ - rx_drops = drop_err_pkts(pkt_tbl, pkts); + if (gbl_args->appl.error_check) { + int rx_drops; - if (odp_unlikely(rx_drops)) { - stats->s.rx_drops += rx_drops; - if (pkts == rx_drops) - continue; + /* Drop packets with errors */ + rx_drops = drop_err_pkts(pkt_tbl, pkts); - pkts -= rx_drops; + if (odp_unlikely(rx_drops)) { + stats->s.rx_drops += rx_drops; + if (pkts == rx_drops) + continue; + + pkts -= rx_drops; + } } } @@ -605,18 +629,23 @@ static int run_worker_direct_mode(void *arg) if (odp_unlikely(pkts <= 0)) continue; - if (gbl_args->appl.error_check) { - int rx_drops; + if (odp_unlikely(gbl_args->appl.extra_check)) { + if (gbl_args->appl.chksum) + chksum_insert(pkt_tbl, pkts); + + if (gbl_args->appl.error_check) { + int rx_drops; - /* Drop packets with errors */ - rx_drops = drop_err_pkts(pkt_tbl, pkts); + /* Drop packets with errors */ + rx_drops = drop_err_pkts(pkt_tbl, pkts); - if (odp_unlikely(rx_drops)) { - stats->s.rx_drops += rx_drops; - if (pkts == rx_drops) - continue; + if (odp_unlikely(rx_drops)) { + stats->s.rx_drops += rx_drops; + if (pkts == rx_drops) + continue; - pkts -= rx_drops; + pkts -= rx_drops; + } } } @@ -707,9 +736,17 @@ static int create_pktio(const char *dev, int idx, int num_rx, int num_tx, } odp_pktio_config_init(&config); - config.parser.layer = gbl_args->appl.error_check ? + config.parser.layer = gbl_args->appl.extra_check ? ODP_PKTIO_PARSER_LAYER_ALL : ODP_PKTIO_PARSER_LAYER_NONE; + + if (gbl_args->appl.chksum) { + printf("Checksum offload enabled\n"); + config.pktout.bit.ipv4_chksum_ena = 1; + config.pktout.bit.udp_chksum_ena = 1; + config.pktout.bit.tcp_chksum_ena = 1; + } + odp_pktio_config(pktio, &config); odp_pktin_queue_param_init(&pktin_param); @@ -1132,9 +1169,12 @@ static void usage(char *progname) " Requires also the -d flag to be set\n" " -e, --error_check 0: Don't check packet errors (default)\n" " 1: Check packet errors\n" + " -k, --chksum 0: Don't use checksum offload (default)\n" + " 1: Use checksum offload\n" " -g, --groups Number of groups to use: 0 ... num\n" " 0: SCHED_GROUP_ALL (default)\n" " num: must not exceed number of interfaces or workers\n" + " -v, --verbose Verbose output.\n" " -h, --help Display help and exit.\n\n" "\n", NO_PATH(progname), NO_PATH(progname), MAX_PKTIOS ); @@ -1166,13 +1206,14 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) {"dst_change", required_argument, NULL, 'd'}, {"src_change", required_argument, NULL, 's'}, {"error_check", required_argument, NULL, 'e'}, + {"chksum", required_argument, NULL, 'k'}, {"groups", required_argument, NULL, 'g'}, {"verbose", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0} }; - static const char *shortopts = "+c:+t:+a:i:m:o:r:d:s:e:g:vh"; + static const char *shortopts = "+c:+t:+a:i:m:o:r:d:s:e:k:g:vh"; /* let helper collect its own arguments (e.g. --odph_proc) */ odph_parse_options(argc, argv, shortopts, longopts); @@ -1184,6 +1225,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->num_groups = 0; /* use default group */ appl_args->error_check = 0; /* don't check packet errors by default */ appl_args->verbose = 0; + appl_args->chksum = 0; /* don't use checksum offload by default */ opterr = 0; /* do not issue errors on helper options */ @@ -1308,6 +1350,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) case 'e': appl_args->error_check = atoi(optarg); break; + case 'k': + appl_args->chksum = atoi(optarg); + break; case 'g': appl_args->num_groups = atoi(optarg); break; @@ -1335,6 +1380,8 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) exit(EXIT_FAILURE); } + appl_args->extra_check = appl_args->error_check || appl_args->chksum; + optind = 1; /* reset 'extern optind' from the getopt lib */ }