1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg/lwip_netdev: add support for IPC based Bottom Half Processor

This commit is contained in:
Jose Alamos 2022-08-17 14:39:45 +02:00
parent 4b75725dd3
commit 4daaaccb0f
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
3 changed files with 35 additions and 1 deletions

View File

@ -89,6 +89,9 @@ endif
ifneq (,$(filter lwip_contrib,$(USEMODULE)))
USEMODULE += sema
USEMODULE += ztimer_msec
ifneq (,$(filter bhp,$(USEMODULE)))
USEMODULE += bhp_msg
endif
endif
ifneq (,$(filter lwip_netif,$(USEMODULE)))

View File

@ -87,7 +87,11 @@ err_t lwip_netdev_init(struct netif *netif)
}
}
/* initialize netdev and netif */
/* initialize Bottom Half Processor, netdev and netif */
if (IS_USED(MODULE_BHP_MSG)) {
bhp_msg_claim_thread(lwip_netif_get_bhp(netif), _pid);
}
netdev = netif->state;
lwip_netif_dev_acquire(netif);
netdev->driver->init(netdev);
@ -333,6 +337,9 @@ static void *_event_loop(void *arg)
dev->driver->isr(dev);
lwip_netif_dev_release(netif);
}
else if (IS_USED(MODULE_BHP_MSG) && msg.type == BHP_MSG_BH_REQUEST) {
bhp_msg_handler(&msg);
}
}
return NULL;
}

View File

@ -22,6 +22,7 @@
#include "lwip/netif.h"
#include "net/netif.h"
#include "bhp/msg.h"
#ifdef __cplusplus
extern "C" {
@ -34,6 +35,9 @@ typedef struct {
netif_t common_netif; /**< network interface descriptor */
struct netif lwip_netif; /**< lwIP interface data */
rmutex_t lock; /**< lock for the interface */
#if IS_USED(MODULE_BHP_MSG)
bhp_msg_t bhp; /**< IPC Bottom Half Processor */
#endif
} lwip_netif_t;
/**
@ -69,6 +73,26 @@ static inline void lwip_netif_dev_release(struct netif *netif)
rmutex_unlock(&compat_netif->lock);
}
/**
* @brief Get the IPC based Bottom Half Processor for LWIP
*
* @param[in] netif pointer to the LWIP network interface
*
* @return pointer to the IPC based Bottom Half Processor descriptor, if
* @ref sys_bhp_msg is present.
* @return NULL otherwise
*/
static inline bhp_msg_t *lwip_netif_get_bhp(struct netif *netif)
{
#if IS_USED(MODULE_BHP_MSG)
lwip_netif_t *compat_netif = container_of(netif, lwip_netif_t, lwip_netif);
return &compat_netif->bhp;
#else
(void) netif;
return NULL;
#endif
}
#ifdef __cplusplus
}
#endif