[qca-nss-drv] PPPoE Logging
Change-Id: I31763a227d57ad93c0f5d2ac9227d661d70e6248
Signed-off-by: Sachin Shashidhar <sshashid@codeaurora.org>
diff --git a/Makefile b/Makefile
index 9c0b291..3d66014 100644
--- a/Makefile
+++ b/Makefile
@@ -78,6 +78,7 @@
nss_ppe.o \
nss_ppe_stats.o \
nss_pppoe.o \
+ nss_pppoe_log.o \
nss_pppoe_stats.o \
nss_pptp.o \
nss_pptp_stats.o \
diff --git a/Makefile.fsm b/Makefile.fsm
index acf426b..cfcf592 100644
--- a/Makefile.fsm
+++ b/Makefile.fsm
@@ -68,6 +68,7 @@
nss_ppe.o \
nss_ppe_stats.o \
nss_pppoe.o \
+ nss_pppoe_log.o \
nss_pppoe_stats.o \
nss_pptp.o \
nss_pptp_stats.o \
diff --git a/nss_pppoe.c b/nss_pppoe.c
index 4f142e9..5a0c4b3 100644
--- a/nss_pppoe.c
+++ b/nss_pppoe.c
@@ -21,6 +21,7 @@
#include "nss_tx_rx_common.h"
#include "nss_pppoe_stats.h"
+#include "nss_pppoe_log.h"
#define NSS_PPPOE_TX_TIMEOUT 3000 /* 3 Seconds */
@@ -81,6 +82,11 @@
struct nss_cmn_msg *ncm = &msg->cm;
/*
+ * Trace Messages
+ */
+ nss_pppoe_log_tx_msg(msg);
+
+ /*
* Sanity check the message
*/
if (!nss_is_dynamic_interface(ncm->interface)) {
@@ -139,6 +145,11 @@
BUG_ON(!(nss_is_dynamic_interface(ncm->interface) || ncm->interface == NSS_PPPOE_INTERFACE));
/*
+ * Trace Messages
+ */
+ nss_pppoe_log_rx_msg(nim);
+
+ /*
* Sanity check the message type
*/
if (ncm->type >= NSS_PPPOE_MSG_MAX) {
diff --git a/nss_pppoe_log.c b/nss_pppoe_log.c
new file mode 100644
index 0000000..927c3e3
--- /dev/null
+++ b/nss_pppoe_log.c
@@ -0,0 +1,133 @@
+/*
+ **************************************************************************
+ * 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_pppoe_log.c
+ * NSS PPPOE logger file.
+ */
+
+#include "nss_core.h"
+
+/*
+ * nss_pppoe_log_message_types_str
+ * NSS PPPOE message strings
+ */
+static int8_t *nss_pppoe_log_message_types_str[NSS_PPPOE_MSG_MAX] __maybe_unused = {
+ "PPPOE Session Create",
+ "PPPOE Session Destroy",
+ "PPPOE Stats",
+};
+
+/*
+ * nss_pppoe_log_session_create_msg()
+ * Log NSS Session Create.
+ */
+static void nss_pppoe_log_session_create_msg(struct nss_pppoe_msg *npm)
+{
+ struct nss_pppoe_create_msg *npcm __maybe_unused = &npm->msg.create;
+ nss_trace("%p: NSS PPPOE Session Create message \n"
+ "PPPOE Physical Interface Number: %d\n"
+ "PPPOE MTU: %d\n"
+ "PPPOE Server MAC: %pM\n"
+ "PPPOE Local MAC: %pM\n"
+ "PPPOE Session ID: %d\n",
+ npcm, npcm->phy_if_num,
+ npcm->mtu, npcm->server_mac,
+ npcm->local_mac, npcm->session_id);
+}
+
+/*
+ * nss_pppoe_log_session_destroy_msg()
+ * Log NSS Session Destroy.
+ */
+static void nss_pppoe_log_session_destroy_msg(struct nss_pppoe_msg *npm)
+{
+ struct nss_pppoe_destroy_msg *npdm __maybe_unused = &npm->msg.destroy;
+ nss_trace("%p: NSS PPPOE Session Destroy message \n"
+ "PPPOE Session ID: %d\n"
+ "PPPOE Server MAC: %pM\n"
+ "PPPOE Local MAC: %pM\n",
+ npdm, npdm->session_id,
+ npdm->server_mac, npdm->local_mac);
+}
+
+/*
+ * nss_pppoe_log_verbose()
+ * Log message contents.
+ */
+static void nss_pppoe_log_verbose(struct nss_pppoe_msg *npm)
+{
+ switch (npm->cm.type) {
+ case NSS_PPPOE_MSG_SESSION_CREATE:
+ nss_pppoe_log_session_create_msg(npm);
+ break;
+
+ case NSS_PPPOE_MSG_SESSION_DESTROY:
+ nss_pppoe_log_session_destroy_msg(npm);
+ break;
+
+ case NSS_PPPOE_MSG_SYNC_STATS:
+ /*
+ * No log for valid stats message.
+ */
+ break;
+
+ default:
+ nss_trace("%p: Invalid message type\n", npm);
+ break;
+ }
+}
+
+/*
+ * nss_pppoe_log_tx_msg()
+ * Log messages transmitted to FW.
+ */
+void nss_pppoe_log_tx_msg(struct nss_pppoe_msg *npm)
+{
+ if (npm->cm.type >= NSS_PPPOE_MSG_MAX) {
+ nss_warning("%p: Invalid message type\n", npm);
+ return;
+ }
+
+ nss_info("%p: type[%d]:%s\n", npm, npm->cm.type, nss_pppoe_log_message_types_str[npm->cm.type]);
+ nss_pppoe_log_verbose(npm);
+}
+
+/*
+ * nss_pppoe_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_pppoe_log_rx_msg(struct nss_pppoe_msg *npm)
+{
+ if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) {
+ nss_warning("%p: Invalid response\n", npm);
+ return;
+ }
+
+ if (npm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npm->cm.response == NSS_CMN_RESPONSE_ACK)) {
+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type,
+ nss_pppoe_log_message_types_str[npm->cm.type],
+ npm->cm.response, nss_cmn_response_str[npm->cm.response]);
+ goto verbose;
+ }
+
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n",
+ npm, npm->cm.type, nss_pppoe_log_message_types_str[npm->cm.type],
+ npm->cm.response, nss_cmn_response_str[npm->cm.response]);
+
+verbose:
+ nss_pppoe_log_verbose(npm);
+}
diff --git a/nss_pppoe_log.h b/nss_pppoe_log.h
new file mode 100644
index 0000000..4636b08
--- /dev/null
+++ b/nss_pppoe_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_PPPOE_LOG_H
+#define __NSS_PPPOE_LOG_H
+
+/*
+ * nss_pppoe.h
+ * NSS PPPOE header file.
+ */
+
+/*
+ * Logger APIs
+ */
+
+/*
+ * nss_pppoe_log_tx_msg
+ * Logs a pppoe message that is sent to the NSS firmware.
+ */
+void nss_pppoe_log_tx_msg(struct nss_pppoe_msg *nim);
+
+/*
+ * nss_pppoe_log_rx_msg
+ * Logs a pppoe message that is received from the NSS firmware.
+ */
+void nss_pppoe_log_rx_msg(struct nss_pppoe_msg *nim);
+
+#endif /* __NSS_PPPOE_LOG_H */