Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dpdk: fix minor problems when starting with DPDK runmode #9286

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/runmode-dpdk.c
Expand Up @@ -357,7 +357,6 @@ static int ConfigSetThreads(DPDKIfaceConfig *iconf, const char *entry_str)
{
SCEnter();
static int32_t remaining_auto_cpus = -1;
static uint32_t total_cpus = 0;
if (!threading_set_cpu_affinity) {
SCLogError("DPDK runmode requires configured thread affinity");
SCReturnInt(-EINVAL);
Expand Down Expand Up @@ -432,12 +431,6 @@ static int ConfigSetThreads(DPDKIfaceConfig *iconf, const char *entry_str)
SCReturnInt(-ERANGE);
}

total_cpus += iconf->threads;
if (total_cpus > sched_cpus) {
SCLogError("Interfaces requested more cores than configured in the threading section");
SCReturnInt(-ERANGE);
}

SCReturnInt(0);
}

Expand Down Expand Up @@ -801,6 +794,25 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface)
SCReturnInt(0);
}

static int32_t ConfigValidateThreads(uint16_t iface_threads)
{
static uint32_t total_cpus = 0;
total_cpus += iface_threads;
ThreadsAffinityType *wtaf = GetAffinityTypeFromName("worker-cpu-set");
if (wtaf == NULL) {
SCLogError("Specify worker-cpu-set list in the threading section");
return -1;
}
if (total_cpus > UtilAffinityGetAffinedCPUNum(wtaf)) {
SCLogError("Interfaces requested more cores than configured in the threading section "
"(requested %d configured %d",
total_cpus, UtilAffinityGetAffinedCPUNum(wtaf));
return -1;
}

return 0;
}

static DPDKIfaceConfig *ConfigParse(const char *iface)
{
SCEnter();
Expand All @@ -811,7 +823,7 @@ static DPDKIfaceConfig *ConfigParse(const char *iface)

ConfigInit(&iconf);
retval = ConfigLoad(iconf, iface);
if (retval < 0) {
if (retval < 0 || ConfigValidateThreads(iconf->threads) != 0) {
iconf->DerefFunc(iconf);
SCReturnPtr(NULL, "void *");
}
Expand Down Expand Up @@ -1061,7 +1073,7 @@ static void DeviceSetMTU(struct rte_eth_conf *port_conf, uint16_t mtu)
/**
* \param port_id - queried port
* \param socket_id - socket ID of the queried port
* \return positive number on success, negative on failure (errno)
* \return non-negative number on success, negative on failure (errno)
*/
static int32_t DeviceSetSocketID(uint16_t port_id, int32_t *socket_id)
{
Expand All @@ -1071,6 +1083,9 @@ static int32_t DeviceSetSocketID(uint16_t port_id, int32_t *socket_id)

#if RTE_VERSION >= RTE_VERSION_NUM(22, 11, 0, 0) // DPDK API changed since 22.11
retval = -rte_errno;
#else
if (retval == SOCKET_ID_ANY)
retval = 0; // DPDK couldn't determine socket ID of a port
#endif

return retval;
Expand Down
7 changes: 3 additions & 4 deletions src/source-dpdk.c
Expand Up @@ -547,11 +547,10 @@ static TmEcode ReceiveDPDKThreadInit(ThreadVars *tv, const void *initdata, void
DevicePostStartPMDSpecificActions(ptv, dev_info.driver_name);

uint16_t inconsistent_numa_cnt = SC_ATOMIC_GET(dpdk_config->inconsitent_numa_cnt);
if (inconsistent_numa_cnt > 0) {
if (inconsistent_numa_cnt > 0 && ptv->port_socket_id != SOCKET_ID_ANY) {
SCLogWarning("%s: NIC is on NUMA %d, %u threads on different NUMA node(s)",
dpdk_config->iface, rte_eth_dev_socket_id(ptv->port_id), inconsistent_numa_cnt);
}
if (ptv->port_socket_id == SOCKET_ID_ANY) {
dpdk_config->iface, ptv->port_socket_id, inconsistent_numa_cnt);
} else if (ptv->port_socket_id == SOCKET_ID_ANY) {
SCLogNotice(
"%s: unable to determine NIC's NUMA node, degraded performance can be expected",
dpdk_config->iface);
Expand Down