qca-nss-drv: Remove netdev allocation per IRQ

Change-Id: I2f2cb3a1a14bc767ddab13ec6841d7dc51019f3f
Signed-off-by: Aniruddha Paul <paulani@codeaurora.org>
diff --git a/nss_core.c b/nss_core.c
index e4c93f3..6180768 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -2080,8 +2080,7 @@
 {
 	int16_t processed, weight, count = 0;
 	uint32_t prio_cause, int_cause = 0, cause_type;
-	struct netdev_priv_instance *ndev_priv = netdev_priv(napi->dev);
-	struct int_ctx_instance *int_ctx = ndev_priv->int_ctx;
+	struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi);
 	struct nss_ctx_instance *nss_ctx = int_ctx->nss_ctx;
 
 	/*
@@ -2164,8 +2163,7 @@
  */
 int nss_core_handle_napi_emergency(struct napi_struct *napi, int budget)
 {
-	struct netdev_priv_instance *ndev_priv = netdev_priv(napi->dev);
-	struct int_ctx_instance *int_ctx = ndev_priv->int_ctx;
+	struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi);
 
 	nss_info_always("NSS core %d signal COREDUMP COMPLETE %x\n",
 				int_ctx->nss_ctx->id, int_ctx->cause);
@@ -2180,9 +2178,8 @@
  */
 int nss_core_handle_napi_queue(struct napi_struct *napi, int budget)
 {
-	struct netdev_priv_instance *ndev_priv = netdev_priv(napi->dev);
-	struct int_ctx_instance *int_ctx = ndev_priv->int_ctx;
 	int processed;
+	struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi);
 
 	processed = nss_core_handle_cause_queue(int_ctx, int_ctx->cause, budget);
 	if (processed < budget) {
@@ -2199,8 +2196,7 @@
  */
 int nss_core_handle_napi_non_queue(struct napi_struct *napi, int budget)
 {
-	struct netdev_priv_instance *ndev_priv = netdev_priv(napi->dev);
-	struct int_ctx_instance *int_ctx = ndev_priv->int_ctx;
+	struct int_ctx_instance *int_ctx = container_of(napi, struct int_ctx_instance, napi);
 
 	nss_core_handle_cause_nonqueue(int_ctx, int_ctx->cause, 0);
 	napi_complete(napi);
diff --git a/nss_core.h b/nss_core.h
index 5a6d982..e8a3817 100644
--- a/nss_core.h
+++ b/nss_core.h
@@ -412,7 +412,6 @@
 	uint32_t irq;			/* HLOS IRQ numbers bind to this instance */
 	uint32_t shift_factor;	/* Shift factor for this IRQ queue */
 	uint32_t cause;			/* Interrupt cause carried forward to BH */
-	struct net_device *ndev;/* Netdev associated with this interrupt ctx */
 	struct napi_struct napi;/* NAPI handler */
 };
 
@@ -499,6 +498,7 @@
 	struct nss_top_instance *nss_top;
 					/* Back pointer to NSS Top */
 	struct device *dev;		/* Pointer to the original device from probe */
+	struct net_device napi_ndev;    /* Dummy_netdev for NAPI */
 	uint32_t id;			/* Core ID for this instance */
 	void __iomem *nmap;		/* Pointer to NSS CSM registers */
 	void __iomem *vmap;		/* Virt mem pointer to virtual register map */
@@ -510,6 +510,7 @@
 	struct nss_meminfo_ctx meminfo_ctx;	/* Meminfo context */
 	enum nss_core_state state;	/* State of NSS core */
 	uint32_t c2c_start;		/* C2C start address */
+	uint32_t num_irq;                /* IRQ numbers per queue */
 	struct int_ctx_instance int_ctx[NSS_MAX_IRQ_PER_CORE];
 					/* Interrupt context instances for each queue */
 	struct hlos_h2n_desc_rings h2n_desc_rings[NSS_H2N_DESC_RING_NUM];
diff --git a/nss_hal/fsm9010/nss_hal_pvt.c b/nss_hal/fsm9010/nss_hal_pvt.c
index a2a9bf2..164e5bd 100644
--- a/nss_hal/fsm9010/nss_hal_pvt.c
+++ b/nss_hal/fsm9010/nss_hal_pvt.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -290,7 +290,7 @@
 	}
 
 	int_ctx->irq = npd->irq[irq_num];
-	netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi, 64);
+	netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64);
 	return 0;
 }
 
diff --git a/nss_hal/ipq60xx/nss_hal_pvt.c b/nss_hal/ipq60xx/nss_hal_pvt.c
index 4843a39..42ce7a5 100644
--- a/nss_hal/ipq60xx/nss_hal_pvt.c
+++ b/nss_hal/ipq60xx/nss_hal_pvt.c
@@ -572,55 +572,55 @@
 	int err = -1, irq = npd->irq[irq_num];
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_sos", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_queue", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_TX_UNBLOCKED;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss-tx-unblock", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_0;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue0", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1) {
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_1;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue1", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2) {
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_2;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue2", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3) {
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_3;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue3", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE) {
 		int_ctx->cause = NSS_N2H_INTR_COREDUMP_COMPLETE;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_paged_empty_buf_sos", int_ctx);
 	}
