[ovs-dev,v5,6/6] netdev-dpdk: Rename dpdk_mp_put as dpdk_mp_free.

Message ID 1507737656-31627-7-git-send-email-antonio.fischetti@intel.com
State Superseded
Headers show
Series
  • netdev-dpdk: Fix management of pre-existing mempools.
Related show

Commit Message

Fischetti, Antonio Oct. 11, 2017, 4 p.m.
Rename dpdk_mp_put as dpdk_mp_free, add other comments
to mempool functions.

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>
---
 lib/netdev-dpdk.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Kavanagh, Mark B Oct. 13, 2017, 2:48 p.m. | #1
>From: ovs-dev-bounces@openvswitch.org [mailto:ovs-dev-bounces@openvswitch.org]
>On Behalf Of antonio.fischetti@intel.com
>Sent: Wednesday, October 11, 2017 5:01 PM
>To: dev@openvswitch.org
>Subject: [ovs-dev] [PATCH v5 6/6] netdev-dpdk: Rename dpdk_mp_put as
>dpdk_mp_free.
>
>Rename dpdk_mp_put as dpdk_mp_free, add other comments
>to mempool functions.

Hey Antonio,

As previously mentioned, I don't think this patch belongs in this patchset, since it involves cosmetic purely changes.

In terms of the content itself however, it looks good to me; the comments are welcome, and mp_free is a more accurate description of the function, given that its behaviour has changed from its original implementation.

I suggest rolling a separate 'cleanup' patchset with the cosmetic changes.

Thanks,
Mark 

>
>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>
>---
> lib/netdev-dpdk.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
>diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>index f67c311..934dbb3 100644
>--- a/lib/netdev-dpdk.c
>+++ b/lib/netdev-dpdk.c
>@@ -578,6 +578,9 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool
>*mp_exists)
>     return NULL;
> }
>
>+/* Returns a valid pointer when either of the two cases occur:
>+ * a new mempool was just created or the requested mempool is already
>+ * existing. */
> static struct dpdk_mp *
> dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
> {
>@@ -590,8 +593,9 @@ dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool
>*mp_exists)
>     return dmp;
> }
>
>+/* Release an existing mempool. */
> static void
>-dpdk_mp_put(struct dpdk_mp *dmp)
>+dpdk_mp_free(struct dpdk_mp *dmp)
> {
>     char *mp_name;
>
>@@ -608,8 +612,8 @@ dpdk_mp_put(struct dpdk_mp *dmp)
>     ovs_mutex_unlock(&dpdk_mp_mutex);
> }
>
>-/* Tries to allocate new mempool on requested_socket_id with
>- * mbuf size corresponding to requested_mtu.
>+/* Tries to allocate a new mempool on requested_socket_id with a size
>+ * determined by requested_mtu and requested Rx/Tx queues.
>  * On success new configuration will be applied.
>  * On error, device will be left unchanged. */
> static int
>@@ -636,7 +640,8 @@ netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
>         dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
>         return EEXIST;
>     } else {
>-        dpdk_mp_put(dev->dpdk_mp);
>+        /* A new mempool was created, release the previous one. */
>+        dpdk_mp_free(dev->dpdk_mp);
>         dev->dpdk_mp = mp;
>         dev->mtu = dev->requested_mtu;
>         dev->socket_id = dev->requested_socket_id;
>@@ -1081,7 +1086,7 @@ common_destruct(struct netdev_dpdk *dev)
>     OVS_EXCLUDED(dev->mutex)
> {
>     rte_free(dev->tx_q);
>-    dpdk_mp_put(dev->dpdk_mp);
>+    dpdk_mp_free(dev->dpdk_mp);
>
>     ovs_list_remove(&dev->list_node);
>     free(ovsrcu_get_protected(struct ingress_policer *,
>--
>2.4.11
>
>_______________________________________________
>dev mailing list
>dev@openvswitch.org
>https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f67c311..934dbb3 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -578,6 +578,9 @@  dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
     return NULL;
 }
 
+/* Returns a valid pointer when either of the two cases occur:
+ * a new mempool was just created or the requested mempool is already
+ * existing. */
 static struct dpdk_mp *
 dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
 {
@@ -590,8 +593,9 @@  dpdk_mp_get(struct netdev_dpdk *dev, int mtu, bool *mp_exists)
     return dmp;
 }
 
+/* Release an existing mempool. */
 static void
-dpdk_mp_put(struct dpdk_mp *dmp)
+dpdk_mp_free(struct dpdk_mp *dmp)
 {
     char *mp_name;
 
@@ -608,8 +612,8 @@  dpdk_mp_put(struct dpdk_mp *dmp)
     ovs_mutex_unlock(&dpdk_mp_mutex);
 }
 
-/* Tries to allocate new mempool on requested_socket_id with
- * mbuf size corresponding to requested_mtu.
+/* Tries to allocate a new mempool on requested_socket_id with a size
+ * determined by requested_mtu and requested Rx/Tx queues.
  * On success new configuration will be applied.
  * On error, device will be left unchanged. */
 static int
@@ -636,7 +640,8 @@  netdev_dpdk_mempool_configure(struct netdev_dpdk *dev)
         dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
         return EEXIST;
     } else {
-        dpdk_mp_put(dev->dpdk_mp);
+        /* A new mempool was created, release the previous one. */
+        dpdk_mp_free(dev->dpdk_mp);
         dev->dpdk_mp = mp;
         dev->mtu = dev->requested_mtu;
         dev->socket_id = dev->requested_socket_id;
@@ -1081,7 +1086,7 @@  common_destruct(struct netdev_dpdk *dev)
     OVS_EXCLUDED(dev->mutex)
 {
     rte_free(dev->tx_q);
-    dpdk_mp_put(dev->dpdk_mp);
+    dpdk_mp_free(dev->dpdk_mp);
 
     ovs_list_remove(&dev->list_node);
     free(ovsrcu_get_protected(struct ingress_policer *,