Message ID | 20220905004944.967757-1-aahringo@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [RFC,ben-wpan] fw: add trac reg to tx done | expand |
Hi, On Sun, Sep 4, 2022 at 8:49 PM Alexander Aring <aahringo@redhat.com> wrote: > > This patch adds an additional byte for tx done for the trac status > register which can then evaluated by the atusb Linux driver. > --- > > Just an RFC, need another weekend to test it. > > atusb/fw/mac.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/atusb/fw/mac.c b/atusb/fw/mac.c > index 835002c..045d5fa 100644 > --- a/atusb/fw/mac.c > +++ b/atusb/fw/mac.c > @@ -32,7 +32,7 @@ static uint8_t tx_buf[MAX_PSDU]; > static uint8_t tx_size = 0; > static bool txing = 0; > static bool queued_tx_ack = 0; > -static uint8_t next_seq, this_seq, queued_seq; > +static uint8_t next_seq, this_seq, queued_seq, queued_tx_trac; > > > /* ----- Receive buffer management ----------------------------------------- */ > @@ -57,6 +57,7 @@ static void tx_ack_done(void *user); > static void usb_next(void) > { > const uint8_t *buf; > + uint8_t data[2]; > > if (rx_in != rx_out) { > buf = rx_buf[rx_out]; > @@ -65,7 +66,9 @@ static void usb_next(void) > } > > if (queued_tx_ack) { > - usb_send(&eps[1], &queued_seq, 1, tx_ack_done, NULL); > + data[0] = queued_seq; > + data[1] = queued_tx_trac; > + usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL); > queued_tx_ack = 0; > } > } > @@ -116,7 +119,7 @@ static void receive_frame(void) > > static bool handle_irq(void) > { > - uint8_t irq; > + uint8_t irq, data[2]; > > irq = reg_read(REG_IRQ_STATUS); > if (!(irq & IRQ_TRX_END)) > @@ -124,10 +127,13 @@ static bool handle_irq(void) > > if (txing) { > if (eps[1].state == EP_IDLE) { > - usb_send(&eps[1], &this_seq, 1, tx_ack_done, NULL); > + data[0] = this_seq; > + data[1] = reg_read(REG_TRX_STATE); > + usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL); > } else { > queued_tx_ack = 1; > queued_seq = this_seq; > + queued_tx_trac = reg_read(REG_TRX_STATE); > } > txing = 0; There is probably some race the trac register also have values stored for RX_AACK_ON state which is being changed after the transmit but we need at first to get the trac and then turn into RX_AACK_ON, so I think the state change "change_state(TRX_CMD_RX_AACK_ON);" should be moved after reading the trac. - Alex
diff --git a/atusb/fw/mac.c b/atusb/fw/mac.c index 835002c..045d5fa 100644 --- a/atusb/fw/mac.c +++ b/atusb/fw/mac.c @@ -32,7 +32,7 @@ static uint8_t tx_buf[MAX_PSDU]; static uint8_t tx_size = 0; static bool txing = 0; static bool queued_tx_ack = 0; -static uint8_t next_seq, this_seq, queued_seq; +static uint8_t next_seq, this_seq, queued_seq, queued_tx_trac; /* ----- Receive buffer management ----------------------------------------- */ @@ -57,6 +57,7 @@ static void tx_ack_done(void *user); static void usb_next(void) { const uint8_t *buf; + uint8_t data[2]; if (rx_in != rx_out) { buf = rx_buf[rx_out]; @@ -65,7 +66,9 @@ static void usb_next(void) } if (queued_tx_ack) { - usb_send(&eps[1], &queued_seq, 1, tx_ack_done, NULL); + data[0] = queued_seq; + data[1] = queued_tx_trac; + usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL); queued_tx_ack = 0; } } @@ -116,7 +119,7 @@ static void receive_frame(void) static bool handle_irq(void) { - uint8_t irq; + uint8_t irq, data[2]; irq = reg_read(REG_IRQ_STATUS); if (!(irq & IRQ_TRX_END)) @@ -124,10 +127,13 @@ static bool handle_irq(void) if (txing) { if (eps[1].state == EP_IDLE) { - usb_send(&eps[1], &this_seq, 1, tx_ack_done, NULL); + data[0] = this_seq; + data[1] = reg_read(REG_TRX_STATE); + usb_send(&eps[1], data, sizeof(data), tx_ack_done, NULL); } else { queued_tx_ack = 1; queued_seq = this_seq; + queued_tx_trac = reg_read(REG_TRX_STATE); } txing = 0; return 1;