From patchwork Tue Jan 9 12:00:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123896 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3935405qgn; Tue, 9 Jan 2018 04:04:15 -0800 (PST) X-Google-Smtp-Source: ACJfBosdFrFqKaDDUrgIRSvrHP+5PZGBJekxbsH/t2OkAn55Mtp1BuNfh6Wuy9dg15rlrQ76CLtq X-Received: by 10.237.55.226 with SMTP id j89mr19582625qtb.245.1515499455576; Tue, 09 Jan 2018 04:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515499455; cv=none; d=google.com; s=arc-20160816; b=qiT/lC7HKnKuPGGCwrWyLNAOx2aonXkGYzthXj9xM43zgCYlGvZCiAvJ+HYKN0oVcd QkcmkZKDFvf21F0ljbgA/bKri/ThJE5Me4fFTM+nrCe7Iiy20BAbfx6Riw6MjojwobWk a+8+mRhWPA9Gfq2iEcm533O8IuI89djZ7SDdjHPJiOnXepsZnCiJOjjApkL6eUFEn091 5Xa0vlMXpo1x+U1RNhH+XULEnHfGLKf/VUVmlzStQB19P85YlGTc6bZiOzCr8ePvAK89 v3al2nHkWo9To03WqbxKP+MOdlpk5btlo/Wp9Yzk2wUeWqPsPUvvg8e95FFRaudHa9Ey JVXw== 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=JfHqNCSN239mL+KGuTf2zUGRfCiShZJ+WJ9otLfdJfQ=; b=dQqH9pA05NzI6J8mLLUnqLsmklQaJf/ojE4IZCzuADsgg18Nfmb4/XwBina9igQ3fq RfFmJIY88DdeABUVZqT/Pv2J7la5DlNW7UDcY3AlqsPz7dp6p0YeFO9T7Bl2ppWdkvaG 3u3Lx2leAcOjzuFK8LTBne6Xfo8y6dPDz6HfbVS+gcpdK+cISNAz3UGuK+ilobcD9v/p birtEI8SvUaSQze8te9iKKtDMm39N/1Xw7jsmcpjdhpclU7juHcQ2AzqecsfrhSAx0tY 2mZeyH1uoWZgLDNT/fePGr3BUiteitUc8b+OzbbDrs9SVrna/nc7Y8Xl2gdWGAxsWUh/ Xf8A== 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 t129si322027qkc.27.2018.01.09.04.04.15; Tue, 09 Jan 2018 04:04:15 -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 3BAB561713; Tue, 9 Jan 2018 12:04:15 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 4BC9E61721; Tue, 9 Jan 2018 12:03:14 +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 938FA61720; Tue, 9 Jan 2018 12:03:08 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id A87D761719 for ; Tue, 9 Jan 2018 12:00:21 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 4A35A5A0349B for ; Tue, 9 Jan 2018 15:00:20 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id l3HZCP2JaQ-0JtCM5P3; Tue, 09 Jan 2018 15:00:20 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 0CYWcrRWVI-0J5K9Xhk; Tue, 09 Jan 2018 15:00:19 +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: Tue, 9 Jan 2018 15:00:12 +0300 Message-Id: <1515499216-4272-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> References: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v3 1/5] example: generator: add configuration option for RX burst size 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: Bogdan Pricope Add CLI option to configure RX burst size. Bigger RX burst size may increase packet RX rate. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 343 (bogdanPricope:generator_rx_direct_pr) ** https://github.com/Linaro/odp/pull/343 ** Patch: https://github.com/Linaro/odp/pull/343.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 2eefe24f19e219515f14085c88dda09761f71845 **/ example/generator/odp_generator.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index b1827e9c9..69a03dd26 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -28,7 +28,8 @@ #define DEFAULT_PKT_INTERVAL 1000 /* Interval between each packet */ #define DEFAULT_UDP_TX_BURST 16 #define MAX_UDP_TX_BURST 512 -#define MAX_RX_BURST 32 +#define DEFAULT_RX_BURST 32 +#define MAX_RX_BURST 512 #define APPL_MODE_UDP 0 /**< UDP mode */ #define APPL_MODE_PING 1 /**< ping mode */ @@ -80,6 +81,8 @@ typedef struct { each packet */ int udp_tx_burst; /**< number of udp packets to send with one API call */ + int rx_burst; /**< number of packets to receive with one + API call */ odp_bool_t csum; /**< use platform csum support if available */ } appl_args_t; @@ -130,6 +133,7 @@ typedef struct { /** Global arguments */ int thread_cnt; int tx_burst_size; + int rx_burst_size; } args_t; /** Global pointer to args */ @@ -828,10 +832,11 @@ static int gen_recv_thread(void *arg) odp_event_t events[MAX_RX_BURST]; int pkt_cnt, ev_cnt, i; odp_packet_chksum_status_t csum_status; + int burst_size; - (void)arg; thr = odp_thread_id(); thr_args = (thread_args_t *)arg; + burst_size = args->rx_burst_size; printf(" [%02i] created mode: RECEIVE\n", thr); odp_barrier_wait(&barrier); @@ -842,7 +847,7 @@ static int gen_recv_thread(void *arg) /* Use schedule to get buf from any input queue */ ev_cnt = odp_schedule_multi(NULL, ODP_SCHED_NO_WAIT, - events, MAX_RX_BURST); + events, burst_size); if (ev_cnt == 0) continue; for (i = 0, pkt_cnt = 0; i < ev_cnt; i++) { @@ -1076,12 +1081,16 @@ int main(int argc, char *argv[]) args->thread_cnt = num_workers; /* Burst size */ - if (args->appl.mode == APPL_MODE_PING) + if (args->appl.mode == APPL_MODE_PING) { args->tx_burst_size = 1; - else if (args->appl.mode == APPL_MODE_UDP) + args->rx_burst_size = 1; + } else if (args->appl.mode == APPL_MODE_UDP) { args->tx_burst_size = args->appl.udp_tx_burst; - else + args->rx_burst_size = 0; + } else { args->tx_burst_size = 0; + args->rx_burst_size = args->appl.rx_burst; + } /* Create packet pool */ odp_pool_param_init(¶ms); @@ -1383,11 +1392,12 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) {"interval", required_argument, NULL, 'i'}, {"help", no_argument, NULL, 'h'}, {"udp_tx_burst", required_argument, NULL, 'x'}, + {"rx_burst", required_argument, NULL, 'r'}, {"csum", no_argument, NULL, 'y'}, {NULL, 0, NULL, 0} }; - static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:f:y"; + static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:f:yr:"; /* let helper collect its own arguments (e.g. --odph_proc) */ odph_parse_options(argc, argv, shortopts, longopts); @@ -1398,6 +1408,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->timeout = -1; appl_args->interval = DEFAULT_PKT_INTERVAL; appl_args->udp_tx_burst = DEFAULT_UDP_TX_BURST; + appl_args->rx_burst = DEFAULT_RX_BURST; appl_args->srcport = 0; appl_args->dstport = 0; appl_args->csum = 0; @@ -1540,6 +1551,14 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) exit(EXIT_FAILURE); } break; + case 'r': + appl_args->rx_burst = atoi(optarg); + if (appl_args->rx_burst > MAX_RX_BURST) { + EXAMPLE_ERR("wrong Rx burst size (max %d)\n", + MAX_RX_BURST); + exit(EXIT_FAILURE); + } + break; case 'y': appl_args->csum = 1; @@ -1630,6 +1649,7 @@ static void usage(char *progname) " -n, --count the number of packets to be send\n" " -c, --cpumask to set on cores\n" " -x, --udp_tx_burst size of UDP TX burst\n" + " -r, --rx_burst size of RX burst\n" " -y, --csum use platform checksum support if available\n" " default is disabled\n" "\n", NO_PATH(progname), NO_PATH(progname) From patchwork Tue Jan 9 12:00:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123898 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3937668qgn; Tue, 9 Jan 2018 04:06:04 -0800 (PST) X-Google-Smtp-Source: ACJfBovNiiW8Zhkim14VNa326WhhfsI0PE/2Imi5UbLPSAL/U5xlunj2iW6j6CBQtITXpJ07ZUBr X-Received: by 10.200.4.139 with SMTP id s11mr20347193qtg.144.1515499563959; Tue, 09 Jan 2018 04:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515499563; cv=none; d=google.com; s=arc-20160816; b=cuBDhJe+fs/XLpHz1U/h/b9JUAGVYHtWMyz+dxQi6aLiz7p/n9Yjb3xedgTca5JPQn J9BmD4QdFR3MThH9pLtOtklXTUtUXIjQKD76sf8OfUegVHrmuhPaPkL02dXMvRyoZpTU KOyoBGLMwjU4PommXJsGt9F/sC4C9RA0KPAG2D/F7Al1jLnZF/sICwAR40pyry4Nef0y 46AmD/UcZcY8JaE/QtXIr2zdIWk1Ditl5B3afJmFokRqafJHFyd6q2uWUc9dYbizMQzF z++XJ051lLrvKyUq2TZL40uefwbtegqYAItnMtGru21TKJP2syk0lIP3Lb5f55Mmvh9C ug/g== 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=rMTCBc1wIg6Ywq9R5eNH0Y24F+0Q6pGQDQkPwyBWlMY=; b=aSVZQMigLFBRSNiVhsZW1t54INoEEx7K9KJHebbE7bUYOC0j9fx69E0cVRDCKzd8Ob 6Xp1rVsmoyMaVXWaJtyZRL1priM712F/ywFth67gPGQujQqVJzETey/E3SRSWJjDjb5e 9Ch7MtpHm3AOFLFNhnh+FnVJ8lJYy2ny6urT9/c+q3uF+JfABP8Z1bknmtr2RqR632n0 K2juATK5VT1X8sQew/dWGaeZVyDohhDzMcPRuxo2BECzfk/H9LszzV5amn9gaTN+BHjB rTPJg5KDMR/L5ylUbwygIVoh3wIph5g/GPbM5IaoiurlUX26YZYvtfdXIx68dLscNAa7 Ae9A== 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 y1si1020553qkl.94.2018.01.09.04.06.03; Tue, 09 Jan 2018 04:06:03 -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 7093E616F9; Tue, 9 Jan 2018 12:06:03 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 0AAC161519; Tue, 9 Jan 2018 12:03:31 +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 229D26171D; Tue, 9 Jan 2018 12:03:19 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 77D056171A for ; Tue, 9 Jan 2018 12:00:22 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward104j.mail.yandex.net (Yandex) with ESMTP id DB703441EA for ; Tue, 9 Jan 2018 15:00:20 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id umSyiLKpx7-0KCeP86x; Tue, 09 Jan 2018 15:00:20 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 0CYWcrRWVI-0K5KqjgS; Tue, 09 Jan 2018 15:00:20 +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: Tue, 9 Jan 2018 15:00:13 +0300 Message-Id: <1515499216-4272-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> References: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v3 2/5] example: generator: add configuration option for scheduler RX 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: Bogdan Pricope Add CLI option to enable/disable packet receive with scheduler API. Default: use direct mode API. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 343 (bogdanPricope:generator_rx_direct_pr) ** https://github.com/Linaro/odp/pull/343 ** Patch: https://github.com/Linaro/odp/pull/343.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 2eefe24f19e219515f14085c88dda09761f71845 **/ example/generator/odp_generator.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 69a03dd26..c09cf52a8 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -84,6 +84,7 @@ typedef struct { int rx_burst; /**< number of packets to receive with one API call */ odp_bool_t csum; /**< use platform csum support if available */ + odp_bool_t sched; /**< use scheduler API to receive packets */ } appl_args_t; /** @@ -1394,10 +1395,11 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) {"udp_tx_burst", required_argument, NULL, 'x'}, {"rx_burst", required_argument, NULL, 'r'}, {"csum", no_argument, NULL, 'y'}, + {"sched", no_argument, NULL, 'z'}, {NULL, 0, NULL, 0} }; - static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:f:yr:"; + static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:f:yr:z"; /* let helper collect its own arguments (e.g. --odph_proc) */ odph_parse_options(argc, argv, shortopts, longopts); @@ -1412,6 +1414,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->srcport = 0; appl_args->dstport = 0; appl_args->csum = 0; + appl_args->sched = 0; opterr = 0; /* do not issue errors on helper options */ @@ -1563,6 +1566,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) case 'y': appl_args->csum = 1; break; + case 'z': + appl_args->sched = 1; + break; case 'h': usage(argv[0]); exit(EXIT_SUCCESS); @@ -1652,6 +1658,8 @@ static void usage(char *progname) " -r, --rx_burst size of RX burst\n" " -y, --csum use platform checksum support if available\n" " default is disabled\n" + " -z, --sched use scheduler API to receive packets\n" + " default is direct mode API\n" "\n", NO_PATH(progname), NO_PATH(progname) ); } From patchwork Tue Jan 9 12:00:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123897 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3936402qgn; Tue, 9 Jan 2018 04:05:04 -0800 (PST) X-Google-Smtp-Source: ACJfBosetYdjhGQKf5EZU5DJu//4baiGLYn7CyF7m/TpcR73bJzr7Mb++MAQIFe3S/iRru91mvwV X-Received: by 10.55.19.30 with SMTP id d30mr19435972qkh.288.1515499504705; Tue, 09 Jan 2018 04:05:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515499504; cv=none; d=google.com; s=arc-20160816; b=l+YlDJ5HUcWVfD6x/oVW2DkfQR5v1NpqcFweY7xox6xultLJqtruB5KB55gXZ6tpRi j5bCv/cgIQBjByzuyo0JIvfaYBOkDcM3JTROB8cM4wqSrHPKcYlly4C+Bj5g7w0bfRLn GlyYhGgBZQaZw23PCk1R/lobnZn599k09LIXRt80JFrAsz2cU0IlC17UNVajGL8s84Dh /djTrD2gJyHgZUM0qAGga1pGZVSBgmV1FWQRKxCBg883M4JmMGEpg9z4puBHjJ4BW4rO oTSymJPLHc+u9e0d3fFnjJpvkC+QFNlolNbK4vtgRyECeAlAKAs43aApt3E8uq8JScA/ l7IQ== 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=Jri82i2dmdynFRf1EFGZXsxW1tHana0R/SQo7kPyoqw=; b=szxL9FKby1QIKhQxwDNDTNZUAgGHRHoE1BHl5L/R7/a4gBbL0G4uPlbpfN3HqZnAV0 YpqFLhQFycRlpvlRpStX7ZFepeI8I940GoEopMHDcacIrjTYTOzAW1POxGIzoeIKzDaV ZCQ1rzUb/7VeHwy3wit02ExJps5/kcqKOyk3JIt6i5bsLKrYzvrTYgT0dzSTdYGe5y3Z Pw3Ct0vHCOswcdjH6f7XbvmQu66XhzNTYPA1b2EPvG+TzyELqx8loTGe8s4sXfW7Nsix 9Pj0+G1ozKCgMOPNRXg6PNg42RGnKi+Ypp90WgPkdxoW5MA8KLjLWJipkJ/kURFpl3Yj VCPA== 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 s184si12663268qkc.444.2018.01.09.04.05.04; Tue, 09 Jan 2018 04:05:04 -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 61E746151D; Tue, 9 Jan 2018 12:05:04 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 B379561706; Tue, 9 Jan 2018 12:03:24 +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 7007461720; Tue, 9 Jan 2018 12:03:17 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id E9D336171D for ; Tue, 9 Jan 2018 12:00:22 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 99C9F34C4A40 for ; Tue, 9 Jan 2018 15:00:21 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id V7uGje8foB-0LYmLw8p; Tue, 09 Jan 2018 15:00:21 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 0CYWcrRWVI-0K5ux34B; Tue, 09 Jan 2018 15:00:20 +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: Tue, 9 Jan 2018 15:00:14 +0300 Message-Id: <1515499216-4272-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> References: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v3 3/5] example: generator: add direct mode pktio configuration 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: Bogdan Pricope Update interface configuration function to support direct mode in addition to scheduler mode. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 343 (bogdanPricope:generator_rx_direct_pr) ** https://github.com/Linaro/odp/pull/343 ** Patch: https://github.com/Linaro/odp/pull/343.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 2eefe24f19e219515f14085c88dda09761f71845 **/ example/generator/odp_generator.c | 112 +++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 39 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index c09cf52a8..6ab25280c 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -55,6 +55,8 @@ typedef struct { odp_pktio_config_t config; odp_pktout_queue_t pktout[MAX_WORKERS]; unsigned pktout_count; + odp_pktin_queue_t pktin[MAX_WORKERS]; + unsigned pktin_count; } interface_t; /** @@ -111,6 +113,7 @@ typedef struct { odp_pktout_config_opt_t *pktout_cfg; /**< Packet output config*/ } tx; struct { + odp_pktin_queue_t pktin; /**< Packet input queue */ interface_t *ifs; /**< Interfaces array */ int ifs_count; /**< Interfaces array size */ } rx; @@ -520,10 +523,15 @@ static int create_pktio(const char *dev, odp_pool_t pool, odp_pktio_param_t pktio_param; odp_pktin_queue_param_t pktin_param; odp_pktout_queue_param_t pktout_param; - odp_pktio_op_mode_t pktout_mode; + odp_pktio_op_mode_t pktout_mode, pktin_mode; + odp_bool_t sched = args->appl.sched; odp_pktio_param_init(&pktio_param); - pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + pktio_param.in_mode = num_rx_queues ? + (sched ? ODP_PKTIN_MODE_SCHED : ODP_PKTIN_MODE_DIRECT) : + ODP_PKTIN_MODE_DISABLED; + pktio_param.out_mode = num_tx_queues ? ODP_PKTOUT_MODE_DIRECT : + ODP_PKTOUT_MODE_DISABLED; /* Open a packet IO instance */ itf->pktio = odp_pktio_open(dev, pool, &pktio_param); @@ -572,31 +580,47 @@ static int create_pktio(const char *dev, odp_pool_t pool, return -1; } - if (num_rx_queues > capa.max_input_queues) - num_rx_queues = capa.max_input_queues; - - odp_pktin_queue_param_init(&pktin_param); - pktin_param.num_queues = num_rx_queues; - pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC; + if (num_rx_queues) { + pktin_mode = ODP_PKTIO_OP_MT_UNSAFE; + if (num_rx_queues > capa.max_input_queues) { + num_rx_queues = capa.max_input_queues; + pktin_mode = ODP_PKTIO_OP_MT; + EXAMPLE_DBG("Warning: Force RX multithread safe mode " + "(slower)on %s\n", dev); + } - if (odp_pktin_queue_config(itf->pktio, &pktin_param)) { - EXAMPLE_ERR("Error: pktin queue config failed for %s\n", dev); - return -1; + odp_pktin_queue_param_init(&pktin_param); + pktin_param.num_queues = num_rx_queues; + pktin_param.op_mode = pktin_mode; + if (sched) + pktin_param.queue_param.sched.sync = + ODP_SCHED_SYNC_ATOMIC; + + if (odp_pktin_queue_config(itf->pktio, &pktin_param)) { + EXAMPLE_ERR("Error: pktin queue config failed " + "for %s\n", dev); + return -1; + } } - pktout_mode = ODP_PKTIO_OP_MT_UNSAFE; - if (num_tx_queues > capa.max_output_queues) { - num_tx_queues = capa.max_output_queues; - pktout_mode = ODP_PKTIO_OP_MT; - } + if (num_tx_queues) { + pktout_mode = ODP_PKTIO_OP_MT_UNSAFE; + if (num_tx_queues > capa.max_output_queues) { + num_tx_queues = capa.max_output_queues; + pktout_mode = ODP_PKTIO_OP_MT; + EXAMPLE_DBG("Warning: Force TX multithread safe mode " + "(slower) on %s\n", dev); + } - odp_pktout_queue_param_init(&pktout_param); - pktout_param.num_queues = num_tx_queues; - pktout_param.op_mode = pktout_mode; + odp_pktout_queue_param_init(&pktout_param); + pktout_param.num_queues = num_tx_queues; + pktout_param.op_mode = pktout_mode; - if (odp_pktout_queue_config(itf->pktio, &pktout_param)) { - EXAMPLE_ERR("Error: pktout queue config failed for %s\n", dev); - return -1; + if (odp_pktout_queue_config(itf->pktio, &pktout_param)) { + EXAMPLE_ERR("Error: pktout queue config failed for %s\n", + dev); + return -1; + } } ret = odp_pktio_start(itf->pktio); @@ -604,12 +628,21 @@ static int create_pktio(const char *dev, odp_pool_t pool, EXAMPLE_ABORT("Error: unable to start %s\n", dev); itf->pktout_count = num_tx_queues; - if (odp_pktout_queue(itf->pktio, itf->pktout, itf->pktout_count) != - (int)itf->pktout_count) { + if (itf->pktout_count && + odp_pktout_queue(itf->pktio, itf->pktout, itf->pktout_count) != + (int)itf->pktout_count) { EXAMPLE_ERR("Error: failed to get output queues for %s\n", dev); return -1; } + itf->pktin_count = num_rx_queues; + if (!sched && itf->pktin_count && + odp_pktin_queue(itf->pktio, itf->pktin, itf->pktin_count) != + (int)itf->pktin_count) { + EXAMPLE_ERR("Error: failed to get input queues for %s\n", dev); + return -1; + } + printf(" created pktio:%02" PRIu64 ", dev:%s, queue mode (ATOMIC queues)\n" " default pktio%02" PRIu64 "\n", @@ -1140,28 +1173,29 @@ int main(int argc, char *argv[]) ifs = malloc(sizeof(interface_t) * args->appl.if_count); - if (args->appl.mode == APPL_MODE_PING || - args->appl.mode == APPL_MODE_UDP) - num_rx_queues = 1; - else - num_rx_queues = num_workers; - - if (args->appl.mode == APPL_MODE_PING || - args->appl.mode == APPL_MODE_RCV) - num_tx_queues = 1; - else { - num_tx_queues = num_workers / args->appl.if_count; - if (num_workers % args->appl.if_count) - num_tx_queues++; - } + for (i = 0; i < args->appl.if_count; ++i) { + if (args->appl.mode == APPL_MODE_PING) { + num_rx_queues = 1; + num_tx_queues = 1; + } else if (args->appl.mode == APPL_MODE_UDP) { + num_rx_queues = 0; + num_tx_queues = num_workers / args->appl.if_count; + if (i < num_workers % args->appl.if_count) + num_tx_queues++; + } else { /* APPL_MODE_RCV*/ + num_rx_queues = num_workers / args->appl.if_count; + if (i < num_workers % args->appl.if_count) + num_rx_queues++; + num_tx_queues = 0; + } - for (i = 0; i < args->appl.if_count; ++i) if (create_pktio(args->appl.if_names[i], pool, num_rx_queues, num_tx_queues, &ifs[i])) { EXAMPLE_ERR("Error: create interface %s failed.\n", args->appl.if_names[i]); exit(EXIT_FAILURE); } + } /* Create and init worker threads */ memset(thread_tbl, 0, sizeof(thread_tbl)); From patchwork Tue Jan 9 12:00:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123899 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3938552qgn; Tue, 9 Jan 2018 04:06:52 -0800 (PST) X-Google-Smtp-Source: ACJfBovnYtzA5BpA7QkeXjFZWSSx3nVjibRBxXJVBDH6r7m4Y5r4yfM1pCZyxCxj18VStkG/aoXH X-Received: by 10.200.46.196 with SMTP id i4mr21761253qta.179.1515499612752; Tue, 09 Jan 2018 04:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515499612; cv=none; d=google.com; s=arc-20160816; b=APT/19dHNxMn4lSdMZP0CrEGiM+HVlo6UGhmaWWA6daAgnsj9d+EvZorPbcBHFAN+S 12RprK7ygs8lIa6gE2X8iA6fK7gPrsqPc86kgX9Ro5b+m1i0MCChxvjV6QUPhsSgLvBV 8wx7gg0BwwY7urYqDefaGvWHPGUdoV0e3TDRx25BmqSP7wvrMDE/sXbHcHoOXZNTWxpc ZQMbPofjiE3XiCF9+QyFBvBcGA17ib34J2hKiFtyKpTwVbNS/VX1oMpxBzqZlqDDgJ/y fqS+wP3wfHc/46TJPTo4ZgqnKj+RkW/UlkwLfED1JMYM57ctp+A0ocofW6HZGEYVnk1t Ncew== 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=3dDFGxDTC6aqdpfMQNkC6kMPWpCd2lx7TEzGmvbe/as=; b=LjwO//jNOppHoxv6xSAefNz1nMSYqbJLotxUAggXQP+t8TafA1lT0XaBAmSz9c+I3x gfrnPrvdOzY00H0ciZx9YspA0DDDdv78U5CmA+xi72wULKKcKMBHc1z3LMPiDQ0ybB2A M1KMACNwPK0GDNOxc1v7Z/RC/o38M4p7II+aEpD3FG9CWtJWgecl67Zdy2EMcoH7LvAC z6Pz2Dk9C4ltE+fkBIodgd5rXLr/fsCATEoZiCejX9zEoOLMhgosYeuZ+vKRUOaDYnMy RKmkqDO3fER/p847ITpaeIH3W+mMgJKcVxErJgE6ftNjXuomvEFvYgWiNguKn0iJkCKX xrNA== 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 h36si9038925qtd.240.2018.01.09.04.06.52; Tue, 09 Jan 2018 04:06:52 -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 58560616F9; Tue, 9 Jan 2018 12:06:52 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 5F180616FC; Tue, 9 Jan 2018 12:03:35 +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 608FC61706; Tue, 9 Jan 2018 12:03:22 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id B26836171B for ; Tue, 9 Jan 2018 12:00:23 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 5A9254443856 for ; Tue, 9 Jan 2018 15:00:22 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ttQjmozxnZ-0MtiuGRg; Tue, 09 Jan 2018 15:00:22 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 0CYWcrRWVI-0L5erI8p; Tue, 09 Jan 2018 15:00:21 +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: Tue, 9 Jan 2018 15:00:15 +0300 Message-Id: <1515499216-4272-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> References: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v3 4/5] example: generator: add direct mode packet RX 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: Bogdan Pricope Update packet RX processing by adding direct pktin mode. Direct mode should increase throughput on RX side. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 343 (bogdanPricope:generator_rx_direct_pr) ** https://github.com/Linaro/odp/pull/343 ** Patch: https://github.com/Linaro/odp/pull/343.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 2eefe24f19e219515f14085c88dda09761f71845 **/ example/generator/odp_generator.c | 150 +++++++++++++++++++++++++------------- 1 file changed, 99 insertions(+), 51 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 6ab25280c..e3a523843 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -114,8 +114,6 @@ typedef struct { } tx; struct { odp_pktin_queue_t pktin; /**< Packet input queue */ - interface_t *ifs; /**< Interfaces array */ - int ifs_count; /**< Interfaces array size */ } rx; }; odp_pool_t pool; /**< Pool for packet IO */ @@ -777,19 +775,18 @@ static int gen_send_thread(void *arg) /** * Process icmp packets * + * @param thr worker id + * @param thr_args worker argument * @param icmp icmp header address - * @param msg output buffer */ -static void process_icmp_pkt(thread_args_t *thr_args, - odph_icmphdr_t *icmp, char *msg) +static void process_icmp_pkt(int thr, thread_args_t *thr_args, + odph_icmphdr_t *icmp) { uint64_t trecv; uint64_t tsend; uint64_t rtt_ms, rtt_us; - msg[0] = 0; - if (icmp->type == ICMP_ECHOREPLY) { thr_args->counters.ctr_icmp_reply_rcv++; @@ -799,33 +796,32 @@ static void process_icmp_pkt(thread_args_t *thr_args, rtt_ms = (trecv - tsend) / ODP_TIME_MSEC_IN_NS; rtt_us = (trecv - tsend) / ODP_TIME_USEC_IN_NS - 1000 * rtt_ms; - sprintf(msg, - "ICMP Echo Reply seq %d time %" - PRIu64 ".%.03" PRIu64" ms", + printf(" [%02i] ICMP Echo Reply seq %d time %" + PRIu64 ".%.03" PRIu64" ms\n", thr, odp_be_to_cpu_16(icmp->un.echo.sequence), rtt_ms, rtt_us); } else if (icmp->type == ICMP_ECHO) { - sprintf(msg, "Icmp Echo Request"); + printf(" [%02i] ICMP Echo Request\n", thr); } } /** - * Print odp packets + * Process odp packets * * @param thr worker id + * @param thr_args worker argument * @param pkt_tbl packets to be print * @param len packet number */ -static void print_pkts(int thr, thread_args_t *thr_args, - odp_packet_t pkt_tbl[], unsigned len) +static void process_pkts(int thr, thread_args_t *thr_args, + odp_packet_t pkt_tbl[], unsigned len) { odp_packet_t pkt; + odp_packet_chksum_status_t csum_status; char *buf; odph_ipv4hdr_t *ip; odph_icmphdr_t *icmp; unsigned i; - size_t offset; - char msg[1024]; for (i = 0; i < len; ++i) { pkt = pkt_tbl[i]; @@ -834,10 +830,21 @@ static void print_pkts(int thr, thread_args_t *thr_args, if (!odp_packet_has_ipv4(pkt)) continue; + csum_status = odp_packet_l3_chksum_status(pkt); + if (csum_status == ODP_PACKET_CHKSUM_BAD) + printf("L3 checksum error detected.\n"); + + csum_status = odp_packet_l4_chksum_status(pkt); + if (csum_status == ODP_PACKET_CHKSUM_BAD) + printf("L4 checksum error detected.\n"); + + /* Drop packets with errors */ + if (odp_unlikely(odp_packet_has_error(pkt))) + continue; + thr_args->counters.ctr_pkt_rcv++; buf = odp_packet_data(pkt); ip = (odph_ipv4hdr_t *)(buf + odp_packet_l3_offset(pkt)); - offset = odp_packet_l4_offset(pkt); /* udp */ if (ip->proto == ODPH_IPPROTO_UDP) @@ -845,16 +852,16 @@ static void print_pkts(int thr, thread_args_t *thr_args, /* icmp */ if (ip->proto == ODPH_IPPROTO_ICMPv4) { - icmp = (odph_icmphdr_t *)(buf + offset); + icmp = (odph_icmphdr_t *)(buf + + odp_packet_l4_offset(pkt)); - process_icmp_pkt(thr_args, icmp, msg); - printf(" [%02i] %s\n", thr, msg); + process_icmp_pkt(thr, thr_args, icmp); } } } /** - * Main receive function + * Scheduler receive function * * @param arg thread arguments of type 'thread_args_t *' */ @@ -862,17 +869,16 @@ static int gen_recv_thread(void *arg) { int thr; thread_args_t *thr_args; - odp_packet_t pkts[MAX_RX_BURST], pkt; - odp_event_t events[MAX_RX_BURST]; + odp_packet_t pkts[MAX_RX_BURST]; + odp_event_t events[MAX_RX_BURST], ev; int pkt_cnt, ev_cnt, i; - odp_packet_chksum_status_t csum_status; int burst_size; thr = odp_thread_id(); thr_args = (thread_args_t *)arg; burst_size = args->rx_burst_size; - printf(" [%02i] created mode: RECEIVE\n", thr); + printf(" [%02i] created mode: RECEIVE SCHEDULER\n", thr); odp_barrier_wait(&barrier); for (;;) { @@ -884,29 +890,62 @@ static int gen_recv_thread(void *arg) events, burst_size); if (ev_cnt == 0) continue; + for (i = 0, pkt_cnt = 0; i < ev_cnt; i++) { - pkt = odp_packet_from_event(events[i]); + ev = events[i]; - csum_status = odp_packet_l3_chksum_status(pkt); - if (csum_status == ODP_PACKET_CHKSUM_BAD) - printf("L3 checksum error detected.\n"); + if (odp_event_type(ev) == ODP_EVENT_PACKET) + pkts[pkt_cnt++] = odp_packet_from_event(ev); + else + odp_event_free(ev); + } - csum_status = odp_packet_l4_chksum_status(pkt); - if (csum_status == ODP_PACKET_CHKSUM_BAD) - printf("L4 checksum error detected.\n"); + if (pkt_cnt) { + process_pkts(thr, thr_args, pkts, pkt_cnt); - /* Drop packets with errors */ - if (odp_unlikely(odp_packet_has_error(pkt))) { - odp_packet_free(pkt); - continue; - } - pkts[pkt_cnt++] = pkt; + odp_packet_free_multi(pkts, pkt_cnt); } + } - if (pkt_cnt) { - print_pkts(thr, thr_args, pkts, pkt_cnt); + return 0; +} + +/** + * Direct receive function + * + * @param arg thread arguments of type 'thread_args_t *' + */ +static int gen_recv_direct_thread(void *arg) +{ + int thr; + thread_args_t *thr_args; + odp_packet_t pkts[MAX_RX_BURST]; + int pkt_cnt, burst_size; + odp_pktin_queue_t pktin; + + thr = odp_thread_id(); + thr_args = (thread_args_t *)arg; + pktin = thr_args->rx.pktin; + burst_size = args->rx_burst_size; + + printf(" [%02i] created mode: RECEIVE\n", thr); + odp_barrier_wait(&barrier); + + for (;;) { + if (thr_args->stop) + break; + + pkt_cnt = odp_pktin_recv_tmo(pktin, pkts, burst_size, + ODP_PKTIN_NO_WAIT); + + if (pkt_cnt > 0) { + process_pkts(thr, thr_args, pkts, pkt_cnt); odp_packet_free_multi(pkts, pkt_cnt); + } else if (pkt_cnt == 0) { + continue; + } else { + break; } } @@ -1223,8 +1262,8 @@ int main(int argc, char *argv[]) abort(); } thr_args = &args->thread[PING_THR_RX]; - thr_args->rx.ifs = ifs; - thr_args->rx.ifs_count = args->appl.if_count; + if (!args->appl.sched) + thr_args->rx.pktin = ifs[0].pktin[0]; thr_args->pool = pool; thr_args->tp = tp; thr_args->tq = tq; @@ -1241,7 +1280,10 @@ int main(int argc, char *argv[]) thr_args->mode = args->appl.mode; memset(&thr_params, 0, sizeof(thr_params)); - thr_params.start = gen_recv_thread; + if (args->appl.sched) + thr_params.start = gen_recv_thread; + else + thr_params.start = gen_recv_direct_thread; thr_params.arg = thr_args; thr_params.thr_type = ODP_THREAD_WORKER; thr_params.instance = instance; @@ -1287,21 +1329,24 @@ int main(int argc, char *argv[]) for (i = 0; i < num_workers; ++i) { odp_cpumask_t thd_mask; int (*thr_run_func)(void *); - int if_idx, pktout_idx; + int if_idx, pktq_idx; uint64_t start_seq; + if_idx = i % args->appl.if_count; + if (args->appl.mode == APPL_MODE_RCV) { - args->thread[i].rx.ifs = ifs; - args->thread[i].rx.ifs_count = - args->appl.if_count; + pktq_idx = (i / args->appl.if_count) % + ifs[if_idx].pktin_count; + if (!args->appl.sched) + args->thread[i].rx.pktin = + ifs[if_idx].pktin[pktq_idx]; } else { - if_idx = i % args->appl.if_count; - pktout_idx = (i / args->appl.if_count) % + pktq_idx = (i / args->appl.if_count) % ifs[if_idx].pktout_count; start_seq = i * args->tx_burst_size; args->thread[i].tx.pktout = - ifs[if_idx].pktout[pktout_idx]; + ifs[if_idx].pktout[pktq_idx]; args->thread[i].tx.pktout_cfg = &ifs[if_idx].config.pktout; args->thread[i].counters.ctr_seq = start_seq; @@ -1329,7 +1374,10 @@ int main(int argc, char *argv[]) if (args->appl.mode == APPL_MODE_UDP) { thr_run_func = gen_send_thread; } else if (args->appl.mode == APPL_MODE_RCV) { - thr_run_func = gen_recv_thread; + if (args->appl.sched) + thr_run_func = gen_recv_thread; + else + thr_run_func = gen_recv_direct_thread; } else { EXAMPLE_ERR("ERR MODE\n"); exit(EXIT_FAILURE); From patchwork Tue Jan 9 12:00:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123900 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3939897qgn; Tue, 9 Jan 2018 04:08:00 -0800 (PST) X-Google-Smtp-Source: ACJfBotPGD/mPNf4Pl2OjoCabORGalixTLW181r+LuCQWfxTlPBzmnmqzvfuCKflkV83WGHRWb0P X-Received: by 10.200.57.129 with SMTP id v1mr21306834qte.50.1515499680715; Tue, 09 Jan 2018 04:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515499680; cv=none; d=google.com; s=arc-20160816; b=wUp3oMMwNuMyUmOAVs+J2dgZVHk6hPiqYCvjhcuJmTmaYO//XSRNQ9DHGlWDRUOfgn HJzJFSzMPIjlH+5SmKvmHaPLrvywORneuZ6OnHzDeClGJ1PYdSDxuIbDvkI6TgAEPEKf p8RXpgZI78tcimZXgQdqlzLLPQM73u8V4MAZ+h2Vk+QfTKqsNq/LP+XsdVfrntjXEX1p P0CS9ZTG/6a9nS4j+NtlClwmFLc+1tHdOzWmwk6fuzK1vlS0wToe8Fgu5RyA1E+Yz0oq wT1iyupZCL9WHx9Zo0s+QUnuqr7b0yRbHjg41Kg4wsIIcRN9mxVsMmTxVvNY8pv4ySvX i0Og== 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=fMFf8DZ4k7+k4j/iqoZjYpvZPf55OdZSlNXJbo0Xa08=; b=bhbF4nDeFlXyE7BV5JzLRFPK60rNC4VhG4Leo4VnjPmrooUxGyaaqmGeF6x8sBS2mP YwKfDWICZMlW+msdTpM5t4SykVefTCq3SlvJ20gxkcycWK22hLgX9E+2MiuawPRFRxwN uQjlJ0XccELcIMrZ81ZfFbFsuoPZKEaATMeejkcLclnSwwUu9InkOWwu/JijZnP2MKzW ZM2daYWMfrRwt0OdluHxsflinJdKe3shxoMEDuqBgWlTIXhQK24qKHAkAPjsOSTGqfE/ S5yrCzfOP8BTpSoNViLqCAmMxN3xK3RBdVJXha4QBLV+cQgZPbei2wj3ejMm7SiF0WZ4 sYTg== 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 w140si4302317qkb.333.2018.01.09.04.08.00; Tue, 09 Jan 2018 04:08:00 -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 5D4F461706; Tue, 9 Jan 2018 12:08:00 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 A9A2961735; Tue, 9 Jan 2018 12:03:41 +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 A808261706; Tue, 9 Jan 2018 12:03:23 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 614B56171F for ; Tue, 9 Jan 2018 12:00:30 +0000 (UTC) Received: from mxback3o.mail.yandex.net (mxback3o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1d]) by forward100o.mail.yandex.net (Yandex) with ESMTP id F3C4F2A22BF4 for ; Tue, 9 Jan 2018 15:00:28 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback3o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id fy69rokexj-0MQ4pReH; Tue, 09 Jan 2018 15:00:22 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 0CYWcrRWVI-0M58rCAJ; Tue, 09 Jan 2018 15:00:22 +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: Tue, 9 Jan 2018 15:00:16 +0300 Message-Id: <1515499216-4272-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> References: <1515499216-4272-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v3 5/5] example: generator: replace L3/L4 packet parsing with a simple one 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: Bogdan Pricope Platform packet parsing is providing information not needed by this application while consuming cycles. Replacing platform packet parsing with a limited parsing may increase performance on RX side. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 343 (bogdanPricope:generator_rx_direct_pr) ** https://github.com/Linaro/odp/pull/343 ** Patch: https://github.com/Linaro/odp/pull/343.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 2eefe24f19e219515f14085c88dda09761f71845 **/ example/generator/odp_generator.c | 49 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index e3a523843..537ee7388 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -572,6 +572,12 @@ static int create_pktio(const char *dev, odp_pool_t pool, itf->config.pktout.bit.udp_chksum = 0; } + itf->config.parser.layer = ODP_PROTO_LAYER_L2; + if (itf->config.pktin.bit.udp_chksum) + itf->config.parser.layer = ODP_PROTO_LAYER_L4; + else if (itf->config.pktin.bit.ipv4_chksum) + itf->config.parser.layer = ODP_PROTO_LAYER_L3; + if (odp_pktio_config(itf->pktio, &itf->config)) { EXAMPLE_ERR("Error: Failed to set interface configuration %s\n", dev); @@ -781,11 +787,12 @@ static int gen_send_thread(void *arg) */ static void process_icmp_pkt(int thr, thread_args_t *thr_args, - odph_icmphdr_t *icmp) + uint8_t *_icmp) { uint64_t trecv; uint64_t tsend; uint64_t rtt_ms, rtt_us; + odph_icmphdr_t *icmp = (odph_icmphdr_t *)_icmp; if (icmp->type == ICMP_ECHOREPLY) { thr_args->counters.ctr_icmp_reply_rcv++; @@ -818,18 +825,12 @@ static void process_pkts(int thr, thread_args_t *thr_args, { odp_packet_t pkt; odp_packet_chksum_status_t csum_status; - char *buf; + uint32_t left, offset, i; odph_ipv4hdr_t *ip; - odph_icmphdr_t *icmp; - unsigned i; for (i = 0; i < len; ++i) { pkt = pkt_tbl[i]; - /* only ip pkts */ - if (!odp_packet_has_ipv4(pkt)) - continue; - csum_status = odp_packet_l3_chksum_status(pkt); if (csum_status == ODP_PACKET_CHKSUM_BAD) printf("L3 checksum error detected.\n"); @@ -842,20 +843,36 @@ static void process_pkts(int thr, thread_args_t *thr_args, if (odp_unlikely(odp_packet_has_error(pkt))) continue; + offset = odp_packet_l3_offset(pkt); + left = odp_packet_len(pkt) - offset; + + if (left < sizeof(odph_ipv4hdr_t)) + continue; + + ip = (odph_ipv4hdr_t *)((uint8_t *)odp_packet_data(pkt) + + offset); + + /* only ip pkts */ + if (ODPH_IPV4HDR_VER(ip->ver_ihl) != ODPH_IPV4) + continue; + thr_args->counters.ctr_pkt_rcv++; - buf = odp_packet_data(pkt); - ip = (odph_ipv4hdr_t *)(buf + odp_packet_l3_offset(pkt)); /* udp */ - if (ip->proto == ODPH_IPPROTO_UDP) + if (ip->proto == ODPH_IPPROTO_UDP) { thr_args->counters.ctr_udp_rcv++; + } else if (ip->proto == ODPH_IPPROTO_ICMPv4) { + uint32_t l3_size = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4; + + offset += l3_size; + left -= l3_size; - /* icmp */ - if (ip->proto == ODPH_IPPROTO_ICMPv4) { - icmp = (odph_icmphdr_t *)(buf + - odp_packet_l4_offset(pkt)); + if (left < sizeof(odph_icmphdr_t)) + continue; - process_icmp_pkt(thr, thr_args, icmp); + process_icmp_pkt(thr, thr_args, + (uint8_t *)odp_packet_data(pkt) + + offset); } } }