[ovs-dev,4/4] netdev-dpdk: Reword mp_size as n_mbufs.

Message ID 1506438251-16537-4-git-send-email-antonio.fischetti@intel.com
State New
Headers show
Series
  • [ovs-dev,1/4] netdev-dpdk: fix mempool management with vhu client.
Related show

Commit Message

Fischetti, Antonio Sept. 26, 2017, 3:04 p.m.
The mp_size parameter to be passed to rte mempool creation
functions is meant to contain the number of elements inside
the requested mempool. So it is renamed as n_mbufs.

CC: Ciara Loftus <ciara.loftus@intel.com>
CC: Kevin Traynor <ktraynor@redhat.com>
CC: Aaron Conole <aconole@redhat.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
DPDK doc for rte_pktmbuf_pool_create() at
 http://dpdk.org/doc/api/rte__mbuf_8h.html
DPDK doc for rte_mempool_create() at
 http://dpdk.org/doc/api/rte__mempool_8h.html

 lib/netdev-dpdk.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 7c673ec..46862df 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -308,7 +308,7 @@  struct dpdk_mp {
     int mtu;
     int socket_id;
     char if_name[IFNAMSIZ];
-    unsigned mp_size;
+    unsigned n_mbufs;   /* Number of mbufs inside the mempool. */
     struct ovs_list list_node OVS_GUARDED_BY(dpdk_mp_mutex);
 };
 
@@ -500,11 +500,11 @@  dpdk_mp_name(struct dpdk_mp *dmp)
     uint32_t h = hash_string(dmp->if_name, 0);
     char *mp_name = xcalloc(RTE_MEMPOOL_NAMESIZE, sizeof *mp_name);
     int ret = snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "ovs_%x_%d_%u",
-                       h, dmp->mtu, dmp->mp_size);
+                       h, dmp->mtu, dmp->n_mbufs);
     if (ret < 0 || ret >= RTE_MEMPOOL_NAMESIZE) {
         VLOG_ERR("Failed to generate a mempool name for \"%s\". "
                 "Hash:0x%x, mtu:%d, mbufs:%u",
-                dmp->if_name, h, dmp->mtu, dmp->mp_size);
+                dmp->if_name, h, dmp->mtu, dmp->n_mbufs);
         return NULL;
     }
     return mp_name;
@@ -522,13 +522,13 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
     ovs_strzcpy(dmp->if_name, dev->up.name, IFNAMSIZ);
 
     /*
-     * XXX: rough estimation of memory required for port:
+     * XXX: rough estimation of number of mbufs required for this port:
      * <packets required to fill the device rxqs>
      * + <packets that could be stuck on other ports txqs>
      * + <packets in the pmd threads>
      * + <additional memory for corner cases>
      */
-    dmp->mp_size = dev->requested_n_rxq * dev->requested_rxq_size
+    dmp->n_mbufs = dev->requested_n_rxq * dev->requested_rxq_size
             + dev->requested_n_txq * dev->requested_txq_size
             + MIN(RTE_MAX_LCORE, dev->requested_n_rxq) * NETDEV_MAX_BURST
             + MIN_NB_MBUF;
@@ -540,10 +540,10 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
 
         VLOG_DBG("Requesting a mempool of %u mbufs for netdev %s "
                  "with %d Rx and %d Tx queues.",
-                 dmp->mp_size, dev->up.name,
+                 dmp->n_mbufs, dev->up.name,
                  dev->requested_n_rxq, dev->requested_n_txq);
 
-        dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->mp_size,
+        dmp->mp = rte_pktmbuf_pool_create(mp_name, dmp->n_mbufs,
                                           MP_CACHE_SZ,
                                           sizeof (struct dp_packet)
                                                  - sizeof (struct rte_mbuf),
@@ -552,7 +552,7 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
                                           dmp->socket_id);
         if (dmp->mp) {
             VLOG_DBG("Allocated \"%s\" mempool with %u mbufs", mp_name,
-                    dmp->mp_size);
+                    dmp->n_mbufs);
         } else if (rte_errno == EEXIST) {
             /* A mempool with the same name already exists.  We just
              * retrieve its pointer to be returned to the caller. */
@@ -565,7 +565,7 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
             mp_exists = true;
         } else {
             VLOG_ERR("Failed mempool \"%s\" create request of %u mbufs",
-                     mp_name, dmp->mp_size);
+                     mp_name, dmp->n_mbufs);
         }
         free(mp_name);
         if (dmp->mp) {
@@ -581,7 +581,7 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu)
             return dmp;
         }
     } while (!mp_exists &&
-            (rte_errno == ENOMEM && (dmp->mp_size /= 2) >= MIN_NB_MBUF));
+            (rte_errno == ENOMEM && (dmp->n_mbufs /= 2) >= MIN_NB_MBUF));
 
     rte_free(dmp);
     return NULL;