From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id DC14B1B1A8 for ; Wed, 24 Jan 2018 16:40:16 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6CFFC226E2; Wed, 24 Jan 2018 10:40:16 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:40:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=YJIMnQBP6AZMWcP3E UYZxEI4zmJiFCzO9/HSNUrqfUc=; b=Bkm8y/4AvalyB8ckV0RXjYu8Mhz3uW227 y5K35RbLWbSTHzPhhA5QhY8vZIEBwGZmjT8w2LNYXmSWg3tJc5OF9sFPuXHkZaIY x9c/XUG9imBQI2NuWRajCJSN4ACm0dhxzvsTWykkUupkdVUGpjPjFGv7XeiGdEkV xvDXrbYvn4HI5RqKhCrsTVwslNszYXwnGlzBgfZ1e3Rin75CNWtoVN5VwYjCtk/6 WIzTSuXuckmbBgPKD1ZUuuRXqq0vyIl31+g6r2t8a5mCPUSI1g4Zh6DS3u/YpfZ+ /Md8c01MZDJwUY54HTbEgyOW/yr/oU0Nfj8wPARHr1j+aAXOCMGVQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=YJIMnQBP6AZMWcP3EUYZxEI4zmJiFCzO9/HSNUrqfUc=; b=f/HAbaQM 4I4vnorVW6chsIEidSf0h2Zj9tgmHVjh9d7kfUk5618b/t5eyPhk+hqB8xbv62iw lunKsmIXzDiyAcwNonahvZcfPyE2n1S+8bHf8tXWcOyybexpb1CjEbSyu5ueCI3K zJSAmoR+AAy0euExU+zYwKxZUYviqMoDpH6LXB2NOrcGboorK3z+Ukl65reNC8/U v+BcE3681ftZMrZsHvajbl6beeHXA92bk5vOqGRacvXTWWijCjHmsgwNwHIvXTJg mLFp1/13BZIa9zv/Gn3BtL9UvPQCf9fmxsAP/YmDLSDfn6FaF6dlvbNChu4Dh/yj WOelKAATTFYgCw== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 3F5E47E1A2; Wed, 24 Jan 2018 10:40:13 -0500 (EST) From: Yuanhan Liu To: Natalie Samsonov Cc: dpdk stable Date: Wed, 24 Jan 2018 23:32:46 +0800 Message-Id: <1516808026-25523-98-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/mrvl: fix multiple probe' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:40:17 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 3766e74912f3ed439e7d2bec517ca9b3850c948c Mon Sep 17 00:00:00 2001 From: Natalie Samsonov Date: Thu, 11 Jan 2018 16:35:39 +0100 Subject: [PATCH] net/mrvl: fix multiple probe [ upstream commit 10bce9cf9b47f85d3c5c447ca0aa5ad8c28dfce0 ] MUSDK library initialization and cleanup should be done once. This commit fixes that by doing necessary initialization once the first port is probed and cleanup once the last port is removed. Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton") Signed-off-by: Natalie Samsonov --- drivers/net/mrvl/mrvl_ethdev.c | 78 +++++++++++++++++++++++++++++------------- drivers/net/mrvl/mrvl_ethdev.h | 3 -- drivers/net/mrvl/mrvl_qos.c | 2 +- 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index 2936165..efaf124 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -115,6 +115,11 @@ struct pp2_bpool *mrvl_port_to_bpool_lookup[RTE_MAX_ETHPORTS]; int mrvl_port_bpool_size[PP2_NUM_PKT_PROC][PP2_BPOOL_NUM_POOLS][RTE_MAX_LCORE]; uint64_t cookie_addr_high = MRVL_COOKIE_ADDR_INVALID; +struct mrvl_ifnames { + const char *names[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC]; + int idx; +}; + /* * To use buffer harvesting based on loopback port shadow queue structure * was introduced for buffers information bookkeeping. @@ -160,10 +165,9 @@ struct mrvl_txq { */ struct mrvl_shadow_txq shadow_txqs[RTE_MAX_ETHPORTS][RTE_MAX_LCORE]; -/** Number of ports configured. */ -int mrvl_ports_nb; static int mrvl_lcore_first; static int mrvl_lcore_last; +static int mrvl_dev_num; static inline int mrvl_get_bpool_size(int pp2_id, int pool_id) @@ -583,8 +587,10 @@ mrvl_dev_stop(struct rte_eth_dev *dev) mrvl_dev_set_link_down(dev); mrvl_flush_rx_queues(dev); mrvl_flush_tx_shadow_queues(dev); - if (priv->qos_tbl) + if (priv->qos_tbl) { pp2_cls_qos_tbl_deinit(priv->qos_tbl); + priv->qos_tbl = NULL; + } pp2_ppio_deinit(priv->ppio); priv->ppio = NULL; } @@ -2034,6 +2040,7 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst; eth_dev->tx_pkt_burst = mrvl_tx_pkt_burst; + eth_dev->data->kdrv = RTE_KDRV_NONE; eth_dev->data->dev_private = priv; eth_dev->device = &vdev->device; eth_dev->dev_ops = &mrvl_ops; @@ -2067,6 +2074,7 @@ mrvl_eth_dev_destroy(const char *name) priv = eth_dev->data->dev_private; pp2_bpool_deinit(priv->bpool); + used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit); rte_free(priv); rte_free(eth_dev->data->mac_addrs); rte_eth_dev_release_port(eth_dev); @@ -2090,9 +2098,9 @@ static int mrvl_get_ifnames(const char *key __rte_unused, const char *value, void *extra_args) { - const char **ifnames = extra_args; + struct mrvl_ifnames *ifnames = extra_args; - ifnames[mrvl_ports_nb++] = value; + ifnames->names[ifnames->idx++] = value; return 0; } @@ -2141,6 +2149,8 @@ mrvl_deinit_hifs(void) if (hifs[i]) pp2_hif_deinit(hifs[i]); } + used_hifs = MRVL_MUSDK_HIFS_RESERVED; + memset(hifs, 0, sizeof(hifs)); } static void mrvl_set_first_last_cores(int core_id) @@ -2165,7 +2175,7 @@ static int rte_pmd_mrvl_probe(struct rte_vdev_device *vdev) { struct rte_kvargs *kvlist; - const char *ifnames[PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC]; + struct mrvl_ifnames ifnames; int ret = -EINVAL; uint32_t i, ifnum, cfgnum, core_id; const char *params; @@ -2179,21 +2189,34 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev) return -EINVAL; ifnum = rte_kvargs_count(kvlist, MRVL_IFACE_NAME_ARG); - if (ifnum > RTE_DIM(ifnames)) + if (ifnum > RTE_DIM(ifnames.names)) goto out_free_kvlist; + ifnames.idx = 0; rte_kvargs_process(kvlist, MRVL_IFACE_NAME_ARG, mrvl_get_ifnames, &ifnames); - cfgnum = rte_kvargs_count(kvlist, MRVL_CFG_ARG); - if (cfgnum > 1) { - RTE_LOG(ERR, PMD, "Cannot handle more than one config file!\n"); - goto out_free_kvlist; - } else if (cfgnum == 1) { - rte_kvargs_process(kvlist, MRVL_CFG_ARG, - mrvl_get_qoscfg, &mrvl_qos_cfg); + + /* + * The below system initialization should be done only once, + * on the first provided configuration file + */ + if (!mrvl_qos_cfg) { + cfgnum = rte_kvargs_count(kvlist, MRVL_CFG_ARG); + RTE_LOG(INFO, PMD, "Parsing config file!\n"); + if (cfgnum > 1) { + RTE_LOG(ERR, PMD, "Cannot handle more than one config file!\n"); + goto out_free_kvlist; + } else if (cfgnum == 1) { + rte_kvargs_process(kvlist, MRVL_CFG_ARG, + mrvl_get_qoscfg, &mrvl_qos_cfg); + } } + if (mrvl_dev_num) + goto init_devices; + + RTE_LOG(INFO, PMD, "Perform MUSDK initializations\n"); /* * ret == -EEXIST is correct, it means DMA * has been already initialized (by another PMD). @@ -2217,12 +2240,14 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev) if (ret) goto out_deinit_hifs; +init_devices: for (i = 0; i < ifnum; i++) { - RTE_LOG(INFO, PMD, "Creating %s\n", ifnames[i]); - ret = mrvl_eth_dev_create(vdev, ifnames[i]); + RTE_LOG(INFO, PMD, "Creating %s\n", ifnames.names[i]); + ret = mrvl_eth_dev_create(vdev, ifnames.names[i]); if (ret) goto out_cleanup; } + mrvl_dev_num += ifnum; rte_kvargs_free(kvlist); @@ -2238,12 +2263,15 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev) return 0; out_cleanup: for (; i > 0; i--) - mrvl_eth_dev_destroy(ifnames[i]); + mrvl_eth_dev_destroy(ifnames.names[i]); out_deinit_hifs: - mrvl_deinit_hifs(); - mrvl_deinit_pp2(); + if (mrvl_dev_num == 0) { + mrvl_deinit_hifs(); + mrvl_deinit_pp2(); + } out_deinit_dma: - mv_sys_dma_mem_destroy(); + if (mrvl_dev_num == 0) + mv_sys_dma_mem_destroy(); out_free_kvlist: rte_kvargs_free(kvlist); @@ -2276,11 +2304,15 @@ rte_pmd_mrvl_remove(struct rte_vdev_device *vdev) rte_eth_dev_get_name_by_port(i, ifname); mrvl_eth_dev_destroy(ifname); + mrvl_dev_num--; } - mrvl_deinit_hifs(); - mrvl_deinit_pp2(); - mv_sys_dma_mem_destroy(); + if (mrvl_dev_num == 0) { + RTE_LOG(INFO, PMD, "Perform MUSDK deinit\n"); + mrvl_deinit_hifs(); + mrvl_deinit_pp2(); + mv_sys_dma_mem_destroy(); + } return 0; } diff --git a/drivers/net/mrvl/mrvl_ethdev.h b/drivers/net/mrvl/mrvl_ethdev.h index 2a4ab5a..7764da1 100644 --- a/drivers/net/mrvl/mrvl_ethdev.h +++ b/drivers/net/mrvl/mrvl_ethdev.h @@ -110,7 +110,4 @@ struct mrvl_priv { uint16_t nb_rx_queues; }; -/** Number of ports configured. */ -extern int mrvl_ports_nb; - #endif /* _MRVL_ETHDEV_H_ */ diff --git a/drivers/net/mrvl/mrvl_qos.c b/drivers/net/mrvl/mrvl_qos.c index 7c9943a..fbb3681 100644 --- a/drivers/net/mrvl/mrvl_qos.c +++ b/drivers/net/mrvl/mrvl_qos.c @@ -369,7 +369,7 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, } /* Use the number of ports given as vdev parameters. */ - for (n = 0; n < mrvl_ports_nb; ++n) { + for (n = 0; n < (PP2_NUM_ETH_PPIO * PP2_NUM_PKT_PROC); ++n) { snprintf(sec_name, sizeof(sec_name), "%s %d %s", MRVL_TOK_PORT, n, MRVL_TOK_DEFAULT); -- 2.7.4