tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26852 )
Change subject: icE1usb fw: Update LED status even in E1 FSM is in IDLE state
......................................................................
icE1usb fw: Update LED status even in E1 FSM is in IDLE state
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
Change-Id: I82b867c4886c9f34ff685764424d3db9a8303789
---
M firmware/ice40-riscv/icE1usb/e1.c
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/52/26852/1
diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c
index 1b6d978..09bc6d2 100644
--- a/firmware/ice40-riscv/icE1usb/e1.c
+++ b/firmware/ice40-riscv/icE1usb/e1.c
@@ -444,10 +444,6 @@
uint32_t bd;
unsigned int ofs;
- /* Active ? */
- if ((e1->rx.state == IDLE) && (e1->tx.state == IDLE))
- return;
-
/* HACK: LED link status */
if (e1_regs->rx.csr & E1_RX_SR_ALIGNED) {
e1_platform_led_set(port, E1P_LED_GREEN, E1P_LED_ST_ON);
@@ -461,6 +457,10 @@
/* TODO: completely off if rx tick counter not incrementing */
}
+ /* Active ? */
+ if ((e1->rx.state == IDLE) && (e1->tx.state == IDLE))
+ return;
+
/* Recover any done TX BD */
while ( (bd = e1_regs->tx.bd) & E1_BD_VALID ) {
e1f_multiframe_read_discard(&e1->tx.fifo);
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26852
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: I82b867c4886c9f34ff685764424d3db9a8303789
Gerrit-Change-Number: 26852
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt(a)246tNt.com>
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newchange
tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26842 )
Change subject: icE1usb fw: Don't prefill feedback
......................................................................
icE1usb fw: Don't prefill feedback
This prevents inlining of the code, and is completely
unecessary.
(1) It will be filled a bit later
(2) We don't have any meaningful feedback to provide anyway
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
Change-Id: I6e97bc79d1fe50950bb1f7cd71d8c428e928d4ae
---
M firmware/ice40-riscv/icE1usb/usb_e1.c
1 file changed, 0 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/42/26842/1
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index a18ebe4..032eec8 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -323,9 +323,6 @@
ep_regs->bd[0].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(292);
ep_regs->bd[1].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(292);
- /* EP Feedback: Pre-fill */
- _usb_fill_feedback_ep(port);
-
break;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26842
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: I6e97bc79d1fe50950bb1f7cd71d8c428e928d4ae
Gerrit-Change-Number: 26842
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt(a)246tNt.com>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26843 )
Change subject: icE1usb fw: Better flow regulation mechanism
......................................................................
icE1usb fw: Better flow regulation mechanism
* FIFO target level :
- The '8 * 16' makes no sense as the FIFO was 128 so this
is the "full" case and could never be that high.
- We tighten up the margin around 5 * 16 which is the "target"
level for the FIFO
* FIFO size :
We also increase the FIFO size to 256 frames. This doesn't
actually affect latency since the target level is the same,
but it allows more leeway to recover without data loss in
case something goes wrong.
* Ticks :
We don't bother using ticks ... the current algo wasn't
working (or rather not doing anything all that useful),
because the difference between USB clock and E1 clock is
tiny and measured over 1 ms, it's not meaningful.
So for the time being we just sent the nominal rate biased
with the FIFO level to keep it on target and this seems
to work fine.
It'd be nice to have a good long term estimate of the rate
to minimize the jitter, but it doesn't seem to be strictly
required for operation for now.
* Misc cleanup :
Just do all in one function instead of splitting the check
if BD needs refill and the actual refill.
This gets rid of sporadic 'TX FIFO Overflow' conditions
by properly handling the case where we have a bit too much
data.
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
Change-Id: Ibd3bc9080961cc56093e43ab9a824840e84c24d2
---
M firmware/ice40-riscv/icE1usb/e1.c
M firmware/ice40-riscv/icE1usb/usb_e1.c
2 files changed, 19 insertions(+), 29 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/43/26843/1
diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c
index 6a87c12..f25e7c1 100644
--- a/firmware/ice40-riscv/icE1usb/e1.c
+++ b/firmware/ice40-riscv/icE1usb/e1.c
@@ -273,8 +273,8 @@
memset(e1, 0x00, sizeof(struct e1_state));
/* Reset FIFOs */
- e1f_reset(&e1->rx.fifo, (256 * port) + 0, 128);
- e1f_reset(&e1->tx.fifo, (256 * port) + 128, 128);
+ e1f_reset(&e1->rx.fifo, (512 * port) + 0, 256);
+ e1f_reset(&e1->tx.fifo, (512 * port) + 256, 256);
/* Enable Rx */
e1->rx.cr = E1_RX_CR_ENABLE | rx_cr;
diff --git a/firmware/ice40-riscv/icE1usb/usb_e1.c b/firmware/ice40-riscv/icE1usb/usb_e1.c
index 032eec8..08b192b 100644
--- a/firmware/ice40-riscv/icE1usb/usb_e1.c
+++ b/firmware/ice40-riscv/icE1usb/usb_e1.c
@@ -74,30 +74,25 @@
static void
_usb_fill_feedback_ep(int port)
{
- static uint16_t ticks_prev = 0;
- uint16_t ticks;
- uint32_t val = 8192;
- unsigned int level;
- volatile struct usb_ep *ep_regs;
+ volatile struct usb_ep *ep_regs = _get_ep_regs(USB_EP_E1_FB(port));
- /* Compute real E1 tick count (with safety against bad values) */
- ticks = e1_tick_read(port);
- val = (ticks - ticks_prev) & 0xffff;
- ticks_prev = ticks;
- if ((val < 7168) | (val > 9216))
- val = 8192;
+ /* Always ensure we're ready to send */
+ if ((ep_regs->bd[0].csr & USB_BD_STATE_MSK) != USB_BD_STATE_RDY_DATA)
+ {
+ uint32_t val = 8192;
- /* Bias depending on TX fifo level */
- level = e1_tx_level(port);
- if (level < (3 * 16))
- val += 256;
- else if (level > (8 * 16))
- val -= 256;
+ /* Add instant bias depending on TX fifo level */
+ unsigned int level = e1_tx_level(port);
- /* Prepare buffer */
- ep_regs = _get_ep_regs(USB_EP_E1_FB(port));
- usb_data_write(ep_regs->bd[0].ptr, &val, 4);
- ep_regs->bd[0].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(3);
+ if (level < (4 * 16))
+ val += 256;
+ else if (level > (6 * 16))
+ val -= 256;
+
+ /* Fill buffer and submit it */
+ usb_data_write(ep_regs->bd[0].ptr, &val, 4);
+ ep_regs->bd[0].csr = USB_BD_STATE_RDY_DATA | USB_BD_LEN(3);
+ }
}
@@ -212,12 +207,7 @@
}
/* Feedback endpoint */
- ep_regs = _get_ep_regs(USB_EP_E1_FB(port));
-
- if ((ep_regs->bd[0].csr & USB_BD_STATE_MSK) != USB_BD_STATE_RDY_DATA)
- {
- _usb_fill_feedback_ep(port);
- }
+ _usb_fill_feedback_ep(port);
}
static enum usb_fnd_resp
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26843
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: Ibd3bc9080961cc56093e43ab9a824840e84c24d2
Gerrit-Change-Number: 26843
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt(a)246tNt.com>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26844 )
Change subject: icE1usb fw: Disable the yellow led if LOS
......................................................................
icE1usb fw: Disable the yellow led if LOS
There is no remote side alarm if there is no remote-side ...
Signed-off-by: Sylvain Munaut <tnt(a)246tNt.com>
Change-Id: I78f43eded5ed6ffde9d86726ccee2b776a3f4675
---
M firmware/ice40-riscv/icE1usb/e1.c
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1-hardware refs/changes/44/26844/1
diff --git a/firmware/ice40-riscv/icE1usb/e1.c b/firmware/ice40-riscv/icE1usb/e1.c
index f25e7c1..af59f14 100644
--- a/firmware/ice40-riscv/icE1usb/e1.c
+++ b/firmware/ice40-riscv/icE1usb/e1.c
@@ -448,6 +448,7 @@
e1->errors.flags &= ~(E1_ERR_F_LOS|E1_ERR_F_ALIGN_ERR);
} else {
e1_platform_led_set(port, E1P_LED_GREEN, E1P_LED_ST_BLINK);
+ e1_platform_led_set(port, E1P_LED_YELLOW, E1P_LED_ST_OFF);
led_color(48, 0, 0);
e1->errors.flags |= E1_ERR_F_ALIGN_ERR;
/* TODO: completely off if rx tick counter not incrementing */
--
To view, visit https://gerrit.osmocom.org/c/osmo-e1-hardware/+/26844
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: I78f43eded5ed6ffde9d86726ccee2b776a3f4675
Gerrit-Change-Number: 26844
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <tnt(a)246tNt.com>
Gerrit-MessageType: newchange