- Adding preliminary (experimental) support of VFs.

- Added "core_mask" configuration option to lift core affinitization 0-up restriction
	- Now you can spawn mTCP/app threads on any core.
master
Asim Jamshed 2018-10-09 00:01:23 +00:00
parent 58fe724c9c
commit 0700a128fb
11 changed files with 87 additions and 43 deletions

View File

@ -27,9 +27,8 @@ multiprocess = 1
#port = xge1
#------ DPDK ports -------#
port = dpdk0
#port = dpdk1
#port = dpdk0 dpdk1
#port = dpdk0:0
#port = dpdk0:1
# Maximum concurrency per core (default = 10000)
#max_concurrency = 10000
@ -60,8 +59,6 @@ tcp_timewait = 0
#stat_print = xge1
#------ DPDK ports -------#
stat_print = dpdk0
#stat_print = dpdk0:0
#stat_print = dpdk0:1
#stat_print = dpdk1
#######################################################

View File

@ -16,6 +16,9 @@ io = dpdk
# following line is uncommented.
#num_cores = 8
# Core mask
core_mask = F000000F0
# Number of memory channels per processor socket (dpdk-only)
num_mem_ch = 4
@ -46,9 +49,8 @@ num_mem_ch = 4
#port = xge1
#------ DPDK ports -------#
port = dpdk0
#port = dpdk1
#port = dpdk0 dpdk1
#port = dpdk0:0
#port = dpdk0:1
# Maximum concurrency per core (default = 10000)
#max_concurrency = 10000
@ -79,8 +81,6 @@ tcp_timewait = 0
#stat_print = xge1
#------ DPDK ports -------#
stat_print = dpdk0
#stat_print = dpdk0:0
#stat_print = dpdk0:1
#stat_print = dpdk1
#######################################################

View File

@ -26,9 +26,8 @@ multiprocess = 1
#port = xge1
#------ DPDK ports -------#
port = dpdk0
#port = dpdk1
#port = dpdk0 dpdk1
#port = dpdk0:0
#port = dpdk0:1
# Maximum concurrency per core (default = 10000)
#max_concurrency = 10000
@ -59,8 +58,6 @@ tcp_timewait = 0
#stat_print = xge1
#------ DPDK ports -------#
stat_print = dpdk0
#stat_print = dpdk0:0
#stat_print = dpdk0:1
#stat_print = dpdk1
#######################################################

View File

@ -34,16 +34,14 @@ num_mem_ch = 4
#onvm_serv = 1
#--------------------------#
# Used port (please adjust accordingly)
#------ PSIO ports -------#
#port = xge0 xge1
#port = xge1
#------ DPDK ports -------#
port = dpdk0
#port = dpdk1
#port = dpdk0 dpdk1
#port = dpdk0:0
#port = dpdk0:1
# Enable multi-process support
#multiprocess = 1

View File

@ -38,9 +38,8 @@ num_mem_ch = 4
#port = xge1
#------ DPDK ports -------#
port = dpdk0
#port = dpdk0 dpdk1
#port = dpdk0
#port = dpdk1
#port = dpdk0 dpdk1
# Maximum concurrency per core (default = 10000)
#max_concurrency = 10000

View File

@ -21,15 +21,15 @@
/* for if_nametoindex */
#include <net/if.h>
#define MAX_ROUTE_ENTRY 64
#define MAX_OPTLINE_LEN 1024
#define ALL_STRING "all"
#define MAX_ROUTE_ENTRY 64
#define MAX_OPTLINE_LEN 1024
#define ALL_STRING "all"
static const char *route_file = "config/route.conf";
static const char *arp_file = "config/arp.conf";
static const char *route_file = "config/route.conf";
static const char *arp_file = "config/arp.conf";
struct mtcp_manager *g_mtcp[MAX_CPUS] = {NULL};
struct mtcp_config CONFIG = {0};
addr_pool_t ap[ETH_NUM] = {NULL};
struct mtcp_config CONFIG = {0};
addr_pool_t ap[ETH_NUM] = {NULL};
/* total cpus detected in the mTCP stack*/
int num_cpus;
/* this should be equal to num_cpus */
@ -556,6 +556,10 @@ ParseConfiguration(char *line)
return -1;
}
num_cpus = CONFIG.num_cores;
} else if (strcmp(p, "core_mask") == 0) {
#ifndef DISABLE_DPDK
mpz_set_str(CONFIG._cpumask, q, 16);
#endif
} else if (strcmp(p, "max_concurrency") == 0) {
CONFIG.max_concurrency = mystrtol(q, 10);
if (CONFIG.max_concurrency < 0) {
@ -656,6 +660,9 @@ LoadConfiguration(const char *fname)
CONFIG.tcp_timeout = TCP_TIMEOUT;
CONFIG.tcp_timewait = TCP_TIMEWAIT;
CONFIG.num_mem_ch = 0;
#ifndef DISABLE_DPDK
mpz_init(CONFIG._cpumask);
#endif
#ifdef ENABLE_ONVM
CONFIG.onvm_inst = (uint16_t) -1;
CONFIG.onvm_dest = (uint16_t) -1;

View File

@ -1180,8 +1180,8 @@ mtcp_create_context(int cpu)
if (cpu >= CONFIG.num_cores) {
TRACE_ERROR("Failed initialize new mtcp context. "
"Requested cpu id %d exceed the number of cores %d configured to use.\n",
cpu, CONFIG.num_cores);
"Requested cpu id %d exceed the number of cores %d configured to use.\n",
cpu, CONFIG.num_cores);
return NULL;
}
@ -1229,7 +1229,7 @@ mtcp_create_context(int cpu)
int master;
master = rte_get_master_lcore();
if (master == cpu) {
if (master == whichCoreID(cpu)) {
lcore_config[master].ret = 0;
lcore_config[master].state = FINISHED;
@ -1239,7 +1239,7 @@ mtcp_create_context(int cpu)
return NULL;
}
} else
rte_eal_remote_launch(MTCPDPDKRunThread, mctx, cpu);
rte_eal_remote_launch(MTCPDPDKRunThread, mctx, whichCoreID(cpu));
} else
#endif
{
@ -1553,6 +1553,9 @@ mtcp_destroy()
for (i = 0; i < CONFIG.eths_num; i++)
DestroyAddressPool(ap[i]);
#ifndef DISABLE_DPDK
mpz_clear(CONFIG._cpumask);
#endif
TRACE_INFO("All MTCP threads are joined.\n");
}
/*----------------------------------------------------------------------------*/

