DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] dma/skeleton: support multiple instances
@ 2022-03-28 14:23 Sivaprasad Tummala
  2022-03-28 14:40 ` Varghese, Vipin
  0 siblings, 1 reply; 5+ messages in thread
From: Sivaprasad Tummala @ 2022-03-28 14:23 UTC (permalink / raw)
  To: fengchengwen; +Cc: dev, 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 <Sivaprasad.Tummala@amd.com>
---
 drivers/dma/skeleton/skeleton_dmadev.c | 37 +++++++++++++++-----------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
index 81cbdd286e..6b1c01d89c 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -100,6 +100,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;
 
@@ -125,7 +126,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!");
@@ -160,7 +162,7 @@ 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)
 {
 	struct skeldma_desc *desc;
 	struct rte_ring *empty;
@@ -168,8 +170,12 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
 	struct rte_ring *running;
 	struct rte_ring *completed;
 	uint16_t i;
+	char pool_name[RTE_RING_NAMESIZE];
+	char ring_name[RTE_RING_NAMESIZE];
 
-	desc = rte_zmalloc_socket("dma_skeleton_desc",
+	snprintf(pool_name, RTE_RING_NAMESIZE, "dma_skel_desc_pool_%d",
+			dev_id);
+	desc = rte_zmalloc_socket(pool_name,
 				  nb_desc * sizeof(struct skeldma_desc),
 				  RTE_CACHE_LINE_SIZE, hw->socket_id);
 	if (desc == NULL) {
@@ -177,13 +183,21 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
 		return -ENOMEM;
 	}
 
-	empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc,
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_empty_%d",
+			dev_id);
+	empty = rte_ring_create(ring_name, nb_desc,
 				hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
-	pending = rte_ring_create("dma_skeleton_desc_pending", nb_desc,
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_pend_%d",
+			dev_id);
+	pending = rte_ring_create(ring_name, nb_desc,
 				  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
-	running = rte_ring_create("dma_skeleton_desc_running", nb_desc,
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_run_%d",
+			dev_id);
+	running = rte_ring_create(ring_name, nb_desc,
 				  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
-	completed = rte_ring_create("dma_skeleton_desc_completed", nb_desc,
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_comp_%d",
+			dev_id);
+	completed = rte_ring_create(ring_name, nb_desc,
 				  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
 	if (empty == NULL || pending == NULL || running == NULL ||
 	    completed == NULL) {
@@ -254,7 +268,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
@@ -548,13 +562,6 @@ 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);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] dma/skeleton: support multiple instances
  2022-03-28 14:23 [PATCH] dma/skeleton: support multiple instances Sivaprasad Tummala
@ 2022-03-28 14:40 ` Varghese, Vipin
  2022-06-07 10:49   ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Varghese, Vipin @ 2022-03-28 14:40 UTC (permalink / raw)
  To: Tummala, Sivaprasad, fengchengwen; +Cc: dev, Tummala, Sivaprasad

[AMD Official Use Only]

Verified on ` AMD EPYC 7713 64-Core Processor` platform with argument ` --vdev=dma_skeleton0,lcore=4 --vdev=dma_skeleton1,lcore=5`. 

Tested-by: Vipin Varghese <Vipin.Varghese@amd.com>

-----Original Message-----
From: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com> 
Sent: Monday, March 28, 2022 7:53 PM
To: fengchengwen@huawei.com
Cc: dev@dpdk.org; Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>
Subject: [PATCH] dma/skeleton: support multiple instances

[CAUTION: External Email]

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 <Sivaprasad.Tummala@amd.com>
---
 drivers/dma/skeleton/skeleton_dmadev.c | 37 +++++++++++++++-----------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
index 81cbdd286e..6b1c01d89c 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -100,6 +100,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;

