From patchwork Wed Nov 12 23:04:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 40698 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B010B24493 for ; Wed, 12 Nov 2014 23:05:01 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf1990246lbj.0 for ; Wed, 12 Nov 2014 15:05:00 -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:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=s1f9rmNbuPaFfqTLaW/2jyxBvbM0QG7UDBi6Fd4rj1A=; b=ZCg7fPp+heY76jYDhjkfLileGdD3tid22QgRcYf95zXXqWIxAEqFYBy5LKbaiBkslX UclbjpS77I0aTJQBGAbDtNuN//Dvz50uYXBA0wDyIbSsdrSEWlcdpOLyHiAQq4HSaLNv ExuJTLccJYLPUe2vcr7FHIJ07o8aLmD5Q9naSKu7s9kG8FmD5YzxPiZKDIV/xxe2y0Ho FgO7LRSJh2LLPCxKW/ATGYxM8lycLvAwFdfqtcrnMcLu834ms247mxR3rGrUC44ROa31 06JpWmnBbuFYMpWqqBWzPnPFXhj+WQ4Teo08xq1XCTGo0yan8sdU5TGXzPieIzs5EAur EOHg== X-Gm-Message-State: ALoCoQkP3Byf9V6VCiTTbgMWc6MT1YE/kradhlEbw52yFHvoJnHBcF2zEih75G3kfkZHtokVPr0a X-Received: by 10.152.37.37 with SMTP id v5mr101253laj.9.1415833500325; Wed, 12 Nov 2014 15:05:00 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls643015lae.38.gmail; Wed, 12 Nov 2014 15:05:00 -0800 (PST) X-Received: by 10.152.43.80 with SMTP id u16mr5013366lal.53.1415833500185; Wed, 12 Nov 2014 15:05:00 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id b2si36406611lbm.104.2014.11.12.15.05.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 15:05:00 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id ge10so12417916lab.30 for ; Wed, 12 Nov 2014 15:05:00 -0800 (PST) X-Received: by 10.152.88.8 with SMTP id bc8mr10587876lab.64.1415833500087; Wed, 12 Nov 2014 15:05:00 -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 ew9csp508536lbc; Wed, 12 Nov 2014 15:04:59 -0800 (PST) X-Received: by 10.180.109.194 with SMTP id hu2mr53189947wib.24.1415833499088; Wed, 12 Nov 2014 15:04:59 -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 16si42137508wjr.38.2014.11.12.15.04.57 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 12 Nov 2014 15:04:59 -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 1Xogy7-0006Qp-Q0; Wed, 12 Nov 2014 23:04:55 +0000 Received: from mail-lb0-f173.google.com ([209.85.217.173]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xogxr-0006Pc-Ls for lng-odp@lists.linaro.org; Wed, 12 Nov 2014 23:04:39 +0000 Received: by mail-lb0-f173.google.com with SMTP id n15so10361163lbi.18 for ; Wed, 12 Nov 2014 15:04:34 -0800 (PST) X-Received: by 10.112.173.39 with SMTP id bh7mr28340744lbc.53.1415833473799; Wed, 12 Nov 2014 15:04:33 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-147.2com.net. [46.188.125.147]) by mx.google.com with ESMTPSA id p2sm7014700lah.48.2014.11.12.15.04.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 15:04:33 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 13 Nov 2014 02:04:21 +0300 Message-Id: <1415833461-9291-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1415833461-9291-1-git-send-email-maxim.uvarov@linaro.org> References: <1415833461-9291-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 2/2] 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.43 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 --- 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 2cf3f0d..424f19b 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -69,6 +69,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; /** @@ -78,6 +79,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; /** @@ -120,6 +122,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; @@ -141,6 +144,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 @@ -229,6 +247,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; @@ -250,6 +270,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); @@ -384,6 +419,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; @@ -492,14 +528,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) @@ -559,6 +597,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]); @@ -629,6 +670,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"