Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: mana: Return error code from mana_create_rxq()
@ 2026-07-18  2:48 Aditya Garg
  0 siblings, 0 replies; only message in thread
From: Aditya Garg @ 2026-07-18  2:48 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
	edumazet, kuba, pabeni, ernis, horms, dipayanroy, gargaditya,
	shacharr, stephen, linux-hyperv, netdev, linux-kernel, ssengar,
	gargaditya

mana_create_rxq() returns a struct mana_rxq pointer and returns NULL on
any failure. The caller, mana_add_rx_queues(), cannot tell what went
wrong and hardcodes the error as -ENOMEM. As a result the actual failure
reported by the lower layers (for example -EPROTO from a failed HW
request) is masked and every RX queue creation failure looks like an
out-of-memory error.

Change mana_create_rxq() to return an int and pass the created rxq back
to the caller through an output parameter. The caller now propagates the
returned error code directly instead of substituting -ENOMEM.

Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)")
Signed-off-by: Aditya Garg <gargaditya@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/ethernet/microsoft/mana/mana_en.c | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index 9d9bfd116dab..9162e356e0c1 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -2811,9 +2811,9 @@ static int mana_create_page_pool(struct mana_rxq *rxq, struct gdma_context *gc)
 	return 0;
 }
 
-static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
-					u32 rxq_idx, struct mana_eq *eq,
-					struct net_device *ndev)
+static int mana_create_rxq(struct mana_port_context *apc, u32 rxq_idx,
+			   struct mana_eq *eq, struct net_device *ndev,
+			   struct mana_rxq **rxq_out)
 {
 	struct gdma_dev *gd = apc->ac->gdma_dev;
 	struct mana_obj_spec wq_spec;
@@ -2829,7 +2829,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
 
 	rxq = kvzalloc_flex(*rxq, rx_oobs, apc->rx_queue_size);
 	if (!rxq)
-		return NULL;
+		return -ENOMEM;
 
 	rxq->ndev = ndev;
 	rxq->num_rx_buf = apc->rx_queue_size;
@@ -2923,14 +2923,16 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
 
 	mana_gd_ring_cq(cq->gdma_cq, SET_ARM_BIT);
 out:
-	if (!err)
-		return rxq;
+	if (!err) {
+		*rxq_out = rxq;
+		return 0;
+	}
 
 	netdev_err(ndev, "Failed to create RXQ: err = %d\n", err);
 
 	mana_destroy_rxq(apc, rxq, false);
 
-	return NULL;
+	return err;
 }
 
 static void mana_create_rxq_debugfs(struct mana_port_context *apc, int idx)
@@ -2963,9 +2965,8 @@ static int mana_add_rx_queues(struct mana_port_context *apc,
 	int i;
 
 	for (i = 0; i < apc->num_queues; i++) {
-		rxq = mana_create_rxq(apc, i, &apc->eqs[i], ndev);
-		if (!rxq) {
-			err = -ENOMEM;
+		err = mana_create_rxq(apc, i, &apc->eqs[i], ndev, &rxq);
+		if (err) {
 			netdev_err(ndev, "Failed to create rxq %d : %d\n", i, err);
 			goto out;
 		}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-18  2:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-18  2:48 [PATCH net] net: mana: Return error code from mana_create_rxq() Aditya Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox