From ad9f83c606a099d29a402a06deb0e31c4e432aa6 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 15 Sep 2025 10:45:53 +0200 Subject: [PATCH 1/2] drivers/atwinc15x0: implement netdev API async This changes the behavior of the netdev implementation to match what async drivers do. The current implementation is synchronous, but that can be fixed once an async UART API is available. In any case, we rather should not complicate testing of the network stack by having network devices come in different flavors. --- drivers/atwinc15x0/atwinc15x0_netdev.c | 15 ++++++++++----- drivers/include/atwinc15x0.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/atwinc15x0/atwinc15x0_netdev.c b/drivers/atwinc15x0/atwinc15x0_netdev.c index bb1cb171e7d9..af708a0fed38 100644 --- a/drivers/atwinc15x0/atwinc15x0_netdev.c +++ b/drivers/atwinc15x0/atwinc15x0_netdev.c @@ -530,12 +530,14 @@ static void _atwinc15x0_wifi_cb(uint8_t type, void *msg) static int _atwinc15x0_send(netdev_t *netdev, const iolist_t *iolist) { - atwinc15x0_t *dev = (atwinc15x0_t *)netdev; + atwinc15x0_t *dev = container_of(netdev, atwinc15x0_t, netdev); assert(dev); assert(dev == atwinc15x0); assert(iolist); + dev->tx_result = -EAGAIN; + /* send wakes from standby but not from sleep */ if (_atwinc15x0_is_sleeping(dev)) { DEBUG("%s WiFi is in SLEEP state, cannot send\n", __func__); @@ -570,20 +572,23 @@ static int _atwinc15x0_send(netdev_t *netdev, const iolist_t *iolist) /* send the packet */ if (m2m_wifi_send_ethernet_pkt(atwinc15x0_eth_buf, tx_len) == M2M_SUCCESS) { - return tx_len; + dev->tx_result = tx_len; } else { DEBUG("%s sending WiFi packet failed", __func__); - return -EIO; + dev->tx_result = -EIO; } + + netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE); + return 0; } static int _confirm_send(netdev_t *netdev, void *info) { - (void)netdev; (void)info; - return -EOPNOTSUPP; + atwinc15x0_t *dev = container_of(netdev, atwinc15x0_t, netdev); + return dev->tx_result; } static int _atwinc15x0_recv(netdev_t *netdev, void *buf, size_t len, void *info) diff --git a/drivers/include/atwinc15x0.h b/drivers/include/atwinc15x0.h index 4fd8839f9e3d..4dde1943c8b3 100644 --- a/drivers/include/atwinc15x0.h +++ b/drivers/include/atwinc15x0.h @@ -92,6 +92,7 @@ typedef struct atwinc15x0 { int8_t rssi; /**< RSSI last measured by the WiFi module */ uint8_t* rx_buf; /**< Incoming packet in receive buffer */ + int tx_result; /**< value to resturn in confirm_send() */ uint16_t rx_len; /**< Length of an incoming packet, if there is no packet in the buffer, it is 0 */ From 72b260621e936a261b3c39d66161a1756184a9f3 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Mon, 15 Sep 2025 10:53:51 +0200 Subject: [PATCH 2/2] Update drivers/include/atwinc15x0.h Co-authored-by: crasbe --- drivers/include/atwinc15x0.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/include/atwinc15x0.h b/drivers/include/atwinc15x0.h index 4dde1943c8b3..d52f98b081c3 100644 --- a/drivers/include/atwinc15x0.h +++ b/drivers/include/atwinc15x0.h @@ -92,7 +92,7 @@ typedef struct atwinc15x0 { int8_t rssi; /**< RSSI last measured by the WiFi module */ uint8_t* rx_buf; /**< Incoming packet in receive buffer */ - int tx_result; /**< value to resturn in confirm_send() */ + int tx_result; /**< value to return in confirm_send() */ uint16_t rx_len; /**< Length of an incoming packet, if there is no packet in the buffer, it is 0 */