X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_dpdk.c;h=e3c737931a01f2f3c2a3084efb5eb8c222cc9d11;hb=57b9e83320b35d4dbd1312db5fbf33ddf8ecd989;hp=640f08bc0f49dd1159e7d2ec7f649474e2f4411a;hpb=446138394bb95c49d0e05ea440fbf63aefe84bab;p=collectd.git diff --git a/src/utils_dpdk.c b/src/utils_dpdk.c index 640f08bc..e3c73793 100644 --- a/src/utils_dpdk.c +++ b/src/utils_dpdk.c @@ -38,6 +38,7 @@ #include #include +#include #include "common.h" #include "utils_dpdk.h" @@ -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; +}