From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 330E61B62E for ; Fri, 22 Dec 2017 19:01:53 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id w68so16121398wrc.10 for ; Fri, 22 Dec 2017 10:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NDB2sfn2XOwt22YMTTuv+GYhuLajn5RimIVHcICgflw=; b=qp+nklGx14gRpAd/GM8YCZ/0x8cOMkHSrWpHns3slos9aRX/xH8hfsddslDFnS5ri2 xG5+N24aDKR4Ydw8Q/dasTd2qhBQBvP+VwCIVpszfsupB3fY7IqZsHr/qy1XUOgQkBWV YAxSHR+0bA+x7Kovy9ocrgerpJhTjfv2gosmG3NbbvWX68F74lgghIPx0Zjq+ttZmYLZ 7WVUKJhA1g8yHpGGd6tgCsLfoTrp8cmtRkbKUnUuRjDxMvlBDHi51Gt88z+SaRFtm+W9 zd1P3gPyCoiKbPgWMHZcfyCE2CRquXao7AD+JiaoK89UI0sG5Cw4vxSyFy5sBoSLu5c5 NlwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NDB2sfn2XOwt22YMTTuv+GYhuLajn5RimIVHcICgflw=; b=n8Mebo+ORxfHv7CB1Ehv9ToJwTZdVTZAwmQ+wdWFdWn1N/PZ1F/jljg4L1QLRl+1b5 Oxrulk9YQjy45Y0fy7qEPejuhE0wkWxsr4lX28SnWb32hf/LoNG9Q717+SXYIoP3Wpij 0VpmVOXWTvvXWfeLptX7xbphOZ4amp9X/oyKpUD4AqMIxuENhvMjL5WhKegDlw/VCAeG u8fSF5tc0YD13dSwbMW7h391ZI2fR/E5fDAANfqwgmK1SxHOTQ3cqSudBiN9Yl2qUFN0 orJldgQLirmr+WUs+qVzIiQknENk4R2L+GLc65MoQ9d6oyHMpjTWzwxJ/hRA9x4KD3RI D8mw== X-Gm-Message-State: AKGB3mJBZR5Eui+/pR2M5aHc2dAmpyYhXJWH4cHjD0hEKCxifv0mXTz1 XC1euqNhdi0sMgR5nTQO9IFrAUd0 X-Google-Smtp-Source: ACJfBovhudL9cqJT164tUawgAK3RjlZEk1ke7ySqALBSAT0BM3tQMo2gBfDnOub/8QfVyDQ5IVL5fg== X-Received: by 10.223.184.18 with SMTP id h18mr15142092wrf.11.1513965711857; Fri, 22 Dec 2017 10:01:51 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id x13sm9013756wre.65.2017.12.22.10.01.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Dec 2017 10:01:51 -0800 (PST) Date: Fri, 22 Dec 2017 19:01:39 +0100 From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, Stephen Hemminger Message-ID: <20171222173846.20731-6-adrien.mazarguil@6wind.com> References: <20171218162443.12971-1-adrien.mazarguil@6wind.com> <20171222173846.20731-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171222173846.20731-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v2 5/5] net/vdev_netvsc: add "force" parameter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Dec 2017 18:01:53 -0000 This parameter allows specifying any non-NetVSC interface to use with tap sub-devices for development purposes. Signed-off-by: Adrien Mazarguil --- doc/guides/nics/vdev_netvsc.rst | 5 +++++ drivers/net/vdev_netvsc/vdev_netvsc.c | 27 +++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/doc/guides/nics/vdev_netvsc.rst b/doc/guides/nics/vdev_netvsc.rst index 73a63e552..a0417b5ef 100644 --- a/doc/guides/nics/vdev_netvsc.rst +++ b/doc/guides/nics/vdev_netvsc.rst @@ -107,5 +107,10 @@ The following device parameters are supported: Same as ``iface`` except a suitable NetVSC interface is located using its MAC address. +- ``force`` [int] + + If nonzero, forces the use of specified interfaces even if not detected as + NetVSC. + Not specifying either ``iface`` or ``mac`` makes this PMD attach itself to all NetVSC interfaces found on the system. diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index 738196e75..5e426adc0 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -63,6 +63,7 @@ #define VDEV_NETVSC_DRIVER net_vdev_netvsc #define VDEV_NETVSC_ARG_IFACE "iface" #define VDEV_NETVSC_ARG_MAC "mac" +#define VDEV_NETVSC_ARG_FORCE "force" #define VDEV_NETVSC_PROBE_MS 1000 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}" @@ -405,6 +406,9 @@ vdev_netvsc_alarm(__rte_unused void *arg) * - struct rte_kvargs *kvargs: * Device arguments provided to current driver instance. * + * - int force: + * Accept specified interface even if not detected as NetVSC. + * * - unsigned int specified: * Number of specific netdevices provided as device arguments. * @@ -422,6 +426,7 @@ vdev_netvsc_netvsc_probe(const struct if_nameindex *iface, { const char *name = va_arg(ap, const char *); struct rte_kvargs *kvargs = va_arg(ap, struct rte_kvargs *); + int force = va_arg(ap, int); unsigned int specified = va_arg(ap, unsigned int); unsigned int *matched = va_arg(ap, unsigned int *); unsigned int i; @@ -480,10 +485,11 @@ vdev_netvsc_netvsc_probe(const struct if_nameindex *iface, if (!specified) return 0; PMD_DRV_LOG(WARNING, - "interface \"%s\" (index %u) is not NetVSC," - " skipping", - iface->if_name, iface->if_index); - return 0; + "interface \"%s\" (index %u) is not NetVSC, %s", + iface->if_name, iface->if_index, + force ? "using anyway (forced)" : "skipping"); + if (!force) + return 0; } /* Create interface context. */ ctx = calloc(1, sizeof(*ctx)); @@ -610,6 +616,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) static const char *const vdev_netvsc_arg[] = { VDEV_NETVSC_ARG_IFACE, VDEV_NETVSC_ARG_MAC, + VDEV_NETVSC_ARG_FORCE, NULL, }; const char *name = rte_vdev_device_name(dev); @@ -618,6 +625,7 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) vdev_netvsc_arg); unsigned int specified = 0; unsigned int matched = 0; + int force = 0; unsigned int i; int ret; @@ -631,14 +639,16 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev) for (i = 0; i != kvargs->count; ++i) { const struct rte_kvargs_pair *pair = &kvargs->pairs[i]; - if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE) || - !strcmp(pair->key, VDEV_NETVSC_ARG_MAC)) + if (!strcmp(pair->key, VDEV_NETVSC_ARG_FORCE)) + force = !!atoi(pair->value); + else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE) || + !strcmp(pair->key, VDEV_NETVSC_ARG_MAC)) ++specified; } rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); /* Gather interfaces. */ ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, name, kvargs, - specified, &matched); + force, specified, &matched); if (ret < 0) goto error; if (matched < specified) @@ -697,7 +707,8 @@ RTE_PMD_REGISTER_VDEV(VDEV_NETVSC_DRIVER, vdev_netvsc_vdev); RTE_PMD_REGISTER_ALIAS(VDEV_NETVSC_DRIVER, eth_vdev_netvsc); RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc, VDEV_NETVSC_ARG_IFACE "= " - VDEV_NETVSC_ARG_MAC "="); + VDEV_NETVSC_ARG_MAC "= " + VDEV_NETVSC_ARG_FORCE "="); /** Initialize driver log type. */ static void -- 2.11.0