Merge "[qca-nss-drv] Frequency logging."
diff --git a/Makefile b/Makefile
index 292d55b..12505a1 100644
--- a/Makefile
+++ b/Makefile
@@ -157,7 +157,9 @@
ifeq "$(NSS_FREQ_SCALE_DISABLE)" "y"
ccflags-y += -DNSS_FREQ_SCALE_SUPPORT=0
else
-qca-nss-drv-objs += nss_freq.o
+qca-nss-drv-objs += \
+ nss_freq.o \
+ nss_freq_log.o
ccflags-y += -DNSS_FREQ_SCALE_SUPPORT=1
endif
diff --git a/nss_freq.c b/nss_freq.c
index 0bfbf7c..e6c594d 100644
--- a/nss_freq.c
+++ b/nss_freq.c
@@ -20,6 +20,7 @@
*/
#include "nss_tx_rx_common.h"
+#include "nss_freq_log.h"
#define NSS_ACK_STARTED 0
#define NSS_ACK_FINISHED 1
@@ -212,6 +213,11 @@
struct nss_corefreq_msg *ncfm = (struct nss_corefreq_msg *)ncm;
+ /*
+ * Trace Messages
+ */
+ nss_freq_log_rx_msg(ncfm);
+
switch (ncfm->cm.type) {
case COREFREQ_METADATA_TYPE_TX_FREQ_ACK:
nss_freq_handle_ack(nss_ctx, &ncfm->msg.nfc);
diff --git a/nss_freq_log.c b/nss_freq_log.c
new file mode 100644
index 0000000..89f7f04
--- /dev/null
+++ b/nss_freq_log.c
@@ -0,0 +1,100 @@
+/*
+ **************************************************************************
+ * 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_freq_log.c
+ * NSS Freq logger file.
+ */
+
+#include "nss_core.h"
+
+/*
+ * nss_freq_log_message_types_str
+ * Freq message strings
+ */
+static int8_t *nss_freq_log_message_types_str[COREFREQ_METADATA_TYPE_MAX] __maybe_unused = {
+ "Freq Error Message",
+ "Freq Change",
+ "Freq ACK",
+ "TX Core Stats",
+};
+
+/*
+ * nss_freq_log_msg()
+ * Log NSS Freq message.
+ */
+static void nss_freq_log_msg(struct nss_corefreq_msg *ncm)
+{
+ struct nss_freq_msg *nfm __maybe_unused = &ncm->msg.nfc;
+ nss_trace("%p: NSS Freq Message:\n"
+ "Frequency request: %d\n"
+ "Frequency start/end: %d\n"
+ "Frequency stats enable: %d\n"
+ "Current Frequency: %d\n"
+ "Frequency ACK: %d\n",
+ nfm, nfm->frequency, nfm->start_or_end,
+ nfm->stats_enable, nfm->freq_current,
+ nfm->ack);
+}
+
+/*
+ * nss_freq_log_verbose()
+ * Log message contents.
+ */
+static void nss_freq_log_verbose(struct nss_corefreq_msg *ncm)
+{
+ switch (ncm->cm.type) {
+ case COREFREQ_METADATA_TYPE_RX_FREQ_CHANGE:
+ case COREFREQ_METADATA_TYPE_TX_FREQ_ACK:
+ nss_freq_log_msg(ncm);
+ break;
+
+ case COREFREQ_METADATA_TYPE_TX_CORE_STATS:
+ /*
+ * No log for a valid stats message.
+ */
+ break;
+
+ default:
+ nss_warning("%p: Invalid message type\n", ncm);
+ break;
+ }
+}
+
+/*
+ * nss_freq_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_freq_log_rx_msg(struct nss_corefreq_msg *ncm)
+{
+ if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) {
+ nss_warning("%p: Invalid response\n", ncm);
+ return;
+ }
+
+ if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) {
+ nss_info("%p: type[%d], response[%d]:%s\n", ncm, ncm->cm.type,
+ ncm->cm.response, nss_cmn_response_str[ncm->cm.response]);
+ goto verbose;
+ }
+
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n",
+ ncm, ncm->cm.type, nss_freq_log_message_types_str[ncm->cm.type],
+ ncm->cm.response, nss_cmn_response_str[ncm->cm.response]);
+
+verbose:
+ nss_freq_log_verbose(ncm);
+}
diff --git a/nss_freq_log.h b/nss_freq_log.h
new file mode 100644
index 0000000..ab7d7d4
--- /dev/null
+++ b/nss_freq_log.h
@@ -0,0 +1,35 @@
+/*
+ **************************************************************************
+ * 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_FREQ_LOG_H
+#define __NSS_FREQ_LOG_H
+
+/*
+ * nss_freq_log.h
+ * NSS frequency log header file.
+ */
+
+/*
+ * Logger APIs
+ */
+
+/*
+ * nss_freq_log_rx_msg
+ * Logs a frequency message that is received from the NSS firmware.
+ */
+void nss_freq_log_rx_msg(struct nss_corefreq_msg *nbm);
+
+#endif /* __NSS_FREQ_LOG_H */
diff --git a/nss_hlos_if.h b/nss_hlos_if.h
index 6c64160..19b367d 100644
--- a/nss_hlos_if.h
+++ b/nss_hlos_if.h
@@ -137,10 +137,11 @@
* NSS frequency scaling messages
*/
enum nss_freq_stats_metadata_types {
- COREFREQ_METADATA_TYPE_ERROR = 0,
- COREFREQ_METADATA_TYPE_RX_FREQ_CHANGE = 1,
- COREFREQ_METADATA_TYPE_TX_FREQ_ACK = 2,
- COREFREQ_METADATA_TYPE_TX_CORE_STATS = 3,
+ COREFREQ_METADATA_TYPE_ERROR,
+ COREFREQ_METADATA_TYPE_RX_FREQ_CHANGE,
+ COREFREQ_METADATA_TYPE_TX_FREQ_ACK,
+ COREFREQ_METADATA_TYPE_TX_CORE_STATS,
+ COREFREQ_METADATA_TYPE_MAX,
};
/*