ethdev: rename memzones allocated for DMA
authorThomas Monjalon <thomas@monjalon.net>
Thu, 11 Oct 2018 12:58:49 +0000 (14:58 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 17 Oct 2018 08:26:59 +0000 (10:26 +0200)
The helper rte_eth_dma_zone_reserve() is called by PMDs
when probing a new port.
It creates a new memzone with an unique name.
The name of this memzone was using the name of the driver
doing the probe.

In order to avoid assigning the driver before the end of the probing,
the driver name is removed from these memzone names.
The ethdev name (data->name) is not used because it may be too long
and may be not set at this stage of probing.

Syntax of old name: <driver>_<ring>_<port>_<queue>
Syntax of new name: eth_p<port>_q<queue>_<ring>

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Tested-by: Andrew Rybchenko <arybchenko@solarflare.com>
app/test-pmd/config.c
drivers/net/bnx2x/bnx2x_rxtx.c
drivers/net/cxgbe/sge.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
lib/librte_ethdev/rte_ethdev.c

index bf3cd0a..a6db5df 100644 (file)
@@ -1479,8 +1479,8 @@ ring_dma_zone_lookup(const char *ring_name, portid_t port_id, uint16_t q_id)
        char mz_name[RTE_MEMZONE_NAMESIZE];
        const struct rte_memzone *mz;
 
-       snprintf(mz_name, sizeof(mz_name), "%s_%s_%d_%d",
-                ports[port_id].dev_info.driver_name, ring_name, port_id, q_id);
+       snprintf(mz_name, sizeof(mz_name), "eth_p%d_q%d_%s",
+                       port_id, q_id, ring_name);
        mz = rte_memzone_lookup(mz_name);
        if (mz == NULL)
                printf("%s ring memory zoneof (port %d, queue %d) not"
index 589735e..ca28aac 100644 (file)
@@ -12,19 +12,8 @@ static const struct rte_memzone *
 ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name,
                      uint16_t queue_id, uint32_t ring_size, int socket_id)
 {
-       char z_name[RTE_MEMZONE_NAMESIZE];
-       const struct rte_memzone *mz;
-
-       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                       dev->device->driver->name, ring_name,
-                       dev->data->port_id, queue_id);
-
-       mz = rte_memzone_lookup(z_name);
-       if (mz)
-               return mz;
-
-       return rte_memzone_reserve_aligned(z_name, ring_size, socket_id,
-                       RTE_MEMZONE_IOVA_CONTIG, BNX2X_PAGE_SIZE);
+       return rte_eth_dma_zone_reserve(dev, ring_name, queue_id,
+                       ring_size, BNX2X_PAGE_SIZE, socket_id);
 }
 
 static void
index 4ea40d1..f9d2d48 100644 (file)
@@ -1873,10 +1873,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
        /* Size needs to be multiple of 16, including status entry. */
        iq->size = cxgbe_roundup(iq->size, 16);
 
-       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                eth_dev->device->driver->name,
-                fwevtq ? "fwq_ring" : "rx_ring",
-                eth_dev->data->port_id, queue_id);
+       snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+                       eth_dev->data->port_id, queue_id,
+                       fwevtq ? "fwq_ring" : "rx_ring");
        snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
        iq->desc = alloc_ring(iq->size, iq->iqe_len, 0, &iq->phys_addr, NULL, 0,
@@ -1938,10 +1937,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
                        fl->size = s->fl_starve_thres - 1 + 2 * 8;
                fl->size = cxgbe_roundup(fl->size, 8);
 
-               snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                        eth_dev->device->driver->name,
-                        fwevtq ? "fwq_ring" : "fl_ring",
-                        eth_dev->data->port_id, queue_id);
+               snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+                               eth_dev->data->port_id, queue_id,
+                               fwevtq ? "fwq_ring" : "fl_ring");
                snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
                fl->desc = alloc_ring(fl->size, sizeof(__be64),
@@ -2144,9 +2142,8 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
        /* Add status entries */
        nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
-       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                eth_dev->device->driver->name, "tx_ring",
-                eth_dev->data->port_id, queue_id);
+       snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+                       eth_dev->data->port_id, queue_id, "tx_ring");
        snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
        txq->q.desc = alloc_ring(txq->q.size, sizeof(struct tx_desc),
@@ -2223,9 +2220,8 @@ int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
        /* Add status entries */
        nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
 
-       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                eth_dev->device->driver->name, "ctrl_tx_ring",
-                eth_dev->data->port_id, queue_id);
+       snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+                       eth_dev->data->port_id, queue_id, "ctrl_tx_ring");
        snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name);
 
        txq->q.desc = alloc_ring(txq->q.size, sizeof(struct tx_desc),
index e41fa49..78e5b76 100644 (file)
@@ -161,8 +161,8 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,
        char z_name[RTE_MEMZONE_NAMESIZE];
        const struct rte_memzone *mz;
 
-       snprintf(z_name, sizeof(z_name), "%s_%d_%s",
-                dev->device->driver->name, dev->data->port_id, post_string);
+       snprintf(z_name, sizeof(z_name), "eth_p%d_%s",
+                       dev->data->port_id, post_string);
 
        mz = rte_memzone_lookup(z_name);
        if (!reuse) {
index 741a864..571f0e8 100644 (file)
@@ -3493,9 +3493,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
        char z_name[RTE_MEMZONE_NAMESIZE];
        const struct rte_memzone *mz;
 
-       snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-                dev->device->driver->name, ring_name,
-                dev->data->port_id, queue_id);
+       snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+                dev->data->port_id, queue_id, ring_name);
 
        mz = rte_memzone_lookup(z_name);
        if (mz)