[qca-nss-drv] unify coredump interrupt method

Using one coredump completion interrupt per core and add hawkeye
interrupt method for core dump completion notification.

Change-Id: I9c1d4b115dae21a6a3543e3fd27f28c72d2e8207
Signed-off-by: Guojun Jin <gjin@codeaurora.org>
diff --git a/nss_core.c b/nss_core.c
index a97d43f..3dfa67c 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -1586,16 +1586,9 @@
 		return NSS_N2H_INTR_DATA_QUEUE_3;
 	}
 
-	if (cause & NSS_N2H_INTR_COREDUMP_COMPLETE_0) {
-		printk("NSS core 0 signal COREDUMP COMPLETE %x ", cause);
+	if (cause & NSS_N2H_INTR_COREDUMP_COMPLETE) {
 		*type = NSS_INTR_CAUSE_EMERGENCY;
-		return NSS_N2H_INTR_COREDUMP_COMPLETE_0;
-	}
-
-	if (cause & NSS_N2H_INTR_COREDUMP_COMPLETE_1) {
-		printk("NSS core 1 signal COREDUMP COMPLETE %x\n", cause);
-		*type = NSS_INTR_CAUSE_EMERGENCY;
-		return NSS_N2H_INTR_COREDUMP_COMPLETE_1;
+		return NSS_N2H_INTR_COREDUMP_COMPLETE;
 	}
 
 	return 0;
@@ -1657,6 +1650,8 @@
 				break;
 
 			case NSS_INTR_CAUSE_EMERGENCY:
+				nss_info_always("NSS core %d signal COREDUMP COMPLETE %x\n",
+					nss_ctx->id, int_ctx->cause);
 				nss_fw_coredump_notify(nss_ctx, prio_cause);
 				int_ctx->cause &= ~prio_cause;
 				break;
@@ -1686,6 +1681,22 @@
 }
 
 /*
+ * nss_core_handle_napi_emergency()
+ *	NAPI handler for NSS crash
+ */
+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;
+
+	nss_info_always("NSS core %d signal COREDUMP COMPLETE %x\n",
+				int_ctx->nss_ctx->id, int_ctx->cause);
+	nss_fw_coredump_notify(int_ctx->nss_ctx, 0);
+
+	return 0;
+}
+
+/*
  * nss_core_handle_napi_queue()
  *	NAPI handler for NSS queue cause
  */
diff --git a/nss_core.h b/nss_core.h
index 24dc848..58224a0 100644
--- a/nss_core.h
+++ b/nss_core.h
@@ -163,7 +163,7 @@
  */
 #if defined(NSS_HAL_IPQ807x_SUPPORT)
 #define NSS_MAX_IRQ_PER_INSTANCE 4
-#define NSS_MAX_IRQ_PER_CORE 7
+#define NSS_MAX_IRQ_PER_CORE 8
 #else
 #define NSS_MAX_IRQ_PER_INSTANCE 1
 #define NSS_MAX_IRQ_PER_CORE 2
@@ -1909,6 +1909,7 @@
 extern int nss_core_handle_napi(struct napi_struct *napi, int budget);
 extern int nss_core_handle_napi_queue(struct napi_struct *napi, int budget);
 extern int nss_core_handle_napi_non_queue(struct napi_struct *napi, int budget);
+extern int nss_core_handle_napi_emergency(struct napi_struct *napi, int budget);
 extern int32_t nss_core_send_buffer(struct nss_ctx_instance *nss_ctx, uint32_t if_num,
 					struct sk_buff *nbuf, uint16_t qid,
 					uint8_t buffer_type, uint16_t flags);
diff --git a/nss_hal/include/nss_hal.h b/nss_hal/include/nss_hal.h
index 1ac6e20..35ea522 100644
--- a/nss_hal/include/nss_hal.h
+++ b/nss_hal/include/nss_hal.h
@@ -47,8 +47,7 @@
 					NSS_N2H_INTR_DATA_QUEUE_1 | \
 					NSS_N2H_INTR_EMPTY_BUFFERS_SOS | \
 					NSS_N2H_INTR_TX_UNBLOCKED | \
-					NSS_N2H_INTR_COREDUMP_COMPLETE_0 | \
-					NSS_N2H_INTR_COREDUMP_COMPLETE_1)
+					NSS_N2H_INTR_COREDUMP_COMPLETE)
 
 /*
  * nss_hal_read_interrupt_cause()
diff --git a/nss_hal/include/nss_regs.h b/nss_hal/include/nss_regs.h
index 9af9508..e9b1fdf 100644
--- a/nss_hal/include/nss_regs.h
+++ b/nss_hal/include/nss_regs.h
@@ -66,8 +66,7 @@
 #define NSS_N2H_INTR_DATA_QUEUE_3		(1 << 4)
 #define NSS_N2H_INTR_EMPTY_BUFFERS_SOS		(1 << 10)
 #define NSS_N2H_INTR_TX_UNBLOCKED		(1 << 11)
-#define NSS_N2H_INTR_COREDUMP_COMPLETE_1	(1 << 13)
-#define NSS_N2H_INTR_COREDUMP_COMPLETE_0	(1 << 14)
+#define NSS_N2H_INTR_COREDUMP_COMPLETE		(1 << 14)
 
 /*
  * Types of H2N interrupts
diff --git a/nss_hal/ipq807x/nss_hal_pvt.c b/nss_hal/ipq807x/nss_hal_pvt.c
index 61363ba..4c93c1d 100644
--- a/nss_hal/ipq807x/nss_hal_pvt.c
+++ b/nss_hal/ipq807x/nss_hal_pvt.c
@@ -517,6 +517,12 @@
 		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);
+		err = request_irq(irq, nss_hal_handle_irq, 0, "nss_coredump_complete", int_ctx);
+	}
+
 	if (err) {
 		return err;
 	}