From abc7458df4e3414a54df3a2fb8eb9ccf05ca0699 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Sun, 13 Jul 2025 01:32:37 +0530 Subject: [PATCH 1/2] drivers: nrf_wifi: Fix return codes for xmit Return proper error codes for xmit instead of generic -1. Signed-off-by: Chaitanya Tata --- drivers/wifi/nrf_wifi/src/net_if.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/wifi/nrf_wifi/src/net_if.c b/drivers/wifi/nrf_wifi/src/net_if.c index 9108a0dab3b25..f94dc5a1e2142 100644 --- a/drivers/wifi/nrf_wifi/src/net_if.c +++ b/drivers/wifi/nrf_wifi/src/net_if.c @@ -363,7 +363,7 @@ enum ethernet_hw_caps nrf_wifi_if_caps_get(const struct device *dev) int nrf_wifi_if_send(const struct device *dev, struct net_pkt *pkt) { - int ret = -1; + int ret = -EINVAL; #ifdef CONFIG_NRF70_DATA_TX struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; @@ -404,6 +404,7 @@ int nrf_wifi_if_send(const struct device *dev, if (nbuf == NULL) { LOG_ERR("%s: allocation failed", __func__); + ret = -ENOMEM; goto drop; } @@ -420,6 +421,7 @@ int nrf_wifi_if_send(const struct device *dev, #endif /* CONFIG_NRF70_RAW_DATA_TX */ if ((vif_ctx_zep->if_carr_state != NRF_WIFI_FMAC_IF_CARR_STATE_ON) || (!vif_ctx_zep->authorized && !is_eapol(pkt))) { + ret = -EPERM; goto drop; } @@ -432,6 +434,8 @@ int nrf_wifi_if_send(const struct device *dev, if (ret == NRF_WIFI_STATUS_FAIL) { /* FMAC API takes care of freeing the nbuf */ host_stats->total_tx_drop_pkts++; + /* Could be many reasons, but likely no space in the queue */ + ret = -ENOBUFS; } goto unlock; drop: From 576647ecdd0bd035c24e6df7a95c395dedc27472 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Sun, 13 Jul 2025 01:33:49 +0530 Subject: [PATCH 2/2] net: Fix the return code for success None of the drivers seem to return the number of bytes, they all return 0 for success, so, fix the docs. Signed-off-by: Chaitanya Tata --- include/zephyr/net/net_l2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/net/net_l2.h b/include/zephyr/net/net_l2.h index a7aa8530ee293..4684706ba835d 100644 --- a/include/zephyr/net/net_l2.h +++ b/include/zephyr/net/net_l2.h @@ -66,7 +66,7 @@ struct net_l2 { * This function is used by net core to push a packet to lower layer * (interface's L2), which in turn might work on the packet relevantly. * (adding proper header etc...) - * Returns a negative error code, or the number of bytes sent otherwise. + * Returns a negative error code, or 0 if the packet was accepted. */ int (*send)(struct net_if *iface, struct net_pkt *pkt);