From 3ba131c0f2ac4a90537f2a1c49d4b369c9bb153c Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 20 Nov 2024 23:37:30 +0100 Subject: [PATCH] netdev_tap: port to netdev_new_api --- cpu/native/Makefile.dep | 2 +- cpu/native/netdev_tap/netdev_tap.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cpu/native/Makefile.dep b/cpu/native/Makefile.dep index b996ab9c3d87..0504cdc7f475 100644 --- a/cpu/native/Makefile.dep +++ b/cpu/native/Makefile.dep @@ -41,7 +41,7 @@ ifneq (,$(filter socket_zep,$(USEMODULE))) endif ifneq (,$(filter netdev_tap,$(USEMODULE))) - USEMODULE += netdev_legacy_api + USEMODULE += netdev_new_api endif ifneq (,$(filter libc_gettimeofday,$(USEMODULE))) diff --git a/cpu/native/netdev_tap/netdev_tap.c b/cpu/native/netdev_tap/netdev_tap.c index dc1848063cea..444ac0f2c029 100644 --- a/cpu/native/netdev_tap/netdev_tap.c +++ b/cpu/native/netdev_tap/netdev_tap.c @@ -166,6 +166,17 @@ static int _set(netdev_t *dev, netopt_t opt, const void *value, size_t value_len return res; } +static int _confirm_send(netdev_t *netdev, void *info) +{ + (void)netdev; + (void)info; + + /* confirm_send should not be called with synchronos send */ + assert(0); + + return -EOPNOTSUPP; +} + static const netdev_driver_t netdev_driver_tap = { .send = _send, .recv = _recv, @@ -173,6 +184,7 @@ static const netdev_driver_t netdev_driver_tap = { .isr = _isr, .get = _get, .set = _set, + .confirm_send = _confirm_send, }; /* driver implementation */ @@ -293,12 +305,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist) unsigned n; iolist_to_iovec(iolist, iov, &n); - int res = _native_writev(dev->tap_fd, iov, n); - - if (netdev->event_callback) { - netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE); - } - return res; + return _native_writev(dev->tap_fd, iov, n); } void netdev_tap_setup(netdev_tap_t *dev, const netdev_tap_params_t *params, int index) {