From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0051.outbound.protection.outlook.com [104.47.1.51]) by dpdk.org (Postfix) with ESMTP id 537DA1B210 for ; Tue, 9 Jan 2018 15:48:24 +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=q4EiO2tT+8k1gBxXkbmz6rCRrdwUXUDRK+yNTtp7RBs=; b=o2QeU2bMiRAjNC5yOBxdbTVX6uEMlJz2bCIgEHfDCKzmSdOCHiuGgwJgiCWtsle8vcqem4bAq5yM5keqeSjgTNOgP7/A798IOU6IntBqxWyoH+pYkSF/SR+u6f+MUcrWevNj3fTJyTre5Jfm+D420JOjw6B/5exOPhW3ol9OJ9U= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM6PR0502MB3799.eurprd05.prod.outlook.com (2603:10a6:209:a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Tue, 9 Jan 2018 14:48:21 +0000 From: Matan Azrad To: Ferruh Yigit Cc: Thomas Monjalon , dev@dpdk.org, stephen@networkplumber.org Date: Tue, 9 Jan 2018 14:47:33 +0000 Message-Id: <1515509253-17834-9-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515509253-17834-1-git-send-email-matan@mellanox.com> References: <20171222173846.20731-1-adrien.mazarguil@6wind.com> <1515509253-17834-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1P191CA0006.EURP191.PROD.OUTLOOK.COM (2603:10a6:3:cf::16) To AM6PR0502MB3799.eurprd05.prod.outlook.com (2603:10a6:209:a::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a14e77fc-57ac-458b-022d-08d5577007e2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM6PR0502MB3799; X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3799; 3:WYs9ikNLnDmDZYqz5RjnSYVntr8eTVTtA+3gTpceJNMkWeNeUB0u9gy22UCnqkTDdUOeA3P52xuGNdzOx3cbtebHTcUyZBZgwCAQvtcxrpneCTsqc8Xmghn9rhRIiZ2dsK0sG6i3XEPVJsvfy3PDc9kSpc/NuYf9VLIN7biSEx5NUkyD/zPUXf7B6l5aLejrfCa2x9wSs0xgiLV52/FUMsx/c3RQF06rybgEakmsJYYXQ2KRbmxKh0swlSNLzN/M; 25:DpU0eUwmzQxogUizbANZGii5oAQy1eqADWbzSocsS8ygQX14MBUus5xCODzvlJd4yJ8S1JJ7ipT1k3Cp4xPTHzbR5v/mbfXlxya7HE96BIMcNPsKn1tbqyz+aKS8GmTichuT8piZYN9SsdMVahi1CPjF+p5BBULiZaHXUEIOSXHSvjLB9pzTEH7LqA/jR5eR+pjDTNjWSybZulpkN6nKLr3pFsJ5zve+kNOoOUSkY32McResu9RrWd2LZAbJ31pPsPcsCHHsWnXya+yVToe7XDHMEmV4MU2wIbVOLqQfSW78YLG1tAUqF7wEff22MEla3cEOgLqqk2PClxoMbl9Kfg==; 31:di42t9QrkQSRHpGNm2vrEalWyuFL0ygqmZGAbU+91/tP/P4PrFYvbebBIO+FHper/NNp+d5lA5lFVPwrczJqDKST1iI1ftStYeiLWcugjNzhRZYDqOGYgxKPMUkSVEqrrommjadb2++mJxTAgvtwaejCtzf+I9lT0Sp6O+blmEZUTlzDXoQI9Btoihmoxb0OcvwLwCjxCuPK93v0YuzEoqdw8n348WWeNYQ2OcW2WCU= X-MS-TrafficTypeDiagnostic: AM6PR0502MB3799: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3799; 20:eHP5AlpR+iAjDSdULxo/6fMPlYJJD/6hkuBp0df72gcue+oXxVqXrrFj6x8iLZ4Rfn0K9sPrPX4O+EPyTUmNR4TCC9yKeTy+OHoKVnSHepIlc+egrm5BaTvKGSFL/fmwWM1zoCsR0qsc0QHHLEZTpNuTia5XZXwEQi/thcBGmGPMTEvUNDa/4CKv8OvvAFqDmr8ngXr1hm3f1FECx3jLpxgYjRghAd2lQCbYB7wX7SfnNgdmQOGvWnsRLijWt6JKFLT28o7sbOGbuuwD5H2aXntv273HR4mkP46qyzZSZWRcyaEda+ypyJkWOYVP2dBw8/fQYz5baso7im5dyixEQzZhdtdJQppeBPNBbxoVDrwV3He6TjXAF7ORZvumkrP4cuBCkimx4mPAw7R4yHZ7bdFMC1fer/I+yHc8K2DSeiX+shB388Ihp722So8P99ChPKbQpjXpfDc52z6kos1IxMeSGtuHtn/pYOouvAfqXsY6xDyKWpnuIBuZFGbPUCEA; 4:zwQnal7LIou55zl2QXW+vmt+EGZ59rS+QjR8c6Coy4ARi1WLFe+Kbg2lH+Q0RomQby3ol9rkN3gXuWoCZcy8DJ4GCVb/22zng0QvpbuGVGt3qwVd30371uDlbitarLFmdRRaXinGHL1buSRVpBYHoMsS8awUJgwT0fgsiSME0b7cSO2E0oxIQDKqNkjkuMCJH6E/8oEnK7atoGOS7ScmB3gJj3/4R1cfY98viA4y2cFgVvhBB1qPK80PZIHCZ9yK7CfiBzdb1QcnD37nqFOj8inguvnvNBgdzAbXQDlyEjXkxv4UWCcNC59CPw9Or1sP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041268)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:AM6PR0502MB3799; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0502MB3799; X-Forefront-PRVS: 0547116B72 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(39380400002)(346002)(366004)(376002)(189003)(199004)(21086003)(16586007)(8676002)(575784001)(8936002)(5890100001)(316002)(3846002)(51416003)(97736004)(33026002)(386003)(6116002)(55016002)(81156014)(86362001)(16526018)(50466002)(48376002)(69596002)(81166006)(50226002)(76176011)(53936002)(2950100002)(6916009)(59450400001)(7696005)(105586002)(36756003)(68736007)(4720700003)(25786009)(5660300001)(106356001)(305945005)(47776003)(52116002)(2906002)(4326008)(7736002)(478600001)(66066001)(6666003)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3799; 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; AM6PR0502MB3799; 23:0Ni3hRsiQ2mZcCZ3DVFkHIwtjQL8ofxpBUhaTnT?= =?us-ascii?Q?n594TB38dulhDMnkYvYj2Rhy9szgkUU6RKX/PFdGOQMa+dDq48KNktxP7Z5S?= =?us-ascii?Q?dZ5oNlclFLUZ+K2BMu5WPgfOwYnpc8ibwbb/Omw0H3BW9gtBj6DaZFHXl/Rs?= =?us-ascii?Q?xmASXklOmxMvcD2wnEhJC94fHbzYnb32BN5q9FY3QSX0qFkz1Gm5Fdu/A6NE?= =?us-ascii?Q?hD+rcByTmqz6mAalT/ENtxLY9SpIWYmYLJFk4KlojRUzBdUyiWXODb/PoEyp?= =?us-ascii?Q?55h1dALaV0Mohv+HROMGkgVLS5XotzXuEangK8O4dzuYEFzVNpw+Fn6B9bMR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g: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2018 14:48:21.4873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a14e77fc-57ac-458b-022d-08d5577007e2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3799 Subject: [dpdk-dev] [PATCH v3 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: Tue, 09 Jan 2018 14:48:24 -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 301f9b6..0897c3d 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -29,13 +29,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}" @@ -44,7 +47,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__,))) @@ -595,6 +598,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); @@ -604,6 +608,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; @@ -617,10 +622,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, @@ -684,7 +696,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) @@ -693,3 +706,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