net/mlx5: limit LRO size to maximum Rx packet
[dpdk.git] / lib / librte_distributor / rte_distributor.c
index 9eb78b3..9fa05f6 100644 (file)
@@ -14,6 +14,7 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_pause.h>
+#include <rte_tailq.h>
 
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
@@ -595,6 +596,12 @@ rte_distributor_create_v1705(const char *name,
        RTE_BUILD_BUG_ON((sizeof(*d) & RTE_CACHE_LINE_MASK) != 0);
        RTE_BUILD_BUG_ON((RTE_DISTRIB_MAX_WORKERS & 7) != 0);
 
+       if (name == NULL || num_workers >=
+               (unsigned int)RTE_MIN(RTE_DISTRIB_MAX_WORKERS, RTE_MAX_LCORE)) {
+               rte_errno = EINVAL;
+               return NULL;
+       }
+
        if (alg_type == RTE_DIST_ALG_SINGLE) {
                d = malloc(sizeof(struct rte_distributor));
                if (d == NULL) {
@@ -612,11 +619,6 @@ rte_distributor_create_v1705(const char *name,
                return d;
        }
 
-       if (name == NULL || num_workers >= RTE_DISTRIB_MAX_WORKERS) {
-               rte_errno = EINVAL;
-               return NULL;
-       }
-
        snprintf(mz_name, sizeof(mz_name), RTE_DISTRIB_PREFIX"%s", name);
        mz = rte_memzone_reserve(mz_name, sizeof(*d), socket_id, NO_FLAGS);
        if (mz == NULL) {