From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr60080.outbound.protection.outlook.com [40.107.6.80]) by dpdk.org (Postfix) with ESMTP id 882121B1AB for ; Thu, 18 Jan 2018 09:44:15 +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=ypfTU6JWtWm2PJ6qacj4XWG9qG1kVZqypBIiilDGI93UoaBMlCnUrkQyOjaMPqZuu2nN0Cph+lnipWzogv1uu+j+l4wMpTZbEVNfZLBQofHEKiIXsjIDh5vaYvzyyGH8ymzCjXJzXkh5WkaY2ZivRffJdKpXG8y2D7KiPReGY0Q= 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 08:44:13 +0000 From: Matan Azrad To: Ferruh Yigit Cc: Thomas Monjalon , dev@dpdk.org, stephen@networkplumber.org Date: Thu, 18 Jan 2018 08:43:46 +0000 Message-Id: <1516265026-6469-9-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516265026-6469-1-git-send-email-matan@mellanox.com> References: <1515509253-17834-1-git-send-email-matan@mellanox.com> <1516265026-6469-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0902CA0040.eurprd09.prod.outlook.com (2603:10a6:802:1::29) To AM6PR0502MB3797.eurprd05.prod.outlook.com (2603:10a6:209:a::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27642bbd-23e0-40ed-634f-08d55e4fa722 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:00SmJsXTUOPtSz5L8vacXOGuErrDAneVFcJ/iV8Vc7pv7SzAguUNDBSG+iPVNQJWgRfSL4C785Kd5on1TI95nT2s68gIIcgcAT+nNbIm7ZJFsDhiYgrjYSD7whcC5/21mgtgRO/7StqyPbkqpU/FiYVdU/pPUCBb2586h8wbz5k1u2YLARKtwuj6S4KUyPOMnDYQeGNsiVQux2glY1a02Ia9YN3zJ0jbnaz8iFUUpA3zoxYpon4mgSU7lSxuODTT; 25:uGGTn9wxHbbSD58igjCqPdKkB6zBF63ZQGhN//I1VIvxjviXHJ4X1TT2Z50Jjek8csaK8rwzj/JE0X0GOOfPodFywrBF4UHWzHns1xJkUZ/lCRfpwlzuo4ypQOn0Xs8O98OUZQQ0fgcmj1BMDJvoqIr6qT3JllPd/xxfLahhgYqHewtk1C3EUFSuJonwwqhPaQq4CqaTaOOYcBqElPQmbnImT8mlzV/f5GEvcKHihh9GVvtxd3M6/zyJEovGb0ggfERlcS69WG+PZrUXdQ83EdDWHYvtoopRrZA1y/HLrJl5ULjG+LiRkyuZgFowvfEh1u99JHO9SjOtYxzNokEz5Q==; 31:KILsCC3aQAo7uHlGky4HExPDUowhuF/6RuJNdGObz3yxO+VvQmWx+YwXKWIMcjzv3LemutzrRO/0QJ52f9Ren8lBpZ0D/6VuSHb6wHJhy++4oAPgtbyyiF1GrfbP39r0TMTldJdzXP98cvVtOe1dVZszvJkRhJK/butIqrd3QhMYgtrfIQLPgNLRVy4gnK9S8J/u2kdezEqCzEzg3eSkU1DuZ0EhK8mAVWzQLuRkC/c= X-MS-TrafficTypeDiagnostic: AM6PR0502MB3797: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3797; 20:2peU7iVOK9l9wJZqPEVY0IX6c37C5pwl3v52T9XButcIopvrlhwZrDwIbE7cFDoWCJY7NEIctKDJYBn8kB06TTPA7odgFJfZQPOJWVsBxN3qcaCV0mn7jSLHOBIciDOOiNyY88hOVlG+jeP4h++cffkPZizxnIBJBYFMdxvuEPFBAy+Ei4nqeXwJCR65TI/A1PqHsCkmHEMIZeuZXy5ZMWLPO5fv8kIweXs+r2MXl0pxd2EKoBJ0UDsy8/+tC+5NbUa9p0MCLygl+NEGTwSuDPz+L+ctL5UiDOEsgk5inAmNtCH68SooVrMaTJIateWSyB2TViPLTFIdy6ibjoCPhPYcOeibHNBCebNh5MDvqJ1BJWfSjVcV9h2HjLJxXvpVbcPbNOOo9q3SaBce43y58k3Q1SQS6IXNUpuZEv951I43k4jt9YGCg7ggiuQBtEkHuQ7X/1Cg8+iDzzkq3gwt06F4mB7mtBFJlE2+ozeKt3PJDh//gKgKcrILY7uboDPQ; 4:mZuOBdQTghCmYEnV7AT/z3LuD3Coh+JqpBbzmT33oXICue+p0LTekL0WpG4voAvNrIScgCg1pM6Z5dHsOfwj2KqvEVzRKEB2N4/DoSeaaGxNTkg93mULKkec83l+pf3yGM37SBOaLa90dgKFMiI+ZzygK920iY90CKk7LE9q1TRsFEL03NRCcQUrTTfDqYRvryfqp44h/IWZ9JtBIyCzeaJbAv0FMf0Y9SA0qZhMbmedIlocHmr5EA1HH5A920tbUXa2i1/3Ut4KkbnBU+yNu6kuwrHpKIB7+5i5+Maro0VplSmgvF7VGP5+fvs+TD8y 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)(2400058)(944501161)(3002001)(93006095)(93001095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(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)(346002)(39380400002)(396003)(376002)(366004)(39860400002)(189003)(199004)(97736004)(68736007)(36756003)(50226002)(4326008)(86362001)(575784001)(16526018)(81156014)(81166006)(8936002)(33026002)(55016002)(105586002)(5660300001)(106356001)(69596002)(3846002)(53936002)(66066001)(7736002)(305945005)(47776003)(2906002)(6116002)(76176011)(26005)(59450400001)(386003)(4720700003)(50466002)(52116002)(6666003)(51416003)(6916009)(7696005)(25786009)(21086003)(2950100002)(48376002)(16586007)(5890100001)(8676002)(316002)(478600001)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3797; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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:V+CvBCsYZWyWPO0lyUFYAS5iMy+qNtzt4EVkElp?= =?us-ascii?Q?8CyVb76heFsKHQBDxuaPLmjRWcWGpm3r0EGu8LkkbrbLU8ddkTQYyZx+z7DV?= =?us-ascii?Q?ntrXCNbWxj9U4qK2mBie9a0VNS4Cg4+7LOTc6JmmgCy8nMdbG2DB3R3k+tDC?= =?us-ascii?Q?v3lA1hdQ0OdbV1fEQTBudS5i5/A159gLiA8Upb6z2UJBw0fwuK/h4mO57kyF?= =?us-ascii?Q?Tj0w1+UFj1cBxkWM5pS0Ebi8Zwvz/j/z+Wzu6Hrhm86Y6OenjnyF4K8tap++?= =?us-ascii?Q?vSHHxK3ZeWbNadx60E1heTj1i7sWMZILcL+L5JoSytjYpf8ez+RpbBm97Y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4uenu2ZemUVM7uvLv85/DgTytrC95pB?= =?us-ascii?Q?REuwOIk5nNE7Zfo7tHGowWljn+g4K/6wlNDDOH/jB?= X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3797; 6:FuasJxJAFkWCbT6HWn+suCYBJfvsQR7y3rwW0aI98clRtSWh/XyLChTSPeSkE0lZplul1MzZYKTgmyPeI3lmFjivr06NRuNpVRxsI0dunpaG8T5kRlRetkE7+SmBApcHgKDmpvhpoae3/fkbSupn/kXSzBvNJyOIQMBXlXunxxHL/hiwKJL3QahQzYBIt7vaQem82ce7xxUyQlaNMyVeJTbpjbrjG7/38lKyFPIdoD6/qoDm4UEN2xAMiyJxCIxTuYXmqIyxSbz3ZOZuuZDddXyUU7MbnaF2X7YXy8OF2XIPPC+QHn9w0gXwv2683m3bX6hME6KdLr5p3G+ep1Ppt8Gf7kgPPx/H9oYcExeh+2c=; 5:iegVVcG3aCAG+QR2CWKtocKkV9P9wg2vln05d0o4o7sCR+3QPZXTTBmpg7lu+bQ2iqMboKC+XMf9CIrSLUlz+tfUbQ3Pp/WFILIcUhbw92HgdP8hOapPxaEwdSeO319n0CXaiHYLPreyCMoc5xrJZEXSzKDZZzHlBQhMonxSbck=; 24:NqtKURDtXJhXhsY+kCEBPZCJrZXKNLFWPbqyxvSek30Tc/wmZV5amwfb//ULhrBLh8VAI6ry8tCi97heQGhVcVKwe9NWd3AZF9bN/fMB8J8=; 7:gd7kNBvKYVdGlHWwR4EqVrOHxKLZQbJyaIa+q9yX/UDqtp99R9ENzFci2xWvghrc0DMadzXDrLzjM2FwS4p8ERn8EQgecd3TojN2dK4SY/NpX0g4d8hoUEwLfYm/QaZU3gcNsIzx1X+dEdOzaQjFRD16l5CAX+juT+pfST531t8i9is14tuPDpOo4URZPzLUlwAzAB44coT+06Xv9PGk6/uNSYE79nS8Cnut2oC8gqmWKFQWaOaIDd5105fO2wDk SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 08:44:13.5862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27642bbd-23e0-40ed-634f-08d55e4fa722 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 v4 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 08:44:16 -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