From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0059.outbound.protection.outlook.com [104.47.0.59]) by dpdk.org (Postfix) with ESMTP id B24B71B104 for ; Tue, 23 Oct 2018 20:26:04 +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=Kag5KP/LDzKuZ+wlkeLFTAcSsH21q2P8ThyO7ySpOlk=; b=fBM/qWDJFtZlG+IZ59ySGHPxlD16wewUJuhwtUvbb9X7IcwUIeEC1WK1JR5LXxuvfKxHJ/TXsyGN8SgBwdTfmj71z1jJD5IkIFGxJB5g/Z3JBR7QKFEiUjY7xdyGRxuS/DEWfnNbHrP1TBQ8SeS2Vi/vGbzCrrj5KuxFqXflkX0= Received: from AM6PR0502MB3735.eurprd05.prod.outlook.com (52.133.21.12) by AM6PR0502MB3624.eurprd05.prod.outlook.com (52.133.20.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.18; Tue, 23 Oct 2018 18:26:03 +0000 Received: from AM6PR0502MB3735.eurprd05.prod.outlook.com ([fe80::5416:c31f:6c60:b280]) by AM6PR0502MB3735.eurprd05.prod.outlook.com ([fe80::5416:c31f:6c60:b280%5]) with mapi id 15.20.1250.028; Tue, 23 Oct 2018 18:26:03 +0000 From: Ophir Munk To: "dev@dpdk.org" , Yongseok Koh , Ophir Munk CC: Thomas Monjalon , Olga Shern , Asaf Penso , Shahaf Shuler Thread-Topic: [PATCH v4 1/3] net/mlx5: allow multiple probing for representor Thread-Index: AQHUav3aWSm5q0mJpk2ekC0GSaloRA== Date: Tue, 23 Oct 2018 18:26:03 +0000 Message-ID: <1540319157-11191-1-git-send-email-ophirmu@mellanox.com> References: <1539936770-24252-1-git-send-email-ophirmu@mellanox.com> In-Reply-To: <1539936770-24252-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: LO2P265CA0388.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::16) To AM6PR0502MB3735.eurprd05.prod.outlook.com (2603:10a6:209:a::12) 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; AM6PR0502MB3624; 6:LkwTIOBRkkTDl+ten+Dp1yZbrX7vlj8z75RNMXA4aF8rkTsW6YvBw00u6chwDsSzn80SmXBRODaISWptgXv+na1Waz9mRIWvJ5X8yCnc/pSQ2bl71ddy6t99QV0hcpAyQySpmerqAnGbXfQk15dfpOGznz3FB5I0xztrOsp/fS1jiLNm8ge9XNrf98TI6j6hFozS0x4/JQ7N07D1LJzQxYp9qrJCAPkrAChTxotgd70JfqHi1Oq19hnRTm+6HdWVus1Re8EbctBS9qTj3TmJw12poDUgsuG7ybj3GhoOySGw2aa3OTmg2BB3lWrXLwOc3VxNdIu7//k3+pCDAPDPRsbjcMcs4+rmyAMNv7MN7xPqeDAKEeJezZerO/80j0TjHAAFR7TR/fNkmIc+qRKjfYCgrNhaAccoCbnkOQLQxNbi2INdf8RggDf5QXUzZsHojq4DKADWtDC5zHDJ7Ma85w==; 5:5FLZCj/8BsaA3sdQls72Js4m3X/3vDmJubI5yKdsiEb+y0014chxryA3kryynX+OUaf28xU4VDLVb0JM8y0fTFeUQCEseI5NkvYVVIxlqD8FPmFORygum8dPe8cWKPXiDlNJKXxBaKlkObZ/7Acw066z5nYdhkiFduTGhXIxMyI=; 7:Y5ktH570JhQEBxWJMQ8Tdyg5oskVTvT05ouhl/o4XA6Z3o0+T+Pa5KujN6nhFctDpqcAuQnA1XPBrm/U/L/ip8GNfdLlKGT45E23k5gYfLifQTJ1CQGgyaRCwVqSPMDQn4wPcY25M63oHWAZtnP1SA== x-ms-office365-filtering-correlation-id: cfa5d250-db05-4bd9-daae-08d63914fd32 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM6PR0502MB3624; x-ms-traffictypediagnostic: AM6PR0502MB3624: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM6PR0502MB3624; BCL:0; PCL:0; RULEID:; SRVR:AM6PR0502MB3624; x-forefront-prvs: 0834BAF534 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(396003)(346002)(366004)(39860400002)(199004)(189003)(2501003)(316002)(6512007)(6306002)(81156014)(86362001)(5250100002)(11346002)(446003)(2616005)(476003)(25786009)(8936002)(2900100001)(110136005)(7049001)(54906003)(66066001)(97736004)(107886003)(68736007)(4326008)(71190400001)(71200400001)(5024004)(8676002)(478600001)(14444005)(256004)(81166006)(486006)(53936002)(76176011)(186003)(3846002)(99286004)(5660300001)(6116002)(6506007)(6436002)(105586002)(2906002)(106356001)(14454004)(305945005)(7736002)(966005)(6486002)(26005)(52116002)(386003)(36756003)(102836004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0502MB3624; H:AM6PR0502MB3735.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: Kg5jhA9tXBUeJCt2tnp2tLsSWueZA1iOcv4siJkk4EHjm938L82dqZiSiVrvWPzQ+GfxI2/ZpT9uMOtMVCz3buk4rj9XYqxeXNG9KeSAOYVGdto+mtNfcGn+afcVJ2eXlaKkaTrgQuXD05F/0vKMJeWRT1f2WWJB+8UUGBJ+Y8u8W5gqqC3Cytb6xmbG9vej3gzv6QaKLSqNcGxB33t16NKcu3T0UXuV5p9KNOcrbiDbyVK5fcLJxQhTe/2VM/V/bHKELYbEmNbAdPzQRFcYBvXKUtYCPBGWMWlNZbpzkYFmRHoBrCsjLi119mhu1hpUrVjoyzQ921HfJIfRzR1xPIYRng1Wvv0RAZaY1W1vJuk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfa5d250-db05-4bd9-daae-08d63914fd32 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 18:26:03.3507 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0502MB3624 Subject: [dpdk-dev] [PATCH v4 1/3] 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: , X-List-Received-Date: Tue, 23 Oct 2018 18:26:05 -0000 Implement probing of a rte device multiple times, see [1]. Set PCI driver RTE_PCI_DRV_PROBE_AGAIN flag to enable multiple probing of the PCI device by the PCI common driver. Consecutive probing requests with a devargs string may contain repetitive master and representors devices for which eth device should be created only once. In case an eth device already exists - silently ignore it. [1] commit e9d159c3d534 ("eal: allow probing a device again") Signed-off-by: Ophir Munk --- v1: Initial release v2: Rebase + code review updates https://patches.dpdk.org/patch/45927/ v3: - Set PCI driver RTE_PCI_DRV_PROBE_AGAIN flag required by PCI common driver - Update commit message v4: Update commit message. Specify reference [1] as commit number drivers/net/mlx5/mlx5.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 297cbff..93b4057 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -694,9 +694,10 @@ * * @return * A valid Ethernet device object on success, NULL otherwise and rte_err= no - * 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, @@ -745,6 +746,7 @@ struct ether_addr mac; char name[RTE_ETH_NAME_MAX_LEN]; int own_domain_id =3D 0; + uint16_t port_id; unsigned int i; =20 /* Determine if this port representor is supposed to be spawned. */ @@ -767,6 +769,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) =3D=3D 0) { + rte_errno =3D EEXIST; + return NULL; + } /* Prepare shared data between primary and secondary process. */ mlx5_prepare_shared_data(); errno =3D 0; @@ -873,11 +886,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() =3D=3D RTE_PROC_SECONDARY) { eth_dev =3D rte_eth_dev_attach_secondary(name); @@ -1421,9 +1429,9 @@ struct mlx5_dev_spawn_data { list[i].eth_dev =3D mlx5_dev_spawn (&pci_dev->device, list[i].ibv_dev, vf, &list[i].info); if (!list[i].eth_dev) { - if (rte_errno !=3D EBUSY) + if (rte_errno !=3D EBUSY && rte_errno !=3D EEXIST) break; - /* Device is disabled, ignore it. */ + /* Device is disabled or already spawned. Ignore it. */ continue; } restore =3D list[i].eth_dev->data->dev_flags; @@ -1518,7 +1526,8 @@ struct mlx5_dev_spawn_data { }, .id_table =3D mlx5_pci_id_map, .probe =3D mlx5_pci_probe, - .drv_flags =3D RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV, + .drv_flags =3D RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV | + RTE_PCI_DRV_PROBE_AGAIN, }; =20 #ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS --=20 1.8.3.1