[ovs-dev,v2] netdev-dpdk: Remove uneeded call to rte_eth_dev_count().

Message ID 1511803549-17488-1-git-send-email-ktraynor@redhat.com
State Accepted
Delegated to: Ian Stokes
Headers show
Series
  • [ovs-dev,v2] netdev-dpdk: Remove uneeded call to rte_eth_dev_count().
Related show

Commit Message

Kevin Traynor Nov. 27, 2017, 5:25 p.m.
The call to rte_eth_dev_count() was added as workaround
for rte_eth_dev_get_port_by_name() not handling cases
when there was no DPDK ports.

In versions of DPDK >= 17.02 rte_eth_dev_get_port_by_name()
does handle this case (DPDK commit f9ae888b1e19).
rte_eth_dev_count() is no longer needed so remove it.

Acked-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---
 lib/netdev-dpdk.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Stokes, Ian Nov. 30, 2017, 1:07 a.m. | #1
> The call to rte_eth_dev_count() was added as workaround for
> rte_eth_dev_get_port_by_name() not handling cases when there was no DPDK
> ports.
> 
> In versions of DPDK >= 17.02 rte_eth_dev_get_port_by_name() does handle
> this case (DPDK commit f9ae888b1e19).
> rte_eth_dev_count() is no longer needed so remove it.
> 
> Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
> ---
>  lib/netdev-dpdk.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index faff842..0436ff0
> 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -1192,6 +1192,5 @@ netdev_dpdk_process_devargs(struct netdev_dpdk *dev,
>      dpdk_port_t new_port_id = DPDK_ETH_PORT_ID_INVALID;
> 
> -    if (!rte_eth_dev_count()
> -            || rte_eth_dev_get_port_by_name(name, &new_port_id)
> +    if (rte_eth_dev_get_port_by_name(name, &new_port_id)
>              || !rte_eth_dev_is_valid_port(new_port_id)) {
>          /* Device not found in DPDK, attempt to attach it */ @@ -2526,6
> +2525,5 @@ netdev_dpdk_detach(struct unixctl_conn *conn, int argc
> OVS_UNUSED,
>      ovs_mutex_lock(&dpdk_mutex);
> 
> -    if (!rte_eth_dev_count() || rte_eth_dev_get_port_by_name(argv[1],
> -                                                             &port_id)) {
> +    if (rte_eth_dev_get_port_by_name(argv[1], &port_id)) {
>          response = xasprintf("Device '%s' not found in DPDK", argv[1]);
>          goto error;

Thanks for this, quick review seems Ok but hope to validate and push to dpdk merge branch tomorrow if no issues arise.

Thanks
Ian
> --
> 1.8.3.1
> 
> _______________________________________________
> 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 faff842..0436ff0 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1192,6 +1192,5 @@  netdev_dpdk_process_devargs(struct netdev_dpdk *dev,
     dpdk_port_t new_port_id = DPDK_ETH_PORT_ID_INVALID;
 
-    if (!rte_eth_dev_count()
-            || rte_eth_dev_get_port_by_name(name, &new_port_id)
+    if (rte_eth_dev_get_port_by_name(name, &new_port_id)
             || !rte_eth_dev_is_valid_port(new_port_id)) {
         /* Device not found in DPDK, attempt to attach it */
@@ -2526,6 +2525,5 @@  netdev_dpdk_detach(struct unixctl_conn *conn, int argc OVS_UNUSED,
     ovs_mutex_lock(&dpdk_mutex);
 
-    if (!rte_eth_dev_count() || rte_eth_dev_get_port_by_name(argv[1],
-                                                             &port_id)) {
+    if (rte_eth_dev_get_port_by_name(argv[1], &port_id)) {
         response = xasprintf("Device '%s' not found in DPDK", argv[1]);
         goto error;