From patchwork Tue Oct 23 18:26:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 47262 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 0CD4A1B113; Tue, 23 Oct 2018 20:26:06 +0200 (CEST) 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 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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_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, @@ -745,6 +746,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. */ @@ -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) == 0) { + rte_errno = EEXIST; + return NULL; + } /* Prepare shared data between primary and secondary process. */ mlx5_prepare_shared_data(); errno = 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() == RTE_PROC_SECONDARY) { eth_dev = rte_eth_dev_attach_secondary(name); @@ -1421,9 +1429,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; @@ -1518,7 +1526,8 @@ struct mlx5_dev_spawn_data { }, .id_table = mlx5_pci_id_map, .probe = mlx5_pci_probe, - .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV, + .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV | + RTE_PCI_DRV_PROBE_AGAIN, }; #ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS From patchwork Tue Oct 23 18:26:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 47263 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 55E111B146; Tue, 23 Oct 2018 20:26:13 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0045.outbound.protection.outlook.com [104.47.0.45]) by dpdk.org (Postfix) with ESMTP id C32C01B104 for ; Tue, 23 Oct 2018 20:26:05 +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=dL4yL07zFi7CjwrHX/Jyw3z8u3A+tQlcd+DKfJ7nDE0=; b=IeJ/o2ggBaqb9RvdhEtmXPQpG2nw3hHVy658KQEaRZppGYNutChuyqb2lRxm6zb+Owv5YgPPAUozrSQwzj+r882EDPFLRQ3QjwSUNwEoVV5Atck71A2OAbYDjXUG6nzevdbmKEOglrk6r9Iq1KDQLTwCUd7JudH19UTrm320VuA= 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:04 +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:04 +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 2/3] net/mlx5: release port on close Thread-Index: AQHUav3bt3C3Mjr3p0aMHUCrCnJsEA== Date: Tue, 23 Oct 2018 18:26:04 +0000 Message-ID: <1540319157-11191-2-git-send-email-ophirmu@mellanox.com> References: <1539936770-24252-1-git-send-email-ophirmu@mellanox.com> <1540319157-11191-1-git-send-email-ophirmu@mellanox.com> In-Reply-To: <1540319157-11191-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:xCg2pRsr5oypo3xdj9I2uba2Zi4Ky9XNiHKld/81vO2tU8X8IkLkl1GtgGBJ638P0OeJ87XoFWEmb+GFL6s0Wxu8d611kKLuQGDmlfudgVyqmdVZ+jbCa6Rqr1L5lrDWI99pjTQQwBevp5ixSeANKgDpuzffz4OMnri6G4360cu4i9lWCRIxEXhT0obEfyl//hMnSqTu74kJk8RgTeLiYvZ5bnLHYnw7YcpMGbDlNImDg/lqoF602iCJxbJ8p7RqkeOH70yCiGUYuEbgG1ngdlOpUq88mMGb7KmWEh2/cUSsBHtL4t+d7ogwsmVKYEvZMxJGfy0kxm3lDJQfJYQ79dxgMuJ3/BLCNUvMwgbxSTH5eJBo2SL2MVcK8xlq9wNkmIYT6VPT7n5iFI4NbvC38yrTfsF68jG3jEnElOmemIxy9ohm6ffbwgCzgcuRDH92EnN8IGaOo1McBTC430UEyA==; 5:SGCKBBXOesRtswMD4pv5WaGfL12ISTa/NYyeYv/3VXwts+G/lftRymuxKrg1qIpqAHJv4//7K/zbwirTBTNPOlcG11CAJXUupIVwgqoOisYE95zhZ56fJpHct1tdRdMKUcKkLIzbvCZMXRYmYD04sf923bBzWLePSLyF4wx5k8Y=; 7:UAIAiWxwYISbeFjOckoJckJMbLPY56SFzuF6I59LhtuqFtnwajhuSg+Y2Mei96nIHNwqw5sVyqnDrqjSouUlNgc3HbjgRHxKBdsspenQEDO2F3K+3ROhomx2rHoFTQS3pnh4O5bycd6FhDmYcB00wA== x-ms-office365-filtering-correlation-id: 207a9e1b-04a2-431e-ab84-08d63914fde5 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:(269456686620040); 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)(81156014)(86362001)(5250100002)(11346002)(446003)(2616005)(476003)(25786009)(8936002)(2900100001)(110136005)(7049001)(54906003)(66066001)(97736004)(107886003)(68736007)(4326008)(71190400001)(71200400001)(8676002)(478600001)(14444005)(256004)(81166006)(486006)(53936002)(76176011)(186003)(3846002)(99286004)(5660300001)(6116002)(6506007)(6436002)(105586002)(2906002)(106356001)(14454004)(305945005)(7736002)(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: vdiNyoKZoe0/hG0BnssDPCuhMgbKCW8armmO/NnM2vNY9GRShXe4tzNrVnwRtEuQPmWCoYKsIU2629h8mif4+srpGyDGcL4HlVQTAbphxAs4NLXIFNOEQBOxpzSQsTyI9hnG26QXUC1WYoipku6Fnva4S0Mzu8cZci2AOB1l6jgqCOZDsF7ZWeIlgLaQVMT/yEZa6BbQffcXq17AyEljhMeoMCKecn3tspbYEa6z6tEbXRQNDfQckoK1XVy0DV+8YqCJKfDsl7A19/OpUuQRAuRGQhBqmdEg04nnPSmDVwBuDAQrfh3qcRTWGtpm582ZKO8l6nYFYdf4tio5A67TTDkK58eBnIjOfQIIx5/0Smw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 207a9e1b-04a2-431e-ab84-08d63914fde5 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 18:26:04.5695 (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 2/3] net/mlx5: release port on close 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" With the introduction of representors several eth devices are using the same rte device (e.g. a PCI bus). It is therefore required to release the eth device resources during an eth device close operation rather than during an rte device removal (detach) operation. In current version many PMDs are still releasing the eth device as part of the rte device removal. In order to allow a smooth transition for all PMDs to behave correctly an ethdev flag RTE_ETH_DEV_CLOSE_REMOVE is used. When this flag is set it indicates to rte_eth_dev_close() to call rte_eth_dev_release_port(), so the port is freed during the close operation. Signed-off-by: Ophir Munk --- v1-v3 This patch was not part of the serie v4: Initial version drivers/net/mlx5/mlx5.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 93b4057..7a8b45a 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -337,6 +337,17 @@ } memset(priv, 0, sizeof(*priv)); priv->domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID; + /* + * flag to rte_eth_dev_close() that it should release the port resources + * (calling rte_eth_dev_release_port()) in addition to closing it. + */ + dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + /* + * Reset mac_addrs to NULL such that it is not freed as part of + * rte_eth_dev_release_port(). mac_addrs is part of dev_private so + * it is freed when dev_private is freed. + */ + dev->data->mac_addrs = NULL; } const struct eth_dev_ops mlx5_dev_ops = { From patchwork Tue Oct 23 18:26:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 47264 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 BE2871B1F2; Tue, 23 Oct 2018 20:26:15 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0063.outbound.protection.outlook.com [104.47.0.63]) by dpdk.org (Postfix) with ESMTP id F14C71B122 for ; Tue, 23 Oct 2018 20:26:06 +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=wQiLtTme2Yc0fErDI3WMmNp4pBIu0XIu7Suf/Glh+5A=; b=Y3UnZ95pViFrVB6/96qkZISNsFWBbVqUxkKtazydwVgcRnUTtWmUjWHBdTDKji8P33No/FByUrrADLLh3oXgHX9/+0l2/fBtsEEKMjD8vLnA5Thpr0ICZIIyYSA9GUqBN5jHrc2HOSrYjqKqkc2OCK7YZuz7OC7fMZftbmB6zQs= 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:05 +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:05 +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 3/3] net/mlx5: close all ports on remove Thread-Index: AQHUav3cJq1CQ8aGDU20yHd6qNxMBQ== Date: Tue, 23 Oct 2018 18:26:05 +0000 Message-ID: <1540319157-11191-3-git-send-email-ophirmu@mellanox.com> References: <1539936770-24252-1-git-send-email-ophirmu@mellanox.com> <1540319157-11191-1-git-send-email-ophirmu@mellanox.com> In-Reply-To: <1540319157-11191-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:5a2eRUBNFCJEf9djFwAyAWXIFfbHHEOPnm5ENfDviKBaNjFuZDBPhj1Vy9rMmbZb7HYvcmvFR2vf5OScrR/ydoSIVbUWfvxjk88JeSAXcMm8dgMPN5dYae9FMgFo91PZMSUFEkHwrSfr4RnBaW5X7ZLnvhkQHMNEa+4KjU59WMfE8NQnQ08ote+yj8Ijt73gsmqZ3IpOv1XucxzEP7C/vzKS8RyGT7IdTXuL8bDmoyOpqDrOYoi5g4F50ssrM2T2H2r6fx0pIQvDLLYUm6NhS6hwbi6qSaifr0uDqoTDFQNLynCJWOYCbkyTfvA4iugbVnH3Z+JAoGRerGlXLoFTZEYrAgzzVL8UI3jdQ0sGpSmViyB4osgdy/N4P419Mu2Pn/IKXa8TQ95zM7luoenjR/9O1sQhnX/VLtFyEPRwSF7LZHGEBK6L9RpERGa2MK7um9K+sqCrCZya8BSU2y3uTw==; 5:/embR07z+X3TpNxlveyZOezbWOsqxsrZyi5fKBuB7qFaCf8ozoCXVBrzj5a9qN9rSQZQV8q1aV3QY4SXgvPhMBR1Uy4X/I9TwfJo1nLEZoyqmNHc+dZt6nzIh9iGT9xZxh2U2mavYH4ST0N4x95JGBmIsx/KUat6tiyySyxxsdE=; 7:nTddUKLKq/OpEGidTtmrSauAorML7YJLZywxsvimRpIToT49WFvK+Y6rsuAjnCHwfUjIdbSaKA2HiMowQs6fEupeBSIGbaENZj6+3gcxUgszhQoD7mIJRBuisOEQ0OLivdDzLe2uqaQmSmyAxyKkRg== x-ms-office365-filtering-correlation-id: 8ea9d4f8-6ae6-4ae9-05b7-08d63914fea2 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)(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)(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: UdUK5r1AOlhpddwk8cZTfDS2JJ06X1Kg1RFojNWU8TeQAB59DTZjvqVbHJF+31quxfib/kb5E6LoBLhmPmn+JhscDbpQedrlrvv9w3Oyh48WvKyP8p+7fPZ1u0dIkgPuRUAx3+UXCc/9j62/uiebSdxRqMa6eifVuMUD48W7tCiYQlXpEhLVNRt/jG7CCuapZ9zT9sI7fWIFC+NMlDV1yNdMywxNA/Uo6NnAPlj93AtxzPOV7a/YPgDRIeRxVMAPzX1I4Oyjn0lQCefKnq7MLpvUeGEIFSJMgMhyyqdOKtQ4NjmCo3MA/C5ik30lIeA9i9hUS/8E2gLuwdOT8nZREIiB7rZ3zIrvibBmac2Ve+Q= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea9d4f8-6ae6-4ae9-05b7-08d63914fea2 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 18:26:05.7414 (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 3/3] net/mlx5: close all ports on remove 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" With the introduction of representors several eth devices are using the same rte device (e.g. a PCI bus). When calling port detach on one eth device it is required that all eth devices belonging to the same rte device have been closed in advance, then the rte device itself can be removed/detached. This commit implements this requirement implicitly by adding a remove callback to struct rte_pci_driver. The new behavior can be demonstrated in testpmd. First we attach a representor 0 using PCI address 0000:08:00.0 testpmd> port attach 0000:08:00.0,representor=[0] Attaching a new port... EAL: PCI device 0000:08:00.0 on NUMA socket 0 EAL: probe driver: 15b3:1013 net_mlx5 Port 0 is attached. Done Port 1 is attached. Done Port 0 is the master device (PF) - an ethdev of the PCI address. Port 1 is representor 0 - another ethdev (representing a VF) using the same PCI address. Next we detach port 1 testpmd> port detach 1 Removing a device... Port 0 is closed Port 1 is closed Now total ports is 0 Done Since port 0 has been implicitly closed we cannot act on it anymore. testpmd> port stop 0 Invalid port 0 Signed-off-by: Ophir Munk --- v1-v3 This patch was not part of the serie v4: Initial version drivers/net/mlx5/mlx5.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 7a8b45a..9f7a099 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1485,6 +1485,22 @@ struct mlx5_dev_spawn_data { return ret; } +static int +mlx5_pci_remove(struct rte_pci_device *pci_dev) +{ + uint16_t port_id; + struct rte_eth_dev *port; + + for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) { + port = &rte_eth_devices[port_id]; + if (port->state != RTE_ETH_DEV_UNUSED && + port->device == &pci_dev->device) + rte_eth_dev_close(port_id); + } + + return 0; +} + static const struct rte_pci_id mlx5_pci_id_map[] = { { RTE_PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, @@ -1537,6 +1553,7 @@ struct mlx5_dev_spawn_data { }, .id_table = mlx5_pci_id_map, .probe = mlx5_pci_probe, + .remove = mlx5_pci_remove, .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV | RTE_PCI_DRV_PROBE_AGAIN, };