aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-04-17 11:28:44 +0200
committerHarald Welte <laforge@osmocom.org>2022-04-17 11:37:29 +0200
commitdb59c3f4b9364dee17f90afc36cfd9be3b8d539f (patch)
tree1867776538cf0ac7d95435936885bc8d3bd12218 /src
parent2c0af2fa987668af1c6ce9de3d9380803cffee61 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/octoi/e1oip.c2
-rw-r--r--src/octoi/frame_rifo.c7
-rw-r--r--src/octoi/frame_rifo.h6
3 files changed, 13 insertions, 2 deletions
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 @@ int e1oip_rcvmsg_tdm_data(struct e1oip_line *iline, struct msgb *msg)
//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 @@ int frame_rifo_in(struct frame_rifo *rifo, const uint8_t *frame, uint32_t fn)
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 @@ int frame_rifo_out(struct frame_rifo *rifo, uint8_t *out)
/* 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 @@ struct frame_rifo {
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 @@ static inline bool frame_rifo_fn_in_range(const struct frame_rifo *ff, uint32_t
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);