Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
trx-ecpri
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
trx-ecpri
Commits
610210c8
Commit
610210c8
authored
Oct 08, 2021
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update trx driver with DPDK
parent
48754dba
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1114 additions
and
52 deletions
+1114
-52
Makefile
Makefile
+42
-10
dpdk-test/Makefile
dpdk-test/Makefile
+16
-9
dpdk-test/dpdk-recv-send.c
dpdk-test/dpdk-recv-send.c
+7
-15
ecpri-tests/Makefile
ecpri-tests/Makefile
+16
-18
ecpri-tests/test-dpdk-ecpri.c
ecpri-tests/test-dpdk-ecpri.c
+116
-0
ecpri-tests/test.sh
ecpri-tests/test.sh
+7
-0
trx_ecpri_dpdk.c
trx_ecpri_dpdk.c
+910
-0
No files found.
Makefile
View file @
610210c8
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
CC
=
gcc
-m64
-msse4
.1
CXX
=
g++
-m64
-msse4
.1
CFLAGS
=
-O2
-fno-strict-aliasing
CFLAGS
=
-O2
-fno-strict-aliasing
-Wall
-pedantic
-std
=
gnu17
CFLAGS
+=
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS
=
64
-D_LARGEFILE_SOURCE
CFLAGS
+=
-MMD
-g
CXXFLAGS
=
$(CFLAGS)
PROGS
=
trx_ecpri.so
# binary name
APP
=
trx_ecpri_dpdk
LIB
=
lib
$(APP)
.so
all
:
$(PROGS)
# all source are stored in SRCS-y
SRCS-y
:=
$(APP)
.c
clean
:
rm
-f
$(PROGS)
*
.lo
*
~
*
.d
PKGCONF
?=
pkg-config
# Build using pkg-config variables if possible
ifneq
($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
$(error
"no installation of DPDK found"
)
endif
all
:
$(LIB)
$(LIB)
:
$(APP).o
$(CC)
-shared
$(LDFLAGS)
$(LDFLAGS_SHARED)
-o
$@
$<
trx_ecpri.so
:
trx_ecpri.lo
$(CC)
-shared
$(LDFLAGS)
-o
$@
$<
-lm
.PHONY
:
shared
shared
:
build/$(APP)-shared
ln
-sf
$(APP)
-shared
build/
$(APP)
%.lo
:
%.c
$(CC)
$(CFLAGS)
-fpic
-c
-o
$@
$<
PC_FILE
:=
$(
shell
$(PKGCONF)
--path
libdpdk 2>/dev/null
)
CFLAGS
+=
-O3
$(
shell
$(PKGCONF)
--cflags
libdpdk
)
LDFLAGS_SHARED
=
$(
shell
$(PKGCONF)
--libs
libdpdk
)
-lpthread
-lm
-include
$(wildcard *.d)
CFLAGS
+=
-DALLOW_EXPERIMENTAL_API
build/$(APP)-shared
:
$(SRCS-y) Makefile $(PC_FILE) | build
$(CC)
$(CFLAGS)
$
(
SRCS-y
)
-o
$@
$(LDFLAGS)
$(LDFLAGS_SHARED)
%.o
:
%.c
$(CC)
$(CFLAGS)
$
(
SRCS-y
)
-fpic
-c
-o
$@
build
:
@
mkdir
-p
$@
.PHONY
:
clean
clean
:
rm
-rf
build
rm
-rf
$(LIB)
rm
-f
*
.o
*
.d
*
.so
dpdk-test/Makefile
View file @
610210c8
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
CC
=
gcc
-m64
-msse4
.1
CXX
=
g++
-m64
-msse4
.1
CFLAGS
=
-O2
-fno-strict-aliasing
CFLAGS
+=
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS
=
64
-D_LARGEFILE_SOURCE
CFLAGS
+=
-MMD
-g
CXXFLAGS
=
$(CFLAGS)
# binary name
APP
=
dpdk-recv-send
...
...
@@ -15,29 +22,29 @@ $(error "no installation of DPDK found")
endif
all
:
shared
.PHONY
:
shared
static
.PHONY
:
shared
shared
:
build/$(APP)-shared
ln
-sf
$(APP)
-shared
build/
$(APP)
static
:
build/$(APP)-static
ln
-sf
$(APP)
-static
build/
$(APP)
dpdk-recv-send.so
:
dpdk-recv-send.o
$(CC)
-shared
$(LDFLAGS)
$(LDFLAGS_SHARED)
-o
$@
$<
PC_FILE
:=
$(
shell
$(PKGCONF)
--path
libdpdk 2>/dev/null
)
CFLAGS
+=
-O3
$(
shell
$(PKGCONF)
--cflags
libdpdk
)
LDFLAGS_SHARED
=
$(
shell
$(PKGCONF)
--libs
libdpdk
)
-lpthread
LDFLAGS_STATIC
=
$(
shell
$(PKGCONF)
--static
--libs
libdpdk
)
LDFLAGS_SHARED
=
$(
shell
$(PKGCONF)
--libs
libdpdk
)
-lpthread
-lm
CFLAGS
+=
-DALLOW_EXPERIMENTAL_API
build/$(APP)-shared
:
$(SRCS-y) Makefile $(PC_FILE) | build
$(CC)
$(CFLAGS)
$
(
SRCS-y
)
-o
$@
$(LDFLAGS)
$(LDFLAGS_SHARED)
build/$(APP)-static
:
$(SRCS-y) Makefile $(PC_FILE) | build
$(CC)
$(CFLAGS)
$
(
SRCS-y
)
-
o
$@
$(LDFLAGS)
$(LDFLAGS_STATIC)
%.o
:
%.c
$(CC)
$(CFLAGS)
$
(
SRCS-y
)
-
fpic
-c
-o
$@
build
:
@
mkdir
-p
$@
.PHONY
:
clean
clean
:
rm
-
f
build/
$(APP)
build/
$(APP)
-static
build/
$(APP)
-share
d
test
-d
build
&&
rmdir
-p
build
||
true
rm
-
rf
buil
d
rm
-f
*
.o
*
.d
*
.so
dpdk-test/dpdk-recv-send.c
View file @
610210c8
#define _GNU_SOURCE
/* See feature_test_macros(7) */
//
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
...
...
@@ -98,10 +98,9 @@ static int64_t calcdiff_ns(struct timespec t1, struct timespec t2) {
return
diff
;
}
#define DATA_SIZE 244
#define BURST_SIZE 16
//#define NB_PACKETS (1 * 1000000)
#define NB_PACKETS 64
#define DATA_LEN 244
#define MEMPOOL_CACHE_SIZE 256
#define RTE_TEST_RX_DESC_DEFAULT 1024
#define RTE_TEST_TX_DESC_DEFAULT 1024
...
...
@@ -110,8 +109,7 @@ static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
struct
rte_mempool
*
mbuf_pool
;
struct
rte_ether_addr
s_addr
=
{{
0xb8
,
0xce
,
0xf6
,
0x4b
,
0x00
,
0x22
}};
struct
rte_ether_addr
d_addr
=
{{
0xb8
,
0xce
,
0xf6
,
0x4b
,
0x00
,
0x23
}};
uint8_t
data
[
BURST_SIZE
][
DATA_LEN
];
int8_t
data
[
BURST_SIZE
][
DATA_SIZE
];
static
const
struct
rte_eth_conf
port_conf_default
=
{
.
rxmode
=
{
.
max_rx_pkt_len
=
RTE_ETHER_MAX_LEN
}
};
...
...
@@ -126,10 +124,6 @@ static inline int port_init(int portid, struct rte_mempool *mbuf_pool) {
if
(
retval
!=
0
)
return
retval
;
//ret = rte_eth_dev_adjust_nb_rx_tx_desc(1, &nb_rxd, &nb_txd);
//if (ret < 0)
// rte_exit(EXIT_FAILURE, "Cannot adjust number of descriptors: err=%d, port=%u\n", ret, 1);
/* Allocate and set up 1 RX queue per Ethernet port. */
for
(
q
=
0
;
q
<
rx_rings
;
q
++
)
{
retval
=
rte_eth_rx_queue_setup
(
portid
,
q
,
nb_rxd
,
...
...
@@ -176,7 +170,6 @@ static void init_dpdk(int argc, char ** argv) {
if
(
port_init
(
1
,
mbuf_pool
)
!=
0
)
rte_exit
(
EXIT_FAILURE
,
"Cannot init port %"
PRIu8
"
\n
"
,
1
);
}
static
void
send_packets
(
int
port
)
{
struct
rte_mbuf
*
pkt
[
BURST_SIZE
];
struct
rte_ether_hdr
*
eth_hdr
;
...
...
@@ -193,8 +186,8 @@ static void send_packets(int port) {
eth_hdr
->
s_addr
=
s_addr
;
}
eth_hdr
->
ether_type
=
0x0a00
;
memcpy
(
rte_pktmbuf_mtod_offset
(
pkt
[
i
],
uint8_t
*
,
sizeof
(
struct
rte_ether_hdr
)),
data
[
i
],
DATA_
LEN
);
pkt_size
=
DATA_
LEN
+
sizeof
(
struct
rte_ether_hdr
);
memcpy
(
rte_pktmbuf_mtod_offset
(
pkt
[
i
],
uint8_t
*
,
sizeof
(
struct
rte_ether_hdr
)),
data
[
i
],
DATA_
SIZE
);
pkt_size
=
DATA_
SIZE
+
sizeof
(
struct
rte_ether_hdr
);
pkt
[
i
]
->
data_len
=
pkt_size
;
pkt
[
i
]
->
pkt_len
=
pkt_size
;
}
...
...
@@ -209,7 +202,6 @@ static void send_packets(int port) {
exit
(
EXIT_FAILURE
);
}
}
static
int
recv_packets
(
int
port
)
{
struct
rte_mbuf
*
pkt
[
BURST_SIZE
];
//if(port == 0) log_info("PORT0", "Init");
...
...
@@ -244,7 +236,7 @@ void * send_thread(void * p) {
log_info
(
"SEND_THREAD"
,
"Init %d"
,
*
port
);
for
(
int
i
=
0
;
i
<
BURST_SIZE
;
i
++
)
{
for
(
int
j
=
0
;
j
<
DATA_
LEN
;
j
++
)
{
for
(
int
j
=
0
;
j
<
DATA_
SIZE
;
j
++
)
{
data
[
i
][
j
]
=
0xfe
;
}
}
...
...
ecpri-tests/Makefile
View file @
610210c8
...
...
@@ -3,30 +3,28 @@
CC
=
gcc
-m64
-msse4
.1
CXX
=
g++
-m64
-msse4
.1
CFLAGS
=
-O2
-fno-strict-aliasing
-Wall
-pedantic
CFLAGS
+=
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS
=
64
-D_LARGEFILE_SOURCE
CFLAGS
+=
-MMD
-g
#CFLAGS=-O2 -Wall -pedantic -std=gnu17
CFLAGS
=
-O2
-fno-strict-aliasing
-Wall
-pedantic
-std
=
gnu17
CFLAGS
+=
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS
=
64
-D_LARGEFILE_SOURCE
CFLAGS
+=
-DALLOW_EXPERIMENTAL_API
CXXFLAGS
=
$(CFLAGS)
LIB
=
trx_ecpri_dpdk
LIBDIR
=
/root/ecpri/trx-ecpri-priv
LDFLAGS
=
-l
$(LIB)
LDFLAGS
+=
-L
/usr/local/lib/x86_64-linux-gnu
-Wl
,--as-needed
-lrte_node
-lrte_graph
-lrte_bpf
-lrte_flow_classify
-lrte_pipeline
-lrte_table
-lrte_port
-lrte_fib
-lrte_ipsec
-lrte_vhost
-lrte_stack
-lrte_security
-lrte_sched
-lrte_reorder
-lrte_rib
-lrte_regexdev
-lrte_rawdev
-lrte_pdump
-lrte_power
-lrte_member
-lrte_lpm
-lrte_latencystats
-lrte_kni
-lrte_jobstats
-lrte_ip_frag
-lrte_gso
-lrte_gro
-lrte_eventdev
-lrte_efd
-lrte_distributor
-lrte_cryptodev
-lrte_compressdev
-lrte_cfgfile
-lrte_bitratestats
-lrte_bbdev
-lrte_acl
-lrte_timer
-lrte_hash
-lrte_metrics
-lrte_cmdline
-lrte_pci
-lrte_ethdev
-lrte_meter
-lrte_net
-lrte_mbuf
-lrte_mempool
-lrte_rcu
-lrte_ring
-lrte_eal
-lrte_telemetry
-lrte_kvargs
-lbsd
-lpthread
-lm
SRCCLIENT
=
trx_ecpri.c client.c
SRCSERVER
=
trx_ecpri.c server.c
OBJCLIENT
=
$(SRCCLIENT:%.c=%.o)
OBJSERVER
=
$(SRCSERVER:%.c=%.o)
CLIENT
=
client
SERVER
=
server
PROG
=
test-dpdk-ecpri
all
:
$(
SERVER) $(CLIENT
)
all
:
$(
PROG
)
clean
:
rm
-f
$(SERVER)
$(CLIENT)
*
.o
*
~
*
.d
$(SERVER)
:
$(OBJSERVER)
$(CC)
$(LDFLAGS)
-o
$@
$^
-lm
-lpthread
$(CLIENT)
:
$(OBJCLIENT)
$(CC)
$(LDFLAGS)
-o
$@
$^
-lm
-lpthread
$(PROG)
:
$(PROG).o
$(CC)
-o
$@
$<
$(LDFLAGS)
%.o
:
%.c
$(CC)
$(CFLAGS)
-fpic
-c
-o
$@
$<
$(CC)
$(CFLAGS)
-c
-o
$@
$<
clean
:
rm
-f
$(PROG)
*
.o
*
~
*
.d
-include
$(wildcard *.d)
ecpri-tests/test-dpdk-ecpri.c
0 → 100644
View file @
610210c8
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <getopt.h>
#include <immintrin.h>
#include <inttypes.h>
#include <limits.h>
#include <linux/if_packet.h>
#include <math.h>
#include <netdb.h>
#include <netinet/ether.h>
#include <netinet/in.h>
#include <net/if.h>
#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
typedef
struct
{
const
char
*
re_mac
;
const
char
*
rec_mac
;
const
char
*
rec_if
;
int
recv_affinity
;
int
send_affinity
;
int
prepare_affinity
;
int
decompress_affinity
;
int
statistic_affinity
;
int
ecpri_period
;
int
flow_id
;
int
sample_rate
;
}
TRXEcpriState
;
static
void
log_error
(
const
char
*
section
,
const
char
*
msg
,
...)
{
time_t
t
;
struct
tm
ts
;
char
line
[
256
];
va_list
arglist
;
time
(
&
t
);
ts
=
*
localtime
(
&
t
);
strftime
(
line
,
80
,
"%m-%d %H:%M:%S"
,
&
ts
);
sprintf
(
line
+
strlen
(
line
),
" ERROR [%s] "
,
section
);
va_start
(
arglist
,
msg
);
vsprintf
(
line
+
strlen
(
line
),
msg
,
arglist
);
va_end
(
arglist
);
puts
(
line
);
exit
(
EXIT_FAILURE
);
}
static
void
log_info
(
const
char
*
section
,
const
char
*
msg
,
...)
{
time_t
t
;
struct
tm
ts
;
char
line
[
256
];
va_list
arglist
;
time
(
&
t
);
ts
=
*
localtime
(
&
t
);
strftime
(
line
,
80
,
"%m-%d %H:%M:%S"
,
&
ts
);
sprintf
(
line
+
strlen
(
line
),
" INFO [%s] "
,
section
);
va_start
(
arglist
,
msg
);
vsprintf
(
line
+
strlen
(
line
),
msg
,
arglist
);
va_end
(
arglist
);
puts
(
line
);
}
int
startdpdk
(
TRXEcpriState
*
s
);
int
main
(
int
argc
,
char
*
argv
[])
{
(
void
)
argc
;
(
void
)
argv
;
TRXEcpriState
*
s
;
s
=
malloc
(
sizeof
(
TRXEcpriState
));
memset
(
s
,
0
,
sizeof
(
*
s
));
#if 0
s->rec_mac = "80:fa:5b:92:39:c3";
s->re_mac = "00:e0:4c:90:20:d3";
s->rec_if = "enp53s0";
#else
s
->
rec_mac
=
"b8:ce:f6:4b:00:22"
;
s
->
re_mac
=
"b8:ce:f6:4b:00:23"
;
s
->
rec_if
=
"ens5f0np0"
;
#endif
s
->
recv_affinity
=
39
;
s
->
send_affinity
=
38
;
s
->
prepare_affinity
=
37
;
s
->
decompress_affinity
=
36
;
s
->
statistic_affinity
=
35
;
s
->
ecpri_period
=
800
;
s
->
flow_id
=
0
;
s
->
sample_rate
=
122880000
;
log_info
(
"TEST-DPDK-ECPRI"
,
"Starting test...
\n
"
);
log_info
(
"TEST-DPDK-ECPRI"
,
"rec-mac: %s, re-mac: %s, rec-if: %s"
,
s
->
rec_mac
,
s
->
re_mac
,
s
->
rec_if
);
startdpdk
(
s
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
sleep
(
1
);
}
}
ecpri-tests/test.sh
0 → 100755
View file @
610210c8
#!/bin/bash
cd
..
;
make
;
cd
ecpri-tests
;
make all
;
./test-dpdk-ecpri
trx_ecpri_dpdk.c
0 → 100644
View file @
610210c8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment