From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00067.outbound.protection.outlook.com [40.107.0.67]) by dpdk.org (Postfix) with ESMTP id D48CD1B2A9 for ; Thu, 18 Jan 2018 11:02:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+k7+BT94y1hMKDeM3TXPkR9XA2VI2V4b8az0SkB7V3k=; b=iOJLGBq6E/UDlGPLh8pD0ntQr7A6XlfS9oId38iTNROS56ph2zI0B573m2nLtWCYKHnFwaLDZ82bNA0/LHV/s1OIRaXQkbzsXwpwjMB+WrMvBsJ0rjPCgKhuTsK2lW3sDqjbn8WzOdxTLskDlcNb0YpKKFen3OHmhG58gqCrR0A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM6PR0502MB3797.eurprd05.prod.outlook.com (2603:10a6:209:a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 18 Jan 2018 10:02:10 +0000 From: Matan Azrad To: Ferruh Yigit Cc: Thomas Monjalon , dev@dpdk.org, stephen@networkplumber.org Date: Thu, 18 Jan 2018 10:01:49 +0000 Message-Id: <1516269709-15252-9-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516269709-15252-1-git-send-email-matan@mellanox.com> References: <1516265026-6469-1-git-send-email-matan@mellanox.com> <1516269709-15252-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0202CA0033.eurprd02.prod.outlook.com (2603:10a6:803:14::46) To AM6PR0502MB3797.eurprd05.prod.outlook.com (2603:10a6:209:a::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d2531628-bb86-4d98-a457-08d55e5a8a8f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020); SRVR:AM6PR0502MB3797; X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3797; 3:8lQNP4LZi8XChXtKIhwfs6bo5MG8kI4ewcMXjqbhhG2DnLjtTvIn90//wRIBtoVM6Ddnclx9+WzsiOqQbuS4tvTzeLGd7elzK6+22x3udx+Ad6hxc2BSscc7tf6sstnp7/1LzjEGlgnnLw/UDE6HOjfYhdmKOpAv7DDJqg5fy+Lol6RJvLVZL6A8qzIPNrq14jHyqfMcEAGEBUvTT0E/+8xw/iyokPRmgZ+LOsAlSyWSb/eGC85p+U9Et6aXdF5T; 25:/dQqXziyFpD4n8/15vJd+DyD/wnkRjRvWI8+Eqbk9Z6yEIXZmfId4E5loW6gLRReegYjhajJ0TyfYyeySxiYN+73vK72MRhh1MJXPOSc5UMxGNe1LzZ4aUFDD5N2MTxenql8OAbszaW4jv5rFo3ANMjftJ/lZOqChu94PS/34RfiKjMj5pYZwVfPcdIC5QVO/MDiPdnlatNND+Os07bN4iCFStH0Ds2OIJzBdoLVZ2iAvtS793iQqx/m9wq+ZVIaLDbSIneP+xeocDPOzDeOegzYmjxkNR9N+B8+d1AVWHP6AhGU5syisiWvutR/Hrp8h8o8FAkij4kEKZy0klwKFg==; 31:IbMnajSqPMWjhZk8GZawmqlIEnS+CHoCrmhbmcjqjV1ovkxpeBb75KMHlt+ArC0TOP8U++o1b697e1sl3pThpOPiUVCYlGn3YTjLxrH7PXFcjk3NVzS0hd3dsLeBxYZBojXRGqdX3ftYxVLX0eCG6NVtxoJy+bTvw2D5v129m35NW2x9Zm8IJdOuBadF5J/6XAgRKIQ+2eoz7LPKkA7w8awdNUowRvsubjbLGXmDztg= X-MS-TrafficTypeDiagnostic: AM6PR0502MB3797: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3797; 20:vLxaTLkinrqQSvobmKGy/Nu1M/m4Y1rvQbaQgW14XTuZYkHjTWL1I9o/EaZagMF1gzo6LdNXmC44wNHH1iVzvffAUE58jKZVUdzoNpyIm4Z1fW1Fyw/mMfV4N3Jza+M87TS/jOQk5TlFqqHeC7sjBo+GbsYHUcBbr1VY/pdJM/QdRCwNaaewDhOvdfwap7yHr0tpLCIgEsDIoWjn81AI77Nv6quut+BC7qxKkvGklj2Gh1c43VlkjAn2/gG0Z6XYr5w3zPh7Tl7ubWxn+Gq6hMTYh1wrjBJbKeiYvxMgWac2ettzn8sNw1fq+mRjMGTnndsepb9sRE9Bhs6m2SRo2+Ic4ay/MahyhKWgKFklrmCJi7ixgVFbRZDa7JCVW9BSUDnp/jHMQD3BgEW8+OFma8S/OIsg8W1IKuKdNnaaCUiUNZW+NVO0EcmLC+xFnoZXaQZmndyjJ2mNXU+GNl9sbUWSRNikpTAxkd1Bjraf4F1iLOyqaQ1Ca6oMq3yN3GVl; 4:elu5Az4UccpwQ72vj7RMYHhAfqzG24M9s1Dj7KrVTKz6xoGHydeVn/VEKzB1OqlTBFpkkZZFsmZb6TxoEKBOAM67upSEr4fLgJixYL5HPdpupPJCxJiDpEw4+4Yctwq4zeOZggSHb6+mRrcEUBJgHie3VkJGYJvdF2yNVpazOi2N7/TRqnCSSOSRormeSdsup48WBlCi/q5Kpfl0Kus8U1rhxfCWhSsRkHJmXXUIHBMjqLuCHJVZpoYLA9UzGLsGBjnTSZv5c6UPdXWyAdsebxLREvJ4Uo6V+cjgdzbrNrNMM/cdb4hDJy+GwOOpOoZ3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(10201501046)(3231023)(2400060)(944501161)(3002001)(93006095)(93001095)(6055026)(6041268)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM6PR0502MB3797; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0502MB3797; X-Forefront-PRVS: 05568D1FF7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(39380400002)(346002)(396003)(376002)(199004)(189003)(6116002)(53936002)(76176011)(386003)(4720700003)(59450400001)(26005)(7736002)(305945005)(50466002)(66066001)(2906002)(47776003)(16586007)(5890100001)(8676002)(478600001)(316002)(21086003)(2950100002)(25786009)(48376002)(52116002)(6666003)(51416003)(7696005)(6916009)(81166006)(81156014)(8936002)(4326008)(86362001)(575784001)(16526018)(97736004)(68736007)(36756003)(50226002)(5660300001)(105586002)(3846002)(69596002)(106356001)(33026002)(55016002)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3797; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM6PR0502MB3797; 23:8vHWvHUN0kLsVLvn3FXtBxGR4VTexV2t/Yp0i6w?= =?us-ascii?Q?3PTAhWXsOn0R+5DvaomUblVQ2QLeedTanY/nccT+iTMq33QtKPUH9dDATSF0?= =?us-ascii?Q?TIVZu3xEFvB5F5xx4ZqelvrwwWzPNOWsCmK0Vr3GHFEEoVkIeDgFCnqeYdDf?= =?us-ascii?Q?2L+Nzc7C3QLEaPvbq/EMP2pjE4T13jcNmvO1s6/bpQ+Is84IkWJK4WSwqtrU?= =?us-ascii?Q?Y0HaH+OAZQ1PNW1ZQa7XuT4wmDyDP/CKHFlfTzVUEv/6o6jtf97ty/j1eNzF?= =?us-ascii?Q?UTxx9pcyMlJ2HYilQMfUkvkizS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amDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 10:02:10.1280 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2531628-bb86-4d98-a457-08d55e5a8a8f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3797 Subject: [dpdk-dev] [PATCH v5 8/8] net/vdev_netvsc: add automatic probing 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: Thu, 18 Jan 2018 10:02:12 -0000 Using DPDK in Hyper-V VM systems requires vdev_netvsc driver to pair the NetVSC netdev device with the same MAC address PCI device by fail-safe PMD. Add vdev_netvsc custom scan in vdev bus to allow automatic probing in Hyper-V VM systems unless it was already specified by command line. Add "ignore" parameter to disable this auto-detection. Signed-off-by: Matan Azrad --- doc/guides/nics/vdev_netvsc.rst | 9 ++++-- drivers/net/vdev_netvsc/vdev_netvsc.c | 55 +++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/doc/guides/nics/vdev_netvsc.rst b/doc/guides/nics/vdev_netvsc.rst index 3c26990..55d130a 100644 --- a/doc/guides/nics/vdev_netvsc.rst +++ b/doc/guides/nics/vdev_netvsc.rst @@ -71,8 +71,8 @@ Build options Run-time parameters ------------------- -To invoke this driver, applications have to explicitly provide the -``--vdev=net_vdev_netvsc`` EAL option. +This driver is invoked automatically in Hyper-V VM systems unless the user +invoked it by command line using ``--vdev=net_vdev_netvsc`` EAL option. The following device parameters are supported: @@ -91,5 +91,10 @@ The following device parameters are supported: If nonzero, forces the use of specified interfaces even if not detected as NetVSC or detected as routed NETVSC. +- ``ignore`` [int] + + If nonzero, ignores the driver runnig (actually used to disable the + auto-detection in Hyper-V VM). + Not specifying either ``iface`` or ``mac`` makes this driver attach itself to all unrouted 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 2d03033..a8a1a7f 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -30,13 +30,16 @@ #include #include #include +#include #include #include #define VDEV_NETVSC_DRIVER net_vdev_netvsc +#define VDEV_NETVSC_DRIVER_NAME RTE_STR(VDEV_NETVSC_DRIVER) #define VDEV_NETVSC_ARG_IFACE "iface" #define VDEV_NETVSC_ARG_MAC "mac" #define VDEV_NETVSC_ARG_FORCE "force" +#define VDEV_NETVSC_ARG_IGNORE "ignore" #define VDEV_NETVSC_PROBE_MS 1000 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}" @@ -45,7 +48,7 @@ #define DRV_LOG(level, ...) \ rte_log(RTE_LOG_ ## level, \ vdev_netvsc_logtype, \ - RTE_FMT(RTE_STR(VDEV_NETVSC_DRIVER) ": " \ + RTE_FMT(VDEV_NETVSC_DRIVER_NAME ": " \ RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__,))) @@ -601,6 +604,7 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = VDEV_NETVSC_ARG_IFACE, VDEV_NETVSC_ARG_MAC, VDEV_NETVSC_ARG_FORCE, + VDEV_NETVSC_ARG_IGNORE, NULL, }; const char *name = rte_vdev_device_name(dev); @@ -610,6 +614,7 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = unsigned int specified = 0; unsigned int matched = 0; int force = 0; + int ignore = 0; unsigned int i; int ret; @@ -623,10 +628,17 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = if (!strcmp(pair->key, VDEV_NETVSC_ARG_FORCE)) force = !!atoi(pair->value); + else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IGNORE)) + ignore = !!atoi(pair->value); else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE) || !strcmp(pair->key, VDEV_NETVSC_ARG_MAC)) ++specified; } + if (ignore) { + if (kvargs) + rte_kvargs_free(kvargs); + return 0; + } rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); /* Gather interfaces. */ ret = vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, name, kvargs, @@ -690,7 +702,8 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc, VDEV_NETVSC_ARG_IFACE "= " VDEV_NETVSC_ARG_MAC "= " - VDEV_NETVSC_ARG_FORCE "="); + VDEV_NETVSC_ARG_FORCE "= " + VDEV_NETVSC_ARG_IGNORE "="); /** Initialize driver log type. */ RTE_INIT(vdev_netvsc_init_log) @@ -699,3 +712,41 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = if (vdev_netvsc_logtype >= 0) rte_log_set_level(vdev_netvsc_logtype, RTE_LOG_NOTICE); } + +/** Compare function for vdev find device operation. */ +static int +vdev_netvsc_cmp_rte_device(const struct rte_device *dev1, + __rte_unused const void *_dev2) +{ + return strcmp(dev1->devargs->name, VDEV_NETVSC_DRIVER_NAME); +} + +/** + * A callback called by vdev bus scan function to ensure this driver probing + * automatically in Hyper-V VM system unless it already exists in the + * devargs list. + */ +static void +vdev_netvsc_scan_callback(__rte_unused void *arg) +{ + struct rte_vdev_device *dev; + struct rte_devargs *devargs; + struct rte_bus *vbus = rte_bus_find_by_name("vdev"); + + TAILQ_FOREACH(devargs, &devargs_list, next) + if (!strcmp(devargs->name, VDEV_NETVSC_DRIVER_NAME)) + return; + dev = (struct rte_vdev_device *)vbus->find_device(NULL, + vdev_netvsc_cmp_rte_device, VDEV_NETVSC_DRIVER_NAME); + if (dev) + return; + if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, VDEV_NETVSC_DRIVER_NAME)) + DRV_LOG(ERR, "unable to add netvsc devargs."); +} + +/** Initialize the custom scan. */ +RTE_INIT(vdev_netvsc_custom_scan_add) +{ + if (rte_hypervisor_get() == RTE_HYPERVISOR_HYPERV) + rte_vdev_add_custom_scan(vdev_netvsc_scan_callback, NULL); +} -- 1.8.3.1