Skip to content

Commit 283f105

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== add v2 FW logging for ice driver Paul Stillwell says: Firmware (FW) log support was added to the ice driver, but that version is no longer supported. There is a newer version of FW logging (v2) that adds more control knobs to get the exact data out of the FW for debugging. The interface for FW logging is debugfs. This was chosen based on discussions here: https://lore.kernel.org/netdev/[email protected]/ and https://lore.kernel.org/netdev/[email protected]/ We talked about using devlink in a variety of ways, but none of those options made any sense for the way the FW reports data. We briefly talked about using ethtool, but that seemed to go by the wayside. Ultimately it seems like using debugfs is the way to go so re-implement the code to use that. FW logging is across all the PFs on the device so restrict the commands to only PF0. If the device supports FW logging then a directory named 'fwlog' will be created under '/sys/kernel/debug/ice/<pci_dev>'. A variety of files will be created to manage the behavior of logging. The following files will be created: - modules/<module> - nr_messages - enable - log_size - data where modules/<module> is used to read/write the log level for a specific module nr_messages is used to determine how many events should be in each message sent to the driver enable is used to start/stop FW logging. This is a boolean value so only 1 or 0 are permissible values log_size is used to configure the amount of memory the driver uses for log data data is used to read/clear the log data Generally there is a lot of data and dumping that data to syslog will result in a loss of data. This causes problems when decoding the data and the user doesn't know that data is missing until later. Instead of dumping the FW log output to syslog use debugfs. This ensures that all the data the driver has gets retrieved correctly. The FW log data is binary data that the FW team decodes to determine what happened in firmware. The binary blob is sent to Intel for decoding. --- v6: - use seq_printf() for outputting module info when reading from 'module' file - replace code that created argc and argv for handling command line input - removed checks in all the _read() and _write() functions to see if FW logging is supported because the files will not exist if it is not supported - removed warnings on allocation failures on debugfs file creation failures - removed a newline between memory allocation and checking if the memory was allocated - fixed cases where we could just return the value from a function call instead of saving the value in a variable - moved the check for PFO in ice_fwlog_init() to an earlier patch - reworked all of argument scanning in the _write() functions in ice_debugfs.c to remove adding characters past the end of the buffer v5: https://lore.kernel.org/netdev/[email protected]/ - changed the log level configuration from a single file for all modules to a file per module. - changed 'nr_buffs' to 'log_size' because users understand memory sizes better than a number of buffers - changed 'resolution' to 'nr_messages' to better reflect what it represents - updated documentation to reflect these changes - updated documentation to indicate that FW logging must be disabled to clear the data. also clarified that any value written to the 'data' file will clear the data v4: https://lore.kernel.org/netdev/[email protected]/ - removed CONFIG_DEBUG_FS wrapper around code because the debugfs calls handle this case already - moved ice_debugfs_exit() call to remove unreachable code issue - minor changes to documentation based on feedback v3: https://lore.kernel.org/netdev/[email protected]/ - Adjust error path cleanup in ice_module_init() for unreachable code. v2: https://lore.kernel.org/netdev/[email protected]/ - Rewrote code to use debugfs instead of devlink v1: https://lore.kernel.org/netdev/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b84d66b + d96f04e commit 283f105

File tree

11 files changed

+1507
-315
lines changed

11 files changed

+1507
-315
lines changed

Documentation/networking/device_drivers/ethernet/intel/ice.rst

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,147 @@ driver writes raw bytes by the GNSS object to the receiver through i2c. Please
895895
refer to the hardware GNSS module documentation for configuration details.
896896

897897

898+
Firmware (FW) logging
899+
---------------------
900+
The driver supports FW logging via the debugfs interface on PF 0 only. The FW
901+
running on the NIC must support FW logging; if the FW doesn't support FW logging
902+
the 'fwlog' file will not get created in the ice debugfs directory.
903+
904+
Module configuration
905+
~~~~~~~~~~~~~~~~~~~~
906+
Firmware logging is configured on a per module basis. Each module can be set to
907+
a value independent of the other modules (unless the module 'all' is specified).
908+
The modules will be instantiated under the 'fwlog/modules' directory.
909+
910+
The user can set the log level for a module by writing to the module file like
911+
this::
912+
913+
# echo <log_level> > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/<module>
914+
915+
where
916+
917+
* log_level is a name as described below. Each level includes the
918+
messages from the previous/lower level
919+
920+
* none
921+
* error
922+
* warning
923+
* normal
924+
* verbose
925+
926+
* module is a name that represents the module to receive events for. The
927+
module names are
928+
929+
* general
930+
* ctrl
931+
* link
932+
* link_topo
933+
* dnl
934+
* i2c
935+
* sdp
936+
* mdio
937+
* adminq
938+
* hdma
939+
* lldp
940+
* dcbx
941+
* dcb
942+
* xlr
943+
* nvm
944+
* auth
945+
* vpd
946+
* iosf
947+
* parser
948+
* sw
949+
* scheduler
950+
* txq
951+
* rsvd
952+
* post
953+
* watchdog
954+
* task_dispatch
955+
* mng
956+
* synce
957+
* health
958+
* tsdrv
959+
* pfreg
960+
* mdlver
961+
* all
962+
963+
The name 'all' is special and allows the user to set all of the modules to the
964+
specified log_level or to read the log_level of all of the modules.
965+
966+
Example usage to configure the modules
967+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
968+
969+
To set a single module to 'verbose'::
970+
971+
# echo verbose > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/link
972+
973+
To set multiple modules then issue the command multiple times::
974+
975+
# echo verbose > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/link
976+
# echo warning > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/ctrl
977+
# echo none > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/dcb
978+
979+
To set all the modules to the same value::
980+
981+
# echo normal > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/all
982+
983+
To read the log_level of a specific module (e.g. module 'general')::
984+
985+
# cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/general
986+
987+
To read the log_level of all the modules::
988+
989+
# cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/modules/all
990+
991+
Enabling FW log
992+
~~~~~~~~~~~~~~~
993+
Configuring the modules indicates to the FW that the configured modules should
994+
generate events that the driver is interested in, but it **does not** send the
995+
events to the driver until the enable message is sent to the FW. To do this
996+
the user can write a 1 (enable) or 0 (disable) to 'fwlog/enable'. An example
997+
is::
998+
999+
# echo 1 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/enable
1000+
1001+
Retrieving FW log data
1002+
~~~~~~~~~~~~~~~~~~~~~~
1003+
The FW log data can be retrieved by reading from 'fwlog/data'. The user can
1004+
write any value to 'fwlog/data' to clear the data. The data can only be cleared
1005+
when FW logging is disabled. The FW log data is a binary file that is sent to
1006+
Intel and used to help debug user issues.
1007+
1008+
An example to read the data is::
1009+
1010+
# cat /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data > fwlog.bin
1011+
1012+
An example to clear the data is::
1013+
1014+
# echo 0 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/data
1015+
1016+
Changing how often the log events are sent to the driver
1017+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1018+
The driver receives FW log data from the Admin Receive Queue (ARQ). The
1019+
frequency that the FW sends the ARQ events can be configured by writing to
1020+
'fwlog/nr_messages'. The range is 1-128 (1 means push every log message, 128
1021+
means push only when the max AQ command buffer is full). The suggested value is
1022+
10. The user can see what the value is configured to by reading
1023+
'fwlog/nr_messages'. An example to set the value is::
1024+
1025+
# echo 50 > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/nr_messages
1026+
1027+
Configuring the amount of memory used to store FW log data
1028+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1029+
The driver stores FW log data within the driver. The default size of the memory
1030+
used to store the data is 1MB. Some use cases may require more or less data so
1031+
the user can change the amount of memory that is allocated for FW log data.
1032+
To change the amount of memory then write to 'fwlog/log_size'. The value must be
1033+
one of: 128K, 256K, 512K, 1M, or 2M. FW logging must be disabled to change the
1034+
value. An example of changing the value is::
1035+
1036+
# echo 128K > /sys/kernel/debug/ice/0000\:18\:00.0/fwlog/log_size
1037+
1038+
8981039
Performance Optimization
8991040
========================
9001041
Driver defaults are meant to fit a wide variety of workloads, but if further

drivers/net/ethernet/intel/ice/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ ice-y := ice_main.o \
3434
ice_lag.o \
3535
ice_ethtool.o \
3636
ice_repr.o \
37-
ice_tc_lib.o
37+
ice_tc_lib.o \
38+
ice_fwlog.o \
39+
ice_debugfs.o
3840
ice-$(CONFIG_PCI_IOV) += \
3941
ice_sriov.o \
4042
ice_virtchnl.o \

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ struct ice_pf {
571571
struct ice_vsi_stats **vsi_stats;
572572
struct ice_sw *first_sw; /* first switch created by firmware */
573573
u16 eswitch_mode; /* current mode of eswitch */
574+
struct dentry *ice_debugfs_pf;
575+
struct dentry *ice_debugfs_pf_fwlog;
576+
/* keep track of all the dentrys for FW log modules */
577+
struct dentry **ice_debugfs_pf_fwlog_modules;
574578
struct ice_vfs vfs;
575579
DECLARE_BITMAP(features, ICE_F_MAX);
576580
DECLARE_BITMAP(state, ICE_STATE_NBITS);
@@ -890,6 +894,11 @@ static inline bool ice_is_adq_active(struct ice_pf *pf)
890894
return false;
891895
}
892896

897+
void ice_debugfs_fwlog_init(struct ice_pf *pf);
898+
void ice_debugfs_init(void);
899+
void ice_debugfs_exit(void);
900+
void ice_pf_fwlog_update_module(struct ice_pf *pf, int log_level, int module);
901+
893902
bool netif_is_ice(const struct net_device *dev);
894903
int ice_vsi_setup_tx_rings(struct ice_vsi *vsi);
895904
int ice_vsi_setup_rx_rings(struct ice_vsi *vsi);

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 84 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,78 +2094,6 @@ struct ice_aqc_add_rdma_qset_data {
20942094
struct ice_aqc_add_tx_rdma_qset_entry rdma_qsets[];
20952095
};
20962096

2097-
/* Configure Firmware Logging Command (indirect 0xFF09)
2098-
* Logging Information Read Response (indirect 0xFF10)
2099-
* Note: The 0xFF10 command has no input parameters.
2100-
*/
2101-
struct ice_aqc_fw_logging {
2102-
u8 log_ctrl;
2103-
#define ICE_AQC_FW_LOG_AQ_EN BIT(0)
2104-
#define ICE_AQC_FW_LOG_UART_EN BIT(1)
2105-
u8 rsvd0;
2106-
u8 log_ctrl_valid; /* Not used by 0xFF10 Response */
2107-
#define ICE_AQC_FW_LOG_AQ_VALID BIT(0)
2108-
#define ICE_AQC_FW_LOG_UART_VALID BIT(1)
2109-
u8 rsvd1[5];
2110-
__le32 addr_high;
2111-
__le32 addr_low;
2112-
};
2113-
2114-
enum ice_aqc_fw_logging_mod {
2115-
ICE_AQC_FW_LOG_ID_GENERAL = 0,
2116-
ICE_AQC_FW_LOG_ID_CTRL,
2117-
ICE_AQC_FW_LOG_ID_LINK,
2118-
ICE_AQC_FW_LOG_ID_LINK_TOPO,
2119-
ICE_AQC_FW_LOG_ID_DNL,
2120-
ICE_AQC_FW_LOG_ID_I2C,
2121-
ICE_AQC_FW_LOG_ID_SDP,
2122-
ICE_AQC_FW_LOG_ID_MDIO,
2123-
ICE_AQC_FW_LOG_ID_ADMINQ,
2124-
ICE_AQC_FW_LOG_ID_HDMA,
2125-
ICE_AQC_FW_LOG_ID_LLDP,
2126-
ICE_AQC_FW_LOG_ID_DCBX,
2127-
ICE_AQC_FW_LOG_ID_DCB,
2128-
ICE_AQC_FW_LOG_ID_NETPROXY,
2129-
ICE_AQC_FW_LOG_ID_NVM,
2130-
ICE_AQC_FW_LOG_ID_AUTH,
2131-
ICE_AQC_FW_LOG_ID_VPD,
2132-
ICE_AQC_FW_LOG_ID_IOSF,
2133-
ICE_AQC_FW_LOG_ID_PARSER,
2134-
ICE_AQC_FW_LOG_ID_SW,
2135-
ICE_AQC_FW_LOG_ID_SCHEDULER,
2136-
ICE_AQC_FW_LOG_ID_TXQ,
2137-
ICE_AQC_FW_LOG_ID_RSVD,
2138-
ICE_AQC_FW_LOG_ID_POST,
2139-
ICE_AQC_FW_LOG_ID_WATCHDOG,
2140-
ICE_AQC_FW_LOG_ID_TASK_DISPATCH,
2141-
ICE_AQC_FW_LOG_ID_MNG,
2142-
ICE_AQC_FW_LOG_ID_MAX,
2143-
};
2144-
2145-
/* Defines for both above FW logging command/response buffers */
2146-
#define ICE_AQC_FW_LOG_ID_S 0
2147-
#define ICE_AQC_FW_LOG_ID_M (0xFFF << ICE_AQC_FW_LOG_ID_S)
2148-
2149-
#define ICE_AQC_FW_LOG_CONF_SUCCESS 0 /* Used by response */
2150-
#define ICE_AQC_FW_LOG_CONF_BAD_INDX BIT(12) /* Used by response */
2151-
2152-
#define ICE_AQC_FW_LOG_EN_S 12
2153-
#define ICE_AQC_FW_LOG_EN_M (0xF << ICE_AQC_FW_LOG_EN_S)
2154-
#define ICE_AQC_FW_LOG_INFO_EN BIT(12) /* Used by command */
2155-
#define ICE_AQC_FW_LOG_INIT_EN BIT(13) /* Used by command */
2156-
#define ICE_AQC_FW_LOG_FLOW_EN BIT(14) /* Used by command */
2157-
#define ICE_AQC_FW_LOG_ERR_EN BIT(15) /* Used by command */
2158-
2159-
/* Get/Clear FW Log (indirect 0xFF11) */
2160-
struct ice_aqc_get_clear_fw_log {
2161-
u8 flags;
2162-
#define ICE_AQC_FW_LOG_CLEAR BIT(0)
2163-
#define ICE_AQC_FW_LOG_MORE_DATA_AVAIL BIT(1)
2164-
u8 rsvd1[7];
2165-
__le32 addr_high;
2166-
__le32 addr_low;
2167-
};
2168-
21692097
/* Download Package (indirect 0x0C40) */
21702098
/* Also used for Update Package (indirect 0x0C41 and 0x0C42) */
21712099
struct ice_aqc_download_pkg {
@@ -2428,6 +2356,84 @@ struct ice_aqc_event_lan_overflow {
24282356
u8 reserved[8];
24292357
};
24302358

2359+
enum ice_aqc_fw_logging_mod {
2360+
ICE_AQC_FW_LOG_ID_GENERAL = 0,
2361+
ICE_AQC_FW_LOG_ID_CTRL,
2362+
ICE_AQC_FW_LOG_ID_LINK,
2363+
ICE_AQC_FW_LOG_ID_LINK_TOPO,
2364+
ICE_AQC_FW_LOG_ID_DNL,
2365+
ICE_AQC_FW_LOG_ID_I2C,
2366+
ICE_AQC_FW_LOG_ID_SDP,
2367+
ICE_AQC_FW_LOG_ID_MDIO,
2368+
ICE_AQC_FW_LOG_ID_ADMINQ,
2369+
ICE_AQC_FW_LOG_ID_HDMA,
2370+
ICE_AQC_FW_LOG_ID_LLDP,
2371+
ICE_AQC_FW_LOG_ID_DCBX,
2372+
ICE_AQC_FW_LOG_ID_DCB,
2373+
ICE_AQC_FW_LOG_ID_XLR,
2374+
ICE_AQC_FW_LOG_ID_NVM,
2375+
ICE_AQC_FW_LOG_ID_AUTH,
2376+
ICE_AQC_FW_LOG_ID_VPD,
2377+
ICE_AQC_FW_LOG_ID_IOSF,
2378+
ICE_AQC_FW_LOG_ID_PARSER,
2379+
ICE_AQC_FW_LOG_ID_SW,
2380+
ICE_AQC_FW_LOG_ID_SCHEDULER,
2381+
ICE_AQC_FW_LOG_ID_TXQ,
2382+
ICE_AQC_FW_LOG_ID_RSVD,
2383+
ICE_AQC_FW_LOG_ID_POST,
2384+
ICE_AQC_FW_LOG_ID_WATCHDOG,
2385+
ICE_AQC_FW_LOG_ID_TASK_DISPATCH,
2386+
ICE_AQC_FW_LOG_ID_MNG,
2387+
ICE_AQC_FW_LOG_ID_SYNCE,
2388+
ICE_AQC_FW_LOG_ID_HEALTH,
2389+
ICE_AQC_FW_LOG_ID_TSDRV,
2390+
ICE_AQC_FW_LOG_ID_PFREG,
2391+
ICE_AQC_FW_LOG_ID_MDLVER,
2392+
ICE_AQC_FW_LOG_ID_MAX,
2393+
};
2394+
2395+
/* Set FW Logging configuration (indirect 0xFF30)
2396+
* Register for FW Logging (indirect 0xFF31)
2397+
* Query FW Logging (indirect 0xFF32)
2398+
* FW Log Event (indirect 0xFF33)
2399+
*/
2400+
struct ice_aqc_fw_log {
2401+
u8 cmd_flags;
2402+
#define ICE_AQC_FW_LOG_CONF_UART_EN BIT(0)
2403+
#define ICE_AQC_FW_LOG_CONF_AQ_EN BIT(1)
2404+
#define ICE_AQC_FW_LOG_QUERY_REGISTERED BIT(2)
2405+
#define ICE_AQC_FW_LOG_CONF_SET_VALID BIT(3)
2406+
#define ICE_AQC_FW_LOG_AQ_REGISTER BIT(0)
2407+
#define ICE_AQC_FW_LOG_AQ_QUERY BIT(2)
2408+
2409+
u8 rsp_flag;
2410+
__le16 fw_rt_msb;
2411+
union {
2412+
struct {
2413+
__le32 fw_rt_lsb;
2414+
} sync;
2415+
struct {
2416+
__le16 log_resolution;
2417+
#define ICE_AQC_FW_LOG_MIN_RESOLUTION (1)
2418+
#define ICE_AQC_FW_LOG_MAX_RESOLUTION (128)
2419+
2420+
__le16 mdl_cnt;
2421+
} cfg;
2422+
} ops;
2423+
__le32 addr_high;
2424+
__le32 addr_low;
2425+
};
2426+
2427+
/* Response Buffer for:
2428+
* Set Firmware Logging Configuration (0xFF30)
2429+
* Query FW Logging (0xFF32)
2430+
*/
2431+
struct ice_aqc_fw_log_cfg_resp {
2432+
__le16 module_identifier;
2433+
u8 log_level;
2434+
u8 rsvd0;
2435+
};
2436+
24312437
/**
24322438
* struct ice_aq_desc - Admin Queue (AQ) descriptor
24332439
* @flags: ICE_AQ_FLAG_* flags
@@ -2507,8 +2513,6 @@ struct ice_aq_desc {
25072513
struct ice_aqc_add_rdma_qset add_rdma_qset;
25082514
struct ice_aqc_add_get_update_free_vsi vsi_cmd;
25092515
struct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;
2510-
struct ice_aqc_fw_logging fw_logging;
2511-
struct ice_aqc_get_clear_fw_log get_clear_fw_log;
25122516
struct ice_aqc_download_pkg download_pkg;
25132517
struct ice_aqc_set_cgu_input_config set_cgu_input_config;
25142518
struct ice_aqc_get_cgu_input_config get_cgu_input_config;
@@ -2520,6 +2524,7 @@ struct ice_aq_desc {
25202524
struct ice_aqc_get_cgu_ref_prio get_cgu_ref_prio;
25212525
struct ice_aqc_get_cgu_info get_cgu_info;
25222526
struct ice_aqc_driver_shared_params drv_shared_params;
2527+
struct ice_aqc_fw_log fw_log;
25232528
struct ice_aqc_set_mac_lb set_mac_lb;
25242529
struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
25252530
struct ice_aqc_set_mac_cfg set_mac_cfg;
@@ -2718,9 +2723,11 @@ enum ice_adminq_opc {
27182723
/* Standalone Commands/Events */
27192724
ice_aqc_opc_event_lan_overflow = 0x1001,
27202725

2721-
/* debug commands */
2722-
ice_aqc_opc_fw_logging = 0xFF09,
2723-
ice_aqc_opc_fw_logging_info = 0xFF10,
2726+
/* FW Logging Commands */
2727+
ice_aqc_opc_fw_logs_config = 0xFF30,
2728+
ice_aqc_opc_fw_logs_register = 0xFF31,
2729+
ice_aqc_opc_fw_logs_query = 0xFF32,
2730+
ice_aqc_opc_fw_logs_event = 0xFF33,
27242731
};
27252732

27262733
#endif /* _ICE_ADMINQ_CMD_H_ */

0 commit comments

Comments
 (0)