mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-28 23:49:47 +01:00
sys/net/gnrc/netif: allow checking if a netdev is legacy or new API
A if `netdev_driver_t::confirm_send()` is provided, it provides the new netdev API. However, detecting the API at runtime and handling both API styles comes at a cost. This can be optimized in case only new or only old style netdevs are in use. To do so, this adds the pseudo modules `netdev_legacy_api` and `netdev_new_api`. As right now no netdev actually implements the new API, all netdevs pull in `netdev_legacy_api`. If `netdev_legacy_api` is in used but `netdev_new_api` is not, we can safely assume at compile time that only legacy netdevs are in use. Similar, if only `netdev_new_api` is used, only support for the new API is needed. Only when both are in use, run time checks are needed. This provides two helper function to check for a netif if the corresponding netdev implements the old or the new API. (With one being the inverse of the other.) They are suitable for constant folding when only new or only legacy devices are in use. Consequently, dead branches should be eliminated by the optimizer.
This commit is contained in:
parent
f2720940d7
commit
276ad5716a
@ -97,6 +97,7 @@ ifneq (,$(filter esp_wifi,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += netopt
|
||||
USEMODULE += ztimer_msec
|
||||
endif
|
||||
|
@ -14,9 +14,10 @@ endif
|
||||
USEMODULE += sam0_common_periph
|
||||
|
||||
ifneq (,$(filter sam0_eth,$(USEMODULE)))
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netopt
|
||||
USEMODULE += iolist
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += netopt
|
||||
FEATURES_REQUIRED += periph_eth
|
||||
endif
|
||||
include $(RIOTCPU)/cortexm_common/Makefile.dep
|
||||
|
@ -22,8 +22,9 @@ endif
|
||||
|
||||
ifneq (,$(filter stm32_eth,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_eth
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += iolist
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
|
@ -237,7 +237,7 @@ ifneq (,$(filter periph_timer_periodic,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_timer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter-out netdev_default, $(filter netdev_%,$(USEMODULE))))
|
||||
ifneq (,$(filter-out netdev_default netdev_new_api netdev_legacy_api, $(filter netdev_%,$(USEMODULE))))
|
||||
USEMODULE += netdev
|
||||
# Don't register netdevs if there is only a single one of them
|
||||
ifeq (,$(filter gnrc_netif_single,$(USEMODULE)))
|
||||
|
@ -16,6 +16,7 @@ menuconfig MODULE_AT86RF215
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
|
@ -33,3 +33,4 @@ endif
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += netdev_ieee802154
|
||||
USEMODULE += netdev_legacy_api
|
||||
|
@ -10,10 +10,11 @@ menuconfig MODULE_AT86RF2XX
|
||||
prompt "AT86RF2xx series radios" if !(MODULE_NETDEV_DEFAULT && HAVE_AT86RF2XX)
|
||||
default (MODULE_NETDEV_DEFAULT && HAVE_AT86RF2XX)
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_XTIMER
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_XTIMER
|
||||
|
||||
if MODULE_AT86RF2XX
|
||||
|
||||
|
@ -4,6 +4,7 @@ DEFAULT_MODULE += netdev_ieee802154_oqpsk
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += netdev_ieee802154
|
||||
USEMODULE += netdev_legacy_api
|
||||
|
||||
# only needed for SPI based variants
|
||||
ifeq (,$(filter at86rfa1 at86rfr2,$(USEMODULE)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += ztimer_msec
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEPKG += driver_atwinc15x0
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
|
@ -1,6 +1,7 @@
|
||||
USEMODULE += cc1xxx_common
|
||||
USEMODULE += luid
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += netdev_legacy_api
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
|
@ -11,13 +11,14 @@ config MODULE_CC2420
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_XTIMER
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
|
||||
config HAVE_CC2420
|
||||
bool
|
||||
|
@ -1,6 +1,7 @@
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += netdev_ieee802154
|
||||
USEMODULE += netdev_legacy_api
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
|
@ -28,15 +28,16 @@ menuconfig MODULE_DOSE
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_UART
|
||||
select MODULE_CHUNKED_RINGBUFFER
|
||||
select MODULE_EUI_PROVIDER
|
||||
select MODULE_IOLIST
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_UART
|
||||
select MODULE_PERIPH_UART_COLLISION if HAS_PERIPH_UART_COLLISION
|
||||
select MODULE_PERIPH_UART_RXSTART_IRQ if HAS_PERIPH_UART_RXSTART_IRQ
|
||||
select MODULE_CHUNKED_RINGBUFFER
|
||||
select MODULE_EUI_PROVIDER
|
||||
select MODULE_IOLIST
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_RANDOM
|
||||
select MODULE_ZTIMER
|
||||
select ZTIMER_USEC
|
||||
|
@ -11,5 +11,6 @@ USEMODULE += chunked_ringbuffer
|
||||
USEMODULE += eui_provider
|
||||
USEMODULE += iolist
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += random
|
||||
USEMODULE += ztimer_usec
|
||||
|
@ -11,11 +11,12 @@ config MODULE_ENC28J60
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_EUI_PROVIDER
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_PERIPH_EUI_PROVIDER
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_XTIMER
|
||||
|
||||
config HAVE_ENC28J60
|
||||
|
@ -4,4 +4,5 @@ FEATURES_REQUIRED += periph_spi
|
||||
|
||||
USEMODULE += eui_provider
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += xtimer
|
||||
|
@ -11,10 +11,11 @@ config MODULE_ENCX24J600
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_XTIMER
|
||||
|
||||
config HAVE_ENCX24J600
|
||||
|
@ -1,4 +1,5 @@
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += xtimer
|
||||
|
@ -9,9 +9,10 @@ config MODULE_ETHOS
|
||||
bool "Ethernet-over-serial (ETHOS)"
|
||||
depends on TEST_KCONFIG
|
||||
depends on HAS_PERIPH_UART
|
||||
select MODULE_PERIPH_UART
|
||||
select MODULE_IOLIST
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_UART
|
||||
select MODULE_RANDOM
|
||||
select MODULE_TSRB
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
USEMODULE += iolist
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += random
|
||||
USEMODULE += tsrb
|
||||
|
||||
|
@ -13,16 +13,15 @@ menuconfig MODULE_KW2XRF
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_CORE_THREAD_FLAGS
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_LUID
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_LUID
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_CORE_THREAD_FLAGS
|
||||
select MODULE_IOLIST
|
||||
select HAVE_BHP_IRQ_HANDLER
|
||||
|
||||
config MODULE_KW2XRF_TESTMODE
|
||||
bool "Test mode"
|
||||
|
@ -13,13 +13,14 @@ menuconfig MODULE_MRF24J40
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_XTIMER
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_NETDEV
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
|
||||
if MODULE_MRF24J40
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += netdev_ieee802154
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += xtimer
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
|
@ -82,6 +82,23 @@ config MODULE_NETDEV_REGISTER
|
||||
|
||||
endif # MODULE_NETDEV
|
||||
|
||||
# This does not depend on MODULE_NETDEV, as it is merely a flag to say if a
|
||||
# given network driver is used via the netdev API, it provides the new netdev
|
||||
# API. However, the driver may also provide a API other than netdev that might
|
||||
# be used directly.
|
||||
config MODULE_NETDEV_NEW_API
|
||||
bool
|
||||
help
|
||||
Support for new API (non-blocking send). With this, netdev
|
||||
drivers implementing `netdev_driver_t::confirm_send()` can be used.
|
||||
|
||||
# Comment above MODULE_NETDEV_NEW_API also applies here.
|
||||
config MODULE_NETDEV_LEGACY_API
|
||||
bool
|
||||
help
|
||||
Support for legacy netdev API (blocking send). With this, netdev drivers
|
||||
**NOT** implementing `netdev_driver_t::confirm_send()` can be used.
|
||||
|
||||
endif # TEST_KCONFIG
|
||||
|
||||
config HAVE_NON_NETDEV_INTERFACE
|
||||
|
@ -10,9 +10,10 @@ config MODULE_NETDEV_IEEE802154_SUBMAC
|
||||
depends on TEST_KCONFIG
|
||||
depends on MODULE_NETDEV
|
||||
default y if HAVE_IEEE802154_RADIO_HAL_INTERFACE
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_IEEE802154
|
||||
select MODULE_IEEE802154_SUBMAC
|
||||
select MODULE_NETDEV_IEEE802154
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
help
|
||||
This module implements the netdev API on top of the IEEE 802.15.4 radio
|
||||
HAL.
|
||||
|
@ -1,4 +1,5 @@
|
||||
USEMODULE += luid
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += netif
|
||||
USEMODULE += xtimer
|
||||
ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
|
||||
|
@ -27,9 +27,10 @@ config MODULE_RN2XX3
|
||||
bool
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_UART
|
||||
select MODULE_FMT
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_UART
|
||||
select MODULE_FMT
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
USEMODULE += fmt
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
USEMODULE += fmt
|
||||
|
@ -10,8 +10,9 @@ menuconfig MODULE_SLIPDEV
|
||||
bool "SLIP over UART network device"
|
||||
depends on HAS_PERIPH_UART
|
||||
depends on TEST_KCONFIG
|
||||
select MODULE_TSRB
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_UART
|
||||
select MODULE_TSRB
|
||||
|
||||
menuconfig KCONFIG_USEMODULE_SLIPDEV
|
||||
bool "Configure SLIPDEV driver"
|
||||
|
@ -1,6 +1,7 @@
|
||||
USEMODULE += tsrb
|
||||
USEMODULE += eui_provider
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += netdev_register
|
||||
USEMODULE += tsrb
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
|
||||
ifneq (,$(filter slipdev_stdio,$(USEMODULE)))
|
||||
|
@ -13,10 +13,11 @@ menuconfig MODULE_SX126X
|
||||
depends on HAS_PERIPH_SPI
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
select MODULE_IOLIST
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_SPI
|
||||
select PACKAGE_DRIVER_SX126X
|
||||
select MODULE_IOLIST
|
||||
|
||||
choice
|
||||
bool "Radio variant"
|
||||
|
@ -1,3 +1,4 @@
|
||||
USEMODULE += iolist
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEPKG += driver_sx126x
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
|
@ -14,14 +14,15 @@ menuconfig MODULE_SX127X
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
depends on HAS_PERIPH_TIMER
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI_GPIO_MODE if HAS_PERIPH_SPI_GPIO_MODE
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
select MODULE_IOLIST
|
||||
select MODULE_LORA
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_PERIPH_SPI_GPIO_MODE if HAS_PERIPH_SPI_GPIO_MODE
|
||||
select MODULE_ZTIMER
|
||||
select MODULE_ZTIMER_MSEC
|
||||
help
|
||||
Only LoRa long range modem is supported at the moment.
|
||||
|
||||
|
@ -3,6 +3,7 @@ FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
FEATURES_OPTIONAL += periph_spi_gpio_mode
|
||||
USEMODULE += iolist
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
USEMODULE += lora
|
||||
|
@ -1,2 +1,3 @@
|
||||
USEPKG += lorabasics
|
||||
USEMODULE += lorabasics_sx1280_driver
|
||||
USEMODULE += netdev_legacy_api
|
||||
|
@ -11,11 +11,12 @@ config MODULE_W5100
|
||||
depends on HAS_PERIPH_GPIO
|
||||
depends on HAS_PERIPH_GPIO_IRQ
|
||||
depends on HAS_PERIPH_SPI
|
||||
select MODULE_LUID
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_NETDEV_LEGACY_API
|
||||
select MODULE_PERIPH_GPIO
|
||||
select MODULE_PERIPH_GPIO_IRQ
|
||||
select MODULE_PERIPH_SPI
|
||||
select MODULE_NETDEV_ETH
|
||||
select MODULE_LUID
|
||||
|
||||
config HAVE_W5100
|
||||
bool
|
||||
|
@ -1,4 +1,5 @@
|
||||
FEATURES_REQUIRED += periph_gpio_irq
|
||||
FEATURES_REQUIRED += periph_spi
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += luid
|
||||
USEMODULE += netdev_eth
|
||||
USEMODULE += netdev_legacy_api
|
||||
|
@ -1,5 +1,6 @@
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
FEATURES_REQUIRED += periph_gpio
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += ztimer
|
||||
USEMODULE += ztimer_msec
|
||||
|
@ -156,6 +156,8 @@ PSEUDOMODULES += netdev_ieee802154_rx_timestamp
|
||||
PSEUDOMODULES += netdev_ieee802154
|
||||
PSEUDOMODULES += netdev_eth
|
||||
PSEUDOMODULES += netdev_layer
|
||||
PSEUDOMODULES += netdev_legacy_api
|
||||
PSEUDOMODULES += netdev_new_api
|
||||
PSEUDOMODULES += netdev_register
|
||||
PSEUDOMODULES += netstats
|
||||
PSEUDOMODULES += netstats_l2
|
||||
|
@ -173,6 +173,7 @@ endif
|
||||
|
||||
ifneq (,$(filter netdev_ieee802154_submac,$(USEMODULE)))
|
||||
USEMODULE += netdev_ieee802154
|
||||
USEMODULE += netdev_legacy_api
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += ieee802154_submac
|
||||
endif
|
||||
|
@ -187,6 +187,55 @@ typedef struct {
|
||||
kernel_pid_t pid; /**< PID of the network interface's thread */
|
||||
} gnrc_netif_t;
|
||||
|
||||
/**
|
||||
* @brief Check if the device belonging to the given netif uses the legacy
|
||||
* netdev API
|
||||
*
|
||||
* Check @ref netdev_driver_t::confirm_send for info about the old and new
|
||||
* netdev API.
|
||||
*
|
||||
* netdevs using the legacy API have to depend on the (pseudo-)module
|
||||
* netdev_legaqcy_api, netdevs using the new API have to depend on the
|
||||
* (pseudo-)module netdev_new_api. If only one of the pseudo modules is used,
|
||||
* this function can be constant folded. For boards mixing legacy and new API
|
||||
* netdevs, this will check the flavor at runtime.
|
||||
*
|
||||
* @see netdev_driver_t::confirm_send
|
||||
*/
|
||||
static inline bool gnrc_netif_netdev_legacy_api(gnrc_netif_t *netif)
|
||||
{
|
||||
if (!IS_USED(MODULE_NETDEV_NEW_API) && !IS_USED(MODULE_NETDEV_LEGACY_API)) {
|
||||
/* this should only happen for external netdevs or when no netdev is
|
||||
* used (e.g. examples/gcoap can be used without any netdev, as still
|
||||
* CoAP requests to ::1 can be send */
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!IS_USED(MODULE_NETDEV_NEW_API)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!IS_USED(MODULE_NETDEV_LEGACY_API)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* both legacy and new API netdevs in use, fall back to runtime test: */
|
||||
return (netif->dev->driver->confirm_send == NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the device belonging to the given netif uses the new
|
||||
* netdev API
|
||||
*
|
||||
* @see gnrc_netif_netdev_legacy_api
|
||||
*
|
||||
* @see netdev_driver_t::confirm_send
|
||||
*/
|
||||
static inline bool gnrc_netif_netdev_new_api(gnrc_netif_t *netif)
|
||||
{
|
||||
return !gnrc_netif_netdev_legacy_api(netif);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see gnrc_netif_ops_t
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user