From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0043.outbound.protection.outlook.com [104.47.0.43]) by dpdk.org (Postfix) with ESMTP id F0B1C1B309 for ; Thu, 18 Jan 2018 14:52:10 +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=Hvoq33Ozl54UAGG5e3MrWMOy32HuJfnjOYfPVm5Yaa5c4BBQwBbU3SozuADgMKav3bK8HY1juBpfwRyZo8oOphcZp1j3N0Azuo2TI5S8WUe9LaGMOtjN0zN4YzAyPm2sdmvYDXmQ57H6FN8NWNvQeHag82xSE4UgmwCHkg+Ca5E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM6PR0502MB3798.eurprd05.prod.outlook.com (2603:10a6:209:a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Thu, 18 Jan 2018 13:52:07 +0000 From: Matan Azrad To: Ferruh Yigit , Adrien Mazarguil , Gaetan Rivet Cc: Thomas Monjalon , dev@dpdk.org Date: Thu, 18 Jan 2018 13:51:46 +0000 Message-Id: <1516283506-21198-9-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516283506-21198-1-git-send-email-matan@mellanox.com> References: <1516269709-15252-1-git-send-email-matan@mellanox.com> <1516283506-21198-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR08CA0115.eurprd08.prod.outlook.com (2603:10a6:800:d4::17) To AM6PR0502MB3798.eurprd05.prod.outlook.com (2603:10a6:209:a::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7ce3eefc-8217-40d8-a1c5-08d55e7aaa82 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM6PR0502MB3798; X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3798; 3:A7vbnmiZhT9Z6phgmmipeODRfiwmcOKA57IaTNN5+hVYm5QerEOAmNNciFUzstnZpGr+iN1toKXdsxNhR9nh0QqgkTxAtH+W25gIJGGKmYkY+NGs+lKDmurM/lgVm8lGj+UZB0sDo7wW2KbOd9CIbdDWQb5euEkCu7z5xgy05ZmmPONTpeB6FSUzNVIMI0doI8L7J7iXT2u83pPpF/JFSwd8tD/CHENtKRuC0PQfQ8g/9Txi25hT38rp0NwVXZRh; 25:Q8+u8pXUWLYvhBFXgvTbWmdLO7u4xuW3Lh3jc7POH5pPpNbAG4zUp4Q6AbXnrncRmuP6mw2eKfgSgjZ4YO5XOlid2g4DSYlFUNBQzHHlVoFCAaKWT6MrwPiH/HKuyXdqz1ra5RLdvjYX1y0cAelt/IxXAyhNndyBC8sBQRaNzW/bkLYQgRAIMU2hrBvvIuEpKkR78FiEq0kENHDbO7qqNSgSsFkDz7eHsQuX4hF44bFrscIK8DOzi+b3aZ3tQWkp26WsUb0S8xmKQmH41eRvHg97QRasZW9AHz2IAN33i6nv9m/oUKjLxeOc1fG2kKQXhYyBbSSDhRCrfOaBk3ydKQ==; 31:v80+EvwsXhm8UVI2rZKf/eVSGNWbOnTr2XQjj0Fw//NgaiMQywe9YTC0FQRBcwobZgAzfpHQOTOFQenO67tZJtdaZ8CNB0xE2Pub01bIsD0yFxyahAoy/9aik38WickfjO9IE+6NCcCbF9v4mXumtcYTPKe0w0lH2Cf8tL/7cNztLi9rubPxrIw6493dj8lpikz0CR0CbyWHQw5i9e2iwWeZy60pUk4shVhwoZZAI0Y= X-MS-TrafficTypeDiagnostic: AM6PR0502MB3798: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR0502MB3798; 20:aL7Y2PacTp9wjy7BJj1zwk4qr1GDx1G2RpJ37unluQZyd8P30+1TRSmblXDFKpNzmJS+uQ1vwIwIZyMxrQRmTOfTYefr7tAfof4KBNqlsZxnMqZuvDYmHNA6As3TnHY4koOd5dNZ6IjKkCjN/waAPg4A+uTRpIz8eMgLU1ZWbmvdS3rPrnQMfsvzsZaczFMQT+16/rqgIEeILiafFXRrKy+iYSgk/9nvRw6mFw5LFaGVc2n/3dsVLohjx2aLSZUs6A55UmpbJavu5DsxXlrynu5x4kAfh9lz/cHHAtSPAlsm+d7ilRftkgWgXuSD06IE9T7Usb85wEweDTFfvV6KXO3d8Lq1PaYRf5Zcnc/owSi6O73QnhwPNfxO2hTnFQzZcquDWGs1spg2Kj9yVmYQvuMDqNwQR68Y8n4EtPJUW+6e5GlePsw6DGXGI1ZyY2nNgS3RZ8vNRqBiAN9cXtt88V13Ft2FJuUC8ybR0afhJapeY+0Amr681qwMaucHrd5s; 4:XT/RnOP9g51LkObvJvspD0qtwtCxaVztr+O0g5DntMYZaNfgrKS2fYCbtGILc3Vv8j0Yzesf/IPMx3PtoGQihyVRfUp0c/TiWQeM0ZFb2jvo7RCLnnx6iM1+y3ziSEwM1WWB3mvQ+ETPbtpEG8MzWWiq97qAFt8DzgdfRBNEP3pXTtdi8xeHk6Je79++2fpAWZhab0KupaGrweS/UGrEDHKiXn4K2VvQs/xxI93olw/z8AUfS2oR38mmsFyPo72dKRFKPMeaziWtvNJpGcPUhthADt996uER4uVmZo1Ok4T131qx678isarLvgdHS647 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)(3002001)(10201501046)(3231023)(944501161)(93006095)(93001095)(6055026)(6041268)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:AM6PR0502MB3798; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0502MB3798; X-Forefront-PRVS: 05568D1FF7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(346002)(39380400002)(39860400002)(376002)(199004)(189003)(386003)(2906002)(51416003)(81156014)(81166006)(5660300001)(305945005)(4326008)(21086003)(7696005)(106356001)(8676002)(68736007)(26005)(69596002)(76176011)(59450400001)(105586002)(86362001)(97736004)(3846002)(6116002)(575784001)(52116002)(53936002)(6666003)(50226002)(55016002)(4720700003)(33026002)(7736002)(2950100002)(36756003)(47776003)(478600001)(16526018)(8936002)(66066001)(316002)(110136005)(48376002)(50466002)(16586007)(5890100001)(25786009)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3798; 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; AM6PR0502MB3798; 23:co4i18jONgoWKTwOf9Xk7JTeLSU7VqPLljXr6+F?= =?us-ascii?Q?DUAskC2wAWB13Ri8nKrtdqZznVN5pn1dCCkPiBF6mcvBIyE+8v17TFrLNhIC?= =?us-ascii?Q?Oq3mjcUTh0lBLlB3DqF01TnleRAqgJJmhD2Y/COMR42U2q0DgAzLI7qzUqoO?= =?us-ascii?Q?KLVbJoqkqD43OSgztISR4eYgSN/Yaa2eKmPLyIcEAJQfFf3hs4SmhRvwslqg?= =?us-ascii?Q?+k84QBWOri4x3mcnagYBOE6U8A+tPyoprUAoKwKSWBWdllBXnoLiiL1KM7O9?= =?us-ascii?Q?fiZfvFt+6DINhY6MYocq/J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 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 13:52:07.5158 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ce3eefc-8217-40d8-a1c5-08d55e7aaa82 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3798 Subject: [dpdk-dev] [PATCH v6 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 13:52:11 -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