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
e3cbb609
Commit
e3cbb609
authored
May 03, 2022
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add offset feature for tracing
parent
977bcccf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
39 deletions
+100
-39
trx_ecpri_dpdk.c
trx_ecpri_dpdk.c
+100
-39
No files found.
trx_ecpri_dpdk.c
View file @
e3cbb609
...
...
@@ -50,7 +50,9 @@
#define EFREQ 38400
//#define DEBUG // Enables / deactivates log_debug
//#define TRACE
//#define TRACE 0
//#define TRACE_TX
//#define TRACE_RX
//#define MONITOR
//#define MONITOR_EXIT
...
...
@@ -160,7 +162,12 @@ static uint8_t pkt_frame_full[1024];
#ifdef TRACE
static
volatile
int
rx_trace_ready
=
0
;
static
volatile
int
tx_trace_ready
=
1
;
static
int
tx_trace_index_start
=
0
;
static
int64_t
encode_counter_prev
=
0
;
static
int64_t
decode_counter_prev
=
0
;
static
volatile
int
rx_exited
=
0
;
static
volatile
int
trxr_exited
=
0
;
static
volatile
int
trxw_exited
=
0
;
static
volatile
int
tx_exited
=
0
;
#endif
// Network
...
...
@@ -381,57 +388,80 @@ static void update_counter(volatile counter_stat_t * c, int64_t v) {
#ifdef TRACE
static
void
trace_handler
(
struct
timespec
initial
,
TRXEcpriState
*
s
)
{
struct
timespec
next
;
if
(
tx_trace_ready
&&
rx_trace_ready
)
{
int
ready
=
1
;
#ifdef TRACE_TX
ready
&=
tx_trace_ready
;
#endif
#ifdef TRACE_RX
ready
&=
rx_trace_ready
;
#endif
if
(
ready
)
{
int64_t
d
;
clock_gettime
(
CLOCK_TAI
,
&
next
);
d
=
calcdiff_ns
(
next
,
initial
);
log_info
(
"TRACE"
,
"Packets sent: %"
PRIi64
,
sent_counter
.
counter
);
log_info
(
"TRACE"
,
"Duration: %"
PRIi64
,
d
);
log_info
(
"TRACE"
,
"FRAME_FREQ: %"
PRIi64
,
FRAME_FREQ
);
FILE
*
f
;
char
n
[
256
];
uint8_t
ones
[
14
];
int
start
;
for
(
int
i
=
0
;
i
<
14
;
i
++
)
ones
[
i
]
=
0xff
;
clock_gettime
(
CLOCK_TAI
,
&
next
);
d
=
calcdiff_ns
(
next
,
initial
);
log_info
(
"TRACE"
,
"Packets sent: %"
PRIi64
,
sent_counter
.
counter
);
log_info
(
"TRACE"
,
"Duration: %"
PRIi64
,
d
);
log_info
(
"TRACE"
,
"FRAME_FREQ: %"
PRIi64
,
FRAME_FREQ
);
#ifdef TRACE_TX
while
(
!
tx_exited
||
!
trxw_exited
)
{
usleep
(
1000
);
}
memset
(
n
,
'\0'
,
256
);
sprintf
(
n
,
"%s/tx.trace"
,
s
->
log_directory
);
f
=
fopen
(
n
,
"wb+"
);
log_info
(
"TRACE"
,
"Writing %d frames to tx.trace"
,
tx_rbuf
.
write_index
+
tx_rbuf
.
buf_len
-
tx_trace_index_start
);
for
(
int
i
=
tx_trace_index_start
;
i
!=
tx_rbuf
.
write_index
;
i
=
(
i
+
1
)
%
tx_rbuf
.
buf_len
)
{
start
=
(
TRACE
+
encode_counter_prev
)
%
tx_rbuf
.
buf_len
;
log_info
(
"TRACE"
,
"Writing %d frames to tx.trace"
,
tx_rbuf
.
write_index
+
tx_rbuf
.
buf_len
-
start
);
for
(
int
i
=
start
;
i
!=
tx_rbuf
.
write_index
;
i
=
(
i
+
1
)
%
tx_rbuf
.
buf_len
)
{
fwrite
(
ones
,
14
,
1
,
f
);
fwrite
(((
uint8_t
*
)
tx_rbuf
.
buffer
)
+
i
*
tx_rbuf
.
len
,
tx_rbuf
.
len
,
1
,
f
);
}
fclose
(
f
);
memset
(
n
,
'\0'
,
256
);
sprintf
(
n
,
"%s/
rx
.trace"
,
s
->
log_directory
);
sprintf
(
n
,
"%s/
trxw
.trace"
,
s
->
log_directory
);
f
=
fopen
(
n
,
"wb+"
);
log_info
(
"TRACE"
,
"Writing %d frames to rx.trace"
,
rx_rbuf
.
write_index
);
for
(
int
i
=
0
;
i
<
rx_rbuf
.
write_index
;
i
++
)
{
fwrite
(((
uint8_t
*
)
rx_rbuf
.
buffer
)
+
i
*
rx_rbuf
.
len
,
rx_rbuf
.
len
,
1
,
f
);
start
=
(
TRACE
)
%
trxw_rbuf
[
0
].
buf_len
;
log_info
(
"TRACE"
,
"Writing %d frames to trxw.trace"
,
trxw_rbuf
[
0
].
write_index
+
trxw_rbuf
.
buf_len
-
start
);
for
(
int
i
=
start
;
i
!=
trxw_rbuf
[
0
].
write_index
;
i
=
(
i
+
1
)
%
trxw_rbuf
[
0
].
buf_len
)
{
for
(
int
j
=
0
;
j
<
TX_N_CHANNEL
;
j
++
)
fwrite
((
uint8_t
*
)
(((
Complex
*
)
trxw_rbuf
[
j
].
buffer
)
+
i
*
trxw_rbuf
[
0
].
len
),
trxw_rbuf
[
0
].
len
*
sizeof
(
Complex
),
1
,
f
);
}
fclose
(
f
);
#endif
#ifdef TRACE_RX
while
(
!
rx_exited
||
!
trxr_exited
)
{
usleep
(
1000
);
}
memset
(
n
,
'\0'
,
256
);
sprintf
(
n
,
"%s/
trxw
.trace"
,
s
->
log_directory
);
sprintf
(
n
,
"%s/
rx
.trace"
,
s
->
log_directory
);
f
=
fopen
(
n
,
"wb+"
);
log_info
(
"TRACE"
,
"Writing %d frames to trxw.trace"
,
trxw_rbuf
[
0
].
write_index
)
;
for
(
int
i
=
0
;
i
<
trxw_rbuf
[
0
].
write_index
;
i
++
)
{
for
(
int
j
=
0
;
j
<
TX_N_CHANNEL
;
j
++
)
fwrite
((
uint8_t
*
)
(((
Complex
*
)
trxw_rbuf
[
j
].
buffer
)
+
i
*
trxw_rbuf
[
0
].
len
),
trxw_rbuf
[
0
].
len
*
sizeof
(
Complex
)
,
1
,
f
);
start
=
TRACE
%
rx_rbuf
.
buf_len
;
log_info
(
"TRACE"
,
"Writing %d frames to rx.trace"
,
rx_rbuf
.
write_index
+
rx_rbuf
.
buf_len
-
start
);
for
(
int
i
=
start
;
i
!=
rx_rbuf
.
write_index
;
i
=
(
i
+
1
)
%
rx_rbuf
.
buf_len
)
{
fwrite
(((
uint8_t
*
)
rx_rbuf
.
buffer
)
+
i
*
rx_rbuf
.
len
,
rx_rbuf
.
len
,
1
,
f
);
}
fclose
(
f
);
memset
(
n
,
'\0'
,
256
);
sprintf
(
n
,
"%s/trxr.trace"
,
s
->
log_directory
);
f
=
fopen
(
n
,
"wb+"
);
log_info
(
"TRACE"
,
"Writing %d frames to trxr.trace"
,
trxr_rbuf
[
0
].
write_index
);
for
(
int
i
=
0
;
i
<
trxr_rbuf
[
0
].
write_index
;
i
++
)
{
start
=
(
TRACE
+
decode_counter_prev
)
%
trxr_rbuf
.
buf_len
;
log_info
(
"TRACE"
,
"Writing %d frames to trxr.trace"
,
trxr_rbuf
[
0
].
write_index
+
trxr_rbuf
[
0
].
buf_len
-
start
);
for
(
int
i
=
start
;
i
!=
trxr_rbuf
[
0
].
write_index
;
i
=
(
i
+
1
)
%
trxr_rbuf
[
0
].
buf_len
)
{
for
(
int
j
=
0
;
j
<
RX_N_CHANNEL
;
j
++
)
fwrite
((
uint8_t
*
)
(((
Complex
*
)
trxr_rbuf
[
j
].
buffer
)
+
i
*
trxr_rbuf
[
0
].
len
),
trxr_rbuf
[
0
].
len
*
sizeof
(
Complex
),
1
,
f
);
}
fclose
(
f
);
#endif
log_exit
(
""
,
"Finished tracing"
);
}
}
...
...
@@ -519,11 +549,17 @@ static void *recv_thread(void *p) {
while
((
nc
=
rbuf_contiguous_copy
(
NULL
,
&
rx_rbuf
,
nr
)))
{
#ifdef TRACE
if
((
rx_rbuf
.
write_index
+
nc
)
>=
rx_rbuf
.
buf_len
)
{
log_info
(
"RECV_THREAD"
,
"RX Trace ready"
);
#if TRACE_RX
if
((
recv_counter
.
counter
+
nc
)
>=
(
rx_rbuf
.
buf_len
+
TRACE
))
{
rx_trace_ready
=
1
;
log_info
(
"RECV_THREAD"
,
"RX Trace ready"
);
rx_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
else
if
(
rx_trace_ready
)
{
rx_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
#endif
#endif
buf
=
((
uint8_t
*
)
rx_rbuf
.
buffer
)
+
(
rx_rbuf
.
write_index
*
rx_rbuf
.
len
);
...
...
@@ -612,8 +648,8 @@ static void *encode_thread(void *p) {
#ifdef START_SENDING
int64_t
target_counter
=
0
;
struct
timespec
next
;
#endif
int
reset_encode_counter
=
1
;
#endif
// Set thread CPU affinity
CPU_ZERO
(
&
mask
);
...
...
@@ -624,15 +660,6 @@ static void *encode_thread(void *p) {
for
(
int64_t
i
=
0
;;
i
++
)
{
int
n
;
if
(
sync_complete
&&
reset_encode_counter
)
{
encode_counter
.
counter
=
0
;
reset_encode_counter
=
0
;
seq_id
=
0
;
#ifdef TRACE
tx_trace_index_start
=
tx_rbuf
.
write_index
;
#endif
}
n
=
rbuf_write_amount
(
&
tx_rbuf
);
// Send empty frames until we receive something
...
...
@@ -655,6 +682,12 @@ static void *encode_thread(void *p) {
}
update_counter
(
&
encode_counter
,
n
);
}
else
if
(
reset_encode_counter
)
{
encode_counter_prev
=
encode_counter
.
counter
;
encode_counter
.
counter
=
0
;
reset_encode_counter
=
0
;
seq_id
=
0
;
}
#endif
// If we have frames to encode (is there space in TX buffer)
...
...
@@ -671,11 +704,17 @@ static void *encode_thread(void *p) {
nb_frames
=
g
->
count
>
n
?
n
:
g
->
count
;
g
->
count
-=
nb_frames
;
#ifdef TRACE
if
((
encode_counter
.
counter
+
nb_frames
)
>=
tx_rbuf
.
buf_len
)
{
log_info
(
"ENCODE_THREAD"
,
"TX Trace ready"
);
#if TRACE_TX
if
(
sync_complete
&&
(
encode_counter
.
counter
+
nb_frames
)
>=
(
tx_rbuf
.
buf_len
+
TRACE
))
{
tx_trace_ready
=
1
;
log_info
(
"ENCODE_THREAD"
,
"TX Trace ready"
);
tx_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
else
if
(
tx_trace_ready
)
{
tx_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
#endif
#endif
if
(
g
->
zeroes
)
{
for
(
int
j
=
0
;
j
<
nb_frames
;
j
++
)
{
...
...
@@ -726,6 +765,7 @@ static void *decode_thread(void *p) {
#ifdef START_RECEIVING
struct
timespec
next
;
int64_t
target_counter
=
0
;
int
reset_decode_counter
=
1
;
#endif
log_info
(
"DECODE_THREAD"
,
"Thread init"
);
...
...
@@ -738,7 +778,7 @@ static void *decode_thread(void *p) {
for
(
int64_t
i
=
0
;;
i
++
)
{
int
n
,
nc
;
#ifdef START_RECEIVING
if
(
!
received_pkts
&&
!
rbuf_read_amount
(
&
rx_rbuf
)
)
{
if
(
!
received_pkts
)
{
if
(
i
==
0
)
clock_gettime
(
CLOCK_TAI
,
&
next
);
// Limit packets sent
...
...
@@ -754,21 +794,36 @@ static void *decode_thread(void *p) {
update_counter
(
&
decode_counter
,
n
);
continue
;
}
else
if
(
reset_decode_counter
)
{
decode_counter_prev
=
decode_counter
.
counter
decode_counter
.
counter
=
0
;
reset_decode_counter
=
0
;
}
#endif
while
(
!
(
n
=
rbuf_read_amount
(
&
rx_rbuf
)));
while
(
rbuf_write_amount
(
&
trxr_rbuf
[
0
])
<
n
);
#ifdef TRACE
trxr_trace_index_start
=
trxr_rbuf
.
write_index
;
#endif
while
((
nc
=
rbuf_contiguous_copy
(
&
rx_rbuf
,
&
trxr_rbuf
[
0
],
n
)))
{
uint8_t
*
buf
=
((
uint8_t
*
)
rx_rbuf
.
buffer
)
+
(
rx_rbuf
.
read_index
*
rx_rbuf
.
len
)
+
22
;
#ifdef TRACE
if
((
trxr_rbuf
[
0
].
write_index
+
nc
)
>=
trxr_rbuf
[
0
].
buf_len
)
{
#if TRACE_RX
if
(
received_pkts
&&
((
decode_counter
.
counter
+
nc
)
>=
(
trxr_rbuf
[
0
].
buf_len
+
TRACE
)))
{
rx_trace_ready
=
1
;
log_info
(
"DECODE_THREAD"
,
"RX Trace ready"
);
trxr_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
else
if
(
rx_trace_ready
)
{
trxr_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
#endif
#endif
Complex
*
iq_samples
[
4
];
...
...
@@ -1109,11 +1164,17 @@ static void trx_ecpri_write(TRXState *s1, trx_timestamp_t timestamp, const void
}
#ifdef TRACE
if
((
trxw_rbuf
[
0
].
write_index
+
write_count
)
>=
trxw_rbuf
[
0
].
buf_len
)
{
log_info
(
"TRX_ECPRI_WRITE"
,
"TX Trace ready"
);
#if TRACE_TX
if
((
write_counter
.
counter
+
write_count
)
>=
(
trxw_rbuf
[
0
].
buf_len
+
TRACE
))
{
tx_trace_ready
=
1
;
log_info
(
"TRX_ECPRI_WRITE"
,
"TX Trace ready"
);
trxw_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
else
if
(
tx_trace_ready
)
{
trxw_exited
=
1
;
pthread_exit
(
EXIT_SUCCESS
);
}
#endif
#endif
if
(
first_trx_write
)
{
...
...
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