From patchwork Thu Nov 20 08:44:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 41220 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 173C023588 for ; Thu, 20 Nov 2014 08:44:51 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf1460728lam.10 for ; Thu, 20 Nov 2014 00:44:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=a190Rv1thvx3yOfYMny0bvBeSvj/qN1lv7GAwqWpyCA=; b=esb3QPxT/ZuJKn2qIVdvD722etVYGl1JaiKGxTxWk6dzPGCxdpr2vwIc5DudXr6s3p 0exCPjpFPoHoliome0UqcvALOuENQuG0rhwnufdWZ4Tojxla1c3u6q/avNcTnd2qkuQ/ C4wJ8t1XM+OtQyEOTEBRkOnO4xJugK3X8fpzOQ8pswKl7GYRrhaT0gx3iYzePuqoRehT XxOTlxOzUwE03kX9FCbCmTiJqloDdz9TRewYPw5zQB08T79iM9f2Sg5MJWDZORDUPVP+ 3djbueyfPUnh2kQpD3EGOY0ulFYE64GusDFCDZmMt8QcK9+Epab2qG1aZegi7g6Yrl8C y5Vw== X-Gm-Message-State: ALoCoQnHpkJmf4/vIUKXqyhM5yqfpSANAhUQnWVeoYvN5WXNzT4+/ig1nL2K5uBsRKEE4j/Rzsev X-Received: by 10.180.94.3 with SMTP id cy3mr2396655wib.7.1416473090004; Thu, 20 Nov 2014 00:44:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.227 with SMTP id i3ls29744lae.28.gmail; Thu, 20 Nov 2014 00:44:49 -0800 (PST) X-Received: by 10.112.138.137 with SMTP id qq9mr1386315lbb.80.1416473089749; Thu, 20 Nov 2014 00:44:49 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id b2si1496304lbm.104.2014.11.20.00.44.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 00:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gd6so2008347lab.5 for ; Thu, 20 Nov 2014 00:44:49 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr9885385lbo.32.1416473089655; Thu, 20 Nov 2014 00:44:49 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp226337lbc; Thu, 20 Nov 2014 00:44:48 -0800 (PST) X-Received: by 10.224.38.5 with SMTP id z5mr58851407qad.89.1416473087983; Thu, 20 Nov 2014 00:44:47 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id q30si2103954qgd.31.2014.11.20.00.44.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Nov 2014 00:44:47 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XrNM5-000895-Hm; Thu, 20 Nov 2014 08:44:45 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XrNLr-00087F-2Z for lng-odp@lists.linaro.org; Thu, 20 Nov 2014 08:44:31 +0000 Received: by mail-la0-f53.google.com with SMTP id pn19so1987214lab.26 for ; Thu, 20 Nov 2014 00:44:24 -0800 (PST) X-Received: by 10.152.170.194 with SMTP id ao2mr10015924lac.60.1416473064601; Thu, 20 Nov 2014 00:44:24 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-135.2com.net. [46.188.125.135]) by mx.google.com with ESMTPSA id ba19sm427858lab.31.2014.11.20.00.44.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 00:44:23 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 20 Nov 2014 11:44:13 +0300 Message-Id: <1416473054-10656-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1416473054-10656-1-git-send-email-maxim.uvarov@linaro.org> References: <1416473054-10656-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv5 2/3] enhance odp_pktio to set/get mtu X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add new option -t or --mtu to set up new mtu value. Signed-off-by: Maxim Uvarov Reviewed-by Mike Holmes Reviewed-by: Anders Roxell --- example/packet/odp_pktio.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 3e08b34..1763c84 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -71,6 +71,7 @@ typedef struct { char **if_names; /**< Array of pointers to interface names */ int mode; /**< Packet IO mode */ odp_buffer_pool_t pool; /**< Buffer pool for packet IO */ + int mtu; /**< Pktio dev MTU */ } appl_args_t; /** @@ -80,6 +81,7 @@ typedef struct { char *pktio_dev; /**< Interface name to use */ odp_buffer_pool_t pool; /**< Buffer pool for packet IO */ int mode; /**< Thread mode */ + int mtu; /**< Pktio dev MTU */ } thread_args_t; /** @@ -122,6 +124,7 @@ static void *pktio_queue_thread(void *arg) int ret; unsigned long pkt_cnt = 0; unsigned long err_cnt = 0; + int mtu = 0; thr = odp_thread_id(); thr_args = arg; @@ -143,6 +146,21 @@ static void *pktio_queue_thread(void *arg) return NULL; } + /* Change mtu if requested */ + if (thr_args->mtu) { + ret = odp_pktio_set_mtu(pktio, thr_args->mtu); + if (ret != 0) + ODP_ERR("setting MTU to %d failed\n", + thr_args->mtu); + } + + mtu = odp_pktio_mtu(pktio); + if (mtu > 0) + printf("PKTIO: %d, dev %s, MTU: %d\n", + pktio, thr_args->pktio_dev, mtu); + else + ODP_ERR("odp_pktio_mtu: unable to get MTU\n"); + /* * Create and set the default INPUT queue associated with the 'pktio' * resource @@ -233,6 +251,8 @@ static void *pktio_ifburst_thread(void *arg) unsigned long pkt_cnt = 0; unsigned long err_cnt = 0; unsigned long tmp = 0; + int mtu; + int ret; thr = odp_thread_id(); thr_args = arg; @@ -254,6 +274,21 @@ static void *pktio_ifburst_thread(void *arg) return NULL; } + /* Change mtu if requested */ + if (thr_args->mtu) { + ret = odp_pktio_set_mtu(pktio, thr_args->mtu); + if (ret != 0) + ODP_ERR("setting MTU to %d failed\n", + thr_args->mtu); + } + + mtu = odp_pktio_mtu(pktio); + if (mtu > 0) + printf("PKTIO: %d, dev %s, MTU: %d\n", + pktio, thr_args->pktio_dev, mtu); + else + ODP_ERR("odp_pktio_mtu: unable to get mtu\n"); + printf(" [%02i] created pktio:%02i, burst mode\n", thr, pktio); @@ -388,6 +423,7 @@ int main(int argc, char *argv[]) args->thread[i].pktio_dev = args->appl.if_names[if_idx]; args->thread[i].pool = pool; args->thread[i].mode = args->appl.mode; + args->thread[i].mtu = args->appl.mtu; if (args->appl.mode == APPL_MODE_PKT_BURST) thr_run_func = pktio_ifburst_thread; @@ -496,14 +532,16 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) {"count", required_argument, NULL, 'c'}, {"interface", required_argument, NULL, 'i'}, /* return 'i' */ {"mode", required_argument, NULL, 'm'}, /* return 'm' */ + {"mtu", required_argument, NULL, 't'}, /* return 't' */ {"help", no_argument, NULL, 'h'}, /* return 'h' */ {NULL, 0, NULL, 0} }; appl_args->mode = -1; /* Invalid, must be changed by parsing */ + appl_args->mtu = 0; while (1) { - opt = getopt_long(argc, argv, "+c:i:m:h", + opt = getopt_long(argc, argv, "+c:i:m:t:h", longopts, &long_index); if (opt == -1) @@ -563,6 +601,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) else appl_args->mode = APPL_MODE_PKT_QUEUE; break; + case 't': + appl_args->mtu = atoi(optarg); + break; case 'h': usage(argv[0]); @@ -633,6 +674,7 @@ static void usage(char *progname) " -i, --interface Eth interfaces (comma-separated, no spaces)\n" " -m, --mode 0: Burst send&receive packets (no queues)\n" " 1: Send&receive packets through ODP queues.\n" + " -t, --mtu MTU\n" "\n" "Optional OPTIONS\n" " -c, --count Core count.\n"