[qca-nss-drv] add nss_gre_tunnel_inquiry API for debug purpose

Change-Id: I1d33c1366ccdfa86ba7065877b763d742104241f
Signed-off-by: Guojun Jin <gjin@codeaurora.org>
diff --git a/exports/nss_gre_tunnel.h b/exports/nss_gre_tunnel.h
index f447c7b..f88e793 100644
--- a/exports/nss_gre_tunnel.h
+++ b/exports/nss_gre_tunnel.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018, 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.
@@ -41,6 +41,7 @@
 	NSS_GRE_TUNNEL_MSG_SESSION_DESTROY,
 	NSS_GRE_TUNNEL_MSG_STATS,
 	NSS_GRE_TUNNEL_MSG_CONFIGURE_DI_TO_WLAN_ID,
+	NSS_GRE_TUNNEL_MSG_INQUIRY,
 	NSS_GRE_TUNNEL_MSG_MAX,
 };
 
@@ -332,6 +333,21 @@
 extern void nss_gre_tunnel_unregister_if(uint32_t if_num);
 
 /**
+ * nss_gre_tunnel_inquiry()
+ *	Inquiry if a GRE tunnel has been established in NSS FW.
+ *
+ * @param[in] inquiry_info  Query parameters similar to creation parameters.
+ * @param[in] cb            Pointer to the message callback.
+ * @param[in] app_data      Pointer to the application context of the message.
+ *
+ * @return
+ * Status of the Tx operation
+ */
+extern nss_tx_status_t nss_gre_tunnel_inquiry(
+		struct nss_gre_tunnel_configure *inquiry_info,
+		nss_gre_tunnel_msg_callback_t cb, void *app_data);
+
+/**
  * @}
  */
 
diff --git a/nss_gre_tunnel.c b/nss_gre_tunnel.c
index 3f58274..e5bc2f9 100644
--- a/nss_gre_tunnel.c
+++ b/nss_gre_tunnel.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018, 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.
@@ -115,6 +115,48 @@
 }
 
 /*
+ * nss_gre_tunnel_inquiry()
+ *	Inquiry if a GRE tunnel has been established in NSS FW.
+ *
+ * Input parameters:
+ *	inquiry_info->ip_type
+ *	inquiry_info->src_ip
+ *	inquiry_info->dest_ip
+ *	inquiry_info->gre_mode
+ *	 if (gre_mode == NSS_GRE_TUNNEL_MODE_GRE_UDP)
+ *		inquiry_info->src_port
+ *		inquiry_info->dest_port
+ *	inquiry_info->encrypt_type	-- currently not checked in FW,
+ */
+nss_tx_status_t nss_gre_tunnel_inquiry(
+		struct nss_gre_tunnel_configure *inquiry_info,
+		nss_gre_tunnel_msg_callback_t cb, void *app_data)
+{
+	nss_tx_status_t nss_tx_status;
+	struct nss_gre_tunnel_msg nim;
+	struct nss_ctx_instance *nss_ctx = nss_gre_tunnel_get_ctx();
+
+	/*
+	 * 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_gre_tunnel_msg_init(&nim, NSS_GRE_TUNNEL_INTERFACE,
+			NSS_GRE_TUNNEL_MSG_INQUIRY,
+			sizeof(struct nss_gre_tunnel_configure),
+			cb, app_data);
+	nim.msg.configure = *inquiry_info;
+	nss_tx_status = nss_gre_tunnel_tx_msg(nss_ctx, &nim);
+	if (nss_tx_status != NSS_TX_SUCCESS) {
+		nss_warning("%p: Send GT inquiry message failed\n", inquiry_info);
+	}
+
+	return nss_tx_status;
+}
+EXPORT_SYMBOL(nss_gre_tunnel_inquiry);
+
+/*
  * nss_get_gre_tunnel_context()
  *	Return the core ctx which the feature is on
  */