[qca-nss-drv] GRE_REDIR 3 radio offload support

Changes to extend full offload support for GRE_REDIR
for more than 2-radios.

Change-Id: Ia872d1819687be4937a90be85745d26a997a0d3c
Signed-off-by: Amit Gupta <amitgupt@codeaurora.org>
diff --git a/exports/nss_gre_redir.h b/exports/nss_gre_redir.h
index f133d7b..a6c6d25 100644
--- a/exports/nss_gre_redir.h
+++ b/exports/nss_gre_redir.h
@@ -30,7 +30,7 @@
 #define NSS_GRE_REDIR_MAX_INTERFACES 24			/**< Maximum number of redirect interfaces. */
 #define NSS_GRE_REDIR_IP_DF_OVERRIDE_FLAG 0x80		/**< Override Do not Fragment bit in IPv4 flags. */
 #define NSS_GRE_REDIR_PER_PACKET_METADATA_OFFSET 4	/**< Offset of per packet metadata from start of packet. */
-#define NSS_GRE_REDIR_NUM_RADIO 2			/**< Maximum number of radios. */
+#define NSS_GRE_REDIR_MAX_RADIO 5			/**< Maximum number of radios. */
 #define NSS_GRE_REDIR_HEADER_VERSION 0			/**< Version for GRE header. */
 
 /**
@@ -59,6 +59,28 @@
 };
 
 /**
+ * nss_gre_redir_error_types
+ *	Error types for GRE redirect configuration messages.
+ */
+enum nss_gre_redir_error_types {
+	NSS_GRE_REDIR_ERROR_NONE,			/**< Configuration successful. */
+	NSS_GRE_REDIR_ERROR_UNKNOWN_MSG_TYPE,		/**< Unknown configuration message type error. */
+	NSS_GRE_REDIR_ERROR_INVALID_IP_HDR_TYPE,	/**< Invalid IP header type error. */
+	NSS_GRE_REDIR_ERROR_MAP_TABLE_FULL,		/**< Map table full error. */
+	NSS_GRE_REDIR_ERROR_MAP_INVALID_PARAM,		/**< Invalid parameter with map message error. */
+	NSS_GRE_REDIR_ERROR_UNMAP_INVALID_PARAM,	/**< Invalid parameter with unmap message error. */
+	NSS_GRE_REDIR_ERROR_ENCAP_MAP_EXIST,		/**< Encapsulation map entry already exist. */
+	NSS_GRE_REDIR_ERROR_DECAP_MAP_EXIST,		/**< Decapsulation map entry already exist. */
+	NSS_GRE_REDIR_ERROR_ENCAP_MAP_ALLOC_FAIL,	/**< Encapsulation map entry allocation failure error. */
+	NSS_GRE_REDIR_ERROR_DECAP_MAP_ALLOC_FAIL,	/**< Decapsulation map entry allocation failure error. */
+	NSS_GRE_REDIR_ERROR_ENCAP_ENTRY_UNMAPPED,	/**< Encapsulation map entry already unmapped. */
+	NSS_GRE_REDIR_ERROR_DECAP_ENTRY_UNMAPPED,	/**< Decapsulation map entry already unmapped. */
+	NSS_GRE_REDIR_ERROR_INVALID_ETH_IF,		/**< Invalid Ethernet NSS interface. */
+	NSS_GRE_REDIR_ERROR_INVALID_VAP_NEXTHOP_IF,	/**< Invalid nexthop NSS interface. */
+	NSS_GRE_REDIR_ERROR_INVALID_PEER_INTERFACE,	/**< Invalid peer interface during tunnel configuration. */
+};
+
+/**
  * nss_gre_redir_tunnel_types
  *	GRE tunnel types.
  */
