diff --git a/config.ini b/config.ini index f9901e64..6aa53d89 100644 --- a/config.ini +++ b/config.ini @@ -1,12 +1,21 @@ [dpdk] -## Hexadecimal bitmask of cores to run on. +# Hexadecimal bitmask of cores to run on. lcore_mask=1 + +# Number of memory channels. channel=4 + +# Specify base virtual address to map. +#base_virtaddr=0x7f0000000000 + +# Promiscuous mode of nic, defualt: enabled. promiscuous=1 numa_on=1 -## TCP segment offload, default: disabled. + +# TCP segment offload, default: disabled. tso=0 -## HW vlan strip, default: enabled. + +# HW vlan strip, default: enabled. vlan_strip=1 # sleep when no pkts incomming @@ -27,40 +36,40 @@ idle_sleep=100 # 1-3,4,7 ports 1,2,3,4,7 are enabled port_list=0 -## Port config section -## Correspond to dpdk.port_list's index: port0, port1... +# Port config section +# Correspond to dpdk.port_list's index: port0, port1... [port0] addr=192.168.1.2 netmask=255.255.255.0 broadcast=192.168.1.255 gateway=192.168.1.1 -## lcore list used to handle this port -## the format is same as port_list +# lcore list used to handle this port +# the format is same as port_list # lcore_list= 0 -## Packet capture path, this will hurt performance +# Packet capture path, this will hurt performance #pcap=./a.pcap -## Kni config: if enabled and method=reject, -## all packets that do not belong to the following tcp_port and udp_port -## will transmit to kernel; if method=accept, all packets that belong to -## the following tcp_port and udp_port will transmit to kernel. +# Kni config: if enabled and method=reject, +# all packets that do not belong to the following tcp_port and udp_port +# will transmit to kernel; if method=accept, all packets that belong to +# the following tcp_port and udp_port will transmit to kernel. #[kni] #enable=1 #method=reject -## The format is same as port_list +# The format is same as port_list #tcp_port=80,443 #udp_port=53 -## FreeBSD network performance tuning configurations. -## Most native FreeBSD configurations are supported. +# FreeBSD network performance tuning configurations. +# Most native FreeBSD configurations are supported. [freebsd.boot] hz=100 -## Block out a range of descriptors to avoid overlap -## with the kernel's descriptor space. -## You can increase this value according to your app. +# Block out a range of descriptors to avoid overlap +# with the kernel's descriptor space. +# You can increase this value according to your app. fd_reserve=1024 kern.ipc.maxsockets=262144 diff --git a/lib/ff_config.c b/lib/ff_config.c index 9ebc7c91..d9a2f6f6 100644 --- a/lib/ff_config.c +++ b/lib/ff_config.c @@ -420,6 +420,8 @@ ini_parse_handler(void* user, const char* section, const char* name, } else if (MATCH("dpdk", "lcore_mask")) { pconfig->dpdk.lcore_mask = strdup(value); return parse_lcore_mask(pconfig, pconfig->dpdk.lcore_mask); + } else if (MATCH("dpdk", "base_virtaddr")) { + pconfig->dpdk.base_virtaddr= strdup(value); } else if (MATCH("dpdk", "port_list")) { return parse_port_list(pconfig, value); } else if (MATCH("dpdk", "promiscuous")) { @@ -485,6 +487,10 @@ dpdk_args_setup(struct ff_config *cfg) sprintf(temp, "--proc-type=%s", cfg->dpdk.proc_type); dpdk_argv[n++] = strdup(temp); } + if (cfg->dpdk.base_virtaddr) { + sprintf(temp, "--base-virtaddr=%s", cfg->dpdk.base_virtaddr); + dpdk_argv[n++] = strdup(temp); + } dpdk_argc = n; @@ -520,7 +526,7 @@ ff_parse_args(struct ff_config *cfg, int argc, char *const argv[]) if (strcmp(cfg->dpdk.proc_type, "primary") && strcmp(cfg->dpdk.proc_type, "secondary") && strcmp(cfg->dpdk.proc_type, "auto")) { - printf("invalid proc-type\n"); + printf("invalid proc-type:%s\n", cfg->dpdk.proc_type); return -1; } diff --git a/lib/ff_config.h b/lib/ff_config.h index 6424b0da..2ecaf1f5 100644 --- a/lib/ff_config.h +++ b/lib/ff_config.h @@ -79,6 +79,9 @@ struct ff_config { /* mask of current proc on all lcores */ char *proc_mask; + /* specify base virtual address to map. */ + char *base_virtaddr; + int nb_channel; int memory; int no_huge; diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index dcf2b44d..1d10516f 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -419,18 +419,21 @@ create_ring(const char *name, unsigned count, int socket_id, unsigned flags) { struct rte_ring *ring; - if (name == NULL) - return NULL; - - /* If already create, just attached it */ - if (likely((ring = rte_ring_lookup(name)) != NULL)) - return ring; + if (name == NULL) { + rte_exit(EXIT_FAILURE, "create ring failed, no name!\n"); + } if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - return rte_ring_create(name, count, socket_id, flags); + ring = rte_ring_create(name, count, socket_id, flags); } else { - return rte_ring_lookup(name); + ring = rte_ring_lookup(name); } + + if (ring == NULL) { + rte_exit(EXIT_FAILURE, "create ring:%s failed!\n", name); + } + + return ring; } static int