mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20993 from benpicco/netdev_new_api-enhance
gnrc_netif: netdev_new_api implies TX end irq, no need to check it
This commit is contained in:
commit
51f969d655
@ -325,7 +325,6 @@ static int _get(netdev_t *netdev, netopt_t opt, void *val, size_t max_len)
|
||||
|
||||
case NETOPT_RX_START_IRQ:
|
||||
case NETOPT_TX_START_IRQ:
|
||||
case NETOPT_TX_END_IRQ:
|
||||
*((netopt_enable_t *)val) = NETOPT_ENABLE;
|
||||
return sizeof(netopt_enable_t);
|
||||
|
||||
@ -859,7 +858,7 @@ static void _enable_tx2rx(at86rf215_t *dev)
|
||||
at86rf215_reg_write(dev, dev->BBC->RG_AMCS, amcs);
|
||||
}
|
||||
|
||||
static void _tx_end(at86rf215_t *dev, netdev_event_t event)
|
||||
static void _tx_end(at86rf215_t *dev)
|
||||
{
|
||||
netdev_t *netdev = &dev->netdev.netdev;
|
||||
|
||||
@ -871,11 +870,6 @@ static void _tx_end(at86rf215_t *dev, netdev_event_t event)
|
||||
|
||||
at86rf215_tx_done(dev);
|
||||
|
||||
if (event == NETDEV_EVENT_TX_NOACK) {
|
||||
/* signal error to confirm_send */
|
||||
dev->tx_frame_len = (int16_t)-EIO;
|
||||
}
|
||||
|
||||
if (netdev->event_callback) {
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||
}
|
||||
@ -884,6 +878,14 @@ static void _tx_end(at86rf215_t *dev, netdev_event_t event)
|
||||
dev->state = AT86RF215_STATE_IDLE;
|
||||
}
|
||||
|
||||
static void __tx_end_timeout(at86rf215_t *dev)
|
||||
{
|
||||
/* signal error to confirm_send */
|
||||
dev->tx_frame_len = (int16_t)-EHOSTUNREACH;
|
||||
|
||||
_tx_end(dev);
|
||||
}
|
||||
|
||||
static void _ack_timeout_cb(void* arg) {
|
||||
at86rf215_t *dev = arg;
|
||||
netdev_t *netdev = &dev->netdev.netdev;
|
||||
@ -975,7 +977,7 @@ static void _handle_ack_timeout(at86rf215_t *dev)
|
||||
at86rf215_rf_cmd(dev, CMD_RF_TXPREP);
|
||||
} else {
|
||||
/* no retransmissions left */
|
||||
_tx_end(dev, NETDEV_EVENT_TX_NOACK);
|
||||
__tx_end_timeout(dev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1234,7 +1236,7 @@ static void _isr(netdev_t *netdev)
|
||||
dev->state = AT86RF215_STATE_TX_WAIT_ACK;
|
||||
_start_ack_timer(dev);
|
||||
} else {
|
||||
_tx_end(dev, NETDEV_EVENT_TX_COMPLETE);
|
||||
_tx_end(dev);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1255,7 +1257,7 @@ static void _isr(netdev_t *netdev)
|
||||
if (_ack_frame_received(dev)) {
|
||||
timeout = 0;
|
||||
xtimer_remove(&dev->timer);
|
||||
_tx_end(dev, NETDEV_EVENT_TX_COMPLETE);
|
||||
_tx_end(dev);
|
||||
at86rf215_rf_cmd(dev, CMD_RF_RX);
|
||||
break;
|
||||
}
|
||||
|
@ -238,6 +238,7 @@ typedef enum {
|
||||
NETDEV_EVENT_RX_COMPLETE, /**< finished receiving a frame */
|
||||
NETDEV_EVENT_TX_STARTED, /**< started to transfer a frame */
|
||||
NETDEV_EVENT_TX_COMPLETE, /**< transfer frame complete */
|
||||
#if IS_USED(MODULE_NETDEV_LEGACY_API) || DOXYGEN
|
||||
/**
|
||||
* @brief transfer frame complete and data pending flag
|
||||
*
|
||||
@ -261,6 +262,7 @@ typedef enum {
|
||||
* `-EBUSY` in netdev_driver_t::confirm_send.
|
||||
*/
|
||||
NETDEV_EVENT_TX_MEDIUM_BUSY,
|
||||
#endif
|
||||
NETDEV_EVENT_LINK_UP, /**< link established */
|
||||
NETDEV_EVENT_LINK_DOWN, /**< link gone */
|
||||
NETDEV_EVENT_TX_TIMEOUT, /**< timeout when sending */
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "debug.h"
|
||||
|
||||
static void _update_l2addr_from_dev(gnrc_netif_t *netif);
|
||||
static void _check_netdev_capabilities(netdev_t *dev);
|
||||
static void _check_netdev_capabilities(netdev_t *dev, bool legacy);
|
||||
static void *_gnrc_netif_thread(void *args);
|
||||
static void _event_cb(netdev_t *dev, netdev_event_t event);
|
||||
|
||||
@ -1491,11 +1491,15 @@ static void _init_from_device(gnrc_netif_t *netif)
|
||||
_update_l2addr_from_dev(netif);
|
||||
}
|
||||
|
||||
static void _check_netdev_capabilities(netdev_t *dev)
|
||||
static void _check_netdev_capabilities(netdev_t *dev, bool legacy)
|
||||
{
|
||||
/* Check whether RX- and TX-complete interrupts are supported by the driver */
|
||||
if (IS_ACTIVE(DEVELHELP)) {
|
||||
if (IS_USED(MODULE_NETSTATS_L2) || IS_USED(MODULE_GNRC_NETIF_PKTQ)) {
|
||||
if (!legacy) {
|
||||
/* new API implies TX end event */
|
||||
return;
|
||||
}
|
||||
netopt_enable_t enable = NETOPT_ENABLE;
|
||||
int res = dev->driver->get(dev, NETOPT_TX_END_IRQ, &enable, sizeof(enable));
|
||||
if ((res != sizeof(enable)) || (enable != NETOPT_ENABLE)) {
|
||||
@ -1640,7 +1644,7 @@ int gnrc_netif_default_init(gnrc_netif_t *netif)
|
||||
return res;
|
||||
}
|
||||
netif_register(&netif->netif);
|
||||
_check_netdev_capabilities(dev);
|
||||
_check_netdev_capabilities(dev, gnrc_netif_netdev_legacy_api(netif));
|
||||
_init_from_device(netif);
|
||||
#ifdef DEVELHELP
|
||||
_test_options(netif);
|
||||
|
@ -177,6 +177,7 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
puts("Tx complete");
|
||||
break;
|
||||
|
||||
#if IS_USED(MODULE_NETDEV_LEGACY_API)
|
||||
case NETDEV_EVENT_TX_COMPLETE_DATA_PENDING:
|
||||
puts("Tx complete (with pending data)");
|
||||
break;
|
||||
@ -188,7 +189,7 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
case NETDEV_EVENT_TX_NOACK:
|
||||
puts("No ACK");
|
||||
break;
|
||||
|
||||
#endif
|
||||
default:
|
||||
printf("Event: %d\n", event);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user