[qca-nss-drv] Enhanced logging

Logging is enhanced to pretty print the message type,
response codes, error codes and message contents.

Change-Id: I36dd6119586bd35843389606b4c43d7a95b0f819
Signed-off-by: Suruchi Agarwal <suruchia@codeaurora.org>
diff --git a/Makefile b/Makefile
index 2f5188b..6e1e3c0 100644
--- a/Makefile
+++ b/Makefile
@@ -19,8 +19,10 @@
 			nss_init.o \
 			nss_ipsec.o \
 			nss_ipv4.o \
+			nss_ipv4_log.o \
 			nss_ipv4_reasm.o \
 			nss_ipv6.o \
+			nss_ipv6_log.o \
 			nss_ipv6_reasm.o \
 			nss_lag.o \
 			nss_lso_rx.o \
diff --git a/Makefile.fsm b/Makefile.fsm
index e4dbd9f..0068b92 100644
--- a/Makefile.fsm
+++ b/Makefile.fsm
@@ -21,8 +21,10 @@
 			nss_init.o \
 			nss_ipsec.o \
 			nss_ipv4.o \
+			nss_ipv4_log.o \
 			nss_ipv4_reasm.o \
 			nss_ipv6.o \
+			nss_ipv6_log.o \
 			nss_ipv6_reasm.o \
 			nss_lag.o \
 			nss_phys_if.o \
diff --git a/exports/nss_cmn.h b/exports/nss_cmn.h
index 2a6d90a..b20d9bb 100644
--- a/exports/nss_cmn.h
+++ b/exports/nss_cmn.h
@@ -97,6 +97,11 @@
 };
 
 /**
+ * Common response structure string
+ */
+extern int8_t *nss_cmn_response_str[NSS_CMN_RESPONSE_LAST];
+
+/**
  * Common structures
  */
 
diff --git a/exports/nss_ipv4.h b/exports/nss_ipv4.h
index 9f5919e..7d10993 100644
--- a/exports/nss_ipv4.h
+++ b/exports/nss_ipv4.h
@@ -604,5 +604,11 @@
  */
 extern int nss_ipv4_update_conn_count(int ipv4_max_conn);
 
+/**
+ * Logger APIs
+ */
+void nss_ipv4_log_tx_msg(struct nss_ipv4_msg *nim);
+void nss_ipv4_log_rx_msg(struct nss_ipv4_msg *nim);
+
 #endif /*__KERNEL__ */
 #endif /* __NSS_IPV4_H */
diff --git a/exports/nss_ipv6.h b/exports/nss_ipv6.h
index 89b1f10..1c5e5e4 100644
--- a/exports/nss_ipv6.h
+++ b/exports/nss_ipv6.h
@@ -568,5 +568,11 @@
  * @return 0 on success
  */
 extern int nss_ipv6_update_conn_count(int ipv6_num_conn);
+
+/**
+ * Logger APIs
+ */
+void nss_ipv6_log_tx_msg(struct nss_ipv6_msg *nim);
+void nss_ipv6_log_rx_msg(struct nss_ipv6_msg *nim);
 #endif
 #endif /* __NSS_IPV6_H */
diff --git a/nss_cmn.c b/nss_cmn.c
index bb3cfd9..a29546d 100644
--- a/nss_cmn.c
+++ b/nss_cmn.c
@@ -26,6 +26,19 @@
 #include "nss_tx_rx_common.h"
 
 /*
+ * nss_cmn_response_str
+ *	Common response structure string
+ */
+int8_t *nss_cmn_response_str[NSS_CMN_RESPONSE_LAST] = {
+	"Message Acknowledge without errors",
+	"Common message version not supported",
+	"Unknown Interface",
+	"Length Error",
+	"Message Error",
+	"FW Notification Message",
+};
+
+/*
  * nss_cmn_msg_init()
  *	Initialize the common message structure.
  */
diff --git a/nss_ipv4.c b/nss_ipv4.c
index 81ea0e2..fee2b67 100644
--- a/nss_ipv4.c
+++ b/nss_ipv4.c
@@ -141,9 +141,9 @@
 	}
 
 	/*
-	 * Log failures
+	 * Trace messages.
 	 */
-	nss_core_log_msg_failures(nss_ctx, ncm);
+	nss_ipv4_log_rx_msg(nim);
 
 	switch (nim->cm.type) {
 	case NSS_IPV4_RX_NODE_STATS_SYNC_MSG:
@@ -244,6 +244,11 @@
 	nim2 = (struct nss_ipv4_msg *)skb_put(nbuf, sizeof(struct nss_ipv4_msg));
 	memcpy(nim2, nim, sizeof(struct nss_ipv4_msg));
 
+	/*
+	 * Trace messages.
+	 */
+	nss_ipv4_log_tx_msg(nim);
+
 	status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0);
 	if (status != NSS_CORE_STATUS_SUCCESS) {
 		dev_kfree_skb_any(nbuf);
diff --git a/nss_ipv4_log.c b/nss_ipv4_log.c
new file mode 100644
index 0000000..3321069
--- /dev/null
+++ b/nss_ipv4_log.c
@@ -0,0 +1,352 @@
+/*
+ **************************************************************************
+ * Copyright (c) 2016, 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ **************************************************************************
+ */
+
+/*
+ * nss_ipv4_log.c
+ *	NSS IPv4 logger file.
+ */
+
+#include "nss_core.h"
+
+/*
+ * nss_ipv4_log_message_types_str
+ *	IPv4 bridge/route rule message strings
+ */
+static int8_t *nss_ipv4_log_message_types_str[NSS_IPV4_MAX_MSG_TYPES] = {
+	"IPv4 create rule message",
+	"IPv4 destroy rule message",
+	"Deprecated: NSS_IPV4_RX_ESTABLISH_RULE_MSG",
+	"IPv4 connection stats sync message",
+	"IPv4 generic statistics sync message",
+	"IPv4 number of connections supported rule message",
+	"IPv4 multicast create rule message",
+	"IPv4 request FW to send many conn sync message",
+};
+
+/*
+ * nss_ipv4_log_error_response_types_str
+ *	Strings for error types for ipv4 messages
+ */
+static int8_t *nss_ipv4_log_error_response_types_str[NSS_IPV4_LAST] = {
+	"No error",
+	"Unknown error",
+	"Invalid interface number",
+	"Missing connection rule",
+	"Buffer allocation failure",
+	"Unable to create PPPoE session",
+	"No connection found to delete",
+	"Conn cfg already done once",
+	"Conn cfg input is not multiple of quanta",
+	"Conn cfg input exceeds max supported connections",
+	"Conn cfg mem alloc fail at NSS FW",
+	"Invalid L4 protocol for multicast rule create",
+	"Invalid multicast flags for multicast update",
+	"Invalid interface for multicast update",
+};
+
+/*
+ * nss_ipv4_log_rule_create_msg()
+ *	Log IPv4 create rule message.
+ */
+static void nss_ipv4_log_rule_create_msg(struct nss_ipv4_msg *nim)
+{
+	struct nss_ipv4_rule_create_msg *nircm = &nim->msg.rule_create;
+	nss_trace("%p: IPv4 create rule message \n"
+		"Protocol: %d\n"
+		"from_mtu: %u\n"
+		"to_mtu: %u\n"
+		"from_ip: %pI4h:%d\n"
+		"to_ip: %pI4h:%d\n"
+		"from_ip_xlate: %pI4h:%d\n"
+		"to_ip_xlate: %pI4h:%d\n"
+		"from_mac: %pM\n"
+		"to_mac: %pM\n"
+		"src_iface_num: %u\n"
+		"dest_iface_num: %u\n"
+		"ingress_inner_vlan_tag: %u\n"
+		"egress_inner_vlan_tag: %u\n"
+		"ingress_outer_vlan_tag: %u\n"
+		"egress_outer_vlan_tag: %u\n"
+		"rule_flags: %x\n"
+		"valid_flags: %x\n"
+		"return_pppoe_session_id: %u\n"
+		"return_pppoe_remote_mac: %pM\n"
+		"flow_pppoe_session_id: %u\n"
+		"flow_pppoe_remote_mac: %pM\n"
+		"flow_qos_tag: %x (%u)\n"
+		"return_qos_tag: %x (%u)\n"
+		"flow_dscp: %x\n"
+		"return_dscp: %x\n",
+		nim,
+		nircm->tuple.protocol,
+		nircm->conn_rule.flow_mtu,
+		nircm->conn_rule.return_mtu,
+		&nircm->tuple.flow_ip, nircm->tuple.flow_ident,
+		&nircm->tuple.return_ip, nircm->tuple.return_ident,
+		&nircm->conn_rule.flow_ip_xlate, nircm->conn_rule.flow_ident_xlate,
+		&nircm->conn_rule.return_ip_xlate, nircm->conn_rule.return_ident_xlate,
+		nircm->conn_rule.flow_mac,
+		nircm->conn_rule.return_mac,
+		nircm->conn_rule.flow_interface_num,
+		nircm->conn_rule.return_interface_num,
+		nircm->vlan_primary_rule.ingress_vlan_tag,
+		nircm->vlan_primary_rule.egress_vlan_tag,
+		nircm->vlan_secondary_rule.ingress_vlan_tag,
+		nircm->vlan_secondary_rule.egress_vlan_tag,
+		nircm->rule_flags,
+		nircm->valid_flags,
+		nircm->pppoe_rule.return_pppoe_session_id,
+		nircm->pppoe_rule.return_pppoe_remote_mac,
+		nircm->pppoe_rule.flow_pppoe_session_id,
+		nircm->pppoe_rule.flow_pppoe_remote_mac,
+		nircm->qos_rule.flow_qos_tag, nircm->qos_rule.flow_qos_tag,
+		nircm->qos_rule.return_qos_tag, nircm->qos_rule.return_qos_tag,
+		nircm->dscp_rule.flow_dscp,
+		nircm->dscp_rule.return_dscp);
+}
+
+/*
+ * nss_ipv4_log_destroy_rule_msg()
+ *	Log IPv4 destroy rule message.
+ */
+static void nss_ipv4_log_destroy_rule_msg(struct nss_ipv4_msg *nim)
+{
+	struct nss_ipv4_rule_destroy_msg *nirdm = &nim->msg.rule_destroy;
+	nss_trace("%p: IPv4 destroy rule message: \n"
+		"flow_ip: %pI4h:%d\n"
+		"return_ip: %pI4h:%d\n"
+		"protocol: %d\n",
+		nim,
+		&nirdm->tuple.flow_ip, nirdm->tuple.flow_ident,
+		&nirdm->tuple.return_ip, nirdm->tuple.return_ident,
+		nirdm->tuple.protocol);
+}
+
+/*
+ * nss_ipv4_log_conn_sync()
+ *	Log IPv4 connection stats sync message.
+ */
+static void nss_ipv4_log_conn_sync(struct nss_ipv4_msg *nim)
+{
+	struct nss_ipv4_conn_sync *sync = &nim->msg.conn_stats;
+	if (sync->flow_tx_packet_count || sync->return_tx_packet_count) {
+		nss_trace("%p: IPv4 connection stats sync message: \n"
+			"Protocol: %d\n"
+			"src_addr: %pI4h:%d\n"
+			"dest_addr: %pI4h:%d\n"
+			"flow_rx_packet_count: %u\n"
+			"flow_rx_byte_count: %u\n"
+			"return_rx_packet_count: %u\n"
+			"return_rx_byte_count: %u\n"
+			"flow_tx_packet_count: %u\n"
+			"flow_tx_byte_count: %u\n"
+			"return_tx_packet_count: %u\n"
+			"return_tx_byte_count: %u\n",
+			nim,
+			(int)sync->protocol,
+			&sync->flow_ip, (int)sync->flow_ident,
+			&sync->return_ip_xlate, (int)sync->return_ident_xlate,
+			sync->flow_rx_packet_count,
+			sync->flow_rx_byte_count,
+			sync->return_rx_packet_count,
+			sync->return_rx_byte_count,
+			sync->flow_tx_packet_count,
+			sync->flow_tx_byte_count,
+			sync->return_tx_packet_count,
+			sync->return_tx_byte_count);
+		}
+}
+
+/*
+ * nss_ipv4_log_conn_cfg_msg()
+ *	Log IPv4 number of connections supported rule message.
+ */
+static void nss_ipv4_log_conn_cfg_msg(struct nss_ipv4_msg *nim)
+{
+	struct nss_ipv4_rule_conn_cfg_msg *nirccm = &nim->msg.rule_conn_cfg;
+	nss_trace("%p: IPv4 number of connections supported rule message: \n"
+		"num_conn: %d\n",
+		nim,
+		nirccm->num_conn);
+}
+
+/*
+ * nss_ipv4_log_mc_rule_create_msg()
+ *	Log IPv4 multicast create rule message.
+ */
+static void nss_ipv4_log_mc_rule_create_msg(struct nss_ipv4_msg *nim)
+{
+	uint16_t vif;
+	struct nss_ipv4_mc_rule_create_msg *nimrcm = &nim->msg.mc_rule_create;
+	for (vif = 0; vif < nimrcm->if_count ; vif++) {
+		nss_trace("%p: IPv4 multicast create rule message \n"
+			"Rule flag: %x\n"
+			"Vif: %d\n"
+			"Protocol: %d\n"
+			"to_mtu: %u\n"
+			"from_ip: %pI4h:%d\n"
+			"to_ip: %pI4h:%d\n"
+			"to_mac: %pM\n"
+			"dest_iface_num: %u\n"
+			"out_vlan[0] %x\n"
+			"out_vlan[1] %x\n",
+			nim,
+			nimrcm->if_rule[vif].rule_flags,
+			vif,
+			nimrcm->tuple.protocol,
+			nimrcm->if_rule[vif].if_mtu,
+			&nimrcm->tuple.flow_ip, nimrcm->tuple.flow_ident,
+			&nimrcm->tuple.return_ip, nimrcm->tuple.return_ident,
+			nimrcm->if_rule[vif].if_mac,
+			nimrcm->if_rule[vif].if_num,
+			nimrcm->if_rule[vif].egress_vlan_tag[0],
+			nimrcm->if_rule[vif].egress_vlan_tag[1]);
+	}
+}
+
+/*
+ * nss_ipv4_log_conn_sync_many_msg()
+ *	Log IPv4 many conn sync message.
+ */
+static void nss_ipv4_log_conn_sync_many_msg(struct nss_ipv4_msg *nim)
+{
+	uint16_t i;
+	struct nss_ipv4_conn_sync_many_msg *nicsm = &nim->msg.conn_stats_many;
+	for (i = 0; i < nicsm->count; i++) {
+		struct nss_ipv4_conn_sync *sync = &nicsm->conn_sync[i];
+		if (sync->flow_tx_packet_count || sync->return_tx_packet_count) {
+			nss_trace("%p: IPv4 many conn sync message \n"
+				"count: %d\n"
+				"i: %d\n"
+				"Protocol: %d\n"
+				"src_addr: %pI4h:%d\n"
+				"dest_addr: %pI4h:%d\n"
+				"flow_rx_packet_count: %u\n"
+				"flow_rx_byte_count: %u\n"
+				"return_rx_packet_count: %u\n"
+				"return_rx_byte_count: %u\n"
+				"flow_tx_packet_count: %u\n"
+				"flow_tx_byte_count: %u\n"
+				"return_tx_packet_count: %u\n"
+				"return_tx_byte_count: %u\n",
+				nim,
+				nicsm->count,
+				i,
+				(int)sync->protocol,
+				&sync->flow_ip, (int)sync->flow_ident,
+				&sync->return_ip_xlate, (int)sync->return_ident_xlate,
+				sync->flow_rx_packet_count,
+				sync->flow_rx_byte_count,
+				sync->return_rx_packet_count,
+				sync->return_rx_byte_count,
+				sync->flow_tx_packet_count,
+				sync->flow_tx_byte_count,
+				sync->return_tx_packet_count,
+				sync->return_tx_byte_count);
+		}
+	}
+}
+
+/*
+ * nss_ipv4_log_verbose()
+ *	Log message contents.
+ */
+static void nss_ipv4_log_verbose(struct nss_ipv4_msg *nim)
+{
+	switch (nim->cm.type) {
+	case NSS_IPV4_TX_CREATE_RULE_MSG:
+		nss_ipv4_log_rule_create_msg(nim);
+		break;
+
+	case NSS_IPV4_TX_DESTROY_RULE_MSG:
+		nss_ipv4_log_destroy_rule_msg(nim);
+		break;
+
+	case NSS_IPV4_RX_CONN_STATS_SYNC_MSG:
+		nss_ipv4_log_conn_sync(nim);
+		break;
+
+	case NSS_IPV4_RX_NODE_STATS_SYNC_MSG:
+		/* Getting logged in stats */
+		break;
+
+	case NSS_IPV4_TX_CONN_CFG_RULE_MSG:
+		nss_ipv4_log_conn_cfg_msg(nim);
+		break;
+
+	case NSS_IPV4_TX_CREATE_MC_RULE_MSG:
+		nss_ipv4_log_mc_rule_create_msg(nim);
+		break;
+
+	case NSS_IPV4_TX_CONN_STATS_SYNC_MANY_MSG:
+		nss_ipv4_log_conn_sync_many_msg(nim);
+		break;
+
+	default:
+		nss_trace("%p: Invalid message type\n", nim);
+		break;
+	}
+}
+
+/*
+ * nss_ipv4_log_tx_msg()
+ *	Log messages transmitted to FW.
+ */
+void nss_ipv4_log_tx_msg(struct nss_ipv4_msg *nim)
+{
+	if (nim->cm.type >= NSS_IPV4_MAX_MSG_TYPES) {
+		nss_info("%p: Invalid message type\n", nim);
+		return;
+	}
+
+	nss_info("%p: type[%d]:%s\n", nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type]);
+	nss_ipv4_log_verbose(nim);
+}
+
+/*
+ * nss_ipv4_log_rx_msg()
+ *	Log messages received from FW.
+ */
+void nss_ipv4_log_rx_msg(struct nss_ipv4_msg *nim)
+{
+	if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) {
+		nss_info("%p: Invalid response\n", nim);
+		return;
+	}
+
+	if (nim->cm.response == NSS_CMM_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) {
+		nss_info("%p: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type,
+			nss_ipv4_log_message_types_str[nim->cm.type],
+			nim->cm.response, nss_cmn_response_str[nim->cm.response]);
+		goto verbose;
+	}
+
+	if (nim->cm.error >= NSS_IPV4_LAST) {
+		nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n",
+			nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type],
+			nim->cm.response, nss_cmn_response_str[nim->cm.response],
+			nim->cm.error);
+		goto verbose;
+	}
+
+	nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n",
+		nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type],
+		nim->cm.response, nss_cmn_response_str[nim->cm.response],
+		nim->cm.error, nss_ipv4_log_error_response_types_str[nim->cm.error]);
+
+verbose:
+	nss_ipv4_log_verbose(nim);
+}
\ No newline at end of file
diff --git a/nss_ipv6.c b/nss_ipv6.c
index 3e6fa02..348ac50 100644
--- a/nss_ipv6.c
+++ b/nss_ipv6.c
@@ -141,9 +141,9 @@
 	}
 
 	/*
-	 * Log failures
+	 * Trace messages.
 	 */