diff --git a/nss_hal/ipq806x/nss_hal_pvt.c b/nss_hal/ipq806x/nss_hal_pvt.c
index 4eedc90..e2a8203 100644
--- a/nss_hal/ipq806x/nss_hal_pvt.c
+++ b/nss_hal/ipq806x/nss_hal_pvt.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013, 2015-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013, 2015-2019, The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -1182,7 +1182,7 @@
 	}
 
 	int_ctx->irq = npd->irq[irq_num];
-	netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi, 64);
+	netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi, 64);
 
 	return 0;
 }
diff --git a/nss_hal/ipq807x/nss_hal_pvt.c b/nss_hal/ipq807x/nss_hal_pvt.c
index ed20b13..19702a2 100644
--- a/nss_hal/ipq807x/nss_hal_pvt.c
+++ b/nss_hal/ipq807x/nss_hal_pvt.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -654,55 +654,55 @@
 	irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY);
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_SOS) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFERS_SOS;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_sos", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_EMPTY_BUFFER_QUEUE) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_EMPTY_BUFFER_RETURN_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_EMPTY_BUFFER_QUEUE;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_empty_buf_queue", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_TX_UNBLOCKED) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_TX_UNBLOCKED_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_TX_UNBLOCKED;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss-tx-unblock", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_0) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_0;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue0", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_1) {
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_1;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue1", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_2) {
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_2;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue2", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_DATA_QUEUE_3) {
 		int_ctx->cause = NSS_N2H_INTR_DATA_QUEUE_3;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_queue, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_queue3", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_COREDUMP_COMPLETE) {
 		int_ctx->cause = NSS_N2H_INTR_COREDUMP_COMPLETE;
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_emergency, NSS_DATA_COMMAND_BUFFER_PROCESSING_WEIGHT);
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx);
 	}
 
 	if (irq_num == NSS_HAL_N2H_INTR_PURPOSE_PAGED_EMPTY_BUFFER_SOS) {
-		netif_napi_add(int_ctx->ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
+		netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, nss_core_handle_napi_non_queue, NSS_EMPTY_BUFFER_SOS_PROCESSING_WEIGHT);
 		int_ctx->cause = NSS_N2H_INTR_PAGED_EMPTY_BUFFERS_SOS;
 		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_paged_empty_buf_sos", int_ctx);
 	}
diff --git a/nss_hal/nss_hal.c b/nss_hal/nss_hal.c
index 1b48f0a..46a234b 100644
--- a/nss_hal/nss_hal.c
+++ b/nss_hal/nss_hal.c
@@ -131,74 +131,45 @@
 }
 
 /*
- * nss_hal_dummy_netdev_setup()
- *	Dummy setup for net_device handler
+ * nss_hal_clean_up_irq()
  */
-static void nss_hal_dummy_netdev_setup(struct net_device *ndev)
+static void nss_hal_clean_up_irq(struct int_ctx_instance *int_ctx)
 {
-
-}
-
-/*
- * nss_hal_clean_up_netdevice()
- */
-static void nss_hal_clean_up_netdevice(struct int_ctx_instance *int_ctx)
-{
-	if (int_ctx->irq) {
-		irq_clear_status_flags(int_ctx->irq, IRQ_DISABLE_UNLAZY);
-		free_irq(int_ctx->irq, int_ctx);
-		int_ctx->irq = 0;
-	}
-
-	if (!int_ctx->ndev) {
+	if (!int_ctx->irq) {
 		return;
 	}
 
-	unregister_netdev(int_ctx->ndev);
-	free_netdev(int_ctx->ndev);
-	int_ctx->ndev = NULL;
+	/*
+	 * Wait here till the poll is complete.
+	 */
+	napi_disable(&int_ctx->napi);
+
+	/*
+	 * Interrupt can be raised here before free_irq() but as napi is
+	 * already disabled, it will be never sheduled from hard_irq
+	 * context.
+	 */
+	irq_clear_status_flags(int_ctx->irq, IRQ_DISABLE_UNLAZY);
+	free_irq(int_ctx->irq, int_ctx);
+	int_ctx->irq = 0;
+
+	netif_napi_del(&int_ctx->napi);
 }
 
 /*
- * nss_hal_register_netdevice()
+ * nss_hal_register_irq()
  */
-static int nss_hal_register_netdevice(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd, int irq_num)
+static int nss_hal_register_irq(struct nss_ctx_instance *nss_ctx, struct nss_platform_data *npd,
+					struct net_device *netdev, int irq_num)
 {
 	struct nss_top_instance *nss_top = &nss_top_main;
-	struct net_device *netdev;
-	struct netdev_priv_instance *ndev_priv;
 	struct int_ctx_instance *int_ctx = &nss_ctx->int_ctx[irq_num];
 	int err = 0;
 
 	/*
-	 * Register netdevice handlers
-	 */
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0))
-	netdev = alloc_netdev(sizeof(struct netdev_priv_instance),
-					"qca-nss-dev%d", nss_hal_dummy_netdev_setup);
-#else
-	netdev = alloc_netdev(sizeof(struct netdev_priv_instance),
-					"qca-nss-dev%d", NET_NAME_ENUM, nss_hal_dummy_netdev_setup);
-#endif
-	if (!netdev) {
-		nss_warning("%p: Could not allocate net_device for queue %d\n", nss_ctx, irq_num);
-		return -ENOMEM;
-	}
-
-	netdev->netdev_ops = &nss_netdev_ops;
-	netdev->ethtool_ops = &nss_ethtool_ops;
-	err = register_netdev(netdev);
-	if (err) {
-		nss_warning("%p: Could not register net_device %d\n", nss_ctx, irq_num);
-		free_netdev(netdev);
-		return err;
-	}
-
-	/*
 	 * request for IRQs
 	 */
 	int_ctx->nss_ctx = nss_ctx;
