From patchwork Thu Dec 14 10:00:08 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: 121898 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp6502824edb; Thu, 14 Dec 2017 02:06:52 -0800 (PST) X-Google-Smtp-Source: ACJfBouwXvA/HMF5ZUzH9D74Gmo/ocrwFiZGJu59IdtWs7IHSoqeWYHi0hbUyReaLS86Z6yvZdwf X-Received: by 10.55.161.13 with SMTP id k13mr15627453qke.272.1513245897821; Thu, 14 Dec 2017 02:04:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513245897; cv=none; d=google.com; s=arc-20160816; b=RLKuS57XPw4D6RrHaNnU2Yyk2cE7SeTkzlBL05gb/Hs4mQcgcBfNlq5g/uucdK8kdB Gxa0uITTgUQkikIEchuBy3TnF01hiNsjjswLmhWzhySjA39w7fy7JrOzgFmB7yBcrYC5 Ku//WxO74rEaU+DzRoxHocKbx0jJOAUDbMNumzFpzezct1ly/v5PQM5NQLDCngYDIOR8 0C+8z+0CQ8c+PR51429dGOc/Lt8ZAdx0Q3TrcSklGXQ5u8QPifGQDj7SHH4ajL7/oJYG epQJXQggiLj/GKruIbluLeF6FVX7UflXTJAQc+YvfVGEqnolOZimQsGJvprLymQn3dPM KdMQ== 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=Z0oMMfuSUlBVDTNJmUM/jNbaFU0y24YTr2SenZvJPPg=; b=LNg5Db6dKQHH/UbT4kbN/uAaPrmdvK1tvMrDNU4VYu/GtPzIiPURET/Xnva/U0Bioi LE7hoaGeTEKi9QJqxfUKHf44WGteOxi8ewUl+U1B+siUN4JLJQAtuIUg/FRmd+WSXZOQ aH/B22fE9HsDLOqBUiisay3xM5/lTmf+lE5kFA7JCsIxQdZTHS0/cx5qDuj9Zjykjm3K TFg6e0TEHRyj+2vEoBd4nZbRwA0jxb5CXL0Gy84OUFr/yJGpifiyty15kmLztGU+E2Ni W66L4+efcNUMQChynBC5ScMxkwWrE4W25QhAQnS3HXLfyB/zl9PCfvul2gqI5qEyJ8ts JwYQ== 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 b20si1187567qta.182.2017.12.14.02.04.56; Thu, 14 Dec 2017 02:04:57 -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 3DB4C60926; Thu, 14 Dec 2017 10:04:56 +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,URIBL_BLOCKED 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 3A70460958; Thu, 14 Dec 2017 10:00:43 +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 D62926087C; Thu, 14 Dec 2017 10:00:24 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 1084F60830 for ; Thu, 14 Dec 2017 10:00:22 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 7F310783EC0 for ; Thu, 14 Dec 2017 13:00:11 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id rzjUVc4nbX-0B0qXcM6; Thu, 14 Dec 2017 13:00:11 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YWR8u7FTgT-0AJ8kN6c; Thu, 14 Dec 2017 13:00:10 +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: Thu, 14 Dec 2017 13:00:08 +0300 Message-Id: <1513245609-4681-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513245609-4681-1-git-send-email-odpbot@yandex.ru> References: <1513245609-4681-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v1 1/2] 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: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 1ca03370b6ed8d338465e34b4b3aa7741f1862cf **/ example/generator/odp_generator.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 861e98369..95f7a78e7 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 */ @@ -79,6 +80,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; @@ -129,6 +132,7 @@ typedef struct { /** Global arguments */ int thread_cnt; int tx_burst_size; + int rx_burst_size; } args_t; /** Global pointer to args */ @@ -819,11 +823,13 @@ static int gen_recv_thread(void *arg) odp_packet_t pkts[MAX_RX_BURST], pkt; odp_event_t events[MAX_RX_BURST]; int pkt_cnt, ev_cnt, i; + int burst_size; interface_t *itfs, *itf; thr = odp_thread_id(); thr_args = (thread_args_t *)arg; itfs = thr_args->rx.ifs; + burst_size = args->rx_burst_size; printf(" [%02i] created mode: RECEIVE\n", thr); odp_barrier_wait(&barrier); @@ -834,7 +840,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++) { @@ -1074,12 +1080,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); @@ -1376,11 +1386,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, 'z'}, {"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:yz:"; /* let helper collect its own arguments (e.g. --odph_proc) */ odph_parse_options(argc, argv, shortopts, longopts); @@ -1391,6 +1402,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; @@ -1533,6 +1545,14 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) exit(EXIT_FAILURE); } break; + case 'z': + 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; @@ -1623,6 +1643,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" + " -z, --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 Thu Dec 14 10:00:09 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: 121892 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6596431qgn; Thu, 14 Dec 2017 02:03:01 -0800 (PST) X-Google-Smtp-Source: ACJfBouxd8O5fWhwUgYNe4X0ptcwPwc7O5/pXhn0jVxUuXLGl6jnJAnOTFlw0flJ+F0daVqzuuwh X-Received: by 10.55.156.17 with SMTP id f17mr15091998qke.217.1513245781569; Thu, 14 Dec 2017 02:03:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513245781; cv=none; d=google.com; s=arc-20160816; b=b0AZQxuUWx0uJ/ZkP9fYfyzq9pMNh+g0xqEz4ouIuuExIv14tAMz5bJKy8rE1uhECh ZBrcEUDO6KZ8wmEaTWt/Mij+s6QesKiEgB4tVb5NvwsfAbUp1QNCt0EczGZwwHnyndyP Dw6BPaOPfl6xKJKXF8Pc9f4a3PGFvrLK7GQfeSVCgEu95BqEVBc8OHOMssfZu3bekwX4 EDVpBSDhV8sxWAl+HBalybgs0IMpMtMUfT3qRSPAtvM6F+nkGht4hHHFBZFtTkdW2fbK Z8AIABQvcr+bX/0MzNgcw5DxtwliuIDpDrD0H2NKJYui+nwo8RSKtmE5Fh9mAIPTpyyG E0IA== 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=KEPZ3aTsosH0uJyyJ4GGDiuwtj/7YOqlLqR7XmlArVs=; b=m82L8IWy/F/6IAGv4mTfelQ/x3KwcGDtFtpxL01kmfmYWU7Yiqp9IHnL3ygcsyyGb7 TQgLtDssbEMAZRx6YOcJ3v5WjOF1QSvtFEn9ZGOQ3mS5X40HdT1vK3aph9XsnJSyRD8Y nCCmF1i9Ty38fapyhe2R42lrhvQiBsFyVQqtk6FgrUu/vQNFnPkSuXtdHcQ0y5/HXHQj EyLgfRYGfjDlq024r+9vIeEOsSWROo67POES34Br8ZkfWYnHl08fBGj8pagFNtqGUEi1 POft+hsvNAtjg6hEbNIU3l7iCbSon/g3prdk0CXBy4dXpV0fdwzIeiRfRxMlCLgYy7cS Jlfw== 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 i39si3973533qtb.101.2017.12.14.02.03.01; Thu, 14 Dec 2017 02:03:01 -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 396976087C; Thu, 14 Dec 2017 10:03:01 +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,URIBL_BLOCKED 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 3534E60925; Thu, 14 Dec 2017 10:00:33 +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 C66ED60916; Thu, 14 Dec 2017 10:00:22 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 126C160819 for ; Thu, 14 Dec 2017 10:00:14 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 6502134C5C39 for ; Thu, 14 Dec 2017 13:00:12 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id UrSL8rZIng-0ClSJekW; Thu, 14 Dec 2017 13:00:12 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YWR8u7FTgT-0BJ8xaux; Thu, 14 Dec 2017 13:00:11 +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: Thu, 14 Dec 2017 13:00:09 +0300 Message-Id: <1513245609-4681-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513245609-4681-1-git-send-email-odpbot@yandex.ru> References: <1513245609-4681-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 343 Subject: [lng-odp] [PATCH v1 2/2] example: generator: replace scheduler mode with direct pktin mode 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 receive mode by replacing scheduler mode with direct pktin mode. This 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: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 1ca03370b6ed8d338465e34b4b3aa7741f1862cf **/ example/generator/odp_generator.c | 197 ++++++++++++++++++++++---------------- 1 file changed, 114 insertions(+), 83 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 95f7a78e7..e378db67f 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -54,6 +54,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; /** @@ -109,6 +111,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; @@ -517,10 +520,13 @@ 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_pktio_param_init(&pktio_param); - pktio_param.in_mode = ODP_PKTIN_MODE_SCHED; + pktio_param.in_mode = num_rx_queues ? 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); @@ -563,31 +569,43 @@ 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; + 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); + } - odp_pktin_queue_param_init(&pktin_param); - pktin_param.num_queues = num_rx_queues; - pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC; + odp_pktin_queue_param_init(&pktin_param); + pktin_param.num_queues = num_rx_queues; + pktin_param.op_mode = pktin_mode; - if (odp_pktin_queue_config(itf->pktio, &pktin_param)) { - EXAMPLE_ERR("Error: pktin queue config failed for %s\n", dev); - return -1; + if (odp_pktin_queue_config(itf->pktio, &pktin_param)) { + EXAMPLE_ERR("Error: Pktin 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 config failed for %s\n", + dev); + return -1; + } } ret = odp_pktio_start(itf->pktio); @@ -595,12 +613,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 (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", @@ -768,14 +795,14 @@ static void process_icmp_pkt(thread_args_t *thr_args, } /** - * Print odp packets + * Process odp packets * * @param thr worker id * @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; char *buf; @@ -784,10 +811,33 @@ static void print_pkts(int thr, thread_args_t *thr_args, unsigned i; size_t offset; char msg[1024]; + interface_t *itfs, *itf; + + itfs = thr_args->rx.ifs; for (i = 0; i < len; ++i) { pkt = pkt_tbl[i]; + itf = &itfs[odp_pktio_index(odp_packet_input(pkt))]; + + if (odp_packet_has_ipv4(pkt)) { + if (itf->config.pktin.bit.ipv4_chksum) { + if (odp_packet_has_l3_error(pkt)) + printf("HW detected L3 error\n"); + } + } + + if (odp_packet_has_udp(pkt)) { + if (itf->config.pktin.bit.udp_chksum) { + if (odp_packet_has_l4_error(pkt)) + printf("HW detected L4 error\n"); + } + } + + /* Drop packets with errors */ + if (odp_unlikely(odp_packet_has_error(pkt))) + continue; + /* only ip pkts */ if (!odp_packet_has_ipv4(pkt)) continue; @@ -820,15 +870,13 @@ 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]; - int pkt_cnt, ev_cnt, i; - int burst_size; - interface_t *itfs, *itf; + 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; - itfs = thr_args->rx.ifs; + pktin = thr_args->rx.pktin; burst_size = args->rx_burst_size; printf(" [%02i] created mode: RECEIVE\n", thr); @@ -838,41 +886,17 @@ static int gen_recv_thread(void *arg) if (thr_args->stop) break; - /* Use schedule to get buf from any input queue */ - ev_cnt = odp_schedule_multi(NULL, ODP_SCHED_NO_WAIT, - 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]); - itf = &itfs[odp_pktio_index(odp_packet_input(pkt))]; - - if (odp_packet_has_ipv4(pkt)) { - if (itf->config.pktin.bit.ipv4_chksum) { - if (odp_packet_has_l3_error(pkt)) - printf("HW detected L3 error\n"); - } - } - - if (odp_packet_has_udp(pkt)) { - if (itf->config.pktin.bit.udp_chksum) { - if (odp_packet_has_l4_error(pkt)) - printf("HW detected L4 error\n"); - } - } - - /* Drop packets with errors */ - if (odp_unlikely(odp_packet_has_error(pkt))) { - odp_packet_free(pkt); - continue; - } - pkts[pkt_cnt++] = pkt; - } + pkt_cnt = odp_pktin_recv_tmo(pktin, pkts, burst_size, + ODP_PKTIN_NO_WAIT); - if (pkt_cnt) { - print_pkts(thr, thr_args, pkts, pkt_cnt); + 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; } } @@ -1133,28 +1157,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)); @@ -1182,6 +1207,7 @@ int main(int argc, char *argv[]) abort(); } thr_args = &args->thread[PING_THR_RX]; + thr_args->rx.pktin = ifs[0].pktin[0]; thr_args->rx.ifs = ifs; thr_args->rx.ifs_count = args->appl.if_count; thr_args->pool = pool; @@ -1246,21 +1272,26 @@ 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) { + pktq_idx = (i / args->appl.if_count) % + ifs[if_idx].pktin_count; + args->thread[i].rx.pktin = + ifs[if_idx].pktin[pktq_idx]; args->thread[i].rx.ifs = ifs; args->thread[i].rx.ifs_count = args->appl.if_count; } 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;