add v2 FW logging for ice driver
Subsystems (2)
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 controls knobs to get the exact data out of the FW for debugging.
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 new device parameters are added:
- fwlog_supported (read-only): does the FW support FW logging
- fwlog_enabled (read/write): is FW logging currently running
- fwlog_level (read/write): the log level enabled, valid values are 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_resolution (read/write): 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.
This patch series adds the following set of devlink commands:
devlink dev param set <pci dev> name fwlog_enabled value <true/false> cmode runtime devlink dev param set <pci dev> name fwlog_level value <0-4> cmode runtime devlink dev param set <pci dev> name fwlog_resolution value <1-128> cmode runtime
Paul M Stillwell Jr (5):
ice: remove FW logging code
ice: enable devlink to check FW logging status
ice: add ability to query/set FW log level and resolution
ice: disable FW logging on driver unload
ice: use debugfs to output FW log data
drivers/net/ethernet/intel/ice/Makefile | 4 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 164 ++++---- drivers/net/ethernet/intel/ice/ice_common.c | 218 +--------- drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 +++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 205 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 394 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 56 +++ drivers/net/ethernet/intel/ice/ice_main.c | 99 ++++- drivers/net/ethernet/intel/ice/ice_type.h | 23 +- 10 files changed, 980 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
PATCH 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.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 78 ------- drivers/net/ethernet/intel/ice/ice_common.c | 218 ------------------ drivers/net/ethernet/intel/ice/ice_main.c | 3 - drivers/net/ethernet/intel/ice/ice_type.h | 20 -- 4 files changed, 319 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0 -78
@@ -1980,78 +1980,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 {
@@ -2211,8 +2139,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;
@@ -2399,10 +2325,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_main.c +0 -3
@@ -1486,9 +1486,6 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)if (!ice_is_malicious_vf (pf, &event, i, pending))ice_vc_process_vf_msg (pf, &event);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
@@ -728,24 +728,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
PATCH 2/5 ice: enable devlink to check FW logging status
In reply to Paul M Stillwell JrCustomers want the ability to debug FW issues by retrieving the FW logs from the E8xx devices. Enable devlink to query the driver to see if the NVM image allows FW logging and to see if FW logging is currently running. The set command is not supported at this time.
This is the beginning of the v2 for FW logging.
pick bfdfb2dc6192 ice: add ability to query/set FW log level and resolution
--- drivers/net/ethernet/intel/ice/Makefile | 3 +- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 82 ++++++++++++ drivers/net/ethernet/intel/ice/ice_common.c | 2 + drivers/net/ethernet/intel/ice/ice_devlink.c | 73 ++++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 117 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 51 ++++++++ drivers/net/ethernet/intel/ice/ice_type.h | 4 + 7 files changed, 330 insertions(+), 2 deletions(-) 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 +2 -1
@@ -32,7 +32,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 \
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +82 -0
100 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_common.c +2 -0
@@ -879,6 +879,8 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_cqinit; +ice_fwlog_set_support_ena (hw); + status =ice_clear_pf_cfg (hw);if (status) goto err_unroll_cqinit;
drivers/net/ethernet/intel/ice/ice_devlink.c +72 -1
91 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.c new file +117 -0
117 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.h new file +51 -0
51 lines not on this page · raw message
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) {
@@ -860,6 +861,9 @@ struct ice_hw {u8 fw_patch;/* firmware patch version */ u32 fw_build;/* firmware build number */ +bool fwlog_support_ena;/* does hardware support FW logging? */ +bool fwlog_ena;/* currently 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
Tony Nguyen
maintainerRe: [Intel-wired-lan] [PATCH net-next 2/5] ice: enable devlink to check FW logging status
Quoted 77 lines · Paul M Stillwell Jr
Customers want the ability to debug FW issues by retrieving the FW logs from the E8xx devices. Enable devlink to query the driver to see if the NVM image allows FW logging and to see if FW logging is currently running. The set command is not supported at this time.
This is the beginning of the v2 for FW logging.
Signed-off-by Paul M Stillwell Jr <[email protected]>pick
bfdfb2dc6192ice: add ability to query/set FW log level and resolution--- drivers/net/ethernet/intel/ice/Makefile | 3 +- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 82 ++++++++++++ drivers/net/ethernet/intel/ice/ice_common.c | 2 + drivers/net/ethernet/intel/ice/ice_devlink.c | 73 ++++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 117 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 51 ++++++++ drivers/net/ethernet/intel/ice/ice_type.h | 4 + 7 files changed, 330 insertions(+), 2 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_fwlog.ccreate mode 100644drivers/net/ethernet/intel/ice/ice_fwlog.hdrivers/net/ethernet/intel/ice/Makefile +2
-1@@ -32,7 +32,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 \drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +32
-0@@ -2065,6 +2065,86 @@ struct ice_aqc_event_lan_overflow {u8 reserved[8 ]; }; +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_XLR , +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_SYNCE , +ICE_AQC_FW_LOG_ID_HEALTH , +ICE_AQC_FW_LOG_ID_TSDRV , +ICE_AQC_FW_LOG_ID_PFREG ,
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_event_lan_overflow { · line 2109
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +10
-0+ICE_AQC_FW_LOG_ID_MDLVER , + ICE_AQC_FW_LOG_ID_MAX, +}; + +/* Set FW Logging configuration (indirect 0xFF30) +* Register for FW Logging (indirect 0xFF31) +* Query FW Logging (indirect 0xFF32) +* FW Log Event (indirect 0xFF33) +* Get FW Log (indirect 0xFF34) +* Clear FW Log (indirect 0xFF35)
I don't think I saw the 0xFF35 op added anywhere. Also, the 0xFF34 looks unused (more on that later in the series)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_event_lan_overflow { · line 2119
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +10
-0+*/ +struct ice_aqc_fw_log { +u8 cmd_flags; +#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) +#define ICE_AQC_FW_LOG_PERSISTENT BIT(0)
Please add a newline to separate the defines and the member they are associated with.
Also, I don't believe I'm seeing there persistent define being used...
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_event_lan_overflow { · line 2121
Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2
-0+u8 rsp_flag; +#define ICE_AQC_FW_LOG_MORE_DATA BIT(1)
or this one.
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h struct ice_aqc_event_lan_overflow { · line 2126
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +5
-0+__le16 fw_rt_msb; +union { +struct { +__le32 fw_rt_lsb; + } sync;
I don't think I saw sync used either.
Quoted 314 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +23
-0+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; +__le32 addr_high; +__le32 addr_low; +}; + +/* Response Buffer for: +* Set Firmware Logging Configuration (0xFF30) +* Query FW Logging (0xFF32) +*/ +struct ice_aqc_fw_log_cfg_resp { +__le16 module_identifier; +u8 log_level; +u8 rsvd0; +}; +/** * struct ice_aq_desc - Admin Queue (AQ) descriptor * @flags: ICE_AQ_FLAG_* flags @@ -2141,6 +2221,7 @@ struct ice_aq_desc {struct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;struct ice_aqc_download_pkg download_pkg;struct ice_aqc_driver_shared_params drv_shared_params; +struct ice_aqc_fw_log fw_log;struct ice_aqc_set_mac_lb set_mac_lb;struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;struct ice_aqc_set_mac_cfg set_mac_cfg;@@ -2325,6 +2406,7 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow =0x1001 , + ice_aqc_opc_fw_logs_query = 0xFF32, };#endif /* _ICE_ADMINQ_CMD_H_ */ drivers/net/ethernet/intel/ice/ice_common.c +2
-0@@ -879,6 +879,8 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_cqinit; +ice_fwlog_set_support_ena (hw); + status =ice_clear_pf_cfg (hw);if (status) goto err_unroll_cqinit;drivers/net/ethernet/intel/ice/ice_devlink.c +72
-1@@ -1484,6 +1484,56 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,return 0 ; } +enum ice_devlink_param_id { +ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX , +ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , +ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +}; + +static int +ice_devlink_fwlog_supported_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + + ctx->val.vbool =ice_fwlog_supported (&pf->hw); +return 0 ; +} + +static int +ice_devlink_fwlog_supported_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +/* set operation is unsupported */ +return -EOPNOTSUPP ; +} + +static int +ice_devlink_fwlog_enabled_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + + ctx->val.vbool = pf->hw.fwlog_ena; +return 0 ; +} + +static int +ice_devlink_fwlog_enabled_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +/* set operation is unsupported at this time */ +return -EOPNOTSUPP ; +} +static const struct devlink_param ice_devlink_params[] = { DEVLINK_PARAM_GENERIC(ENABLE_ROCE, BIT(DEVLINK_PARAM_CMODE_RUNTIME), ice_devlink_enable_roce_get,@@ -1500,7 +1550,18 @@ static const struct devlink_param ice_devlink_params[] = { ice_devlink_txbalance_get, ice_devlink_txbalance_set, ice_devlink_txbalance_validate), - +DEVLINK_PARAM_DRIVER (ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , +"fwlog_supported" ,DEVLINK_PARAM_TYPE_BOOL , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + ice_devlink_fwlog_supported_get, + ice_devlink_fwlog_supported_set, +NULL ), +DEVLINK_PARAM_DRIVER (ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +"fwlog_enabled" ,DEVLINK_PARAM_TYPE_BOOL , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + ice_devlink_fwlog_enabled_get, + ice_devlink_fwlog_enabled_set, + NULL), };static void ice_devlink_free (void *devlink_ptr)@@ -1596,6 +1657,16 @@ int ice_devlink_register_params(struct ice_pf *pf)DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE , value); + value.vbool = false; +devlink_param_driverinit_value_set (devlink, +ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , + value); + + value.vbool = false; +devlink_param_driverinit_value_set (devlink, +ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , + value); +return 0 ; }drivers/net/ethernet/intel/ice/ice_fwlog.c new file +117
-0@@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, Intel Corporation. */ + +#include "ice_common.h" +#include "ice_fwlog.h" + +/** +* ice_fwlog_supported - Cached for whether FW supports FW logging or not +* @hw: pointer to the HW structure +* +* This will always return false if called before ice_init_hw(), so it must be +* called after ice_init_hw(). +*/ +bool ice_fwlog_supported (struct ice_hw *hw) +{ +return hw->fwlog_support_ena; +} + +/** +* ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32) +* @hw: pointer to the HW structure +* @cfg: firmware logging configuration to populate +*/ +static int +ice_aq_fwlog_get (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ +struct ice_aqc_fw_log_cfg_resp *fw_modules; +struct ice_aqc_fw_log *cmd; +struct ice_aq_desc desc; +u16 i, module_id_cnt; +int status; +void *buf; + +memset (cfg,0 ,sizeof (*cfg)); + + buf =kzalloc (ICE_AQ_MAX_BUF_LEN ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_fw_logs_query); + cmd = &desc.params.fw_log; + + cmd->cmd_flags =ICE_AQC_FW_LOG_AQ_QUERY ; + + status =ice_aq_send_cmd (hw, &desc, buf,ICE_AQ_MAX_BUF_LEN ,NULL ); +if (status) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Failed to get FW log configuration\n" ); + goto status_out; + } + + module_id_cnt =le16_to_cpu (cmd->ops.cfg.mdl_cnt); +if (module_id_cnt <ICE_AQC_FW_LOG_ID_MAX ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"FW returned less than the expected number of FW log module IDs\n" ); + }else { +if (module_id_cnt >ICE_AQC_FW_LOG_ID_MAX ) +ice_debug (hw,ICE_DBG_FW_LOG ,"FW returned more than expected number of FW log module IDs, setting module_id_cnt to software expected max %u\n" , +ICE_AQC_FW_LOG_ID_MAX ); + module_id_cnt =ICE_AQC_FW_LOG_ID_MAX ; + } + + cfg->log_resolution =le16_to_cpu (cmd->ops.cfg.log_resolution); +if (cmd->cmd_flags &ICE_AQC_FW_LOG_CONF_AQ_EN ) + cfg->options |=ICE_FWLOG_OPTION_ARQ_ENA ; +if (cmd->cmd_flags &ICE_AQC_FW_LOG_CONF_UART_EN ) + cfg->options |=ICE_FWLOG_OPTION_UART_ENA ; +if (cmd->cmd_flags &ICE_AQC_FW_LOG_QUERY_REGISTERED ) + cfg->options |=ICE_FWLOG_OPTION_IS_REGISTERED ; + + fw_modules = (struct ice_aqc_fw_log_cfg_resp *)buf; + +for (i =0 ; i < module_id_cnt; i++) { +struct ice_aqc_fw_log_cfg_resp *fw_module = &fw_modules[i]; + + cfg->module_entries[i].module_id = +le16_to_cpu (fw_module->module_identifier); + cfg->module_entries[i].log_level = fw_module->log_level; + } + +status_out: +kfree (buf); +return status; +} + +/** +* ice_fwlog_set_support_ena - Set if FW logging is supported by FW +* @hw: pointer to the HW struct +* +* If FW returns success to the ice_aq_fwlog_get call then it supports FW +* logging, else it doesn't. Set the fwlog_support_ena flag accordingly. +* +* This function is only meant to be called during driver init to determine if +* the FW support FW logging. +*/ +void ice_fwlog_set_support_ena (struct ice_hw *hw) +{ +struct ice_fwlog_cfg *cfg; +int status; + + hw->fwlog_support_ena = false; + + cfg =kzalloc (sizeof (*cfg),GFP_KERNEL ); +if (!cfg) +return ; + +/* don't call ice_fwlog_get() because that would overwrite the cached +* configuration from the call to ice_fwlog_init(), which is expected to +* be called prior to this function +*/ + status =ice_aq_fwlog_get (hw, cfg); +if (status) +ice_debug (hw,ICE_DBG_FW_LOG ,"ice_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n" , + status); +else + hw->fwlog_support_ena = true; + +kfree (cfg); +}drivers/net/ethernet/intel/ice/ice_fwlog.h new file +34
-0@@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2018-2021, Intel Corporation. */ + +#ifndef _ICE_FWLOG_H_ +#define _ICE_FWLOG_H_ +#include "ice_adminq_cmd.h" + +struct ice_hw; + +/* Only a single log level should be set and all log levels under the set value + * are enabled, e.g. if log level is set to ICE_FW_LOG_LEVEL_VERBOSE, then all + * other log levels are included (except ICE_FW_LOG_LEVEL_NONE) + */ +enum ice_fwlog_level { + ICE_FWLOG_LEVEL_NONE = 0, + ICE_FWLOG_LEVEL_ERROR = 1, + ICE_FWLOG_LEVEL_WARNING = 2, + ICE_FWLOG_LEVEL_NORMAL = 3, + ICE_FWLOG_LEVEL_VERBOSE = 4, + ICE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */ +}; + +struct ice_fwlog_module_entry { + /* module ID for the corresponding firmware logging event */ + u16 module_id; + /* verbosity level for the module_id */ + u8 log_level; +}; + +struct ice_fwlog_cfg { + /* list of modules for configuring log level */ + struct ice_fwlog_module_entry module_entries[ICE_AQC_FW_LOG_ID_MAX]; +#define ICE_FWLOG_OPTION_ARQ_ENA BIT(0) +#define ICE_FWLOG_OPTION_UART_ENA BIT(1)
drivers/net/ethernet/intel/ice/ice_fwlog.h line 44
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_fwlog.h new file +10
-0+/* set before calling ice_fwlog_init() so the PF registers for firmware +* logging on initialization +*/ +#define ICE_FWLOG_OPTION_REGISTER_ON_INIT BIT(2) +/* set in the ice_fwlog_get() response if the PF is registered for FW +* logging events over ARQ +*/ +#define ICE_FWLOG_OPTION_IS_REGISTERED BIT(3) +/* options used to configure firmware logging */ +u16 options;
I believe the other structs put the define below the member, this seems to put it above.
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_fwlog.h new file +7
-0+/* minimum number of log events sent per Admin Receive Queue event */ + u16 log_resolution; +}; + +void ice_fwlog_set_support_ena (struct ice_hw *hw); +bool ice_fwlog_supported (struct ice_hw *hw); +#endif /* _ICE_FWLOG_H_ */ drivers/net/ethernet/intel/ice/ice_type.h +0
-0
drivers/net/ethernet/intel/ice/ice_type.h line 19
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_type.h +0
-0@@ -17,6 +17,7 @@#include "ice_protocol_type.h" #include "ice_sbq_cmd.h" #include "ice_vlan_mode.h"
newline here please
drivers/net/ethernet/intel/ice/ice_type.h struct ice_hw { · line 864
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_type.h +2
-0+#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 */ +bool fwlog_support_ena;/* does hardware support FW logging? */
IMO this name is a bit confusing as the ena makes me think it represents enabled not whether hardware supports it. Why not just 'supported' (and the other associated *support_ena fields and functions)?
drivers/net/ethernet/intel/ice/ice_type.h struct ice_hw { · line 869
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_type.h +2
-0+bool fwlog_ena;/* currently logging? */ +/* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL * register. Used for determining the ITR/INTRL granularity during * initialization.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 3/5 ice: add ability to query/set FW log level and resolution
In reply to Paul M Stillwell JrThe E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_common.c | 4 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 142 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 277 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 429 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +4 -0
@@ -2406,7 +2406,11 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow =0x1001 , +/* FW Logging Commands */ + 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_common.c +3 -1
@@ -879,7 +879,9 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_cqinit; -ice_fwlog_set_support_ena (hw); + 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)
drivers/net/ethernet/intel/ice/ice_devlink.c +139 -3
170 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.c +277 -0
292 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_fwlog.h +5 -0
@@ -48,4 +48,9 @@ struct ice_fwlog_cfg {void ice_fwlog_set_support_ena (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_ */
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -861,6 +861,7 @@ struct ice_hw {u8 fw_patch;/* firmware patch version */ u32 fw_build;/* firmware build number */ +struct ice_fwlog_cfg fwlog_cfg;bool fwlog_support_ena;/* does hardware support FW logging? */ bool fwlog_ena;/* currently logging? */
Signature · 6 lines
2.35.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 3/5] ice: add ability to query/set FW log level and resolution
Quoted 87 lines · Paul M Stillwell Jr
The E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
Signed-off-by Paul M Stillwell Jr <[email protected]>--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_common.c | 4 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 142 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 277 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 429 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +4
-0@@ -2406,7 +2406,11 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow =0x1001 , +/* FW Logging Commands */ + 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_common.c +3
-1@@ -879,7 +879,9 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_cqinit; -ice_fwlog_set_support_ena (hw); + 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)drivers/net/ethernet/intel/ice/ice_devlink.c +24
-2@@ -1488,6 +1488,8 @@ enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED ,ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , + ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION, }; static int@@ -1530,8 +1532,121 @@ static int ice_devlink_fwlog_enabled_set(struct devlink *devlink, u32 id, struct devlink_param_gset_ctx *ctx) { - /* set operation is unsupported at this time */ - return -EOPNOTSUPP; + struct ice_pf *pf = devlink_priv(devlink); +struct ice_hw *hw = &pf->hw; +int status; + +/* only support fw log commands on PF 0 */ +if (hw->bus.func) +return -EOPNOTSUPP ; + +if (hw->fwlog_ena == ctx->val.vbool) +return 0 ; + + hw->fwlog_ena = ctx->val.vbool; + +if (hw->fwlog_ena) + hw->fwlog_cfg.options |=ICE_FWLOG_OPTION_ARQ_ENA ; +else + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + +/* send the cfg to FW and register for events */ + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +return status;
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1566
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0+ +if (hw->fwlog_ena) { + status =ice_fwlog_register (hw); +if (status) +return status; + }else { + status =ice_fwlog_unregister (hw); +if (status) +return status; + }
This could be simplified i.e
if (hw->fwlog_ena) {
status = ice_fwlog_register(hw);
else
status = ice_fwlog_unregister(hw);
return status;Quoted 66 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +66
-0+ +return 0 ; +} + +static int +ice_devlink_fwlog_level_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +/* all the log levels are the same so pick the first one */ + ctx->val.vu8 = pf->hw.fwlog_cfg.module_entries[0 ].log_level; + +return 0 ; +} + +static int +ice_devlink_fwlog_level_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); +struct ice_fwlog_cfg *cfg; +u8 i; + +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +if (ctx->val.vu8 >=ICE_FWLOG_LEVEL_INVALID ) { +dev_err (ice_pf_to_dev (pf),"Log level is greater than allowed! %d\n" , + ctx->val.vu8); +return -EINVAL ; + } + + cfg = &pf->hw.fwlog_cfg; + +/* update the log level for all modules to the same thing. this gets +* written to the FW when the user says enable logging +*/ +for (i =0 ; i <ICE_AQC_FW_LOG_ID_MAX ; i++) + cfg->module_entries[i].log_level = ctx->val.vu8; + +return 0 ; +} + +static int +ice_devlink_fwlog_resolution_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + + ctx->val.vu8 = pf->hw.fwlog_cfg.log_resolution; + +return 0 ; +} + +static int +ice_devlink_fwlog_resolution_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx)
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1642
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0+{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +if (ctx->val.vu8 <ICE_AQC_FW_LOG_MIN_RESOLUTION || + ctx->val.vu8 >ICE_AQC_FW_LOG_MAX_RESOLUTION ) { + dev_err(ice_pf_to_dev(pf), "Log resolution is not allowed! Should be between 1 - 128: %d\n",
This message might be a bit confusing, maybe something like 'Log resolution out of range" ?
Quoted 152 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +29
-1+ ctx->val.vu8); +return -EINVAL ; + } + + pf->hw.fwlog_cfg.log_resolution = ctx->val.vu8; + +return 0 ; }static const struct devlink_param ice_devlink_params[] = {@@ -1562,6 +1677,18 @@ static const struct devlink_param ice_devlink_params[] = { ice_devlink_fwlog_enabled_get, ice_devlink_fwlog_enabled_set, NULL), +DEVLINK_PARAM_DRIVER (ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , +"fwlog_level" ,DEVLINK_PARAM_TYPE_U8 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + ice_devlink_fwlog_level_get, + ice_devlink_fwlog_level_set, +NULL ), +DEVLINK_PARAM_DRIVER (ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , +"fwlog_resolution" ,DEVLINK_PARAM_TYPE_U8 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + ice_devlink_fwlog_resolution_get, + ice_devlink_fwlog_resolution_set, + NULL), };static void ice_devlink_free (void *devlink_ptr)@@ -1662,11 +1789,20 @@ int ice_devlink_register_params(struct ice_pf *pf)ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , value); - value.vbool = false;devlink_param_driverinit_value_set (devlink,ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , value); + value.vu8 =ICE_FWLOG_LEVEL_NORMAL ; +devlink_param_driverinit_value_set (devlink, +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , + value); + +/* set the default value for the FW to pack 10 messages per AQ event */ + value.vu8 =10 ; +devlink_param_driverinit_value_set (devlink, +ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , + value);return 0 ; }drivers/net/ethernet/intel/ice/ice_fwlog.c +93
-0@@ -4,6 +4,165 @@#include "ice_common.h" #include "ice_fwlog.h" +/** +* cache_cfg - Cache FW logging config +* @hw: pointer to the HW structure +* @cfg: config to cache +*/ +static void cache_cfg (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ + hw->fwlog_cfg = *cfg; +} + +/** +* valid_module_entries - validate all the module entry IDs and log levels +* @hw: pointer to the HW structure +* @entries: entries to validate +* @num_entries: number of entries to validate +*/ +static bool +valid_module_entries (struct ice_hw *hw,struct ice_fwlog_module_entry *entries, +u16 num_entries) +{ +u16 i; + +if (!entries) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Null ice_fwlog_module_entry array\n" ); +return false; + } + +if (!num_entries) { +ice_debug (hw,ICE_DBG_FW_LOG ,"num_entries must be non-zero\n" ); +return false; + } + +for (i =0 ; i < num_entries; i++) { +struct ice_fwlog_module_entry *entry = &entries[i]; + +if (entry->module_id >=ICE_AQC_FW_LOG_ID_MAX ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Invalid module_id %u, max valid module_id is %u\n" , + entry->module_id,ICE_AQC_FW_LOG_ID_MAX -1 ); +return false; + } + +if (entry->log_level >=ICE_FWLOG_LEVEL_INVALID ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Invalid log_level %u, max valid log_level is %u\n" , + entry->log_level, +ICE_AQC_FW_LOG_ID_MAX -1 ); +return false; + } + } + +return true; +} + +/** +* valid_cfg - validate entire configuration +* @hw: pointer to the HW structure +* @cfg: config to validate +*/ +static bool valid_cfg (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ +if (!cfg) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Null ice_fwlog_cfg\n" ); +return false; + } + +if (cfg->log_resolution <ICE_AQC_FW_LOG_MIN_RESOLUTION || + cfg->log_resolution >ICE_AQC_FW_LOG_MAX_RESOLUTION ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Unsupported log_resolution %u, must be between %u and %u\n" , + cfg->log_resolution,ICE_AQC_FW_LOG_MIN_RESOLUTION , +ICE_AQC_FW_LOG_MAX_RESOLUTION ); +return false; + } + +if (!valid_module_entries (hw, cfg->module_entries, +ICE_AQC_FW_LOG_ID_MAX )) +return false; + +return true; +} + +/** +* ice_fwlog_init - Initialize FW logging variables +* @hw: pointer to the HW structure +* +* This function should be called on driver initialization during +* ice_init_hw(). +*/ +int ice_fwlog_init (struct ice_hw *hw) +{ +int status; + +ice_fwlog_set_support_ena (hw); + +if (ice_fwlog_supported (hw)) {
drivers/net/ethernet/intel/ice/ice_fwlog.c line 109
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +10
-0+struct ice_fwlog_cfg *cfg; + + cfg =kzalloc (sizeof (*cfg),GFP_KERNEL ); +if (!cfg) +return -ENOMEM ; + +/* read the current config from the FW and store it */ + status =ice_fwlog_get (hw, cfg); +if (status) +return status;
Maybe initialize status with zero, and just return status at the end ?
Quoted 207 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +174
-0+ } + +return 0 ; +} + +/** +* ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30) +* @hw: pointer to the HW structure +* @entries: entries to configure +* @num_entries: number of @entries +* @options: options from ice_fwlog_cfg->options structure +* @log_resolution: logging resolution +*/ +static int +ice_aq_fwlog_set (struct ice_hw *hw,struct ice_fwlog_module_entry *entries, +u16 num_entries,u16 options,u16 log_resolution) +{ +struct ice_aqc_fw_log_cfg_resp *fw_modules; +struct ice_aqc_fw_log *cmd; +struct ice_aq_desc desc; +int status; +u16 i; + + fw_modules =kcalloc (num_entries,sizeof (*fw_modules),GFP_KERNEL ); +if (!fw_modules) +return -ENOMEM ; + +for (i =0 ; i < num_entries; i++) { + fw_modules[i].module_identifier = +cpu_to_le16 (entries[i].module_id); + fw_modules[i].log_level = entries[i].log_level; + } + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_fw_logs_config); + desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); + + cmd = &desc.params.fw_log; + + cmd->cmd_flags =ICE_AQC_FW_LOG_CONF_SET_VALID ; + cmd->ops.cfg.log_resolution =cpu_to_le16 (log_resolution); + cmd->ops.cfg.mdl_cnt =cpu_to_le16 (num_entries); + +if (options &ICE_FWLOG_OPTION_ARQ_ENA ) + cmd->cmd_flags |=ICE_AQC_FW_LOG_CONF_AQ_EN ; +if (options &ICE_FWLOG_OPTION_UART_ENA ) + cmd->cmd_flags |=ICE_AQC_FW_LOG_CONF_UART_EN ; + + status =ice_aq_send_cmd (hw, &desc, fw_modules, +sizeof (*fw_modules) * num_entries, +NULL ); + +kfree (fw_modules); + +return status; +} +/** * ice_fwlog_supported - Cached for whether FW supports FW logging or not * @hw: pointer to the HW structure @@ -16,6 +175,99 @@ bool ice_fwlog_supported(struct ice_hw *hw)return hw->fwlog_support_ena; } +/** +* ice_fwlog_set - Set the firmware logging settings +* @hw: pointer to the HW structure +* @cfg: config used to set firmware logging +* +* This function should be called whenever the driver needs to set the firmware +* logging configuration. It can be called on initialization, reset, or during +* runtime. +* +* If the PF wishes to receive FW logging then it must register via +* ice_fwlog_register. Note, that ice_fwlog_register does not need to be called +* for init. +*/ +int +ice_fwlog_set (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + +if (!valid_cfg (hw, cfg)) +return -EINVAL ; + + status =ice_aq_fwlog_set (hw, cfg->module_entries, +ICE_AQC_FW_LOG_ID_MAX , cfg->options, + cfg->log_resolution); +if (!status) +cache_cfg (hw, cfg); + +return status; +} + +/** +* ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31) +* @hw: pointer to the HW structure +* @reg: true to register and false to unregister +*/ +static int ice_aq_fwlog_register (struct ice_hw *hw,bool reg) +{ +struct ice_aq_desc desc; + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_fw_logs_register); + +if (reg) + desc.params.fw_log.cmd_flags =ICE_AQC_FW_LOG_AQ_REGISTER ; + +return ice_aq_send_cmd (hw, &desc,NULL ,0 ,NULL ); +} + +/** +* ice_fwlog_register - Register the PF for firmware logging +* @hw: pointer to the HW structure +* +* After this call the PF will start to receive firmware logging based on the +* configuration set in ice_fwlog_set. +*/ +int ice_fwlog_register (struct ice_hw *hw) +{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + + status =ice_aq_fwlog_register (hw, true); +if (status) +ice_debug (hw,ICE_DBG_FW_LOG ,"Failed to register for firmware logging events over ARQ\n" ); +else + hw->fwlog_cfg.options |=ICE_FWLOG_OPTION_IS_REGISTERED ; + +return status; +} + +/** +* ice_fwlog_unregister - Unregister the PF from firmware logging +* @hw: pointer to the HW structure +*/ +int ice_fwlog_unregister (struct ice_hw *hw) +{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + + status =ice_aq_fwlog_register (hw, false); +if (status) +ice_debug (hw,ICE_DBG_FW_LOG ,"Failed to unregister from firmware logging events over ARQ\n" ); +else + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED ; + +return status; +} +/** * ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32) * @hw: pointer to the HW structure @@ -115,3 +367,28 @@ void ice_fwlog_set_support_ena(struct ice_hw *hw)kfree (cfg); } + +/** +* ice_fwlog_get - Get the firmware logging settings +* @hw: pointer to the HW structure +* @cfg: config to populate based on current firmware logging settings +*/ +int +ice_fwlog_get (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + +if (!cfg) +return -EINVAL ; + + status =ice_aq_fwlog_get (hw, cfg); +if (status) +return status; + +cache_cfg (hw, cfg); + +return 0 ; +}drivers/net/ethernet/intel/ice/ice_fwlog.h +5
-0@@ -48,4 +48,9 @@ struct ice_fwlog_cfg {void ice_fwlog_set_support_ena (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_ */ drivers/net/ethernet/intel/ice/ice_type.h +0
-0
drivers/net/ethernet/intel/ice/ice_type.h struct ice_hw { · line 867
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_type.h +1
-0@@ -861,6 +861,7 @@ struct ice_hw {u8 fw_patch;/* firmware patch version */ u32 fw_build;/* firmware build number */ +struct ice_fwlog_cfg fwlog_cfg;bool fwlog_support_ena;/* does hardware support FW logging? */ bool fwlog_ena;/* currently logging? */
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 3/5] ice: add ability to query/set FW log level and resolution
From: "Wilczynski, Michal" <[email protected]>
Date: Tue, 29 Nov 2022 12:48:25 +0100
Quoted 7 lines · Paul M Stillwell Jr
Quoted 6 lines
The E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
Signed-off-by Paul M Stillwell Jr <[email protected]>
[...]
Quoted 17 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4
-0+/* send the cfg to FW and register for events */ + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +return status;drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1566
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0+ +if (hw->fwlog_ena) { + status =ice_fwlog_register (hw); +if (status) +return status; + }else { + status =ice_fwlog_unregister (hw); +if (status) +return status; + }This could be simplified i.e
Quoted 6 lines
if (hw->fwlog_ena) {
status = ice_fwlog_register(hw);
else
status = ice_fwlog_unregister(hw);
return status;return hw->fwlog_ena ? ice_fwlog_register(hw) : ice_fwlog_unregister(hw);
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1566
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +3
-0+ +return 0 ; +}
[...]
Thanks,
Olek
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 3/5] ice: add ability to query/set FW log level and resolution
Quoted 30 lines · Alexander Lobakin
From: "Wilczynski, Michal" <[email protected]>
Date: Tue, 29 Nov 2022 12:48:25 +0100Quoted 7 lines · Paul M Stillwell Jr
Quoted 6 lines
The E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
Signed-off-by Paul M Stillwell Jr <[email protected]>[...]
Quoted 17 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4
-0+/* send the cfg to FW and register for events */ + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +return status;drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1566
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0+ +if (hw->fwlog_ena) { + status =ice_fwlog_register (hw); +if (status) +return status; + }else { + status =ice_fwlog_unregister (hw); +if (status) +return status; + }This could be simplified i.e
Quoted 8 lines
Quoted 6 lines
if (hw->fwlog_ena) { status = ice_fwlog_register(hw); else status = ice_fwlog_unregister(hw); return status;return hw->fwlog_ena ? ice_fwlog_register(hw) : ice_fwlog_unregister(hw);
Will change.
Quoted 10 lines
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1566
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +3
-0+ +return 0 ; +}[...]
Thanks,
Olek
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainerRe: [Intel-wired-lan] [PATCH net-next 3/5] ice: add ability to query/set FW log level and resolution
In reply to Paul M Stillwell JrQuoted 20 lines · Paul M Stillwell Jr
The E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
Signed-off-by Paul M Stillwell Jr <[email protected]>--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_common.c | 4 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 142 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 277 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 429 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0
-0
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h enum ice_adminq_opc { · line 2409
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +1
-0@@ -2406,7 +2406,11 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow = 0x1001, +/* FW Logging Commands */
nit: As this seperator was removed from patch 1 and the first command in patch 2. This comment seems to fit better there. Also retaining the new line between the op and the FW logging group would be nice.
Quoted 79 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +3
-0+ 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_common.c +3
-1@@ -879,7 +879,9 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_cqinit; -ice_fwlog_set_support_ena (hw); + 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)drivers/net/ethernet/intel/ice/ice_devlink.c +40
-2@@ -1488,6 +1488,8 @@ enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED ,ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , + ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION, }; static int@@ -1530,8 +1532,121 @@ static int ice_devlink_fwlog_enabled_set(struct devlink *devlink, u32 id, struct devlink_param_gset_ctx *ctx) { - /* set operation is unsupported at this time */ - return -EOPNOTSUPP; + struct ice_pf *pf = devlink_priv(devlink); +struct ice_hw *hw = &pf->hw; +int status; + +/* only support fw log commands on PF 0 */ +if (hw->bus.func) +return -EOPNOTSUPP ; + +if (hw->fwlog_ena == ctx->val.vbool) +return 0 ; + + hw->fwlog_ena = ctx->val.vbool; + +if (hw->fwlog_ena) + hw->fwlog_cfg.options |=ICE_FWLOG_OPTION_ARQ_ENA ; +else + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + +/* send the cfg to FW and register for events */ + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +return status; + +if (hw->fwlog_ena) { + status =ice_fwlog_register (hw); +if (status) +return status; + }else { + status =ice_fwlog_unregister (hw); +if (status) +return status; + } + +return 0 ; +} + +static int +ice_devlink_fwlog_level_get(struct devlink *devlink, u32 id,
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1582
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0+ struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +/* all the log levels are the same so pick the first one */ + ctx->val.vu8 = pf->hw.fwlog_cfg.module_entries[0 ].log_level;
Since they are all the same, would it make sense to store it in the config and pull the value from there instead of duplicating it for each entry?
Quoted 90 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +79
-0+ +return 0 ; +} + +static int +ice_devlink_fwlog_level_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); +struct ice_fwlog_cfg *cfg; +u8 i; + +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +if (ctx->val.vu8 >=ICE_FWLOG_LEVEL_INVALID ) { +dev_err (ice_pf_to_dev (pf),"Log level is greater than allowed! %d\n" , + ctx->val.vu8); +return -EINVAL ; + } + + cfg = &pf->hw.fwlog_cfg; + +/* update the log level for all modules to the same thing. this gets +* written to the FW when the user says enable logging +*/ +for (i =0 ; i <ICE_AQC_FW_LOG_ID_MAX ; i++) + cfg->module_entries[i].log_level = ctx->val.vu8; + +return 0 ; +} + +static int +ice_devlink_fwlog_resolution_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + + ctx->val.vu8 = pf->hw.fwlog_cfg.log_resolution; + +return 0 ; +} + +static int +ice_devlink_fwlog_resolution_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +if (ctx->val.vu8 <ICE_AQC_FW_LOG_MIN_RESOLUTION || + ctx->val.vu8 >ICE_AQC_FW_LOG_MAX_RESOLUTION ) { +dev_err (ice_pf_to_dev (pf),"Log resolution is not allowed! Should be between 1 - 128: %d\n" , + ctx->val.vu8); +return -EINVAL ; + } + + pf->hw.fwlog_cfg.log_resolution = ctx->val.vu8; + +return 0 ; }static const struct devlink_param ice_devlink_params[] = {@@ -1562,6 +1677,18 @@ static const struct devlink_param ice_devlink_params[] = { ice_devlink_fwlog_enabled_get, ice_devlink_fwlog_enabled_set, NULL), +DEVLINK_PARAM_DRIVER (ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , +"fwlog_level" ,DEVLINK_PARAM_TYPE_U8 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + ice_devlink_fwlog_level_get, + ice_devlink_fwlog_level_set, +NULL ), +DEVLINK_PARAM_DRIVER (ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , +"fwlog_resolution" ,DEVLINK_PARAM_TYPE_U8 , +BIT (DEVLINK_PARAM_CMODE_RUNTIME ), + ice_devlink_fwlog_resolution_get, + ice_devlink_fwlog_resolution_set, + NULL), };static void ice_devlink_free (void *devlink_ptr)
drivers/net/ethernet/intel/ice/ice_devlink.c int ice_devlink_register_params(struct ice_pf *pf) · line 1665
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +0
-1@@ -1662,11 +1789,20 @@ int ice_devlink_register_params(struct ice_pf *pf)ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , value); - value.vbool = false;
Is this on purpose?
Quoted 196 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0devlink_param_driverinit_value_set (devlink,ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , value); + value.vu8 =ICE_FWLOG_LEVEL_NORMAL ; +devlink_param_driverinit_value_set (devlink, +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , + value); + +/* set the default value for the FW to pack 10 messages per AQ event */ + value.vu8 =10 ; +devlink_param_driverinit_value_set (devlink, +ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , + value);return 0 ; }drivers/net/ethernet/intel/ice/ice_fwlog.c +164
-0@@ -4,6 +4,165 @@#include "ice_common.h" #include "ice_fwlog.h" +/** +* cache_cfg - Cache FW logging config +* @hw: pointer to the HW structure +* @cfg: config to cache +*/ +static void cache_cfg (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ + hw->fwlog_cfg = *cfg; +} + +/** +* valid_module_entries - validate all the module entry IDs and log levels +* @hw: pointer to the HW structure +* @entries: entries to validate +* @num_entries: number of entries to validate +*/ +static bool +valid_module_entries (struct ice_hw *hw,struct ice_fwlog_module_entry *entries, +u16 num_entries) +{ +u16 i; + +if (!entries) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Null ice_fwlog_module_entry array\n" ); +return false; + } + +if (!num_entries) { +ice_debug (hw,ICE_DBG_FW_LOG ,"num_entries must be non-zero\n" ); +return false; + } + +for (i =0 ; i < num_entries; i++) { +struct ice_fwlog_module_entry *entry = &entries[i]; + +if (entry->module_id >=ICE_AQC_FW_LOG_ID_MAX ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Invalid module_id %u, max valid module_id is %u\n" , + entry->module_id,ICE_AQC_FW_LOG_ID_MAX -1 ); +return false; + } + +if (entry->log_level >=ICE_FWLOG_LEVEL_INVALID ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Invalid log_level %u, max valid log_level is %u\n" , + entry->log_level, +ICE_AQC_FW_LOG_ID_MAX -1 ); +return false; + } + } + +return true; +} + +/** +* valid_cfg - validate entire configuration +* @hw: pointer to the HW structure +* @cfg: config to validate +*/ +static bool valid_cfg (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ +if (!cfg) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Null ice_fwlog_cfg\n" ); +return false; + } + +if (cfg->log_resolution <ICE_AQC_FW_LOG_MIN_RESOLUTION || + cfg->log_resolution >ICE_AQC_FW_LOG_MAX_RESOLUTION ) { +ice_debug (hw,ICE_DBG_FW_LOG ,"Unsupported log_resolution %u, must be between %u and %u\n" , + cfg->log_resolution,ICE_AQC_FW_LOG_MIN_RESOLUTION , +ICE_AQC_FW_LOG_MAX_RESOLUTION ); +return false; + } + +if (!valid_module_entries (hw, cfg->module_entries, +ICE_AQC_FW_LOG_ID_MAX )) +return false; + +return true; +} + +/** +* ice_fwlog_init - Initialize FW logging variables +* @hw: pointer to the HW structure +* +* This function should be called on driver initialization during +* ice_init_hw(). +*/ +int ice_fwlog_init (struct ice_hw *hw) +{ +int status; + +ice_fwlog_set_support_ena (hw); + +if (ice_fwlog_supported (hw)) { +struct ice_fwlog_cfg *cfg; + + cfg =kzalloc (sizeof (*cfg),GFP_KERNEL ); +if (!cfg) +return -ENOMEM ; + +/* read the current config from the FW and store it */ + status =ice_fwlog_get (hw, cfg); +if (status) +return status; + } + +return 0 ; +} + +/** +* ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30) +* @hw: pointer to the HW structure +* @entries: entries to configure +* @num_entries: number of @entries +* @options: options from ice_fwlog_cfg->options structure +* @log_resolution: logging resolution +*/ +static int +ice_aq_fwlog_set (struct ice_hw *hw,struct ice_fwlog_module_entry *entries, +u16 num_entries,u16 options,u16 log_resolution) +{ +struct ice_aqc_fw_log_cfg_resp *fw_modules; +struct ice_aqc_fw_log *cmd; +struct ice_aq_desc desc; +int status; +u16 i; + + fw_modules =kcalloc (num_entries,sizeof (*fw_modules),GFP_KERNEL ); +if (!fw_modules) +return -ENOMEM ; + +for (i =0 ; i < num_entries; i++) { + fw_modules[i].module_identifier = +cpu_to_le16 (entries[i].module_id); + fw_modules[i].log_level = entries[i].log_level; + } + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_fw_logs_config); + desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); + + cmd = &desc.params.fw_log; + + cmd->cmd_flags =ICE_AQC_FW_LOG_CONF_SET_VALID ; + cmd->ops.cfg.log_resolution =cpu_to_le16 (log_resolution); + cmd->ops.cfg.mdl_cnt =cpu_to_le16 (num_entries); + +if (options &ICE_FWLOG_OPTION_ARQ_ENA ) + cmd->cmd_flags |=ICE_AQC_FW_LOG_CONF_AQ_EN ; +if (options &ICE_FWLOG_OPTION_UART_ENA ) + cmd->cmd_flags |=ICE_AQC_FW_LOG_CONF_UART_EN ; + + status =ice_aq_send_cmd (hw, &desc, fw_modules, +sizeof (*fw_modules) * num_entries, +NULL ); + +kfree (fw_modules); + +return status; +} +/** * ice_fwlog_supported - Cached for whether FW supports FW logging or not * @hw: pointer to the HW structure @@ -16,6 +175,99 @@ bool ice_fwlog_supported(struct ice_hw *hw)return hw->fwlog_support_ena; } +/** +* ice_fwlog_set - Set the firmware logging settings +* @hw: pointer to the HW structure +* @cfg: config used to set firmware logging +*
drivers/net/ethernet/intel/ice/ice_fwlog.c bool ice_fwlog_supported(struct ice_hw *hw) · line 192
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +10
-0+* This function should be called whenever the driver needs to set the firmware +* logging configuration. It can be called on initialization, reset, or during +* runtime. +* +* If the PF wishes to receive FW logging then it must register via +* ice_fwlog_register. Note, that ice_fwlog_register does not need to be called +* for init. +*/ +int +ice_fwlog_set (struct ice_hw *hw,struct ice_fwlog_cfg *cfg)
This can fit on one line...
Quoted 83 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +78
-0+{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + +if (!valid_cfg (hw, cfg)) +return -EINVAL ; + + status =ice_aq_fwlog_set (hw, cfg->module_entries, +ICE_AQC_FW_LOG_ID_MAX , cfg->options, + cfg->log_resolution); +if (!status) +cache_cfg (hw, cfg); + +return status; +} + +/** +* ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31) +* @hw: pointer to the HW structure +* @reg: true to register and false to unregister +*/ +static int ice_aq_fwlog_register (struct ice_hw *hw,bool reg) +{ +struct ice_aq_desc desc; + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_fw_logs_register); + +if (reg) + desc.params.fw_log.cmd_flags =ICE_AQC_FW_LOG_AQ_REGISTER ; + +return ice_aq_send_cmd (hw, &desc,NULL ,0 ,NULL ); +} + +/** +* ice_fwlog_register - Register the PF for firmware logging +* @hw: pointer to the HW structure +* +* After this call the PF will start to receive firmware logging based on the +* configuration set in ice_fwlog_set. +*/ +int ice_fwlog_register (struct ice_hw *hw) +{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + + status =ice_aq_fwlog_register (hw, true); +if (status) +ice_debug (hw,ICE_DBG_FW_LOG ,"Failed to register for firmware logging events over ARQ\n" ); +else + hw->fwlog_cfg.options |=ICE_FWLOG_OPTION_IS_REGISTERED ; + +return status; +} + +/** +* ice_fwlog_unregister - Unregister the PF from firmware logging +* @hw: pointer to the HW structure +*/ +int ice_fwlog_unregister (struct ice_hw *hw) +{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + + status =ice_aq_fwlog_register (hw, false); +if (status) +ice_debug (hw,ICE_DBG_FW_LOG ,"Failed to unregister from firmware logging events over ARQ\n" ); +else + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED ; + +return status; +} +/** * ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32) * @hw: pointer to the HW structure @@ -115,3 +367,28 @@ void ice_fwlog_set_support_ena(struct ice_hw *hw)
drivers/net/ethernet/intel/ice/ice_fwlog.c void ice_fwlog_set_support_ena(struct ice_hw *hw) · line 377
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +8
-0kfree (cfg); } + +/** +* ice_fwlog_get - Get the firmware logging settings +* @hw: pointer to the HW structure +* @cfg: config to populate based on current firmware logging settings +*/ +int +ice_fwlog_get (struct ice_hw *hw,struct ice_fwlog_cfg *cfg)
and this one. Can you check that all the others are pulled up properly as well?
Quoted 36 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +17
-0+{ +int status; + +if (!ice_fwlog_supported (hw)) +return -EOPNOTSUPP ; + +if (!cfg) +return -EINVAL ; + + status =ice_aq_fwlog_get (hw, cfg); +if (status) +return status; + +cache_cfg (hw, cfg); + +return 0 ; +}drivers/net/ethernet/intel/ice/ice_fwlog.h +5
-0@@ -48,4 +48,9 @@ struct ice_fwlog_cfg {void ice_fwlog_set_support_ena (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_ */ drivers/net/ethernet/intel/ice/ice_type.h +0
-0
drivers/net/ethernet/intel/ice/ice_type.h struct ice_hw { · line 867
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_type.h +1
-0@@ -861,6 +861,7 @@ struct ice_hw {u8 fw_patch;/* firmware patch version */ u32 fw_build;/* firmware build number */ +struct ice_fwlog_cfg fwlog_cfg;bool fwlog_support_ena;/* does hardware support FW logging? */ bool fwlog_ena;/* currently logging? */
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 3/5] ice: add ability to query/set FW log level and resolution
Quoted 107 lines · Tony Nguyen
Quoted 20 lines · Paul M Stillwell Jr
The E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
Signed-off-by Paul M Stillwell Jr <[email protected]>---
.../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_common.c | 4 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 142 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 277 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 + drivers/net/ethernet/intel/ice/ice_type.h | 1 +6 files changed, 429 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0
-0drivers/net/ethernet/intel/ice/ice_adminq_cmd.h enum ice_adminq_opc { · line 2408
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +1
-0@@ -2406,7 +2406,11 @@ enum ice_adminq_opc { /* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow = 0x1001, + /* FW Logging Commands */nit: As this seperator was removed from patch 1 and the first command in patch 2. This comment seems to fit better there. Also retaining the new line between the op and the FW logging group would be nice.
Quoted 80 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +3
-0+ 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_common.c +3
-1@@ -879,7 +879,9 @@ int ice_init_hw(struct ice_hw *hw) if (status) goto err_unroll_cqinit; - ice_fwlog_set_support_ena(hw); + 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)drivers/net/ethernet/intel/ice/ice_devlink.c +2
-0@@ -1488,6 +1488,8 @@ enum ice_devlink_param_id { ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED, ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED, + ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL, + ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION, };static int
drivers/net/ethernet/intel/ice/ice_devlink.c +42
-2@@ -1530,8 +1532,121 @@ static int ice_devlink_fwlog_enabled_set(struct devlink *devlink, u32 id, struct devlink_param_gset_ctx *ctx) { - /* set operation is unsupported at this time */ - return -EOPNOTSUPP; + struct ice_pf *pf = devlink_priv(devlink); + struct ice_hw *hw = &pf->hw; + int status; + + /* only support fw log commands on PF 0 */ + if (hw->bus.func) + return -EOPNOTSUPP; + + if (hw->fwlog_ena == ctx->val.vbool) + return 0; + + hw->fwlog_ena = ctx->val.vbool; + + if (hw->fwlog_ena) + hw->fwlog_cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA; + else + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA; + + /* send the cfg to FW and register for events */ + status = ice_fwlog_set(hw, &hw->fwlog_cfg); + if (status) + return status; + + if (hw->fwlog_ena) { + status = ice_fwlog_register(hw); + if (status) + return status; + } else { + status = ice_fwlog_unregister(hw); + if (status) + return status; + } + + return 0; +} + +static int +ice_devlink_fwlog_level_get (struct devlink *devlink,u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); +
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1582
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +6
-0+ /* only support fw log commands on PF 0 */ + if (pf->hw.bus.func) + return -EOPNOTSUPP; + + /* all the log levels are the same so pick the first one */ + ctx->val.vu8 = pf->hw.fwlog_cfg.module_entries[0].log_level;Since they are all the same, would it make sense to store it in the config and pull the value from there instead of duplicating it for each entry?
I don't think so. They have to all be stored in the config because you have to write them all out when you write the config. It makes sense to me to keep them all in the config and read one of them instead of having 2 places with the value and possibly having a bug because they are out of sync.
If I'm misundersstanding your comment then let me know.
Quoted 89 lines
Quoted 89 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +67
-0+ + return 0; +} + +static int +ice_devlink_fwlog_level_set (struct devlink *devlink,u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + struct ice_fwlog_cfg *cfg; + u8 i; + + if (pf->hw.bus.func) + return -EOPNOTSUPP; + + if (ctx->val.vu8 >= ICE_FWLOG_LEVEL_INVALID) { + dev_err(ice_pf_to_dev(pf), "Log level is greater than allowed! %d\n", + ctx->val.vu8); + return -EINVAL; + } + + cfg = &pf->hw.fwlog_cfg; + + /* update the log level for all modules to the same thing. this gets + * written to the FW when the user says enable logging + */ + for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++) + cfg->module_entries[i].log_level = ctx->val.vu8; + + return 0; +} + +static int +ice_devlink_fwlog_resolution_get (struct devlink *devlink,u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + + /* only support fw log commands on PF 0 */ + if (pf->hw.bus.func) + return -EOPNOTSUPP; + + ctx->val.vu8 = pf->hw.fwlog_cfg.log_resolution; + + return 0; +} + +static int +ice_devlink_fwlog_resolution_set (struct devlink *devlink,u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct ice_pf *pf = devlink_priv(devlink); + + /* only support fw log commands on PF 0 */ + if (pf->hw.bus.func) + return -EOPNOTSUPP; + + if (ctx->val.vu8 < ICE_AQC_FW_LOG_MIN_RESOLUTION || + ctx->val.vu8 > ICE_AQC_FW_LOG_MAX_RESOLUTION) { + dev_err(ice_pf_to_dev(pf), "Log resolution is not allowed! Should be between 1 - 128: %d\n", + ctx->val.vu8); + return -EINVAL; + } + + pf->hw.fwlog_cfg.log_resolution = ctx->val.vu8; + + return 0; }static const struct
devlink_paramice_devlink_params[] = {drivers/net/ethernet/intel/ice/ice_devlink.c +12
-0@@ -1562,6 +1677,18 @@ static const struct devlink_param ice_devlink_params[] = { ice_devlink_fwlog_enabled_get, ice_devlink_fwlog_enabled_set, NULL), + DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL, + "fwlog_level", DEVLINK_PARAM_TYPE_U8, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + ice_devlink_fwlog_level_get, + ice_devlink_fwlog_level_set, + NULL), + DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION, + "fwlog_resolution", DEVLINK_PARAM_TYPE_U8, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + ice_devlink_fwlog_resolution_get, + ice_devlink_fwlog_resolution_set, + NULL), };
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c int ice_devlink_register_params(struct ice_pf · line 1665
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +0
-1static void ice_devlink_free(void *devlink_ptr)@@ -1662,11 +1789,20 @@ int ice_devlink_register_params(struct ice_pf *pf) ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED, value); - value.vbool = false;Is this on purpose?
Yes, the value doesn't change between the 2 calls so no need to set it a second time.
Quoted 207 lines
Quoted 207 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +6
-0devlink_param_driverinit_value_set(devlink, ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED, value); + value.vu8 = ICE_FWLOG_LEVEL_NORMAL; + devlink_param_driverinit_value_set(devlink, + ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL, + value); + + /* set the default value for the FW to pack 10 messages per AQevent */
+ value.vu8 = 10;
+ devlink_param_driverinit_value_set(devlink,
+ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION, + value);
return 0;
}drivers/net/ethernet/intel/ice/ice_fwlog.c +12
-0@@ -4,6 +4,165 @@ #include "ice_common.h" #include "ice_fwlog.h" +/** +* cache_cfg - Cache FW logging config +* @hw: pointer to the HW structure +* @cfg: config to cache +*/ +static void cache_cfg (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ + hw->fwlog_cfg = *cfg; +} + +/** +* valid_module_entries - validate all the module entry IDs and log levels
+ * @hw: pointer to the HW structure
+ * @entries: entries to validate
+ * @num_entries: number of entries to validate
+ */drivers/net/ethernet/intel/ice/ice_fwlog.c +2
-0+static bool +valid_module_entries(struct ice_hw *hw, struct ice_fwlog_module_entry*entries,
+ u16num_entries)drivers/net/ethernet/intel/ice/ice_fwlog.c +5
-0+{ + u16 i; + + if (!entries) { + ice_debug(hw, ICE_DBG_FW_LOG, "Null ice_fwlog_module_entryarray\n");
+ return false;
+ }drivers/net/ethernet/intel/ice/ice_fwlog.c +11
-0+ + if (!num_entries) { + ice_debug(hw, ICE_DBG_FW_LOG, "num_entries must be non-zero\n"); + return false; + } + + for (i = 0; i < num_entries; i++) { + struct ice_fwlog_module_entry *entry = &entries[i]; + + if (entry->module_id >= ICE_AQC_FW_LOG_ID_MAX) { + ice_debug(hw, ICE_DBG_FW_LOG, "Invalid module_id %u, maxvalid
module_idis %u\n",
+entry->module_id,ICE_AQC_FW_LOG_ID_MAX- 1); + return false;
+ }
+
+ if (entry->log_level>=ICE_FWLOG_LEVEL_INVALID) { + ice_debug(hw,ICE_DBG_FW_LOG, "Invalidlog_level%u, max validlog_levelis %u\n",
+entry->log_level,
+ICE_AQC_FW_LOG_ID_MAX- 1);
+ return false;
+ }
+ }drivers/net/ethernet/intel/ice/ice_fwlog.c +19
-0+ + return true; +} + +/** +* valid_cfg - validate entire configuration +* @hw: pointer to the HW structure +* @cfg: config to validate +*/ +static bool valid_cfg (struct ice_hw *hw,struct ice_fwlog_cfg *cfg) +{ + if (!cfg) { + ice_debug(hw, ICE_DBG_FW_LOG, "Null ice_fwlog_cfg\n"); + return false; + } + + if (cfg->log_resolution < ICE_AQC_FW_LOG_MIN_RESOLUTION || + cfg->log_resolution > ICE_AQC_FW_LOG_MAX_RESOLUTION) { + ice_debug(hw, ICE_DBG_FW_LOG, "Unsupported log_resolution %u,must be between %u and %u\n",
+cfg->log_resolution,ICE_AQC_FW_LOG_MIN_RESOLUTION, +ICE_AQC_FW_LOG_MAX_RESOLUTION);
+ return false;
+ }drivers/net/ethernet/intel/ice/ice_fwlog.c +47
-0+ + if (!valid_module_entries(hw, cfg->module_entries, + ICE_AQC_FW_LOG_ID_MAX)) + return false; + + return true; +} + +/** +* ice_fwlog_init - Initialize FW logging variables +* @hw: pointer to the HW structure +* +* This function should be called on driver initialization during +* ice_init_hw(). +*/ +int ice_fwlog_init (struct ice_hw *hw) +{ + int status; + + ice_fwlog_set_support_ena(hw); + + if (ice_fwlog_supported(hw)) { + struct ice_fwlog_cfg *cfg; + + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return -ENOMEM; + + /* read the current config from the FW and store it */ + status = ice_fwlog_get(hw, cfg); + if (status) + return status; + } + + return 0; +} + +/** +* ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30) +* @hw: pointer to the HW structure +* @entries: entries to configure +* @num_entries: number of @entries +* @options: options from ice_fwlog_cfg->options structure +* @log_resolution: logging resolution +*/ +static int +ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry*entries,
+ u16num_entries, u16 options, u16log_resolution)drivers/net/ethernet/intel/ice/ice_fwlog.c +40
-0+{ + struct ice_aqc_fw_log_cfg_resp *fw_modules; + struct ice_aqc_fw_log *cmd; + struct ice_aq_desc desc; + int status; + u16 i; + + fw_modules = kcalloc(num_entries, sizeof(*fw_modules), GFP_KERNEL); + if (!fw_modules) + return -ENOMEM; + + for (i = 0; i < num_entries; i++) { + fw_modules[i].module_identifier = + cpu_to_le16(entries[i].module_id); + fw_modules[i].log_level = entries[i].log_level; + } + + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_fw_logs_config); + desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD); + + cmd = &desc.params.fw_log; + + cmd->cmd_flags = ICE_AQC_FW_LOG_CONF_SET_VALID; + cmd->ops.cfg.log_resolution = cpu_to_le16(log_resolution); + cmd->ops.cfg.mdl_cnt = cpu_to_le16(num_entries); + + if (options & ICE_FWLOG_OPTION_ARQ_ENA) + cmd->cmd_flags |= ICE_AQC_FW_LOG_CONF_AQ_EN; + if (options & ICE_FWLOG_OPTION_UART_ENA) + cmd->cmd_flags |= ICE_AQC_FW_LOG_CONF_UART_EN; + + status = ice_aq_send_cmd(hw, &desc, fw_modules, + sizeof(*fw_modules) * num_entries, + NULL); + + kfree(fw_modules); + + return status; +} +/**
*ice_fwlog_supported- Cached for whether FW supports FW logging or not
* @hw: pointer to the HW structuredrivers/net/ethernet/intel/ice/ice_fwlog.c +6
-0@@ -16,6 +175,99 @@ bool ice_fwlog_supported(struct ice_hw *hw) return hw->fwlog_support_ena; } +/** +* ice_fwlog_set - Set the firmware logging settings +* @hw: pointer to the HW structure +* @cfg: config used to set firmware logging +* +* This function should be called whenever the driver needs to set the firmware
+ * logging configuration. It can be called on initialization, reset, or during
+ * runtime.
+ *
+ * If the PF wishes to receive FW logging then it must register via
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c bool ice_fwlog_supported(struct ice_hw *hw) · line 192
Quoted 6 lines
+ *
ice_fwlog_register. Note, thatice_fwlog_registerdoes not need to be called
+ * for init.
+ */drivers/net/ethernet/intel/ice/ice_fwlog.c +2
-0+int +ice_fwlog_set (struct ice_hw *hw,struct ice_fwlog_cfg *cfg)This can fit on one line...
I went through the file and pulled all of them up that could be. Nice catch.
Quoted 131 lines
Quoted 86 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +20
-0+{ + int status; + + if (!ice_fwlog_supported(hw)) + return -EOPNOTSUPP; + + if (!valid_cfg(hw, cfg)) + return -EINVAL; + + status = ice_aq_fwlog_set(hw, cfg->module_entries, + ICE_AQC_FW_LOG_ID_MAX, cfg->options, + cfg->log_resolution); + if (!status) + cache_cfg(hw, cfg); + + return status; +} + +/** +* ice_aq_fwlog_register - Register PF for firmware logging events (
0xFF31)
+ * @hw: pointer to the HW structure
+ * @reg: true to register and false to unregister
+ */drivers/net/ethernet/intel/ice/ice_fwlog.c +17
-0+static int ice_aq_fwlog_register (struct ice_hw *hw,bool reg) +{ + struct ice_aq_desc desc; + + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_fw_logs_register); + + if (reg) + desc.params.fw_log.cmd_flags = ICE_AQC_FW_LOG_AQ_REGISTER; + + return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL); +} + +/** +* ice_fwlog_register - Register the PF for firmware logging +* @hw: pointer to the HW structure +* +* After this call the PF will start to receive firmware logging based on the
+ * configuration set inice_fwlog_set.
+ */drivers/net/ethernet/intel/ice/ice_fwlog.c +10
-0+int ice_fwlog_register (struct ice_hw *hw) +{ + int status; + + if (!ice_fwlog_supported(hw)) + return -EOPNOTSUPP; + + status = ice_aq_fwlog_register(hw, true); + if (status) + ice_debug(hw, ICE_DBG_FW_LOG, "Failed to register forfirmware logging events over ARQ\n");
+ else
+hw->fwlog_cfg.options|=ICE_FWLOG_OPTION_IS_REGISTERED;drivers/net/ethernet/intel/ice/ice_fwlog.c +18
-0+ + return status; +} + +/** +* ice_fwlog_unregister - Unregister the PF from firmware logging +* @hw: pointer to the HW structure +*/ +int ice_fwlog_unregister (struct ice_hw *hw) +{ + int status; + + if (!ice_fwlog_supported(hw)) + return -EOPNOTSUPP; + + status = ice_aq_fwlog_register(hw, false); + if (status) + ice_debug(hw, ICE_DBG_FW_LOG, "Failed to unregister fromfirmware logging events over ARQ\n");
+ else
+hw->fwlog_cfg.options&= ~ICE_FWLOG_OPTION_IS_REGISTERED;drivers/net/ethernet/intel/ice/ice_fwlog.c +4
-0+ + return status; +} +/**
*ice_aq_fwlog_get- Get the current firmware logging configuration (0xFF32)
* @hw: pointer to the HW structuredrivers/net/ethernet/intel/ice/ice_fwlog.c void ice_fwlog_set_support_ena(struct ice_hw *hw) · line 376
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +8
-0@@ -115,3 +367,28 @@ void ice_fwlog_set_support_ena(struct ice_hw *hw) kfree(cfg); } + +/** +* ice_fwlog_get - Get the firmware logging settings +* @hw: pointer to the HW structure +* @cfg: config to populate based on current firmware logging settings +*/ +int +ice_fwlog_get (struct ice_hw *hw,struct ice_fwlog_cfg *cfg)and this one. Can you check that all the others are pulled up properly as well?
Quoted 32 lines
drivers/net/ethernet/intel/ice/ice_fwlog.c +17
-0+{ + int status; + + if (!ice_fwlog_supported(hw)) + return -EOPNOTSUPP; + + if (!cfg) + return -EINVAL; + + status = ice_aq_fwlog_get(hw, cfg); + if (status) + return status; + + cache_cfg(hw, cfg); + + return 0; +}drivers/net/ethernet/intel/ice/ice_fwlog.h +5
-0@@ -48,4 +48,9 @@ struct ice_fwlog_cfg { void ice_fwlog_set_support_ena(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_ */drivers/net/ethernet/intel/ice/ice_type.h +0
-0
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_type.h +0
-0@@ -861,6 +861,7 @@ struct ice_hw {u8 fw_patch; /* firmware patch version */
u32 fw_build; /* firmware build number */
+ structice_fwlog_cfgfwlog_cfg;
boolfwlog_support_ena; /* does hardware support FW logging? */ boolfwlog_ena; /* currently logging? */
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 3/5] ice: add ability to query/set FW log level and resolution
In reply to Paul M Stillwell JrDear Paul,
Thank you for the patch.
Am 28.11.22 um 22:47 schrieb Paul M Stillwell Jr:
Quoted 4 lines
The E8xx has the ability to change the FW log level and the granularity at which the logs get output. Enable the ability to see what the current values are and to change them.
Please reflow the message for 75 characters per line.
Please add the examples, how to list and change the current values.
A small comment regarding the implementation would also be nice, and maybe a reference to the used datasheet (name, revision).
Quoted 109 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 + drivers/net/ethernet/intel/ice/ice_common.c | 4 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 142 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 277 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + 6 files changed, 429 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +4
-0@@ -2406,7 +2406,11 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow =0x1001 , +/* FW Logging Commands */ + 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_common.c +3
-1@@ -879,7 +879,9 @@ int ice_init_hw(struct ice_hw *hw)if (status) goto err_unroll_cqinit; -ice_fwlog_set_support_ena (hw); + 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)drivers/net/ethernet/intel/ice/ice_devlink.c +51
-2@@ -1488,6 +1488,8 @@ enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED ,ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , + ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION, }; static int@@ -1530,8 +1532,121 @@ static int ice_devlink_fwlog_enabled_set(struct devlink *devlink, u32 id, struct devlink_param_gset_ctx *ctx) { - /* set operation is unsupported at this time */ - return -EOPNOTSUPP; + struct ice_pf *pf = devlink_priv(devlink); +struct ice_hw *hw = &pf->hw; +int status; + +/* only support fw log commands on PF 0 */ +if (hw->bus.func) +return -EOPNOTSUPP ; + +if (hw->fwlog_ena == ctx->val.vbool) +return 0 ; + + hw->fwlog_ena = ctx->val.vbool; + +if (hw->fwlog_ena) + hw->fwlog_cfg.options |=ICE_FWLOG_OPTION_ARQ_ENA ; +else + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + +/* send the cfg to FW and register for events */ + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +return status; + +if (hw->fwlog_ena) { + status =ice_fwlog_register (hw); +if (status) +return status; + }else { + status =ice_fwlog_unregister (hw); +if (status) +return status; + } + +return 0 ; +} + +static int +ice_devlink_fwlog_level_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return -EOPNOTSUPP ; + +/* all the log levels are the same so pick the first one */ + ctx->val.vu8 = pf->hw.fwlog_cfg.module_entries[0 ].log_level; +
drivers/net/ethernet/intel/ice/ice_devlink.c static int · line 1593
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +10
-0+return 0 ; +} + +static int +ice_devlink_fwlog_level_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct ice_pf *pf =devlink_priv (devlink); +struct ice_fwlog_cfg *cfg; +u8 i;
Please use native types. Limiting the width actually generates more code [1]. (You can also check that with scripts/bloat-o-meter.)
(Please also fix that for the rest of the added code.)
[…]
Kind regards,
Paul
[1]: https://notabs.org/coding/smallIntsBigPenalty.htm
_______________________________________________
Intel-wired-lan mailing list [email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 4/5 ice: disable FW logging on driver unload
In reply to Paul M Stillwell JrThe FW is running in it's own context irregardless of what the driver is doing. In this case, if the driver previously registered for FW log events and then the driver unloads without informing the FW to unregister for FW log events then the FW still has a timer running to output FW logs.
The next time the driver loads and tries to register for FW log events then the FW returns an error, but still enables the continued outputting of FW logs. This causes an IO error to devlink which isn't intuitive since the logs are still being output.
Fix this by disabling FW logging when the driver is being unloaded.
--- drivers/net/ethernet/intel/ice/ice_devlink.c | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +24 -8
@@ -378,6 +378,10 @@ static int ice_devlink_info_get(struct devlink *devlink,enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_TX_BALANCE , +ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , +ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , +ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , };/**
@@ -1484,14 +1488,6 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,return 0 ; } -enum ice_devlink_param_id { -ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX , -ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , -ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , -ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , -ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , -}; -static int ice_devlink_fwlog_supported_get (struct devlink *devlink,u32 id,struct devlink_param_gset_ctx *ctx)
@@ -1743,6 +1739,26 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister (struct ice_pf *pf) { +struct ice_hw *hw = &pf->hw; + +/* make sure FW logging is disabled to not put the FW in a weird state +* for the next driver load +*/ +if (hw->fwlog_ena) { +int status; + + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , + status); + + status =ice_fwlog_unregister (hw); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , + status); + } +devlink_unregister (priv_to_devlink (pf)); }
Signature · 6 lines
2.35.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 4/5] ice: disable FW logging on driver unload
Quoted 23 lines · Paul M Stillwell Jr
The FW is running in it's own context irregardless of what the driver is doing. In this case, if the driver previously registered for FW log events and then the driver unloads without informing the FW to unregister for FW log events then the FW still has a timer running to output FW logs.
The next time the driver loads and tries to register for FW log events then the FW returns an error, but still enables the continued outputting of FW logs. This causes an IO error to devlink which isn't intuitive since the logs are still being output.
Fix this by disabling FW logging when the driver is being unloaded.
Signed-off-by Paul M Stillwell Jr <[email protected]>--- drivers/net/ethernet/intel/ice/ice_devlink.c | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-)drivers/net/ethernet/intel/ice/ice_devlink.c +0
-0
drivers/net/ethernet/intel/ice/ice_devlink.c static int ice_devlink_info_get(struct devlink *devlink, · line 384
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +4
-0@@ -378,6 +378,10 @@ static int ice_devlink_info_get(struct devlink *devlink,enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_TX_BALANCE , +ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , +ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , +ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION ,
My understanding was the the community doesn't like private devlink params. Was some investigation done whether the FW logging can be done using some generic API ? I believe we had a discussion about this a long time ago. Maybe I'm a bit out of a loop at this point :)
Quoted 35 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +13
-8};/** @@ -1484,14 +1488,6 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,return 0 ; } -enum ice_devlink_param_id { -ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX , -ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , -ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , -ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , -ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , -}; -static int ice_devlink_fwlog_supported_get (struct devlink *devlink,u32 id,struct devlink_param_gset_ctx *ctx)@@ -1743,6 +1739,26 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister (struct ice_pf *pf) { +struct ice_hw *hw = &pf->hw; + +/* make sure FW logging is disabled to not put the FW in a weird state +* for the next driver load +*/ +if (hw->fwlog_ena) { +int status; + + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , + status);
drivers/net/ethernet/intel/ice/ice_devlink.c void ice_devlink_register(struct ice_pf *pf) · line 1764
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +7
-0+ + status =ice_fwlog_unregister (hw); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , + status); + } +devlink_unregister (priv_to_devlink (pf)); }
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 4/5] ice: disable FW logging on driver unload
Quoted 30 lines · Michal
Quoted 27 lines · Paul M Stillwell Jr
The FW is running in it's own context irregardless of what the driver is doing. In this case, if the driver previously registered for FW log events and then the driver unloads without informing the FW to unregister for FW log events then the FW still has a timer running to output FW logs.
The next time the driver loads and tries to register for FW log events then the FW returns an error, but still enables the continued outputting of FW logs. This causes an IO error to devlink which isn't intuitive since the logs are still being output.
Fix this by disabling FW logging when the driver is being unloaded.
Signed-off-by Paul M Stillwell Jr <[email protected]>--- drivers/net/ethernet/intel/ice/ice_devlink.c | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-)drivers/net/ethernet/intel/ice/ice_devlink.c +1
-0@@ -378,6 +378,10 @@ static int ice_devlink_info_get(struct devlink *devlink,enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_TX_BALANCE , +ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED ,
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c static int ice_devlink_info_get(struct devlink *devlink, · line 384
Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +3
-0+ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , + ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION,My understanding was the the community doesn't like private devlink params. Was some investigation done whether the FW logging can be done using some generic API ? I believe we had a discussion about this a long time ago. Maybe I'm a bit out of a loop at this point :)
Yeah, I looked at all the other devlink interfaces and couldn't find one that really worked. I considered adding a brand new interface, but didn't want to go that route unless we have to because I'm guessing that every device that can get FW logs has a slightly different way to do it.
If you have a suggestion then I'm all ears :).
Quoted 37 lines
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +15
-8};/** @@ -1484,14 +1488,6 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,return 0 ; } -enum ice_devlink_param_id { -ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX , -ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , -ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , -ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , -ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , -}; -static int ice_devlink_fwlog_supported_get (struct devlink *devlink,u32 id,struct devlink_param_gset_ctx *ctx)@@ -1743,6 +1739,26 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister (struct ice_pf *pf) { +struct ice_hw *hw = &pf->hw; + +/* make sure FW logging is disabled to not put the FW in a weird state +* for the next driver load +*/ +if (hw->fwlog_ena) { +int status; + + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , + status); + + status =ice_fwlog_unregister (hw);
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_devlink.c void ice_devlink_register(struct ice_pf *pf) · line 1764
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +5
-0+if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , + status); + } +devlink_unregister (priv_to_devlink (pf)); }
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainerRe: [Intel-wired-lan] [PATCH net-next 4/5] ice: disable FW logging on driver unload
In reply to Paul M Stillwell JrQuoted 34 lines · Paul M Stillwell Jr
The FW is running in it's own context irregardless of what the driver is doing. In this case, if the driver previously registered for FW log events and then the driver unloads without informing the FW to unregister for FW log events then the FW still has a timer running to output FW logs.
The next time the driver loads and tries to register for FW log events then the FW returns an error, but still enables the continued outputting of FW logs. This causes an IO error to devlink which isn't intuitive since the logs are still being output.
Fix this by disabling FW logging when the driver is being unloaded.
Signed-off-by Paul M Stillwell Jr <[email protected]>--- drivers/net/ethernet/intel/ice/ice_devlink.c | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-)drivers/net/ethernet/intel/ice/ice_devlink.c +4
-0@@ -378,6 +378,10 @@ static int ice_devlink_info_get(struct devlink *devlink,enum ice_devlink_param_id {ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX ,ICE_DEVLINK_PARAM_ID_TX_BALANCE , +ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , +ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , +ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , +ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , };/**
drivers/net/ethernet/intel/ice/ice_devlink.c ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id, · line 1493
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +0
-7@@ -1484,14 +1488,6 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,return 0 ; } -enum ice_devlink_param_id { -ICE_DEVLINK_PARAM_ID_BASE =DEVLINK_PARAM_GENERIC_ID_MAX , -ICE_DEVLINK_PARAM_ID_FWLOG_SUPPORTED , -ICE_DEVLINK_PARAM_ID_FWLOG_ENABLED , -ICE_DEVLINK_PARAM_ID_FWLOG_LEVEL , -ICE_DEVLINK_PARAM_ID_FWLOG_RESOLUTION , -};
Is there a reason you didn't add to the original enum in the previous patches and are it combining now?
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +13
-1-static int ice_devlink_fwlog_supported_get (struct devlink *devlink,u32 id,struct devlink_param_gset_ctx *ctx)@@ -1743,6 +1739,26 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister (struct ice_pf *pf) { +struct ice_hw *hw = &pf->hw; + +/* make sure FW logging is disabled to not put the FW in a weird state +* for the next driver load +*/ +if (hw->fwlog_ena) { +int status; + + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , + status);
drivers/net/ethernet/intel/ice/ice_devlink.c void ice_devlink_register(struct ice_pf *pf) · line 1764
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_devlink.c +7
-0+ + status =ice_fwlog_unregister (hw); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , + status); + } +devlink_unregister (priv_to_devlink (pf)); }
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 5/5 ice: use debugfs to output FW log data
In reply to Paul M Stillwell JrThe FW log data can be quite large so we don't want to use syslog. Instead take advantage of debugfs to write the data to.
Also, a previous patch addded codde to disable FW logging when the driver was unloaded. The code was added to ice_devlink_unregister(), which didn't seem correct so move the disabling of FW logging on driver unload to a better place.
--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 20 ---- drivers/net/ethernet/intel/ice/ice_main.c | 98 ++++++++++++++++ 6 files changed, 235 insertions(+), 21 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_debugfs.c
drivers/net/ethernet/intel/ice/Makefile +2 -1
@@ -33,7 +33,8 @@ ice-y := ice_main.o \ ice_ethtool.o \ ice_repr.o \ ice_tc_lib.o \ - ice_fwlog.o + ice_fwlog.o \ + ice_debugfs.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ ice_virtchnl.o \
drivers/net/ethernet/intel/ice/ice.h +24 -0
@@ -552,6 +552,9 @@ 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 */ +#ifdef CONFIG_DEBUG_FS +struct dentry *ice_debugfs_pf; +#endif /* CONFIG_DEBUG_FS */ struct ice_vfs vfs;DECLARE_BITMAP (features,ICE_F_MAX );DECLARE_BITMAP (state,ICE_STATE_NBITS );
@@ -634,6 +637,8 @@ struct ice_pf {#define ICE_VF_AGG_NODE_ID_START 65#define ICE_MAX_VF_AGG_NODES 32struct 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 {
@@ -648,6 +653,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 64 +/** * ice_vector_ch_enabled * @qv: pointer to q_vector, can be NULL
@@ -872,6 +886,16 @@ 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 ); +#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 ) { } +#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 +2 -0
@@ -2406,11 +2406,13 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow =0x1001 , +/* FW Logging Commands */ 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 , + ice_aqc_opc_fw_logs_get = 0xFF34, };#endif /* _ICE_ADMINQ_CMD_H_ */
drivers/net/ethernet/intel/ice/ice_debugfs.c new file +109 -0
109 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_devlink.c +0 -20
@@ -1739,26 +1739,6 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister (struct ice_pf *pf) { -struct ice_hw *hw = &pf->hw; - -/* make sure FW logging is disabled to not put the FW in a weird state -* for the next driver load -*/ -if (hw->fwlog_ena) { -int status; - - hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; - status =ice_fwlog_set (hw, &hw->fwlog_cfg); -if (status) -dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , - status); - - status =ice_fwlog_unregister (hw); -if (status) -dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , - status); - } -devlink_unregister (priv_to_devlink (pf)); }
drivers/net/ethernet/intel/ice/ice_main.c +98 -0
146 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
Re: [Intel-wired-lan] [PATCH net-next 5/5] ice: use debugfs to output FW log data
Dear Paul,
Am 28.11.22 um 22:47 schrieb Paul M Stillwell Jr:
Quoted 4 lines
The FW log data can be quite large so we don't want to use syslog. Instead take advantage of debugfs to write the data to.
Also, a previous patch addded codde to disable FW logging when
added code
Quoted 3 lines
the driver was unloaded. The code was added to
ice_devlink_unregister(), which didn't seem correct so move the disabling of FW logging on driver unload to a better place.
It’d be great if you added examples, how to get the log from debugfs, and decode(?) it.
Kind regards,
Paul
Quoted 10 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 20 ---- drivers/net/ethernet/intel/ice/ice_main.c | 98 ++++++++++++++++ 6 files changed, 235 insertions(+), 21 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_debugfs.c
[…]
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 5/5] ice: use debugfs to output FW log data
Quoted 11 lines · Paul Menzel
Dear Paul,
Am 28.11.22 um 22:47 schrieb Paul M Stillwell Jr:
Quoted 4 lines
The FW log data can be quite large so we don't want to use syslog. Instead take advantage of debugfs to write the data to.
Also, a previous patch addded codde to disable FW logging when
added code
Good catch, will fix.
Quoted 6 lines
Quoted 3 lines
the driver was unloaded. The code was added to
ice_devlink_unregister(), which didn't seem correct so move the disabling of FW logging on driver unload to a better place.It’d be great if you added examples, how to get the log from debugfs, and decode(?) it.
Will do
Quoted 17 lines
Kind regards,
Paul
Quoted 10 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>---
drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 20 ---- drivers/net/ethernet/intel/ice/ice_main.c | 98 ++++++++++++++++6 files changed, 235 insertions(+), 21 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_debugfs.c
Quoted 1 line
[…]
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainerRe: [Intel-wired-lan] [PATCH net-next 5/5] ice: use debugfs to output FW log data
In reply to Paul M Stillwell JrQuoted 7 lines · Paul M Stillwell Jr
The FW log data can be quite large so we don't want to use syslog. Instead take advantage of debugfs to write the data to.
Also, a previous patch addded codde to disable FW logging when the driver was unloaded. The code was added to
ice_devlink_unregister(), which didn't seem correct so move the disabling of FW logging on driver unload to a better place.
Since this was done in the patch directly preceding this, why don't you just modify the previous patch to put it in the proper place?
Quoted 87 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 20 ---- drivers/net/ethernet/intel/ice/ice_main.c | 98 ++++++++++++++++ 6 files changed, 235 insertions(+), 21 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_debugfs.cdrivers/net/ethernet/intel/ice/Makefile +2
-1@@ -33,7 +33,8 @@ ice-y := ice_main.o \ ice_ethtool.o \ ice_repr.o \ ice_tc_lib.o \ - ice_fwlog.o + ice_fwlog.o \ + ice_debugfs.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ ice_virtchnl.o \drivers/net/ethernet/intel/ice/ice.h +24
-0@@ -552,6 +552,9 @@ 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 */ +#ifdef CONFIG_DEBUG_FS +struct dentry *ice_debugfs_pf; +#endif /* CONFIG_DEBUG_FS */ struct ice_vfs vfs;DECLARE_BITMAP (features,ICE_F_MAX );DECLARE_BITMAP (state,ICE_STATE_NBITS );@@ -634,6 +637,8 @@ struct ice_pf {#define ICE_VF_AGG_NODE_ID_START 65#define ICE_MAX_VF_AGG_NODES 32struct 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 {@@ -648,6 +653,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 64 +/** * ice_vector_ch_enabled * @qv: pointer to q_vector, can be NULL @@ -872,6 +886,16 @@ 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 ); +#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 ) { } +#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 +0
-0
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h enum ice_adminq_opc { · line 2415
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +2
-0@@ -2406,11 +2406,13 @@ enum ice_adminq_opc {/* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow =0x1001 , +/* FW Logging Commands */ 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 , + ice_aqc_opc_fw_logs_get = 0xFF34,
I don't think I see this being used.
Quoted 211 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0
-0};#endif /* _ICE_ADMINQ_CMD_H_ */ drivers/net/ethernet/intel/ice/ice_debugfs.c new file +109
-0@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, Intel Corporation. */ + +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <linux/random.h> +#include "ice.h" + +static struct dentry *ice_debugfs_root; + +/** +* ice_debugfs_command_read - read from command datum +* @filp: the opened file +* @buffer: where to write the data for the user to read +* @count: the size of the user's buffer +* @ppos: file position offset +*/ +static ssize_t ice_debugfs_command_read (struct file *filp,char __user *buffer, +size_t count,loff_t *ppos) +{ +struct ice_pf *pf = filp->private_data; +struct device *dev =ice_pf_to_dev (pf); +struct ice_fwlog_data *log, *tmp_log; +int data_copied =0 ; + +if (list_empty (&pf->fwlog_data_list)) { +dev_info (dev,"FW log is empty\n" ); +return 0 ; + } + +list_for_each_entry_safe (log, tmp_log, &pf->fwlog_data_list, list) { +u16 cur_buf_len = log->data_size; +int retval; + +if (cur_buf_len > count) +break ; + + retval =copy_to_user (buffer, log->data, cur_buf_len); +if (retval) +return -EFAULT ; + + data_copied += cur_buf_len; + buffer += cur_buf_len; + count -= cur_buf_len; + *ppos += cur_buf_len; + +/* don't delete the list element until we know it got copied */ +kfree (log->data); +list_del (&log->list); +kfree (log); + pf->fwlog_list_count--; + } + +return data_copied; +} + +static const struct file_operations ice_debugfs_command_fops = { + .owner =THIS_MODULE , + .open = simple_open, + .read = ice_debugfs_command_read, +}; + +/** +* ice_debugfs_fwlog_init - setup the debugfs directory +* @pf: the ice that is starting up +*/ +void ice_debugfs_fwlog_init (struct ice_pf *pf) +{ +const char *name =pci_name (pf->pdev); +struct dentry *pfile; + +/* only support fw log commands on PF 0 */ +if (pf->hw.bus.func) +return ; + + pf->ice_debugfs_pf =debugfs_create_dir (name, ice_debugfs_root); +if (IS_ERR (pf->ice_debugfs_pf)) +return ; + + pfile =debugfs_create_file ("fwlog" ,0400 , pf->ice_debugfs_pf, pf, + &ice_debugfs_command_fops); +if (!pfile) + goto create_failed; + +return ; + +create_failed: +dev_err (ice_pf_to_dev (pf),"debugfs dir/file for %s failed\n" , name); +debugfs_remove_recursive (pf->ice_debugfs_pf); +} + +/** +* ice_debugfs_init - create root directory for debugfs entries +*/ +void ice_debugfs_init (void ) +{ + ice_debugfs_root =debugfs_create_dir (KBUILD_MODNAME ,NULL ); +if (IS_ERR (ice_debugfs_root)) +pr_info ("init of debugfs failed\n" ); +} + +/** +* ice_debugfs_exit - remove debugfs entries +*/ +void ice_debugfs_exit (void ) +{ +debugfs_remove_recursive (ice_debugfs_root); + ice_debugfs_root =NULL ; +}drivers/net/ethernet/intel/ice/ice_devlink.c +0
-20@@ -1739,26 +1739,6 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister (struct ice_pf *pf) { -struct ice_hw *hw = &pf->hw; - -/* make sure FW logging is disabled to not put the FW in a weird state -* for the next driver load -*/ -if (hw->fwlog_ena) { -int status; - - hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; - status =ice_fwlog_set (hw, &hw->fwlog_cfg); -if (status) -dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , - status); - - status =ice_fwlog_unregister (hw); -if (status) -dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , - status); - } -devlink_unregister (priv_to_devlink (pf)); }drivers/net/ethernet/intel/ice/ice_main.c +42
-0@@ -1213,6 +1213,45 @@ 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 device *dev =ice_pf_to_dev (pf); +struct ice_fwlog_data *fwlog; + +if (pf->fwlog_list_count >=ICE_FWLOG_MAX_SIZE ) { +dev_info (dev,"Reached max list size for fwlog list!\n" ); +return ; + } + + fwlog =kzalloc (sizeof (*fwlog),GFP_KERNEL ); +if (!fwlog) { +dev_warn (dev,"Couldn't allocate memory for FWlog element\n" ); +return ; + } + +INIT_LIST_HEAD (&fwlog->list); + + fwlog->data_size =le16_to_cpu (event->desc.datalen); + fwlog->data =kzalloc (fwlog->data_size,GFP_KERNEL ); +if (!fwlog->data) { +dev_warn (dev,"Couldn't allocate memory for FWlog data\n" ); +kfree (fwlog); +return ; + } + +memcpy (fwlog->data, event->msg_buf, fwlog->data_size); + +list_add_tail (&fwlog->list, &pf->fwlog_data_list); + + pf->fwlog_list_count++; +} +enum ice_aq_task_state {ICE_AQ_TASK_WAITING =0 ,ICE_AQ_TASK_COMPLETE ,@@ -1486,6 +1525,9 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)if (!ice_is_malicious_vf (pf, &event, i, pending))ice_vc_process_vf_msg (pf, &event);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 ;@@ -4688,6 +4730,52 @@ static int ice_register_netdev(struct ice_pf *pf)return err;
drivers/net/ethernet/intel/ice/ice_main.c static int ice_register_netdev(struct ice_pf *pf) · line 4740
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +8
-0} +/** +* ice_pf_fwlog_init - initialize FW logging on device init +* @pf: pointer to the PF struct +* +* This should always be called after ice_hw_init(). +*/ +static void +ice_pf_fwlog_init (struct ice_pf *pf)
Is this going to expand to other things or why not just call it ice_fwlog_init()?
drivers/net/ethernet/intel/ice/ice_main.c static int ice_register_netdev(struct ice_pf *pf) · line 4750
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +10
-0+{ +INIT_LIST_HEAD (&pf->fwlog_data_list); +} + +/** +* ice_pf_fwlog_deinit - clear FW logging metadata on device exit +* @pf: pointer to the PF struct +*/ +static void +ice_pf_fwlog_deinit (struct ice_pf *pf)
same with this one
Quoted 32 lines
drivers/net/ethernet/intel/ice/ice_main.c +28
-0+{ +struct ice_fwlog_data *fwlog, *fwlog_tmp; +struct ice_hw *hw = &pf->hw; + +/* make sure FW logging is disabled to not put the FW in a weird state +* for the next driver load +*/ +if (hw->fwlog_ena) { +int status; + + hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA ; + status =ice_fwlog_set (hw, &hw->fwlog_cfg); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to turn off FW logging, status: %d\n" , + status); + + status =ice_fwlog_unregister (hw); +if (status) +dev_warn (ice_pf_to_dev (pf),"Unable to unregister FW logging, status: %d\n" , + status); + } + +list_for_each_entry_safe (fwlog, fwlog_tmp, &pf->fwlog_data_list, list) { +kfree (fwlog->data); +kfree (fwlog); + } +} +/** * ice_probe - Device initialization routine * @pdev: PCI device information struct
drivers/net/ethernet/intel/ice/ice_main.c ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) · line 4869
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c +4
-0@@ -4773,8 +4861,12 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) goto err_exit_unroll; } +ice_pf_fwlog_init (pf); +ice_init_feature_support (pf); +ice_debugfs_fwlog_init (pf); +
Do these need to be unrolled for error path?
Quoted 27 lines
drivers/net/ethernet/intel/ice/ice_main.c +5
-0err =ice_init_ddp_config (hw, pf);/* during topology change ice_init_hw may fail */ @@ -5139,6 +5231,8 @@ static void ice_remove(struct pci_dev *pdev)msleep (100 ); } +ice_pf_fwlog_deinit (pf); +ice_tc_indir_block_remove (pf);if (test_bit (ICE_FLAG_SRIOV_ENA , pf->flags)) {@@ -5620,10 +5714,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_main.c static void __exit ice_module_exit(void) · line 5743
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +1
-0@@ -5640,6 +5737,7 @@ static void __exit ice_module_exit(void) {pci_unregister_driver (&ice_driver);destroy_workqueue (ice_wq); +ice_debugfs_exit ();pr_info ("module unloaded\n" ); }module_exit (ice_module_exit);
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 5/5] ice: use debugfs to output FW log data
Quoted 11 lines · Tony Nguyen
Quoted 7 lines · Paul M Stillwell Jr
The FW log data can be quite large so we don't want to use syslog. Instead take advantage of debugfs to write the data to.
Also, a previous patch addded codde to disable FW logging when the driver was unloaded. The code was added to
ice_devlink_unregister(), which didn't seem correct so move the disabling of FW logging on driver unload to a better place.Since this was done in the patch directly preceding this, why don't you just modify the previous patch to put it in the proper place?
I'll look and see what things look like and see if I can move it
Quoted 88 lines
Quoted 88 lines
Signed-off-by Paul M Stillwell Jr <[email protected]>---
drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 2 + drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 20 ---- drivers/net/ethernet/intel/ice/ice_main.c | 98 ++++++++++++++++6 files changed, 235 insertions(+), 21 deletions(-)create mode 100644
drivers/net/ethernet/intel/ice/ice_debugfs.cdrivers/net/ethernet/intel/ice/Makefile +2
-1@@ -33,7 +33,8 @@ ice-y := ice_main.o \ ice_ethtool.o \ ice_repr.o \ ice_tc_lib.o \ - ice_fwlog.o + ice_fwlog.o \ + ice_debugfs.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ ice_virtchnl.o \drivers/net/ethernet/intel/ice/ice.h +0
-0@@ -552,6 +552,9 @@ 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 */drivers/net/ethernet/intel/ice/ice.h +3
-0+#ifdef CONFIG_DEBUG_FS + struct dentry *ice_debugfs_pf; +#endif /* CONFIG_DEBUG_FS */ struct
ice_vfsvfs;
DECLARE_BITMAP(features, ICE_F_MAX);
DECLARE_BITMAP(state, ICE_STATE_NBITS);drivers/net/ethernet/intel/ice/ice.h +21
-0@@ -634,6 +637,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 {@@ -648,6 +653,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 64 + /*** ice_vector_ch_enabled * @qv: pointer to q_vector, can be NULL @@ -872,6 +886,16 @@ 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 ); +#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 ) { } +#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 +1
-0@@ -2406,11 +2406,13 @@ enum ice_adminq_opc { /* Standalone Commands/Events */ ice_aqc_opc_event_lan_overflow = 0x1001, +
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h enum ice_adminq_opc { · line 2415
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +1
-0/* FW Logging Commands */ 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, + ice_aqc_opc_fw_logs_get = 0xFF34,I don't think I see this being used.
Will remove
Quoted 218 lines
Quoted 218 lines
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +0
-0}; #endif /* _ICE_ADMINQ_CMD_H_ */drivers/net/ethernet/intel/ice/ice_debugfs.c new file +18
-0@@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, Intel Corporation. */ + +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <linux/random.h> +#include "ice.h" + +static struct dentry *ice_debugfs_root; + +/** +* ice_debugfs_command_read - read from command datum +* @filp: the opened file +* @buffer: where to write the data for the user to read +* @count: the size of the user's buffer +* @ppos: file position offset +*/ +static ssize_t ice_debugfs_command_read(struct file *filp, char
__user*buffer,
+size_tcount,loff_t*ppos)drivers/net/ethernet/intel/ice/ice_debugfs.c new file +69
-0+{ + struct ice_pf *pf = filp->private_data; + struct device *dev = ice_pf_to_dev(pf); + struct ice_fwlog_data *log, *tmp_log; + int data_copied = 0; + + if (list_empty(&pf->fwlog_data_list)) { + dev_info(dev, "FW log is empty\n"); + return 0; + } + + list_for_each_entry_safe(log, tmp_log, &pf->fwlog_data_list, list) { + u16 cur_buf_len = log->data_size; + int retval; + + if (cur_buf_len > count) + break; + + retval = copy_to_user(buffer, log->data, cur_buf_len); + if (retval) + return -EFAULT; + + data_copied += cur_buf_len; + buffer += cur_buf_len; + count -= cur_buf_len; + *ppos += cur_buf_len; + + /* don't delete the list element until we know it got copied */ + kfree(log->data); + list_del(&log->list); + kfree(log); + pf->fwlog_list_count--; + } + + return data_copied; +} + +static const struct file_operations ice_debugfs_command_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = ice_debugfs_command_read, +}; + +/** +* ice_debugfs_fwlog_init - setup the debugfs directory +* @pf: the ice that is starting up +*/ +void ice_debugfs_fwlog_init (struct ice_pf *pf) +{ + const char *name = pci_name(pf->pdev); + struct dentry *pfile; + + /* only support fw log commands on PF 0 */ + if (pf->hw.bus.func) + return; + + pf->ice_debugfs_pf = debugfs_create_dir(name, ice_debugfs_root); + if (IS_ERR(pf->ice_debugfs_pf)) + return; + + pfile = debugfs_create_file("fwlog", 0400, pf->ice_debugfs_pf, pf, + &ice_debugfs_command_fops); + if (!pfile) + goto create_failed; + + return; + +create_failed: + dev_err(ice_pf_to_dev(pf), "debugfs dir/file for %s failed\n",name);
+debugfs_remove_recursive(pf->ice_debugfs_pf);drivers/net/ethernet/intel/ice/ice_debugfs.c new file +20
-0+} + +/** +* ice_debugfs_init - create root directory for debugfs entries +*/ +void ice_debugfs_init (void ) +{ + ice_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); + if (IS_ERR(ice_debugfs_root)) + pr_info("init of debugfs failed\n"); +} + +/** +* ice_debugfs_exit - remove debugfs entries +*/ +void ice_debugfs_exit (void ) +{ + debugfs_remove_recursive(ice_debugfs_root); + ice_debugfs_root = NULL; +}drivers/net/ethernet/intel/ice/ice_devlink.c +0
-3@@ -1739,26 +1739,6 @@ void ice_devlink_register(struct ice_pf *pf)*/ void ice_devlink_unregister(struct ice_pf *pf) { - struct ice_hw *hw = &pf->hw; - - /* make sure FW logging is disabled to not put the FW in a weirdstate
- * for the next driver load
- */
- if (hw->fwlog_ena) {
- int status;
-
-hw->fwlog_cfg.options&= ~ICE_FWLOG_OPTION_ARQ_ENA; - status =ice_fwlog_set(hw, &hw->fwlog_cfg);
- if (status)
- dev_warn(ice_pf_to_dev(pf), "Unable to turn off FW logging, status: %d\n",
- status);
-
- status =ice_fwlog_unregister(hw);
- if (status)
- dev_warn(ice_pf_to_dev(pf), "Unable to unregister FW logging, status: %d\n",
- status);
- }
-
devlink_unregister(priv_to_devlink(pf));
}drivers/net/ethernet/intel/ice/ice_main.c +42
-0@@ -1213,6 +1213,45 @@ 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 device *dev = ice_pf_to_dev(pf); + struct ice_fwlog_data *fwlog; + + if (pf->fwlog_list_count >= ICE_FWLOG_MAX_SIZE) { + dev_info(dev, "Reached max list size for fwlog list!\n"); + return; + } + + fwlog = kzalloc(sizeof(*fwlog), GFP_KERNEL); + if (!fwlog) { + dev_warn(dev, "Couldn't allocate memory for FWlog element\n"); + return; + } + + INIT_LIST_HEAD(&fwlog->list); + + fwlog->data_size = le16_to_cpu(event->desc.datalen); + fwlog->data = kzalloc(fwlog->data_size, GFP_KERNEL); + if (!fwlog->data) { + dev_warn(dev, "Couldn't allocate memory for FWlog data\n"); + kfree(fwlog); + return; + } + + memcpy(fwlog->data, event->msg_buf, fwlog->data_size); + + list_add_tail(&fwlog->list, &pf->fwlog_data_list); + + pf->fwlog_list_count++; +} + enum ice_aq_task_state { ICE_AQ_TASK_WAITING = 0, ICE_AQ_TASK_COMPLETE,@@ -1486,6 +1525,9 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type) if (!ice_is_malicious_vf(pf, &event, i, pending)) ice_vc_process_vf_msg(pf, &event); 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_main.c +2
-0@@ -4688,6 +4730,52 @@ static int ice_register_netdev(struct ice_pf *pf) return err; } +/** +* ice_pf_fwlog_init - initialize FW logging on device init
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c static int ice_register_netdev(struct ice_pf *pf) · line 4740
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_main.c +6
-0+* @pf: pointer to the PF struct +* +* This should always be called after ice_hw_init(). +*/ +static void +ice_pf_fwlog_init (struct ice_pf *pf)Is this going to expand to other things or why not just call it
ice_fwlog_init()?
The reason I called it ice_pf_fwlog_init() is because it's going to get called for every PF. In my mind the implication of calling it ice_fwlog_init() is that it's only called once, which wouldn't be true.
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_main.c +4
-0+{ + INIT_LIST_HEAD(&pf->fwlog_data_list); +} +
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c static int ice_register_netdev(struct ice_pf *pf) · line 4750
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_main.c +6
-0+/** +* ice_pf_fwlog_deinit - clear FW logging metadata on device exit +* @pf: pointer to the PF struct +*/ +static void +ice_pf_fwlog_deinit (struct ice_pf *pf)same with this one
Same answer as above
Quoted 38 lines
Quoted 38 lines
drivers/net/ethernet/intel/ice/ice_main.c +5
-0+{ + struct ice_fwlog_data *fwlog, *fwlog_tmp; + struct ice_hw *hw = &pf->hw; + + /* make sure FW logging is disabled to not put the FW in a weirdstate
+ * for the next driver load
+ */
+ if (hw->fwlog_ena) {
+ int status;
+
+hw->fwlog_cfg.options&= ~ICE_FWLOG_OPTION_ARQ_ENA; + status =ice_fwlog_set(hw, &hw->fwlog_cfg);
+ if (status)
+ dev_warn(ice_pf_to_dev(pf), "Unable to turn off FW logging, status: %d\n",
+ status);
+
+ status =ice_fwlog_unregister(hw);
+ if (status)
+ dev_warn(ice_pf_to_dev(pf), "Unable to unregister FW logging, status: %d\n",
+ status);
+ }
+
+list_for_each_entry_safe(fwlog, fwlog_tmp, &pf->fwlog_data_list, list){
+kfree(fwlog->data);
+ kfree(fwlog);
+ }drivers/net/ethernet/intel/ice/ice_main.c +2
-0+} +/**
*ice_probe- Device initialization routine
* @pdev: PCI device information structdrivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -4773,8 +4861,12 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) goto err_exit_unroll;
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) · line 4869
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_main.c +4
-0} + ice_pf_fwlog_init(pf); + ice_init_feature_support(pf); + ice_debugfs_fwlog_init(pf); +Do these need to be unrolled for error path?
I don't think so. In ice_module_exit() we will remove the debugfs entry points
Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_main.c +5
-0err = ice_init_ddp_config(hw, pf); /* during topology change ice_init_hw may fail */@@ -5139,6 +5231,8 @@ static void ice_remove(struct pci_dev *pdev) msleep(100); } + ice_pf_fwlog_deinit(pf); + ice_tc_indir_block_remove(pf); if (test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) {@@ -5620,10 +5714,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;
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c static void __exit ice_module_exit(void) · line 5743
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c +1
-0@@ -5640,6 +5737,7 @@ static void __exit ice_module_exit(void) { pci_unregister_driver(&ice_driver); destroy_workqueue(ice_wq); + ice_debugfs_exit(); pr_info("module unloaded\n"); } module_exit(ice_module_exit);
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainerQuoted 46 lines · Paul M Stillwell Jr
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 controls knobs to get the exact data out of the FW for debugging.
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 new device parameters are added:
-fwlog_supported(read-only): does the FW support FW logging
-fwlog_enabled(read/write): is FW logging currently running
-fwlog_level(read/write): the log level enabled, valid values are 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_resolution(read/write): 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.This patch series adds the following set of devlink commands:
devlink dev param set <pci dev> name
fwlog_enabledvalue <true/false> cmode runtime devlink dev param set <pci dev> namefwlog_levelvalue <0-4> cmode runtime devlink dev param set <pci dev> namefwlog_resolutionvalue <1-128> cmode runtimePaul M Stillwell Jr (5):
ice: remove FW logging code
ice: enable devlink to check FW logging status
ice: add ability to query/set FW log level and resolution
ice: disable FW logging on driver unload
ice: use debugfs to output FW log data
Quoted 10 lines
drivers/net/ethernet/intel/ice/Makefile | 4 +- drivers/net/ethernet/intel/ice/ice.h | 24 ++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 164 ++++---- drivers/net/ethernet/intel/ice/ice_common.c | 218 +--------- drivers/net/ethernet/intel/ice/ice_debugfs.c | 109 +++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 205 ++++++++- drivers/net/ethernet/intel/ice/ice_fwlog.c | 394 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fwlog.h | 56 +++ drivers/net/ethernet/intel/ice/ice_main.c | 99 ++++- drivers/net/ethernet/intel/ice/ice_type.h | 23 +-
Please add Documentation for this
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan