Skip to contentSkip to conversation

add v2 FW logging for ice driver

PATCH Superseded Paul M Stillwell Jr 1 participant 6 messages Mar 13, 2023

Subsystems (4)

v11 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

v11 cover add v2 FW logging for ice driver

FW log support was added to the ice driver, but that version is no longer supported. There is a newer version of FW logging (v2) that adds more control knobs to get the exact data out of the FW for debugging.

The interface for FW logging is debugfs. This was chosen based on a discussion
here: https://lore.kernel.org/netdev/[email protected]/
We talked about using devlink in a variety of ways, but none of those options made any sense for the way the FW reports data. We briefly talked about using ethtool, but that seemed to go by the wayside. Ultimately it seems like using debugfs is the way to go so re-implement the code to use that.

Additionally, instead of dumping the FW log output to syslog, dump it to debugfs. The FW log data is really just binary data that the FW log team decodes to determine what happens so the translation from binary to some text output just slows things down and results in potential dropped data. The structure for the debugfs entry is: /sys/kernel/debug/ice/<pci device>/fwlog

Once enabled the FW log data is received as ARQ events that the driver processes.

The FW logging is across all the PFs on the device, so restrict the commands to only PF0.

The following debugfs commands are added:
- disable fwlog
- dump fwlog_cfg
- enable fwlog
- update fwlog_cfg <fwlog_level> <fwlog_events> <fwlog_resolution>

where
fwlog_level is a value from 0-4 as described below
Each level includes the messages from the previous/lower level
0 - no logging
1 - error logging
2 - warning logging
3 - normal logging
4 - verbose logging

fwlog_events is a value from 0-32 that represents the module to receive events for. The values are sent as a hex value where each bit represents a specific module. The module values are:

        0 (0x00) - General
        1 (0x01) - Control (Resets + Autoload)
        2 (0x02) - Link Management
        3 (0x03) - Link Topology Detection
        4 (0x04) - DNL
        5 (0x05) - I2C
        6 (0x06) - SDP
        7 (0x07) - MDIO
        8 (0x08) - Admin Queue
        9 (0x09) - HDMA
        10 (0x0A) - LLDP
        11 (0x0B) - DCBX
        12 (0x0C) - DCB
        13 (0x0D) - XLR
        14 (0x0E) - NVM
        15 (0x0F) - Authentication
        16 (0x10) - VPD
        17 (0x11) - IOSF
        18 (0x12) - Parser
        19 (0x13) - Switch
        20 (0x14) - Scheduler
        21 (0x15) - Tx Queue Management
        22 (0x16) - Unsupported
        23 (0x17) - Post
        24 (0x18) - Watchdog
        25 (0x19) - Task Dispatcher
        26 (0x1A) - Manageability
        27 (0x1B) - Synce
        28 (0x1C) - Health
        29 (0x1D) - Time Sync
        30 (0x1E) - PF Registration
        31 (0x1F) - Module Version

fwlog_resolution is the number of log messages to included in a single ARQ event. The range is 1-128 (1 means push every log message, 128 means push only when the max AQ command buffer is full). The suggested value is 10.

The user can read the fwlog data by reading from the 'fwlog' file like this:

  # cat /sys/kernel/debug/ice/<pci-dev>/fwlog > <filename>

---
v11:
- changed 'events' variable to be u32 instead of unsigned long since the FW expects a 32-bit value. This caused some changes to a few functions that pass 'events' and changed the parsing in debugfs. Also fixed an issue with i386 cross compile where BIT_ULL() was being used incorrectly and causing compiler issues on i386 because the value was larger than the variable.

v10 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v10:
- updated code to only create 'fwlog' file if FW logging is supported
- combined code under single ifdef in header file
- removed defines that were not used and added them when the correct patch is applied
- added newline between defines and variables in structure
- moved include header into alphabetical order at top of file
- removed unnecessary casts
- updated return statements for more efficient code
- changed BIT() to BIT_ULL() to try to fix i386 cross compile issue
- fixed RCT issue
- added documentation in Documentation/networking/device-drivers/ethernet/intel/ice.rst
- updated commit messages appropriately
-

v9 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v9:
- rewrote code to use debugfs instead of devlink

v8 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v8:
- added vmalloc.h file for correct prototypes
- moved code change from patch 5 to patch 3 where it was supposed to be
- fixed a style issue

v7 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v7:
- removed dev_info() in ice_debugfs_command_read() since it wasn't needed
- refactored ice_debugfs_command_read() to split the copying of the data and the freeing of the buffers. This allows for better error recovery in case the copy_to_user() fails
- changed allocation of fwlog buffers and structure from kernel memory to virtual memory (vmalloc/vzalloc)
- fixed a compile bug

v6 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v6:
- removed cache_cfg() based on feedback
- a couple of other minor changes based on feedback

v5 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v5:
- handle devlink reload path correctly so debugfs directories don't get added twice
- fix issue where code wrapped with CONFIG_DEBUG_FS was causing sparc compile issues with multiple defines

No v4 cover letter

v4:
- actually changed the modes in ice.rst for new params

v3 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v3:
- fixed ice.rst to have proper mode for new params and fixed formatting

v2 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

v2:
- removed some unused admin queue commands
- updated copyright in ice_fwlog.[ch] to 2022
- moved defines in structures under the variables and added blank line
- removed a couple of unused defines
- changed fwlog_support_ena to fwlog_supported to be clearer
- consolidated ice_devlink_param_id enum together
- changed ice_fwlog_set_support_ena() to ice_fwlog_set_supported()
- consolidated return status logic in ice_devlink_fwlog_enabled_set()
- pull up functions in ice_fwlog.c where appropriate
- add newline for FW Logging Commands comment
- changed any new u[8/16] loop variables to int
- moved ice_pf_fwlog_deinit() from patch 5 to patch 4
- changed error message to be clearer
- updated Documentation/networking/devlink/ice.rst
- updated commit messages with examples of devlink commands and using debugfs to get log files

v1 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

Paul M Stillwell Jr (5):
ice: remove FW logging code
ice: enable debugfs to check FW logging status
ice: add ability to set FW log configuration
ice: enable FW logging based on stored configuration
ice: add ability to read FW logging data

 .../device_drivers/ethernet/intel/ice.rst     |  85 ++++
 drivers/net/ethernet/intel/ice/Makefile       |   4 +-
 drivers/net/ethernet/intel/ice/ice.h          |  31 ++
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   | 161 ++++----
 drivers/net/ethernet/intel/ice/ice_common.c   | 218 +---------
 drivers/net/ethernet/intel/ice/ice_common.h   |   1 -
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 390 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_fwlog.c    | 362 ++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_fwlog.h    |  57 +++
 drivers/net/ethernet/intel/ice/ice_main.c     | 133 +++++-
 drivers/net/ethernet/intel/ice/ice_type.h     |  22 +-
 11 files changed, 1148 insertions(+), 316 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_debugfs.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_fwlog.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_fwlog.h
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw

PATCH v11 1/5 ice: remove FW logging code

The FW logging code doesn't work because there is no way to set cq_ena or uart_ena so remove the code. This code is the original (v1) way of FW logging so it should be replaced with the v2 way.

---
v10->v11: none
v9->v10: none
v8->v9: none
v7->v8: none
v6->v7: none
v5->v6: none
v4->v5: none
v3->v4: none
v2->v3: none
v1->v2: none

---
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  78 -------
 drivers/net/ethernet/intel/ice/ice_common.c   | 218 ------------------
 drivers/net/ethernet/intel/ice/ice_common.h   |   1 -
 drivers/net/ethernet/intel/ice/ice_main.c     |   3 -
 drivers/net/ethernet/intel/ice/ice_type.h     |  20 --
 5 files changed, 320 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -78
index 838d9b274d68..e1b95cc3a538 100644
@@ -1953,78 +1953,6 @@ struct ice_aqc_add_rdma_qset_data {
 	struct ice_aqc_add_tx_rdma_qset_entry rdma_qsets[];
 };
 
-/* Configure Firmware Logging Command (indirect 0xFF09)
- * Logging Information Read Response (indirect 0xFF10)
- * Note: The 0xFF10 command has no input parameters.
- */
-struct ice_aqc_fw_logging {
-	u8 log_ctrl;
-#define ICE_AQC_FW_LOG_AQ_EN		BIT(0)
-#define ICE_AQC_FW_LOG_UART_EN		BIT(1)
-	u8 rsvd0;
-	u8 log_ctrl_valid; /* Not used by 0xFF10 Response */
-#define ICE_AQC_FW_LOG_AQ_VALID		BIT(0)
-#define ICE_AQC_FW_LOG_UART_VALID	BIT(1)
-	u8 rsvd1[5];
-	__le32 addr_high;
-	__le32 addr_low;
-};
-
-enum ice_aqc_fw_logging_mod {
-	ICE_AQC_FW_LOG_ID_GENERAL = 0,
-	ICE_AQC_FW_LOG_ID_CTRL,
-	ICE_AQC_FW_LOG_ID_LINK,
-	ICE_AQC_FW_LOG_ID_LINK_TOPO,
-	ICE_AQC_FW_LOG_ID_DNL,
-	ICE_AQC_FW_LOG_ID_I2C,
-	ICE_AQC_FW_LOG_ID_SDP,
-	ICE_AQC_FW_LOG_ID_MDIO,
-	ICE_AQC_FW_LOG_ID_ADMINQ,
-	ICE_AQC_FW_LOG_ID_HDMA,
-	ICE_AQC_FW_LOG_ID_LLDP,
-	ICE_AQC_FW_LOG_ID_DCBX,
-	ICE_AQC_FW_LOG_ID_DCB,
-	ICE_AQC_FW_LOG_ID_NETPROXY,
-	ICE_AQC_FW_LOG_ID_NVM,
-	ICE_AQC_FW_LOG_ID_AUTH,
-	ICE_AQC_FW_LOG_ID_VPD,
-	ICE_AQC_FW_LOG_ID_IOSF,
-	ICE_AQC_FW_LOG_ID_PARSER,
-	ICE_AQC_FW_LOG_ID_SW,
-	ICE_AQC_FW_LOG_ID_SCHEDULER,
-	ICE_AQC_FW_LOG_ID_TXQ,
-	ICE_AQC_FW_LOG_ID_RSVD,
-	ICE_AQC_FW_LOG_ID_POST,
-	ICE_AQC_FW_LOG_ID_WATCHDOG,
-	ICE_AQC_FW_LOG_ID_TASK_DISPATCH,
-	ICE_AQC_FW_LOG_ID_MNG,
-	ICE_AQC_FW_LOG_ID_MAX,
-};
-
-/* Defines for both above FW logging command/response buffers */
-#define ICE_AQC_FW_LOG_ID_S		0
-#define ICE_AQC_FW_LOG_ID_M		(0xFFF << ICE_AQC_FW_LOG_ID_S)
-
-#define ICE_AQC_FW_LOG_CONF_SUCCESS	0	/* Used by response */
-#define ICE_AQC_FW_LOG_CONF_BAD_INDX	BIT(12)	/* Used by response */
-
-#define ICE_AQC_FW_LOG_EN_S		12
-#define ICE_AQC_FW_LOG_EN_M		(0xF << ICE_AQC_FW_LOG_EN_S)
-#define ICE_AQC_FW_LOG_INFO_EN		BIT(12)	/* Used by command */
-#define ICE_AQC_FW_LOG_INIT_EN		BIT(13)	/* Used by command */
-#define ICE_AQC_FW_LOG_FLOW_EN		BIT(14)	/* Used by command */
-#define ICE_AQC_FW_LOG_ERR_EN		BIT(15)	/* Used by command */
-
-/* Get/Clear FW Log (indirect 0xFF11) */
-struct ice_aqc_get_clear_fw_log {
-	u8 flags;
-#define ICE_AQC_FW_LOG_CLEAR		BIT(0)
-#define ICE_AQC_FW_LOG_MORE_DATA_AVAIL	BIT(1)
-	u8 rsvd1[7];
-	__le32 addr_high;
-	__le32 addr_low;
-};
-
 /* Download Package (indirect 0x0C40) */
 /* Also used for Update Package (indirect 0x0C41 and 0x0C42) */
 struct ice_aqc_download_pkg {
@@ -2184,8 +2112,6 @@ struct ice_aq_desc {
 		struct ice_aqc_add_rdma_qset add_rdma_qset;
 		struct ice_aqc_add_get_update_free_vsi vsi_cmd;
 		struct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;
-		struct ice_aqc_fw_logging fw_logging;
-		struct ice_aqc_get_clear_fw_log get_clear_fw_log;
 		struct ice_aqc_download_pkg download_pkg;
 		struct ice_aqc_driver_shared_params drv_shared_params;
 		struct ice_aqc_set_mac_lb set_mac_lb;
@@ -2368,10 +2294,6 @@ enum ice_adminq_opc {
 
 	/* Standalone Commands/Events */
 	ice_aqc_opc_event_lan_overflow			= 0x1001,
-
-	/* debug commands */
-	ice_aqc_opc_fw_logging				= 0xFF09,
-	ice_aqc_opc_fw_logging_info			= 0xFF10,
 };
 
 #endif /* _ICE_ADMINQ_CMD_H_ */
drivers/net/ethernet/intel/ice/ice_common.c +0 -218

236 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_common.h +0 -1
index 8ba5f935a092..831212824d84 100644
@@ -188,7 +188,6 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle,
 		struct ice_sq_cd *cd);
 int ice_replay_vsi(struct ice_hw *hw, u16 vsi_handle);
 void ice_replay_post(struct ice_hw *hw);
-void ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);
 struct ice_q_ctx *
 ice_get_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 q_handle);
 int ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in);
drivers/net/ethernet/intel/ice/ice_main.c +0 -3
index 8dc1ae3f8e53..f476eb05ee36 100644
@@ -1519,9 +1519,6 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
 
 			ice_vc_process_vf_msg(pf, &event, &data);
 			break;
-		case ice_aqc_opc_fw_logging:
-			ice_output_fw_log(hw, &event.desc, event.msg_buf);
-			break;
 		case ice_aqc_opc_lldp_set_mib_change:
 			ice_dcb_process_lldp_set_mib_change(pf, &event);
 			break;
drivers/net/ethernet/intel/ice/ice_type.h +0 -20
index a09556e57803..ce0b502365e9 100644
@@ -727,24 +727,6 @@ struct ice_switch_info {
 	DECLARE_BITMAP(prof_res_bm[ICE_MAX_NUM_PROFILES], ICE_MAX_FV_WORDS);
 };
 
-/* FW logging configuration */
-struct ice_fw_log_evnt {
-	u8 cfg : 4;	/* New event enables to configure */
-	u8 cur : 4;	/* Current/active event enables */
-};
-
-struct ice_fw_log_cfg {
-	u8 cq_en : 1;    /* FW logging is enabled via the control queue */
-	u8 uart_en : 1;  /* FW logging is enabled via UART for all PFs */
-	u8 actv_evnts;   /* Cumulation of currently enabled log events */
-
-#define ICE_FW_LOG_EVNT_INFO	(ICE_AQC_FW_LOG_INFO_EN >> ICE_AQC_FW_LOG_EN_S)
-#define ICE_FW_LOG_EVNT_INIT	(ICE_AQC_FW_LOG_INIT_EN >> ICE_AQC_FW_LOG_EN_S)
-#define ICE_FW_LOG_EVNT_FLOW	(ICE_AQC_FW_LOG_FLOW_EN >> ICE_AQC_FW_LOG_EN_S)
-#define ICE_FW_LOG_EVNT_ERR	(ICE_AQC_FW_LOG_ERR_EN >> ICE_AQC_FW_LOG_EN_S)
-	struct ice_fw_log_evnt evnts[ICE_AQC_FW_LOG_ID_MAX];
-};
-
 /* Enum defining the different states of the mailbox snapshot in the
  * PF-VF mailbox overflow detection algorithm. The snapshot can be in
  * states:
@@ -878,8 +860,6 @@ struct ice_hw {
 	u8 fw_patch;		/* firmware patch version */
 	u32 fw_build;		/* firmware build number */
 
