add v2 FW logging for ice driver
Subsystems (4)
Tony Nguyen
maintainerPaul Stillwell says:
Firmware (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.
FW logging is across all the PFs on the device so restrict the commands to only PF0.
If FW logging is supported then a directory named 'fwlog' will be created under '/sys/kernel/debug/ice/<pci_dev>'. A variety of files will be created to manage the behavior of logging. The following files will be created:
- modules
- resolution
- enable
- nr_buffs
- data
where modules is used to read/write the configuration for FW logging
resolution is used to determine how often to send FW logging events to the driver
enable is used to start/stop FW logging. This is a boolean value so only 1 or 0 are permissible values
nr_buffs is used to configure the number of data buffers the driver uses for log data
data is used to read/clear the log data
Generally there is a lot of data and dumping that data to syslog will result in a loss of data. This causes problems when decoding the data and the user doesn't know that data is missing until later. Instead of dumping the FW log output to syslog use debugfs. This ensures that all the data the driver has gets retrieved correctly.
The FW log data is binary data that the FW team decodes to determine what happened in firmware. The binary blob is sent to Intel for decoding.
---
v4:
- removed CONFIG_DEBUG_FS wrapper around code because the debugfs calls handle this case already
- moved ice_debugfs_exit() call to remove unreachable code issue
- minor changes to documentation based on feedback
v3: https://lore.kernel.org/netdev/[email protected]/
- Adjust error path cleanup in ice_module_init() for unreachable code.
v2: https://lore.kernel.org/netdev/[email protected]/
- Rewrote code to use debugfs instead of devlink
v1: https://lore.kernel.org/netdev/[email protected]/
Previous discussion:
https://lore.kernel.org/netdev/[email protected]/
The following are changes since commit 49e7265fd098fdade2bbdd9331e6b914cda7fa83:
net_sched: sch_fq: add TCA_FQ_WEIGHTS attribute
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 100GbE
Paul M Stillwell Jr (5):
ice: remove FW logging code
ice: configure FW logging
ice: enable FW logging
ice: add ability to read FW log data and configure the number of log
buffers
ice: add documentation for FW logging
.../device_drivers/ethernet/intel/ice.rst | 117 +++ drivers/net/ethernet/intel/ice/Makefile | 4 +- drivers/net/ethernet/intel/ice/ice.h | 7 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 161 ++-- drivers/net/ethernet/intel/ice/ice_common.c | 219 +---- drivers/net/ethernet/intel/ice/ice_common.h | 1 - drivers/net/ethernet/intel/ice/ice_debugfs.c | 807 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.c | 450 ++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 78 ++ drivers/net/ethernet/intel/ice/ice_main.c | 51 +- drivers/net/ethernet/intel/ice/ice_type.h | 23 +- 11 files changed, 1603 insertions(+), 315 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 · 1 line
2.38.1
Tony Nguyen
maintainerPATCH v4 1/5 ice: remove FW logging code
From: Paul M Stillwell Jr <[email protected]>
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.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 78 ------- drivers/net/ethernet/intel/ice/ice_common.c | 217 ------------------ 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, 319 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -78
@@ -2031,78 +2031,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 {
@@ -2442,8 +2370,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_set_cgu_input_config set_cgu_input_config;struct ice_aqc_get_cgu_input_config get_cgu_input_config;
@@ -2651,10 +2577,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 -217
235 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.h +0 -1
@@ -199,7 +199,6 @@ ice_aq_cfg_lan_txq(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *buf, 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
@@ -1531,9 +1531,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
@@ -729,24 +729,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:
@@ -888,8 +870,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 · 1 line
2.38.1
Tony Nguyen
maintainerPATCH v4 2/5 ice: configure FW logging
In reply to Tony NguyenFrom: Paul M Stillwell Jr <[email protected]>
Users want the ability to debug FW issues by retrieving the FW logs from the E8xx devices. Use debugfs to allow the user to read/write the FW log configuration by adding a 'fwlog/modules' file. Reading the file will show either the currently running configuration or the next configuration (if the user has changed the configuration). Writing to the file will update the configuration, but NOT enable the configuration (that is a separate command).
To see the status of FW logging then read the 'fwlog/modules' file like this:
cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules
To change the configuration of FW logging then write to the 'fwlog/modules' file like this:
echo DCB NORMAL > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules
The format to change the configuration is
echo <fwlog_module> <fwlog_level> > /sys/kernel/debug/ice/<pci device>/fwlog/modules
where
* fwlog_level is a name as described below. Each level includes the messages from the previous/lower level
* NONE
* ERROR
* WARNING
* NORMAL
* VERBOSE* fwlog_event is a name that represents the module to receive events for. The module names are
* GENERAL
* CTRL
* LINK
* LINK_TOPO
* DNL
* I2C
* SDP
* MDIO
* ADMINQ
* HDMA
* LLDP
* DCBX
* DCB
* XLR
* NVM
* AUTH
* VPD
* IOSF
* PARSER
* SW
* SCHEDULER
* TXQ
* RSVD
* POST
* WATCHDOG
* TASK_DISPATCH
* MNG
* SYNCE
* HEALTH
* TSDRV
* PFREG
* MDLVER
* ALLThe name ALL is special and specifies setting all of the modules to the specified fwlog_level.
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.
In addition to configuring the modules, the user can also configure the number of log messages (resolution) to include in a single Admin Receive Queue (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.
To see/change the resolution the user can read/write the 'fwlog/resolution' file. An example changing the value to 50 is
echo 50 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/resolution
--- drivers/net/ethernet/intel/ice/Makefile | 4 +- drivers/net/ethernet/intel/ice/ice.h | 7 + .../net/ethernet/intel/ice/ice_adminq_cmd.h | 80 ++++ drivers/net/ethernet/intel/ice/ice_common.c | 5 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 450 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.c | 231 +++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 55 +++ drivers/net/ethernet/intel/ice/ice_main.c | 21 + drivers/net/ethernet/intel/ice/ice_type.h | 4 + 9 files changed, 856 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
@@ -34,7 +34,9 @@ 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_debugfs.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ ice_virtchnl.o \
drivers/net/ethernet/intel/ice/ice.h +7 -0
@@ -561,6 +561,8 @@ 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 dentry *ice_debugfs_pf_fwlog;struct ice_vfs vfs;DECLARE_BITMAP (features,ICE_F_MAX );DECLARE_BITMAP (state,ICE_STATE_NBITS );
@@ -879,6 +881,11 @@ static inline bool ice_is_adq_active(struct ice_pf *pf)return false; } +void ice_debugfs_fwlog_init (struct ice_pf *pf); +void ice_debugfs_init (void ); +void ice_debugfs_exit (void ); +void ice_pf_fwlog_update_module (struct ice_pf *pf,int log_level,int module); +bool netif_is_ice (const 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 +80 -0
98 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.c +5 -0
@@ -954,6 +954,11 @@ 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 +450 -0
450 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.c new file +231 -0
231 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.h new file +55 -0
55 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_main.c +21 -0
@@ -4355,6 +4355,22 @@ 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_module - update 1 module +* @pf: pointer to the PF struct +* @log_level: log_level to use for the @module +* @module: module to update +*/ +void ice_pf_fwlog_update_module (struct ice_pf *pf,int log_level,int module) +{ +struct ice_fwlog_module_entry *entries; +struct ice_hw *hw = &pf->hw; + + entries = (struct ice_fwlog_module_entry *)hw->fwlog_cfg.module_entries; + + entries[module].log_level = log_level; +} +/** * ice_register_netdev - register netdev * @vsi: pointer to the VSI struct
@@ -5181,6 +5197,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);
@@ -5642,6 +5660,8 @@ static int __init ice_module_init(void) goto err_dest_wq; } +ice_debugfs_init (); + status =pci_register_driver (&ice_driver);if (status) {pr_err ("failed to register PCI driver, err %d\n" , status);
@@ -5652,6 +5672,7 @@ static int __init ice_module_init(void) err_dest_lag_wq:destroy_workqueue (ice_lag_wq); +ice_debugfs_exit (); err_dest_wq:destroy_workqueue (ice_wq);return status;
drivers/net/ethernet/intel/ice/ice_type.h +4 -0
@@ -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) {
@@ -870,6 +871,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 · 1 line
2.38.1
Jakub Kicinski
maintainerRe: [PATCH net-next v4 2/5] ice: configure FW logging
drivers/net/ethernet/intel/ice/ice_debugfs.c line 148
Quoted 6 lines · On Thu, 5 Oct 2023 10:01:07 -0700 Tony Nguyen wrote:
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +6
-0+static ssize_t ice_debugfs_parse_cmd_line (const char __user *src,size_t len, +char ***argv,int *argc) +{ +char *cmd_buf, *cmd_buf_tmp; + + cmd_buf =memdup_user (src, len +1 );
memdup() with len + 1 is quite suspicious, the buffer has length of len you shouldn't copy more than that
Quoted 48 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +47
-0+if (IS_ERR (cmd_buf)) +return PTR_ERR (cmd_buf); + cmd_buf[len] ='\0' ; + +/* the cmd_buf has a newline at the end of the command so +* remove it +*/ + cmd_buf_tmp =strchr (cmd_buf,'\n' ); +if (cmd_buf_tmp) { + *cmd_buf_tmp ='\0' ; + len = (size_t )cmd_buf_tmp - (size_t )cmd_buf +1 ; + } + + *argv =argv_split (GFP_KERNEL , cmd_buf, argc); +if (!*argv) +return -ENOMEM ; + +kfree (cmd_buf); +return 0 ; +static ssize_t +ice_debugfs_module_write (struct file *filp,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct device *dev =ice_pf_to_dev (pf); +ssize_t ret; +char **argv; +int argc; + +/* don't allow commands if the FW doesn't support it */ +if (!ice_fwlog_supported (&pf->hw)) +return -EOPNOTSUPP ; + +/* don't allow partial writes */ +if (*ppos !=0 ) +return 0 ; + + ret =ice_debugfs_parse_cmd_line (buf, count, &argv, &argc); +if (ret) + goto err_copy_from_user; + +if (argc ==2 ) { +int module, log_level; + + module =sysfs_match_string (ice_fwlog_module_string, argv[0 ]); +if (module <0 ) { +dev_info (dev,"unknown module '%s'\n" , argv[0 ]);
drivers/net/ethernet/intel/ice/ice_debugfs.c line 250
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +10
-0+ ret = -EINVAL ; + goto module_write_error; + } + + log_level =sysfs_match_string (ice_fwlog_level_string, argv[1 ]); +if (log_level <0 ) { +dev_info (dev,"unknown log level '%s'\n" , argv[1 ]); + ret = -EINVAL ; + goto module_write_error; + }
The parsing looks pretty over-engineered.
You can group the entries into structs like this:
struct something {
const char *name;
size_t sz;
enum whatever value;
};
#define FILL_IN_STH(thing) \
{ .name = thing, sz = sizeof(thing) - 1, value = ICE_..##thing,}struct something[] = {
FILL_IN_STH(ALL),
FILL_IN_STH(MNG),
...
};
but with nicer names
Then just:
for entry in array(..) {
if !strncmp(input, entry->name, entry->sz) {
str += entry->sz + 1
found = entry;
break }
}
Quoted 34 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +33
-0+static ssize_t ice_debugfs_resolution_read (struct file *filp, +char __user *buffer,size_t count, +loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct ice_hw *hw = &pf->hw; +char buff[32 ] = {}; +int status; + +/* don't allow commands if the FW doesn't support it */ +if (!ice_fwlog_supported (&pf->hw)) +return -EOPNOTSUPP ; + +snprintf (buff,sizeof (buff),"%d\n" , + hw->fwlog_cfg.log_resolution); + + status =simple_read_from_buffer (buffer, count, ppos, buff, +strlen (buff)); + +return status; +} +static ssize_t +ice_debugfs_resolution_write (struct file *filp,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct device *dev =ice_pf_to_dev (pf); +struct ice_hw *hw = &pf->hw; +ssize_t ret; +char **argv; +int argc; + +/* don't allow commands if the FW doesn't support it */
drivers/net/ethernet/intel/ice/ice_debugfs.c line 352
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +10
-0+if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + +/* don't allow partial writes */ +if (*ppos !=0 ) +return 0 ; + + ret =ice_debugfs_parse_cmd_line (buf, count, &argv, &argc); +if (ret) + goto err_copy_from_user;
And for the simple params can you try to reuse existing debugfs helpers? They can already read and write scalars, all you need is to inject yourself on the write path to update the config in the device.
Re: [PATCH net-next v4 2/5] ice: configure FW logging
Quoted 11 lines · Jakub Kicinski
drivers/net/ethernet/intel/ice/ice_debugfs.c line 148
Quoted 6 lines · On Thu, 5 Oct 2023 10:01:07 -0700 Tony Nguyen wrote:
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +6
-0+static ssize_t ice_debugfs_parse_cmd_line (const char __user *src,size_t len, +char ***argv,int *argc) +{ +char *cmd_buf, *cmd_buf_tmp; + + cmd_buf =memdup_user (src, len +1 );
memdup()with len + 1 is quite suspicious, the buffer has length of len you shouldn't copy more than that
Yeah, you're right. I'll double check that... IIRC there was a reason I did it; for some reason I think it had to do with the CRLF from the user input, but that may have been an issue in a previous iteration.
Quoted 81 lines
Quoted 48 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +47
-0+if (IS_ERR (cmd_buf)) +return PTR_ERR (cmd_buf); + cmd_buf[len] ='\0' ; + +/* the cmd_buf has a newline at the end of the command so +* remove it +*/ + cmd_buf_tmp =strchr (cmd_buf,'\n' ); +if (cmd_buf_tmp) { + *cmd_buf_tmp ='\0' ; + len = (size_t )cmd_buf_tmp - (size_t )cmd_buf +1 ; + } + + *argv =argv_split (GFP_KERNEL , cmd_buf, argc); +if (!*argv) +return -ENOMEM ; + +kfree (cmd_buf); +return 0 ; +static ssize_t +ice_debugfs_module_write (struct file *filp,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct device *dev =ice_pf_to_dev (pf); +ssize_t ret; +char **argv; +int argc; + +/* don't allow commands if the FW doesn't support it */ +if (!ice_fwlog_supported (&pf->hw)) +return -EOPNOTSUPP ; + +/* don't allow partial writes */ +if (*ppos !=0 ) +return 0 ; + + ret =ice_debugfs_parse_cmd_line (buf, count, &argv, &argc); +if (ret) + goto err_copy_from_user; + +if (argc ==2 ) { +int module, log_level; + + module =sysfs_match_string (ice_fwlog_module_string, argv[0 ]); +if (module <0 ) { +dev_info (dev,"unknown module '%s'\n" , argv[0 ]);drivers/net/ethernet/intel/ice/ice_debugfs.c line 250
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +10
-0+ ret = -EINVAL ; + goto module_write_error; + } + + log_level =sysfs_match_string (ice_fwlog_level_string, argv[1 ]); +if (log_level <0 ) { +dev_info (dev,"unknown log level '%s'\n" , argv[1 ]); + ret = -EINVAL ; + goto module_write_error; + }The parsing looks pretty over-engineered.
You can group the entries into structs like this:
struct something { const char *name; size_t sz; enum whatever value; }; #define FILL_IN_STH(thing) \ { .name = thing, sz = sizeof(thing) - 1, value = ICE_..##thing,}struct something[] = { FILL_IN_STH(ALL), FILL_IN_STH(MNG), ... };but with nicer names
Then just:
Quoted 8 lines
for entry in array(..) {
if !strncmp(input, entry->name, entry->sz) {
str += entry->sz + 1
found = entry;
break
}
}I'm probably missing something here, but I don't know if this will do what I need or not. What I have is a user passing a module name and a log level and I'm trying to match those strings and create integer values from them so I can configure the FW log for that module. I'm not seeing how the above gets me there...
I was trying to not use strncmp and instead use the built in kernel string matching functions so that's how I ended up with the code I have
Quoted 41 lines
Quoted 41 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +40
-0+static ssize_t ice_debugfs_resolution_read (struct file *filp, +char __user *buffer,size_t count, +loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct ice_hw *hw = &pf->hw; +char buff[32 ] = {}; +int status; + +/* don't allow commands if the FW doesn't support it */ +if (!ice_fwlog_supported (&pf->hw)) +return -EOPNOTSUPP ; + +snprintf (buff,sizeof (buff),"%d\n" , + hw->fwlog_cfg.log_resolution); + + status =simple_read_from_buffer (buffer, count, ppos, buff, +strlen (buff)); + +return status; +} +static ssize_t +ice_debugfs_resolution_write (struct file *filp,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct device *dev =ice_pf_to_dev (pf); +struct ice_hw *hw = &pf->hw; +ssize_t ret; +char **argv; +int argc; + +/* don't allow commands if the FW doesn't support it */ +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + +/* don't allow partial writes */ +if (*ppos !=0 ) +return 0 ; +
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c line 233
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +3
-0+ ret =ice_debugfs_parse_cmd_line (buf, count, &argv, &argc); +if (ret) + goto err_copy_from_user;And for the simple params can you try to reuse existing debugfs helpers? They can already read and write scalars, all you need is to inject yourself on the write path to update the config in the device.
I would use existing debugfs helpers, but the ones that exist look like they are really set up for variables you want to read only. We need to do some validation on the input when the user is writing and I don't see how we could do that with the existing debugfs_create_* helpers. I've looked through the kernel code at uses of debugfs_create_* and couldn't find one that was setting up a writable file, but I could have missed it.
If you can point me to some code that does what you want then I'm happy to try it, I just couldn't find anything.
Jakub Kicinski
maintainerRe: [PATCH net-next v4 2/5] ice: configure FW logging
Quoted 8 lines · On Tue, 10 Oct 2023 16:26:15 -0700 Paul M Stillwell Jr wrote:
I'm probably missing something here, but I don't know if this will do what I need or not. What I have is a user passing a module name and a log level and I'm trying to match those strings and create integer values from them so I can configure the FW log for that module. I'm not seeing how the above gets me there...
I was trying to not use strncmp and instead use the built in kernel string matching functions so that's how I ended up with the code I have
You're supposed to do very simple and targeted matching here. The cmdline parsing makes the code harder to follow.
Re: [PATCH net-next v4 2/5] ice: configure FW logging
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Tue, 10 Oct 2023 16:26:15 -0700 Paul M Stillwell Jr wrote:
I'm probably missing something here, but I don't know if this will do what I need or not. What I have is a user passing a module name and a log level and I'm trying to match those strings and create integer values from them so I can configure the FW log for that module. I'm not seeing how the above gets me there...
Quoted 5 lines
Quoted 2 lines
I was trying to not use strncmp and instead use the built in kernel string matching functions so that's how I ended up with the code I have
You're supposed to do very simple and targeted matching here. The cmdline parsing makes the code harder to follow.
OK, so what if we changed the code to create a new debugfs file entry for each module and used the dentry for ther file to know what file is being written to. Then we would only need to parse the log level. Would that be acceptable?
My confusion is around what makes the cmdline parsing harder to follow. Obviously for me it's easy :) so I am trying to understand your point of view.
Jakub Kicinski
maintainerRe: [PATCH net-next v4 2/5] ice: configure FW logging
Quoted 4 lines · On Wed, 11 Oct 2023 17:40:04 -0700 Paul M Stillwell Jr wrote:
OK, so what if we changed the code to create a new debugfs file entry for each module and used the dentry for ther file to know what file is being written to. Then we would only need to parse the log level. Would that be acceptable?
Yes, even better!
Quoted 3 lines
My confusion is around what makes the cmdline parsing harder to follow. Obviously for me it's easy :) so I am trying to understand your point of view.
Dunno how to explain it other than "took me more than 10min to understand this code and I only had 10min" :) Reviewers have their own angle when evaluation code which doesn't always align with the author's..
Re: [PATCH net-next v4 2/5] ice: configure FW logging
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Wed, 11 Oct 2023 17:40:04 -0700 Paul M Stillwell Jr wrote:
OK, so what if we changed the code to create a new debugfs file entry for each module and used the dentry for ther file to know what file is being written to. Then we would only need to parse the log level. Would that be acceptable?
Yes, even better!
Cool, I'll work on this along with the other changes we discussed.
Quoted 8 lines
Quoted 3 lines
My confusion is around what makes the cmdline parsing harder to follow. Obviously for me it's easy :) so I am trying to understand your point of view.
Dunno how to explain it other than "took me more than 10min to understand this code and I only had 10min" :) Reviewers have their own angle when evaluation code which doesn't always align with the author's..
No problem, I appreciate your feedback. Hopefully the new patches are easier to follow. I'll also try to keep your 10 minute rule in mind :)
Tony Nguyen
maintainerPATCH v4 3/5 ice: enable FW logging
In reply to Tony NguyenFrom: Paul M Stillwell Jr <[email protected]>
Once users have configured the FW logging then allow them to enable it by writing to the 'fwlog/enable' file. The file accepts a boolean value (0 or 1) where 1 means enable FW logging and 0 means disable FW logging. The user can read the 'fwlog/enable' file to see whether logging is enabled or not. Reading the actual data is a separate patch.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 3 + drivers/net/ethernet/intel/ice/ice_common.c | 1 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 115 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.c | 91 ++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 3 + 5 files changed, 213 insertions(+)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +3 -0
@@ -2330,6 +2330,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 {
@@ -2338,6 +2339,7 @@ struct ice_aqc_fw_log {#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;
@@ -2656,6 +2658,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_common.c +1 -0
@@ -1108,6 +1108,7 @@ void ice_deinit_hw(struct ice_hw *hw)ice_free_hw_tbls (hw);mutex_destroy (&hw->tnl_lock); +ice_fwlog_deinit (hw);ice_destroy_all_ctrlq (hw);/* Clear VSI contexts if not already cleared */
drivers/net/ethernet/intel/ice/ice_debugfs.c +115 -0
127 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.c +91 -0
109 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.h +3 -0
@@ -50,6 +50,9 @@ 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); +void ice_fwlog_deinit (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 · 1 line
2.38.1
Tony Nguyen
maintainerPATCH v4 4/5 ice: add ability to read FW log data and configure the number of log buffers
In reply to Tony NguyenFrom: Paul M Stillwell Jr <[email protected]>
Once logging is enabled the user should read the data from the 'data' file. The data is in the form of a binary blob that can be sent to Intel for decoding. To read the data use a command like:
cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data > log_data.bin
If the user wants to clear the FW log data that has been stored in the driver then they can write a 0 to the 'data' file and that will clear the data.
In addition to being able to read the data the user can configure how many buffers can be used to store the FW logs within the driver. This allows the user to increase/decrease the number of buffers used based on the users situation. The buffers are used as a ring so if the driver runs out of buffers then it will overwrite data. To change the number of buffers the user can write to the 'nr_buffs' file like this:
echo 128 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/nr_buffs
The value written to the file must be a power of 2 value between 1 (not recommended) and 512.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 242 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.c | 130 +++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.h | 20 ++ drivers/net/ethernet/intel/ice/ice_main.c | 29 +++ drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 423 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2 -0
@@ -2332,6 +2332,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;
@@ -2660,6 +2661,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 +242 -0
254 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.c +129 -1
161 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.h +20 -0
@@ -47,12 +47,32 @@ struct ice_fwlog_cfg {u16 log_resolution; }; +struct ice_fwlog_data { +u16 data_size; +u8 *data; +}; + +struct ice_fwlog_ring { +struct ice_fwlog_data *rings; +u16 size; +u16 head; +u16 tail; +}; + +#define ICE_FWLOG_RING_SIZE_DFLT 256 +#define ICE_FWLOG_RING_SIZE_MAX 512 + +bool ice_fwlog_ring_full (struct ice_fwlog_ring *rings); +bool ice_fwlog_ring_empty (struct ice_fwlog_ring *rings); +void ice_fwlog_ring_increment (u16 *item,u16 size);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);void ice_fwlog_deinit (struct ice_hw *hw); +void ice_fwlog_deinit (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); +void ice_fwlog_realloc_rings (struct ice_hw *hw,int num_rings);#endif /* _ICE_FWLOG_H_ */
drivers/net/ethernet/intel/ice/ice_main.c +29 -0
@@ -1250,6 +1250,32 @@ ice_handle_link_event(struct ice_pf *pf, struct ice_rq_event_info *event)return status; } +/** +* ice_get_fwlog_data - copy the FW log data from ARQ event +* @pf: PF that the FW log event is associated with +* @event: event structure containing FW log data +*/ +static void +ice_get_fwlog_data (struct ice_pf *pf,struct ice_rq_event_info *event) +{ +struct ice_fwlog_data *fwlog; +struct ice_hw *hw = &pf->hw; + + fwlog = &hw->fwlog_ring.rings[hw->fwlog_ring.tail]; + +memset (fwlog->data,0 ,PAGE_SIZE ); + fwlog->data_size =le16_to_cpu (event->desc.datalen); + +memcpy (fwlog->data, event->msg_buf, fwlog->data_size); +ice_fwlog_ring_increment (&hw->fwlog_ring.tail, hw->fwlog_ring.size); + +if (ice_fwlog_ring_full (&hw->fwlog_ring)) { +/* the rings are full so bump the head to create room */ +ice_fwlog_ring_increment (&hw->fwlog_ring.head, + hw->fwlog_ring.size); + } +} +/** * ice_aq_prep_for_event - Prepare to wait for an AdminQ event from firmware * @pf: pointer to the PF private structure
@@ -1531,6 +1557,9 @@ 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_logs_event: +ice_get_fwlog_data (pf, &event); +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 +1 -0
@@ -873,6 +873,7 @@ struct ice_hw {struct ice_fwlog_cfg fwlog_cfg;bool fwlog_supported;/* does hardware support FW logging? */ +struct ice_fwlog_ring fwlog_ring;/* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL * register. Used for determining the ITR/INTRL granularity during
Signature · 1 line
2.38.1
Tony Nguyen
maintainerPATCH v4 5/5 ice: add documentation for FW logging
In reply to Tony NguyenFrom: Paul M Stillwell Jr <[email protected]>
Add documentation for FW logging in Documentation/networking/device-drivers/ethernet/intel/ice.rst
--- .../device_drivers/ethernet/intel/ice.rst | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+)
Documentation/networking/device_drivers/ethernet/intel/ice.rst +117 -0
@@ -895,6 +895,123 @@ 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. + +Module configuration +~~~~~~~~~~~~~~~~~~~~ +To see the status of FW logging, read the 'fwlog/modules' file like this:: + + # cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +To configure FW logging, write to the 'fwlog/modules' file like this:: + + # echo <fwlog_event> <fwlog_level> > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +where + +* fwlog_level is a name as described below. Each level includes the + messages from the previous/lower level + + * NONE + * ERROR + * WARNING + * NORMAL + * VERBOSE + +* fwlog_event is a name that represents the module to receive events for. The + module names are + + * GENERAL + * CTRL + * LINK + * LINK_TOPO + * DNL + * I2C + * SDP + * MDIO + * ADMINQ + * HDMA + * LLDP + * DCBX + * DCB + * XLR + * NVM + * AUTH + * VPD + * IOSF + * PARSER + * SW + * SCHEDULER + * TXQ + * RSVD + * POST + * WATCHDOG + * TASK_DISPATCH + * MNG + * SYNCE + * HEALTH + * TSDRV + * PFREG + * MDLVER + * ALL + +The name ALL is special and specifies setting all of the modules to the +specified fwlog_level. + +Example usage to configure the modules:: + + # echo LINK VERBOSE > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +Enabling FW log +~~~~~~~~~~~~~~~ +Once the desired modules are configured the user enables logging. To do +this the user can write a 1 (enable) or 0 (disable) to 'fwlog/enable'. An +example is:: + + # echo 1 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/enable + +Retrieving FW log data +~~~~~~~~~~~~~~~~~~~~~~ +The FW log data can be retrieved by reading from 'fwlog/data'. The user can +write to 'fwlog/data' to clear the data. The data can only be cleared when FW +logging is disabled. The FW log data is a binary file that is sent to Intel and +used to help debug user issues. + +An example to read the data is:: + + # cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data > fwlog.bin + +An example to clear the data is:: + + # echo 0 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data + +Changing how often the log events are sent to the driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver receives FW log data from the Admin Receive Queue (ARQ). The +frequency that the FW sends the ARQ events can be configured by writing to +'fwlog/resolution'. 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 see what the value is configured to by reading +'fwlog/resolution'. An example to set the value is:: + + # echo 50 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/resolution + +Configuring the number of buffers used to store FW log data +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver stores FW log data in a ring within the driver. The default size of +the ring is 256 4K buffers. Some use cases may require more or less data so +the user can change the number of buffers that are allocated for FW log data. +To change the number of buffers write to 'fwlog/nr_buffs'. The value must be one +of: 64, 128, 256, or 512. FW logging must be disabled to change the value. An +example of changing the value is:: + + # echo 128 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/nr_buffs + + Performance Optimization ======================== Driver defaults are meant to fit a wide variety of workloads, but if further
Signature · 1 line
2.38.1
Jakub Kicinski
maintainerRe: [PATCH net-next v4 5/5] ice: add documentation for FW logging
Quoted 4 lines · On Thu, 5 Oct 2023 10:01:10 -0700 Tony Nguyen wrote:
From: Paul M Stillwell Jr <[email protected]>
Add documentation for FW logging in
Documentation/networking/device-drivers/ethernet/intel/ice.rst
Wrong spelling, I think, because no such file.
Quoted 5 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>Signed-off-by Tony Nguyen <[email protected]>+Firmware (FW) logging
+---------------------
I think you need empty lines after the headers.
Did you try to build this documentation and checked the warnings?
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 902
Quoted 3 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +3
-0+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.
Odd phrasing - "in order to work it needs to be supported"
also NVM == non-volatile memory, you mean the logging goes into NVM or NVM as in FW in the NVM needs to support it?
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+Module configuration +~~~~~~~~~~~~~~~~~~~~ +To see the status of FW logging, read the 'fwlog/modules' file like this:: + + # cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +To configure FW logging, write to the 'fwlog/modules' file like this:: + + # echo <fwlog_event> <fwlog_level> > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules +
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 923
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+where + +* fwlog_level is a name as described below. Each level includes the + messages from the previous/lower level + + * NONE + * ERROR + * WARNING + * NORMAL + * VERBOSE
Is this going to give us a nice list when we render the docs? White space looks odd.
Quoted 41 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +41
-0+* fwlog_event is a name that represents the module to receive events for. The + module names are + + * GENERAL + * CTRL + * LINK + * LINK_TOPO + * DNL + * I2C + * SDP + * MDIO + * ADMINQ + * HDMA + * LLDP + * DCBX + * DCB + * XLR + * NVM + * AUTH + * VPD + * IOSF + * PARSER + * SW + * SCHEDULER + * TXQ + * RSVD + * POST + * WATCHDOG + * TASK_DISPATCH + * MNG + * SYNCE + * HEALTH + * TSDRV + * PFREG + * MDLVER + * ALL + +The name ALL is special and specifies setting all of the modules to the +specified fwlog_level. + +Example usage to configure the modules::
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 975
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+ + # echo LINK VERBOSE > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +Enabling FW log +~~~~~~~~~~~~~~~ +Once the desired modules are configured the user enables logging. To do +this the user can write a 1 (enable) or 0 (disable) to 'fwlog/enable'. An +example is:: + + # echo 1 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/enable
Hm, so we "select" the module and then enable / disable?
It'd feel more natural to steal the +/- thing from dynamic printing. To enable:
# echo '+LINK VERBOSE' > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/active
To disable:
# echo '-LINK VERBOSE' > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/active
No?
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please
Quoted 5 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +5
-0+Retrieving FW log data +~~~~~~~~~~~~~~~~~~~~~~ +The FW log data can be retrieved by reading from 'fwlog/data'. The user can +write to 'fwlog/data' to clear the data. The data can only be cleared when FW +logging is disabled.
Oh, now it sounds like only one thing can be enabled at a time. Can you clarify?
Quoted 11 lines
The FW log data is a binary file that is sent to Intel and
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+used to help debug user issues. + +An example to read the data is:: + + # cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data > fwlog.bin + +An example to clear the data is:: + + # echo 0 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data +
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 1001
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+Changing how often the log events are sent to the driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver receives FW log data from the Admin Receive Queue (ARQ). The +frequency that the FW sends the ARQ events can be configured by writing to +'fwlog/resolution'. 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 see what the value is configured to by reading +'fwlog/resolution'. An example to set the value is:: + + # echo 50 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/resolution
Resolution doesn't sound quite right, batch_size maybe?
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 1012
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+Configuring the number of buffers used to store FW log data +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver stores FW log data in a ring within the driver. The default size of +the ring is 256 4K buffers. Some use cases may require more or less data so +the user can change the number of buffers that are allocated for FW log data. +To change the number of buffers write to 'fwlog/nr_buffs'. The value must be one +of: 64, 128, 256, or 512. FW logging must be disabled to change the value. An +example of changing the value is:: + + # echo 128 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/nr_buffs
Why 4K? The number of buffers is irrelevant to the user, why not let the user configure the size in bytes (which his how much DRAM the driver will hold hostage)?
Re: [PATCH net-next v4 5/5] ice: add documentation for FW logging
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 5 Oct 2023 10:01:10 -0700 Tony Nguyen wrote:
From: Paul M Stillwell Jr <[email protected]>
Add documentation for FW logging in
Documentation/networking/device-drivers/ethernet/intel/ice.rstWrong spelling, I think, because no such file.
Sorry, hyphen vs underscore issue, will fix.
Quoted 9 lines
Quoted 5 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>Signed-off-by Tony Nguyen <[email protected]>+Firmware (FW) logging
+---------------------I think you need empty lines after the headers.
Did you try to build this documentation and checked the warnings?
I believe this to be correct. It is the same as the section above it for GNSS and it looks correct when complete. I did run 'make htmldocs' on this and I don't get any errors or warnings and the page looks correct.
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 902
Quoted 3 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +3
-0+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.Odd phrasing - "in order to work it needs to be supported"
also NVM == non-volatile memory, you mean the logging goes into NVM or NVM as in FW in the NVM needs to support it?
Yeah, I can see it as oddly phrased. What I'm trying to say is that the NVM image on the NIC has to support FW logging and if it doesn't then the 'fwlog' directory will not be created. I'll take another run at it to try to make it less confusing.
Quoted 15 lines
Quoted 15 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +15
-0+Module configuration +~~~~~~~~~~~~~~~~~~~~ +To see the status of FW logging, read the 'fwlog/modules' file like this:: + + # cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +To configure FW logging, write to the 'fwlog/modules' file like this:: + + # echo <fwlog_event> <fwlog_level> > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +where + +* fwlog_level is a name as described below. Each level includes the + messages from the previous/lower level +
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 923
Quoted 5 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +5
-0+ * NONE + * ERROR + * WARNING + * NORMAL + * VERBOSEIs this going to give us a nice list when we render the docs? White space looks odd.
Yes, it does give a nice list
Quoted 57 lines
Quoted 41 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +41
-0+* fwlog_event is a name that represents the module to receive events for. The + module names are + + * GENERAL + * CTRL + * LINK + * LINK_TOPO + * DNL + * I2C + * SDP + * MDIO + * ADMINQ + * HDMA + * LLDP + * DCBX + * DCB + * XLR + * NVM + * AUTH + * VPD + * IOSF + * PARSER + * SW + * SCHEDULER + * TXQ + * RSVD + * POST + * WATCHDOG + * TASK_DISPATCH + * MNG + * SYNCE + * HEALTH + * TSDRV + * PFREG + * MDLVER + * ALL + +The name ALL is special and specifies setting all of the modules to the +specified fwlog_level. + +Example usage to configure the modules::Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 975
Quoted 10 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +10
-0+ + # echo LINK VERBOSE > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules + +Enabling FW log +~~~~~~~~~~~~~~~ +Once the desired modules are configured the user enables logging. To do +this the user can write a 1 (enable) or 0 (disable) to 'fwlog/enable'. An +example is:: + + # echo 1 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/enableHm, so we "select" the module and then enable / disable?
It'd feel more natural to steal the +/- thing from dynamic printing. To enable:
Quoted 8 lines
# echo '+LINK VERBOSE' > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/activeTo disable:
# echo '-LINK VERBOSE' > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/activeNo?
I like this idea, but not sure if it will work or not for us. What I'm trying to do is reduce the number of AQ commands we send to the FW when configuring/enabling logging.
What normally happens is the user sets multiple different modules up with different log values so my initial thought is to allow the user to do all the configuration first and then 'enable' that configuration. This way there is only 1 AQ write to the FW instead of a bunch of them and we know that once the logging is 'enabled' then the data we get from the FW is the data that we expect to see.
If we enable each module individually then we are going to get data coming from the FW as each module gets enabled. That can get confusing to the FW team as they look at the log data because they may not see all the events they expect to see in any given time because the event wasn't enabled.
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please
Quoted 5 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +5
-0+Retrieving FW log data +~~~~~~~~~~~~~~~~~~~~~~ +The FW log data can be retrieved by reading from 'fwlog/data'. The user can +write to 'fwlog/data' to clear the data. The data can only be cleared when FW +logging is disabled.Oh, now it sounds like only one thing can be enabled at a time. Can you clarify?
What I'm trying to describe here is a mechanism to read all the data (whatever modules have been enabled) as it's coming in and to also be able to clear the data in case the user wants to start fresh (by writing 0 to the file). Does that make sense? I probably wasn't clear in the previous section that the user can enable many modules at the same time.
Quoted 15 lines
Quoted 15 lines
The FW log data is a binary file that is sent to Intel and
Documentation/networking/device_drivers/ethernet/intel/ice.rst +14
-0+used to help debug user issues. + +An example to read the data is:: + + # cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data > fwlog.bin + +An example to clear the data is:: + + # echo 0 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data + +Changing how often the log events are sent to the driver +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver receives FW log data from the Admin Receive Queue (ARQ). The +frequency that the FW sends the ARQ events can be configured by writing to
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 1001
Quoted 6 lines
+'fwlog/resolution'. The range is 1-128 (1 means push every log message, 128
Documentation/networking/device_drivers/ethernet/intel/ice.rst +5
-0+means push only when the max AQ command buffer is full). The suggested value is +10. The user can see what the value is configured to by reading +'fwlog/resolution'. An example to set the value is:: + + # echo 50 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/resolutionResolution doesn't sound quite right,
batch_sizemaybe?
I agree, resolution is what the FW team uses, but I'll change this to some other name
Quoted 6 lines
Quoted 6 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +6
-0+Configuring the number of buffers used to store FW log data +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver stores FW log data in a ring within the driver. The default size of +the ring is 256 4K buffers. Some use cases may require more or less data so +the user can change the number of buffers that are allocated for FW log data. +To change the number of buffers write to 'fwlog/nr_buffs'. The value must be one
Quoted 8 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please · line 1012
Quoted 4 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +4
-0+of: 64, 128, 256, or 512. FW logging must be disabled to change the value. An +example of changing the value is:: + + # echo 128 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/nr_buffsWhy 4K? The number of buffers is irrelevant to the user, why not let the user configure the size in bytes (which his how much DRAM the driver will hold hostage)?
I'm trying to keep the numbers small for the user :). I could say 1048576 bytes (256 x 4096), but those kinds of numbers get unwieldy to a user (IMO).
The FW logs generate a LOT of data depending on what modules are enabled so we typically need a lot of buffers to handle them.
In the past we have tried to use the syslog mechanism, but we generate SO much data that we overwhelm that and lose data. That's why the idea of using static buffers is appealing to us. We could still overrun the buffers, but at least we will have contiguous data. The problem then becomes one of allocating enough space for what the user is trying to catch instead of trying to start/stop logging and hoping you get all the events in the log.
I can drop the mention of 4K buffers in the documentation. Or we could use terms like 1M, 2M, 512K, et al. That would require string parsing in the driver though and I'm trying to avoid that if possible. What do you think?
Jakub Kicinski
maintainerRe: [PATCH net-next v4 5/5] ice: add documentation for FW logging
Quoted 10 lines · On Tue, 10 Oct 2023 16:00:13 -0700 Paul M Stillwell Jr wrote:
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please
Quoted 5 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +5
-0+Retrieving FW log data +~~~~~~~~~~~~~~~~~~~~~~ +The FW log data can be retrieved by reading from 'fwlog/data'. The user can +write to 'fwlog/data' to clear the data. The data can only be cleared when FW +logging is disabled.Oh, now it sounds like only one thing can be enabled at a time. Can you clarify?
Quoted 4 lines
What I'm trying to describe here is a mechanism to read all the data (whatever modules have been enabled) as it's coming in and to also be able to clear the data in case the user wants to start fresh (by writing 0 to the file). Does that make sense?
Yes that part does.
Quoted 2 lines
I probably wasn't clear in the
previous section that the user can enable many modules at the same time.
Probably best if you describe enabling of multiple modules in the example. I'm not sure how one disables a module with the current API.
Quoted 7 lines
Quoted 3 lines
Why 4K? The number of buffers is irrelevant to the user, why not let the user configure the size in bytes (which his how much DRAM the driver will hold hostage)?
I'm trying to keep the numbers small for the user :). I could say 1048576 bytes (256 x 4096), but those kinds of numbers get unwieldy to a user (IMO).
echo $((256 * 4096)) >> $the_file
But also...
Quoted 11 lines
The FW logs generate a LOT of data depending on what modules are enabled so we typically need a lot of buffers to handle them.
In the past we have tried to use the syslog mechanism, but we generate SO much data that we overwhelm that and lose data. That's why the idea of using static buffers is appealing to us. We could still overrun the buffers, but at least we will have contiguous data. The problem then becomes one of allocating enough space for what the user is trying to catch instead of trying to start/stop logging and hoping you get all the events in the log.
Quoted 4 lines
I can drop the mention of 4K buffers in the documentation. Or we could use terms like 1M, 2M, 512K, et al. That would require string parsing in the driver though and I'm trying to avoid that if possible. What do you think?
.. I thought such helpers already existed.
Re: [PATCH net-next v4 5/5] ice: add documentation for FW logging
Quoted 16 lines · Jakub Kicinski
Quoted 10 lines · On Tue, 10 Oct 2023 16:00:13 -0700 Paul M Stillwell Jr wrote:
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst driver writes raw bytes by the GNSS object to the receiver through i2c. Please
Quoted 5 lines
Documentation/networking/device_drivers/ethernet/intel/ice.rst +5
-0+Retrieving FW log data +~~~~~~~~~~~~~~~~~~~~~~ +The FW log data can be retrieved by reading from 'fwlog/data'. The user can +write to 'fwlog/data' to clear the data. The data can only be cleared when FW +logging is disabled.Oh, now it sounds like only one thing can be enabled at a time. Can you clarify?
Quoted 4 lines
What I'm trying to describe here is a mechanism to read all the data (whatever modules have been enabled) as it's coming in and to also be able to clear the data in case the user wants to start fresh (by writing 0 to the file). Does that make sense?
Quoted 8 lines
Yes that part does.
Quoted 2 lines
I probably wasn't clear in the
previous section that the user can enable many modules at the same time.Probably best if you describe enabling of multiple modules in the example. I'm not sure how one disables a module with the current API.
Will do
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Why 4K? The number of buffers is irrelevant to the user, why not let the user configure the size in bytes (which his how much DRAM the driver will hold hostage)?
I'm trying to keep the numbers small for the user :). I could say 1048576 bytes (256 x 4096), but those kinds of numbers get unwieldy to a user (IMO).
echo $((256 * 4096)) >> $the_file
I'll change it to be a bytes of data to store instead of number of buffers
Quoted 13 lines
But also...
Quoted 11 lines
The FW logs generate a LOT of data depending on what modules are enabled so we typically need a lot of buffers to handle them.
In the past we have tried to use the syslog mechanism, but we generate SO much data that we overwhelm that and lose data. That's why the idea of using static buffers is appealing to us. We could still overrun the buffers, but at least we will have contiguous data. The problem then becomes one of allocating enough space for what the user is trying to catch instead of trying to start/stop logging and hoping you get all the events in the log.
Quoted 6 lines
Quoted 4 lines
I can drop the mention of 4K buffers in the documentation. Or we could use terms like 1M, 2M, 512K, et al. That would require string parsing in the driver though and I'm trying to avoid that if possible. What do you think?
.. I thought such helpers already existed.
If you are referring to helpers to handle 1M et al, I couldn't find anything. I found the kstrto<x> stuff, but that doesn't handle this case correctly I don't think.