From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C5515A00E6 for ; Mon, 5 Aug 2019 10:03:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9B2FD1BACA; Mon, 5 Aug 2019 10:03:36 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 80F811B9D9 for ; Mon, 5 Aug 2019 10:03:35 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7580El5019229 for ; Mon, 5 Aug 2019 01:03:35 -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=lFs7m+/WWUGC0ShQbVhwGJ3xgqhSnllG3p33bHFTBPg=; b=Fqp2RK131J/pcftO6slI5KcqhI4T5Wi8JfixZLINm2NkaZ/7NVTg90GK2IFPgyKyDqXH xdzWIgfhUrwVPdKmhcyiKiHU7qFXt2UFvacRG4ijxO2RrVsCSaQDFeTlqaEAJ6+GEV8k LiuqTOv05Xj3xO+CF7rasHLC57dFMLwwXoJm6y/kxkYr3AbhpA3Pg5ZRFQheZGlm8y4t rgekN3VGRVdnMjAY1fKqGL18pDorvkrUBrI3FwJ8+Zr5OmlWLplrluFQhS7u76O9BjuB wzoxFQ7yUiDVa5XPhKbUcc9Mgh7s2PzmBNliVhFslxV/OZZ9ZzjLQ2eYyp6SO+d6Rx43 UQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2u59skne8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 05 Aug 2019 01:03:34 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 5 Aug 2019 01:03:33 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 5 Aug 2019 01:03:33 -0700 Received: from pt-lxl0023.marvell.com (pt-lxl0023.marvell.com [10.5.213.12]) by maili.marvell.com (Postfix) with ESMTP id 01F993F7041; Mon, 5 Aug 2019 01:03:31 -0700 (PDT) From: To: CC: , Date: Mon, 5 Aug 2019 13:16:56 +0300 Message-ID: <1565000216-9465-1-git-send-email-lironh@marvell.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-05_03:2019-07-31,2019-08-05 signatures=0 Subject: [dpdk-dev] [PATCH] net/mvpp2: 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: Liron Himi 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: Liron Himi Reviewed-by: Yuri Chipchev --- drivers/net/mvpp2/mrvl_ethdev.c | 79 +++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 50 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index d1d0d41..810a703 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -144,6 +144,9 @@ static uint16_t mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); static uint16_t mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +static int rte_pmd_mrvl_remove(struct rte_vdev_device *vdev); +static void mrvl_deinit_pp2(void); +static void mrvl_deinit_hifs(void); #define MRVL_XSTATS_TBL_ENTRY(name) { \ @@ -898,6 +901,22 @@ mrvl_dev_close(struct rte_eth_dev *dev) pp2_cls_plcr_deinit(priv->default_policer); priv->default_policer = NULL; } + + + if (priv->bpool) { + pp2_bpool_deinit(priv->bpool); + used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit); + priv->bpool = NULL; + } + + mrvl_dev_num--; + + if (mrvl_dev_num == 0) { + MRVL_LOG(INFO, "Perform MUSDK deinit"); + mrvl_deinit_hifs(); + mrvl_deinit_pp2(); + rte_mvep_deinit(MVEP_MOD_T_PP2); + } } /** @@ -2809,6 +2828,9 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) mrvl_set_tx_function(eth_dev); eth_dev->dev_ops = &mrvl_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: @@ -2818,28 +2840,6 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) } /** - * Cleanup previously created device representing Ethernet port. - * - * @param name - * Pointer to the port name. - */ -static void -mrvl_eth_dev_destroy(const char *name) -{ - struct rte_eth_dev *eth_dev; - struct mrvl_priv *priv; - - eth_dev = rte_eth_dev_allocated(name); - if (!eth_dev) - return; - - priv = eth_dev->data->dev_private; - pp2_bpool_deinit(priv->bpool); - used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit); - rte_eth_dev_release_port(eth_dev); -} - -/** * Callback used by rte_kvargs_process() during argument parsing. * * @param key @@ -2959,20 +2959,15 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev) ret = mrvl_eth_dev_create(vdev, ifnames.names[i]); if (ret) goto out_cleanup; + mrvl_dev_num++; } - mrvl_dev_num += ifnum; rte_kvargs_free(kvlist); return 0; out_cleanup: - for (; i > 0; i--) - mrvl_eth_dev_destroy(ifnames.names[i]); + rte_pmd_mrvl_remove(vdev); - if (mrvl_dev_num == 0) { - mrvl_deinit_pp2(); - rte_mvep_deinit(MVEP_MOD_T_PP2); - } out_free_kvlist: rte_kvargs_free(kvlist); @@ -2991,28 +2986,12 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev) static int rte_pmd_mrvl_remove(struct rte_vdev_device *vdev) { - int i; - const char *name; + uint16_t port_id; - name = rte_vdev_device_name(vdev); - if (!name) - return -EINVAL; - - MRVL_LOG(INFO, "Removing %s", name); - - RTE_ETH_FOREACH_DEV(i) { /* FIXME: removing all devices! */ - char ifname[RTE_ETH_NAME_MAX_LEN]; - - rte_eth_dev_get_name_by_port(i, ifname); - mrvl_eth_dev_destroy(ifname); - mrvl_dev_num--; - } - - if (mrvl_dev_num == 0) { - MRVL_LOG(INFO, "Perform MUSDK deinit"); - mrvl_deinit_hifs(); - mrvl_deinit_pp2(); - rte_mvep_deinit(MVEP_MOD_T_PP2); + RTE_ETH_FOREACH_DEV(port_id) { + if (rte_eth_devices[port_id].device != &vdev->device) + continue; + rte_eth_dev_close(port_id); } return 0; -- 2.7.4