From patchwork Tue Nov 11 18:15:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 40609 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 41E79206A5 for ; Tue, 11 Nov 2014 18:15:41 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf1035119wiv.2 for ; Tue, 11 Nov 2014 10:15:40 -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=VonGe+S6rD8rCsrfCbpCxnDOpkO2cGUVjRyrFRw/Gi8=; b=X7rfcjGnIfZi1TDPjZ+F0Gf+223OegXOBB77hDzjaqFI+FdFlFmanbtd6Hm9oQ31Kq xvFE+FSkF1abGMSRZhP6Mp1rqYSVt7vgMxtlepZ4yZnsoHRPAmUqJQplEfi49VVEj8TH Bspj129emxemVoW4lryEsD/PqyijE9VnRcPGdAq8a9ddTjoCtGJWToMjDSrXrl2aI46R CxVGxC5kOdKcc+TyCfFBLB/GOYXXlq85HzD8PEeCscmqm18mlyzuqU/UVBGM/Fbd/pC5 wKRBJjvbiZAiMlG58nThPvZn53ka1KRdXA9nLn7wXvRi7u02VShKy17GRCBr9wxRi5iT XOXA== X-Gm-Message-State: ALoCoQmojJwvAFfAKRD1LJdvKmz4cFJbHcMFhWbodU34ClmSA71JVBm4rGZ02yru7rjZprGzlRoD X-Received: by 10.180.100.100 with SMTP id ex4mr5607057wib.2.1415729740489; Tue, 11 Nov 2014 10:15:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.5 with SMTP id ca5ls471360lad.68.gmail; Tue, 11 Nov 2014 10:15:40 -0800 (PST) X-Received: by 10.152.5.100 with SMTP id r4mr37829853lar.26.1415729740091; Tue, 11 Nov 2014 10:15:40 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id c1si32424092lbv.23.2014.11.11.10.15.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 10:15:40 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gf13so10115225lab.17 for ; Tue, 11 Nov 2014 10:15:40 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr37310013lap.44.1415729739994; Tue, 11 Nov 2014 10:15:39 -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 ew9csp302515lbc; Tue, 11 Nov 2014 10:15:38 -0800 (PST) X-Received: by 10.140.86.116 with SMTP id o107mr51064802qgd.67.1415729738345; Tue, 11 Nov 2014 10:15:38 -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 gc8si37994038qcb.7.2014.11.11.10.15.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 10:15:38 -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 1XoFya-0006jd-H6; Tue, 11 Nov 2014 18:15:36 +0000 Received: from mail-lb0-f181.google.com ([209.85.217.181]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoFyP-0006jG-Ax for lng-odp@lists.linaro.org; Tue, 11 Nov 2014 18:15:25 +0000 Received: by mail-lb0-f181.google.com with SMTP id l4so7983642lbv.26 for ; Tue, 11 Nov 2014 10:15:19 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr37231482lbc.23.1415729719681; Tue, 11 Nov 2014 10:15:19 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id bk3sm6143870lbc.34.2014.11.11.10.15.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 10:15:18 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 11 Nov 2014 21:15:00 +0300 Message-Id: <1415729700-23420-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1415729700-23420-1-git-send-email-maxim.uvarov@linaro.org> References: <1415729700-23420-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 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.44 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..04cfa5f 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 */ + unsigned 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 */ + unsigned 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; + unsigned 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); + } + + ret = odp_pktio_mtu(pktio, &mtu); + if (!ret) + 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; + unsigned int mtu = 0; + 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); + } + + ret = odp_pktio_mtu(pktio, &mtu); + if (!ret) + 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"