Skip to content

Commit 55c9e13

Browse files
kapbhkrish2718
authored andcommitted
[nrf fromtree] drivers: wifi: Add tx packets drop count calculation
[SHEL-1063] Add calculation of drop packets in tx due to lack of buffer memory. Signed-off-by: Kapil Bhatt <[email protected]> (cherry picked from commit e5a665d)
1 parent 985a031 commit 55c9e13

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/wifi/nrfwifi/src/net_if.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ int nrf_wifi_if_send(const struct device *dev,
282282
#ifdef CONFIG_NRF70_DATA_TX
283283
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
284284
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
285+
struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL;
286+
struct rpu_host_stats *host_stats = NULL;
287+
void *nbuf = NULL;
285288

286289
if (!dev || !pkt) {
287290
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
@@ -306,6 +309,15 @@ int nrf_wifi_if_send(const struct device *dev,
306309
goto unlock;
307310
}
308311

312+
def_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx);
313+
host_stats = &def_dev_ctx->host_stats;
314+
nbuf = net_pkt_to_nbuf(pkt);
315+
if (!nbuf) {
316+
LOG_DBG("Failed to allocate net_pkt");
317+
host_stats->total_tx_drop_pkts++;
318+
goto out;
319+
}
320+
309321
#ifdef CONFIG_NRF70_RAW_DATA_TX
310322
if ((*(unsigned int *)pkt->frags->data) == NRF_WIFI_MAGIC_NUM_RAWTX) {
311323
if (vif_ctx_zep->if_carr_state != NRF_WIFI_FMAC_IF_CARR_STATE_ON) {
@@ -314,7 +326,7 @@ int nrf_wifi_if_send(const struct device *dev,
314326

315327
ret = nrf_wifi_fmac_start_rawpkt_xmit(rpu_ctx_zep->rpu_ctx,
316328
vif_ctx_zep->vif_idx,
317-
net_pkt_to_nbuf(pkt));
329+
nbuf);
318330
} else {
319331
#endif /* CONFIG_NRF70_RAW_DATA_TX */
320332
if ((vif_ctx_zep->if_carr_state != NRF_WIFI_FMAC_IF_CARR_STATE_ON) ||
@@ -324,7 +336,7 @@ int nrf_wifi_if_send(const struct device *dev,
324336

325337
ret = nrf_wifi_fmac_start_xmit(rpu_ctx_zep->rpu_ctx,
326338
vif_ctx_zep->vif_idx,
327-
net_pkt_to_nbuf(pkt));
339+
nbuf);
328340
#ifdef CONFIG_NRF70_RAW_DATA_TX
329341
}
330342
#endif /* CONFIG_NRF70_RAW_DATA_TX */

0 commit comments

Comments
 (0)