Merge "[qca-nss-drv] SJACK Logging"
diff --git a/Makefile b/Makefile
index fc1a531..2f03ad2 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@
nss_eth_rx.o \
nss_eth_rx_stats.o \
nss_gre.o \
+ nss_gre_log.o \
nss_gre_stats.o \
nss_gre_redir.o \
nss_gre_redir_log.o \
@@ -42,6 +43,7 @@
nss_if.o \
nss_init.o \
nss_ipsec.o \
+ nss_ipsec_log.o \
nss_ipv4.o \
nss_ipv4_stats.o \
nss_ipv4_log.o \
@@ -78,11 +80,13 @@
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 \
nss_rps.o \
nss_qrfs.o \
+ nss_qrfs_log.o \
nss_qrfs_stats.o \
nss_shaper.o \
nss_sjack.o \
diff --git a/Makefile.fsm b/Makefile.fsm
index 8a209e1..abdc1a9 100644
--- a/Makefile.fsm
+++ b/Makefile.fsm
@@ -25,6 +25,7 @@
nss_eth_rx.o \
nss_eth_rx_stats.o \
nss_gre.o \
+ nss_gre_log.o \
nss_gre_stats.o \
nss_gre_redir.o \
nss_gre_redir_log.o \
@@ -34,6 +35,7 @@
nss_if.o \
nss_init.o \
nss_ipsec.o \
+ nss_ipsec_log.o \
nss_ipv4.o \
nss_ipv4_stats.o \
nss_ipv4_log.o \
@@ -68,6 +70,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_gre.c b/nss_gre.c
index fb510e0..7178ed7 100644
--- a/nss_gre.c
+++ b/nss_gre.c
@@ -16,6 +16,7 @@
#include "nss_tx_rx_common.h"
#include "nss_gre_stats.h"
+#include "nss_gre_log.h"
#define NSS_GRE_TX_TIMEOUT 3000 /* 3 Seconds */
@@ -89,6 +90,11 @@
BUG_ON(!(nss_is_dynamic_interface(ncm->interface) || ncm->interface == NSS_GRE_INTERFACE));
/*
+ * Trace Messages
+ */
+ nss_gre_log_rx_msg(ntm);
+
+ /*
* Is this a valid request/response packet?
*/
if (ncm->type >= NSS_GRE_MSG_MAX) {
@@ -217,6 +223,11 @@
return NSS_TX_FAILURE;
}
+ /*
+ * Trace Messages
+ */
+ nss_gre_log_tx_msg(msg);
+
return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE);
}
EXPORT_SYMBOL(nss_gre_tx_msg);
diff --git a/nss_gre_log.c b/nss_gre_log.c
new file mode 100644
index 0000000..b779d93
--- /dev/null
+++ b/nss_gre_log.c
@@ -0,0 +1,187 @@
+/*
+ **************************************************************************
+ * 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_gre_log.c
+ * NSS GRE logger file.
+ */
+
+#include "nss_core.h"
+
+#define NSS_GRE_LOG_MESSAGE_TYPE_INDEX(type) ((type) - NSS_IF_MAX_MSG_TYPES - 1)
+
+/*
+ * nss_gre_log_message_types_str
+ * NSS GRE message strings
+ */
+static int8_t *nss_gre_log_message_types_str[NSS_GRE_MSG_MAX] __maybe_unused = {
+ "GRE Message Configure",
+ "GRE Message Deconfigure",
+ "GRE Session Stats",
+ "GRE Base Stats"
+};
+
+/*
+ * nss_gre_log_config_msg()
+ * Log NSS GRE Config message.
+ */
+static void nss_gre_log_config_msg(struct nss_gre_msg *ngm)
+{
+ struct nss_gre_config_msg *ngcm __maybe_unused = &ngm->msg.cmsg;
+ nss_trace("%p: NSS GRE Config message\n"
+ "GRE flags: %d\n"
+ "GRE ikey: %d\n"
+ "GRE okey: %d\n"
+ "GRE mode: %d\n"
+ "GRE ip type: %d\n"
+ "GRE interface number: %d\n"
+ "GRE Src MAC: %pM\n"
+ "GRE Dst MAC: %pM\n"
+ "GRE ttl: %d\n"
+ "GRE tos: %d\n"
+ "GRE metadata size: %d\n",
+ ngcm, ngcm->flags, ngcm->ikey, ngcm->okey,
+ ngcm->mode, ngcm->ip_type, ngcm->next_node_if_num,
+ ngcm->src_mac, ngcm->dest_mac, ngcm->ttl, ngcm->tos,
+ ngcm->metadata_size);
+ /*
+ * Continuation of the log message. Different identifiers based on IP type.
+ */
+ if (ngcm->ip_type == NSS_GRE_IP_IPV6) {
+ nss_trace("GRE Source IP: %pI6\n"
+ "GRE Dest IP: %pI6\n",
+ ngcm->src_ip, ngcm->dest_ip);
+ } else {
+ nss_trace("GRE Source IP: %pI4\n"
+ "GRE Dest IP: %pI4\n",
+ ngcm->src_ip, ngcm->dest_ip);
+ }
+}
+
+/*
+ * nss_gre_log_deconfig_msg()
+ * Log NSS GRE deconfig message.
+ */
+static void nss_gre_log_deconfig_msg(struct nss_gre_msg *ngm)
+{
+ struct nss_gre_deconfig_msg *ngdm __maybe_unused = &ngm->msg.dmsg;
+ nss_trace("%p: NSS GRE deconfig message\n"
+ "GRE interface number: %d\n",
+ ngdm, ngdm->if_number);
+}
+
+/*
+ * nss_gre_log_linkup_msg()
+ * Log NSS GRE linkup message.
+ */
+static void nss_gre_log_linkup_msg(struct nss_gre_msg *ngm)
+{
+ struct nss_gre_linkup_msg *nglm __maybe_unused = &ngm->msg.linkup;
+ nss_trace("%p: NSS GRE linkup message\n"
+ "GRE interface number: %d\n",
+ nglm, nglm->if_number);
+}
+
+/*
+ * nss_gre_log_linkdown_msg()
+ * Log NSS GRE linkdown message.
+ */
+static void nss_gre_log_linkdown_msg(struct nss_gre_msg *ngm)
+{
+ struct nss_gre_linkdown_msg *ngdm __maybe_unused = &ngm->msg.linkdown;
+ nss_trace("%p: NSS GRE linkdown message\n"
+ "GRE interface number: %d\n",
+ ngdm, ngdm->if_number);
+}
+
+/*
+ * nss_gre_log_verbose()
+ * Log message contents.
+ */
+static void nss_gre_log_verbose(struct nss_gre_msg *ngm)
+{
+ switch (ngm->cm.type) {
+ case NSS_GRE_MSG_ENCAP_CONFIGURE:
+ case NSS_GRE_MSG_DECAP_CONFIGURE:
+ nss_gre_log_config_msg(ngm);
+ break;
+
+ case NSS_GRE_MSG_ENCAP_DECONFIGURE:
+ case NSS_GRE_MSG_DECAP_DECONFIGURE:
+ nss_gre_log_deconfig_msg(ngm);
+ break;
+
+ case NSS_IF_OPEN:
+ nss_gre_log_linkup_msg(ngm);
+ break;
+
+ case NSS_IF_CLOSE:
+ nss_gre_log_linkdown_msg(ngm);
+ break;
+
+ case NSS_GRE_MSG_SESSION_STATS:
+ case NSS_GRE_MSG_BASE_STATS:
+ /*
+ * No log for valid stats messages.
+ */
+ break;
+
+ default:
+ nss_trace("%p: Invalid message type\n", ngm);
+ break;
+ }
+}
+
+/*
+ * nss_gre_log_tx_msg()
+ * Log messages transmitted to FW.
+ */
+void nss_gre_log_tx_msg(struct nss_gre_msg *ngm)
+{
+ if (ngm->cm.type >= NSS_GRE_MSG_MAX) {
+ nss_warning("%p: Invalid message type\n", ngm);
+ return;
+ }
+
+ nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)]);
+ nss_gre_log_verbose(ngm);
+}
+
+/*
+ * nss_gre_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_gre_log_rx_msg(struct nss_gre_msg *ngm)
+{
+ if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) {
+ nss_warning("%p: Invalid response\n", ngm);
+ return;
+ }
+
+ if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) {
+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type,
+ nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)],
+ ngm->cm.response, nss_cmn_response_str[ngm->cm.response]);
+ goto verbose;
+ }
+
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n",
+ ngm, ngm->cm.type, nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)],
+ ngm->cm.response, nss_cmn_response_str[ngm->cm.response]);
+
+verbose:
+ nss_gre_log_verbose(ngm);
+}
diff --git a/nss_gre_log.h b/nss_gre_log.h
new file mode 100644
index 0000000..2a21117
--- /dev/null
+++ b/nss_gre_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_GRE_LOG_H
+#define __NSS_GRE_LOG_H
+
+/*
+ * nss_gre_log.h
+ * NSS GRE header file.
+ */
+
+/*
+ * Logger APIs
+ */
+
+/*
+ * nss_gre_log_tx_msg
+ * Logs a gre message that is sent to the NSS firmware.
+ */
+void nss_gre_log_tx_msg(struct nss_gre_msg *ngm);
+
+/*
+ * nss_gre_log_rx_msg
+ * Logs a gre message that is received from the NSS firmware.
+ */
+void nss_gre_log_rx_msg(struct nss_gre_msg *ngm);
+
+#endif /* __NSS_GRE_LOG_H */
diff --git a/nss_ipsec.c b/nss_ipsec.c
index c71ad95..65b7085 100644
--- a/nss_ipsec.c
+++ b/nss_ipsec.c
@@ -22,6 +22,7 @@
#include "nss_tx_rx_common.h"
#include "nss_ipsec.h"
#include "nss_ppe.h"
+#include "nss_ipsec_log.h"
#if defined(NSS_HAL_IPQ806X_SUPPORT)
#define NSS_IPSEC_ENCAP_INTERFACE_NUM NSS_IPSEC_ENCAP_IF_NUMBER
@@ -117,6 +118,11 @@
uint32_t if_num = ncm->interface;
/*
+ * Trace messages.
+ */
+ nss_ipsec_log_rx_msg(nim);
+
+ /*
* Sanity check the message type
*/
if (ncm->type > NSS_IPSEC_MSG_TYPE_MAX) {
@@ -203,6 +209,11 @@
BUILD_BUG_ON(NSS_NBUF_PAYLOAD_SIZE < sizeof(struct nss_ipsec_msg));
+ /*
+ * Trace messages.
+ */
+ nss_ipsec_log_tx_msg(msg);
+
if ((ncm->interface != NSS_IPSEC_ENCAP_INTERFACE_NUM) && (ncm->interface != NSS_IPSEC_DECAP_INTERFACE_NUM)) {
nss_warning("%p: tx message request for another interface: %d", nss_ctx, ncm->interface);
return NSS_TX_FAILURE;
diff --git a/nss_ipsec_log.c b/nss_ipsec_log.c
new file mode 100644
index 0000000..5835b0b
--- /dev/null
+++ b/nss_ipsec_log.c
@@ -0,0 +1,205 @@
+/*
+ **************************************************************************
+ * 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_ipsec_log.c
+ * NSS IPSEC logger file.
+ */
+
+#include "nss_core.h"
+
+#define NSS_IPSEC_LOG_IPV4 4
+#define NSS_IPSEC_LOG_IPV6 6
+
+/*
+ * nss_ipsec_log_message_types_str
+ * IPSEC message strings
+ */
+static int8_t *nss_ipsec_log_message_types_str[NSS_IPSEC_MSG_TYPE_MAX] __maybe_unused = {
+ "IPSEC Msg None",
+ "IPSEC ADD Rule",
+ "IPSEC DEL Rule",
+ "IPSEC Flush Tunnel",
+ "IPSEC SA Stats",
+ "IPSEC Flow Stats",
+ "IPSEC Node Stats",
+ "IPSEC Configure Node",
+};
+
+/*
+ * nss_ipsec_log_error_response_types_str
+ * Strings for error types for IPSEC messages
+ */
+static int8_t *nss_ipsec_log_error_response_types_str[NSS_IPSEC_ERROR_TYPE_MAX] __maybe_unused = {
+ "IPSEC No Error",
+ "IPSEC Hash Duplicate",
+ "IPSEC Hash Collision",
+ "IPSEC Unhandled Message",
+ "IPSEC Invalid Rule",
+ "IPSEC MAX SA",
+ "IPSEC MAX Flow",
+ "IPSEC Invalid CINDEX",
+ "IPSEC Invalid IP Version",
+};
+
+/*
+ * nss_ipsec_log_rule_msg()
+ * Log NSS IPSEC rule message.
+ */
+static void nss_ipsec_log_rule_msg(struct nss_ipsec_msg *nim)
+{
+ struct nss_ipsec_rule *nir __maybe_unused = &nim->msg.rule;
+
+ nss_trace("%p: NSS IPSEC Rule Message:\n"
+ "IPSEC ESP SPI Index: %dn"
+ "IPSEC TTL Hop Limit: %dn"
+ "IPSEC IP Version: %x\n"
+ "IPSEC Crypto Index: %d\n"
+ "IPSEC Window Size: %d\n"
+ "IPSEC Cipher Block Len: %d\n"
+ "IPSEC Initialization Vector Length: %d\n"
+ "IPSEC NAT-T Required: %d\n"
+ "IPSEC ICV Length: %d\n"
+ "IPSEC Skip Seq Number: %d\n"
+ "IPSEC Skip ESP Trailer: %d\n"
+ "IPSEC Use Pattern: %d\n"
+ "IPSEC Enable Extended Sequence Number: %d\n"
+ "IPSEC DSCP Value: %d\n"
+ "IPSEC Don't Fragment Flag: %d\n"
+ "IPSEC DSCP Copy %d\n"
+ "IPSEC DF Copy: %d\n"
+ "IPSEC NSS Index: %d\n"
+ "IPSEC SA Index: %d\n",
+ nir, nir->oip.esp_spi,
+ nir->oip.ttl_hop_limit, nir->oip.ip_ver,
+ nir->data.crypto_index, nir->data.window_size,
+ nir->data.cipher_blk_len, nir->data.iv_len,
+ nir->data.nat_t_req, nir->data.esp_icv_len,
+ nir->data.esp_seq_skip, nir->data.esp_tail_skip,
+ nir->data.use_pattern, nir->data.enable_esn,
+ nir->data.dscp, nir->data.df,
+ nir->data.copy_dscp, nir->data.copy_df,
+ nir->index, nir->sa_idx);
+
+ /*
+ * Continuation of previous log. Different identifiers based on ip_ver
+ */
+ if (nir->oip.ip_ver == NSS_IPSEC_LOG_IPV6) {
+ nss_trace("IPSEC Destination Address: %pI6\n"
+ "IPSEC Source Address: %pI6\n",
+ nir->oip.dst_addr, nir->oip.src_addr);
+ } else if (nir->oip.ip_ver == NSS_IPSEC_LOG_IPV4) {
+ nss_trace("IPSEC Destination Address: %pI4\n"
+ "IPSEC Source Address: %pI4\n",
+ nir->oip.dst_addr, nir->oip.src_addr);
+ }
+}
+
+/*
+ * nss_ipsec_log_configure_node_msg()
+ * Log NSS IPSEC configure node message.
+ */
+static void nss_ipsec_log_configure_node_msg(struct nss_ipsec_msg *nim)
+{
+ struct nss_ipsec_configure_node *nicn __maybe_unused = &nim->msg.node;
+ nss_trace("%p: NSS IPSEC Configure Node\n"
+ "IPSEC DMA Redirect: %d\n"
+ "IPSEC DMA Lookaside: %d\n",
+ nicn, nicn->dma_redirect,
+ nicn->dma_lookaside);
+}
+
+/*
+ * nss_ipsec_log_verbose()
+ * Log message contents.
+ */
+static void nss_ipsec_log_verbose(struct nss_ipsec_msg *nim)
+{
+ switch (nim->cm.type) {
+ case NSS_IPSEC_MSG_TYPE_ADD_RULE:
+ case NSS_IPSEC_MSG_TYPE_DEL_RULE:
+ nss_ipsec_log_rule_msg(nim);
+ break;
+
+ case NSS_IPSEC_MSG_TYPE_CONFIGURE_NODE:
+ nss_ipsec_log_configure_node_msg(nim);
+ break;
+
+ case NSS_IPSEC_MSG_TYPE_NONE:
+ case NSS_IPSEC_MSG_TYPE_FLUSH_TUN:
+ case NSS_IPSEC_MSG_TYPE_SYNC_SA_STATS:
+ case NSS_IPSEC_MSG_TYPE_SYNC_FLOW_STATS:
+ case NSS_IPSEC_MSG_TYPE_SYNC_NODE_STATS:
+ /*
+ * No log for these valid messages.
+ */
+ break;
+
+ default:
+ nss_warning("%p: Invalid message type\n", nim);
+ break;
+ }
+}
+
+/*
+ * nss_ipsec_log_tx_msg()
+ * Log messages transmitted to FW.
+ */
+void nss_ipsec_log_tx_msg(struct nss_ipsec_msg *nim)
+{
+ if (nim->cm.type >= NSS_IPSEC_MSG_TYPE_MAX) {
+ nss_warning("%p: Invalid message type\n", nim);
+ return;
+ }
+
+ nss_info("%p: type[%d]:%s\n", nim, nim->cm.type, nss_ipsec_log_message_types_str[nim->cm.type]);
+ nss_ipsec_log_verbose(nim);
+}
+
+/*
+ * nss_ipsec_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_ipsec_log_rx_msg(struct nss_ipsec_msg *nim)
+{
+ if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) {
+ nss_warning("%p: Invalid response\n", nim);
+ return;
+ }
+
+ if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) {
+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type,
+ nss_ipsec_log_message_types_str[nim->cm.type],
+ nim->cm.response, nss_cmn_response_str[nim->cm.response]);
+ goto verbose;
+ }
+
+ if (nim->cm.error >= NSS_IPSEC_ERROR_TYPE_MAX) {
+ nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n",
+ nim, nim->cm.type, nss_ipsec_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 nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n",
+ nim, nim->cm.type, nss_ipsec_log_message_types_str[nim->cm.type],
+ nim->cm.response, nss_cmn_response_str[nim->cm.response],
+ nim->cm.error, nss_ipsec_log_error_response_types_str[nim->cm.error]);
+
+verbose:
+ nss_ipsec_log_verbose(nim);
+}
diff --git a/nss_ipsec_log.h b/nss_ipsec_log.h
new file mode 100644
index 0000000..5342c20
--- /dev/null
+++ b/nss_ipsec_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_IPSEC_LOG_H__
+#define __NSS_IPSEC_LOG_H__
+
+/*
+ * nss_ipsec_log.h
+ * NSS Crypto Log Header File
+ */
+
+/*
+ * nss_ipsec_log_tx_msg
+ * Logs a ipsec message that is sent to the NSS firmware.
+ */
+void nss_ipsec_log_tx_msg(struct nss_ipsec_msg *nim);
+
+/*
+ * nss_ipsec_log_rx_msg
+ * Logs a ipsec message that is received from the NSS firmware.
+ */
+void nss_ipsec_log_rx_msg(struct nss_ipsec_msg *nim);
+
+#endif /* __NSS_IPSEC_LOG_H__ */
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 */
diff --git a/nss_qrfs.c b/nss_qrfs.c
index 5710568..baa23fe 100644
--- a/nss_qrfs.c
+++ b/nss_qrfs.c
@@ -16,6 +16,7 @@
#include "nss_tx_rx_common.h"
#include "nss_qrfs_stats.h"
+#include "nss_qrfs_log.h"
/*
* Notify data structure
@@ -45,6 +46,11 @@
struct nss_qrfs_msg *nqm = (struct nss_qrfs_msg *)ncm;
nss_qrfs_msg_callback_t cb;
+ /*
+ * Trace messages.
+ */
+ nss_qrfs_log_rx_msg(nqm);
+
if (!nss_qrfs_verify_if_num(ncm->interface)) {
nss_warning("%p: invalid interface %d for QRFS\n", nss_ctx, ncm->interface);
return;
@@ -253,6 +259,11 @@
struct nss_cmn_msg *ncm = &msg->cm;
/*
+ * Trace messages.
+ */
+ nss_qrfs_log_tx_msg(msg);
+
+ /*
* Sanity check the message
*/
if (!nss_qrfs_verify_if_num(ncm->interface)) {
diff --git a/nss_qrfs_log.c b/nss_qrfs_log.c
new file mode 100644
index 0000000..567bc32
--- /dev/null
+++ b/nss_qrfs_log.c
@@ -0,0 +1,174 @@
+/*
+ **************************************************************************
+ * 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_qrfs_log.c
+ * NSS QRFS logger file.
+ */
+
+#include "nss_core.h"
+#define NSS_QRFS_LOG_IPV4 4
+#define NSS_QRFS_LOG_IPV6 6
+
+/*
+ * nss_qrfs_log_message_types_str
+ * QRFS message strings
+ */
+static int8_t *nss_qrfs_log_message_types_str[NSS_QRFS_MSG_MAX] __maybe_unused = {
+ "QRFS Flow Add Message",
+ "QRFS Flow Delete Message",
+ "QRFS MAC Add Message",
+ "QRFS MAC Delete Message",
+ "QRFS Stats Sync",
+};
+
+/*
+ * nss_qrfs_log_error_response_types_str
+ * Strings for error types for QRFS messages
+ */
+static int8_t *nss_qrfs_log_error_response_types_str[NSS_QRFS_ERROR_MAX] __maybe_unused = {
+ "QRFS Invalid Message Type",
+ "QRFS Invalid Message Size",
+ "QRFS Invalid IP Version",
+ "QRFS V4 Flow Table Full",
+ "QRFS V6 Flow Table Full",
+ "QRFS MAC Table Full",
+};
+
+/*
+ * nss_qrfs_log_flow_rule_msg()
+ * Log NSS QRFS Flow Rule Message.
+ */
+static void nss_qrfs_log_flow_rule_msg(struct nss_qrfs_flow_rule_msg *nqfm)
+{
+ nss_trace("%p: NSS QRFS Flow Rule Message:\n"
+ "QRFS Source Port: %d\n"
+ "QRFS Destination Port: %d\n"
+ "QRFS IP Version: %d\n"
+ "QRFS Protcol: %d\n"
+ "QRFS CPU ID: %d\n"
+ "QRFS Physical Interface Number: %d\n",
+ nqfm, nqfm->src_port,
+ nqfm->dst_port, nqfm->ip_version,
+ nqfm->protocol, nqfm->cpu,
+ nqfm->if_num);
+
+ /*
+ * Continuation of log. Different identifiers based on ip_version
+ */
+ if (nqfm->ip_version == NSS_QRFS_LOG_IPV6) {
+ nss_trace("QRFS Source Address: %pI6\n"
+ "QRFS Destination Address: %pI6\n",
+ nqfm->src_addr, nqfm->dst_addr);
+ } else if (nqfm->ip_version == NSS_QRFS_LOG_IPV4) {
+ nss_trace("QRFS Source Address: %pI4\n"
+ "QRFS Destination Address: %pI4\n",
+ nqfm->src_addr, nqfm->dst_addr);
+ }
+}
+
+/*
+ * nss_qrfs_log_mac_rule_msg()
+ * Log NSS QRFS MAC Rule Message.
+ */
+static void nss_qrfs_log_mac_rule_msg(struct nss_qrfs_mac_rule_msg *nqmm)
+{
+ nss_trace("%p: NSS QRFS MAC Rule Message:\n"
+ "QRFS MAC: %pM\n"
+ "QRFS CPU ID: %d\n"
+ "QRFS Physical Interface Number: %d\n",
+ nqmm, nqmm->mac,
+ nqmm->cpu, nqmm->if_num);
+}
+
+/*
+ * nss_qrfs_log_verbose()
+ * Log message contents.
+ */
+static void nss_qrfs_log_verbose(struct nss_qrfs_msg *nqm)
+{
+ switch (nqm->cm.type) {
+ case NSS_QRFS_MSG_FLOW_ADD:
+ case NSS_QRFS_MSG_FLOW_DELETE:
+ nss_qrfs_log_flow_rule_msg(&nqm->msg.flow_add);
+ break;
+
+ case NSS_QRFS_MSG_MAC_ADD:
+ case NSS_QRFS_MSG_MAC_DELETE:
+ nss_qrfs_log_mac_rule_msg(&nqm->msg.mac_add);
+ break;
+
+ case NSS_QRFS_MSG_STATS_SYNC:
+ /*
+ * No log for valid stats message.
+ */
+ break;
+
+ default:
+ nss_warning("%p: Invalid message type\n", nqm);
+ break;
+ }
+}
+
+/*
+ * nss_qrfs_log_tx_msg()
+ * Log messages transmitted to FW.
+ */
+void nss_qrfs_log_tx_msg(struct nss_qrfs_msg *nqm)
+{
+ if (nqm->cm.type >= NSS_QRFS_MSG_MAX) {
+ nss_warning("%p: Invalid message type\n", nqm);
+ return;
+ }
+
+ nss_info("%p: type[%d]:%s\n", nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type]);
+ nss_qrfs_log_verbose(nqm);
+}
+
+/*
+ * nss_qrfs_log_rx_msg()
+ * Log messages received from FW.
+ */
+void nss_qrfs_log_rx_msg(struct nss_qrfs_msg *nqm)
+{
+ if (nqm->cm.response >= NSS_CMN_RESPONSE_LAST) {
+ nss_warning("%p: Invalid response\n", nqm);
+ return;
+ }
+
+ if (nqm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nqm->cm.response == NSS_CMN_RESPONSE_ACK)) {
+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", nqm, nqm->cm.type,
+ nss_qrfs_log_message_types_str[nqm->cm.type],
+ nqm->cm.response, nss_cmn_response_str[nqm->cm.response]);
+ goto verbose;
+ }
+
+ if (nqm->cm.error >= NSS_QRFS_ERROR_MAX) {
+ nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n",
+ nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type],
+ nqm->cm.response, nss_cmn_response_str[nqm->cm.response],
+ nqm->cm.error);
+ goto verbose;
+ }
+
+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n",
+ nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type],
+ nqm->cm.response, nss_cmn_response_str[nqm->cm.response],
+ nqm->cm.error, nss_qrfs_log_error_response_types_str[nqm->cm.error]);
+
+verbose:
+ nss_qrfs_log_verbose(nqm);
+}
diff --git a/nss_qrfs_log.h b/nss_qrfs_log.h
new file mode 100644
index 0000000..de9832e
--- /dev/null
+++ b/nss_qrfs_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_QRFS_LOG_H__
+#define __NSS_QRFS_LOG_H__
+
+/*
+ * nss_qrfs_log.h
+ * NSS QRFS Log Header File
+ */
+
+/*
+ * nss_qrfs_log_tx_msg
+ * Logs a qrfs message that is sent to the NSS firmware.
+ */
+void nss_qrfs_log_tx_msg(struct nss_qrfs_msg *nqm);
+
+/*
+ * nss_qrfs_log_rx_msg
+ * Logs a qrfs message that is received from the NSS firmware.
+ */
+void nss_qrfs_log_rx_msg(struct nss_qrfs_msg *nqm);
+
+#endif /* __NSS_QRFS_LOG_H__ */