Apply patch of SPF11.3.CSU1

Change-Id: I672ea5d6128cbf1ab8cc431e06984e6a55067f67
diff --git a/nss_clmap.c b/nss_clmap.c
index a76fd64..0d78a71 100644
--- a/nss_clmap.c
+++ b/nss_clmap.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-2020, 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.
@@ -88,12 +88,12 @@
 	 * Is this a valid request/response packet?
 	 */
 	if (ncm->type >= NSS_CLMAP_MSG_TYPE_MAX) {
-		nss_warning("%p: received invalid message %d for clmap interface", nss_ctx, ncm->type);
+		nss_warning("%px: received invalid message %d for clmap interface", nss_ctx, ncm->type);
 		return;
 	}
 
 	if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_clmap_msg)) {
-		nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
+		nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm));
 		return;
 	}
 
@@ -113,8 +113,8 @@
 	 * Update the callback and app_data for NOTIFY messages.
 	 */
 	if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) {
-		ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface];
-		ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data;
+		ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface);
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data;
 	}
 
 	/*
@@ -122,7 +122,7 @@
 	 */
 	cb = (nss_clmap_msg_callback_t)ncm->cb;
 	if (!cb) {
-		nss_trace("%p: cb is null for interface %d", nss_ctx, ncm->interface);
+		nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface);
 		return;
 	}
 
@@ -169,14 +169,14 @@
 
 	status = nss_clmap_tx_msg(nss_ctx, nclm);
 	if (status != NSS_TX_SUCCESS) {
-		nss_warning("%p: clmap_tx_msg failed\n", nss_ctx);
+		nss_warning("%px: clmap_tx_msg failed\n", nss_ctx);
 		up(&clmap_pvt.sem);
 		return status;
 	}
 
 	ret = wait_for_completion_timeout(&clmap_pvt.complete, msecs_to_jiffies(NSS_CLMAP_TX_TIMEOUT));
 	if (!ret) {
-		nss_warning("%p: clmap tx sync failed due to timeout\n", nss_ctx);
+		nss_warning("%px: clmap tx sync failed due to timeout\n", nss_ctx);
 		clmap_pvt.response = NSS_TX_FAILURE;
 	}
 
@@ -205,19 +205,25 @@
 bool nss_clmap_unregister(uint32_t if_num)
 {
 	struct nss_ctx_instance *nss_ctx;
+	int status;
 
 	nss_ctx = nss_clmap_get_ctx();
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 
 	if (!nss_clmap_verify_if_num(if_num)) {
-		nss_warning("%p: clmap unregister request received for invalid interface %d", nss_ctx, if_num);
+		nss_warning("%px: clmap unregister request received for invalid interface %d", nss_ctx, if_num);
 		return false;
 	}
 
-	nss_clmap_stats_session_unregister(if_num);
-	nss_core_unregister_handler(nss_ctx, if_num);
+	status = nss_core_unregister_msg_handler(nss_ctx, if_num);
+	if (status != NSS_CORE_STATUS_SUCCESS) {
+		nss_warning("%px: Failed to unregister handler for clmap NSS I/F:%u\n", nss_ctx, if_num);
+		return false;
+	}
+
 	nss_core_unregister_subsys_dp(nss_ctx, if_num);
-	nss_top_main.if_rx_msg_callback[if_num] = NULL;
+	nss_core_unregister_handler(nss_ctx, if_num);
+	nss_clmap_stats_session_unregister(if_num);
 
 	return true;
 }
@@ -242,8 +248,8 @@
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 
 	if (!nss_clmap_verify_if_num(if_num)) {
-		nss_warning("%p: clmap register request received for invalid interface %d", nss_ctx, if_num);
-		return NULL;
+		nss_warning("%px: clmap register request received for invalid interface %d", nss_ctx, if_num);
+		goto fail;
 	}
 
 	if (di_type == NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US) {
@@ -253,22 +259,33 @@
 	}
 
 	if (!stats_status) {
-		nss_warning("%p: statistics registration failed for interface: %d\n", nss_ctx, if_num);
-		return NULL;
+		nss_warning("%px: statistics registration failed for interface: %d\n", nss_ctx, if_num);
+		goto fail;
 	}
 
 	core_status = nss_core_register_handler(nss_ctx, if_num, nss_clmap_msg_handler, (void *)netdev);
 	if (core_status != NSS_CORE_STATUS_SUCCESS) {
-		nss_clmap_stats_session_unregister(if_num);
-		nss_warning("%p: NSS core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status);
-		return NULL;
+		goto core_reg_fail;
+	}
+
+	core_status = nss_core_register_msg_handler(nss_ctx, if_num, notify_cb);
+	if (core_status != NSS_CORE_STATUS_SUCCESS) {
+		goto msg_reg_fail;
 	}
 
 	nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, (void *)netdev, netdev, features);
 	nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, di_type);
-	nss_top_main.if_rx_msg_callback[if_num] = notify_cb;
 
 	return nss_ctx;
+
+msg_reg_fail:
+	nss_core_unregister_handler(nss_ctx, if_num);
+core_reg_fail:
+	nss_clmap_stats_session_unregister(if_num);
+	nss_warning("%px: NSS core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status);
+fail:
+	return NULL;
+
 }
 EXPORT_SYMBOL(nss_clmap_register);
 
@@ -282,7 +299,7 @@
 
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 	if (!nss_is_dynamic_interface(if_num)) {
-		nss_warning("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num);
+		nss_warning("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num);
 		return 0;
 	}
 	return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num);