@@ -209,7 +231,7 @@
 struct nss_gre_redir_stats_sync_msg {
 	struct nss_cmn_node_stats node_stats;		/**< Common node statistics. */
 	uint32_t sjack_rx_packets;			/**< SJACK packet counter. */
-	uint32_t offl_rx_pkts[NSS_GRE_REDIR_NUM_RADIO];	/**< Offload packet counter. */
+	uint32_t offl_rx_pkts[NSS_GRE_REDIR_MAX_RADIO];	/**< Offload packet counter. */
 	uint32_t encap_sg_alloc_drop;			/**< Encapsulation drop counters due to scatter gather buffer allocation failure. */
 	uint32_t decap_fail_drop;			/**< Decapsulation drop counters due to invalid IP header. */
 	uint32_t decap_split_drop;			/**< Decapsulation drop counters due to split flow processing. */
@@ -234,8 +256,8 @@
 	uint64_t tx_dropped;				/**< Dropped Tx packets. */
 	uint64_t sjack_rx_packets;			/**< SJACK Rx packet counter. */
 	uint64_t sjack_tx_packets;			/**< SJACK Tx packet counter. */
-	uint64_t offl_rx_pkts[NSS_GRE_REDIR_NUM_RADIO];	/**< Offload Rx packet counter per radio. */
-	uint64_t offl_tx_pkts[NSS_GRE_REDIR_NUM_RADIO];	/**< Offload Tx packet counter per radio. */
+	uint64_t offl_rx_pkts[NSS_GRE_REDIR_MAX_RADIO];	/**< Offload Rx packet counter per radio. */
+	uint64_t offl_tx_pkts[NSS_GRE_REDIR_MAX_RADIO];	/**< Offload Tx packet counter per radio. */
 	uint64_t exception_us_rx;			/**< Upstream exception Rx packet counter. */
 	uint64_t exception_us_tx;			/**< Upstream exception Tx packet counter. */
 	uint64_t exception_ds_rx;			/**< Downstream exception Rx packet counter. */
diff --git a/nss_gre_redir.c b/nss_gre_redir.c
index 894239d..ef8eec3 100644
--- a/nss_gre_redir.c
+++ b/nss_gre_redir.c
@@ -116,7 +116,7 @@
 		tun_stats[i].sjack_tx_packets += ngss->sjack_rx_packets;
 		tun_stats[i].encap_sg_alloc_drop += ngss->encap_sg_alloc_drop;
 		tun_stats[i].tx_dropped += nss_cmn_rx_dropped_sum(&(ngss->node_stats));
-		for (j = 0; j < NSS_GRE_REDIR_NUM_RADIO; j++) {
+		for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) {
 			tun_stats[i].offl_tx_pkts[j] += ngss->offl_rx_pkts[j];
 		}
 
@@ -133,7 +133,7 @@
 		tun_stats[i].split_not_enough_tailroom += ngss->split_not_enough_tailroom;
 		tun_stats[i].decap_eapol_frames += ngss->decap_eapol_frames;
 		tun_stats[i].node_stats.rx_dropped[0] += nss_cmn_rx_dropped_sum(&(ngss->node_stats));
-		for (j = 0; j < NSS_GRE_REDIR_NUM_RADIO; j++) {
+		for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) {
 			tun_stats[i].offl_rx_pkts[j] += ngss->offl_rx_pkts[j];
 		}
 
diff --git a/nss_gre_redir_stats.c b/nss_gre_redir_stats.c
index de5ec03..3dd7e6b 100644
--- a/nss_gre_redir_stats.c
+++ b/nss_gre_redir_stats.c
@@ -85,7 +85,7 @@
 		tcnt = s->sjack_tx_packets;
 		return snprintf(line, len, "Offload stats start:\n\n%s = %llu\n", nss_gre_redir_stats_str[i], tcnt);
 	case NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS:
-		for (j = 0; j < NSS_GRE_REDIR_NUM_RADIO; j++) {
+		for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) {
 			scnprintf(name, sizeof(name), "TX offload pkts for radio %d", j);
 			tcnt += snprintf(line + tcnt, len - tcnt, "%s = %llu\n", name, s->offl_tx_pkts[j]);
 		}
@@ -94,7 +94,7 @@
 		tcnt = s->sjack_rx_packets;
 		return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt);
 	case NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS:
-		for (j = 0; j < NSS_GRE_REDIR_NUM_RADIO; j++) {
+		for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) {
 			scnprintf(name, sizeof(name), "RX offload pkts for radio %d", j);
 			tcnt += snprintf(line + tcnt, len - tcnt, "%s = %llu\n", name, s->offl_rx_pkts[j]);
 		}
@@ -163,7 +163,7 @@
 	ssize_t bytes_read = 0;
 	struct nss_gre_redir_tunnel_stats stats;
 	size_t bytes;
-	char line[80 * NSS_MAX_NUM_PRI];
+	char line[80 * NSS_GRE_REDIR_MAX_RADIO];
 	int start, end;
 	int index = 0;