octoi: Simple RX priming / pre-filling

This was not an issue with the original FIFO code, which dynamically
substituted frames and always created the minimal required backlog.

The RIFO can by principle not operate this way, so we really have to
prime / pre-fill it with a number of TDM frames.  That initial fill
level has to be sufficient to cover RTT jitter of the OCTOI link as
well as clock drift between (GPS synced) receiver and transmitter.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I3a4b3846d3dbd1c99989e994ad95e609f2757219
This commit is contained in:
Sylvain Munaut 2022-04-17 07:41:52 +00:00 committed by Harald Welte
parent 99161f1423
commit 8a2e82560c
3 changed files with 9 additions and 1 deletions

View File

@ -286,7 +286,7 @@ struct e1oip_line *e1oip_line_alloc(struct octoi_peer *peer)
e1oip_line_set_name(iline, peer->name);
iline->cfg.batching_factor = 32;
iline->cfg.prefill_frame_count = 400; /* 50ms */
iline->cfg.prefill_frame_count = 200; /* 25ms */
e1oip_line_reset(iline);
@ -305,6 +305,7 @@ void e1oip_line_reset(struct e1oip_line *iline)
frame_rifo_init(&iline->e1t.rifo);
memset(&iline->e1t.last_frame, 0xff, sizeof(iline->e1t.last_frame));
iline->e1t.next_fn32 = 0;
iline->e1t.primed_rx_tdm = false;
}
void e1oip_line_destroy(struct e1oip_line *iline)

View File

@ -53,6 +53,7 @@ struct e1oip_line {
struct frame_rifo rifo;
uint8_t last_frame[BYTES_PER_FRAME]; /* last frame on the E1 side */
uint32_t next_fn32; /* next expected frame number */
bool primed_rx_tdm; /* Was RX RIFO primed */
} e1t;
/* TODO: statistics (RTT, frame loss, std deviation, alarms */

View File

@ -118,6 +118,12 @@ void octoi_peer_e1t_out(struct octoi_peer *peer, uint8_t *buf, int fts)
if (!peer->tdm_permitted)
return;
if (!iline->e1t.primed_rx_tdm) {
if (frame_rifo_frames(&iline->e1t.rifo) > iline->cfg.prefill_frame_count)
iline->e1t.primed_rx_tdm = true;
return;
}
for (int i = 0; i < fts; i++) {
uint8_t *cur = buf + BYTES_PER_FRAME*i;
rc = frame_rifo_out(&iline->e1t.rifo, cur);