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));