View File

@ -16,6 +16,8 @@
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_lcore.h>
#include <gmp.h>
#include <mtcp.h>
#endif
#define MAX_FILE_NAME 1024
@ -33,6 +35,27 @@ Gettid()
return syscall(__NR_gettid);
}
/*----------------------------------------------------------------------------*/
inline int
whichCoreID(int thread_no)
{
#ifndef DISABLE_DPDK
int i, cpu_id;
if (mpz_get_ui(CONFIG._cpumask) == 0)
return thread_no;
else {
int limit = mpz_popcount(CONFIG._cpumask);
for (cpu_id = 0, i = 0; i < limit; cpu_id++)
if (mpz_tstbit(CONFIG._cpumask, cpu_id)) {
if (thread_no == i)
return cpu_id;
i++;
}
}
#endif
return thread_no;
}
/*----------------------------------------------------------------------------*/
int
mtcp_core_affinitize(int cpu)
{
@ -42,6 +65,8 @@ mtcp_core_affinitize(int cpu)
n = GetNumCPUs();
cpu = whichCoreID(cpu);
if (cpu < 0 || cpu >= (int) n) {
errno = -EINVAL;
return -1;

View File

@ -3,4 +3,6 @@
int GetNumCPUs();
inline int whichCoreID(int thread_no);
#endif /* CPU_H */

View File

@ -6,6 +6,9 @@
#include <sys/time.h>
#include <sys/queue.h>
#include <pthread.h>
#ifndef DISABLE_DPDK
#include <gmp.h>
#endif
#include "memory_mgt.h"
#include "tcp_ring_buffer.h"
@ -150,6 +153,9 @@ struct mtcp_config
int num_cores;
int num_mem_ch;
int max_concurrency;
#ifndef DISABLE_DPDK
mpz_t _cpumask;
#endif
int max_num_buffers;
int rcvbuf_size;

View File

@ -238,18 +238,22 @@ SetInterfaceInfo(char* dev_name_list)
#ifndef DISABLE_DPDK
int cpu = CONFIG.num_cores;
mpz_t _cpumask;
char cpumaskbuf[30];
char mem_channels[5];
char cpumaskbuf[32];
char mem_channels[8];
int ret;
static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
mpz_init(_cpumask);
/* get the cpu mask */
for (ret = 0; ret < cpu; ret++)
mpz_setbit(_cpumask, ret);
gmp_sprintf(cpumaskbuf, "%ZX", _cpumask);
if (!mpz_cmp(_cpumask, CONFIG._cpumask)) {
/* get the cpu mask */
for (ret = 0; ret < cpu; ret++)
mpz_setbit(_cpumask, ret);
gmp_sprintf(cpumaskbuf, "%ZX", _cpumask);
} else
gmp_sprintf(cpumaskbuf, "%ZX", CONFIG._cpumask);
mpz_clear(_cpumask);
/* get the mem channels per socket */
@ -291,12 +295,15 @@ SetInterfaceInfo(char* dev_name_list)
/* initialize the dpdk eal env */
ret = rte_eal_init(argc, argv);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Invalid EAL args!\n");
if (ret < 0) {
TRACE_ERROR("Invalid EAL args!\n");
exit(EXIT_FAILURE);
}
/* give me the count of 'detected' ethernet ports */
num_devices = rte_eth_dev_count();
if (num_devices == 0) {
rte_exit(EXIT_FAILURE, "No Ethernet port!\n");
TRACE_ERROR("No Ethernet port!\n");
exit(EXIT_FAILURE);
}
/* get mac addr entries of 'detected' dpdk ports */
@ -487,8 +494,8 @@ SetInterfaceInfo(char* dev_name_list)
#ifdef ENABLE_ONVM
int cpu = CONFIG.num_cores;
mpz_t cpumask;
char cpumaskbuf[30];
char mem_channels[5];
char cpumaskbuf[32];
char mem_channels[8];
char service[6];
char instance[6];
int ret;
@ -541,12 +548,15 @@ SetInterfaceInfo(char* dev_name_list)
/* initialize the dpdk eal env */
ret = onvm_nflib_init(argc, argv, "mtcp_nf");
if (ret < 0)
rte_exit(EXIT_FAILURE, "Invalid EAL args!\n");
if (ret < 0) {
TRACE_ERROR("Invalid EAL args!\n");
exit(EXIT_FAILURE);
}
/* give me the count of 'detected' ethernet ports */
num_devices = ports->num_ports;
if (num_devices == 0) {
rte_exit(EXIT_FAILURE, "No Ethernet port!\n");
TRACE_ERROR("No Ethernet port!\n");
exit(EXIT_FAILURE);
}
num_queues = MIN(CONFIG.num_cores, MAX_CPUS);