laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27809 )
Change subject: OCTOI: re-implement LINE_STAT_E1oIP_E1T_FIFO ......................................................................
OCTOI: re-implement LINE_STAT_E1oIP_E1T_FIFO
There use to be a stat_item for the depth of the E1-terminated FIFO, as in a FIFO this is very easy to determine. When we switched to RIFO, it was lost. Let's re-introduce it with the approximate depth of the RIFO.
Change-Id: I960cbf196ae930b1b72745b8bfe9c2a21fd53325 --- M src/octoi/e1oip.c M src/octoi/frame_rifo.c M src/octoi/frame_rifo.h 3 files changed, 13 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/09/27809/1
diff --git a/src/octoi/e1oip.c b/src/octoi/e1oip.c index 00c671d..490b7f4 100644 --- a/src/octoi/e1oip.c +++ b/src/octoi/e1oip.c @@ -256,7 +256,7 @@ //if (fn32 >= iline->e1t.next_fn32I iline->e1t.next_fn32 = fn32 + n_frames;
- //iline_stat_set(iline, LINE_STAT_E1oIP_E1T_FIFO, frame_fifo_frames(&iline->e1t.fifo)); + iline_stat_set(iline, LINE_STAT_E1oIP_E1T_FIFO, frame_rifo_depth(&iline->e1t.rifo));
return 0; } diff --git a/src/octoi/frame_rifo.c b/src/octoi/frame_rifo.c index 9f25cf0..94758e9 100644 --- a/src/octoi/frame_rifo.c +++ b/src/octoi/frame_rifo.c @@ -122,6 +122,7 @@ OSMO_ASSERT(dst + BYTES_PER_FRAME <= RIFO_BUF_END(rifo)); memcpy(dst, frame, BYTES_PER_FRAME); bucket_bit_set(rifo, bucket); + rifo->last_in_fn = fn;
return 0; } @@ -147,9 +148,13 @@
/* advance by one frame */ rifo->next_out += BYTES_PER_FRAME; - rifo->next_out_fn += 1; if (rifo->next_out >= RIFO_BUF_END(rifo)) rifo->next_out -= sizeof(rifo->buf);
+ rifo->next_out_fn += 1; + /* make sure that frame_rifo_depth() doing last_in - next_out won't overflow */ + if (rifo->next_out_fn == rifo->last_in_fn + 1) + rifo->last_in_fn = rifo->next_out_fn; + return rc; } diff --git a/src/octoi/frame_rifo.h b/src/octoi/frame_rifo.h index 6988710..401e873 100644 --- a/src/octoi/frame_rifo.h +++ b/src/octoi/frame_rifo.h @@ -7,6 +7,7 @@
uint8_t buf[BYTES_PER_FRAME * FRAMES_PER_FIFO];
+ uint32_t last_in_fn; /* frame number of most recently inserted frame */ uint32_t next_out_fn; /* frame number of next output frame */ uint8_t bitvec[FRAMES_PER_FIFO/8]; /* bit-vector of occupied (data received) slots in FIFO, @@ -20,6 +21,11 @@ return d < FRAMES_PER_FIFO; }
+/* current depth of RIFO */ +static inline unsigned int frame_rifo_depth(struct frame_rifo *rifo) +{ + return rifo->last_in_fn - rifo->next_out_fn; +}
void frame_rifo_init(struct frame_rifo *rifo);