1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

Merge pull request #18201 from benpicco/slip_dose_rxqueue

drivers/{dose, slipdev, sam0_eth}: generate RX event for queued packets
This commit is contained in:
benpicco 2022-08-26 13:25:13 +02:00 committed by GitHub
commit 28cedd52a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 2 deletions

View File

@ -323,6 +323,11 @@ int sam0_eth_receive_blocking(char *data, unsigned max_len)
return _try_receive(data, max_len, 1);
}
bool sam0_eth_has_queued_pkt(void)
{
return _try_receive(NULL, 0, 0) > 0;
}
int sam0_eth_init(void)
{
/* Enable clocks */

View File

@ -40,6 +40,7 @@ extern void sam0_eth_poweron(void);
extern void sam0_eth_poweroff(void);
extern int sam0_eth_send(const struct iolist *iolist);
extern int sam0_eth_receive_blocking(char *data, unsigned max_len);
extern bool sam0_eth_has_queued_pkt(void);
extern void sam0_eth_set_mac(const eui48_t *mac);
extern void sam0_eth_get_mac(char *out);
extern void sam0_clear_rx_buffers(void);
@ -68,6 +69,12 @@ static int _sam0_eth_recv(netdev_t *netdev, void *buf, size_t len, void *info)
(void)info;
(void)netdev;
unsigned ret = sam0_eth_receive_blocking((char *)buf, len);
/* frame received, check if another frame is queued */
if (buf && sam0_eth_has_queued_pkt()) {
netdev_trigger_event_isr(netdev);
}
return ret;
}

View File

@ -431,6 +431,7 @@ static void _isr(netdev_t *netdev)
static int _recv(netdev_t *dev, void *buf, size_t len, void *info)
{
int res;
dose_t *ctx = container_of(dev, dose_t, netdev);
(void)info;
@ -446,10 +447,18 @@ static int _recv(netdev_t *dev, void *buf, size_t len, void *info)
}
if (crb_consume_chunk(&ctx->rb, buf, len)) {
return len;
res = len;
} else {
return -1;
res = -1;
}
size_t dummy;
if (crb_get_chunk_size(&ctx->rb, &dummy)) {
DEBUG("dose: %u byte pkt in rx queue\n", (unsigned)dummy);
netdev_trigger_event_isr(&ctx->netdev);
}
return res;
}
static uint8_t wait_for_state(dose_t *ctx, uint8_t state)

View File

@ -98,6 +98,8 @@ typedef struct {
* @see [Device state definitions](@ref drivers_slipdev_states)
*/
uint8_t state;
uint8_t rx_queued; /**< pkt queued in inbuf */
uint8_t rx_done; /**< pkt processed */
} slipdev_t;
/**

View File

@ -67,6 +67,7 @@ static void _slip_rx_cb(void *arg, uint8_t byte)
check_end:
if (byte == SLIPDEV_END) {
if (dev->state == SLIPDEV_STATE_NET) {
dev->rx_queued++;
netdev_trigger_event_isr(&dev->netdev);
}
dev->state = SLIPDEV_STATE_NONE;
@ -207,6 +208,11 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
return -ENOBUFS;
}
} while (byte != SLIPDEV_END);
if (++dev->rx_done != dev->rx_queued) {
DEBUG("slipdev: pkt still in queue");
netdev_trigger_event_isr(&dev->netdev);
}
}
return res;
}