-	nss_core_log_msg_failures(nss_ctx, ncm);
+	nss_ipv6_log_rx_msg(nim);
 
 	/*
 	 * Handle deprecated messages.  Eventually these messages should be removed.
@@ -247,6 +247,11 @@
 	nim2 = (struct nss_ipv6_msg *)skb_put(nbuf, sizeof(struct nss_ipv6_msg));
 	memcpy(nim2, nim, sizeof(struct nss_ipv6_msg));
 
+	/*
+	 * Trace messages.
+	 */
+	nss_ipv6_log_tx_msg(nim);
+
 	status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_CMD_QUEUE, H2N_BUFFER_CTRL, 0);
 	if (status != NSS_CORE_STATUS_SUCCESS) {
 		dev_kfree_skb_any(nbuf);
diff --git a/nss_ipv6_log.c b/nss_ipv6_log.c
new file mode 100644
index 0000000..48703d3
--- /dev/null
+++ b/nss_ipv6_log.c
@@ -0,0 +1,384 @@
+/*
+ **************************************************************************
+ * Copyright (c) 2016, 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ **************************************************************************
+ */
+
+/*
+ * nss_ipv6_log.c
+ *	NSS IPv6 logger file.
+ */
+
+#include "nss_core.h"
+
+/*
+ * This macro converts IPv6 address to network format
+ */
+#define NSS_IPV6_ADDR_TO_NW(nss6, nw) \
+	{ \
+		nw[0] = htonl(nss6[0]); \
+		nw[1] = htonl(nss6[1]); \
+		nw[2] = htonl(nss6[2]); \
+		nw[3] = htonl(nss6[3]); \
+	}
+
+/*
+ * nss_ipv6_log_message_types_str
+ *	IPv6 bridge/route rule messages strings
+ */
+static int8_t *nss_ipv6_log_message_types_str[NSS_IPV6_MAX_MSG_TYPES] = {
+	"IPv6 create rule message",
+	"IPv6 destroy rule message",
+	"Deprecated: NSS_IPV4_RX_ESTABLISH_RULE_MSG",
+	"IPv6 connection stats sync message",
+	"IPv6 generic statistics sync message",
+	"IPv6 number of connections supported rule message",
+	"IPv6 multicast create rule message",
+	"IPv6 request FW to send many conn sync message",
+};
+
+/*
+ * nss_ipv6_log_error_response_types_str
+ *	Strings for error types for ipv6 messages
+ */
+static int8_t *nss_ipv6_log_error_response_types_str[] = {
+	"No error",
+	"Unknown error",
+	"Invalid interface number",
+	"Missing connection rule",
+	"Buffer allocation failure",
+	"Unable to create PPPoE session",
+	"No connection found to delete",
+	"Conn cfg already done once",
+	"Conn cfg input is not multiple of quanta",
+	"Conn cfg input exceeds max supported connections",
+	"Conn cfg mem alloc fail at NSS FW",
+	"Invalid L4 protocol for multicast rule create",
+	"Invalid multicast flags for multicast update",
+	"Invalid interface for multicast update",
+};
+
+/*
+ * nss_ipv6_log_rule_create_msg()
+ *	Log IPv6 create rule message.
+ */
+static void nss_ipv6_log_rule_create_msg(struct nss_ipv6_msg *nim)
+{
+	uint32_t src_ip[4];
+	uint32_t dest_ip[4];
+	struct nss_ipv6_rule_create_msg *nircm = &nim->msg.rule_create;
+
+	NSS_IPV6_ADDR_TO_NW(nircm->tuple.flow_ip, src_ip);
+	NSS_IPV6_ADDR_TO_NW(nircm->tuple.return_ip, dest_ip);
+
+	nss_trace("%p: IPv6 create rule message \n"
+		"Protocol: %d\n"
+		"from_mtu: %u\n"
+		"to_mtu: %u\n"
+		"from_ip: %pI6:%d\n"
+		"to_ip: %pI6:%d\n"
+		"from_mac: %pM\n"
+		"to_mac: %pM\n"
+		"src_iface_num: %u\n"
+		"dest_iface_num: %u\n"
+		"ingress_inner_vlan_tag: %u\n"
+		"egress_inner_vlan_tag: %u\n"
+		"ingress_outer_vlan_tag: %u\n"
+		"egress_outer_vlan_tag: %u\n"
+		"rule_flags: %x\n"
+		"valid_flags: %x\n"
+		"return_pppoe_session_id: %u\n"
+		"return_pppoe_remote_mac: %pM\n"
+		"flow_pppoe_session_id: %u\n"
+		"flow_pppoe_remote_mac: %pM\n"
+		"flow_qos_tag: %x (%u)\n"
+		"return_qos_tag: %x (%u)\n"
+		"flow_dscp: %x\n"
+		"return_dscp: %x\n",
+		nim,
+		nircm->tuple.protocol,
+		nircm->conn_rule.flow_mtu,
+		nircm->conn_rule.return_mtu,
+		src_ip, nircm->tuple.flow_ident,
+		dest_ip, nircm->tuple.return_ident,
+		nircm->conn_rule.flow_mac,
+		nircm->conn_rule.return_mac,
+		nircm->conn_rule.flow_interface_num,
+		nircm->conn_rule.return_interface_num,
+		nircm->vlan_primary_rule.ingress_vlan_tag,
+		nircm->vlan_primary_rule.egress_vlan_tag,
+		nircm->vlan_secondary_rule.ingress_vlan_tag,
+		nircm->vlan_secondary_rule.egress_vlan_tag,
+		nircm->rule_flags,
+		nircm->valid_flags,
+		nircm->pppoe_rule.return_pppoe_session_id,
+		nircm->pppoe_rule.return_pppoe_remote_mac,
+		nircm->pppoe_rule.flow_pppoe_session_id,
+		nircm->pppoe_rule.flow_pppoe_remote_mac,
+		nircm->qos_rule.flow_qos_tag, nircm->qos_rule.flow_qos_tag,
+		nircm->qos_rule.return_qos_tag, nircm->qos_rule.return_qos_tag,
+		nircm->dscp_rule.flow_dscp,
+		nircm->dscp_rule.return_dscp);
+}
+
+/*
+ * nss_ipv6_log_destroy_rule_msg()
+ *	Log IPv6 destroy rule message.
+ */
+static void nss_ipv6_log_destroy_rule_msg(struct nss_ipv6_msg *nim)
+{
+	uint32_t src_ip[4];
+	uint32_t dest_ip[4];
+	struct nss_ipv6_rule_destroy_msg *nirdm = &nim->msg.rule_destroy;
+
+	NSS_IPV6_ADDR_TO_NW(nirdm->tuple.flow_ip, src_ip);
+	NSS_IPV6_ADDR_TO_NW(nirdm->tuple.return_ip, dest_ip);
+
+	nss_trace("%p: IPv6 destroy rule message: \n"
+		"flow_ip: %pI6:%d\n"
+		"return_ip: %pI6:%d\n"
+		"protocol: %d\n",
+		nim,
+		src_ip, nirdm->tuple.flow_ident,
+		dest_ip, nirdm->tuple.return_ident,
+		nirdm->tuple.protocol);
+}
+
+/*
+ * nss_ipv6_log_conn_sync()
+ *	Log IPv6 connection stats sync message.
+ */
+static void nss_ipv6_log_conn_sync(struct nss_ipv6_msg *nim)
+{
+	struct nss_ipv6_conn_sync *sync = &nim->msg.conn_stats;
+	if (sync->flow_tx_packet_count || sync->return_tx_packet_count) {
+		uint32_t src_ip[4];
+		uint32_t dest_ip[4];
+
+		NSS_IPV6_ADDR_TO_NW(sync->flow_ip, src_ip);
+		NSS_IPV6_ADDR_TO_NW(sync->return_ip, dest_ip);
+
+		nss_trace("%p: IPv6 connection stats sync message: \n"
+			"Protocol: %d\n"
+			"src_addr: %pI6:%d\n"
+			"dest_addr: %pI6:%d\n"
+			"flow_rx_packet_count: %u\n"
+			"flow_rx_byte_count: %u\n"
+			"return_rx_packet_count: %u\n"
+			"return_rx_byte_count: %u\n"
+			"flow_tx_packet_count: %u\n"
+			"flow_tx_byte_count: %u\n"
+			"return_tx_packet_count: %u\n"
+			"return_tx_byte_count: %u\n",
+			nim,
+			(int)sync->protocol,
+			src_ip, (int)sync->flow_ident,
+			dest_ip, (int)sync->return_ident,
+			sync->flow_rx_packet_count,
+			sync->flow_rx_byte_count,
+			sync->return_rx_packet_count,
+			sync->return_rx_byte_count,
+			sync->flow_tx_packet_count,
+			sync->flow_tx_byte_count,
+			sync->return_tx_packet_count,
+			sync->return_tx_byte_count);
+		}
+}
+
+/*
+ * nss_ipv6_log_conn_cfg_msg()
+ *	Log IPv6 number of connections supported rule message.
+ */
+static void nss_ipv6_log_conn_cfg_msg(struct nss_ipv6_msg *nim)
+{
+	struct nss_ipv6_rule_conn_cfg_msg *nirccm = &nim->msg.rule_conn_cfg;
+	nss_trace("%p: IPv6 number of connections supported rule message: \n"
+		"num_conn: %d\n",
+		nim,
+		nirccm->num_conn);
+}
+
+/*
+ * nss_ipv6_log_mc_rule_create_msg()
+ *	Log IPv6 multicast create rule message.
+ */
+static void nss_ipv6_log_mc_rule_create_msg(struct nss_ipv6_msg *nim)
+{
+	uint16_t vif;
+	uint32_t src_ip[4];
+	uint32_t dest_ip[4];
+	struct nss_ipv6_mc_rule_create_msg *nimrcm = &nim->msg.mc_rule_create;
+
+	NSS_IPV6_ADDR_TO_NW(nimrcm->tuple.flow_ip, src_ip);
+	NSS_IPV6_ADDR_TO_NW(nimrcm->tuple.return_ip, dest_ip);
+
+	for (vif = 0; vif < nimrcm->if_count ; vif++) {
+		nss_trace("%p: IPv6 multicast create rule message \n"
+			"Rule flag: %x\n"
+			"Vif: %d\n"
+			"Protocol: %d\n"
+			"to_mtu: %u\n"
+			"from_ip: %pI6:%d\n"
+			"to_ip: %pI6:%d\n"
+			"to_mac: %pM\n"
+			"dest_iface_num: %u\n"
+			"out_vlan[0] %x\n"
+			"out_vlan[1] %x\n",
+			nim,
+			nimrcm->if_rule[vif].rule_flags,
+			vif,
+			nimrcm->tuple.protocol,
+			nimrcm->if_rule[vif].if_mtu,
+			src_ip, nimrcm->tuple.flow_ident,
+			dest_ip, nimrcm->tuple.return_ident,
+			nimrcm->if_rule[vif].if_mac,
+			nimrcm->if_rule[vif].if_num,
+			nimrcm->if_rule[vif].egress_vlan_tag[0],
+			nimrcm->if_rule[vif].egress_vlan_tag[1]);
+	}
+}
+
+/*
+ * nss_ipv6_log_conn_sync_many_msg()
+ *	Log IPv6 many conn sync message.
+ */
+static void nss_ipv6_log_conn_sync_many_msg(struct nss_ipv6_msg *nim)
+{
+	uint16_t i;
+	struct nss_ipv6_conn_sync_many_msg *nicsm = &nim->msg.conn_stats_many;
+	for (i = 0; i < nicsm->count; i++) {
+		struct nss_ipv6_conn_sync *sync = &nicsm->conn_sync[i];
+		if (sync->flow_tx_packet_count || sync->return_tx_packet_count) {
+			uint32_t src_ip[4];
+			uint32_t dest_ip[4];
+
+			NSS_IPV6_ADDR_TO_NW(sync->flow_ip, src_ip);
+			NSS_IPV6_ADDR_TO_NW(sync->return_ip, dest_ip);
+
+			nss_trace("%p: IPv6 many conn sync message \n"
+				"count: %d\n"
+				"i: %d\n"
+				"Protocol: %d\n"
+				"src_addr: %pI6:%d\n"
+				"dest_addr: %pI6:%d\n"
+				"flow_rx_packet_count: %u\n"
+				"flow_rx_byte_count: %u\n"
+				"return_rx_packet_count: %u\n"
+				"return_rx_byte_count: %u\n"
+				"flow_tx_packet_count: %u\n"
+				"flow_tx_byte_count: %u\n"
+				"return_tx_packet_count: %u\n"
+				"return_tx_byte_count: %u\n",
+				nim,
+				nicsm->count,
+				i,
+				(int)sync->protocol,
+				src_ip, (int)sync->flow_ident,
+				dest_ip, (int)sync->return_ident,
+				sync->flow_rx_packet_count,
+				sync->flow_rx_byte_count,
+				sync->return_rx_packet_count,
+				sync->return_rx_byte_count,
+				sync->flow_tx_packet_count,
+				sync->flow_tx_byte_count,
+				sync->return_tx_packet_count,
+				sync->return_tx_byte_count);
+		}
+	}
+}
+
+/*
+ * nss_ipv6_log_verbose()
+ *	Log message contents.
+ */
+static void nss_ipv6_log_verbose(struct nss_ipv6_msg *nim)
+{
+	switch (nim->cm.type) {
+	case NSS_IPV6_TX_CREATE_RULE_MSG:
+		nss_ipv6_log_rule_create_msg(nim);
+		break;
+
+	case NSS_IPV6_TX_DESTROY_RULE_MSG:
+		nss_ipv6_log_destroy_rule_msg(nim);
+		break;
+
+	case NSS_IPV6_RX_CONN_STATS_SYNC_MSG:
+		nss_ipv6_log_conn_sync(nim);
+		break;
+
+	case NSS_IPV6_RX_NODE_STATS_SYNC_MSG:
+		/* Getting logged in stats */
+		break;
+
+	case NSS_IPV6_TX_CONN_CFG_RULE_MSG:
+		nss_ipv6_log_conn_cfg_msg(nim);
+		break;
+
+	case NSS_IPV6_TX_CREATE_MC_RULE_MSG:
+		nss_ipv6_log_mc_rule_create_msg(nim);
+		break;
+
+	case NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG:
+		nss_ipv6_log_conn_sync_many_msg(nim);
+		break;
+
+	default:
+		nss_trace("%p: Invalid message type\n", nim);
+		break;
+	}
+}
+
+/*
+ * nss_ipv6_log_tx_msg()
+ *	Log messages transmitted to FW.
+ */
+void nss_ipv6_log_tx_msg(struct nss_ipv6_msg *nim)
+{
+	nss_info("%p: type[%d]: %s\n", nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type]);
+	nss_ipv6_log_verbose(nim);
+}
+
+/*
+ * nss_ipv6_log_rx_msg()
+ *	Log messages received from FW.
+ */
+void nss_ipv6_log_rx_msg(struct nss_ipv6_msg *nim)
+{
+	if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) {
+		nss_info("%p: Invalid response\n", nim);
+		return;
+	}
+
+	if (nim->cm.response == NSS_CMM_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) {
+		nss_info("%p: type[%d]: %s, response[%d]: %s\n", nim, nim->cm.type,
+			nss_ipv6_log_message_types_str[nim->cm.type],
+			nim->cm.response, nss_cmn_response_str[nim->cm.response]);
+		goto verbose;
+	}
+
+	if (nim->cm.error > NSS_IPV6_CR_MULTICAST_UPDATE_INVALID_IF) {
+		nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n",
+			nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type],
+			nim->cm.response, nss_cmn_response_str[nim->cm.response],
+			nim->cm.error);
+		goto verbose;
+	}
+
+	nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n",
+		nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type],
+		nim->cm.response, nss_cmn_response_str[nim->cm.response],
+		nim->cm.error, nss_ipv6_log_error_response_types_str[nim->cm.error]);
+
+verbose:
+	nss_ipv6_log_verbose(nim);
+}