diff --git a/drivers/include/net/netdev/ieee802154_submac.h b/drivers/include/net/netdev/ieee802154_submac.h index 2a9472a779dc..1f4eb6afef8c 100644 --- a/drivers/include/net/netdev/ieee802154_submac.h +++ b/drivers/include/net/netdev/ieee802154_submac.h @@ -50,6 +50,7 @@ typedef struct { ieee802154_submac_t submac; /**< IEEE 802.15.4 SubMAC descriptor */ ztimer_t ack_timer; /**< ztimer descriptor for the ACK timeout timer */ int isr_flags; /**< netdev submac @ref NETDEV_EVENT_ISR flags */ + int bytes_tx; /**< size of the sent frame or tx error */ int8_t retrans; /**< number of frame retransmissions of the last TX */ bool dispatch; /**< whether an event should be dispatched or not */ netdev_event_t ev; /**< event to be dispatched */ diff --git a/drivers/netdev_ieee802154_submac/Makefile.dep b/drivers/netdev_ieee802154_submac/Makefile.dep new file mode 100644 index 000000000000..ded8dc45528e --- /dev/null +++ b/drivers/netdev_ieee802154_submac/Makefile.dep @@ -0,0 +1,5 @@ +USEMODULE += netdev_ieee802154 +USEMODULE += netdev_new_api +USEMODULE += ieee802154 +USEMODULE += ieee802154_submac +USEMODULE += ztimer_usec diff --git a/drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c b/drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c index 2e675f108001..2fbbc64974d1 100644 --- a/drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c +++ b/drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c @@ -174,6 +174,7 @@ static int _send(netdev_t *netdev, const iolist_t *pkt) * inside the TX Done callback */ netdev_submac->ev = NETDEV_EVENT_TX_STARTED; } + netdev_submac->bytes_tx = res; return res; } @@ -280,21 +281,14 @@ static void submac_tx_done(ieee802154_submac_t *submac, int status, } netdev_submac->dispatch = true; + netdev_submac->ev = NETDEV_EVENT_TX_COMPLETE; switch (status) { - case TX_STATUS_SUCCESS: - netdev_submac->ev = NETDEV_EVENT_TX_COMPLETE; - break; - case TX_STATUS_FRAME_PENDING: - netdev_submac->ev = NETDEV_EVENT_TX_COMPLETE_DATA_PENDING; - break; case TX_STATUS_MEDIUM_BUSY: - netdev_submac->ev = NETDEV_EVENT_TX_MEDIUM_BUSY; + netdev_submac->bytes_tx = -EBUSY; break; case TX_STATUS_NO_ACK: - netdev_submac->ev = NETDEV_EVENT_TX_NOACK; - break; - default: + netdev_submac->bytes_tx = -EHOSTUNREACH; break; } } @@ -377,6 +371,16 @@ static int _init(netdev_t *netdev) return 0; } +static int _confirm_send(netdev_t *netdev, void *info) +{ + (void)info; + netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev, netdev_ieee802154_t, netdev); + netdev_ieee802154_submac_t *netdev_submac = container_of(netdev_ieee802154, + netdev_ieee802154_submac_t, + dev); + return netdev_submac->bytes_tx; +} + int netdev_ieee802154_submac_init(netdev_ieee802154_submac_t *netdev_submac) { netdev_t *netdev = &netdev_submac->dev.netdev; @@ -402,6 +406,7 @@ static const netdev_driver_t netdev_submac_driver = { .recv = _recv, .isr = _isr, .init = _init, + .confirm_send = _confirm_send, }; /** @} */ diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 00afb08a25ee..5b0375c92a56 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -150,14 +150,6 @@ ifneq (,$(filter netdev_ieee802154,$(USEMODULE))) USEMODULE += random endif -ifneq (,$(filter netdev_ieee802154_submac,$(USEMODULE))) - USEMODULE += netdev_ieee802154 - USEMODULE += netdev_legacy_api - USEMODULE += ieee802154 - USEMODULE += ieee802154_submac - USEMODULE += ztimer_usec -endif - ifneq (,$(filter uhcpc,$(USEMODULE))) USEMODULE += posix_inet USEMODULE += ztimer_msec