-	struct ice_fw_log_cfg fw_log;
-
 /* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL
  * register. Used for determining the ITR/INTRL granularity during
  * initialization.
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#2 lore raw

PATCH v11 2/5 ice: enable debugfs to check FW logging status

In reply to Paul M Stillwell Jr

Users want the ability to debug FW issues by retrieving the FW logs from the E8xx devices. Enable debugfs to query the driver to see if the NVM image allows FW logging and to see if FW logging is currently running.

If the NVM supports FW logging then the file 'fwlog' will be created under the PCI device ID for the ice driver. If the file does not exist then either the NVM doesn't support FW logging or debugfs is not enabled on the system.

To see the status of FW logging use 'dump fwlog_cfg' like this:

echo dump fwlog_cfg > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog

---
v10->v11: none
no data on previous versions

---
 drivers/net/ethernet/intel/ice/Makefile       |   4 +-
 drivers/net/ethernet/intel/ice/ice.h          |  20 ++
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  76 +++++
 drivers/net/ethernet/intel/ice/ice_common.c   |   4 +
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 280 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_fwlog.c    | 159 ++++++++++
 drivers/net/ethernet/intel/ice/ice_fwlog.h    |  54 ++++
 drivers/net/ethernet/intel/ice/ice_main.c     |   5 +
 drivers/net/ethernet/intel/ice/ice_type.h     |   4 +
 9 files changed, 605 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_debugfs.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_fwlog.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_fwlog.h
drivers/net/ethernet/intel/ice/Makefile +3 -1
index 5d89392f969b..3290f594286e 100644
@@ -33,7 +33,8 @@ ice-y := ice_main.o	\
 	 ice_lag.o	\
 	 ice_ethtool.o  \
 	 ice_repr.o	\
-	 ice_tc_lib.o
+	 ice_tc_lib.o	\
+	 ice_fwlog.o
 ice-$(CONFIG_PCI_IOV) +=	\
 	ice_sriov.o		\
 	ice_virtchnl.o		\
@@ -48,3 +49,4 @@ ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
 ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
 ice-$(CONFIG_ICE_SWITCHDEV) += ice_eswitch.o
 ice-$(CONFIG_GNSS) += ice_gnss.o
+ice-$(CONFIG_DEBUG_FS) += ice_debugfs.o
drivers/net/ethernet/intel/ice/ice.h +20 -0
index aa32111afd6e..5b44e400b740 100644
@@ -552,6 +552,7 @@ struct ice_pf {
 	struct ice_vsi_stats **vsi_stats;
 	struct ice_sw *first_sw;	/* first switch created by firmware */
 	u16 eswitch_mode;		/* current mode of eswitch */
+	struct dentry *ice_debugfs_pf;
 	struct ice_vfs vfs;
 	DECLARE_BITMAP(features, ICE_F_MAX);
 	DECLARE_BITMAP(state, ICE_STATE_NBITS);
@@ -872,6 +873,25 @@ static inline bool ice_is_adq_active(struct ice_pf *pf)
 	return false;
 }
 
+#ifdef CONFIG_DEBUG_FS
+void ice_debugfs_fwlog_init(struct ice_pf *pf);
+void ice_debugfs_init(void);
+void ice_debugfs_exit(void);
+int
+ice_pf_fwlog_update_modules(struct ice_pf *pf, u8 log_level,
+			    unsigned long events);
+#else
+static inline void ice_debugfs_fwlog_init(struct ice_pf *pf) { }
+static inline void ice_debugfs_init(void) { }
+static inline void ice_debugfs_exit(void) { }
+static int
+ice_pf_fwlog_update_modules(struct ice_pf *pf, u8 log_level,
+			    unsigned long events)
+{
+	return -EOPNOTSUPP;
+}
+#endif /* CONFIG_DEBUG_FS */
+
 bool netif_is_ice(struct net_device *dev);
 int ice_vsi_setup_tx_rings(struct ice_vsi *vsi);
 int ice_vsi_setup_rx_rings(struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +76 -0

94 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_common.c +4 -0
index 39ed1c6877f4..da55db0170dd 100644
@@ -879,6 +879,10 @@ int ice_init_hw(struct ice_hw *hw)
 	if (status)
 		goto err_unroll_cqinit;
 
+	status = ice_fwlog_init(hw);
+	if (status)
+		ice_debug(hw, ICE_DBG_FW_LOG, "Error initializing FW logging: %d\n", status);
+
 	status = ice_clear_pf_cfg(hw);
 	if (status)
 		goto err_unroll_cqinit;
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +280 -0

280 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fwlog.c new file +159 -0

159 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fwlog.h new file +54 -0

54 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_main.c +5 -0
index f476eb05ee36..47b95a1185f6 100644
@@ -5323,6 +5323,8 @@ static void ice_remove(struct pci_dev *pdev)
 		msleep(100);
 	}
 
