From patchwork Fri Oct 5 11:06:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 46120 X-Patchwork-Delegate: shahafs@mellanox.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BFF272C36; Fri, 5 Oct 2018 13:06:52 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20072.outbound.protection.outlook.com [40.107.2.72]) by dpdk.org (Postfix) with ESMTP id B110C2BD3 for ; Fri, 5 Oct 2018 13:06:51 +0200 (CEST) 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:X-MS-Exchange-SenderADCheck; bh=f4FFdz86RMO7r8OgEDZmogmv24OGd6Tm1xSZq0SJQzU=; b=wbLNRfkneO9YmcOB9VKVSQuuf6SkloTqSBhgyPJuVGQM8Y7tNRuabsKTXwHRa3ApNQD0xWr2wkohf7vHYtPIsJIwYQDznjBzGKeT/SjjmE0/Yj4dKnHF44LVGmTBdGPaxiuhtUQYeorYMdTudVMDaqW+1pPDJUjLmU+nskpLb2A= Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com (52.134.8.154) by VI1PR0502MB3806.eurprd05.prod.outlook.com (52.134.9.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.22; Fri, 5 Oct 2018 11:06:49 +0000 Received: from VI1PR0502MB3743.eurprd05.prod.outlook.com ([fe80::e48b:53fa:f268:753]) by VI1PR0502MB3743.eurprd05.prod.outlook.com ([fe80::e48b:53fa:f268:753%2]) with mapi id 15.20.1207.024; Fri, 5 Oct 2018 11:06:49 +0000 From: Ophir Munk To: "dev@dpdk.org" , Yongseok Koh CC: Asaf Penso , Shahaf Shuler , Thomas Monjalon , Olga Shern , Ophir Munk Thread-Topic: [PATCH v2] net/mlx5: allow multiple probing for representor Thread-Index: AQHUXJuDE/vRm8qkxkeUUkPJFV7rMw== Date: Fri, 5 Oct 2018 11:06:49 +0000 Message-ID: <1538737591-24022-1-git-send-email-ophirmu@mellanox.com> References: <1538553677-32010-1-git-send-email-ophirmu@mellanox.com> In-Reply-To: <1538553677-32010-1-git-send-email-ophirmu@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0018.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::31) To VI1PR0502MB3743.eurprd05.prod.outlook.com (2603:10a6:803:11::26) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0502MB3806; 6:D8DBW1AKMQCbDSRINWX+CSQ3ZyRA8s3u0ZJdHiJE9OX3Efuhqd86CsJ5wpsiCFZXapqicKcveTLmwLomLbaw7FE7P7o+FnWzY7p6y+sdo+kg+JUZWsBuB4B3px6oSkh7jYT1WfOgFTHKCdhFeUMlZLtDYIG2i140FY28HNmO/QeI7eizsJ32pqP9m5xSt3YyYwofZ8zcABBonPqOuacKL47fc7rGF0hz8+2+BU9vb1mzGoBaW3JCKb5MeJO8LdTVmzbc1Prg3Vq2L+u427CUcI/3JcjKN12fdyno+BZC/pEKg89vviaQtLnSRq8nT5hji4zpkW8tXQSqDDHH9FYho2qdr/6HNu89vM52zUU44uC2EAlzpHmJpxkDKQBz5V5acQUiYi803lsh2BBYe9vqVfHUBcCaoi721dXhwoJZky/mGubqPFBg2M0VmhC3V81hkk7lQEP4lWSl1Xa5IZJ9gA==; 5:hpfD/WfVlRyfrSrvoCxIHH16k+qwQQMtqSCOkrbdYuXeCNgAh9OpsNwgKAEW4ewNwrslaUYEOyzIcmf8OrS2yiHVj7UnCvmsvC6/8wHDj12ZVP1naCW2bB+WDpLF86Bzzqdlo2SUXe/WVUO6DbeTzAn+AsgBzr9rbr8k8OaoJrg=; 7:99Rx2dsA6EVIM1lqko5berQT8qqvsjeegwYBfaFtWatd+K/0w4NnEdg0lcPbi6cTJuE8OPeP1rrXQCPZPqsE+VN4ffAmOP6TNQB6zRljFl+rhoiBzLXO7p4l60xZoXwAOHiZYX8qTcIFFAv09S0kxjKOeV4281N8qx2WKjVrnzCOW2lIrss/OEoJ4hF1b9GtIvxF+cROzLzw7bGr6bkHGR38xtQx7I25MOJJVvVz0eoEabUqMDGeJS4xXgqUDYHR x-ms-office365-filtering-correlation-id: 8b1e47ac-07e9-47ea-e728-08d62ab2a577 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0502MB3806; x-ms-traffictypediagnostic: VI1PR0502MB3806: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231355)(944501410)(52105095)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051); SRVR:VI1PR0502MB3806; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB3806; x-forefront-prvs: 0816F1D86E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(396003)(346002)(366004)(39860400002)(199004)(189003)(97736004)(99286004)(106356001)(6506007)(52116002)(2900100001)(76176011)(6512007)(6306002)(4326008)(386003)(36756003)(6636002)(110136005)(107886003)(6436002)(305945005)(54906003)(7736002)(316002)(53936002)(105586002)(6486002)(5660300001)(25786009)(8676002)(81166006)(81156014)(68736007)(8936002)(478600001)(3846002)(11346002)(446003)(2616005)(476003)(66066001)(186003)(6116002)(14454004)(26005)(486006)(2906002)(102836004)(5250100002)(966005)(5024004)(2501003)(86362001)(14444005)(71190400001)(71200400001)(256004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3806; H:VI1PR0502MB3743.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: l1RgELisZzUR6Vf8UwTpcnBnSErwkANfMfVx4amxmyENoivn4wUD9CZKopGoDAOZTZaRNoo+oqk5fCaqM/RU9QFRP1vKNdGZNPWqY+ZYCoUrYxGAco2xVG8k5H+azfQZjvOA5rB6UrpNemDhov0K2Jlm13t66/cT2IQIHcAOckoLO/ZRjVdYNeQNs0FdzUZMUXbljVt8fPb/lu0c2i74XhWS4NCLOeZZaijIW9xNMwQ4/0V2LEQSNTjv9op1RKMV+Kz28Xy2UOl+SG90x/OUPi/C/v8CsG8nO7SN1dxRbm0bFWUMKOdw4DkvFslNVMk3ubK0KMCBJ1mXDNa555+9CHr1r/Yw+LAafSw/7+aKKSI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b1e47ac-07e9-47ea-e728-08d62ab2a577 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Oct 2018 11:06:49.2450 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3806 Subject: [dpdk-dev] [PATCH v2] net/mlx5: allow multiple probing for representor 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Implement probing of a device multiple times, see [1]. Consecutive probing requests with a devargs string may contain repetitive master and representors devices for which eth device should be created. If an eth device already exists - silently ignore it. [1] https://patches.dpdk.org/patch/45601/ ("eal: allow probing a device again") Signed-off-by: Ophir Munk Acked-by: Yongseok Koh --- v1: Initial release v2: Rebase + code review updates https://patches.dpdk.org/patch/45927/ drivers/net/mlx5/mlx5.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 9131290..a5a9eca 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -693,9 +693,10 @@ * * @return * A valid Ethernet device object on success, NULL otherwise and rte_errno - * is set. The following error is defined: + * is set. The following errors are defined: * * EBUSY: device is not supposed to be spawned. + * EEXIST: device is already spawned */ static struct rte_eth_dev * mlx5_dev_spawn(struct rte_device *dpdk_dev, @@ -744,6 +745,7 @@ struct ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id = 0; + uint16_t port_id; unsigned int i; /* Determine if this port representor is supposed to be spawned. */ @@ -766,6 +768,17 @@ return NULL; } } + /* Build device name. */ + if (!switch_info->representor) + rte_strlcpy(name, dpdk_dev->name, sizeof(name)); + else + snprintf(name, sizeof(name), "%s_representor_%u", + dpdk_dev->name, switch_info->port_name); + /* check if the device is already spawned */ + if (rte_eth_dev_get_port_by_name(name, &port_id) == 0) { + rte_errno = EEXIST; + return NULL; + } /* Prepare shared data between primary and secondary process. */ mlx5_prepare_shared_data(); errno = 0; @@ -872,11 +885,6 @@ DEBUG("ibv_query_device_ex() failed"); goto error; } - if (!switch_info->representor) - rte_strlcpy(name, dpdk_dev->name, sizeof(name)); - else - snprintf(name, sizeof(name), "%s_representor_%u", - dpdk_dev->name, switch_info->port_name); DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { eth_dev = rte_eth_dev_attach_secondary(name); @@ -1306,9 +1314,6 @@ struct mlx5_dev_spawn_data { assert(pci_drv == &mlx5_driver); errno = 0; - if (rte_dev_is_probed(&pci_dev->device)) - return -EEXIST; - ibv_list = mlx5_glue->get_device_list(&ret); if (!ibv_list) { rte_errno = errno ? errno : ENOSYS; @@ -1418,9 +1423,9 @@ struct mlx5_dev_spawn_data { list[i].eth_dev = mlx5_dev_spawn (&pci_dev->device, list[i].ibv_dev, vf, &list[i].info); if (!list[i].eth_dev) { - if (rte_errno != EBUSY) + if (rte_errno != EBUSY && rte_errno != EEXIST) break; - /* Device is disabled, ignore it. */ + /* Device is disabled or already spawned. Ignore it. */ continue; } restore = list[i].eth_dev->data->dev_flags;