-	int_ctx->ndev = netdev;
 	err = nss_top->hal_ops->request_irq(nss_ctx, npd, irq_num);
 	if (err) {
 		nss_warning("%p: IRQ request for queue %d failed", nss_ctx, irq_num);
@@ -208,8 +179,6 @@
 	/*
 	 * Register NAPI for NSS core interrupt
 	 */
-	ndev_priv = netdev_priv(netdev);
-	ndev_priv->int_ctx = int_ctx;
 	napi_enable(&int_ctx->napi);
 	return 0;
 }
@@ -253,6 +222,7 @@
 	nss_ctx = &nss_top->nss[nss_dev->id];
 	nss_ctx->id = nss_dev->id;
 #endif
+	nss_ctx->num_irq = npd->num_irq;
 	nss_ctx->nss_top = nss_top;
 
 	/*
@@ -322,10 +292,15 @@
 		goto err_init;
 	}
 
+	/*
+	 * Initialize the dummy netdevice.
+	 */
+	init_dummy_netdev(&nss_ctx->napi_ndev);
+
 	for (i = 0; i < npd->num_irq; i++) {
-		err = nss_hal_register_netdevice(nss_ctx, npd, i);
+		err = nss_hal_register_irq(nss_ctx, npd, &nss_ctx->napi_ndev, i);
 		if (err) {
-			goto err_register_netdevice;
+			goto err_register_irq;
 		}
 	}
 
@@ -575,7 +550,7 @@
 	 */
 	err = nss_top->hal_ops->core_reset(nss_dev, nss_ctx->nmap, nss_ctx->load, nss_top->clk_src);
 	if (err) {
-		goto err_register_netdevice;
+		goto err_register_irq;
 	}
 
 	/*
@@ -593,20 +568,18 @@
 	}
 
 	/*
-	 * Enable interrupts for NSS core
+	 * Enable interrupts for NSS core.
 	 */
-	nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
-
-	if (npd->num_queue > 1) {
-		nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[1].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
+	for (i = 0; i < npd->num_irq; i++) {
+		nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[i].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
 	}
 
 	nss_info("%p: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id);
 	goto out;
 
-err_register_netdevice:
-	for (i = 0; i < npd->num_queue; i++) {
-		nss_hal_clean_up_netdevice(&nss_ctx->int_ctx[i]);
+err_register_irq:
+	for (i = 0; i < npd->num_irq; i++) {
+		nss_hal_clean_up_irq(&nss_ctx->int_ctx[i]);
 	}
 
 err_init:
@@ -635,6 +608,7 @@
 {
 	struct nss_top_instance *nss_top = &nss_top_main;
 	struct nss_ctx_instance *nss_ctx = &nss_top->nss[nss_dev->id];
+	int i;
 
 	/*
 	 * Clean up debugfs
@@ -642,18 +616,12 @@
 	nss_stats_clean();
 
 	/*
-	 * Clean up netdev/interrupts
+	 * Clear up the resources associated with the interrupt
 	 */
-	nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
-	nss_hal_clean_up_netdevice(&nss_ctx->int_ctx[0]);
-
-	/*
-	 * Check if second interrupt is supported
-	 * If so then clear resources for second interrupt as well
-	 */
-	if (nss_ctx->int_ctx[1].ndev) {
-		nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[1].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS);
-		nss_hal_clean_up_netdevice(&nss_ctx->int_ctx[1]);
+	for (i = 0; i < nss_ctx->num_irq; i++) {
+		nss_hal_disable_interrupt(nss_ctx, nss_ctx->int_ctx[i].shift_factor,
+					  NSS_HAL_SUPPORTED_INTERRUPTS);
+		nss_hal_clean_up_irq(&nss_ctx->int_ctx[i]);
 	}
 
 	/*