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
cee0e699
Commit
cee0e699
authored
Jan 27, 2025
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
3785f12d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
15 deletions
+50
-15
trx_ecpri.c
trx_ecpri.c
+50
-15
No files found.
trx_ecpri.c
View file @
cee0e699
...
...
@@ -164,6 +164,7 @@ static counter_stat_t rx_drop_counter; // frames sent to RRH
static
counter_stat_t
tx_drop_counter
;
// frames sent to RRH
// Network
static
uint8_t
prev_seq_id
;
static
uint8_t
seq_id
;
static
uint8_t
frame_id
;
static
uint8_t
sub_frame_id
;
...
...
@@ -367,6 +368,33 @@ static void update_counter(counter_stat_t * c, int64_t v) {
c
->
counter
+=
v
;
}
void
print_bytes
(
const
char
*
str
,
uint8_t
*
data
,
int
*
offset
,
int
count
)
{
int
i
;
printf
(
"%s"
,
str
);
for
(
i
=
*
offset
;
i
<
(
*
offset
+
count
);
i
++
)
printf
(
"%X"
,
data
[
i
]);
*
offset
+=
count
;
printf
(
"
\n
"
);
}
void
print_packet
(
uint8_t
*
data
,
int
length
)
{
int
offset
=
0
;
int
j
;
uint16_t
antenna_id
;
uint8_t
_seq_id
;
print_bytes
(
"MAC DST: "
,
data
,
&
offset
,
6
);
print_bytes
(
"MAC SRC: "
,
data
,
&
offset
,
6
);
print_bytes
(
"Ethertype: "
,
data
,
&
offset
,
2
);
print_bytes
(
"eCPRI Common Header: "
,
data
,
&
offset
,
4
);
print_bytes
(
"IQ DATA Header: "
,
data
,
&
offset
,
4
);
print_bytes
(
"IQ payload:
\n
"
,
data
,
&
offset
,
length
-
offset
);
j
=
ETHERNET_HEADER
+
ECPRI_COMMON_HEADER
;
antenna_id
=
ntohs
(
*
((
uint16_t
*
)
(
data
+
j
+
0
)));
_seq_id
=
((
uint8_t
)
(
*
((
uint16_t
*
)
(
data
+
j
+
2
))
>>
8
));
printf
(
"Antenna ID: %d
\n
"
,
antenna_id
);
printf
(
"Seq ID: %d
\n
"
,
_seq_id
);
}
#define MAX_RX_BURST 32768
static
void
*
recv_thread
(
void
*
p
)
{
#ifdef DISABLE_RECV
...
...
@@ -405,20 +433,19 @@ static void *recv_thread(void *p) {
for
(
int
j
=
0
;
j
<
s
->
rx_burst
;)
{
uint8_t
*
data
;
int
other_packets
=
0
;
int
ret
=
recvmmsg
(
recv_sockfd
,
msgh
+
j
,
s
->
rx_burst
-
j
,
0
,
NULL
);
if
(
ret
<=
-
1
)
error
(
EXIT_FAILURE
,
errno
,
"recvmmsg error"
);
for
(
int
l
=
0
;
l
<
ret
;
l
++
)
{
if
((
msgh
+
j
+
l
)
->
msg_len
!=
PACKET_SIZE
)
log_exit
(
"RECV_THREAD"
,
"Received message has len %d instead of %d"
,
(
msgh
+
j
+
l
)
->
msg_len
,
PACKET_SIZE
);
data
=
((
uint8_t
*
)
((
msgh
+
j
+
l
)
->
msg_hdr
.
msg_iov
->
iov_base
));
int
o
=
ETHERNET_HEADER
+
ECPRI_COMMON_HEADER
;
uint16_t
antenna_id
=
ntohs
(
*
((
uint16_t
*
)
(
data
+
o
+
0
)));
uint8_t
seq_id
=
((
uint8_t
)
(
*
((
uint16_t
*
)
(
data
+
o
+
2
))
>>
8
));
if
(
antenna_id
>
s
->
rx_n_channel
||
antenna_id
<
0
)
{
log_exit
(
"RECV_THREAD"
,
"Wrong Antenna ID: %d
\n
"
,
antenna_id
);
}
if
(
((
uint16_t
*
)
data
)[
6
]
!=
0xaefe
)
other_packets
++
;
else
if
((
msgh
+
j
+
l
)
->
msg_len
!=
PACKET_SIZE
)
{
other_packets
++
;
print_packet
(
data
,
(
msgh
+
j
+
l
)
->
msg_len
);
log_exit
(
"RECV_THREAD"
,
"Received message has len %d instead of %d"
,
(
msgh
+
j
+
l
)
->
msg_len
,
PACKET_SIZE
);
}
}
j
+=
ret
;
update_counter
(
&
recv_counter
,
ret
);
...
...
@@ -569,6 +596,7 @@ static void *decode_thread(void *p) {
cpu_set_t
mask
;
uint8_t
*
data
;
TRXEcpriState
*
s
=
(
TRXEcpriState
*
)
p
;
int
stop
=
0
;
log_info
(
"DECODE_THREAD"
,
"Thread init"
);
// Set thread CPU affinity
...
...
@@ -589,20 +617,27 @@ static void *decode_thread(void *p) {
int
j
=
ETHERNET_HEADER
+
ECPRI_COMMON_HEADER
;
uint16_t
antenna_id
=
ntohs
(
*
((
uint16_t
*
)
(
data
+
j
+
0
)));
uint8_t
seq_id
=
((
uint8_t
)
(
*
((
uint16_t
*
)
(
data
+
j
+
2
))
>>
8
));
uint8_t
_
seq_id
=
((
uint8_t
)
(
*
((
uint16_t
*
)
(
data
+
j
+
2
))
>>
8
));
if
(
(((
int
)
prev_seq_id
)
-
((
int
)
_seq_id
)
+
256
)
%
256
!=
1
)
{
stop
=
1
;
log_info
(
"DECODE_THREAD"
,
"seq_ids are not sequential (%d, %d)"
,
prev_seq_id
,
_seq_id
);
}
if
(
antenna_id
>
s
->
rx_n_channel
||
antenna_id
<
0
)
{
stop
=
1
;
log_info
(
"DECODE_THREAD"
,
"Wrong Antenna ID: %d
\n
"
,
antenna_id
);
}
if
(
stop
)
{
printf
(
"PREVIOUS PACKET DATA:
\n
"
);
for
(
int
k
=
0
;
k
<
PACKET_SIZE
*
2
;
k
++
)
printf
(
"%X"
,
rbuf_read
(
&
rx_rbuf
)[
k
-
PACKET_SIZE
]);
printf
(
"
\n
"
);
printf
(
"PACKET DATA:
\n
"
);
printf
(
"
\n
PACKET DATA:
\n
"
);
for
(
int
k
=
0
;
k
<
PACKET_SIZE
;
k
++
)
printf
(
"%X"
,
data
[
k
]);
printf
(
"
\n
"
);
printf
(
"RX RI = %d, PACKET_SIZE = %d
\n
"
,
rx_rbuf
.
read_index
,
PACKET_SIZE
);
log_exit
(
"DECODE_THREAD"
,
"Wrong Antenna ID: %d
\n
"
,
antenna_id
);
printf
(
"
\n
RX RI = %d, PACKET_SIZE = %d
\n
"
,
rx_rbuf
.
read_index
,
PACKET_SIZE
);
log_exit
(
"DECODE_THREAD"
,
"Exiting"
);
}
prev_seq_id
=
_seq_id
;
memcpy
(
trxr_rbuf
[
antenna_id
].
buffer
,
data
+
PACKET_HEADER
,
IQ_PAYLOAD
);
...
...
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