Commit 32312e27 authored by vember's avatar vember

Optimize the code, increase the bandwidth of more than 100M

parent ac565b19
set interface state GigabitEthernetb/0/0 up
set interface ip address GigabitEthernetb/0/0 192.168.10.10/24
set interface state if_n3 up
set interface ip address if_n3 192.168.10.10/24
set interface state if_n6 up
set interface ip address if_n6 192.168.30.10/24
create gtpu tunnel src 192.168.10.10 dst 192.168.10.100 teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add 192.169.0.0/24 via gtpu_tunnel0
ip route add 0.0.0.0/0 via if_n6 192.168.30.11
set interface mac address if_n3 9c:69:b4:61:f0:c0
set interface state GigabitEthernetb/0/1 up
set interface ip address GigabitEthernetb/0/1 192.168.30.10/24
create gtpu tunnel src 192.168.10.10 dst 192.168.10.11 teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add 192.168.20.0/24 via gtpu_tunnel0
ip route add 0.0.0.0/0 via GigabitEthernetb/0/1
......@@ -158,8 +158,8 @@ upf_forward (vlib_main_t * vm, vlib_node_runtime_t * node,
next = UPF_FORWARD_NEXT_DROP;
//active = pfcp_get_rules (sess, PFCP_ACTIVE);
if (PREDICT_FALSE (!sess))
goto trace;
//if (PREDICT_FALSE (!sess))
// goto trace;
if (PREDICT_TRUE (upf_buffer_opaque (b)->gtpu.pdr_idx != ~0))
{
......@@ -167,8 +167,8 @@ upf_forward (vlib_main_t * vm, vlib_node_runtime_t * node,
//far = pfcp_get_far_by_id (active, pdr->far_id); // how find far by far_id ?
}
if (PREDICT_FALSE (!pdr) /* || PREDICT_FALSE (!far)*/ )
goto trace;
//if (PREDICT_FALSE (!pdr) /* || PREDICT_FALSE (!far)*/ )
// goto trace;
u8 is_find = 0;
......
......@@ -135,6 +135,10 @@ upf_gtpu_input (vlib_main_t * vm,
clib_warning("rule_index0:0x%x, rule_index0:0x%x, t0->flags:0x%x, t1->flags:0x%x",
rule_index0, rule_index1,t0->flags, t1->flags);
//static int count = 0;
//if((count++) % 100 == 0)
// clib_upf_debug(um->log_fd,"count:%d", count);
/* Prefetch next iteration. */
{
vlib_buffer_t *p2, *p3;
......@@ -327,7 +331,8 @@ upf_gtpu_input (vlib_main_t * vm,
if(gtpu0->next_ext_type == NR_RAN_CONTAINER || gtpu0->next_ext_type == PDU_SESSION_CONTAINER)
{
u8 *ext_header = (u8 *)(&gtpu0->next_ext_type + 1);
while (cur_num < MAX_EXT_NUM && ((u8 *)ext_header < end))
static int count_a = 0;
while (cur_num < MAX_EXT_NUM && ((u8 *)ext_header < end) && (count_a == 0))
{
gtpu_hdr_len0 += (*ext_header) * 4;
gtpu_ext0[cur_num].len = (*ext_header);
......@@ -343,10 +348,13 @@ upf_gtpu_input (vlib_main_t * vm,
cur_num += 1;
tmp += 1 ;
if(1 != *ext_header || NR_RAN_CONTAINER != *(ext_header + 3) || PDU_SESSION_CONTAINER != *(ext_header + 3))
{
count_a++;
break;
}
}
}
}
#if 0
if (PREDICT_FALSE ((gtpu0->ver_flags & GTPU_E_BIT) != 0))
{
......@@ -405,6 +413,7 @@ upf_gtpu_input (vlib_main_t * vm,
//add it in 20200708
if(ip4_0)
{
static int count_b =0;
gtpu4_header_dl_t *gtpu_dl = bupt_lookup_dl_gtpu4_header_by_ueip(ip4_0->src_address.as_u32);
if(gtpu_dl)
{
......@@ -415,9 +424,10 @@ upf_gtpu_input (vlib_main_t * vm,
gtpu_dl->next_ext_type = gtpu0->next_ext_type;
gtpu_dl->cur_ext_num = cur_num;
if(gtpu_dl->cur_ext_num > 0)
if(gtpu_dl->cur_ext_num > 0 && (count_b == 0))
{
memcpy(gtpu_dl->ext_dl, gtpu_ext0, cur_num * sizeof(gtpu_ext_header_t));
count_b++;
}
}
}
......@@ -441,16 +451,6 @@ upf_gtpu_input (vlib_main_t * vm,
if(UPF_GTPU_INPUT_NEXT_DROP == next0)
clib_upf_debug(um->log_fd, "gtpu_drop, packet 0");
if(0x7302a8c0 == ip4_0->dst_address.as_u32 && 17 == ip4_0->protocol) //192.168.2.96
{
count++;
struct in_addr addr;
addr.s_addr = ip4_0->dst_address.as_u32;
long end_time = end_microsecond();
clib_upf_debug(um->log_fd,"UL ICMP count:%d,diff_time:%ld, dstip:%s, length:%d, packet 0", count, end_time - start_time, inet_ntoa(addr), clib_net_to_host_u16(ip4_0->length) - 20 - 8);
}
if (PREDICT_FALSE
((gtpu1->ver_flags & GTPU_VER_MASK) != GTPU_V1_VER))
{
......@@ -578,7 +578,8 @@ upf_gtpu_input (vlib_main_t * vm,
if (PREDICT_FALSE ((gtpu1->ver_flags & GTPU_E_BIT) != 0))
{
u8 *end = vlib_buffer_get_tail(b1);
if(gtpu1->next_ext_type == NR_RAN_CONTAINER || gtpu1->next_ext_type == PDU_SESSION_CONTAINER)
static int count_c =0;
if((gtpu1->next_ext_type == NR_RAN_CONTAINER || gtpu1->next_ext_type == PDU_SESSION_CONTAINER) && (count_c == 0))
{
u8 *ext_header = (u8 *)(&gtpu1->next_ext_type + 1);
while (cur_num < MAX_EXT_NUM && ((u8 *)ext_header < end))
......@@ -597,10 +598,14 @@ upf_gtpu_input (vlib_main_t * vm,
cur_num += 1;
tmp += 1 ;
if(1 != *ext_header || NR_RAN_CONTAINER != *(ext_header + 3) || PDU_SESSION_CONTAINER != *(ext_header + 3))
{
count_c++;
break;
}
}
}
}
#if 0
if (PREDICT_FALSE ((gtpu1->ver_flags & GTPU_E_BIT) != 0))
......@@ -660,6 +665,7 @@ upf_gtpu_input (vlib_main_t * vm,
//test
if(ip4_1)
{
static int count_d = 0;
gtpu4_header_dl_t *gtpu_dl = bupt_lookup_dl_gtpu4_header_by_ueip(ip4_1->src_address.as_u32);
if(gtpu_dl)
{
......@@ -670,9 +676,10 @@ upf_gtpu_input (vlib_main_t * vm,
gtpu_dl->next_ext_type = gtpu0->next_ext_type;
gtpu_dl->cur_ext_num = cur_num;
if(gtpu_dl->cur_ext_num > 0)
if(gtpu_dl->cur_ext_num > 0 && (count_d == 0))
{
memcpy(gtpu_dl->ext_dl, gtpu_ext1, cur_num * sizeof(gtpu_ext_header_t));
count_d++;
}
}
}
......@@ -698,16 +705,6 @@ upf_gtpu_input (vlib_main_t * vm,
if(UPF_GTPU_INPUT_NEXT_DROP == next1)
clib_upf_debug(um->log_fd, "gtpu_drop, packet 1");
if(0x7302a8c0 == ip4_1->dst_address.as_u32 && 17 == ip4_1->protocol) //192.168.2.96
{
count++;
struct in_addr addr;
addr.s_addr = ip4_1->dst_address.as_u32;
long end_time = end_microsecond();
clib_upf_debug(um->log_fd,"UL ICMP count:%d,diff_time:%ld, dstip:%s, length:%d, packet 1", count, end_time - start_time, inet_ntoa(addr), clib_net_to_host_u16(ip4_0->length) - 20 - 8);
}
vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
to_next, n_left_to_next,
bi0, bi1, next0, next1);
......@@ -894,7 +891,7 @@ upf_gtpu_input (vlib_main_t * vm,
if (PREDICT_FALSE ((gtpu0->ver_flags & GTPU_E_BIT) != 0))
{
u8 *end = vlib_buffer_get_tail(b0);
if(gtpu0->next_ext_type == NR_RAN_CONTAINER || gtpu0->next_ext_type == PDU_SESSION_CONTAINER)
if((gtpu0->next_ext_type == NR_RAN_CONTAINER) || (gtpu0->next_ext_type == PDU_SESSION_CONTAINER))
{
u8 *ext_header = (u8 *)(&gtpu0->next_ext_type + 1);
while (cur_num < MAX_EXT_NUM && ((u8 *)ext_header < end))
......@@ -912,11 +909,11 @@ upf_gtpu_input (vlib_main_t * vm,
ext_header = ext_header + gtpu_ext[cur_num].len * 4;
cur_num += 1;
tmp += 1 ;
if(1 != *ext_header || NR_RAN_CONTAINER != *(ext_header + 3) || PDU_SESSION_CONTAINER != *(ext_header + 3))
break;
}
}
}
}
else
......@@ -947,6 +944,7 @@ upf_gtpu_input (vlib_main_t * vm,
/* inner IP header */
ip4_0 = vlib_buffer_get_current (b0) + hdr_len0;
// ueip_is_exist_in_teid(u32 ueip, upf_session_t);
if ((ip4_0->ip_version_and_header_length & 0xF0) == 0x40)
......@@ -963,7 +961,9 @@ upf_gtpu_input (vlib_main_t * vm,
if(ip4_0)
{
gtpu4_header_dl_t *gtpu_dl = bupt_lookup_dl_gtpu4_header_by_ueip(ip4_0->src_address.as_u32);
if(gtpu_dl)
//Avoid copying data multiple times
if(gtpu_dl && (gtpu_dl->cur_ext_num == 0) && !cur_num)
{
gtpu_dl->ver_flags = gtpu0->ver_flags;
gtpu_dl->type = gtpu0->type;
......@@ -972,12 +972,9 @@ upf_gtpu_input (vlib_main_t * vm,
gtpu_dl->next_ext_type = gtpu0->next_ext_type;
gtpu_dl->cur_ext_num = cur_num;
if(gtpu_dl->cur_ext_num > 0)
{
memcpy(gtpu_dl->ext_dl, gtpu_ext, cur_num * sizeof(gtpu_ext_header_t));
}
}
}
vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0;
......
......@@ -161,8 +161,8 @@ upf_input (vlib_main_t * vm, vlib_node_runtime_t * node,
sidx = upf_buffer_opaque (b)->gtpu.session_index;
sess = pool_elt_at_index (gtm->sessions, sidx);
if (PREDICT_FALSE (!sess))
goto trace;
//if (PREDICT_FALSE (!sess))
// goto trace;
if (PREDICT_TRUE (upf_buffer_opaque (b)->gtpu.pdr_idx != ~0))
{
......@@ -170,8 +170,8 @@ upf_input (vlib_main_t * vm, vlib_node_runtime_t * node,
//far = pfcp_get_far_by_id (active, pdr->far_id); // how find far by far_id ?
}
if (PREDICT_FALSE (!pdr) /* || PREDICT_FALSE (!far)*/ )
goto trace;
//if (PREDICT_FALSE (!pdr) /* || PREDICT_FALSE (!far)*/ )
// goto trace;
//inner ip
if(pdr->pdi.ue_addr.ip4.as_u32 != ip4_0->src_address.as_u32)
......
......@@ -2751,7 +2751,6 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
clib_memcpy_fast(new_gtpu_header, gtpu4_header, sizeof(bupt_gtpu4_header_t));
clib_memcpy_fast(new_gtpu_header + sizeof(bupt_gtpu4_header_t), gtpu4_ext_body, ext_all_len);
//84: ip + icmp ;
u8 *old_ip4 = (u8 *)(gtpu0 + 1);
clib_memcpy_fast(new_gtpu_header + sizeof(bupt_gtpu4_header_t) + ext_all_len, old_ip4, inner_ip_length);
......
......@@ -2,24 +2,38 @@ unix {
nodaemon
log /var/log/upf/vpp/vpp.log
full-coredump
gid vpp
interactive
gid vpp
cli-listen /run/vpp/cli.sock
#exec test_wzy.sh
#cli-listen localhost:5002
#exec @/work/gtpu_ext/vpp_0618/config_system.sh@
exec /work/modify_teid/Buptvppe/config_system.sh
#exec /work96/test_mul_thread/upf_v0.4/upf-vpp/src/Buptvppe/config_system_v1.sh
monitor_url http://192.168.2.216:8878/status/vpp
exec ./config_system.sh
logsize 100
cli-prompt bupt#
}
api-trace {
on
#save-api-table /tmp/save_api_table
}
api-segment {
gid vpp
# global-size 2G
# api-size 64M
# global-pvt-heap-size size 262144
#api-pvt-heap-size 1M
}
logging
{
default-log-level info
default-syslog-log-level info
}
statseg {
default
#size 1024M
per-node-counters on
}
cpu {
......@@ -30,11 +44,11 @@ cpu {
## Set logical CPU core where main thread runs, if main core is not set
## VPP will use core 1 if available
main-core 13
main-core 6
## Set logical CPU core(s) where worker threads are running
corelist-workers 14,15
#corelist-io 5,6
corelist-workers 7
#corelist-io 3,4
## Automatic pinning of thread(s) to CPU core(s)
......@@ -42,12 +56,12 @@ cpu {
## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
## The main thread is automatically pinned to the first available CPU core and worker(s)
## are pinned to next free CPU core(s) after core assigned to main thread
#skip-cores 4
# skip-cores 4
## Specify a number of workers to be created
## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
## and main thread's CPU core
#workers 4
#workers 1
## Set scheduling policy and priority of main and worker threads
......@@ -64,32 +78,37 @@ buffers {
## Increase number of buffers allocated, needed only in scenarios with
## large number of interfaces and worker threads. Value is per numa node.
## Default is 16384 (8192 if running unpriviledged)
buffers-per-numa 128000
#buffers-per-numa 128000
buffers-per-numa 2560000
#buffers-per-numa 2560000
## Size of buffer data area
## Default is 2048
#Default is 2048
#data size 4096
#default data-size 2048
default data-size 2048
}
#mactime {
# lookup-table-buckets 32
# lookup-table-memory 1G
#}
dpdk {
## Change default settings for all interfaces
dev default {
## Number of receive queues, enables RSS
## Default is 1
num-rx-queues 1
## Number of transmit queues, Default is equal
## to number of worker threads or 1 if no workers treads
num-tx-queues 1
## Number of descriptors in transmit and receive rings
## increasing or reducing number can impact performance
## Default is 1024 for both rx and tx
num-rx-desc 1024
num-tx-desc 1024
# num-rx-desc 512
# num-tx-desc 512
## VLAN strip offload mode for interface
## Default is off
......@@ -100,27 +119,23 @@ dpdk {
#82576 1G
#dev 0000:09:00.0 {
# vlan-strip-offload off
# num-rx-queues 1
# num-tx-queues 1
#}
# dev 0000:09:00.1 {
# vlan-strip-offload off
# num-rx-queues 1
# num-tx-queues 1
#}
dev 0000:02:00.0
{
name if_n3
num-rx-queues 2
num-tx-queues 2
# num-rx-desc 1024
# num-tx-desc 1024
}
#dev 0000:02:00.0 {
# num-rx-queues 1
# num-rx-queues 1
#}
dev 0000:06:00.1
dev 0000:06:00.0
dev 0000:02:00.1
{
name if_n6
num-rx-queues 1
# num-rx-desc 1024
# num-tx-desc 1024
}
#dev 0000:02:00.0
#dev 0000:05:00.0
## Whitelist specific interface by specifying PCI address and in
## addition specify custom parameters for this interface
......@@ -130,29 +145,39 @@ dpdk {
## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci,
## uio_pci_generic or auto (default)
# uio-driver vfio-pci
uio-driver igb_uio
#uio-driver vfio-pci
## Disable multi-segment buffers, improves performance but
## disables Jumbo MTU support
#no-multi-seg
no-multi-seg
## Change hugepages allocation per-socket, needed only if there is need for
## larger number of mbufs. Default is 256M on each detected CPU socket
#socket-mem 2048,2048
socket-mem 1024
#socket-mem 2048
socket-mem 2048,2048
## Disables UDP / TCP TX checksum offload. Typically needed for use
## faster vector PMDs (together with no-multi-seg)
#no-tx-checksum-offload
no-tx-checksum-offload
}
plugins {
path /work/modify_teid/Buptvppe/build-root/install-vpp_debug-native/vpp/lib/vpp_plugins/
#memory {
# main-heap-size 4G
# main-heap-page-size 1G
#}
#default main:1G, work:1G
heapsize 2G
#plugin default { enable }
plugins {
path ./build-root/install-vpp_debug-native/vpp/lib/vpp_plugins
plugin default { enable }
plugin dpdk_plugin.so { enable }
plugin gtpu_plugin.so { enable }
plugin upf_plugin.so { enable }
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment