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
f4dcc629
Commit
f4dcc629
authored
Dec 18, 2024
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
454bb157
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
46 deletions
+37
-46
trx_ecpri.c
trx_ecpri.c
+37
-46
No files found.
trx_ecpri.c
View file @
f4dcc629
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#define PPS_UPDATE_PERIOD INT64_C(1000000000)
#define PPS_UPDATE_PERIOD INT64_C(1000000000)
#define STAT_INT_LEN "9"
#define STAT_INT_LEN "9"
#define N_SAMPLES (32)
#define MIN_PACKET_SIZE 64
#define MIN_PACKET_SIZE 64
#define MAX_CHANNELS 4
#define MAX_CHANNELS 4
#define ETHERNET_HEADER 14
#define ETHERNET_HEADER 14
...
@@ -850,87 +851,77 @@ static void trx_ecpri_end(TRXState *s1)
...
@@ -850,87 +851,77 @@ static void trx_ecpri_end(TRXState *s1)
free
(
s
);
free
(
s
);
}
}
static
int64_t
prev_t
s
=
0
;
static
int64_t
prev_t
imestamp
=
0
;
static
int64_t
prev_count
=
0
;
static
int64_t
prev_count
=
0
;
#define M 32
/* count: how much IQ samples to write (multiple of 32)
timestamp: should be equal to the amount of written IQ samples
__samples: can be null if zeroes are to be written
*/
static
void
trx_ecpri_write
(
TRXState
*
s1
,
trx_timestamp_t
timestamp
,
const
void
**
__samples
,
int
count
,
int
tx_port_index
,
TRXWriteMetadata
*
md
)
static
void
trx_ecpri_write
(
TRXState
*
s1
,
trx_timestamp_t
timestamp
,
const
void
**
__samples
,
int
count
,
int
tx_port_index
,
TRXWriteMetadata
*
md
)
{
{
int
write_count
;
int64_t
ts
;
sample_group_t
*
g
;
int
64_t
count_left
,
ts
;
sample_group_t
*
g
;
size_t
nc
,
nk
;
size_t
nc
,
nk
;
float
**
_samples
=
(
float
**
)
__samples
;
float
**
_samples
=
(
float
**
)
__samples
;
TRXEcpriState
*
s
=
s1
->
opaque
;
TRXEcpriState
*
s
=
s1
->
opaque
;
write_count
=
count
/
M
;
ts
=
timestamp
/
M
;
log_debug
(
"TRX_ECPRI_WRITE"
,
"trx_ecpri_write, count = %ld"
,
count
);
log_debug
(
"TRX_ECPRI_WRITE"
,
"trx_ecpri_write, count = %ld"
,
count
);
if
(
prev_count
&&
((
t
s
-
prev_ts
)
!=
prev_count
))
{
if
(
prev_count
&&
((
t
imestamp
-
prev_timestamp
)
!=
prev_count
))
{
log_exit
(
"TRX_ECPRI_WRITE"
,
log_exit
(
"TRX_ECPRI_WRITE"
,
"Gap between timestamps: prev_ts %li ts %li prev_count %li count %li diff_ts %li"
,
"Gap between timestamps: prev_ts %li ts %li prev_count %li count %li diff_ts %li"
,
prev_t
s
,
ts
,
prev_count
,
count
,
(
ts
-
prev_ts
));
prev_t
imestamp
,
timestamp
,
prev_count
,
count
,
(
timestamp
-
prev_timestamp
));
}
}
prev_t
s
=
ts
;
prev_count
=
write_
count
;
prev_t
imestamp
=
timestamp
;
prev_count
=
count
;
if
(
write_count
>
rbuf_write_amount
(
&
trxw_rbuf
[
0
])
)
{
if
(
count
>
(
rbuf_write_amount
(
&
trxw_rbuf
[
0
])
/
sizeof
(
Complex
))
)
{
//log_exit("TRX_ECPRI_WRITE",
//log_exit("TRX_ECPRI_WRITE",
// "Not enough space to write in trxw_rbuf (
write count = %d)", write_
count);
// "Not enough space to write in trxw_rbuf (
count = %d)",
count);
update_counter
(
&
tx_drop_counter
,
write_count
);
update_counter
(
&
tx_drop_counter
,
count
/
N_SAMPLES
);
return
;
return
;
}
}
if
(
first_trx_write
)
{
count_left
=
count
sample_group_t
*
g2
=
RBUF_WRITE0
(
trxw_group_rbuf
,
sample_group_t
);
while
((
nc
=
rbuf_contiguous_copy
(
NULL
,
&
trxw_rbuf
[
0
],
count_left
*
sizeof
(
Complex
))))
{
g2
->
count
=
ts
;
for
(
int
i
=
0
;
i
<
s
->
tx_n_channel
;
i
++
)
{
g2
->
wait
=
1
;
if
(
__samples
)
g2
->
zeroes
=
1
;
rbuf_update_write_index
(
&
trxw_group_rbuf
);
}
g
=
RBUF_WRITE0
(
trxw_group_rbuf
,
sample_group_t
);
g
->
zeroes
=
__samples
?
0
:
1
;
g
->
wait
=
0
;
g
->
count
=
write_count
;
while
((
nc
=
rbuf_contiguous_copy
(
NULL
,
&
trxw_rbuf
[
0
],
write_count
)))
{
size_t
len
=
nc
*
trxr_rbuf
[
0
].
len
*
sizeof
(
Complex
);
if
(
__samples
)
for
(
int
i
=
0
;
i
<
s
->
tx_n_channel
;
i
++
)
{
memcpy
(
memcpy
(
((
uint8_t
*
)
trxw_rbuf
[
i
].
buffer
)
+
\
((
uint8_t
*
)
trxw_rbuf
[
i
].
buffer
)
+
trxw_rbuf
[
0
].
write_index
,
trxw_rbuf
[
0
].
write_index
*
trxw_rbuf
[
0
].
len
*
sizeof
(
Complex
),
((
uint8_t
*
)
_samples
[
i
])
+
nk
,
((
uint8_t
*
)
_samples
[
i
])
+
nk
,
len
);
nc
);
}
else
trxw_rbuf
[
0
].
write_index
=
(
trxw_rbuf
[
0
].
write_index
+
nc
)
%
trxw_rbuf
[
0
].
buf_len
;
memset
(
write_count
-=
nc
;
((
uint8_t
*
)
trxw_rbuf
[
i
].
buffer
)
+
trxw_rbuf
[
0
].
write_index
,
0
,
nc
);
}
rbuf_increment_write
(
&
trxw_rbuf
,
nc
);
count_left
-=
nc
/
sizeof
(
Complex
);
nk
+=
nc
;
nk
+=
nc
;
}
}
update_counter
(
&
write_counter
,
count
/
N_SAMPLES
);
rbuf_update_write_index
(
&
trxw_group_rbuf
);
update_counter
(
&
write_counter
,
count
/
M
);
}
}
static
int
trx_ecpri_read
(
TRXState
*
s1
,
trx_timestamp_t
*
ptimestamp
,
void
**
__samples
,
int
count
,
int
rx_port_index
,
TRXReadMetadata
*
md
)
static
int
trx_ecpri_read
(
TRXState
*
s1
,
trx_timestamp_t
*
ptimestamp
,
void
**
__samples
,
int
count
,
int
rx_port_index
,
TRXReadMetadata
*
md
)
{
{
int
nc
;
int
n
;
int
64_t
nc
;
int64_t
n
,
count_left
;
float
**
_samples
=
(
float
**
)
__samples
;
float
**
_samples
=
(
float
**
)
__samples
;
int
read_count
=
(
count
/
M
);
int
offset
=
0
;
int
offset
=
0
;
TRXEcpriState
*
s
=
s1
->
opaque
;
TRXEcpriState
*
s
=
s1
->
opaque
;
log_debug
(
"TRX_ECPRI_READ"
,
"count = %ld (%li)"
,
read_
count
,
read_counter
.
counter
);
log_debug
(
"TRX_ECPRI_READ"
,
"count = %ld (%li)"
,
count
,
read_counter
.
counter
);
while
(
rbuf_read_amount
(
&
trxr_rbuf
[
0
])
<
read_
count
);
while
(
(
rbuf_read_amount
(
&
trxr_rbuf
[
0
])
/
sizeof
(
Complex
))
<
count
);
sync_complete
=
1
;
sync_complete
=
1
;
n
=
read_count
;
count_left
=
count
;
while
((
nc
=
rbuf_contiguous_copy
(
&
trxr_rbuf
[
0
],
NULL
,
n
)))
{
while
((
nc
=
rbuf_contiguous_copy
(
&
trxr_rbuf
[
0
],
NULL
,
count_left
*
sizeof
(
Complex
))))
{
int
len
=
nc
*
trxr_rbuf
[
0
].
len
*
sizeof
(
Complex
);
for
(
int
i
=
0
;
i
<
s
->
rx_n_channel
;
i
++
)
{
for
(
int
i
=
0
;
i
<
s
->
rx_n_channel
;
i
++
)
{
uint8_t
*
dst
=
(
uint8_t
*
)
(
_samples
[
i
]
+
offset
);
memcpy
(
uint8_t
*
src
=
((
uint8_t
*
)
trxr_rbuf
[
i
].
buffer
)
+
trxr_rbuf
[
0
].
read_index
*
trxr_rbuf
[
0
].
len
*
sizeof
(
Complex
);
(
uint8_t
*
)
(
_samples
[
i
]
+
offset
),
memcpy
(
dst
,
src
,
len
);
((
uint8_t
*
)
trxr_rbuf
[
i
].
buffer
)
+
trxr_rbuf
[
0
].
read_index
*
trxr_rbuf
[
0
].
len
*
sizeof
(
Complex
);
,
len
);
}
}
trxr_rbuf
[
0
].
read_index
=
(
trxr_rbuf
[
0
].
read_index
+
nc
)
%
trxr_rbuf
[
0
].
buf_len
;
trxr_rbuf
[
0
].
read_index
=
(
trxr_rbuf
[
0
].
read_index
+
nc
)
%
trxr_rbuf
[
0
].
buf_len
;
n
-=
nc
;
n
-=
nc
;
...
...
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