- More improvements to the configuration module.

master
Asim Jamshed 2018-10-13 00:58:21 +00:00
parent 51fa9686be
commit c160b9f761
4 changed files with 63 additions and 39 deletions

View File

@ -17,7 +17,7 @@ io = dpdk
#num_cores = 8
# Core mask
core_mask = F000000F0
core_mask = 0000000F0
# Number of memory channels per processor socket (dpdk-only)
num_mem_ch = 4

View File

@ -21,15 +21,17 @@
/* 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";
struct mtcp_manager *g_mtcp[MAX_CPUS] = {NULL};
struct mtcp_config CONFIG = {0};
addr_pool_t ap[ETH_NUM] = {NULL};
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};
static char port_list[MAX_OPTLINE_LEN] = "";
static char port_stat_list[MAX_OPTLINE_LEN] = "";
/* total cpus detected in the mTCP stack*/
int num_cpus;
/* this should be equal to num_cpus */
@ -475,14 +477,14 @@ LoadARPTable()
numEntry = GetIntValue(p + sizeof(ARP_ENTRY));
if (numEntry <= 0) {
fprintf(stderr, "Wrong entry in arp.conf: %s\n", p);
exit(-1);
exit(EXIT_FAILURE);
}
#if 0
CONFIG.arp.entry = (struct arp_entry *)
calloc(numEntry + MAX_ARPENTRY, sizeof(struct arp_entry));
if (CONFIG.arp.entry == NULL) {
fprintf(stderr, "Wrong entry in arp.conf: %s\n", p);
exit(-1);
exit(EXIT_FAILURE);
}
#endif
hasNumEntry = 1;
@ -491,7 +493,7 @@ LoadARPTable()
fprintf(stderr,
"Error in arp.conf: more entries than "
"are specifed, entry=%s\n", p);
exit(-1);
exit(EXIT_FAILURE);
}
EnrollARPTableEntry(p);
numEntry--;
@ -521,6 +523,18 @@ SetMultiProcessSupport(char *multiprocess_details)
return 0;
}
/*----------------------------------------------------------------------------*/
static inline void
SaveInterfaceInfo(char *dev_name_list)
{
strcpy(port_list, dev_name_list);
}
/*----------------------------------------------------------------------------*/
static inline void
SaveInterfaceStatList(char *dev_name_list)
{
strcpy(port_stat_list, dev_name_list);
}
/*----------------------------------------------------------------------------*/
static int
ParseConfiguration(char *line)
{
@ -595,19 +609,12 @@ ParseConfiguration(char *line)
CONFIG.tcp_timewait = SEC_TO_USEC(CONFIG.tcp_timewait) / TIME_TICK;
}
} else if (strcmp(p, "stat_print") == 0) {
int i;
for (i = 0; i < CONFIG.eths_num; i++) {
if (strcmp(CONFIG.eths[i].dev_name, q) == 0) {
CONFIG.eths[i].stat_print = TRUE;
}
}
SaveInterfaceStatList(q);
} else if (strcmp(p, "port") == 0) {
if(strncmp(q, ALL_STRING, sizeof(ALL_STRING)) == 0) {
SetInterfaceInfo(q);
} else {
SetInterfaceInfo(line + strlen(p) + 1);
}
if(strncmp(q, ALL_STRING, sizeof(ALL_STRING)) == 0)
SaveInterfaceInfo(q);
else
SaveInterfaceInfo(line + strlen(p) + 1);
} else if (strcmp(p, "io") == 0) {
AssignIOModule(q);
if (CheckIOModuleAccessPermissions() == -1) {
@ -652,21 +659,21 @@ LoadConfiguration(const char *fname)
}
/* set default configuration */
CONFIG.num_cores = num_cpus;
CONFIG.max_concurrency = 10000;
CONFIG.max_num_buffers = 10000;
CONFIG.rcvbuf_size = -1;
CONFIG.sndbuf_size = -1;
CONFIG.tcp_timeout = TCP_TIMEOUT;
CONFIG.tcp_timewait = TCP_TIMEWAIT;
CONFIG.num_mem_ch = 0;
CONFIG.num_cores = num_cpus;
CONFIG.max_concurrency = 10000;
CONFIG.max_num_buffers = 10000;
CONFIG.rcvbuf_size = -1;
CONFIG.sndbuf_size = -1;
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;
CONFIG.onvm_serv = (uint16_t) -1;
CONFIG.onvm_inst = (uint16_t) -1;
CONFIG.onvm_dest = (uint16_t) -1;
CONFIG.onvm_serv = (uint16_t) -1;
#endif
while (1) {
char *p;
@ -707,6 +714,8 @@ LoadConfiguration(const char *fname)
if (CONFIG.rcvbuf_size == -1 && CONFIG.sndbuf_size == -1)
CONFIG.sndbuf_size = CONFIG.rcvbuf_size = 8192;
return SetNetEnv(port_list, port_stat_list);
return 0;
}
/*----------------------------------------------------------------------------*/

View File

@ -72,7 +72,7 @@ typedef struct io_module_func {
} io_module_func __attribute__((aligned(__WORDSIZE)));
/*----------------------------------------------------------------------------*/
/* set I/O module context */
int SetInterfaceInfo(char *);
int SetNetEnv(char *port_list, char *port_stat_list);
/* retrive device-specific endian type */
int FetchEndianType();

View File

@ -142,7 +142,7 @@ probe_all_rte_devices(char **argv, int *argc, char *dev_name_list)
#endif /* !DISABLE_DPDK */
/*----------------------------------------------------------------------------*/
int
SetInterfaceInfo(char* dev_name_list)
SetNetEnv(char *dev_name_list, char *port_stat_list)
{
int eidx = 0;
int i, j;
@ -240,6 +240,7 @@ SetInterfaceInfo(char* dev_name_list)
mpz_t _cpumask;
char cpumaskbuf[32];
char mem_channels[8];
char socket_mem[8];
int ret;
static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
@ -263,6 +264,15 @@ SetInterfaceInfo(char* dev_name_list)
exit(EXIT_FAILURE);
}
sprintf(mem_channels, "%d", CONFIG.num_mem_ch);
/* get socket memory threshold (in MB) */
sprintf(socket_mem, "%d",
(CONFIG.num_cores *
(CONFIG.rcvbuf_size +
CONFIG.sndbuf_size) *
CONFIG.max_concurrency) >> 19);
TRACE_DBG("socket_mem: %s\n", socket_mem);
/* initialize the rte env first, what a waste of implementation effort! */
#ifdef CONTAINERIZED_SUPPORT
int argc = 8;
@ -276,6 +286,7 @@ SetInterfaceInfo(char* dev_name_list)
mem_channels,
#ifdef CONTAINERIZED_SUPPORT
"--socket-mem",
//socket_mem,
"1024",
#endif
"--proc-type=auto"
@ -465,7 +476,7 @@ SetInterfaceInfo(char* dev_name_list)
ETH_ALEN))
CONFIG.eths[eidx].ifindex = ifr.ifr_ifindex;
#endif
CONFIG.eths[eidx].ifindex = eidx;//if_nametoindex(ifr.ifr_name);
CONFIG.eths[eidx].ifindex = eidx;
TRACE_INFO("Ifindex of interface %s is: %d\n",
ifr.ifr_name, CONFIG.eths[eidx].ifindex);
#if 0
@ -478,7 +489,7 @@ SetInterfaceInfo(char* dev_name_list)
break;
}
}
devices_attached[num_devices_attached] = if_nametoindex(ifr.ifr_name);//CONFIG.eths[eidx].ifindex;
devices_attached[num_devices_attached] = if_nametoindex(ifr.ifr_name);
num_devices_attached++;
fprintf(stderr, "Total number of attached devices: %d\n",
num_devices_attached);
@ -642,6 +653,10 @@ SetInterfaceInfo(char* dev_name_list)
/* the physic port index of the i-th port listed in the config file is j*/
CONFIG.nif_to_eidx[j] = i;
/* finally set the port stats option `on' */
if (strcmp(CONFIG.eths[i].dev_name, port_stat_list) == 0)
CONFIG.eths[i].stat_print = TRUE;
}
return 0;