[qca-nss-drv]: Add a module parameter to NSS DRV

Add a module parameter to NSS driver to bypass the NW processing in NSS for physical interfaces

Change-Id: I702c19ca25c998201763ef598977ee8e132cee6a
Signed-off-by: Radha krishna Simha Jiguru <rjiguru@codeaurora.org>
diff --git a/nss_data_plane.c b/nss_data_plane.c
index d9c3d0d..abde343 100644
--- a/nss_data_plane.c
+++ b/nss_data_plane.c
@@ -20,6 +20,8 @@
 #include "nss_tx_rx_common.h"
 #include <nss_gmac_api_if.h>
 
+extern int nss_skip_nw_process;
+
 #define NSS_DP_SUPPORTED_FEATURES NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)
 
 struct nss_data_plane_param nss_data_plane_params[NSS_MAX_PHYSICAL_INTERFACES];
@@ -35,7 +37,7 @@
 	if (dp->notify_open) {
 		return NSS_GMAC_SUCCESS;
 	}
-	if (nss_phys_if_open(dp->nss_ctx, tx_desc_ring, rx_desc_ring, mode, dp->if_num) == NSS_TX_SUCCESS) {
+	if (nss_phys_if_open(dp->nss_ctx, tx_desc_ring, rx_desc_ring, mode, dp->if_num, dp->bypass_nw_process) == NSS_TX_SUCCESS) {
 		dp->notify_open = 1;
 		return NSS_GMAC_SUCCESS;
 	}
@@ -159,6 +161,15 @@
 	ndpp->notify_open = 0;
 	ndpp->features = 0;
 
+	/*
+	 * Check if NSS NW processing to be bypassed for this GMAC
+	 */
+	if (nss_skip_nw_process) {
+		ndpp->bypass_nw_process = 1;
+	} else {
+		ndpp->bypass_nw_process = 0;
+	}
+
 	if (nss_gmac_override_data_plane(netdev, &dp_ops, ndpp) != NSS_GMAC_SUCCESS) {
 		nss_info("Override nss-gmac data plane failed\n");
 		return false;
@@ -196,4 +207,5 @@
 	nss_data_plane_params[if_num].if_num = 0;
 	nss_data_plane_params[if_num].notify_open = 0;
 	nss_data_plane_params[if_num].enabled = 0;
+	nss_data_plane_params[if_num].bypass_nw_process = 0;
 }
diff --git a/nss_data_plane.h b/nss_data_plane.h
index bf6fb4c..065bb0d 100644
--- a/nss_data_plane.h
+++ b/nss_data_plane.h
@@ -35,6 +35,7 @@
 	int notify_open;			/* This gmac interface has been opened or not */
 	int enabled;				/* This gmac is enabled or not */
 	uint32_t features;			/* skb types supported by this interface */
+	uint32_t bypass_nw_process;		/* Do we want to bypass NW processing in NSS for this GMAC */
 };
 
 /*
diff --git a/nss_init.c b/nss_init.c
index 92055a4..3396137 100755
--- a/nss_init.c
+++ b/nss_init.c
@@ -62,6 +62,8 @@
 int nss_ctl_logbuf __read_mostly = 0;
 int nss_jumbo_mru  __read_mostly = 0;
 int nss_paged_mode __read_mostly = 0;
+int nss_skip_nw_process = 0x0;
+module_param(nss_skip_nw_process, int, S_IRUGO);
 
 /*
  * PM client handle
diff --git a/nss_phys_if.c b/nss_phys_if.c
index 5fb0721..5d9d386 100644
--- a/nss_phys_if.c
+++ b/nss_phys_if.c
@@ -482,7 +482,7 @@
  * nss_phys_if_open()
  *	Send open command to physical interface
  */
-nss_tx_status_t nss_phys_if_open(struct nss_ctx_instance *nss_ctx, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode, uint32_t if_num)
+nss_tx_status_t nss_phys_if_open(struct nss_ctx_instance *nss_ctx, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode, uint32_t if_num, uint32_t bypass_nw_process)
 {
 	struct nss_phys_if_msg nim;
 	struct nss_if_open *nio;
@@ -496,6 +496,7 @@
 	nio = &nim.msg.if_msg.open;
 	nio->tx_desc_ring = tx_desc_ring;
 	nio->rx_desc_ring = rx_desc_ring;
+
 	if (mode == NSS_GMAC_MODE0) {
 		nio->rx_forward_if = NSS_ETH_RX_INTERFACE;
 		nio->alignment_mode = NSS_IF_DATA_ALIGN_2BYTE;
@@ -510,6 +511,15 @@
 		return NSS_GMAC_FAILURE;
 	}
 
+	/*
+	 * If Network processing in NSS is bypassed
+	 * update next hop and alignment accordingly
+	 */
+	if (bypass_nw_process) {
+		nio->rx_forward_if = NSS_N2H_INTERFACE;
+		nio->alignment_mode = NSS_IF_DATA_ALIGN_2BYTE;
+	}
+
 	return nss_phys_if_msg_sync(nss_ctx, &nim);
 }
 
diff --git a/nss_phys_if.h b/nss_phys_if.h
index 59efebf..c8df99e 100644
--- a/nss_phys_if.h
+++ b/nss_phys_if.h
@@ -204,10 +204,12 @@
  * @param tx_desc_ring Tx descriptor ring address
  * @param rx_desc_ring Rx descriptor ring address
  * @param if_num GMAC i/f number
+ * @param bypass_nw_process network processing in nss is bypassed for GMAC
  *
  * @return nss_tx_status_t Tx status
  */
-nss_tx_status_t nss_phys_if_open(struct nss_ctx_instance *nss_ctx, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode, uint32_t if_num);
+nss_tx_status_t nss_phys_if_open(struct nss_ctx_instance *nss_ctx, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode, uint32_t if_num,
+								uint32_t bypass_nw_process);
 
 /**
  * @brief Close GMAC interface on NSS