[qca-nss-drv] Trustsec TX log.
Change-Id: I670fca0d23bac51a71868764aea2537c29272f9c
Signed-off-by: Sachin Shashidhar <sshashid@codeaurora.org>
diff --git a/Makefile b/Makefile
index 53718a1..fc9b52f 100644
--- a/Makefile
+++ b/Makefile
@@ -83,6 +83,7 @@
nss_tstamp.o \
nss_tun6rd.o \
nss_trustsec_tx.o \
+ nss_trustsec_tx_log.o \
nss_trustsec_tx_stats.o \
nss_tunipip6.o \
nss_virt_if.o \
diff --git a/Makefile.fsm b/Makefile.fsm
index 04cc2a5..e3e19e8 100644
--- a/Makefile.fsm
+++ b/Makefile.fsm
@@ -73,6 +73,7 @@
nss_tstamp.o \
nss_tun6rd.o \
nss_trustsec_tx.o \
+ nss_trustsec_tx_log.o \
nss_trustsec_tx_stats.o \
nss_tunipip6.o \
nss_virt_if.o \
diff --git a/nss_trustsec_tx.c b/nss_trustsec_tx.c
index 842fd53..b84da30 100644
--- a/nss_trustsec_tx.c
+++ b/nss_trustsec_tx.c
@@ -16,6 +16,7 @@
#include "nss_tx_rx_common.h"
#include "nss_trustsec_tx_stats.h"
+#include "nss_trustsec_tx_log.h"
#define NSS_TRUSTSEC_TX_TIMEOUT 3000 /* 3 Seconds */
@@ -41,6 +42,11 @@
BUG_ON(ncm->interface != NSS_TRUSTSEC_TX_INTERFACE);
/*
+ * Trace messages.
+ */
+ nss_trustsec_tx_log_rx_msg(npm);
+
+ /*
* Is this a valid request/response packet?
*/
if (ncm->type >= NSS_TRUSTSEC_TX_MAX_MSG_TYPE) {
@@ -100,6 +106,11 @@
struct nss_cmn_msg *ncm = &msg->cm;
/*
+ * Trace messages.
+ */
+ nss_trustsec_tx_log_tx_msg(msg);
+
+ /*
* Sanity check the message
*/
if (ncm->interface != NSS_TRUSTSEC_TX_INTERFACE) {
diff --git a/nss_trustsec_tx_log.c b/nss_trustsec_tx_log.c
new file mode 100644
index 0000000..d795f71
--- /dev/null
+++ b/nss_trustsec_tx_log.c
@@ -0,0 +1,149 @@
+/*
+ **************************************************************************
+ * 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_trustsec_tx_log.c
+ * NSS TRUSTSEC_TX logger file.
+ */
+
+#include "nss_core.h"
+
+/*
+ * nss_trustsec_tx_log_message_types_str
+ * TRUSTSEC_TX message strings
+ */
+static int8_t *nss_trustsec_tx_log_message_types_str[NSS_TRUSTSEC_TX_MAX_MSG_TYPE] __maybe_unused = {
+ "TRUSTSEC_TX Configure Message",
+ "TRUSTSEC_TX Unconfigure Message",
+ "TRUSTSEC_TX Stats Sync",
+};
+
+/*
+ * nss_trustsec_tx_log_error_response_types_str
+ * Strings for error types for TRUSTSEC_TX messages
+ */
+static int8_t *nss_trustsec_tx_log_error_response_types_str[NSS_TRUSTSEC_TX_ERR_UNKNOWN] __maybe_unused = {
+ "TRUSTSEC_TX Invalid Source Interface",
+ "TRUSTSEC_TX Reconfigure Source Interface"
+ "TRUSTSEC_TX Destination Interface Not Found",
+ "TRUSTSEC_TX Not Configured",
+ "TRUSTSEC_TX Unknown Error",
+};
+
+/*
+ * nss_trustsec_tx_log_configure_msg()
+ * Log NSS TRUSTSEC_TX configure message.
+ */
+static void nss_trustsec_tx_log_configure_msg(struct nss_trustsec_tx_msg *ntm)
+{
+ struct nss_trustsec_tx_configure_msg *ntcm __maybe_unused = &ntm->msg.configure;
+ nss_trace("%p: NSS TRUSTSEC_TX Configure Message:\n"
+ "TRUSTSEC_TX Source: %d\n"
+ "TRUSTSEC_TX Destination: %d\n"
+ "TRUSTSEC_TX Security Group Tag: %d\n",
+ ntcm, ntcm->src,
+ ntcm->dest, ntcm->sgt);
+}
+
+/*
+ * nss_trustsec_tx_log_unconfigure_msg()
+ * Log NSS TRUSTSEC_TX unconfigure message.
+ */
+static void nss_trustsec_tx_log_unconfigure_msg(struct nss_trustsec_tx_msg *ntm)
+{
+ struct nss_trustsec_tx_unconfigure_msg *ntcm __maybe_unused = &ntm->msg.unconfigure;
+ nss_trace("%p: NSS TRUSTSEC_TX Unconfigure Message:\n"
+ "TRUSTSEC_TX Source: %d\n"
+ "TRUSTSEC_TX Security Group Tag: %d\n",
+ ntcm, ntcm->src, ntcm->sgt);
+}
+
+/*
+ * nss_trustsec_tx_log_verbose()
+ * Log message contents.
+ */
+static void nss_trustsec_tx_log_verbose(struct nss_trustsec_tx_msg *ntm)
+{
+ switch (ntm->cm.type) {
+ case NSS_TRUSTSEC_TX_CONFIGURE_MSG:
+ nss_trustsec_tx_log_configure_msg(ntm);
+ break;
+
+ case NSS_TRUSTSEC_TX_UNCONFIGURE_MSG:
+ nss_trustsec_tx_log_unconfigure_msg(ntm);
+ break;
+
+ case NSS_TRUSTSEC_TX_STATS_SYNC_MSG:
+ /*
+ * No log for valid stats message.
+ */
+ break;
+
+ default:
+ nss_warning("%p: Invalid message type\n", ntm);
+ break;
+ }
+}
+
+/*
+ * nss_trustsec_tx_log_tx_msg()
+ * Log messages transmitted to FW.
+ */
+void nss_trustsec_tx_log_tx_msg(struct nss_trustsec_tx_msg *ntm)
+{
+ if (ntm->cm.type >= NSS_TRUSTSEC_TX_MAX_MSG_TYPE) {
+ nss_warning("%p: Invalid message type\n", ntm);
+ return;
+ }
+
+ nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type]);
+ nss_trustsec_tx_log_verbose(ntm);
+}
+
+/*
+ * nss_trustsec_tx_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_trustsec_tx_log_rx_msg(struct nss_trustsec_tx_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_trustsec_tx_log_message_types_str[ntm->cm.type],
+ ntm->cm.response, nss_cmn_response_str[ntm->cm.response]);
+ goto verbose;
+ }
+
+ if (ntm->cm.error >= NSS_TRUSTSEC_TX_ERR_UNKNOWN) {
+ nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n",
+ ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type],
+ ntm->cm.response, nss_cmn_response_str[ntm->cm.response],
+ ntm->cm.error);
+ goto verbose;
+ }
+
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n",
+ ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type],
+ ntm->cm.response, nss_cmn_response_str[ntm->cm.response],
+ ntm->cm.error, nss_trustsec_tx_log_error_response_types_str[ntm->cm.error]);
+
+verbose:
+ nss_trustsec_tx_log_verbose(ntm);
+}
diff --git a/nss_trustsec_tx_log.h b/nss_trustsec_tx_log.h
new file mode 100644
index 0000000..58633c9
--- /dev/null
+++ b/nss_trustsec_tx_log.h
@@ -0,0 +1,37 @@
+/*
+ ******************************************************************************
+ * 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_TRUSTSEC_TX_LOG_H__
+#define __NSS_TRUSTSEC_TX_LOG_H__
+
+/*
+ * nss_trustsec_tx_log.h
+ * NSS TRUSTSEC_TX Log Header File
+ */
+
+/*
+ * nss_trustsec_tx_log_tx_msg
+ * Logs a trustsec_tx message that is sent to the NSS firmware.
+ */
+void nss_trustsec_tx_log_tx_msg(struct nss_trustsec_tx_msg *ncm);
+
+/*
+ * nss_trustsec_tx_log_rx_msg
+ * Logs a trustsec_tx message that is received from the NSS firmware.
+ */
+void nss_trustsec_tx_log_rx_msg(struct nss_trustsec_tx_msg *ncm);
+
+#endif /* __NSS_TRUSTSEC_TX_LOG_H__ */