Skip to content

Commit 6d20afb

Browse files
author
root
committed
add base_virtaddr config.
1 parent c605f59 commit 6d20afb

File tree

5 files changed

+59
-38
lines changed

5 files changed

+59
-38
lines changed

config.ini

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
[dpdk]
2-
## Hexadecimal bitmask of cores to run on.
2+
# Hexadecimal bitmask of cores to run on.
33
lcore_mask=1
4+
5+
# Number of memory channels.
46
channel=4
7+
8+
# Specify base virtual address to map.
9+
#base_virtaddr=0x7f0000000000
10+
11+
# Promiscuous mode of nic, defualt: enabled.
512
promiscuous=1
613
numa_on=1
7-
## TCP segment offload, default: disabled.
14+
15+
# TCP segment offload, default: disabled.
816
tso=0
9-
## HW vlan strip, default: enabled.
17+
18+
# HW vlan strip, default: enabled.
1019
vlan_strip=1
1120

1221
# sleep when no pkts incomming
@@ -27,40 +36,40 @@ idle_sleep=100
2736
# 1-3,4,7 ports 1,2,3,4,7 are enabled
2837
port_list=0
2938

30-
## Port config section
31-
## Correspond to dpdk.port_list's index: port0, port1...
39+
# Port config section
40+
# Correspond to dpdk.port_list's index: port0, port1...
3241
[port0]
33-
addr=192.168.1.2
34-
netmask=255.255.255.0
35-
broadcast=192.168.1.255
36-
gateway=192.168.1.1
42+
addr=10.139.144.123
43+
netmask=255.255.224.0
44+
broadcast=10.139.159.255
45+
gateway=10.139.128.1
3746

38-
## lcore list used to handle this port
39-
## the format is same as port_list
47+
# lcore list used to handle this port
48+
# the format is same as port_list
4049
# lcore_list= 0
4150

42-
## Packet capture path, this will hurt performance
51+
# Packet capture path, this will hurt performance
4352
#pcap=./a.pcap
4453

45-
## Kni config: if enabled and method=reject,
46-
## all packets that do not belong to the following tcp_port and udp_port
47-
## will transmit to kernel; if method=accept, all packets that belong to
48-
## the following tcp_port and udp_port will transmit to kernel.
49-
#[kni]
50-
#enable=1
51-
#method=reject
52-
## The format is same as port_list
53-
#tcp_port=80,443
54-
#udp_port=53
55-
56-
## FreeBSD network performance tuning configurations.
57-
## Most native FreeBSD configurations are supported.
54+
# Kni config: if enabled and method=reject,
55+
# all packets that do not belong to the following tcp_port and udp_port
56+
# will transmit to kernel; if method=accept, all packets that belong to
57+
# the following tcp_port and udp_port will transmit to kernel.
58+
[kni]
59+
enable=1
60+
method=reject
61+
# The format is same as port_list
62+
tcp_port=80,443
63+
udp_port=53
64+
65+
# FreeBSD network performance tuning configurations.
66+
# Most native FreeBSD configurations are supported.
5867
[freebsd.boot]
5968
hz=100
6069

61-
## Block out a range of descriptors to avoid overlap
62-
## with the kernel's descriptor space.
63-
## You can increase this value according to your app.
70+
# Block out a range of descriptors to avoid overlap
71+
# with the kernel's descriptor space.
72+
# You can increase this value according to your app.
6473
fd_reserve=1024
6574

6675
kern.ipc.maxsockets=262144

lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ HOST_OS:=$(shell uname -s)
1919

2020
#DEBUG=-O0 -gdwarf-2 -g3 -Wno-format-truncation
2121

22-
#FF_KNI=1
22+
FF_KNI=1
2323
#FF_NETGRAPH=1
2424
#FF_IPFW=1
2525

lib/ff_config.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ ini_parse_handler(void* user, const char* section, const char* name,
420420
} else if (MATCH("dpdk", "lcore_mask")) {
421421
pconfig->dpdk.lcore_mask = strdup(value);
422422
return parse_lcore_mask(pconfig, pconfig->dpdk.lcore_mask);
423+
} else if (MATCH("dpdk", "base_virtaddr")) {
424+
pconfig->dpdk.base_virtaddr= strdup(value);
423425
} else if (MATCH("dpdk", "port_list")) {
424426
return parse_port_list(pconfig, value);
425427
} else if (MATCH("dpdk", "promiscuous")) {
@@ -485,6 +487,10 @@ dpdk_args_setup(struct ff_config *cfg)
485487
sprintf(temp, "--proc-type=%s", cfg->dpdk.proc_type);
486488
dpdk_argv[n++] = strdup(temp);
487489
}
490+
if (cfg->dpdk.base_virtaddr) {
491+
sprintf(temp, "--base-virtaddr=%s", cfg->dpdk.base_virtaddr);
492+
dpdk_argv[n++] = strdup(temp);
493+
}
488494

489495
dpdk_argc = n;
490496

@@ -520,7 +526,7 @@ ff_parse_args(struct ff_config *cfg, int argc, char *const argv[])
520526
if (strcmp(cfg->dpdk.proc_type, "primary") &&
521527
strcmp(cfg->dpdk.proc_type, "secondary") &&
522528
strcmp(cfg->dpdk.proc_type, "auto")) {
523-
printf("invalid proc-type\n");
529+
printf("invalid proc-type:%s\n", cfg->dpdk.proc_type);
524530
return -1;
525531
}
526532

lib/ff_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ struct ff_config {
7979
/* mask of current proc on all lcores */
8080
char *proc_mask;
8181

82+
/* specify base virtual address to map. */
83+
char *base_virtaddr;
84+
8285
int nb_channel;
8386
int memory;
8487
int no_huge;

lib/ff_dpdk_if.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,18 +419,21 @@ create_ring(const char *name, unsigned count, int socket_id, unsigned flags)
419419
{
420420
struct rte_ring *ring;
421421

422-
if (name == NULL)
423-
return NULL;
424-
425-
/* If already create, just attached it */
426-
if (likely((ring = rte_ring_lookup(name)) != NULL))
427-
return ring;
422+
if (name == NULL) {
423+
rte_exit(EXIT_FAILURE, "create ring failed, no name!\n");
424+
}
428425

429426
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
430-
return rte_ring_create(name, count, socket_id, flags);
427+
ring = rte_ring_create(name, count, socket_id, flags);
431428
} else {
432-
return rte_ring_lookup(name);
429+
ring = rte_ring_lookup(name);
433430
}
431+
432+
if (ring == NULL) {
433+
rte_exit(EXIT_FAILURE, "create ring:%s failed!\n", name);
434+
}
435+
436+
return ring;
434437
}
435438

436439
static int

0 commit comments

Comments
 (0)