mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
net/gnrc_netif: add support for priority queues
This commit is contained in:
parent
0b5f270b15
commit
2c9f3072fb
@ -76,6 +76,25 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Index of the high priority queue
|
||||
*/
|
||||
#define GNRC_NETIF_EVQ_INDEX_PRIO_HIGH (0)
|
||||
|
||||
/**
|
||||
* @brief Index of the low priority queue
|
||||
*/
|
||||
#if IS_USED(MODULE_BHP_EVENT)
|
||||
#define GNRC_NETIF_EVQ_INDEX_PRIO_LOW (GNRC_NETIF_EVQ_INDEX_PRIO_HIGH + 1)
|
||||
#else
|
||||
#define GNRC_NETIF_EVQ_INDEX_PRIO_LOW GNRC_NETIF_EVQ_INDEX_PRIO_HIGH
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of event queues
|
||||
*/
|
||||
#define GNRC_NETIF_EVQ_NUMOF (GNRC_NETIF_EVQ_INDEX_PRIO_LOW + 1)
|
||||
|
||||
/**
|
||||
* @brief Per-Interface Event Message Buses
|
||||
*/
|
||||
@ -142,7 +161,7 @@ typedef struct {
|
||||
/**
|
||||
* @brief Event queue for asynchronous events
|
||||
*/
|
||||
event_queue_t evq;
|
||||
event_queue_t evq[GNRC_NETIF_EVQ_NUMOF];
|
||||
/**
|
||||
* @brief ISR event for the network device
|
||||
*/
|
||||
|
@ -2030,7 +2030,7 @@ static void _gomach_event_cb(netdev_t *dev, netdev_event_t event)
|
||||
gnrc_netif_t *netif = (gnrc_netif_t *) dev->context;
|
||||
|
||||
if (event == NETDEV_EVENT_ISR) {
|
||||
event_post(&netif->evq, &netif->event_isr);
|
||||
event_post(&netif->evq[GNRC_NETIF_EVQ_INDEX_PRIO_LOW], &netif->event_isr);
|
||||
}
|
||||
else {
|
||||
DEBUG("gnrc_netdev: event triggered -> %i\n", event);
|
||||
|
@ -795,7 +795,7 @@ static void _lwmac_event_cb(netdev_t *dev, netdev_event_t event)
|
||||
gnrc_netif_t *netif = (gnrc_netif_t *) dev->context;
|
||||
|
||||
if (event == NETDEV_EVENT_ISR) {
|
||||
event_post(&netif->evq, &netif->event_isr);
|
||||
event_post(&netif->evq[GNRC_NETIF_EVQ_INDEX_PRIO_LOW], &netif->event_isr);
|
||||
}
|
||||
else {
|
||||
DEBUG("gnrc_netdev: event triggered -> %i\n", event);
|
||||
|
@ -1675,6 +1675,18 @@ static void _process_receive_stats(gnrc_netif_t *netdev, gnrc_pktsnip_t *pkt)
|
||||
netstats_nb_update_rx(&netdev->netif, src, src_len, hdr->rssi, hdr->lqi);
|
||||
}
|
||||
|
||||
static event_t *_gnrc_netif_fetch_event(gnrc_netif_t *netif)
|
||||
{
|
||||
event_t *ev;
|
||||
/* Iterate from highest priority to lowest priority */
|
||||
for (int i = 0; i < GNRC_NETIF_EVQ_NUMOF; i++) {
|
||||
if ((ev = event_get(&netif->evq[i]))) {
|
||||
return ev;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Process any pending events and wait for IPC messages
|
||||
*
|
||||
@ -1697,8 +1709,7 @@ static void _process_events_await_msg(gnrc_netif_t *netif, msg_t *msg)
|
||||
event_t *evp;
|
||||
/* We can not use event_loop() or event_wait() because then we would not
|
||||
* wake up when a message arrives */
|
||||
event_queue_t *evq = &netif->evq;
|
||||
while ((evp = event_get(evq))) {
|
||||
while ((evp = _gnrc_netif_fetch_event(netif))) {
|
||||
DEBUG("gnrc_netif: event %p\n", (void *)evp);
|
||||
if (evp->handler) {
|
||||
evp->handler(evp);
|
||||
@ -1844,7 +1855,7 @@ static void *_gnrc_netif_thread(void *args)
|
||||
|
||||
netif->event_isr.handler = _event_handler_isr,
|
||||
/* set up the event queue */
|
||||
event_queue_init(&netif->evq);
|
||||
event_queues_init(netif->evq, GNRC_NETIF_EVQ_NUMOF);
|
||||
|
||||
/* setup the link-layer's message queue */
|
||||
msg_init_queue(msg_queue, GNRC_NETIF_MSG_QUEUE_SIZE);
|
||||
@ -1957,7 +1968,7 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
gnrc_netif_t *netif = (gnrc_netif_t *) dev->context;
|
||||
|
||||
if (event == NETDEV_EVENT_ISR) {
|
||||
event_post(&netif->evq, &netif->event_isr);
|
||||
event_post(&netif->evq[GNRC_NETIF_EVQ_INDEX_PRIO_LOW], &netif->event_isr);
|
||||
}
|
||||
else {
|
||||
DEBUG("gnrc_netif: event triggered -> %i\n", event);
|
||||
|
@ -200,7 +200,7 @@ static void _driver_cb(netdev_t *dev, netdev_event_t event)
|
||||
gnrc_lorawan_t *mac = &netif->lorawan.mac;
|
||||
|
||||
if (event == NETDEV_EVENT_ISR) {
|
||||
event_post(&netif->evq, &netif->event_isr);
|
||||
event_post(&netif->evq[GNRC_NETIF_EVQ_INDEX_PRIO_LOW], &netif->event_isr);
|
||||
}
|
||||
else {
|
||||
DEBUG("gnrc_netif: event triggered -> %i\n", event);
|
||||
|
Loading…
Reference in New Issue
Block a user