[v1,1/2] net/af_xdp: name the buf ring dynamically

Message ID 20190418152056.15018-1-xiaolong.ye@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v1,1/2] net/af_xdp: name the buf ring dynamically |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Xiaolong Ye April 18, 2019, 3:20 p.m. UTC
  Naming the buf_ring dynamically allows to create multiple af_xdp vdevs.

Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")

Reported-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

David Marchand April 19, 2019, 9:46 a.m. UTC | #1
On Thu, Apr 18, 2019 at 5:27 PM Xiaolong Ye <xiaolong.ye@intel.com> wrote:

> Naming the buf_ring dynamically allows to create multiple af_xdp vdevs.
>
> Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
>
> Reported-by: Markus Theil <markus.theil@tu-ilmenau.de>
> Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 497e2cfde..d8e99204e 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -473,7 +473,7 @@ xdp_umem_destroy(struct xsk_umem_info *umem)
>  }
>
>  static struct
> -xsk_umem_info *xdp_umem_configure(void)
> +xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals)
>  {
>         struct xsk_umem_info *umem;
>         const struct rte_memzone *mz;
> @@ -482,6 +482,7 @@ xsk_umem_info *xdp_umem_configure(void)
>                 .comp_size = ETH_AF_XDP_DFLT_NUM_DESCS,
>                 .frame_size = ETH_AF_XDP_FRAME_SIZE,
>                 .frame_headroom = ETH_AF_XDP_DATA_HEADROOM };
> +       char ring_name[RTE_RING_NAMESIZE];
>         int ret;
>         uint64_t i;
>
> @@ -491,7 +492,9 @@ xsk_umem_info *xdp_umem_configure(void)
>                 return NULL;
>         }
>
> -       umem->buf_ring = rte_ring_create("af_xdp_ring",
> +       ret = snprintf(ring_name, sizeof(ring_name), "af_xdp_ring_%s_%d",
> +                      internals->if_name, internals->queue_idx);
>

You can drop the ret assignment, you won't check it anyway.
queue_idx is unsigned %d -> %u ?

+       umem->buf_ring = rte_ring_create(ring_name,
>                                          ETH_AF_XDP_NUM_BUFFERS,
>                                          rte_socket_id(),
>                                          0x0);
> @@ -541,7 +544,7 @@ xsk_configure(struct pmd_internals *internals, struct
> pkt_rx_queue *rxq,
>         int ret = 0;
>         int reserve_size;
>
> -       rxq->umem = xdp_umem_configure();
> +       rxq->umem = xdp_umem_configure(internals);
>         if (rxq->umem == NULL)
>                 return -ENOMEM;
>
> --
> 2.17.1
>
>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 497e2cfde..d8e99204e 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -473,7 +473,7 @@  xdp_umem_destroy(struct xsk_umem_info *umem)
 }
 
 static struct
-xsk_umem_info *xdp_umem_configure(void)
+xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals)
 {
 	struct xsk_umem_info *umem;
 	const struct rte_memzone *mz;
@@ -482,6 +482,7 @@  xsk_umem_info *xdp_umem_configure(void)
 		.comp_size = ETH_AF_XDP_DFLT_NUM_DESCS,
 		.frame_size = ETH_AF_XDP_FRAME_SIZE,
 		.frame_headroom = ETH_AF_XDP_DATA_HEADROOM };
+	char ring_name[RTE_RING_NAMESIZE];
 	int ret;
 	uint64_t i;
 
@@ -491,7 +492,9 @@  xsk_umem_info *xdp_umem_configure(void)
 		return NULL;
 	}
 
-	umem->buf_ring = rte_ring_create("af_xdp_ring",
+	ret = snprintf(ring_name, sizeof(ring_name), "af_xdp_ring_%s_%d",
+		       internals->if_name, internals->queue_idx);
+	umem->buf_ring = rte_ring_create(ring_name,
 					 ETH_AF_XDP_NUM_BUFFERS,
 					 rte_socket_id(),
 					 0x0);
@@ -541,7 +544,7 @@  xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 	int ret = 0;
 	int reserve_size;
 
-	rxq->umem = xdp_umem_configure();
+	rxq->umem = xdp_umem_configure(internals);
 	if (rxq->umem == NULL)
 		return -ENOMEM;