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
06c22671
Commit
06c22671
authored
Oct 05, 2021
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up
parent
821d9418
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
11 deletions
+23
-11
af-xdp-test/af_xdp.c
af-xdp-test/af_xdp.c
+21
-9
raw-socket-test/Makefile
raw-socket-test/Makefile
+1
-1
raw-socket-test/raw_socket.c
raw-socket-test/raw_socket.c
+0
-0
raw-socket-test/test.sh
raw-socket-test/test.sh
+1
-1
No files found.
af-xdp-test/af_xdp.c
View file @
06c22671
...
@@ -45,17 +45,21 @@
...
@@ -45,17 +45,21 @@
exit(EXIT_FAILURE); \
exit(EXIT_FAILURE); \
} while (0)
} while (0)
#define err_errno(...) error(EXIT_FAILURE, errno, __VA_ARGS__);
#define err_errno(...) error(EXIT_FAILURE, errno, __VA_ARGS__);
#define NUM_FRAMES 4096
#define ETH_FCS_SIZE 4
#define ETH_FCS_SIZE 4
//#define FRAME_SIZE XSK_UMEM__DEFAULT_FRAME_SIZE
#define FRAME_SIZE XSK_UMEM__DEFAULT_FRAME_SIZE
#define FRAME_SIZE 2048
#define PACKET_SIZE 262
#define PACKET_SIZE 262
#define BUFFER_SIZE 4096
#define NB_PACKETS 1000000
#define NB_PACKETS 1000000
//#define NB_PACKETS 100
#define BATCH_SIZE 2048
#define BATCH_SIZE 2048
//#define PRINT_PROGRESS
//#define PRINT_PROGRESS
#define PRINT_PROGRESS_INTERVAL 1000
#define PRINT_PROGRESS_INTERVAL 1000
#define ACTIVE_POLLING
//#define DEBUG
//#define DEBUG
static
void
log_info
(
const
char
*
section
,
const
char
*
msg
,
...)
{
static
void
log_info
(
const
char
*
section
,
const
char
*
msg
,
...)
{
time_t
t
;
time_t
t
;
...
@@ -234,11 +238,11 @@ static void init_xdp_send(char * network_if) {
...
@@ -234,11 +238,11 @@ static void init_xdp_send(char * network_if) {
log_debug
(
""
,
"posix_memalign"
);
log_debug
(
""
,
"posix_memalign"
);
/* Allocate user space memory for xdp frames */
/* Allocate user space memory for xdp frames */
ret
=
posix_memalign
(
&
buffer
,
sysconf
(
_SC_PAGE_SIZE
),
NUM_FRAMES
*
FRAME_SIZE
);
ret
=
posix_memalign
(
&
buffer
,
sysconf
(
_SC_PAGE_SIZE
),
BUFFER_SIZE
*
FRAME_SIZE
);
if
(
ret
)
err_errno
(
"posix_memalign() failed"
);
if
(
ret
)
err_errno
(
"posix_memalign() failed"
);
log_debug
(
""
,
"xsk_umem__create"
);
log_debug
(
""
,
"xsk_umem__create"
);
ret
=
xsk_umem__create
(
&
send_xdp_socket
.
umem
.
umem
,
buffer
,
NUM_FRAMES
*
FRAME_SIZE
,
ret
=
xsk_umem__create
(
&
send_xdp_socket
.
umem
.
umem
,
buffer
,
BUFFER_SIZE
*
FRAME_SIZE
,
&
send_xdp_socket
.
umem
.
fq
,
&
send_xdp_socket
.
umem
.
cq
,
&
cfg
);
&
send_xdp_socket
.
umem
.
fq
,
&
send_xdp_socket
.
umem
.
cq
,
&
cfg
);
if
(
ret
)
err
(
"xsk_umem__create() failed"
);
if
(
ret
)
err
(
"xsk_umem__create() failed"
);
send_xdp_socket
.
umem
.
buffer
=
buffer
;
send_xdp_socket
.
umem
.
buffer
=
buffer
;
...
@@ -275,11 +279,11 @@ static void init_xdp_recv(char * network_if) {
...
@@ -275,11 +279,11 @@ static void init_xdp_recv(char * network_if) {
log_debug
(
""
,
"posix_memalign"
);
log_debug
(
""
,
"posix_memalign"
);
/* Allocate user space memory for xdp frames */
/* Allocate user space memory for xdp frames */
ret
=
posix_memalign
(
&
buffer
,
sysconf
(
_SC_PAGE_SIZE
),
NUM_FRAMES
*
FRAME_SIZE
);
ret
=
posix_memalign
(
&
buffer
,
sysconf
(
_SC_PAGE_SIZE
),
BUFFER_SIZE
*
FRAME_SIZE
);
if
(
ret
)
err_errno
(
"posix_memalign() failed"
);
if
(
ret
)
err_errno
(
"posix_memalign() failed"
);
log_debug
(
""
,
"xsk_umem__create"
);
log_debug
(
""
,
"xsk_umem__create"
);
ret
=
xsk_umem__create
(
&
recv_xdp_socket
.
umem
.
umem
,
buffer
,
NUM_FRAMES
*
FRAME_SIZE
,
ret
=
xsk_umem__create
(
&
recv_xdp_socket
.
umem
.
umem
,
buffer
,
BUFFER_SIZE
*
FRAME_SIZE
,
&
recv_xdp_socket
.
umem
.
fq
,
&
recv_xdp_socket
.
umem
.
cq
,
&
cfg
);
&
recv_xdp_socket
.
umem
.
fq
,
&
recv_xdp_socket
.
umem
.
cq
,
&
cfg
);
if
(
ret
)
err
(
"xsk_umem__create() failed"
);
if
(
ret
)
err
(
"xsk_umem__create() failed"
);
recv_xdp_socket
.
umem
.
buffer
=
buffer
;
recv_xdp_socket
.
umem
.
buffer
=
buffer
;
...
@@ -321,7 +325,7 @@ static void send_xdp_packet(void) {
...
@@ -321,7 +325,7 @@ static void send_xdp_packet(void) {
fds
[
0
].
fd
=
xsk_socket__fd
(
send_xdp_socket
.
xsk
);
fds
[
0
].
fd
=
xsk_socket__fd
(
send_xdp_socket
.
xsk
);
fds
[
0
].
events
=
POLLOUT
;
fds
[
0
].
events
=
POLLOUT
;
for
(
int
i
=
0
;
i
<
NUM_FRAMES
;
i
++
)
for
(
int
i
=
0
;
i
<
BUFFER_SIZE
;
i
++
)
memcpy
(
xsk_umem__get_data
(
send_xdp_socket
.
umem
.
buffer
,
i
*
FRAME_SIZE
),
pkt_data
,
PACKET_SIZE
-
ETH_FCS_SIZE
);
memcpy
(
xsk_umem__get_data
(
send_xdp_socket
.
umem
.
buffer
,
i
*
FRAME_SIZE
),
pkt_data
,
PACKET_SIZE
-
ETH_FCS_SIZE
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
start
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
start
);
...
@@ -334,11 +338,19 @@ static void send_xdp_packet(void) {
...
@@ -334,11 +338,19 @@ static void send_xdp_packet(void) {
progress
+=
PRINT_PROGRESS_INTERVAL
;
progress
+=
PRINT_PROGRESS_INTERVAL
;
}
}
#endif
#endif
#ifdef ACTIVE_POLLING
ret
=
poll
(
fds
,
1
,
0
);
ret
=
poll
(
fds
,
1
,
0
);
if
((
ret
<=
0
)
||
!
(
fds
[
0
].
revents
&
POLLOUT
))
{
if
((
ret
<=
0
)
||
!
(
fds
[
0
].
revents
&
POLLOUT
))
{
complete_tx_only
();
complete_tx_only
();
continue
;
continue
;
}
}
#else
ret
=
poll
(
fds
,
1
,
100
);
if
((
ret
<=
0
)
||
!
(
fds
[
0
].
revents
&
POLLOUT
))
{
complete_tx_only
();
continue
;
}
#endif
while
(
xsk_ring_prod__reserve
(
&
send_xdp_socket
.
tx
,
batch_size
,
&
idx
)
<
batch_size
)
while
(
xsk_ring_prod__reserve
(
&
send_xdp_socket
.
tx
,
batch_size
,
&
idx
)
<
batch_size
)
complete_tx_only
();
complete_tx_only
();
...
...
raw-socket-test/Makefile
View file @
06c22671
...
@@ -2,7 +2,7 @@ CC=gcc
...
@@ -2,7 +2,7 @@ CC=gcc
CFLAGS
=
-O2
CFLAGS
=
-O2
CFLAGS
+=
-g
CFLAGS
+=
-g
PROG
=
raw_
pa
cket
PROG
=
raw_
so
cket
OBJ
=
$(PROG)
.o
OBJ
=
$(PROG)
.o
all
:
$(PROG)
all
:
$(PROG)
...
...
raw-socket-test/raw_
pa
cket.c
→
raw-socket-test/raw_
so
cket.c
View file @
06c22671
File moved
raw-socket-test/test.sh
View file @
06c22671
...
@@ -7,6 +7,6 @@ tx_packets() {
...
@@ -7,6 +7,6 @@ tx_packets() {
make clean
&&
make
;
make clean
&&
make
;
A
=
$(
tx_packets
)
A
=
$(
tx_packets
)
nice
-n
-20
chrt 99 ./raw_
pa
cket
;
nice
-n
-20
chrt 99 ./raw_
so
cket
;
B
=
$(
tx_packets
)
B
=
$(
tx_packets
)
echo
"Ethtool tx packets sent:
$((
B
-
A
))
"
;
echo
"Ethtool tx packets sent:
$((
B
-
A
))
"
;
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