[qca-nss-drv] TUN6RD Log.
Change-Id: I85d9ad481c34bf686580abdef161d3af0f45c2cb
Signed-off-by: Sachin Shashidhar <sshashid@codeaurora.org>
diff --git a/Makefile b/Makefile
index 9c0b291..0e0cc47 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@
nss_stats.o \
nss_tstamp.o \
nss_tun6rd.o \
+ nss_tun6rd_log.o \
nss_trustsec_tx.o \
nss_trustsec_tx_log.o \
nss_trustsec_tx_stats.o \
diff --git a/Makefile.fsm b/Makefile.fsm
index acf426b..cf6ed75 100644
--- a/Makefile.fsm
+++ b/Makefile.fsm
@@ -78,6 +78,7 @@
nss_stats.o \
nss_tstamp.o \
nss_tun6rd.o \
+ nss_tun6rd_log.o \
nss_trustsec_tx.o \
nss_trustsec_tx_log.o \
nss_trustsec_tx_stats.o \
diff --git a/nss_tun6rd.c b/nss_tun6rd.c
index 1900034..1ca82e3 100644
--- a/nss_tun6rd.c
+++ b/nss_tun6rd.c
@@ -15,6 +15,7 @@
*/
#include "nss_tx_rx_common.h"
+#include "nss_tun6rd_log.h"
/*
* nss_tun6rd_handler()
@@ -30,6 +31,11 @@
BUG_ON(!nss_is_dynamic_interface(ncm->interface));
/*
+ * Trace Messages
+ */
+ nss_tun6rd_log_rx_msg(ntm);
+
+ /*
* Is this a valid request/response packet?
*/
if (ncm->type >= NSS_TUN6RD_MAX) {
@@ -88,6 +94,11 @@
struct nss_cmn_msg *ncm = &msg->cm;
/*
+ * Trace Messages
+ */
+ nss_tun6rd_log_tx_msg(msg);
+
+ /*
* Sanity check the message
*/
if (!nss_is_dynamic_interface(ncm->interface)) {
diff --git a/nss_tun6rd_log.c b/nss_tun6rd_log.c
new file mode 100644
index 0000000..ade241a
--- /dev/null
+++ b/nss_tun6rd_log.c
@@ -0,0 +1,138 @@
+/*
+ **************************************************************************
+ * Copyright (c) 2018, 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_tun6rd_log.c
+ * NSS TUN6RD logger file.
+ */
+
+#include "nss_core.h"
+
+/*
+ * nss_tun6rd_log_message_types_str
+ * NSS TUN6RD message strings
+ */
+static int8_t *nss_tun6rd_log_message_types_str[NSS_TUN6RD_MAX] __maybe_unused = {
+ "TUN6RD Attach PNODE",
+ "TUN6RD Stats",
+ "TUN6RD Update Peer",
+};
+
+/*
+ * nss_tun6rd_log_attach_pnode_msg()
+ * Log NSS TUN6RD Attach PNODE
+ */
+static void nss_tun6rd_log_attach_pnode_msg(struct nss_tun6rd_msg *ntm)
+{
+ struct nss_tun6rd_attach_tunnel_msg *ntam __maybe_unused = &ntm->msg.tunnel;
+ nss_trace("%p: NSS TUN6RD Attach Tunnel message \n"
+ "TUN6RD Prefix: %pI6\n"
+ "TUN6RD Relay Prefix: %d\n"
+ "TUN6RD Prefix Length: %d\n"
+ "TUN6RD Relay Prefix Length: %d\n"
+ "TUN6RD Source Address: %pI4\n"
+ "TUN6RD Destination Address: %pI4\n"
+ "TUN6RD Type of Service: %d\n"
+ "TUN6RD Time To Live: %d\n"
+ "TUN6RD Sibling Interface Number: %d\n",
+ ntam, ntam->prefix,
+ ntam->relay_prefix, ntam->prefixlen,
+ ntam->relay_prefixlen, &ntam->saddr,
+ &ntam->daddr, ntam->tos,
+ ntam->ttl, ntam->sibling_if_num);
+}
+
+/*
+ * nss_tun6rd_log_set_peer_msg()
+ * Log NSS TUN6RD Set Peer Message
+ */
+static void nss_tun6rd_log_set_peer_msg(struct nss_tun6rd_msg *ntm)
+{
+ struct nss_tun6rd_set_peer_msg *ntspm __maybe_unused = &ntm->msg.peer;
+ nss_trace("%p: NSS TUN6RD Set Peer message \n"
+ "TUN6RD IPv6 Address: %pI6\n"
+ "TUN6RD Destination: %pI4\n",
+ ntspm, ntspm->ipv6_address,
+ &ntspm->dest);
+}
+
+/*
+ * nss_tun6rd_log_verbose()
+ * Log message contents.
+ */
+static void nss_tun6rd_log_verbose(struct nss_tun6rd_msg *ntm)
+{
+ switch (ntm->cm.type) {
+ case NSS_TUN6RD_ATTACH_PNODE:
+ nss_tun6rd_log_attach_pnode_msg(ntm);
+ break;
+
+ case NSS_TUN6RD_ADD_UPDATE_PEER:
+ nss_tun6rd_log_set_peer_msg(ntm);
+ break;
+
+ case NSS_TUN6RD_RX_STATS_SYNC:
+ /*
+ * No log for valid stats message.
+ */
+ break;
+
+ default:
+ nss_trace("%p: Invalid message type\n", ntm);
+ break;
+ }
+}
+
+/*
+ * nss_tun6rd_log_tx_msg()
+ * Log messages transmitted to FW.
+ */
+void nss_tun6rd_log_tx_msg(struct nss_tun6rd_msg *ntm)
+{
+ if (ntm->cm.type >= NSS_TUN6RD_MAX) {
+ nss_warning("%p: Invalid message type\n", ntm);
+ return;
+ }
+
+ nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_tun6rd_log_message_types_str[ntm->cm.type]);
+ nss_tun6rd_log_verbose(ntm);
+}
+
+/*
+ * nss_tun6rd_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_tun6rd_log_rx_msg(struct nss_tun6rd_msg *ntm)
+{
+ if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) {
+ nss_warning("%p: Invalid response\n", ntm);
+ return;
+ }
+
+ if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) {
+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type,
+ nss_tun6rd_log_message_types_str[ntm->cm.type],
+ ntm->cm.response, nss_cmn_response_str[ntm->cm.response]);
+ goto verbose;
+ }
+
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n",
+ ntm, ntm->cm.type, nss_tun6rd_log_message_types_str[ntm->cm.type],
+ ntm->cm.response, nss_cmn_response_str[ntm->cm.response]);
+
+verbose:
+ nss_tun6rd_log_verbose(ntm);
+}
diff --git a/nss_tun6rd_log.h b/nss_tun6rd_log.h
new file mode 100644
index 0000000..c7c3b3a
--- /dev/null
+++ b/nss_tun6rd_log.h
@@ -0,0 +1,41 @@
+/*
+ **************************************************************************
+ * Copyright (c) 2018, 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.
+ **************************************************************************
+ */
+
+#ifndef __NSS_TUN6RD_LOG_H
+#define __NSS_TUN6RD_LOG_H
+
+/*
+ * nss_tun6rd.h
+ * NSS TUN6RD header file.
+ */
+
+/*
+ * Logger APIs
+ */
+
+/*
+ * nss_tun6rd_log_tx_msg
+ * Logs a tun6rd message that is sent to the NSS firmware.
+ */
+void nss_tun6rd_log_tx_msg(struct nss_tun6rd_msg *ntm);
+
+/*
+ * nss_tun6rd_log_rx_msg
+ * Logs a tun6rd message that is received from the NSS firmware.
+ */
+void nss_tun6rd_log_rx_msg(struct nss_tun6rd_msg *ntm);
+
+#endif /* __NSS_TUN6RD_LOG_H */