[qca-nss-drv] avoid duplicate callback register

Avoid duplicate callback register which can happen
when multiple IPsec tunnels are created

Change-Id: Icbd306a5dad0e0abe691533c8e213d48d576f674
Signed-off-by: Samarjeet Banerjee <banerjee@codeaurora.org>
diff --git a/nss_ipsec.c b/nss_ipsec.c
index 151416a..ed87afe 100644
--- a/nss_ipsec.c
+++ b/nss_ipsec.c
@@ -284,6 +284,13 @@
 		return NULL;
 	}
 
+	/*
+	 * avoid multiple registeration for multiple tunnels
+	 */
+	if (nss_ctx->nss_top->ipsec_encap_callback || nss_ctx->nss_top->ipsec_decap_callback) {
+		return nss_ctx;
+	}
+
 	if (nss_ipsec_set_msg_callback(nss_ctx, if_num, cb, app_data) != NSS_TX_SUCCESS) {
 		nss_ipsec_warning("%p: register failed\n", nss_ctx);
 		return NULL;
@@ -326,6 +333,13 @@
 		return NULL;
 	}
 
+	/*
+	 * avoid multiple registeration for multiple tunnels
+	 */
+	if (nss_ctx->nss_top->subsys_dp_register[if_num].cb) {
+		return nss_ctx;
+	}
+
 	nss_ctx->nss_top->subsys_dp_register[if_num].cb = cb;
 	nss_ctx->nss_top->subsys_dp_register[if_num].app_data = NULL;
 	nss_ctx->nss_top->subsys_dp_register[if_num].ndev = netdev;