From patchwork Thu Nov 13 12:18:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 40745 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 263CB24493 for ; Thu, 13 Nov 2014 12:18:49 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf9326046eek.5 for ; Thu, 13 Nov 2014 04:18:48 -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=Nd5CJGOc5OTHJmSVyftqMSQoPj/LAKfmxwKZBigzKQWUh8HOFsxdwvm/5V0fLXlfID ubjkpYqRMgh7qWTdYVTu69VwPVm2vnauQ2CX7Hph9QTNLRQLk75Gjj1gYMr581hnJcya CEHHf0sSfekEVfnOw81ZphmwlDmeSTqHw+WWpqsDt5EKnjRL6UeLShfERa+WpW3TLtYc /OW9c1EnKWiIgY9UUGZIdIqRX6oMbsvJClYCftnk3F54sSv9AC/+VNlAZkf6G3OsJ5lK C3kimXWXGSdy8F2PyL8efYXm+4rIZJc9DySIDD8sE+xD7PT7MxXfrAmlHngYZ7Y4t0dS yJ2g== X-Gm-Message-State: ALoCoQkLtncWoZLNVE1/vrey10+BbfqHShfzAwdXAmVHQwbpa/NwEKaU9a0vrYH22VUoijKi4jsx X-Received: by 10.181.8.194 with SMTP id dm2mr7917041wid.2.1415881127094; Thu, 13 Nov 2014 04:18:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.1 with SMTP id lk1ls817043lac.9.gmail; Thu, 13 Nov 2014 04:18:46 -0800 (PST) X-Received: by 10.112.172.97 with SMTP id bb1mr2125707lbc.38.1415881126933; Thu, 13 Nov 2014 04:18:46 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id k5si20857791lag.75.2014.11.13.04.18.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 04:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id pn19so12970847lab.4 for ; Thu, 13 Nov 2014 04:18:46 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr2079213lbr.74.1415881126840; Thu, 13 Nov 2014 04:18:46 -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 ew9csp579525lbc; Thu, 13 Nov 2014 04:18:45 -0800 (PST) X-Received: by 10.140.85.233 with SMTP id n96mr2740396qgd.78.1415881125213; Thu, 13 Nov 2014 04:18:45 -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 g4si15923518qcl.38.2014.11.13.04.18.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Nov 2014 04:18:45 -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 1XotMH-0001UG-Bw; Thu, 13 Nov 2014 12:18:41 +0000 Received: from mail-lb0-f180.google.com ([209.85.217.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XotM1-0001Td-Md for lng-odp@lists.linaro.org; Thu, 13 Nov 2014 12:18:25 +0000 Received: by mail-lb0-f180.google.com with SMTP id z11so4152485lbi.39 for ; Thu, 13 Nov 2014 04:18:19 -0800 (PST) X-Received: by 10.112.150.71 with SMTP id ug7mr2056541lbb.73.1415881099731; Thu, 13 Nov 2014 04:18:19 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-147.2com.net. [46.188.125.147]) by mx.google.com with ESMTPSA id j6sm7450270lbs.9.2014.11.13.04.18.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Nov 2014 04:18:18 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 13 Nov 2014 15:18:06 +0300 Message-Id: <1415881086-13088-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1415881086-13088-1-git-send-email-maxim.uvarov@linaro.org> References: <1415881086-13088-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 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.45 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"