[qca-nss-drv] Fix redirect data_callback interface handler.

- The virtual packets from the NSS FW comes to the
driver with the N2H interface number as source. So,
we should register the data_callback and fast path
packet handlers with this interface number.
- Rename the dynamic 802.3 redirect interface types
as generic.

Change-Id: I59d28fb8000adb1e60e21e2e0326511b08c26869
Signed-off-by: Murat Sezgin <msezgin@codeaurora.org>
diff --git a/exports/nss_dynamic_interface.h b/exports/nss_dynamic_interface.h
index 6bab870..801cf28 100644
--- a/exports/nss_dynamic_interface.h
+++ b/exports/nss_dynamic_interface.h
@@ -66,8 +66,8 @@
 	NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER,
 	NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_INNER,
 	NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INLINE_OUTER,
-	NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H,
-	NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N,
+	NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H,
+	NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N,
 	NSS_DYNAMIC_INTERFACE_TYPE_TUN6RD_INNER,
 	NSS_DYNAMIC_INTERFACE_TYPE_TUN6RD_OUTER,
 	NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US,
diff --git a/nss_cmn.c b/nss_cmn.c
index 920aca2..55131b7 100644
--- a/nss_cmn.c
+++ b/nss_cmn.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2019, 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.
@@ -186,8 +186,8 @@
 	enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, interface_num);
 
 	return type == NSS_DYNAMIC_INTERFACE_TYPE_WIFI
-		|| type == NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H
-		|| type == NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N
+		|| type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H
+		|| type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N
 		|| type == NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED;
 }
 EXPORT_SYMBOL(nss_cmn_interface_is_redirect);
diff --git a/nss_hal/nss_hal.c b/nss_hal/nss_hal.c
index b5697b1..1d2cd95 100644
--- a/nss_hal/nss_hal.c
+++ b/nss_hal/nss_hal.c
@@ -371,8 +371,8 @@
 
 		nss_top->virt_if_handler_id = nss_dev->id;
 
-		nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H] = nss_dev->id;
-		nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N] = nss_dev->id;
+		nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H] = nss_dev->id;
+		nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N] = nss_dev->id;
 	}
 
 	if (npd->capwap_enabled == NSS_FEATURE_ENABLED) {
diff --git a/nss_virt_if.c b/nss_virt_if.c
index 3fd280d..981ae49 100644
--- a/nss_virt_if.c
+++ b/nss_virt_if.c
@@ -54,8 +54,8 @@
 {
 	enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_virt_if_get_context(), if_num);
 
-	return type == NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H
-		|| type == NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N;
+	return type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H
+		|| type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N;
 }
 EXPORT_SYMBOL(nss_virt_if_verify_if_num);
 
@@ -227,13 +227,13 @@
 	index_n2h = NSS_VIRT_IF_GET_INDEX(if_num_n2h);
 	index_h2n = NSS_VIRT_IF_GET_INDEX(if_num_h2n);
 
-	status = nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H);
+	status = nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H);
 	if (status != NSS_TX_SUCCESS) {
 		nss_warning("%p: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status);
 		return status;
 	}
 
-	status = nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N);
+	status = nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N);
 	if (status != NSS_TX_SUCCESS) {
 		nss_warning("%p: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status);
 		return status;
@@ -358,24 +358,24 @@
 		return NULL;
 	}
 
-	if_num_n2h = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H);
+	if_num_n2h = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H);
 	if (if_num_n2h < 0) {
 		nss_warning("%p: failure allocating redir_n2h\n", nss_ctx);
 		return NULL;
 	}
 
-	if_num_h2n = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N);
+	if_num_h2n = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N);
 	if (if_num_h2n < 0) {
 		nss_warning("%p: failure allocating redir_h2n\n", nss_ctx);
-		nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H);
+		nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H);
 		return NULL;
 	}
 
 	handle = nss_virt_if_handle_create_sync(nss_ctx, if_num_n2h, if_num_h2n, &ret);
 	if (!handle) {
 		nss_warning("%p: virt_if handle creation failed ret %d\n", nss_ctx, ret);
-		nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_N2H);
-		nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N);
+		nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H);
+		nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N);
 		return NULL;
 	}
 
@@ -619,12 +619,12 @@
 	nss_ctx = handle->nss_ctx;
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 
-	if (!nss_virt_if_verify_if_num(handle->if_num_h2n)) {
+	if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) {
 		nss_warning("if_num is invalid\n");
 		return;
 	}
 
-	reg = &nss_ctx->subsys_dp_register[handle->if_num_h2n];
+	reg = &nss_ctx->subsys_dp_register[handle->if_num_n2h];
 	reg->xmit_cb = cb;
 }
 EXPORT_SYMBOL(nss_virt_if_xmit_callback_register);
@@ -646,12 +646,12 @@
 	nss_ctx = handle->nss_ctx;
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 
-	if (!nss_virt_if_verify_if_num(handle->if_num_h2n)) {
+	if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) {
 		nss_warning("if_num is invalid\n");
 		return;
 	}
 
-	reg = &nss_ctx->subsys_dp_register[handle->if_num_h2n];
+	reg = &nss_ctx->subsys_dp_register[handle->if_num_n2h];
 	reg->xmit_cb = NULL;
 }
 EXPORT_SYMBOL(nss_virt_if_xmit_callback_unregister);
@@ -674,12 +674,12 @@
 	nss_ctx = handle->nss_ctx;
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 
-	if (!nss_virt_if_verify_if_num(handle->if_num_h2n)) {
+	if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) {
 		nss_warning("if_num is invalid\n");
 		return;
 	}
 
-	if_num = handle->if_num_h2n;
+	if_num = handle->if_num_n2h;
 
 	nss_core_register_subsys_dp(nss_ctx, if_num, data_callback, NULL, NULL, netdev, (uint32_t)netdev->features);
 	nss_top_main.if_rx_msg_callback[if_num] = NULL;
@@ -702,12 +702,12 @@
 	nss_ctx = handle->nss_ctx;
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
 
-	if (!nss_virt_if_verify_if_num(handle->if_num_h2n)) {
+	if (!nss_virt_if_verify_if_num(handle->if_num_n2h)) {
 		nss_warning("if_num is invalid\n");
 		return;
 	}
 
-	if_num = handle->if_num_h2n;
+	if_num = handle->if_num_n2h;
 
 	nss_core_unregister_subsys_dp(nss_ctx, if_num);
 
diff --git a/nss_virt_if_stats.c b/nss_virt_if_stats.c
index 7b2f7ba..2df701c 100644
--- a/nss_virt_if_stats.c
+++ b/nss_virt_if_stats.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 2019, 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.
@@ -126,7 +126,7 @@
 		/*
 		 * redir_h2n will collect stats from redir_n2h and redir_h2n in nss.
 		 */
-		if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_802_3_REDIR_H2N)
+		if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N)
 			continue;
 
 		bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num);