From patchwork Wed Jul 3 07:58:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liron Himi X-Patchwork-Id: 55926 X-Patchwork-Delegate: jerinj@marvell.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 ED5954CE4; Wed, 3 Jul 2019 07:47:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id DB44B1E20 for ; Wed, 3 Jul 2019 07:47:28 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x635jNFM010638 for ; Tue, 2 Jul 2019 22:47:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0818; bh=huoIKKSKSyHeRd/dxd3PKydZN9XTDEOCaqnjLUSBfW0=; b=urk3a7yhYykCw1YfV28pDtXizWNZETxiBozcQq6l+e7OOa64NwAv1GnWGcAkIEe2Q5qr D12o1+1DD/ylQF+t/TgZ5E/Xr0wbhTea+5CeFoFDHFWxwsWqI5V4PiMG7qHigeRGAp9K W1e41B7XZlVGdYZdj12NOpLjIFNVS0e99HOg45kZRPeQdUXPwPyEFSZkMIo5XKyqUnXM eB8FM6xtZiNX1VdBvCr0mtvmwiv/88yBc5sVustuJ1Q6nCce8UYHWbTNjPu9Wa1EYkB6 mekObpw4SRqKcwk1hzx7ehLEvdncd75fSvlZTnw7iZNrJEMfyFG+MfUAA8wViZDrCikY dQ== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2tg5734137-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 02 Jul 2019 22:47:28 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 2 Jul 2019 22:47:26 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 2 Jul 2019 22:47:26 -0700 Received: from pt-lxl0023.marvell.com (unknown [10.5.213.12]) by maili.marvell.com (Postfix) with ESMTP id 3B2963F70D8; Tue, 2 Jul 2019 22:45:56 -0700 (PDT) From: To: CC: , , yuric Date: Wed, 3 Jul 2019 10:58:12 +0300 Message-ID: <1562140692-309-1-git-send-email-lironh@marvell.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-03_02:, , signatures=0 Subject: [dpdk-dev] [PATCH] net/mvneta: remove resources when port is closed 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" From: yuric Since 18.11, it is suggested that driver should release all its private resources at the dev_close routine. So all resources previously released in remove routine are now released at the dev_close routine, and the dev_close routine will be called in driver remove routine in order to support removing a device without closing its ports. Above behavior changes are supported by setting RTE_ETH_DEV_CLOSE_REMOVE flag during probe stage. Signed-off-by: yuric Reviewed-by: Liron Himi --- drivers/net/mvneta/mvneta_ethdev.c | 46 +++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c index d46a13b..a8def8f 100644 --- a/drivers/net/mvneta/mvneta_ethdev.c +++ b/drivers/net/mvneta/mvneta_ethdev.c @@ -49,6 +49,8 @@ struct mvneta_ifnames { static int mvneta_dev_num; static void mvneta_stats_reset(struct rte_eth_dev *dev); +static int rte_pmd_mvneta_remove(struct rte_vdev_device *vdev); + /** * Deinitialize packet processor. @@ -445,6 +447,14 @@ mvneta_dev_close(struct rte_eth_dev *dev) mvneta_tx_queue_release(dev->data->tx_queues[i]); dev->data->tx_queues[i] = NULL; } + + mvneta_dev_num--; + + if (mvneta_dev_num == 0) { + MVNETA_LOG(INFO, "Perform MUSDK deinit"); + mvneta_neta_deinit(); + rte_mvep_deinit(MVEP_MOD_T_NETA); + } } /** @@ -808,6 +818,9 @@ mvneta_eth_dev_create(struct rte_vdev_device *vdev, const char *name) mvneta_set_tx_function(eth_dev); eth_dev->dev_ops = &mvneta_ops; + /* Flag to call rte_eth_dev_release_port() in rte_eth_dev_close(). */ + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + rte_eth_dev_probing_finish(eth_dev); return 0; out_free: @@ -906,20 +919,16 @@ rte_pmd_mvneta_probe(struct rte_vdev_device *vdev) ret = mvneta_eth_dev_create(vdev, ifnames.names[i]); if (ret) goto out_cleanup; + + mvneta_dev_num++; } - mvneta_dev_num += ifnum; rte_kvargs_free(kvlist); return 0; out_cleanup: - for (; i > 0; i--) - mvneta_eth_dev_destroy_name(ifnames.names[i]); + rte_pmd_mvneta_remove(vdev); - if (mvneta_dev_num == 0) { - mvneta_neta_deinit(); - rte_mvep_deinit(MVEP_MOD_T_NETA); - } out_free_kvlist: rte_kvargs_free(kvlist); @@ -938,27 +947,12 @@ rte_pmd_mvneta_probe(struct rte_vdev_device *vdev) static int rte_pmd_mvneta_remove(struct rte_vdev_device *vdev) { - int i; - const char *name; - - name = rte_vdev_device_name(vdev); - if (!name) - return -EINVAL; - - MVNETA_LOG(INFO, "Removing %s", name); + uint16_t port_id; - RTE_ETH_FOREACH_DEV(i) { - if (rte_eth_devices[i].device != &vdev->device) + RTE_ETH_FOREACH_DEV(port_id) { + if (rte_eth_devices[port_id].device != &vdev->device) continue; - - mvneta_eth_dev_destroy(&rte_eth_devices[i]); - mvneta_dev_num--; - } - - if (mvneta_dev_num == 0) { - MVNETA_LOG(INFO, "Perform MUSDK deinit"); - mvneta_neta_deinit(); - rte_mvep_deinit(MVEP_MOD_T_NETA); + rte_eth_dev_close(port_id); } return 0;