This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26706 )
Change subject: icE1usb firmware: Detect A-bit in TS0; set flag in usb xfer hdr
......................................................................
icE1usb firmware: Detect A-bit in TS0; set flag in usb xfer hdr
Scan over every odd E1 frame TS0 byte to check if the A-bit is
set, indiciating a remote alarm. If so, set a new flag in the
USB IN transfer header.
Change-Id: Ic4f57cf79bd32cf75f81ef3073cb8d4a2d1857d8
---
M firmware/ice40-riscv/icE1usb/e1.c
M firmware/ice40-riscv/icE1usb/usb_e1.c
2 files changed, 25 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/06/26706/1
diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c
index 5e57480..1955936 100644
--- a/firmware/ice40-riscv/icE1usb/e1.c
+++ b/firmware/ice40-riscv/icE1usb/e1.c
@@ -288,12 +288,16 @@
#include "dma.h"
unsigned int
-e1_rx_need_data(unsigned int usb_addr, unsigned int max_frames, unsigned int *pos)
+e1_rx_need_data(unsigned int usb_addr, unsigned int max_frames, unsigned int *pos,
+ unsigned int *alarm_cnt)
{
unsigned int ofs;
int tot_frames = 0;
int n_frames;
+ if (alarm_cnt)
+ *alarm_cnt = 0;
+
while (max_frames) {
/* Get some data from the FIFO */
n_frames = e1f_frame_read(&g_e1.rx.fifo, &ofs, max_frames);
@@ -314,6 +318,19 @@
max_frames -= n_frames;
tot_frames += n_frames;
+ /* While DMA is running: Determine if remote end indicates any alarms */
+ if (alarm_cnt) {
+ for (int i = 0; i < n_frames; i++) {
+ unsigned int frame_nr = ofs + i;
+ /* A bit is present in every odd frame TS0 */
+ if (frame_nr & 1) {
+ uint8_t ts0 = *e1_data_ptr(0, ofs + i, 0);
+ if (ts0 & 0x20)
+ *alarm_cnt++;
+ }
+ }
+ }
+
/* Wait for DMA completion */
while (dma_poll());
}
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index e180fec..b96e761 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -42,7 +42,8 @@
/* Hack */
-unsigned int e1_rx_need_data(unsigned int usb_addr, unsigned int max_len, unsigned int *pos);
+unsigned int e1_rx_need_data(unsigned int usb_addr, unsigned int max_len, unsigned int *pos,
+ unsigned int *alarm_cnt);
unsigned int e1_tx_feed_data(unsigned int usb_addr, unsigned int len);
unsigned int e1_tx_level(void);
unsigned int e1_rx_level(void);
@@ -115,7 +116,7 @@
{
uint32_t ptr = usb_ep_regs[2].in.bd[bdi].ptr;
uint32_t hdr;
- unsigned int pos;
+ unsigned int pos, alarm_cnt;
/* Error check */
if ((usb_ep_regs[2].in.bd[bdi].csr & USB_BD_STATE_MSK) == USB_BD_STATE_DONE_ERR)
@@ -133,10 +134,13 @@
else if (!n)
break;
- n = e1_rx_need_data((ptr >> 2) + 1, n, &pos);
+ n = e1_rx_need_data((ptr >> 2) + 1, n, &pos, &alarm_cnt);
/* Write header: currently version and pos (mfr/fr number) */
hdr = (0 << 28) | (pos & 0xff);
+ /* indicate at least one remote alarm was reported within the frames of this transfer */
+ if (alarm_cnt)
+ hdr |= (1 << 8);
usb_data_write(ptr, &hdr, 4);
/* Resubmit */
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26706
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-e1-hardware
Gerrit-Branch: master
Gerrit-Change-Id: Ic4f57cf79bd32cf75f81ef3073cb8d4a2d1857d8
Gerrit-Change-Number: 26706
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20220101/46cfcbf2/attachment.htm>