@@ -125,7 +126,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!"); @@ -160,7 +162,7 @@ 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)
 {
        struct skeldma_desc *desc;
        struct rte_ring *empty;
@@ -168,8 +170,12 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
        struct rte_ring *running;
        struct rte_ring *completed;
        uint16_t i;
+       char pool_name[RTE_RING_NAMESIZE];
+       char ring_name[RTE_RING_NAMESIZE];

-       desc = rte_zmalloc_socket("dma_skeleton_desc",
+       snprintf(pool_name, RTE_RING_NAMESIZE, "dma_skel_desc_pool_%d",
+                       dev_id);
+       desc = rte_zmalloc_socket(pool_name,
                                  nb_desc * sizeof(struct skeldma_desc),
                                  RTE_CACHE_LINE_SIZE, hw->socket_id);
        if (desc == NULL) {
@@ -177,13 +183,21 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
                return -ENOMEM;
        }

-       empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc,
+       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_empty_%d",
+                       dev_id);
+       empty = rte_ring_create(ring_name, nb_desc,
                                hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
-       pending = rte_ring_create("dma_skeleton_desc_pending", nb_desc,
+       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_pend_%d",
+                       dev_id);
+       pending = rte_ring_create(ring_name, nb_desc,
                                  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
-       running = rte_ring_create("dma_skeleton_desc_running", nb_desc,
+       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_run_%d",
+                       dev_id);
+       running = rte_ring_create(ring_name, nb_desc,
                                  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
-       completed = rte_ring_create("dma_skeleton_desc_completed", nb_desc,
+       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_comp_%d",
+                       dev_id);
+       completed = rte_ring_create(ring_name, nb_desc,
                                  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
        if (empty == NULL || pending == NULL || running == NULL ||
            completed == NULL) {
@@ -254,7 +268,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
@@ -548,13 +562,6 @@ 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);
--
2.17.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dma/skeleton: support multiple instances
  2022-03-28 14:40 ` Varghese, Vipin
@ 2022-06-07 10:49   ` Thomas Monjalon
  2022-06-08  7:10     ` fengchengwen
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Monjalon @ 2022-06-07 10:49 UTC (permalink / raw)
  To: fengchengwen
  Cc: Tummala, Sivaprasad, dev, Tummala, Sivaprasad, Varghese, Vipin

Chengwen, as the maintainer of this driver, what do you think?


28/03/2022 16:40, Varghese, Vipin:
> [AMD Official Use Only]
> 
> Verified on ` AMD EPYC 7713 64-Core Processor` platform with argument ` --vdev=dma_skeleton0,lcore=4 --vdev=dma_skeleton1,lcore=5`. 
> 
> Tested-by: Vipin Varghese <Vipin.Varghese@amd.com>
> 
> -----Original Message-----
> From: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com> 
> Sent: Monday, March 28, 2022 7:53 PM
> To: fengchengwen@huawei.com
> Cc: dev@dpdk.org; Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>
> Subject: [PATCH] dma/skeleton: support multiple instances
> 
> [CAUTION: External Email]
> 
> 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 <Sivaprasad.Tummala@amd.com>
> ---
>  drivers/dma/skeleton/skeleton_dmadev.c | 37 +++++++++++++++-----------
>  1 file changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
> index 81cbdd286e..6b1c01d89c 100644
> --- a/drivers/dma/skeleton/skeleton_dmadev.c
> +++ b/drivers/dma/skeleton/skeleton_dmadev.c
> @@ -100,6 +100,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;
> 
> @@ -125,7 +126,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!"); @@ -160,7 +162,7 @@ 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)
>  {
>         struct skeldma_desc *desc;
>         struct rte_ring *empty;
> @@ -168,8 +170,12 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
>         struct rte_ring *running;
>         struct rte_ring *completed;
>         uint16_t i;
> +       char pool_name[RTE_RING_NAMESIZE];
> +       char ring_name[RTE_RING_NAMESIZE];
> 
> -       desc = rte_zmalloc_socket("dma_skeleton_desc",
> +       snprintf(pool_name, RTE_RING_NAMESIZE, "dma_skel_desc_pool_%d",
> +                       dev_id);
> +       desc = rte_zmalloc_socket(pool_name,
>                                   nb_desc * sizeof(struct skeldma_desc),
>                                   RTE_CACHE_LINE_SIZE, hw->socket_id);
>         if (desc == NULL) {
> @@ -177,13 +183,21 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
>                 return -ENOMEM;
>         }
> 
> -       empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc,
> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_empty_%d",
> +                       dev_id);
> +       empty = rte_ring_create(ring_name, nb_desc,
>                                 hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
> -       pending = rte_ring_create("dma_skeleton_desc_pending", nb_desc,
> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_pend_%d",
> +                       dev_id);
> +       pending = rte_ring_create(ring_name, nb_desc,
>                                   hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
> -       running = rte_ring_create("dma_skeleton_desc_running", nb_desc,
> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_run_%d",
> +                       dev_id);
> +       running = rte_ring_create(ring_name, nb_desc,
>                                   hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
> -       completed = rte_ring_create("dma_skeleton_desc_completed", nb_desc,
> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_comp_%d",
> +                       dev_id);
> +       completed = rte_ring_create(ring_name, nb_desc,
>                                   hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
>         if (empty == NULL || pending == NULL || running == NULL ||
>             completed == NULL) {
> @@ -254,7 +268,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
> @@ -548,13 +562,6 @@ 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);
> --
> 2.17.1
> 






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dma/skeleton: support multiple instances
  2022-06-07 10:49   ` Thomas Monjalon
@ 2022-06-08  7:10     ` fengchengwen
  0 siblings, 0 replies; 5+ messages in thread
From: fengchengwen @ 2022-06-08  7:10 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Tummala, Sivaprasad, dev, Varghese, Vipin

This patch LGTM, but it forget remove skeldma_count variable.

Also I find the skeleton_dma has the same bug with [1], So I will
send a patchset which contains this patch (add my reviewed-by).

Sivaprasad, Vipin, thanks for your work.

[1] dma/hisilicon: fix return last-idx when no DMA completed

On 2022/6/7 18:49, Thomas Monjalon wrote:
> Chengwen, as the maintainer of this driver, what do you think?
> 
> 
> 28/03/2022 16:40, Varghese, Vipin:
>> [AMD Official Use Only]
>>
>> Verified on ` AMD EPYC 7713 64-Core Processor` platform with argument ` --vdev=dma_skeleton0,lcore=4 --vdev=dma_skeleton1,lcore=5`. 
>>
>> Tested-by: Vipin Varghese <Vipin.Varghese@amd.com>
>>
>> -----Original Message-----
>> From: Sivaprasad Tummala <Sivaprasad.Tummala@amd.com> 
>> Sent: Monday, March 28, 2022 7:53 PM
>> To: fengchengwen@huawei.com
>> Cc: dev@dpdk.org; Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>
>> Subject: [PATCH] dma/skeleton: support multiple instances
>>
>> [CAUTION: External Email]
>>
>> 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 <Sivaprasad.Tummala@amd.com>
>> ---
>>  drivers/dma/skeleton/skeleton_dmadev.c | 37 +++++++++++++++-----------
>>  1 file changed, 22 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
>> index 81cbdd286e..6b1c01d89c 100644
>> --- a/drivers/dma/skeleton/skeleton_dmadev.c
>> +++ b/drivers/dma/skeleton/skeleton_dmadev.c
>> @@ -100,6 +100,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;
>>
>> @@ -125,7 +126,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!"); @@ -160,7 +162,7 @@ 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)
>>  {
>>         struct skeldma_desc *desc;
>>         struct rte_ring *empty;
>> @@ -168,8 +170,12 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
>>         struct rte_ring *running;
>>         struct rte_ring *completed;
>>         uint16_t i;
>> +       char pool_name[RTE_RING_NAMESIZE];
>> +       char ring_name[RTE_RING_NAMESIZE];
>>
>> -       desc = rte_zmalloc_socket("dma_skeleton_desc",
>> +       snprintf(pool_name, RTE_RING_NAMESIZE, "dma_skel_desc_pool_%d",
>> +                       dev_id);
>> +       desc = rte_zmalloc_socket(pool_name,
>>                                   nb_desc * sizeof(struct skeldma_desc),
>>                                   RTE_CACHE_LINE_SIZE, hw->socket_id);
>>         if (desc == NULL) {
>> @@ -177,13 +183,21 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
>>                 return -ENOMEM;
>>         }
>>
>> -       empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc,
>> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_empty_%d",
>> +                       dev_id);
>> +       empty = rte_ring_create(ring_name, nb_desc,
>>                                 hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
>> -       pending = rte_ring_create("dma_skeleton_desc_pending", nb_desc,
>> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_pend_%d",
>> +                       dev_id);
>> +       pending = rte_ring_create(ring_name, nb_desc,
>>                                   hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
>> -       running = rte_ring_create("dma_skeleton_desc_running", nb_desc,
>> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_run_%d",
>> +                       dev_id);
>> +       running = rte_ring_create(ring_name, nb_desc,
>>                                   hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
>> -       completed = rte_ring_create("dma_skeleton_desc_completed", nb_desc,
>> +       snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_comp_%d",
>> +                       dev_id);
>> +       completed = rte_ring_create(ring_name, nb_desc,
>>                                   hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
>>         if (empty == NULL || pending == NULL || running == NULL ||
>>             completed == NULL) {
>> @@ -254,7 +268,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
>> @@ -548,13 +562,6 @@ 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);
>> --
>> 2.17.1
>>
> 
> 
> 
> 
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] dma/skeleton: support multiple instances
@ 2022-03-28 12:53 Sivaprasad Tummala
  0 siblings, 0 replies; 5+ messages in thread
From: Sivaprasad Tummala @ 2022-03-28 12:53 UTC (permalink / raw)
  To: fengchengwen; +Cc: dev, 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 <Sivaprasad.Tummala@amd.com>
---
 drivers/dma/skeleton/skeleton_dmadev.c | 41 +++++++++++++++-----------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c
index d9e4f731d7..a1847571c1 100644
--- a/drivers/dma/skeleton/skeleton_dmadev.c
+++ b/drivers/dma/skeleton/skeleton_dmadev.c
@@ -100,6 +100,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;
 
@@ -125,7 +126,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!");
@@ -160,7 +162,7 @@ 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)
 {
 	struct skeldma_desc *desc;
 	struct rte_ring *empty;
@@ -168,8 +170,12 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
 	struct rte_ring *running;
 	struct rte_ring *completed;
 	uint16_t i;
+	char pool_name[RTE_RING_NAMESIZE];
+	char ring_name[RTE_RING_NAMESIZE];
 
-	desc = rte_zmalloc_socket("dma_skelteon_desc",
+	snprintf(pool_name, RTE_RING_NAMESIZE, "dma_skel_desc_pool_%d",
+			dev_id);
+	desc = rte_zmalloc_socket(pool_name,
 				  nb_desc * sizeof(struct skeldma_desc),
 				  RTE_CACHE_LINE_SIZE, hw->socket_id);
 	if (desc == NULL) {
@@ -177,13 +183,21 @@ vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc)
 		return -ENOMEM;
 	}
 
-	empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc,
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_empty_%d",
+				dev_id);
+	empty = rte_ring_create(ring_name, 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,
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_pend_%d",
+				dev_id);
+	pending = rte_ring_create(ring_name, nb_desc,
+				hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_run_%d",
+				dev_id);
+	running = rte_ring_create(ring_name, nb_desc,
+				hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
+	snprintf(ring_name, RTE_RING_NAMESIZE, "dma_skel_desc_comp_%d",
+				dev_id);
+	completed = rte_ring_create(ring_name, nb_desc,
 				  hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ);
 	if (empty == NULL || pending == NULL || running == NULL ||
 	    completed == NULL) {
@@ -254,7 +268,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
@@ -548,13 +562,6 @@ 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);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-08  7:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 14:23 [PATCH] dma/skeleton: support multiple instances Sivaprasad Tummala
2022-03-28 14:40 ` Varghese, Vipin
2022-06-07 10:49   ` Thomas Monjalon
2022-06-08  7:10     ` fengchengwen
  -- strict thread matches above, loose matches on Subject: below --
2022-03-28 12:53 Sivaprasad Tummala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).