Remove parentheses around return arguments
[collectd.git] / src / utils_dpdk.c
index 640f08b..3a30438 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <rte_config.h>
 #include <rte_eal.h>
+#include <rte_ethdev.h>
 
 #include "common.h"
 #include "utils_dpdk.h"
@@ -263,7 +264,7 @@ int dpdk_helper_data_size_get(dpdk_helper_ctx_t *phc) {
     return -EINVAL;
   }
 
-  return (phc->shm_size - sizeof(dpdk_helper_ctx_t));
+  return phc->shm_size - sizeof(dpdk_helper_ctx_t);
 }
 
 int dpdk_helper_init(const char *name, size_t data_size,
@@ -850,3 +851,22 @@ uint128_t str_to_uint128(const char *str, int len) {
   }
   return lcore_mask;
 }
+
+uint8_t dpdk_helper_eth_dev_count() {
+  uint8_t ports = rte_eth_dev_count();
+  if (ports == 0) {
+    ERROR(
+        "%s:%d: No DPDK ports available. Check bound devices to DPDK driver.\n",
+        __FUNCTION__, __LINE__);
+    return ports;
+  }
+
+  if (ports > RTE_MAX_ETHPORTS) {
+    ERROR("%s:%d: Number of DPDK ports (%u) is greater than "
+          "RTE_MAX_ETHPORTS=%d. Ignoring extra ports\n",
+          __FUNCTION__, __LINE__, ports, RTE_MAX_ETHPORTS);
+    ports = RTE_MAX_ETHPORTS;
+  }
+
+  return ports;
+}