Skip to content

Commit 6d71690

Browse files
committed
support dpdk-17.05.2 and faster ip stack
1 parent 8b2f499 commit 6d71690

File tree

17 files changed

+160
-116
lines changed

17 files changed

+160
-116
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ANS(accelerated network stack) is porting from [FreeBSD](http://freebsd.org) TCP
1313
- test: Example application with ANS for testing ANS tcp/ip stack
1414

1515
Support environment
16-
- EAL is based on dpdk-17.02.1;
16+
- EAL is based on dpdk-17.05.2;
1717
- Development enviroment is based on x86_64-native-linuxapp-gcc;
1818
- linux version:
1919
4.4.0-45-generic (Ubuntu 16.04.1 LTS).

ans/ans_kni.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int ans_kni_sendpkt_burst(struct rte_mbuf ** mbufs, unsigned nb_mbufs, unsigned
145145
if(unlikely(ring == NULL))
146146
return -ENOENT;
147147

148-
return rte_ring_enqueue_bulk(ring,(void **)mbufs,nb_mbufs);
148+
return rte_ring_enqueue_bulk(ring,(void **)mbufs, nb_mbufs, NULL);
149149
}
150150

151151
int ans_kni_init()
@@ -322,7 +322,7 @@ static void kni_ring_to_kni(struct kni_port_params *p)
322322
port_id = p->port_id;
323323

324324
/* Burst rx from ring */
325-
nb_rx = rte_ring_dequeue_burst(p->ring,(void **)&pkts_burst, PKT_BURST_SZ);
325+
nb_rx = rte_ring_dequeue_burst(p->ring,(void **)&pkts_burst, PKT_BURST_SZ, NULL);
326326

327327
if (unlikely(nb_rx > PKT_BURST_SZ))
328328
{

ans/ans_main.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
#include <rte_spinlock.h>
7979

8080
#include "ans_init.h"
81-
#include "ans_enet_intf.h"
8281
#include "ans_ip_intf.h"
8382

8483
/* add by ans_team -- end */
@@ -464,7 +463,7 @@ static int ans_init_ports(unsigned short nb_ports, struct ans_user_config *user
464463
/* user default tx conf */
465464

466465
/* txconf = &ans_tx_conf; */
467-
txconf->txq_flags = 0;
466+
txconf->txq_flags = 0; /* enable NIC all TX offload */
468467

469468
printf("\t lcore id:%u, tx queue id:%d, socket id:%d \n", lcore_id, queueid, socketid);
470469
printf("\t Conf-- tx pthresh:%d, tx hthresh:%d, tx wthresh:%d, txq_flags:0x%x \n", txconf->tx_thresh.pthresh,
@@ -746,7 +745,7 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
746745
cur_tsc = rte_rdtsc();
747746

748747
/* add by ans_team ---start */
749-
ans_message_handle(lcore_id, cur_tsc);
748+
ans_message_handle(lcore_id);
750749
/* add by ans_team ---end */
751750

752751

@@ -970,28 +969,31 @@ int main(int argc, char **argv)
970969
printf("add %s device\r\n", ifname);
971970
rte_eth_macaddr_get(portid, &eth_addr);
972971

973-
ans_intf_add(portid, ifname, &eth_addr);
972+
ans_iface_add(portid, ifname, &eth_addr);
974973

975-
int ip_addr = 0x0200000a;
974+
/* host byte order */
975+
int ip_addr = 0x0a000002;
976976
ip_addr += portid << 16;
977977

978978
printf("add IP %x on device %s \n", ip_addr, ifname);
979-
ans_intf_add_ipaddr((caddr_t)ifname, ip_addr, 0x00ffffff);
979+
ans_add_ipaddr((char *)ifname, ip_addr, 24);
980980
}
981+
982+
printf("show all IPs: \n");
983+
ans_show_ipaddr();
984+
printf("\n");
985+
981986
/* add by ans_team ---end */
982987

983988
/* add by ans_team for testing ---start */
984-
985-
printf("Show interface \n");
986-
ans_intf_show();
987-
989+
988990
int route_ret = 0;
989991
printf("add static route \r\n");
990992

991-
route_ret = ans_add_route(0x00000a0a, 1, 0x0500000a, 0x00ffffff, ANS_IP_RTF_GATEWAY);
992-
993-
ans_route_show_all();
993+
/* host byte order */
994+
route_ret = ans_add_route(0x0a0a0000, 24, 0x0a000005);
994995

996+
ans_show_route();
995997
printf("\n");
996998
/* add by ans_team ---end */
997999

cli/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
4242

4343
include $(RTE_SDK)/mk/rte.vars.mk
4444

45-
ODP_PATH = $(RTE_ANS)
4645

4746
# binary name
4847
APP = anscli
4948

49+
50+
5051
# all source are stored in SRCS-y
51-
SRCS-y := anscli_main.c anscli_conf.c anscli_ring.c
52+
SRCS-y := anscli_main.c
5253

5354
CFLAGS += -O3
5455
#CFLAGS += $(WERROR_FLAGS)
55-
CFLAGS += -I$(ODP_PATH)/librte_ans/include
56-
CFLAGS += -I$(ODP_PATH)/shared
56+
CFLAGS += -I$(RTE_ANS)/librte_anscli/include
57+
58+
LDLIBS += $(RTE_ANS)/librte_anscli/librte_anscli.a
59+
5760

5861
include $(RTE_SDK)/mk/rte.extapp.mk

cli/anscli_main.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@
4848
#endif
4949
#endif
5050

51-
#include <cmdline_rdline.h>
52-
#include <cmdline_parse.h>
53-
#include <cmdline_parse_ipaddr.h>
54-
#include <cmdline_parse_num.h>
55-
#include <cmdline_parse_string.h>
56-
#include <cmdline.h>
57-
#include <cmdline_socket.h>
58-
59-
6051
#include <rte_memory.h>
6152
#include <rte_memzone.h>
6253
#include <rte_tailq.h>
@@ -65,14 +56,12 @@
6556
#include <rte_log.h>
6657

6758
#include "anscli_main.h"
68-
#include "anscli_conf.h"
69-
#include "anscli_ring.h"
59+
#include "anscli_intf.h"
7060

7161

7262
int main(void)
7363
{
7464
int ret;
75-
struct cmdline *cl;
7665
int param_num = 8;
7766
char *param[] = {"anscli",
7867
"-c",
@@ -85,22 +74,12 @@ int main(void)
8574
NULL};
8675

8776

88-
rte_set_log_level(RTE_LOG_ERR);
77+
rte_log_set_global_level(RTE_LOG_ERR);
8978
ret = rte_eal_init(param_num, param);
9079
if (ret < 0)
9180
rte_panic("Cannot init EAL\n");
9281

93-
ret = anscli_ring_init();
94-
if(ret != 0)
95-
rte_panic("Cannot init ring\n");
96-
97-
98-
cl = cmdline_stdin_new(ip_main_ctx, "ans> ");
99-
if (cl == NULL)
100-
rte_panic("Cannot create ans cmdline instance\n");
101-
102-
cmdline_interact(cl);
103-
cmdline_stdin_exit(cl);
104-
82+
anscli_start();
83+
10584
return 0;
10685
}

doc/api/doxy-api-index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ There are many libraries, so their headers may be grouped by topics:
4040
[init] (@ref ans_init.h)
4141

4242
- **layers**:
43-
[ethernet] (@ref ans_enet_intf.h),
4443
[IP] (@ref ans_ip_intf.h)
4544

4645
- **socket**:
4746
[anssock] (@ref anssock_intf.h)
47+
48+
- **cli**:
49+
[anscli] (@ref anscli_intf.h)

doc/api/doxy-api.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ PROJECT_NAME = ANS
3434
INPUT = doc/api/doxy-api-index.md \
3535
librte_ans/include \
3636
librte_anssock/include \
37-
37+
librte_anscli/include \
38+
3839
FILE_PATTERNS = ans*.h \
3940
cmdline.h
4041
PREDEFINED = __DOXYGEN__ \

examples/http_server/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CFLAGS += -O3 \
5050

5151
LDLIBS += $(RTE_ANS)/librte_anssock/librte_anssock.a \
5252
-L$(RTE_SDK)/$(RTE_TARGET)/lib \
53-
-Wl,--whole-archive -Wl,-lrte_mbuf -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal -Wl,--no-whole-archive -Wl,-export-dynamic \
53+
-Wl,--whole-archive -Wl,-lrte_mbuf -Wl,-lrte_mempool_ring -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal -Wl,--no-whole-archive -Wl,-export-dynamic \
5454
-lrt -pthread -ldl
5555

5656
OBJS = http_server.o

examples/https_server/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CFLAGS += -O3 -DLOAD_CERTIFICATE\
5050

5151
LDLIBS += $(RTE_ANS)/librte_anssock/librte_anssock.a \
5252
-L$(RTE_SDK)/$(RTE_TARGET)/lib \
53-
-Wl,--whole-archive -Wl,-lrte_mbuf -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal -Wl,--no-whole-archive -Wl,-export-dynamic \
53+
-Wl,--whole-archive -Wl,-lrte_mbuf -Wl,-lrte_mempool_ring -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal -Wl,--no-whole-archive -Wl,-export-dynamic \
5454
-lrt -pthread -ldl \
5555
-lnsl -lresolv -rdynamic -lssl -lcrypto
5656

examples/https_server/ans_module.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
#define __USE_GNU
6666

6767
#include <unistd.h>
68-
#include <sched.h>
6968
#include <sys/types.h>
7069
#include <fcntl.h>
7170
#include <sys/syscall.h>
@@ -131,7 +130,7 @@ void ans_mod_init()
131130
real_##func = dlsym(RTLD_NEXT, #func); \
132131
assert(real_##func)
133132

134-
INIT_FUNCTION(socket);
133+
INIT_FUNCTION(socket);
135134
INIT_FUNCTION(bind);
136135
INIT_FUNCTION(connect);
137136
INIT_FUNCTION(close);
@@ -385,7 +384,7 @@ ssize_t read(int fd, void *buf, size_t count)
385384
else
386385
{
387386
rc =real_read(fd, buf, count);
388-
ANS_FD_DEBUG("linux fd %d read data len %ld \n", fd, rc);
387+
// ANS_FD_DEBUG("linux fd %d read data len %ld \n", fd, rc);
389388

390389
return rc;
391390
}
@@ -793,7 +792,7 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
793792
fd -= ANS_FD_BASE;
794793

795794
ANS_FD_DEBUG("ans fd %d readv with iovcnt %d \n", fd, iovcnt);
796-
rc =anssock_readv(fd, iov, iovcnt);
795+
rc =anssock_readv(fd, iov, iovcnt);
797796
return rc;
798797
}
799798
else

0 commit comments

Comments
 (0)