From patchwork Fri Nov 14 09:30:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 40803 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3CC4240ED for ; Fri, 14 Nov 2014 09:31:44 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d17sf10453535eek.11 for ; Fri, 14 Nov 2014 01:31:44 -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=S1AesAwIu29F6RJ4wm8lX+mk92Tqf65gcEgwkd2x5bqGydkIF0nNUyGBA2TR6wj+Wn fzswOr8UmwX4NOnd7WkiVT/GsioBkje2TX0xrEGqyq8WPytHc6cub/QiHu5gDCwrUJRm ZfVsDsLRVxm7SBYMyGr7vXLD12YRFsvfm6v+cpds6cQs9IUj1RNqsHma3ockWctg3KHj Ni14Bf1pf2Qq28IScARtMHE7qFJWKZ4gBqYBdPgVOkMudU7zRD331TxkEDNwstCnU+VR LWMJ6Q+FaZXPfIMoKmmt45iu8ppL/CnG/zHLren7OCO9PshYPBQiuSdOlhfvx3XXISJT C7xg== X-Gm-Message-State: ALoCoQldmiB0nuk7wdkfxokGVAJ/+yiE+Y3cM7VGEjtv/6ipimga5jtNSH894rIUXZncoVGtXiGR X-Received: by 10.112.55.10 with SMTP id n10mr202623lbp.14.1415957504060; Fri, 14 Nov 2014 01:31:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.228.140 with SMTP id si12ls882721lac.25.gmail; Fri, 14 Nov 2014 01:31:43 -0800 (PST) X-Received: by 10.112.201.72 with SMTP id jy8mr7173925lbc.65.1415957503840; Fri, 14 Nov 2014 01:31:43 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id xe3si40922922lbb.114.2014.11.14.01.31.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 01:31:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id gf13so2808573lab.28 for ; Fri, 14 Nov 2014 01:31:43 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr7277256lbc.34.1415957503717; Fri, 14 Nov 2014 01:31:43 -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 ew9csp736024lbc; Fri, 14 Nov 2014 01:31:42 -0800 (PST) X-Received: by 10.224.129.9 with SMTP id m9mr10097933qas.50.1415957502097; Fri, 14 Nov 2014 01:31:42 -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 f109si40760516qga.115.2014.11.14.01.31.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 14 Nov 2014 01:31:42 -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 1XpDE4-0003ni-Pr; Fri, 14 Nov 2014 09:31:32 +0000 Received: from mail-lb0-f172.google.com ([209.85.217.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XpDDp-0003mg-52 for lng-odp@lists.linaro.org; Fri, 14 Nov 2014 09:31:17 +0000 Received: by mail-lb0-f172.google.com with SMTP id u10so5027014lbd.31 for ; Fri, 14 Nov 2014 01:31:11 -0800 (PST) X-Received: by 10.112.148.199 with SMTP id tu7mr7297059lbb.7.1415957471595; Fri, 14 Nov 2014 01:31:11 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-121.2com.net. [46.188.125.121]) by mx.google.com with ESMTPSA id x3sm1676435laj.34.2014.11.14.01.31.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 01:31:10 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 14 Nov 2014 12:30:58 +0300 Message-Id: <1415957459-11458-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1415957459-11458-1-git-send-email-maxim.uvarov@linaro.org> References: <1415957459-11458-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv4 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.41 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"