[qca-nss-drv] Adding connection inquiry for NSS debug.

Give 5 tuples to NSS FW to find if a matching connection exists;
nss_ipv#_conn_inquiry() is the API to pass 5 tuple for inquiry,
and its callback parameter (cb) is for checking return result/status.

Change-Id: Ib968b9b3b7d1a4125425a8926489e74cb90af30f
Signed-off-by: Guojun Jin <gjin@codeaurora.org>
diff --git a/exports/nss_ipv4.h b/exports/nss_ipv4.h
index d135bbd..c05db64 100644
--- a/exports/nss_ipv4.h
+++ b/exports/nss_ipv4.h
@@ -43,6 +43,7 @@
 	NSS_IPV4_TX_CREATE_MC_RULE_MSG,
 	NSS_IPV4_TX_CONN_STATS_SYNC_MANY_MSG,
 	NSS_IPV4_TX_ACCEL_MODE_CFG_MSG,
+	NSS_IPV4_TX_CONN_CFG_INQUIRY_MSG,
 	NSS_IPV4_MAX_MSG_TYPES,
 };
 
@@ -335,6 +336,17 @@
 };
 
 /**
+ * nss_ipv4__inquiry_msg
+ *	IPv4 connection inquiry naming structure.
+ */
+struct nss_ipv4_inquiry_msg {
+	/*
+	 * Request by its 5 tuple and get Response for other items.
+	 */
+	struct nss_ipv4_rule_create_msg rr;
+};
+
+/**
  * nss_ipv4_mc_if_rule
  *	IPv4 multicast rule for creating per-interface information.
  */
@@ -677,6 +689,8 @@
 				/**< Synchronize multiple connection statistics. */
 		struct nss_ipv4_accel_mode_cfg_msg accel_mode_cfg;
 				/**< Acceleration mode. */
+		struct nss_ipv4_inquiry_msg inquiry;
+				/**< Inquiry if a connection has created. */
 	} msg;			/**< Message payload. */
 };
 
diff --git a/exports/nss_ipv6.h b/exports/nss_ipv6.h
index 49aaf4f..2d2566f 100644
--- a/exports/nss_ipv6.h
+++ b/exports/nss_ipv6.h
@@ -43,6 +43,7 @@
 	NSS_IPV6_TX_CREATE_MC_RULE_MSG,
 	NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG,
 	NSS_IPV6_TX_ACCEL_MODE_CFG_MSG,
+	NSS_IPV6_TX_CONN_CFG_INQUIRY_MSG,
 	NSS_IPV6_MAX_MSG_TYPES,
 };
 
@@ -398,6 +399,17 @@
 };
 
 /**
+ * nss_ipv6_inquiry_msg
+ *	IPv6 connection inquiry sub-messages.
+ */
+struct nss_ipv6_inquiry_msg {
+	/*
+	 * Request by 5 tuple, and Response in other items.
+	 */
+	struct nss_ipv6_rule_create_msg rr;
+};
+
+/**
  * nss_ipv6_mc_if_rule
  *	IPv6 multicast rule for creating a per-interface payload.
  */
@@ -642,6 +654,8 @@
 				/**< Synchronize multiple connection statistics. */
 		struct nss_ipv6_accel_mode_cfg_msg accel_mode_cfg;
 				/**< Configure acceleration mode. */
+		struct nss_ipv6_inquiry_msg inquiry;
+				/**< Inquiry if a connection has been created. */
 	} msg;			/**< Message payload. */
 };
 
diff --git a/nss_ipv4.c b/nss_ipv4.c
index 7930be3..b2b9e8a 100644
--- a/nss_ipv4.c
+++ b/nss_ipv4.c
@@ -55,6 +55,37 @@
 EXPORT_SYMBOL(nss_ipv4_max_conn_count);
 
 /*
+ * nss_ipv4_conn_inquiry()
+ *	Inquiry if a connection has been established in NSS FW
+ */
+nss_tx_status_t nss_ipv4_conn_inquiry(struct nss_ipv4_5tuple *ipv4_5t_p,
+				nss_ipv4_msg_callback_t cb)
+{
+	nss_tx_status_t nss_tx_status;
+	struct nss_ipv4_msg nim;
+	struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[0];
+
+	/*
+	 * Initialize inquiry message structure.
+	 * This is async message and the result will be returned
+	 * to the caller by the msg_callback passed in.
+	 */
+	memset(&nim, 0, sizeof(nim));
+	nss_ipv4_msg_init(&nim, NSS_IPV4_RX_INTERFACE,
+			NSS_IPV4_TX_CONN_CFG_INQUIRY_MSG,
+			sizeof(struct nss_ipv4_inquiry_msg),
+			cb, NULL);
+	nim.msg.inquiry.rr.tuple = *ipv4_5t_p;
+	nss_tx_status = nss_ipv4_tx(nss_ctx, &nim);
+	if (nss_tx_status != NSS_TX_SUCCESS) {
+		nss_warning("%p: Send inquiry message failed\n", ipv4_5t_p);
+	}
+
+	return nss_tx_status;
+}
+EXPORT_SYMBOL(nss_ipv4_conn_inquiry);
+
+/*
  * nss_ipv4_driver_conn_sync_update()
  *	Update driver specific information from the messsage.
  */
diff --git a/nss_ipv6.c b/nss_ipv6.c
index 430d260..c5a6590 100644
--- a/nss_ipv6.c
+++ b/nss_ipv6.c
@@ -54,6 +54,37 @@
 EXPORT_SYMBOL(nss_ipv6_max_conn_count);
 
 /*
+ * nss_ipv6_conn_inquiry()
+ *	Inquiry if a connection has been established in NSS FW
+ */
+nss_tx_status_t nss_ipv6_conn_inquiry(struct nss_ipv6_5tuple *ipv6_5t_p,
+				nss_ipv6_msg_callback_t cb)
+{
+	nss_tx_status_t nss_tx_status;
+	struct nss_ipv6_msg nim;
+	struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[0];
+
+	/*
+	 * Initialize inquiry message structure.
+	 * This is async message and the result will be returned
+	 * to the caller by the msg_callback passed in.
+	 */
+	memset(&nim, 0, sizeof(nim));
+	nss_ipv6_msg_init(&nim, NSS_IPV6_RX_INTERFACE,
+			NSS_IPV6_TX_CONN_CFG_INQUIRY_MSG,
+			sizeof(struct nss_ipv6_inquiry_msg),
+			cb, NULL);
+	nim.msg.inquiry.rr.tuple = *ipv6_5t_p;
+	nss_tx_status = nss_ipv6_tx(nss_ctx, &nim);
+	if (nss_tx_status != NSS_TX_SUCCESS) {
+		nss_warning("%p: Send inquiry message failed\n", ipv6_5t_p);
+	}
+
+	return nss_tx_status;
+}
+EXPORT_SYMBOL(nss_ipv6_conn_inquiry);
+
+/*
  * nss_ipv6_driver_conn_sync_update()
  *	Update driver specific information from the messsage.
  */