@@ -14,6 +14,8 @@
extern "C" {
#endif
+#define RTE_DEFAULT_SIMD_BITWIDTH RTE_SIMD_MAX
+
typedef int32x4_t xmm_t;
#define XMM_SIZE (sizeof(xmm_t))
@@ -35,6 +35,7 @@
#ifndef RTE_EXEC_ENV_WINDOWS
#include <rte_telemetry.h>
#endif
+#include <rte_vect.h>
#include "eal_internal_cfg.h"
#include "eal_options.h"
@@ -102,6 +103,7 @@ eal_long_options[] = {
{OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM},
{OPT_TELEMETRY, 0, NULL, OPT_TELEMETRY_NUM },
{OPT_NO_TELEMETRY, 0, NULL, OPT_NO_TELEMETRY_NUM },
+ {OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM},
{0, 0, NULL, 0 }
};
@@ -343,6 +345,8 @@ eal_reset_internal_config(struct internal_config *internal_cfg)
internal_cfg->user_mbuf_pool_ops_name = NULL;
CPU_ZERO(&internal_cfg->ctrl_cpuset);
internal_cfg->init_complete = 0;
+ internal_cfg->max_simd_bitwidth.bitwidth = RTE_DEFAULT_SIMD_BITWIDTH;
+ internal_cfg->max_simd_bitwidth.forced = 0;
}
static int
@@ -1309,6 +1313,34 @@ eal_parse_iova_mode(const char *name)
return 0;
}
+static int
+eal_parse_simd_bitwidth(const char *arg)
+{
+ char *end;
+ unsigned long bitwidth;
+ int ret;
+ struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+
+ if (arg == NULL || arg[0] == '\0')
+ return -1;
+
+ errno = 0;
+ bitwidth = strtoul(arg, &end, 0);
+
+ /* check for errors */
+ if (errno != 0 || end == NULL || *end != '\0' || bitwidth > RTE_SIMD_MAX)
+ return -1;
+
+ if (bitwidth == 0)
+ bitwidth = (unsigned long) RTE_SIMD_MAX;
+ ret = rte_set_max_simd_bitwidth(bitwidth);
+ if (ret < 0)
+ return -1;
+ internal_conf->max_simd_bitwidth.forced = 1;
+ return 0;
+}
+
static int
eal_parse_base_virtaddr(const char *arg)
{
@@ -1707,6 +1739,13 @@ eal_parse_common_option(int opt, const char *optarg,
case OPT_NO_TELEMETRY_NUM:
conf->no_telemetry = 1;
break;
+ case OPT_FORCE_MAX_SIMD_BITWIDTH_NUM:
+ if (eal_parse_simd_bitwidth(optarg) < 0) {
+ RTE_LOG(ERR, EAL, "invalid parameter for --"
+ OPT_FORCE_MAX_SIMD_BITWIDTH "\n");
+ return -1;
+ }
+ break;
/* don't know what to do, leave this to caller */
default:
@@ -1903,6 +1942,32 @@ eal_check_common_options(struct internal_config *internal_cfg)
return 0;
}
+uint16_t
+rte_get_max_simd_bitwidth(void)
+{
+ const struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+ return internal_conf->max_simd_bitwidth.bitwidth;
+}
+
+int
+rte_set_max_simd_bitwidth(uint16_t bitwidth)
+{
+ struct internal_config *internal_conf =
+ eal_get_internal_configuration();
+ if (internal_conf->max_simd_bitwidth.forced) {
+ RTE_LOG(NOTICE, EAL, "Cannot set max SIMD bitwidth - user runtime override enabled");
+ return -EPERM;
+ }
+
+ if (bitwidth < RTE_SIMD_DISABLED || !rte_is_power_of_2(bitwidth)) {
+ RTE_LOG(ERR, EAL, "Invalid bitwidth value!\n");
+ return -EINVAL;
+ }
+ internal_conf->max_simd_bitwidth.bitwidth = bitwidth;
+ return 0;
+}
+
void
eal_common_usage(void)
{
@@ -1981,6 +2046,7 @@ eal_common_usage(void)
" --"OPT_BASE_VIRTADDR" Base virtual address\n"
" --"OPT_TELEMETRY" Enable telemetry support (on by default)\n"
" --"OPT_NO_TELEMETRY" Disable telemetry support\n"
+ " --"OPT_FORCE_MAX_SIMD_BITWIDTH" Force the max SIMD bitwidth\n"
"\nEAL options for DEBUG use only:\n"
" --"OPT_HUGE_UNLINK" Unlink hugepage files after init\n"
" --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n"
@@ -33,6 +33,12 @@ struct hugepage_info {
int lock_descriptor; /**< file descriptor for hugepage dir */
};
+struct simd_bitwidth {
+ bool forced;
+ /**< flag indicating if bitwidth is forced and can't be modified */
+ uint16_t bitwidth; /**< bitwidth value */
+};
+
/**
* internal configuration
*/
@@ -85,6 +91,8 @@ struct internal_config {
volatile unsigned int init_complete;
/**< indicates whether EAL has completed initialization */
unsigned int no_telemetry; /**< true to disable Telemetry */
+ struct simd_bitwidth max_simd_bitwidth;
+ /**< max simd bitwidth path to use */
};
void eal_reset_internal_config(struct internal_config *internal_cfg);
@@ -85,6 +85,8 @@ enum {
OPT_TELEMETRY_NUM,
#define OPT_NO_TELEMETRY "no-telemetry"
OPT_NO_TELEMETRY_NUM,
+#define OPT_FORCE_MAX_SIMD_BITWIDTH "force-max-simd-bitwidth"
+ OPT_FORCE_MAX_SIMD_BITWIDTH_NUM,
OPT_LONG_MAX_NUM
};
@@ -43,6 +43,23 @@ enum rte_proc_type_t {
RTE_PROC_INVALID
};
+/**
+ * The max SIMD bitwidth value to limit vector path selection.
+ */
+enum rte_max_simd {
+ RTE_SIMD_DISABLED = 64,
+ /**< Limits path selection to scalar, disables all vector paths. */
+ RTE_SIMD_128 = 128,
+ /**< Limits path selection to SSE/NEON/Altivec or below. */
+ RTE_SIMD_256 = 256, /**< Limits path selection to AVX2 or below. */
+ RTE_SIMD_512 = 512, /**< Limits path selection to AVX512 or below. */
+ RTE_SIMD_MAX = INT16_MAX + 1,
+ /**<
+ * Disables limiting by max SIMD bitwidth, allows all suitable paths.
+ * This value is used as it is a large number and a power of 2.
+ */
+};
+
/**
* Get the process type in a multi-process setup
*
@@ -51,6 +68,29 @@ enum rte_proc_type_t {
*/
enum rte_proc_type_t rte_eal_process_type(void);
+/**
+ * Get the supported SIMD bitwidth.
+ *
+ * @return
+ * uint16_t bitwidth.
+ */
+__rte_experimental
+uint16_t rte_get_max_simd_bitwidth(void);
+
+/**
+ * Set the supported SIMD bitwidth.
+ * This API should only be called once at initialization, before EAL init.
+ *
+ * @param bitwidth
+ * uint16_t bitwidth.
+ * @return
+ * - 0 on success.
+ * - -EINVAL on invalid bitwidth parameter.
+ * - -EPERM if bitwidth is forced.
+ */
+__rte_experimental
+int rte_set_max_simd_bitwidth(uint16_t bitwidth);
+
/**
* Request iopl privilege for all RPL.
*
@@ -15,6 +15,8 @@
extern "C" {
#endif
+#define RTE_DEFAULT_SIMD_BITWIDTH RTE_SIMD_256
+
typedef vector signed int xmm_t;
#define XMM_SIZE (sizeof(xmm_t))
@@ -26,6 +26,7 @@ EXPORTS
rte_eal_tailq_register
rte_eal_using_phys_addrs
rte_free
+ rte_get_max_simd_bitwidth
rte_get_tsc_hz
rte_hexdump
rte_intr_rx_ctl
@@ -62,6 +63,7 @@ EXPORTS
rte_memzone_reserve_aligned
rte_memzone_reserve_bounded
rte_memzone_walk
+ rte_set_max_simd_bitwidth
rte_socket_id
rte_strerror
rte_strsplit
@@ -400,6 +400,8 @@ EXPERIMENTAL {
# added in 20.11
__rte_eal_trace_generic_size_t;
rte_service_lcore_may_be_active;
+ rte_get_max_simd_bitwidth;
+ rte_set_max_simd_bitwidth;
};
INTERNAL {
@@ -35,6 +35,8 @@
extern "C" {
#endif
+#define RTE_DEFAULT_SIMD_BITWIDTH RTE_SIMD_256
+
typedef __m128i xmm_t;
#define XMM_SIZE (sizeof(xmm_t))