From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 99F20A0548; Wed, 8 Jun 2022 10:56:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F2984280E; Wed, 8 Jun 2022 10:56:33 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id CE2764069C for ; Wed, 8 Jun 2022 10:56:29 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4LJ1Kj2b1rz17HJL; Wed, 8 Jun 2022 16:56:09 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 8 Jun 2022 16:56:27 +0800 From: Chengwen Feng To: , , CC: , , Subject: [PATCH 3/3] dma/skeleton: support multiple instances Date: Wed, 8 Jun 2022 16:50:07 +0800 Message-ID: <20220608085007.10679-4-fengchengwen@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220608085007.10679-1-fengchengwen@huawei.com> References: <20220608085007.10679-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Sivaprasad Tummala dpdk app can support multiple hardware dma instances. with dma skeleton, only a single instance can be configured. This patch supports multiple driver instances per device. Signed-off-by: Sivaprasad Tummala Tested-by: Vipin Varghese Reviewed-by: Chengwen Feng Tested-by: Chengwen Feng --- drivers/dma/skeleton/skeleton_dmadev.c | 50 +++++++++++--------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c index 6b0bb14e2c..82b4661323 100644 --- a/drivers/dma/skeleton/skeleton_dmadev.c +++ b/drivers/dma/skeleton/skeleton_dmadev.c @@ -22,9 +22,6 @@ RTE_LOG_REGISTER_DEFAULT(skeldma_logtype, INFO); rte_log(RTE_LOG_ ## level, skeldma_logtype, "%s(): " fmt "\n", \ __func__, ##args) -/* Count of instances, currently only 1 is supported. */ -static uint16_t skeldma_count; - static int skeldma_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_info, uint32_t info_sz) @@ -100,6 +97,7 @@ static int skeldma_start(struct rte_dma_dev *dev) { struct skeldma_hw *hw = dev->data->dev_private; + char name[RTE_MAX_THREAD_NAME_LEN]; rte_cpuset_t cpuset; int ret; @@ -126,7 +124,8 @@ skeldma_start(struct rte_dma_dev *dev) rte_mb(); - ret = rte_ctrl_thread_create(&hw->thread, "dma_skeleton", NULL, + snprintf(name, sizeof(name), "dma_skel_%d", dev->data->dev_id); + ret = rte_ctrl_thread_create(&hw->thread, name, NULL, cpucopy_thread, dev); if (ret) { SKELDMA_LOG(ERR, "Start cpucopy thread fail!"); @@ -161,8 +160,9 @@ skeldma_stop(struct rte_dma_dev *dev) } static int -vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc) +vchan_setup(struct skeldma_hw *hw, int16_t dev_id, uint16_t nb_desc) { + char name[RTE_RING_NAMESIZE]; struct skeldma_desc *desc; struct rte_ring *empty; struct rte_ring *pending; @@ -170,22 +170,25 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc) struct rte_ring *completed; uint16_t i; - desc = rte_zmalloc_socket("dma_skeleton_desc", - nb_desc * sizeof(struct skeldma_desc), + desc = rte_zmalloc_socket(NULL, nb_desc * sizeof(struct skeldma_desc), RTE_CACHE_LINE_SIZE, hw->socket_id); if (desc == NULL) { SKELDMA_LOG(ERR, "Malloc dma skeleton desc fail!"); return -ENOMEM; } - empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc, - hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); - pending = rte_ring_create("dma_skeleton_desc_pending", nb_desc, - hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); - running = rte_ring_create("dma_skeleton_desc_running", nb_desc, - hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); - completed = rte_ring_create("dma_skeleton_desc_completed", nb_desc, - hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); + snprintf(name, RTE_RING_NAMESIZE, "dma_skel_desc_empty_%d", dev_id); + empty = rte_ring_create(name, nb_desc, hw->socket_id, + RING_F_SP_ENQ | RING_F_SC_DEQ); + snprintf(name, RTE_RING_NAMESIZE, "dma_skel_desc_pend_%d", dev_id); + pending = rte_ring_create(name, nb_desc, hw->socket_id, + RING_F_SP_ENQ | RING_F_SC_DEQ); + snprintf(name, RTE_RING_NAMESIZE, "dma_skel_desc_run_%d", dev_id); + running = rte_ring_create(name, nb_desc, hw->socket_id, + RING_F_SP_ENQ | RING_F_SC_DEQ); + snprintf(name, RTE_RING_NAMESIZE, "dma_skel_desc_comp_%d", dev_id); + completed = rte_ring_create(name, nb_desc, hw->socket_id, + RING_F_SP_ENQ | RING_F_SC_DEQ); if (empty == NULL || pending == NULL || running == NULL || completed == NULL) { SKELDMA_LOG(ERR, "Create dma skeleton desc ring fail!"); @@ -255,7 +258,7 @@ skeldma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, } vchan_release(hw); - return vchan_setup(hw, conf->nb_desc); + return vchan_setup(hw, dev->data->dev_id, conf->nb_desc); } static int @@ -559,21 +562,12 @@ skeldma_probe(struct rte_vdev_device *vdev) return -EINVAL; } - /* More than one instance is not supported */ - if (skeldma_count > 0) { - SKELDMA_LOG(ERR, "Multiple instance not supported for %s", - name); - return -EINVAL; - } - skeldma_parse_vdev_args(vdev, &lcore_id); ret = skeldma_create(name, vdev, lcore_id); - if (ret >= 0) { + if (ret >= 0) SKELDMA_LOG(INFO, "Create %s dmadev with lcore-id %d", name, lcore_id); - skeldma_count = 1; - } return ret < 0 ? ret : 0; } @@ -589,10 +583,8 @@ skeldma_remove(struct rte_vdev_device *vdev) return -1; ret = skeldma_destroy(name); - if (!ret) { - skeldma_count = 0; + if (!ret) SKELDMA_LOG(INFO, "Remove %s dmadev", name); - } return ret; } -- 2.33.0