+	ice_debugfs_exit();
+
 	if (test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) {
 		set_bit(ICE_VF_RESETS_DISABLED, pf->state);
 		ice_free_vfs(pf);
@@ -5784,10 +5786,13 @@ static int __init ice_module_init(void)
 		return -ENOMEM;
 	}
 
+	ice_debugfs_init();
+
 	status = pci_register_driver(&ice_driver);
 	if (status) {
 		pr_err("failed to register PCI driver, err %d\n", status);
 		destroy_workqueue(ice_wq);
+		ice_debugfs_exit();
 	}
 
 	return status;
drivers/net/ethernet/intel/ice/ice_type.h +4 -0
index ce0b502365e9..dd3e11b7e3ed 100644
@@ -17,6 +17,7 @@
 #include "ice_protocol_type.h"
 #include "ice_sbq_cmd.h"
 #include "ice_vlan_mode.h"
+#include "ice_fwlog.h"
 
 static inline bool ice_is_tc_ena(unsigned long bitmap, u8 tc)
 {
@@ -860,6 +861,9 @@ struct ice_hw {
 	u8 fw_patch;		/* firmware patch version */
 	u32 fw_build;		/* firmware build number */
 
+	struct ice_fwlog_cfg fwlog_cfg;
+	bool fwlog_supported; /* does hardware support FW logging? */
+
 /* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL
  * register. Used for determining the ITR/INTRL granularity during
  * initialization.
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#3 lore raw

PATCH v11 3/5 ice: add ability to set FW log configuration

In reply to Paul M Stillwell Jr

The FW log has several configuration options to control what gets output and how often it gets output. Allow the user to set the log level, events, and how often the FW generates messages with data in them (resolution).

The command to set the configuration looks like:

update fwlog_cfg <fwlog_level> <fwlog_events> <fwlog_resolution>

where
fwlog_level is a value from 0-4 as described below
Each level includes the messages from the previous/lower level
0 - no logging
1 - error logging
2 - warning logging
3 - normal logging
4 - verbose logging

fwlog_events is a value from 0-32 that represents the module to receive events for. The values are sent as a hex value where each bit represents a specific module. The module values are:

	0 (0x00) - General
	1 (0x01) - Control (Resets + Autoload)
	2 (0x02) - Link Management
	3 (0x03) - Link Topology Detection
	4 (0x04) - DNL
	5 (0x05) - I2C
	6 (0x06) - SDP
	7 (0x07) - MDIO
	8 (0x08) - Admin Queue
	9 (0x09) - HDMA
	10 (0x0A) - LLDP
	11 (0x0B) - DCBX
	12 (0x0C) - DCB
	13 (0x0D) - XLR
	14 (0x0E) - NVM
	15 (0x0F) - Authentication
	16 (0x10) - VPD
	17 (0x11) - IOSF
	18 (0x12) - Parser
	19 (0x13) - Switch
	20 (0x14) - Scheduler
	21 (0x15) - Tx Queue Management
	22 (0x16) - Unsupported
	23 (0x17) - Post
	24 (0x18) - Watchdog
	25 (0x19) - Task Dispatcher
	26 (0x1A) - Manageability
	27 (0x1B) - Synce
	28 (0x1C) - Health
	29 (0x1D) - Time Sync
	30 (0x1E) - PF Registration
	31 (0x1F) - Module Version

fwlog_resolution is the number of log messages to included in a single ARQ event. The range is 1-128 (1 means push every log message, 128 means push only when the max AQ command buffer is full). The suggested value is 10.

An example command to update the FW log configuration is:

echo update fwlog_cfg 4 0x82414821 50 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog

The above command would set the log level to 4 (Verbose) for the following modules

        0 (0x00) - General
        5 (0x05) - I2C
        11 (0x0B) - DCBX
        14 (0x0E) - NVM
        16 (0x10) - VPD
        22 (0x16) - Unsupported
        25 (0x19) - Task Dispatcher
        31 (0x1F) - Module Version

The setting of the configuration does NOT enable FW logging, that is a separate command. There are effectively 2 configurations at this point:
the one that is currently running and the staged configuration.

To allow the user to see what is going on the 'dump fwlog_cfg' command now shows the 'Running' config and the 'Staged' config. This allows the user to be able to compare the currently running configuration with what will be enabled when the user executes the command to enable the staged configuration.

---
v11:
- changed 'events' variable to be u32 instead of unsigned long since the FW expects a 32-bit value. This caused some changes to a few functions that pass 'events' and changed the parsing in debugfs. Also fixed an issue with i386 cross compile where BIT_ULL() was being used incorrectly and causing compiler issues on i386 because the value was larger than the variable.

v10 at:
https://lore.kernel.org/intel-wired-lan/[email protected]/

---
 drivers/net/ethernet/intel/ice/ice.h          |  2 +-
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  3 ++
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 35 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_main.c     | 37 +++++++++++++++++++
 4 files changed, 76 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice.h +1 -1
index 5b44e400b740..8269f033e84d 100644
@@ -879,7 +879,7 @@ void ice_debugfs_init(void);
 void ice_debugfs_exit(void);
 int
 ice_pf_fwlog_update_modules(struct ice_pf *pf, u8 log_level,
-			    unsigned long events);
+			    u32 events);
 #else
 static inline void ice_debugfs_fwlog_init(struct ice_pf *pf) { }
 static inline void ice_debugfs_init(void) { }
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +3 -0
index 80e5376ca064..558a17d38918 100644
@@ -2092,6 +2092,9 @@ struct ice_aqc_fw_log {
 		} sync;
 		struct {
 			__le16 log_resolution;
+#define ICE_AQC_FW_LOG_MIN_RESOLUTION		(1)
+#define ICE_AQC_FW_LOG_MAX_RESOLUTION		(128)
+
 			__le16 mdl_cnt;
 		} cfg;
 	} ops;
drivers/net/ethernet/intel/ice/ice_debugfs.c +35 -0
index 1319ec3e97b1..cb1b578e929e 100644
@@ -146,6 +146,8 @@ static void ice_fwlog_dump_cfg(struct ice_hw *hw)
 
 	dev_info(dev, "Running FWLOG Configuration:\n");
 	ice_print_fwlog_config(hw, cfg);
+	dev_info(dev, "Staged FWLOG Configuration:\n");
+	ice_print_fwlog_config(hw, &hw->fwlog_cfg);
 
 	kfree(cfg);
 }
@@ -199,10 +201,43 @@ ice_debugfs_command_write(struct file *filp, const char __user *buf,
 	if (argc == 2 && !strncmp(argv[0], "dump", 4) &&
 	    !strncmp(argv[1], "fwlog_cfg", 9)) {
 		ice_fwlog_dump_cfg(&pf->hw);
+	} else if (argc == 5 && !strncmp(argv[0], "update", 6) &&
+		   !strncmp(argv[1], "fwlog_cfg", 9)) {
+		struct ice_hw *hw = &pf->hw;
+		u8 log_level, resolution;
+		u32 events;
+
+		ret = kstrtou8(argv[2], 0, &log_level);
+		if (ret)
+			goto command_write_error;
+
+		ret = kstrtouint(argv[3], 0, &events);
+		if (ret)
+			goto command_write_error;
+
+		ret = kstrtou8(argv[4], 0, &resolution);
+		if (ret)
+			goto command_write_error;
+
+		if (resolution < ICE_AQC_FW_LOG_MIN_RESOLUTION ||
+		    resolution > ICE_AQC_FW_LOG_MAX_RESOLUTION) {
+			dev_err(dev, "Invalid FW log resolution %d, value must be between %d - %d\n",
+				resolution, ICE_AQC_FW_LOG_MIN_RESOLUTION,
+				ICE_AQC_FW_LOG_MAX_RESOLUTION);
+			ret = -EINVAL;
+			goto command_write_error;
+		}
+
+		ret = ice_pf_fwlog_update_modules(pf, log_level, events);
+		if (ret)
+			goto command_write_error;
+
+		hw->fwlog_cfg.log_resolution = resolution;
 	} else {
 		dev_info(dev, "unknown or invalid command '%s'\n", cmd_buf);
 		dev_info(dev, "available commands\n");
 		dev_info(dev, "\t dump fwlog_cfg\n");
+		dev_info(dev, "\t update fwlog_cfg <fwlog_level> <fwlog_events> <fwlog_resolution>");
 		ret = -EINVAL;
 		goto command_write_error;
 	}
drivers/net/ethernet/intel/ice/ice_main.c +37 -0
index 47b95a1185f6..a5ce84d84843 100644
@@ -4552,6 +4552,43 @@ static void ice_print_wake_reason(struct ice_pf *pf)
 	dev_info(ice_pf_to_dev(pf), "Wake reason: %s", wake_str);
 }
 
+/**
+ * ice_pf_fwlog_update_modules - update 1 or more modules via debugfs
+ * @pf: pointer to the PF struct
+ * @log_level: log_level to use for the @events
+ * @events: events to update
+ */
+int ice_pf_fwlog_update_modules(struct ice_pf *pf, u8 log_level,
+				u32 events)
+{
+	struct ice_fwlog_module_entry *entries;
+	struct ice_hw *hw = &pf->hw;
+	u16 max_bits;
+	int i;
+
+	if (log_level >= ICE_FWLOG_LEVEL_INVALID) {
+		dev_err(ice_pf_to_dev(pf), "Invalid FW log level %u, all level(s) >= %u are invalid\n",
+			log_level, ICE_FWLOG_LEVEL_INVALID);
+		return -EINVAL;
+	}
+
+	entries = (struct ice_fwlog_module_entry *)hw->fwlog_cfg.module_entries;
+
+	max_bits = min_t(u32, BITS_PER_TYPE(u32),
+			 ICE_AQC_FW_LOG_ID_MAX);
+
+	/* look for the set bits in events. the driver can't use any of the
+	 * built in bitops because they all need an unsigned long type which
+	 * events is not
+	 */
+	for (i = 0; i < max_bits; i++) {
+		if (BIT(i) & events)
+			entries[i].log_level = log_level;
+	}
+
+	return 0;
+}
+
 /**
  * ice_register_netdev - register netdev
  * @vsi: pointer to the VSI struct
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#4 lore raw

PATCH v11 4/5 ice: enable FW logging based on stored configuration

In reply to Paul M Stillwell Jr

Give users the ability to enable/disable the FW logging configuration that is staged. Enabling the logging causes ARQ events to start being received by the driver with FW logging data in them.

To enable/disable FW logging use 'enable fwlog' and 'disable fwlog'. An example command to enable FW logging:

echo enable fwlog > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog

Similarly to disable FW logging:

echo disable fwlog > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog

---
v10->v11: none
no data on previous versions

---
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   4 +
 drivers/net/ethernet/intel/ice/ice_debugfs.c  |  24 +++
 drivers/net/ethernet/intel/ice/ice_fwlog.c    | 203 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_fwlog.h    |   3 +
 4 files changed, 234 insertions(+)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +4 -0
index 558a17d38918..1af036beeb45 100644
@@ -2075,6 +2075,7 @@ enum ice_aqc_fw_logging_mod {
 };
 
 /* Set FW Logging configuration (indirect 0xFF30)
+ * Register for FW Logging (indirect 0xFF31)
  * Query FW Logging (indirect 0xFF32)
  */
 struct ice_aqc_fw_log {
@@ -2082,6 +2083,8 @@ struct ice_aqc_fw_log {
 #define ICE_AQC_FW_LOG_CONF_UART_EN	BIT(0)
 #define ICE_AQC_FW_LOG_CONF_AQ_EN	BIT(1)
 #define ICE_AQC_FW_LOG_QUERY_REGISTERED	BIT(2)
+#define ICE_AQC_FW_LOG_CONF_SET_VALID	BIT(3)
+#define ICE_AQC_FW_LOG_AQ_REGISTER	BIT(0)
 #define ICE_AQC_FW_LOG_AQ_QUERY		BIT(2)
 
 	u8 rsp_flag;
@@ -2372,6 +2375,7 @@ enum ice_adminq_opc {
 
 	/* FW Logging Commands */
 	ice_aqc_opc_fw_logs_config			= 0xFF30,
+	ice_aqc_opc_fw_logs_register			= 0xFF31,
 	ice_aqc_opc_fw_logs_query			= 0xFF32,
 };
 
drivers/net/ethernet/intel/ice/ice_debugfs.c +24 -0
index cb1b578e929e..f9edaf871c87 100644
@@ -233,11 +233,35 @@ ice_debugfs_command_write(struct file *filp, const char __user *buf,
 			goto command_write_error;
 
 		hw->fwlog_cfg.log_resolution = resolution;
+	} else if (argc == 2 && !strncmp(argv[0], "enable", 6) &&
+		   !strncmp(argv[1], "fwlog", 5)) {
+		struct ice_hw *hw = &pf->hw;
+
+		hw->fwlog_cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
+
+		ret = ice_fwlog_set(hw, &hw->fwlog_cfg);
+		if (ret)
+			goto command_write_error;
+
+		ret = ice_fwlog_register(hw);
+	} else if (argc == 2 && !strncmp(argv[0], "disable", 7) &&
+		   !strncmp(argv[1], "fwlog", 5)) {
+		struct ice_hw *hw = &pf->hw;
+
+		hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
+
+		ret = ice_fwlog_set(hw, &hw->fwlog_cfg);
+		if (ret)
+			goto command_write_error;
+
+		ret = ice_fwlog_unregister(hw);
 	} else {
 		dev_info(dev, "unknown or invalid command '%s'\n", cmd_buf);
 		dev_info(dev, "available commands\n");
 		dev_info(dev, "\t dump fwlog_cfg\n");
 		dev_info(dev, "\t update fwlog_cfg <fwlog_level> <fwlog_events> <fwlog_resolution>");
+		dev_info(dev, "\t enable fwlog\n");
+		dev_info(dev, "\t disable fwlog\n");
 		ret = -EINVAL;
 		goto command_write_error;
 	}
drivers/net/ethernet/intel/ice/ice_fwlog.c +203 -0

221 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_fwlog.h +3 -0
index 9d60e77e2c5b..fcfceb9f6ec2 100644
@@ -50,5 +50,8 @@ struct ice_fwlog_cfg {
 void ice_fwlog_set_supported(struct ice_hw *hw);
 bool ice_fwlog_supported(struct ice_hw *hw);
 int ice_fwlog_init(struct ice_hw *hw);
+int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
 int ice_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
+int ice_fwlog_register(struct ice_hw *hw);
+int ice_fwlog_unregister(struct ice_hw *hw);
 #endif /* _ICE_FWLOG_H_ */
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#5 lore raw

PATCH v11 5/5 ice: add ability to read FW logging data

In reply to Paul M Stillwell Jr

Once logging is enable the user should read the data using something like:

cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog > log_data.bin

The output file is a binary file that will be decoded by Intel for debugging.

Also added documentation to Documentation/networking/device-drivers/ethernet/intel/ice.rst

---
v10->v11: none
no data on previous versions

---
 .../device_drivers/ethernet/intel/ice.rst     | 85 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice.h          | 11 +++
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  2 +
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 51 +++++++++++
 drivers/net/ethernet/intel/ice/ice_main.c     | 90 +++++++++++++++++++
 5 files changed, 239 insertions(+)
Documentation/networking/device_drivers/ethernet/intel/ice.rst +85 -0
index 5efea4dd1251..c59f4f89ee84 100644
@@ -913,6 +913,91 @@ driver writes raw bytes by the GNSS object to the receiver through i2c. Please
 refer to the hardware GNSS module documentation for configuration details.
 
 
+Firmware (FW) logging
+---------------------
+The driver supports FW logging via the debugfs interface on PF 0 only. In order
+for FW logging to work, the NVM must support it. The 'fwlog' file will only get
+created in the ice debugfs directory if the NVM supports FW logging.
+
+To see the status of FW logging the 'dump fwlog_cfg' command can be used::
+
+  # echo dump fwlog_cfg > /sys/kernel/debug/ice/<pci-dev>/fwlog
+
+To configure FW logging the 'update fwlog_cfg' command can be used::
+
+  # update fwlog_cfg <fwlog_level> <fwlog_events> <fwlog_resolution>
+
+where
+
+* fwlog_level is a value from 0-4 as described below. Each level includes the
+  messages from the previous/lower level
+
+      * 0 - no logging
+      * 1 - error logging
+      * 2 - warning logging
+      * 3 - normal logging
+      * 4 - verbose logging
+
+* fwlog_events is a value from 0-32 that represents the module to receive
+  events for. The values are sent as a hex value where each bit represents
+  a specific module. The module values are
+
+      * 0 (0x00) - General
+      * 1 (0x01) - Control (Resets + Autoload)
+      * 2 (0x02) - Link Management
+      * 3 (0x03) - Link Topology Detection
+      * 4 (0x04) - DNL
+      * 5 (0x05) - I2C
+      * 6 (0x06) - SDP
+      * 7 (0x07) - MDIO
+      * 8 (0x08) - Admin Queue
+      * 9 (0x09) - HDMA
+      * 10 (0x0A) - LLDP
+      * 11 (0x0B) - DCBX
+      * 12 (0x0C) - DCB
+      * 13 (0x0D) - XLR
+      * 14 (0x0E) - NVM
+      * 15 (0x0F) - Authentication
+      * 16 (0x10) - VPD
+      * 17 (0x11) - IOSF
+      * 18 (0x12) - Parser
+      * 19 (0x13) - Switch
+      * 20 (0x14) - Scheduler
+      * 21 (0x15) - Tx Queue Management
+      * 22 (0x16) - Unsupported
+      * 23 (0x17) - Post
+      * 24 (0x18) - Watchdog
+      * 25 (0x19) - Task Dispatcher
+      * 26 (0x1A) - Manageability
+      * 27 (0x1B) - Synce
+      * 28 (0x1C) - Health
+      * 29 (0x1D) - Time Sync
+      * 30 (0x1E) - PF Registration
+      * 31 (0x1F) - Module Version
+
+* fwlog_resolution is the number of log messages to included
+  in a single ARQ event. The range is 1-128 (1 means push every log
+  message, 128 means push only when the max AQ command buffer is full).
+  The suggested value is 10.
+
+An example command to enable FW logging is::
+
+  # echo update fwlog_cfg 4 0x82414821 50 > /sys/kernel/debug/ice/<pci-dev>/fwlog
+
+To turn on FW logging the 'enable fwlog' command can be used::
+
+  # echo enable fwlog > /sys/kernel/debug/ice/<pci-dev>/fwlog
+
+To turn off FW logging the 'disable fwlog' command can be used::
+
+  # echo disable fwlog > /sys/kernel/debug/ice/<pci-dev>/fwlog
+
+To read the data captured by the driver the user can read from the 'fwlog'
+file::
+
+  # cat /sys/kernel/debug/ice/<pci-dev>/fwlog > fwlog.bin
+
+
 Performance Optimization
 ========================
 Driver defaults are meant to fit a wide variety of workloads, but if further
drivers/net/ethernet/intel/ice/ice.h +11 -0
index 8269f033e84d..0f22b6957d83 100644
@@ -635,6 +635,8 @@ struct ice_pf {
 #define ICE_VF_AGG_NODE_ID_START	65
 #define ICE_MAX_VF_AGG_NODES		32
 	struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES];
+	struct list_head fwlog_data_list;
+	u8 fwlog_list_count;
 };
 
 struct ice_netdev_priv {
@@ -649,6 +651,15 @@ struct ice_netdev_priv {
 	struct list_head tc_indr_block_priv_list;
 };
 
+struct ice_fwlog_data {
+	struct list_head list;
+	u16 data_size;
+	u8 *data;
+};
+
+/* define the maximum number of items that can be in the list */
+#define ICE_FWLOG_MAX_SIZE	128
+
 /**
  * ice_vector_ch_enabled
  * @qv: pointer to q_vector, can be NULL
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2 -0
index 1af036beeb45..56fcba403dec 100644
@@ -2077,6 +2077,7 @@ enum ice_aqc_fw_logging_mod {
 /* Set FW Logging configuration (indirect 0xFF30)
  * Register for FW Logging (indirect 0xFF31)
  * Query FW Logging (indirect 0xFF32)
+ * FW Log Event (indirect 0xFF33)
  */
 struct ice_aqc_fw_log {
 	u8 cmd_flags;
@@ -2377,6 +2378,7 @@ enum ice_adminq_opc {
 	ice_aqc_opc_fw_logs_config			= 0xFF30,
 	ice_aqc_opc_fw_logs_register			= 0xFF31,
 	ice_aqc_opc_fw_logs_query			= 0xFF32,
+	ice_aqc_opc_fw_logs_event			= 0xFF33,
 };
 
 #endif /* _ICE_ADMINQ_CMD_H_ */
drivers/net/ethernet/intel/ice/ice_debugfs.c +51 -0

67 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_main.c +90 -0

126 lines not on this page · raw message

Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan