* [PATCH iwl-next v1 01/15] ice: make fwlog functions static
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 11:58 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 02/15] ice: move get_fwlog_data() to fwlog file Michal Swiatkowski
` (14 subsequent siblings)
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
ice_fwlog_supported(), ice_fwlog_get() and ice_fwlog_supported() aren't
called outside the ice_fwlog.c file. Make it static and move in the file
to allow clean build.
Drop ice_fwlog_get(). It is called only from ice_fwlog_init() function
where the fwlog support is already checked. There is no need to check it
again, call ice_aq_fwlog_get() instead.
Drop no longer valid comment from ice_fwlog_get_supported().
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_fwlog.c | 232 ++++++++++-----------
drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 +-
2 files changed, 109 insertions(+), 128 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index a31bb026ad34..e48856206648 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -123,6 +123,113 @@ void ice_fwlog_realloc_rings(struct ice_hw *hw, int index)
hw->fwlog_ring.tail = 0;
}
+/**
+ * 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().
+ */
+static bool ice_fwlog_supported(struct ice_hw *hw)
+{
+ return hw->fwlog_supported;
+}
+
+/**
+ * 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 libie_aq_desc desc;
+ u16 module_id_cnt;
+ int status;
+ void *buf;
+ int i;
+
+ 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 = libie_aq_raw(&desc);
+
+ 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_supported - 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_supported flag accordingly.
+ *
+ * This function is only meant to be called during driver init to determine if
+ * the FW support FW logging.
+ */
+static void ice_fwlog_set_supported(struct ice_hw *hw)
+{
+ struct ice_fwlog_cfg *cfg;
+ int status;
+
+ hw->fwlog_supported = false;
+
+ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ if (!cfg)
+ return;
+
+ 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_supported = true;
+
+ kfree(cfg);
+}
+
/**
* ice_fwlog_init - Initialize FW logging configuration
* @hw: pointer to the HW structure
@@ -142,7 +249,7 @@ int ice_fwlog_init(struct ice_hw *hw)
int status;
/* read the current config from the FW and store it */
- status = ice_fwlog_get(hw, &hw->fwlog_cfg);
+ status = ice_aq_fwlog_get(hw, &hw->fwlog_cfg);
if (status)
return status;
@@ -214,18 +321,6 @@ void ice_fwlog_deinit(struct ice_hw *hw)
}
}
-/**
- * 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_supported;
-}
-
/**
* ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30)
* @hw: pointer to the HW structure
@@ -300,83 +395,6 @@ int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
cfg->log_resolution);
}
-/**
- * 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 libie_aq_desc desc;
- u16 module_id_cnt;
- int status;
- void *buf;
- int i;
-
- 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 = libie_aq_raw(&desc);
-
- 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_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)
-{
- if (!ice_fwlog_supported(hw))
- return -EOPNOTSUPP;
-
- return ice_aq_fwlog_get(hw, cfg);
-}
-
/**
* ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31)
* @hw: pointer to the HW structure
@@ -438,37 +456,3 @@ int ice_fwlog_unregister(struct ice_hw *hw)
return status;
}
-
-/**
- * ice_fwlog_set_supported - 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_supported 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_supported(struct ice_hw *hw)
-{
- struct ice_fwlog_cfg *cfg;
- int status;
-
- hw->fwlog_supported = false;
-
- cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
- if (!cfg)
- return;
-
- /* don't call ice_fwlog_get() because that would check to see if FW
- * logging is supported which is what the driver is determining now
- */
- 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_supported = true;
-
- kfree(cfg);
-}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 287e71fa4b86..7d95d11b6ef9 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -38,7 +38,7 @@ struct ice_fwlog_cfg {
* 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
+ /* set in the ice_aq_fwlog_get() response if the PF is registered for FW
* logging events over ARQ
*/
#define ICE_FWLOG_OPTION_IS_REGISTERED BIT(3)
@@ -67,12 +67,9 @@ struct ice_fwlog_ring {
bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings);
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
void ice_fwlog_ring_increment(u16 *item, u16 size);
-void ice_fwlog_set_supported(struct ice_hw *hw);
-bool ice_fwlog_supported(struct ice_hw *hw);
int ice_fwlog_init(struct ice_hw *hw);
void ice_fwlog_deinit(struct ice_hw *hw);
int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
-int ice_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
int ice_fwlog_register(struct ice_hw *hw);
int ice_fwlog_unregister(struct ice_hw *hw);
void ice_fwlog_realloc_rings(struct ice_hw *hw, int index);
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 01/15] ice: make fwlog functions static
2025-07-22 10:45 ` [PATCH iwl-next v1 01/15] ice: make fwlog functions static Michal Swiatkowski
@ 2025-07-22 11:58 ` Loktionov, Aleksandr
0 siblings, 0 replies; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-22 11:58 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 01/15] ice: make fwlog
> functions static
>
> ice_fwlog_supported(), ice_fwlog_get() and ice_fwlog_supported()
> aren't called outside the ice_fwlog.c file. Make it static and move in
> the file to allow clean build.
>
> Drop ice_fwlog_get(). It is called only from ice_fwlog_init() function
> where the fwlog support is already checked. There is no need to check
> it again, call ice_aq_fwlog_get() instead.
>
> Drop no longer valid comment from ice_fwlog_get_supported().
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_fwlog.c | 232 ++++++++++----------
> -
> drivers/net/ethernet/intel/ice/ice_fwlog.h | 5 +-
> 2 files changed, 109 insertions(+), 128 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> index a31bb026ad34..e48856206648 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> @@ -123,6 +123,113 @@ void ice_fwlog_realloc_rings(struct ice_hw *hw,
> int index)
> hw->fwlog_ring.tail = 0;
> }
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 02/15] ice: move get_fwlog_data() to fwlog file
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 01/15] ice: make fwlog functions static Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 12:02 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 03/15] ice: drop ice_pf_fwlog_update_module() Michal Swiatkowski
` (13 subsequent siblings)
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Change the function prototype to receive hw structure instead of pf to
simplify the call. Instead of passing whole event pass only msg_buf
pointer and length.
Make ice_fwlog_ring_full() static as it isn't called from any other
context.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_fwlog.c | 27 +++++++++++++++++++-
drivers/net/ethernet/intel/ice/ice_fwlog.h | 2 +-
drivers/net/ethernet/intel/ice/ice_main.c | 29 ++--------------------
3 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index e48856206648..ea5d6d2d3f30 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -6,7 +6,7 @@
#include "ice_common.h"
#include "ice_fwlog.h"
-bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
+static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
{
u16 head, tail;
@@ -456,3 +456,28 @@ int ice_fwlog_unregister(struct ice_hw *hw)
return status;
}
+
+/**
+ * ice_get_fwlog_data - copy the FW log data from ARQ event
+ * @hw: HW that the FW log event is associated with
+ * @buf: event buffer pointer
+ * @len: len of event descriptor
+ */
+void ice_get_fwlog_data(struct ice_hw *hw, u8 *buf, u16 len)
+{
+ struct ice_fwlog_data *fwlog;
+
+ fwlog = &hw->fwlog_ring.rings[hw->fwlog_ring.tail];
+
+ memset(fwlog->data, 0, PAGE_SIZE);
+ fwlog->data_size = len;
+
+ memcpy(fwlog->data, buf, fwlog->data_size);
+ ice_fwlog_ring_increment(&hw->fwlog_ring.tail, hw->fwlog_ring.size);
+
+ if (ice_fwlog_ring_full(&hw->fwlog_ring)) {
+ /* the rings are full so bump the head to create room */
+ ice_fwlog_ring_increment(&hw->fwlog_ring.head,
+ hw->fwlog_ring.size);
+ }
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 7d95d11b6ef9..5b9244f4f0f1 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -64,7 +64,6 @@ struct ice_fwlog_ring {
#define ICE_FWLOG_RING_SIZE_DFLT 256
#define ICE_FWLOG_RING_SIZE_MAX 512
-bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings);
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
void ice_fwlog_ring_increment(u16 *item, u16 size);
int ice_fwlog_init(struct ice_hw *hw);
@@ -73,4 +72,5 @@ int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
int ice_fwlog_register(struct ice_hw *hw);
int ice_fwlog_unregister(struct ice_hw *hw);
void ice_fwlog_realloc_rings(struct ice_hw *hw, int index);
+void ice_get_fwlog_data(struct ice_hw *hw, u8 *buf, u16 len);
#endif /* _ICE_FWLOG_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 8e0b06c1e02b..c2101853adf8 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1250,32 +1250,6 @@ ice_handle_link_event(struct ice_pf *pf, struct ice_rq_event_info *event)
return status;
}
-/**
- * ice_get_fwlog_data - copy the FW log data from ARQ event
- * @pf: PF that the FW log event is associated with
- * @event: event structure containing FW log data
- */
-static void
-ice_get_fwlog_data(struct ice_pf *pf, struct ice_rq_event_info *event)
-{
- struct ice_fwlog_data *fwlog;
- struct ice_hw *hw = &pf->hw;
-
- fwlog = &hw->fwlog_ring.rings[hw->fwlog_ring.tail];
-
- memset(fwlog->data, 0, PAGE_SIZE);
- fwlog->data_size = le16_to_cpu(event->desc.datalen);
-
- memcpy(fwlog->data, event->msg_buf, fwlog->data_size);
- ice_fwlog_ring_increment(&hw->fwlog_ring.tail, hw->fwlog_ring.size);
-
- if (ice_fwlog_ring_full(&hw->fwlog_ring)) {
- /* the rings are full so bump the head to create room */
- ice_fwlog_ring_increment(&hw->fwlog_ring.head,
- hw->fwlog_ring.size);
- }
-}
-
/**
* ice_aq_prep_for_event - Prepare to wait for an AdminQ event from firmware
* @pf: pointer to the PF private structure
@@ -1566,7 +1540,8 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
}
break;
case ice_aqc_opc_fw_logs_event:
- ice_get_fwlog_data(pf, &event);
+ ice_get_fwlog_data(hw, event.msg_buf,
+ le16_to_cpu(event.desc.datalen));
break;
case ice_aqc_opc_lldp_set_mib_change:
ice_dcb_process_lldp_set_mib_change(pf, &event);
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 02/15] ice: move get_fwlog_data() to fwlog file
2025-07-22 10:45 ` [PATCH iwl-next v1 02/15] ice: move get_fwlog_data() to fwlog file Michal Swiatkowski
@ 2025-07-22 12:02 ` Loktionov, Aleksandr
2025-07-23 4:48 ` Michal Swiatkowski
0 siblings, 1 reply; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-22 12:02 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 02/15] ice: move
> get_fwlog_data() to fwlog file
>
> Change the function prototype to receive hw structure instead of pf to
> simplify the call. Instead of passing whole event pass only msg_buf
> pointer and length.
>
> Make ice_fwlog_ring_full() static as it isn't called from any other
> context.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_fwlog.c | 27 +++++++++++++++++++-
> drivers/net/ethernet/intel/ice/ice_fwlog.h | 2 +-
> drivers/net/ethernet/intel/ice/ice_main.c | 29 ++--------------------
> 3 files changed, 29 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> index e48856206648..ea5d6d2d3f30 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> @@ -6,7 +6,7 @@
> #include "ice_common.h"
> #include "ice_fwlog.h"
>
> -bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
> +static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
> {
> u16 head, tail;
>
Can you consider adding kernel-doc for ice_fwlog_ring_full()?
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v1 02/15] ice: move get_fwlog_data() to fwlog file
2025-07-22 12:02 ` [Intel-wired-lan] " Loktionov, Aleksandr
@ 2025-07-23 4:48 ` Michal Swiatkowski
0 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-23 4:48 UTC (permalink / raw)
To: Loktionov, Aleksandr
Cc: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org,
netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com
On Tue, Jul 22, 2025 at 12:02:52PM +0000, Loktionov, Aleksandr wrote:
>
>
> > -----Original Message-----
> > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> > Of Michal Swiatkowski
> > Sent: Tuesday, July 22, 2025 12:46 PM
> > To: intel-wired-lan@lists.osuosl.org
> > Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> > <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> > Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > Subject: [Intel-wired-lan] [PATCH iwl-next v1 02/15] ice: move
> > get_fwlog_data() to fwlog file
> >
> > Change the function prototype to receive hw structure instead of pf to
> > simplify the call. Instead of passing whole event pass only msg_buf
> > pointer and length.
> >
> > Make ice_fwlog_ring_full() static as it isn't called from any other
> > context.
> >
> > Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > ---
> > drivers/net/ethernet/intel/ice/ice_fwlog.c | 27 +++++++++++++++++++-
> > drivers/net/ethernet/intel/ice/ice_fwlog.h | 2 +-
> > drivers/net/ethernet/intel/ice/ice_main.c | 29 ++--------------------
> > 3 files changed, 29 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> > b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> > index e48856206648..ea5d6d2d3f30 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> > @@ -6,7 +6,7 @@
> > #include "ice_common.h"
> > #include "ice_fwlog.h"
> >
> > -bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
> > +static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
> > {
> > u16 head, tail;
> >
> Can you consider adding kernel-doc for ice_fwlog_ring_full()?
>
I will add it.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 03/15] ice: drop ice_pf_fwlog_update_module()
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 01/15] ice: make fwlog functions static Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 02/15] ice: move get_fwlog_data() to fwlog file Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 12:06 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 04/15] ice: introduce ice_fwlog structure Michal Swiatkowski
` (12 subsequent siblings)
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski,
Larysa Zaremba
Any other access to fwlog_cfg isn't done through a function. Follow
scheme that is used to access other fwlog_cfg elements from debugfs and
write to the log_level directly.
ice_pf_fwlog_update_module() is called only twice (from one function).
Remove it.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice.h | 1 -
drivers/net/ethernet/intel/ice/ice_debugfs.c | 5 +++--
drivers/net/ethernet/intel/ice/ice_main.c | 13 -------------
3 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index e952d67388bf..a6803b344540 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -912,7 +912,6 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf);
void ice_debugfs_pf_deinit(struct ice_pf *pf);
void ice_debugfs_init(void);
void ice_debugfs_exit(void);
-void ice_pf_fwlog_update_module(struct ice_pf *pf, int log_level, int module);
bool netif_is_ice(const struct net_device *dev);
int ice_vsi_setup_tx_rings(struct ice_vsi *vsi);
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index cb71eca6a85b..170050548e74 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -164,6 +164,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
struct ice_pf *pf = file_inode(filp)->i_private;
struct dentry *dentry = file_dentry(filp);
struct device *dev = ice_pf_to_dev(pf);
+ struct ice_hw *hw = &pf->hw;
char user_val[16], *cmd_buf;
int module, log_level, cnt;
@@ -192,7 +193,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
}
if (module != ICE_AQC_FW_LOG_ID_MAX) {
- ice_pf_fwlog_update_module(pf, log_level, module);
+ hw->fwlog_cfg.module_entries[module].log_level = log_level;
} else {
/* the module 'all' is a shortcut so that we can set
* all of the modules to the same level quickly
@@ -200,7 +201,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
int i;
for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++)
- ice_pf_fwlog_update_module(pf, log_level, i);
+ hw->fwlog_cfg.module_entries[i].log_level = log_level;
}
return count;
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index c2101853adf8..7f72b8d09d79 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4620,19 +4620,6 @@ static void ice_print_wake_reason(struct ice_pf *pf)
dev_info(ice_pf_to_dev(pf), "Wake reason: %s", wake_str);
}
-/**
- * ice_pf_fwlog_update_module - update 1 module
- * @pf: pointer to the PF struct
- * @log_level: log_level to use for the @module
- * @module: module to update
- */
-void ice_pf_fwlog_update_module(struct ice_pf *pf, int log_level, int module)
-{
- struct ice_hw *hw = &pf->hw;
-
- hw->fwlog_cfg.module_entries[module].log_level = log_level;
-}
-
/**
* ice_register_netdev - register netdev
* @vsi: pointer to the VSI struct
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 03/15] ice: drop ice_pf_fwlog_update_module()
2025-07-22 10:45 ` [PATCH iwl-next v1 03/15] ice: drop ice_pf_fwlog_update_module() Michal Swiatkowski
@ 2025-07-22 12:06 ` Loktionov, Aleksandr
0 siblings, 0 replies; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-22 12:06 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com, Zaremba, Larysa
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>; Zaremba,
> Larysa <larysa.zaremba@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 03/15] ice: drop
> ice_pf_fwlog_update_module()
>
> Any other access to fwlog_cfg isn't done through a function. Follow
> scheme that is used to access other fwlog_cfg elements from debugfs
> and write to the log_level directly.
>
> ice_pf_fwlog_update_module() is called only twice (from one function).
> Remove it.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 04/15] ice: introduce ice_fwlog structure
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (2 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 03/15] ice: drop ice_pf_fwlog_update_module() Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 12:17 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 05/15] ice: add pdev into fwlog structure and use it for logging Michal Swiatkowski
` (11 subsequent siblings)
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski,
Larysa Zaremba
The new structure is needed to make the fwlog code a library. A goal is
to drop ice_hw structure in all fwlog related functions calls.
Pass a ice_fwlog pointer across fwlog functions and use it wherever it
is possible.
Still use &hw->fwlog in debugfs code as it needs changing the value
being passed in priv. It will be done in one of the next patches.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 4 +-
drivers/net/ethernet/intel/ice/ice_debugfs.c | 44 ++++----
drivers/net/ethernet/intel/ice/ice_fwlog.c | 112 ++++++++++---------
drivers/net/ethernet/intel/ice/ice_fwlog.h | 19 +++-
drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
drivers/net/ethernet/intel/ice/ice_type.h | 4 +-
6 files changed, 98 insertions(+), 87 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 95e40779b176..5d7f348aa596 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1012,7 +1012,7 @@ int ice_init_hw(struct ice_hw *hw)
if (status)
goto err_unroll_cqinit;
- status = ice_fwlog_init(hw);
+ status = ice_fwlog_init(hw, &hw->fwlog);
if (status)
ice_debug(hw, ICE_DBG_FW_LOG, "Error initializing FW logging: %d\n",
status);
@@ -1178,7 +1178,7 @@ void ice_deinit_hw(struct ice_hw *hw)
ice_free_hw_tbls(hw);
mutex_destroy(&hw->tnl_lock);
- ice_fwlog_deinit(hw);
+ ice_fwlog_deinit(hw, &hw->fwlog);
ice_destroy_all_ctrlq(hw);
/* Clear VSI contexts if not already cleared */
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index 170050548e74..dbcc0cb438aa 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -81,7 +81,7 @@ static const char * const ice_fwlog_log_size[] = {
static void
ice_fwlog_print_module_cfg(struct ice_hw *hw, int module, struct seq_file *s)
{
- struct ice_fwlog_cfg *cfg = &hw->fwlog_cfg;
+ struct ice_fwlog_cfg *cfg = &hw->fwlog.cfg;
struct ice_fwlog_module_entry *entry;
if (module != ICE_AQC_FW_LOG_ID_MAX) {
@@ -193,7 +193,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
}
if (module != ICE_AQC_FW_LOG_ID_MAX) {
- hw->fwlog_cfg.module_entries[module].log_level = log_level;
+ hw->fwlog.cfg.module_entries[module].log_level = log_level;
} else {
/* the module 'all' is a shortcut so that we can set
* all of the modules to the same level quickly
@@ -201,7 +201,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
int i;
for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++)
- hw->fwlog_cfg.module_entries[i].log_level = log_level;
+ hw->fwlog.cfg.module_entries[i].log_level = log_level;
}
return count;
@@ -231,7 +231,7 @@ static ssize_t ice_debugfs_nr_messages_read(struct file *filp,
char buff[32] = {};
snprintf(buff, sizeof(buff), "%d\n",
- hw->fwlog_cfg.log_resolution);
+ hw->fwlog.cfg.log_resolution);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
}
@@ -278,7 +278,7 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
return -EINVAL;
}
- hw->fwlog_cfg.log_resolution = nr_messages;
+ hw->fwlog.cfg.log_resolution = nr_messages;
return count;
}
@@ -306,7 +306,7 @@ static ssize_t ice_debugfs_enable_read(struct file *filp,
char buff[32] = {};
snprintf(buff, sizeof(buff), "%u\n",
- (u16)(hw->fwlog_cfg.options &
+ (u16)(hw->fwlog.cfg.options &
ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
@@ -346,18 +346,18 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
goto enable_write_error;
if (enable)
- hw->fwlog_cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
+ hw->fwlog.cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
else
- hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
+ hw->fwlog.cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
- ret = ice_fwlog_set(hw, &hw->fwlog_cfg);
+ ret = ice_fwlog_set(hw, &hw->fwlog.cfg);
if (ret)
goto enable_write_error;
if (enable)
- ret = ice_fwlog_register(hw);
+ ret = ice_fwlog_register(hw, &hw->fwlog);
else
- ret = ice_fwlog_unregister(hw);
+ ret = ice_fwlog_unregister(hw, &hw->fwlog);
if (ret)
goto enable_write_error;
@@ -401,7 +401,7 @@ static ssize_t ice_debugfs_log_size_read(struct file *filp,
char buff[32] = {};
int index;
- index = hw->fwlog_ring.index;
+ index = hw->fwlog.ring.index;
snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
@@ -443,14 +443,14 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
user_val);
ret = -EINVAL;
goto log_size_write_error;
- } else if (hw->fwlog_cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
+ } else if (hw->fwlog.cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
dev_info(dev, "FW logging is currently running. Please disable FW logging to change log_size\n");
ret = -EINVAL;
goto log_size_write_error;
}
/* free all the buffers and the tracking info and resize */
- ice_fwlog_realloc_rings(hw, index);
+ ice_fwlog_realloc_rings(hw, &hw->fwlog, index);
/* if we get here, nothing went wrong; return count since we didn't
* really write anything
@@ -490,14 +490,14 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
int data_copied = 0;
bool done = false;
- if (ice_fwlog_ring_empty(&hw->fwlog_ring))
+ if (ice_fwlog_ring_empty(&hw->fwlog.ring))
return 0;
- while (!ice_fwlog_ring_empty(&hw->fwlog_ring) && !done) {
+ while (!ice_fwlog_ring_empty(&hw->fwlog.ring) && !done) {
struct ice_fwlog_data *log;
u16 cur_buf_len;
- log = &hw->fwlog_ring.rings[hw->fwlog_ring.head];
+ log = &hw->fwlog.ring.rings[hw->fwlog.ring.head];
cur_buf_len = log->data_size;
if (cur_buf_len >= count) {
done = true;
@@ -516,8 +516,8 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
buffer += cur_buf_len;
count -= cur_buf_len;
*ppos += cur_buf_len;
- ice_fwlog_ring_increment(&hw->fwlog_ring.head,
- hw->fwlog_ring.size);
+ ice_fwlog_ring_increment(&hw->fwlog.ring.head,
+ hw->fwlog.ring.size);
}
return data_copied;
@@ -546,9 +546,9 @@ ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
/* any value is allowed to clear the buffer so no need to even look at
* what the value is
*/
- if (!(hw->fwlog_cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
- hw->fwlog_ring.head = 0;
- hw->fwlog_ring.tail = 0;
+ if (!(hw->fwlog.cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
+ hw->fwlog.ring.head = 0;
+ hw->fwlog.ring.tail = 0;
} else {
dev_info(dev, "Can't clear FW log data while FW log running\n");
ret = -EINVAL;
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index ea5d6d2d3f30..a010f655ffb7 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -74,10 +74,12 @@ static void ice_fwlog_free_ring_buffs(struct ice_fwlog_ring *rings)
/**
* ice_fwlog_realloc_rings - reallocate the FW log rings
* @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
* @index: the new index to use to allocate memory for the log data
*
*/
-void ice_fwlog_realloc_rings(struct ice_hw *hw, int index)
+void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog *fwlog,
+ int index)
{
struct ice_fwlog_ring ring;
int status, ring_size;
@@ -92,7 +94,7 @@ void ice_fwlog_realloc_rings(struct ice_hw *hw, int index)
* can be correctly parsed by the tools
*/
ring_size = ICE_FWLOG_INDEX_TO_BYTES(index) / ICE_AQ_MAX_BUF_LEN;
- if (ring_size == hw->fwlog_ring.size)
+ if (ring_size == fwlog->ring.size)
return;
/* allocate space for the new rings and buffers then release the
@@ -113,26 +115,26 @@ void ice_fwlog_realloc_rings(struct ice_hw *hw, int index)
return;
}
- ice_fwlog_free_ring_buffs(&hw->fwlog_ring);
- kfree(hw->fwlog_ring.rings);
+ ice_fwlog_free_ring_buffs(&fwlog->ring);
+ kfree(fwlog->ring.rings);
- hw->fwlog_ring.rings = ring.rings;
- hw->fwlog_ring.size = ring.size;
- hw->fwlog_ring.index = index;
- hw->fwlog_ring.head = 0;
- hw->fwlog_ring.tail = 0;
+ fwlog->ring.rings = ring.rings;
+ fwlog->ring.size = ring.size;
+ fwlog->ring.index = index;
+ fwlog->ring.head = 0;
+ fwlog->ring.tail = 0;
}
/**
* ice_fwlog_supported - Cached for whether FW supports FW logging or not
- * @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
*
* This will always return false if called before ice_init_hw(), so it must be
* called after ice_init_hw().
*/
-static bool ice_fwlog_supported(struct ice_hw *hw)
+static bool ice_fwlog_supported(struct ice_fwlog *fwlog)
{
- return hw->fwlog_supported;
+ return fwlog->supported;
}
/**
@@ -202,6 +204,7 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
/**
* ice_fwlog_set_supported - Set if FW logging is supported by FW
* @hw: pointer to the HW struct
+ * @fwlog: pointer to the fwlog structure
*
* If FW returns success to the ice_aq_fwlog_get call then it supports FW
* logging, else it doesn't. Set the fwlog_supported flag accordingly.
@@ -209,12 +212,12 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
* This function is only meant to be called during driver init to determine if
* the FW support FW logging.
*/
-static void ice_fwlog_set_supported(struct ice_hw *hw)
+static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
{
struct ice_fwlog_cfg *cfg;
int status;
- hw->fwlog_supported = false;
+ fwlog->supported = false;
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
if (!cfg)
@@ -225,7 +228,7 @@ static void ice_fwlog_set_supported(struct ice_hw *hw)
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_supported = true;
+ fwlog->supported = true;
kfree(cfg);
}
@@ -233,42 +236,43 @@ static void ice_fwlog_set_supported(struct ice_hw *hw)
/**
* ice_fwlog_init - Initialize FW logging configuration
* @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
*
* This function should be called on driver initialization during
* ice_init_hw().
*/
-int ice_fwlog_init(struct ice_hw *hw)
+int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog)
{
/* only support fw log commands on PF 0 */
if (hw->bus.func)
return -EINVAL;
- ice_fwlog_set_supported(hw);
+ ice_fwlog_set_supported(hw, fwlog);
- if (ice_fwlog_supported(hw)) {
+ if (ice_fwlog_supported(fwlog)) {
int status;
/* read the current config from the FW and store it */
- status = ice_aq_fwlog_get(hw, &hw->fwlog_cfg);
+ status = ice_aq_fwlog_get(hw, &fwlog->cfg);
if (status)
return status;
- hw->fwlog_ring.rings = kcalloc(ICE_FWLOG_RING_SIZE_DFLT,
- sizeof(*hw->fwlog_ring.rings),
- GFP_KERNEL);
- if (!hw->fwlog_ring.rings) {
+ fwlog->ring.rings = kcalloc(ICE_FWLOG_RING_SIZE_DFLT,
+ sizeof(*fwlog->ring.rings),
+ GFP_KERNEL);
+ if (!fwlog->ring.rings) {
dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log rings\n");
return -ENOMEM;
}
- hw->fwlog_ring.size = ICE_FWLOG_RING_SIZE_DFLT;
- hw->fwlog_ring.index = ICE_FWLOG_RING_SIZE_INDEX_DFLT;
+ fwlog->ring.size = ICE_FWLOG_RING_SIZE_DFLT;
+ fwlog->ring.index = ICE_FWLOG_RING_SIZE_INDEX_DFLT;
- status = ice_fwlog_alloc_ring_buffs(&hw->fwlog_ring);
+ status = ice_fwlog_alloc_ring_buffs(&fwlog->ring);
if (status) {
dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log ring data buffers\n");
- ice_fwlog_free_ring_buffs(&hw->fwlog_ring);
- kfree(hw->fwlog_ring.rings);
+ ice_fwlog_free_ring_buffs(&fwlog->ring);
+ kfree(fwlog->ring.rings);
return status;
}
@@ -283,10 +287,11 @@ int ice_fwlog_init(struct ice_hw *hw)
/**
* ice_fwlog_deinit - unroll FW logging configuration
* @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
*
* This function should be called in ice_deinit_hw().
*/
-void ice_fwlog_deinit(struct ice_hw *hw)
+void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
{
struct ice_pf *pf = hw->back;
int status;
@@ -300,8 +305,8 @@ void ice_fwlog_deinit(struct ice_hw *hw)
/* make sure FW logging is disabled to not put the FW in a weird state
* for the next driver load
*/
- hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
- status = ice_fwlog_set(hw, &hw->fwlog_cfg);
+ fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
+ status = ice_fwlog_set(hw, &fwlog->cfg);
if (status)
dev_warn(ice_hw_to_dev(hw), "Unable to turn off FW logging, status: %d\n",
status);
@@ -310,14 +315,14 @@ void ice_fwlog_deinit(struct ice_hw *hw)
pf->ice_debugfs_pf_fwlog_modules = NULL;
- status = ice_fwlog_unregister(hw);
+ status = ice_fwlog_unregister(hw, fwlog);
if (status)
dev_warn(ice_hw_to_dev(hw), "Unable to unregister FW logging, status: %d\n",
status);
- if (hw->fwlog_ring.rings) {
- ice_fwlog_free_ring_buffs(&hw->fwlog_ring);
- kfree(hw->fwlog_ring.rings);
+ if (fwlog->ring.rings) {
+ ice_fwlog_free_ring_buffs(&fwlog->ring);
+ kfree(fwlog->ring.rings);
}
}
@@ -387,7 +392,7 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
*/
int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
{
- if (!ice_fwlog_supported(hw))
+ if (!ice_fwlog_supported(&hw->fwlog))
return -EOPNOTSUPP;
return ice_aq_fwlog_set(hw, cfg->module_entries,
@@ -417,22 +422,23 @@ static int ice_aq_fwlog_register(struct ice_hw *hw, bool reg)
/**
* ice_fwlog_register - Register the PF for firmware logging
* @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog 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 ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog)
{
int status;
- if (!ice_fwlog_supported(hw))
+ if (!ice_fwlog_supported(fwlog))
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;
+ fwlog->cfg.options |= ICE_FWLOG_OPTION_IS_REGISTERED;
return status;
}
@@ -440,44 +446,44 @@ int ice_fwlog_register(struct ice_hw *hw)
/**
* ice_fwlog_unregister - Unregister the PF from firmware logging
* @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
*/
-int ice_fwlog_unregister(struct ice_hw *hw)
+int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog)
{
int status;
- if (!ice_fwlog_supported(hw))
+ if (!ice_fwlog_supported(fwlog))
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;
+ fwlog->cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED;
return status;
}
/**
* ice_get_fwlog_data - copy the FW log data from ARQ event
- * @hw: HW that the FW log event is associated with
+ * @fwlog: fwlog that the FW log event is associated with
* @buf: event buffer pointer
* @len: len of event descriptor
*/
-void ice_get_fwlog_data(struct ice_hw *hw, u8 *buf, u16 len)
+void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len)
{
- struct ice_fwlog_data *fwlog;
+ struct ice_fwlog_data *log;
- fwlog = &hw->fwlog_ring.rings[hw->fwlog_ring.tail];
+ log = &fwlog->ring.rings[fwlog->ring.tail];
- memset(fwlog->data, 0, PAGE_SIZE);
- fwlog->data_size = len;
+ memset(log->data, 0, PAGE_SIZE);
+ log->data_size = len;
- memcpy(fwlog->data, buf, fwlog->data_size);
- ice_fwlog_ring_increment(&hw->fwlog_ring.tail, hw->fwlog_ring.size);
+ memcpy(log->data, buf, log->data_size);
+ ice_fwlog_ring_increment(&fwlog->ring.tail, fwlog->ring.size);
- if (ice_fwlog_ring_full(&hw->fwlog_ring)) {
+ if (ice_fwlog_ring_full(&fwlog->ring)) {
/* the rings are full so bump the head to create room */
- ice_fwlog_ring_increment(&hw->fwlog_ring.head,
- hw->fwlog_ring.size);
+ ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
}
}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 5b9244f4f0f1..334a125eac80 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -64,13 +64,20 @@ struct ice_fwlog_ring {
#define ICE_FWLOG_RING_SIZE_DFLT 256
#define ICE_FWLOG_RING_SIZE_MAX 512
+struct ice_fwlog {
+ struct ice_fwlog_cfg cfg;
+ bool supported; /* does hardware support FW logging? */
+ struct ice_fwlog_ring ring;
+};
+
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
void ice_fwlog_ring_increment(u16 *item, u16 size);
-int ice_fwlog_init(struct ice_hw *hw);
-void ice_fwlog_deinit(struct ice_hw *hw);
+int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog);
+void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
-int ice_fwlog_register(struct ice_hw *hw);
-int ice_fwlog_unregister(struct ice_hw *hw);
-void ice_fwlog_realloc_rings(struct ice_hw *hw, int index);
-void ice_get_fwlog_data(struct ice_hw *hw, u8 *buf, u16 len);
+int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog);
+int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog);
+void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog *fwlog,
+ int index);
+void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
#endif /* _ICE_FWLOG_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 7f72b8d09d79..976aca5dc90f 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1540,7 +1540,7 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
}
break;
case ice_aqc_opc_fw_logs_event:
- ice_get_fwlog_data(hw, event.msg_buf,
+ ice_get_fwlog_data(&hw->fwlog, event.msg_buf,
le16_to_cpu(event.desc.datalen));
break;
case ice_aqc_opc_lldp_set_mib_change:
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index c606cd75844d..e4cc91e50643 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -954,9 +954,7 @@ struct ice_hw {
u8 fw_patch; /* firmware patch version */
u32 fw_build; /* firmware build number */
- struct ice_fwlog_cfg fwlog_cfg;
- bool fwlog_supported; /* does hardware support FW logging? */
- struct ice_fwlog_ring fwlog_ring;
+ struct ice_fwlog fwlog;
/* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL
* register. Used for determining the ITR/INTRL granularity during
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 04/15] ice: introduce ice_fwlog structure
2025-07-22 10:45 ` [PATCH iwl-next v1 04/15] ice: introduce ice_fwlog structure Michal Swiatkowski
@ 2025-07-22 12:17 ` Loktionov, Aleksandr
0 siblings, 0 replies; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-22 12:17 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com, Zaremba, Larysa
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>; Zaremba,
> Larysa <larysa.zaremba@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 04/15] ice: introduce
> ice_fwlog structure
>
> The new structure is needed to make the fwlog code a library. A goal
> is to drop ice_hw structure in all fwlog related functions calls.
>
> Pass a ice_fwlog pointer across fwlog functions and use it wherever it
> is possible.
>
> Still use &hw->fwlog in debugfs code as it needs changing the value
> being passed in priv. It will be done in one of the next patches.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 05/15] ice: add pdev into fwlog structure and use it for logging
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (3 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 04/15] ice: introduce ice_fwlog structure Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-23 10:36 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 06/15] ice: allow calling custom send function in fwlog Michal Swiatkowski
` (10 subsequent siblings)
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Prepare the code to be moved to the library. ice_debug() won't be there
so switch to dev_dbg().
Add struct pdev pointer in fwlog to track on which pdev the fwlog was
created.
Switch the dev passed in dev_warn() to the one stored in fwlog.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 3 +-
drivers/net/ethernet/intel/ice/ice_debugfs.c | 2 +-
drivers/net/ethernet/intel/ice/ice_fwlog.c | 37 ++++++++++----------
drivers/net/ethernet/intel/ice/ice_fwlog.h | 7 ++--
4 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 5d7f348aa596..7f293c791775 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -992,6 +992,7 @@ int ice_init_hw(struct ice_hw *hw)
{
struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
void *mac_buf __free(kfree) = NULL;
+ struct ice_pf *pf = hw->back;
u16 mac_buf_len;
int status;
@@ -1012,7 +1013,7 @@ int ice_init_hw(struct ice_hw *hw)
if (status)
goto err_unroll_cqinit;
- status = ice_fwlog_init(hw, &hw->fwlog);
+ status = ice_fwlog_init(hw, &hw->fwlog, pf->pdev);
if (status)
ice_debug(hw, ICE_DBG_FW_LOG, "Error initializing FW logging: %d\n",
status);
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index dbcc0cb438aa..1e036bc128c5 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -450,7 +450,7 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
}
/* free all the buffers and the tracking info and resize */
- ice_fwlog_realloc_rings(hw, &hw->fwlog, index);
+ ice_fwlog_realloc_rings(&hw->fwlog, index);
/* if we get here, nothing went wrong; return count since we didn't
* really write anything
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index a010f655ffb7..b1c1359d5ab5 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -73,13 +73,11 @@ static void ice_fwlog_free_ring_buffs(struct ice_fwlog_ring *rings)
#define ICE_FWLOG_INDEX_TO_BYTES(n) ((128 * 1024) << (n))
/**
* ice_fwlog_realloc_rings - reallocate the FW log rings
- * @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog structure
* @index: the new index to use to allocate memory for the log data
*
*/
-void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog *fwlog,
- int index)
+void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
{
struct ice_fwlog_ring ring;
int status, ring_size;
@@ -109,7 +107,7 @@ void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog *fwlog,
status = ice_fwlog_alloc_ring_buffs(&ring);
if (status) {
- dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log ring data buffers\n");
+ dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log ring data buffers\n");
ice_fwlog_free_ring_buffs(&ring);
kfree(ring.rings);
return;
@@ -165,16 +163,16 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
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");
+ dev_dbg(&hw->fwlog.pdev->dev, "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");
+ dev_dbg(&hw->fwlog.pdev->dev, "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);
+ dev_dbg(&hw->fwlog.pdev->dev, "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;
}
@@ -225,8 +223,8 @@ static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
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);
+ dev_dbg(&fwlog->pdev->dev, "ice_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n",
+ status);
else
fwlog->supported = true;
@@ -237,17 +235,20 @@ static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
* ice_fwlog_init - Initialize FW logging configuration
* @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog structure
+ * @pdev: pointer to the pci dev used in dev_warn()
*
* This function should be called on driver initialization during
* ice_init_hw().
*/
-int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog)
+int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
+ struct pci_dev *pdev)
{
/* only support fw log commands on PF 0 */
if (hw->bus.func)
return -EINVAL;
ice_fwlog_set_supported(hw, fwlog);
+ fwlog->pdev = pdev;
if (ice_fwlog_supported(fwlog)) {
int status;
@@ -261,7 +262,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog)
sizeof(*fwlog->ring.rings),
GFP_KERNEL);
if (!fwlog->ring.rings) {
- dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log rings\n");
+ dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log rings\n");
return -ENOMEM;
}
@@ -270,7 +271,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog)
status = ice_fwlog_alloc_ring_buffs(&fwlog->ring);
if (status) {
- dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log ring data buffers\n");
+ dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log ring data buffers\n");
ice_fwlog_free_ring_buffs(&fwlog->ring);
kfree(fwlog->ring.rings);
return status;
@@ -278,7 +279,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog)
ice_debugfs_fwlog_init(hw->back);
} else {
- dev_warn(ice_hw_to_dev(hw), "FW logging is not supported in this NVM image. Please update the NVM to get FW log support\n");
+ dev_warn(&fwlog->pdev->dev, "FW logging is not supported in this NVM image. Please update the NVM to get FW log support\n");
}
return 0;
@@ -308,7 +309,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
status = ice_fwlog_set(hw, &fwlog->cfg);
if (status)
- dev_warn(ice_hw_to_dev(hw), "Unable to turn off FW logging, status: %d\n",
+ dev_warn(&fwlog->pdev->dev, "Unable to turn off FW logging, status: %d\n",
status);
kfree(pf->ice_debugfs_pf_fwlog_modules);
@@ -317,7 +318,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
status = ice_fwlog_unregister(hw, fwlog);
if (status)
- dev_warn(ice_hw_to_dev(hw), "Unable to unregister FW logging, status: %d\n",
+ dev_warn(&fwlog->pdev->dev, "Unable to unregister FW logging, status: %d\n",
status);
if (fwlog->ring.rings) {
@@ -436,7 +437,7 @@ int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog)
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");
+ dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n");
else
fwlog->cfg.options |= ICE_FWLOG_OPTION_IS_REGISTERED;
@@ -457,7 +458,7 @@ int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog)
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");
+ dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n");
else
fwlog->cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED;
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 334a125eac80..9c56ca6cbef0 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -68,16 +68,17 @@ struct ice_fwlog {
struct ice_fwlog_cfg cfg;
bool supported; /* does hardware support FW logging? */
struct ice_fwlog_ring ring;
+ struct pci_dev *pdev;
};
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
void ice_fwlog_ring_increment(u16 *item, u16 size);
-int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog);
+int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
+ struct pci_dev *pdev);
void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog);
int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog);
-void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog *fwlog,
- int index);
+void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index);
void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
#endif /* _ICE_FWLOG_H_ */
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 05/15] ice: add pdev into fwlog structure and use it for logging
2025-07-22 10:45 ` [PATCH iwl-next v1 05/15] ice: add pdev into fwlog structure and use it for logging Michal Swiatkowski
@ 2025-07-23 10:36 ` Loktionov, Aleksandr
0 siblings, 0 replies; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-23 10:36 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 05/15] ice: add pdev
> into fwlog structure and use it for logging
>
> Prepare the code to be moved to the library. ice_debug() won't be
> there so switch to dev_dbg().
>
> Add struct pdev pointer in fwlog to track on which pdev the fwlog was
> created.
>
> Switch the dev passed in dev_warn() to the one stored in fwlog.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_common.c | 3 +-
> drivers/net/ethernet/intel/ice/ice_debugfs.c | 2 +-
> drivers/net/ethernet/intel/ice/ice_fwlog.c | 37 ++++++++++---------
> -
> drivers/net/ethernet/intel/ice/ice_fwlog.h | 7 ++--
> 4 files changed, 26 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_common.c
> b/drivers/net/ethernet/intel/ice/ice_common.c
> index 5d7f348aa596..7f293c791775 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -992,6 +992,7 @@ int ice_init_hw(struct ice_hw *hw) {
> struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
> void *mac_buf __free(kfree) = NULL;
> + struct ice_pf *pf = hw->back;
> u16 mac_buf_len;
> int status;
>
> @@ -1012,7 +1013,7 @@ int ice_init_hw(struct ice_hw *hw)
> if (status)
> goto err_unroll_cqinit;
>
> - status = ice_fwlog_init(hw, &hw->fwlog);
> + status = ice_fwlog_init(hw, &hw->fwlog, pf->pdev);
> if (status)
> ice_debug(hw, ICE_DBG_FW_LOG, "Error initializing FW
> logging: %d\n",
> status);
> diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c
> b/drivers/net/ethernet/intel/ice/ice_debugfs.c
> index dbcc0cb438aa..1e036bc128c5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
> +++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
> @@ -450,7 +450,7 @@ ice_debugfs_log_size_write(struct file *filp,
> const char __user *buf,
> }
>
> /* free all the buffers and the tracking info and resize */
> - ice_fwlog_realloc_rings(hw, &hw->fwlog, index);
> + ice_fwlog_realloc_rings(&hw->fwlog, index);
>
> /* if we get here, nothing went wrong; return count since we
> didn't
> * really write anything
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> index a010f655ffb7..b1c1359d5ab5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> @@ -73,13 +73,11 @@ static void ice_fwlog_free_ring_buffs(struct
> ice_fwlog_ring *rings) #define ICE_FWLOG_INDEX_TO_BYTES(n) ((128 *
> 1024) << (n))
> /**
> * ice_fwlog_realloc_rings - reallocate the FW log rings
> - * @hw: pointer to the HW structure
> * @fwlog: pointer to the fwlog structure
> * @index: the new index to use to allocate memory for the log data
> *
> */
> -void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog
> *fwlog,
> - int index)
> +void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
> {
> struct ice_fwlog_ring ring;
> int status, ring_size;
> @@ -109,7 +107,7 @@ void ice_fwlog_realloc_rings(struct ice_hw *hw,
> struct ice_fwlog *fwlog,
>
> status = ice_fwlog_alloc_ring_buffs(&ring);
> if (status) {
> - dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory
> for FW log ring data buffers\n");
> + dev_warn(&fwlog->pdev->dev, "Unable to allocate memory
> for FW log
> +ring data buffers\n");
> ice_fwlog_free_ring_buffs(&ring);
> kfree(ring.rings);
> return;
> @@ -165,16 +163,16 @@ static int ice_aq_fwlog_get(struct ice_hw *hw,
> struct ice_fwlog_cfg *cfg)
>
> 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");
> + dev_dbg(&hw->fwlog.pdev->dev, "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");
> + dev_dbg(&hw->fwlog.pdev->dev, "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);
> + dev_dbg(&hw->fwlog.pdev->dev, "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;
> }
>
> @@ -225,8 +223,8 @@ static void ice_fwlog_set_supported(struct ice_hw
> *hw, struct ice_fwlog *fwlog)
>
> 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);
> + dev_dbg(&fwlog->pdev->dev, "ice_aq_fwlog_get failed, FW
> logging is not supported on this version of FW, status %d\n",
> + status);
> else
> fwlog->supported = true;
>
> @@ -237,17 +235,20 @@ static void ice_fwlog_set_supported(struct
> ice_hw *hw, struct ice_fwlog *fwlog)
> * ice_fwlog_init - Initialize FW logging configuration
> * @hw: pointer to the HW structure
> * @fwlog: pointer to the fwlog structure
> + * @pdev: pointer to the pci dev used in dev_warn()
> *
> * This function should be called on driver initialization during
> * ice_init_hw().
> */
> -int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog)
> +int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
> + struct pci_dev *pdev)
> {
> /* only support fw log commands on PF 0 */
> if (hw->bus.func)
> return -EINVAL;
>
> ice_fwlog_set_supported(hw, fwlog);
> + fwlog->pdev = pdev;
>
> if (ice_fwlog_supported(fwlog)) {
> int status;
> @@ -261,7 +262,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
> sizeof(*fwlog->ring.rings),
> GFP_KERNEL);
> if (!fwlog->ring.rings) {
> - dev_warn(ice_hw_to_dev(hw), "Unable to allocate
> memory for FW log rings\n");
> + dev_warn(&fwlog->pdev->dev, "Unable to allocate
> memory for FW log
> +rings\n");
> return -ENOMEM;
> }
>
> @@ -270,7 +271,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
>
> status = ice_fwlog_alloc_ring_buffs(&fwlog->ring);
> if (status) {
> - dev_warn(ice_hw_to_dev(hw), "Unable to allocate
> memory for FW log ring data buffers\n");
> + dev_warn(&fwlog->pdev->dev, "Unable to allocate
> memory for FW log
> +ring data buffers\n");
> ice_fwlog_free_ring_buffs(&fwlog->ring);
> kfree(fwlog->ring.rings);
> return status;
> @@ -278,7 +279,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
>
> ice_debugfs_fwlog_init(hw->back);
> } else {
> - dev_warn(ice_hw_to_dev(hw), "FW logging is not supported
> in this NVM image. Please update the NVM to get FW log support\n");
> + dev_warn(&fwlog->pdev->dev, "FW logging is not supported
> in this NVM
> +image. Please update the NVM to get FW log support\n");
> }
>
> return 0;
> @@ -308,7 +309,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
> fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
> status = ice_fwlog_set(hw, &fwlog->cfg);
> if (status)
> - dev_warn(ice_hw_to_dev(hw), "Unable to turn off FW
> logging, status: %d\n",
> + dev_warn(&fwlog->pdev->dev, "Unable to turn off FW
> logging, status:
> +%d\n",
> status);
>
> kfree(pf->ice_debugfs_pf_fwlog_modules);
> @@ -317,7 +318,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
>
> status = ice_fwlog_unregister(hw, fwlog);
> if (status)
> - dev_warn(ice_hw_to_dev(hw), "Unable to unregister FW
> logging, status: %d\n",
> + dev_warn(&fwlog->pdev->dev, "Unable to unregister FW
> logging, status:
> +%d\n",
> status);
>
> if (fwlog->ring.rings) {
> @@ -436,7 +437,7 @@ int ice_fwlog_register(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
>
> 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");
> + dev_dbg(&fwlog->pdev->dev, "Failed to register for
> firmware logging
> +events over ARQ\n");
> else
> fwlog->cfg.options |= ICE_FWLOG_OPTION_IS_REGISTERED;
>
> @@ -457,7 +458,7 @@ int ice_fwlog_unregister(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
>
> 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");
> + dev_dbg(&fwlog->pdev->dev, "Failed to unregister from
> firmware
> +logging events over ARQ\n");
> else
> fwlog->cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED;
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h
> b/drivers/net/ethernet/intel/ice/ice_fwlog.h
> index 334a125eac80..9c56ca6cbef0 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
> @@ -68,16 +68,17 @@ struct ice_fwlog {
> struct ice_fwlog_cfg cfg;
> bool supported; /* does hardware support FW logging? */
> struct ice_fwlog_ring ring;
> + struct pci_dev *pdev;
> };
>
> bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings); void
> ice_fwlog_ring_increment(u16 *item, u16 size); -int
> ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog);
> +int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
> + struct pci_dev *pdev);
> void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
> int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg); int
> ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog); int
> ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog); -
> void ice_fwlog_realloc_rings(struct ice_hw *hw, struct ice_fwlog
> *fwlog,
> - int index);
> +void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index);
> void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
> #endif /* _ICE_FWLOG_H_ */
> --
> 2.49.0
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 06/15] ice: allow calling custom send function in fwlog
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (4 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 05/15] ice: add pdev into fwlog structure and use it for logging Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 07/15] ice: move out debugfs init from fwlog Michal Swiatkowski
` (9 subsequent siblings)
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Fwlog code needs to communicate with FW. In ice it is done through admin
queue command. Allow indirect calling the send function to move the
specific admin queue send function from fwlog core code.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 23 ++++++-
drivers/net/ethernet/intel/ice/ice_debugfs.c | 6 +-
drivers/net/ethernet/intel/ice/ice_fwlog.c | 67 ++++++++++----------
drivers/net/ethernet/intel/ice/ice_fwlog.h | 14 ++--
4 files changed, 65 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 7f293c791775..7b4ff20f3346 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -984,6 +984,26 @@ static int ice_wait_for_fw(struct ice_hw *hw, u32 timeout)
return -ETIMEDOUT;
}
+static int __fwlog_send_cmd(void *priv, struct libie_aq_desc *desc, void *buf,
+ u16 size)
+{
+ struct ice_hw *hw = priv;
+
+ return ice_aq_send_cmd(hw, desc, buf, size, NULL);
+}
+
+static int __fwlog_init(struct ice_hw *hw)
+{
+ struct ice_pf *pf = hw->back;
+ struct ice_fwlog_api api = {
+ .pdev = pf->pdev,
+ .send_cmd = __fwlog_send_cmd,
+ .priv = hw,
+ };
+
+ return ice_fwlog_init(hw, &hw->fwlog, &api);
+}
+
/**
* ice_init_hw - main hardware initialization routine
* @hw: pointer to the hardware structure
@@ -992,7 +1012,6 @@ int ice_init_hw(struct ice_hw *hw)
{
struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
void *mac_buf __free(kfree) = NULL;
- struct ice_pf *pf = hw->back;
u16 mac_buf_len;
int status;
@@ -1013,7 +1032,7 @@ int ice_init_hw(struct ice_hw *hw)
if (status)
goto err_unroll_cqinit;
- status = ice_fwlog_init(hw, &hw->fwlog, pf->pdev);
+ status = __fwlog_init(hw);
if (status)
ice_debug(hw, ICE_DBG_FW_LOG, "Error initializing FW logging: %d\n",
status);
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index 1e036bc128c5..9235ae099e17 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -350,14 +350,14 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
else
hw->fwlog.cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
- ret = ice_fwlog_set(hw, &hw->fwlog.cfg);
+ ret = ice_fwlog_set(&hw->fwlog, &hw->fwlog.cfg);
if (ret)
goto enable_write_error;
if (enable)
- ret = ice_fwlog_register(hw, &hw->fwlog);
+ ret = ice_fwlog_register(&hw->fwlog);
else
- ret = ice_fwlog_unregister(hw, &hw->fwlog);
+ ret = ice_fwlog_unregister(&hw->fwlog);
if (ret)
goto enable_write_error;
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index b1c1359d5ab5..172905187a3e 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -137,10 +137,10 @@ static bool ice_fwlog_supported(struct ice_fwlog *fwlog)
/**
* ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32)
- * @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
* @cfg: firmware logging configuration to populate
*/
-static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
+static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
{
struct ice_aqc_fw_log_cfg_resp *fw_modules;
struct ice_aqc_fw_log *cmd;
@@ -161,17 +161,17 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_QUERY;
- status = ice_aq_send_cmd(hw, &desc, buf, ICE_AQ_MAX_BUF_LEN, NULL);
+ status = fwlog->send_cmd(fwlog->priv, &desc, buf, ICE_AQ_MAX_BUF_LEN);
if (status) {
- dev_dbg(&hw->fwlog.pdev->dev, "Failed to get FW log configuration\n");
+ dev_dbg(&fwlog->pdev->dev, "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) {
- dev_dbg(&hw->fwlog.pdev->dev, "FW returned less than the expected number of FW log module IDs\n");
+ dev_dbg(&fwlog->pdev->dev, "FW returned less than the expected number of FW log module IDs\n");
} else if (module_id_cnt > ICE_AQC_FW_LOG_ID_MAX) {
- dev_dbg(&hw->fwlog.pdev->dev, "FW returned more than expected number of FW log module IDs, setting module_id_cnt to software expected max %u\n",
+ dev_dbg(&fwlog->pdev->dev, "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;
}
@@ -201,7 +201,6 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
/**
* ice_fwlog_set_supported - Set if FW logging is supported by FW
- * @hw: pointer to the HW struct
* @fwlog: pointer to the fwlog structure
*
* If FW returns success to the ice_aq_fwlog_get call then it supports FW
@@ -210,7 +209,7 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
* This function is only meant to be called during driver init to determine if
* the FW support FW logging.
*/
-static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
+static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
{
struct ice_fwlog_cfg *cfg;
int status;
@@ -221,7 +220,7 @@ static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
if (!cfg)
return;
- status = ice_aq_fwlog_get(hw, cfg);
+ status = ice_aq_fwlog_get(fwlog, cfg);
if (status)
dev_dbg(&fwlog->pdev->dev, "ice_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n",
status);
@@ -235,26 +234,26 @@ static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
* ice_fwlog_init - Initialize FW logging configuration
* @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog structure
- * @pdev: pointer to the pci dev used in dev_warn()
+ * @api: api structure to init fwlog
*
* This function should be called on driver initialization during
* ice_init_hw().
*/
int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
- struct pci_dev *pdev)
+ struct ice_fwlog_api *api)
{
/* only support fw log commands on PF 0 */
if (hw->bus.func)
return -EINVAL;
- ice_fwlog_set_supported(hw, fwlog);
- fwlog->pdev = pdev;
+ fwlog->api = *api;
+ ice_fwlog_set_supported(fwlog);
if (ice_fwlog_supported(fwlog)) {
int status;
/* read the current config from the FW and store it */
- status = ice_aq_fwlog_get(hw, &fwlog->cfg);
+ status = ice_aq_fwlog_get(fwlog, &fwlog->cfg);
if (status)
return status;
@@ -307,7 +306,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
* for the next driver load
*/
fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
- status = ice_fwlog_set(hw, &fwlog->cfg);
+ status = ice_fwlog_set(fwlog, &fwlog->cfg);
if (status)
dev_warn(&fwlog->pdev->dev, "Unable to turn off FW logging, status: %d\n",
status);
@@ -316,7 +315,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
pf->ice_debugfs_pf_fwlog_modules = NULL;
- status = ice_fwlog_unregister(hw, fwlog);
+ status = ice_fwlog_unregister(fwlog);
if (status)
dev_warn(&fwlog->pdev->dev, "Unable to unregister FW logging, status: %d\n",
status);
@@ -329,15 +328,16 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
/**
* ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30)
- * @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog 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)
+ice_aq_fwlog_set(struct ice_fwlog *fwlog,
+ 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;
@@ -369,9 +369,8 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
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);
+ status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules,
+ sizeof(*fw_modules) * num_entries);
kfree(fw_modules);
@@ -380,7 +379,7 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
/**
* ice_fwlog_set - Set the firmware logging settings
- * @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
* @cfg: config used to set firmware logging
*
* This function should be called whenever the driver needs to set the firmware
@@ -391,22 +390,22 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
* 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 ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
{
- if (!ice_fwlog_supported(&hw->fwlog))
+ if (!ice_fwlog_supported(fwlog))
return -EOPNOTSUPP;
- return ice_aq_fwlog_set(hw, cfg->module_entries,
+ return ice_aq_fwlog_set(fwlog, cfg->module_entries,
ICE_AQC_FW_LOG_ID_MAX, cfg->options,
cfg->log_resolution);
}
/**
* ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31)
- * @hw: pointer to the HW structure
+ * @fwlog: pointer to the fwlog structure
* @reg: true to register and false to unregister
*/
-static int ice_aq_fwlog_register(struct ice_hw *hw, bool reg)
+static int ice_aq_fwlog_register(struct ice_fwlog *fwlog, bool reg)
{
struct ice_aqc_fw_log *cmd;
struct libie_aq_desc desc;
@@ -417,25 +416,24 @@ static int ice_aq_fwlog_register(struct ice_hw *hw, bool reg)
if (reg)
cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_REGISTER;
- return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
+ return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0);
}
/**
* ice_fwlog_register - Register the PF for firmware logging
- * @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog 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, struct ice_fwlog *fwlog)
+int ice_fwlog_register(struct ice_fwlog *fwlog)
{
int status;
if (!ice_fwlog_supported(fwlog))
return -EOPNOTSUPP;
- status = ice_aq_fwlog_register(hw, true);
+ status = ice_aq_fwlog_register(fwlog, true);
if (status)
dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n");
else
@@ -446,17 +444,16 @@ int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog)
/**
* ice_fwlog_unregister - Unregister the PF from firmware logging
- * @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog structure
*/
-int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog)
+int ice_fwlog_unregister(struct ice_fwlog *fwlog)
{
int status;
if (!ice_fwlog_supported(fwlog))
return -EOPNOTSUPP;
- status = ice_aq_fwlog_register(hw, false);
+ status = ice_aq_fwlog_register(fwlog, false);
if (status)
dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n");
else
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 9c56ca6cbef0..fe4b2ce6813f 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -68,17 +68,21 @@ struct ice_fwlog {
struct ice_fwlog_cfg cfg;
bool supported; /* does hardware support FW logging? */
struct ice_fwlog_ring ring;
- struct pci_dev *pdev;
+ struct_group_tagged(ice_fwlog_api, api,
+ struct pci_dev *pdev;
+ int (*send_cmd)(void *, struct libie_aq_desc *, void *, u16);
+ void *priv;
+ );
};
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
void ice_fwlog_ring_increment(u16 *item, u16 size);
int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
- struct pci_dev *pdev);
+ struct ice_fwlog_api *api);
void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
-int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
-int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog);
-int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog);
+int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg);
+int ice_fwlog_register(struct ice_fwlog *fwlog);
+int ice_fwlog_unregister(struct ice_fwlog *fwlog);
void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index);
void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
#endif /* _ICE_FWLOG_H_ */
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 07/15] ice: move out debugfs init from fwlog
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (5 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 06/15] ice: allow calling custom send function in fwlog Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 08/15] ice: check for PF number outside the fwlog code Michal Swiatkowski
` (8 subsequent siblings)
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
The root debugfs directory should be available from driver side, not
from library. Move it out from fwlog code.
Make similar to __fwlog_init() __fwlog_deinit() and deinit debugfs
there. In case of ice only fwlog is using debugfs.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice.h | 1 +
drivers/net/ethernet/intel/ice/ice_common.c | 14 ++++++++++++--
drivers/net/ethernet/intel/ice/ice_debugfs.c | 20 +++++++++++++++-----
drivers/net/ethernet/intel/ice/ice_fwlog.c | 2 --
4 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index a6803b344540..ee2ae0cbc25e 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -909,6 +909,7 @@ static inline bool ice_is_adq_active(struct ice_pf *pf)
}
void ice_debugfs_fwlog_init(struct ice_pf *pf);
+int ice_debugfs_pf_init(struct ice_pf *pf);
void ice_debugfs_pf_deinit(struct ice_pf *pf);
void ice_debugfs_init(void);
void ice_debugfs_exit(void);
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 7b4ff20f3346..9119d097eb08 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1000,6 +1000,11 @@ static int __fwlog_init(struct ice_hw *hw)
.send_cmd = __fwlog_send_cmd,
.priv = hw,
};
+ int err;
+
+ err = ice_debugfs_pf_init(pf);
+ if (err)
+ return err;
return ice_fwlog_init(hw, &hw->fwlog, &api);
}
@@ -1179,6 +1184,12 @@ int ice_init_hw(struct ice_hw *hw)
return status;
}
+static void __fwlog_deinit(struct ice_hw *hw)
+{
+ ice_debugfs_pf_deinit(hw->back);
+ ice_fwlog_deinit(hw, &hw->fwlog);
+}
+
/**
* ice_deinit_hw - unroll initialization operations done by ice_init_hw
* @hw: pointer to the hardware structure
@@ -1197,8 +1208,7 @@ void ice_deinit_hw(struct ice_hw *hw)
ice_free_seg(hw);
ice_free_hw_tbls(hw);
mutex_destroy(&hw->tnl_lock);
-
- ice_fwlog_deinit(hw, &hw->fwlog);
+ __fwlog_deinit(hw);
ice_destroy_all_ctrlq(hw);
/* Clear VSI contexts if not already cleared */
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index 9235ae099e17..c7d9e92d7f56 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -584,7 +584,6 @@ static const struct file_operations ice_debugfs_data_fops = {
*/
void ice_debugfs_fwlog_init(struct ice_pf *pf)
{
- const char *name = pci_name(pf->pdev);
struct dentry *fw_modules_dir;
struct dentry **fw_modules;
int i;
@@ -601,10 +600,6 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
if (!fw_modules)
return;
- pf->ice_debugfs_pf = debugfs_create_dir(name, ice_debugfs_root);
- if (IS_ERR(pf->ice_debugfs_pf))
- goto err_create_module_files;
-
pf->ice_debugfs_pf_fwlog = debugfs_create_dir("fwlog",
pf->ice_debugfs_pf);
if (IS_ERR(pf->ice_debugfs_pf_fwlog))
@@ -645,6 +640,21 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
kfree(fw_modules);
}
+/**
+ * ice_debugfs_pf_init - create PF's debugfs
+ * @pf: pointer to the PF struct
+ */
+int ice_debugfs_pf_init(struct ice_pf *pf)
+{
+ const char *name = pci_name(pf->pdev);
+
+ pf->ice_debugfs_pf = debugfs_create_dir(name, ice_debugfs_root);
+ if (IS_ERR(pf->ice_debugfs_pf))
+ return PTR_ERR(pf->ice_debugfs_pf);
+
+ return 0;
+}
+
/**
* ice_debugfs_pf_deinit - cleanup PF's debugfs
* @pf: pointer to the PF struct
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index 172905187a3e..f7dbcb5e11aa 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -300,8 +300,6 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
if (hw->bus.func)
return;
- ice_debugfs_pf_deinit(hw->back);
-
/* make sure FW logging is disabled to not put the FW in a weird state
* for the next driver load
*/
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 08/15] ice: check for PF number outside the fwlog code
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (6 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 07/15] ice: move out debugfs init from fwlog Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-23 10:38 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 09/15] ice: drop driver specific structure from " Michal Swiatkowski
` (7 subsequent siblings)
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Fwlog can be supported only on PF 0. Check this before calling
init/deinit functions.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 8 ++++++++
drivers/net/ethernet/intel/ice/ice_debugfs.c | 4 ----
drivers/net/ethernet/intel/ice/ice_fwlog.c | 7 -------
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 9119d097eb08..2666e59b0786 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1002,6 +1002,10 @@ static int __fwlog_init(struct ice_hw *hw)
};
int err;
+ /* only support fw log commands on PF 0 */
+ if (hw->bus.func)
+ return -EINVAL;
+
err = ice_debugfs_pf_init(pf);
if (err)
return err;
@@ -1186,6 +1190,10 @@ int ice_init_hw(struct ice_hw *hw)
static void __fwlog_deinit(struct ice_hw *hw)
{
+ /* only support fw log commands on PF 0 */
+ if (hw->bus.func)
+ return;
+
ice_debugfs_pf_deinit(hw->back);
ice_fwlog_deinit(hw, &hw->fwlog);
}
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index c7d9e92d7f56..e5b63b6bd44d 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -588,10 +588,6 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
struct dentry **fw_modules;
int i;
- /* only support fw log commands on PF 0 */
- if (pf->hw.bus.func)
- return;
-
/* allocate space for this first because if it fails then we don't
* need to unwind
*/
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index f7dbcb5e11aa..634e3de3ae66 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -242,9 +242,6 @@ static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
struct ice_fwlog_api *api)
{
- /* only support fw log commands on PF 0 */
- if (hw->bus.func)
- return -EINVAL;
fwlog->api = *api;
ice_fwlog_set_supported(fwlog);
@@ -296,10 +293,6 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
struct ice_pf *pf = hw->back;
int status;
- /* only support fw log commands on PF 0 */
- if (hw->bus.func)
- return;
-
/* make sure FW logging is disabled to not put the FW in a weird state
* for the next driver load
*/
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 08/15] ice: check for PF number outside the fwlog code
2025-07-22 10:45 ` [PATCH iwl-next v1 08/15] ice: check for PF number outside the fwlog code Michal Swiatkowski
@ 2025-07-23 10:38 ` Loktionov, Aleksandr
0 siblings, 0 replies; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-23 10:38 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 08/15] ice: check for PF
> number outside the fwlog code
>
> Fwlog can be supported only on PF 0. Check this before calling
> init/deinit functions.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_common.c | 8 ++++++++
> drivers/net/ethernet/intel/ice/ice_debugfs.c | 4 ----
> drivers/net/ethernet/intel/ice/ice_fwlog.c | 7 -------
> 3 files changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_common.c
> b/drivers/net/ethernet/intel/ice/ice_common.c
> index 9119d097eb08..2666e59b0786 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -1002,6 +1002,10 @@ static int __fwlog_init(struct ice_hw *hw)
> };
> int err;
>
> + /* only support fw log commands on PF 0 */
> + if (hw->bus.func)
> + return -EINVAL;
> +
> err = ice_debugfs_pf_init(pf);
> if (err)
> return err;
> @@ -1186,6 +1190,10 @@ int ice_init_hw(struct ice_hw *hw)
>
> static void __fwlog_deinit(struct ice_hw *hw) {
> + /* only support fw log commands on PF 0 */
> + if (hw->bus.func)
> + return;
> +
> ice_debugfs_pf_deinit(hw->back);
> ice_fwlog_deinit(hw, &hw->fwlog);
> }
> diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c
> b/drivers/net/ethernet/intel/ice/ice_debugfs.c
> index c7d9e92d7f56..e5b63b6bd44d 100644
> --- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
> +++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
> @@ -588,10 +588,6 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
> struct dentry **fw_modules;
> int i;
>
> - /* only support fw log commands on PF 0 */
> - if (pf->hw.bus.func)
> - return;
> -
> /* allocate space for this first because if it fails then we
> don't
> * need to unwind
> */
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> index f7dbcb5e11aa..634e3de3ae66 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> @@ -242,9 +242,6 @@ static void ice_fwlog_set_supported(struct
> ice_fwlog *fwlog) int ice_fwlog_init(struct ice_hw *hw, struct
> ice_fwlog *fwlog,
> struct ice_fwlog_api *api)
> {
> - /* only support fw log commands on PF 0 */
> - if (hw->bus.func)
> - return -EINVAL;
>
> fwlog->api = *api;
> ice_fwlog_set_supported(fwlog);
> @@ -296,10 +293,6 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct
> ice_fwlog *fwlog)
> struct ice_pf *pf = hw->back;
> int status;
>
> - /* only support fw log commands on PF 0 */
> - if (hw->bus.func)
> - return;
> -
> /* make sure FW logging is disabled to not put the FW in a
> weird state
> * for the next driver load
> */
> --
> 2.49.0
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 09/15] ice: drop driver specific structure from fwlog code
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (7 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 08/15] ice: check for PF number outside the fwlog code Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 14:54 ` Simon Horman
2025-07-23 10:42 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 10:45 ` [PATCH iwl-next v1 10/15] libie, ice: move fwlog admin queue to libie Michal Swiatkowski
` (6 subsequent siblings)
15 siblings, 2 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
In debugfs pass ice_fwlog structure instead of ice_pf.
The debgufs dirs specific for fwlog can be stored in fwlog structure.
Add debugfs entry point to fwlog api.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice.h | 5 +-
drivers/net/ethernet/intel/ice/ice_common.c | 6 +-
drivers/net/ethernet/intel/ice/ice_debugfs.c | 128 +++++++++----------
drivers/net/ethernet/intel/ice/ice_fwlog.c | 14 +-
drivers/net/ethernet/intel/ice/ice_fwlog.h | 9 +-
5 files changed, 74 insertions(+), 88 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index ee2ae0cbc25e..9ed4197ee7bc 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -568,9 +568,6 @@ struct ice_pf {
struct ice_sw *first_sw; /* first switch created by firmware */
u16 eswitch_mode; /* current mode of eswitch */
struct dentry *ice_debugfs_pf;
- struct dentry *ice_debugfs_pf_fwlog;
- /* keep track of all the dentrys for FW log modules */
- struct dentry **ice_debugfs_pf_fwlog_modules;
struct ice_vfs vfs;
DECLARE_BITMAP(features, ICE_F_MAX);
DECLARE_BITMAP(state, ICE_STATE_NBITS);
@@ -908,7 +905,7 @@ static inline bool ice_is_adq_active(struct ice_pf *pf)
return false;
}
-void ice_debugfs_fwlog_init(struct ice_pf *pf);
+void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root);
int ice_debugfs_pf_init(struct ice_pf *pf);
void ice_debugfs_pf_deinit(struct ice_pf *pf);
void ice_debugfs_init(void);
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 2666e59b0786..5a365f65c0e3 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1010,7 +1010,9 @@ static int __fwlog_init(struct ice_hw *hw)
if (err)
return err;
- return ice_fwlog_init(hw, &hw->fwlog, &api);
+ api.debugfs_root = pf->ice_debugfs_pf;
+
+ return ice_fwlog_init(&hw->fwlog, &api);
}
/**
@@ -1195,7 +1197,7 @@ static void __fwlog_deinit(struct ice_hw *hw)
return;
ice_debugfs_pf_deinit(hw->back);
- ice_fwlog_deinit(hw, &hw->fwlog);
+ ice_fwlog_deinit(&hw->fwlog);
}
/**
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index e5b63b6bd44d..c0258302d5d5 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -74,14 +74,14 @@ static const char * const ice_fwlog_log_size[] = {
/**
* ice_fwlog_print_module_cfg - print current FW logging module configuration
- * @hw: pointer to the HW structure
+ * @cfg: pointer to the fwlog cfg structure
* @module: module to print
* @s: the seq file to put data into
*/
static void
-ice_fwlog_print_module_cfg(struct ice_hw *hw, int module, struct seq_file *s)
+ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
+ struct seq_file *s)
{
- struct ice_fwlog_cfg *cfg = &hw->fwlog.cfg;
struct ice_fwlog_module_entry *entry;
if (module != ICE_AQC_FW_LOG_ID_MAX) {
@@ -103,14 +103,14 @@ ice_fwlog_print_module_cfg(struct ice_hw *hw, int module, struct seq_file *s)
}
}
-static int ice_find_module_by_dentry(struct ice_pf *pf, struct dentry *d)
+static int ice_find_module_by_dentry(struct dentry **modules, struct dentry *d)
{
int i, module;
module = -1;
/* find the module based on the dentry */
for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
- if (d == pf->ice_debugfs_pf_fwlog_modules[i]) {
+ if (d == modules[i]) {
module = i;
break;
}
@@ -126,21 +126,20 @@ static int ice_find_module_by_dentry(struct ice_pf *pf, struct dentry *d)
*/
static int ice_debugfs_module_show(struct seq_file *s, void *v)
{
+ struct ice_fwlog *fwlog = s->private;
const struct file *filp = s->file;
struct dentry *dentry;
- struct ice_pf *pf;
int module;
dentry = file_dentry(filp);
- pf = s->private;
- module = ice_find_module_by_dentry(pf, dentry);
+ module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
if (module < 0) {
- dev_info(ice_pf_to_dev(pf), "unknown module\n");
+ dev_info(&fwlog->pdev->dev, "unknown module\n");
return -EINVAL;
}
- ice_fwlog_print_module_cfg(&pf->hw, module, s);
+ ice_fwlog_print_module_cfg(&fwlog->cfg, module, s);
return 0;
}
@@ -161,10 +160,9 @@ static ssize_t
ice_debugfs_module_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
- struct ice_pf *pf = file_inode(filp)->i_private;
+ struct ice_fwlog *fwlog = file_inode(filp)->i_private;
struct dentry *dentry = file_dentry(filp);
- struct device *dev = ice_pf_to_dev(pf);
- struct ice_hw *hw = &pf->hw;
+ struct device *dev = &fwlog->pdev->dev;
char user_val[16], *cmd_buf;
int module, log_level, cnt;
@@ -176,7 +174,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
if (IS_ERR(cmd_buf))
return PTR_ERR(cmd_buf);
- module = ice_find_module_by_dentry(pf, dentry);
+ module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
if (module < 0) {
dev_info(dev, "unknown module\n");
return -EINVAL;
@@ -193,7 +191,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
}
if (module != ICE_AQC_FW_LOG_ID_MAX) {
- hw->fwlog.cfg.module_entries[module].log_level = log_level;
+ fwlog->cfg.module_entries[module].log_level = log_level;
} else {
/* the module 'all' is a shortcut so that we can set
* all of the modules to the same level quickly
@@ -201,7 +199,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
int i;
for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++)
- hw->fwlog.cfg.module_entries[i].log_level = log_level;
+ fwlog->cfg.module_entries[i].log_level = log_level;
}
return count;
@@ -226,12 +224,11 @@ static ssize_t ice_debugfs_nr_messages_read(struct file *filp,
char __user *buffer, size_t count,
loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
char buff[32] = {};
snprintf(buff, sizeof(buff), "%d\n",
- hw->fwlog.cfg.log_resolution);
+ fwlog->cfg.log_resolution);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
}
@@ -247,9 +244,8 @@ static ssize_t
ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct device *dev = ice_pf_to_dev(pf);
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
+ struct device *dev = &fwlog->pdev->dev;
char user_val[8], *cmd_buf;
s16 nr_messages;
ssize_t ret;
@@ -278,7 +274,7 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
return -EINVAL;
}
- hw->fwlog.cfg.log_resolution = nr_messages;
+ fwlog->cfg.log_resolution = nr_messages;
return count;
}
@@ -301,12 +297,11 @@ static ssize_t ice_debugfs_enable_read(struct file *filp,
char __user *buffer, size_t count,
loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
char buff[32] = {};
snprintf(buff, sizeof(buff), "%u\n",
- (u16)(hw->fwlog.cfg.options &
+ (u16)(fwlog->cfg.options &
ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
@@ -323,8 +318,7 @@ static ssize_t
ice_debugfs_enable_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
char user_val[8], *cmd_buf;
bool enable;
ssize_t ret;
@@ -346,18 +340,18 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
goto enable_write_error;
if (enable)
- hw->fwlog.cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
+ fwlog->cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
else
- hw->fwlog.cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
+ fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
- ret = ice_fwlog_set(&hw->fwlog, &hw->fwlog.cfg);
+ ret = ice_fwlog_set(fwlog, &fwlog->cfg);
if (ret)
goto enable_write_error;
if (enable)
- ret = ice_fwlog_register(&hw->fwlog);
+ ret = ice_fwlog_register(fwlog);
else
- ret = ice_fwlog_unregister(&hw->fwlog);
+ ret = ice_fwlog_unregister(fwlog);
if (ret)
goto enable_write_error;
@@ -396,12 +390,11 @@ static ssize_t ice_debugfs_log_size_read(struct file *filp,
char __user *buffer, size_t count,
loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
char buff[32] = {};
int index;
- index = hw->fwlog.ring.index;
+ index = fwlog->ring.index;
snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
@@ -418,9 +411,8 @@ static ssize_t
ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct device *dev = ice_pf_to_dev(pf);
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
+ struct device *dev = &fwlog->pdev->dev;
char user_val[8], *cmd_buf;
ssize_t ret;
int index;
@@ -443,14 +435,14 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
user_val);
ret = -EINVAL;
goto log_size_write_error;
- } else if (hw->fwlog.cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
+ } else if (fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
dev_info(dev, "FW logging is currently running. Please disable FW logging to change log_size\n");
ret = -EINVAL;
goto log_size_write_error;
}
/* free all the buffers and the tracking info and resize */
- ice_fwlog_realloc_rings(&hw->fwlog, index);
+ ice_fwlog_realloc_rings(fwlog, index);
/* if we get here, nothing went wrong; return count since we didn't
* really write anything
@@ -485,19 +477,18 @@ static const struct file_operations ice_debugfs_log_size_fops = {
static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
size_t count, loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
int data_copied = 0;
bool done = false;
- if (ice_fwlog_ring_empty(&hw->fwlog.ring))
+ if (ice_fwlog_ring_empty(&fwlog->ring))
return 0;
- while (!ice_fwlog_ring_empty(&hw->fwlog.ring) && !done) {
+ while (!ice_fwlog_ring_empty(&fwlog->ring) && !done) {
struct ice_fwlog_data *log;
u16 cur_buf_len;
- log = &hw->fwlog.ring.rings[hw->fwlog.ring.head];
+ log = &fwlog->ring.rings[fwlog->ring.head];
cur_buf_len = log->data_size;
if (cur_buf_len >= count) {
done = true;
@@ -516,8 +507,7 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
buffer += cur_buf_len;
count -= cur_buf_len;
*ppos += cur_buf_len;
- ice_fwlog_ring_increment(&hw->fwlog.ring.head,
- hw->fwlog.ring.size);
+ ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
}
return data_copied;
@@ -534,9 +524,8 @@ static ssize_t
ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
loff_t *ppos)
{
- struct ice_pf *pf = filp->private_data;
- struct device *dev = ice_pf_to_dev(pf);
- struct ice_hw *hw = &pf->hw;
+ struct ice_fwlog *fwlog = filp->private_data;
+ struct device *dev = &fwlog->pdev->dev;
ssize_t ret;
/* don't allow partial writes */
@@ -546,9 +535,9 @@ ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
/* any value is allowed to clear the buffer so no need to even look at
* what the value is
*/
- if (!(hw->fwlog.cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
- hw->fwlog.ring.head = 0;
- hw->fwlog.ring.tail = 0;
+ if (!(fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
+ fwlog->ring.head = 0;
+ fwlog->ring.tail = 0;
} else {
dev_info(dev, "Can't clear FW log data while FW log running\n");
ret = -EINVAL;
@@ -580,9 +569,10 @@ static const struct file_operations ice_debugfs_data_fops = {
/**
* ice_debugfs_fwlog_init - setup the debugfs directory
- * @pf: the ice that is starting up
+ * @fwlog: pointer to the fwlog structure
+ * @root: debugfs root entry on which fwlog director will be registered
*/
-void ice_debugfs_fwlog_init(struct ice_pf *pf)
+void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
{
struct dentry *fw_modules_dir;
struct dentry **fw_modules;
@@ -598,41 +588,39 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
pf->ice_debugfs_pf_fwlog = debugfs_create_dir("fwlog",
pf->ice_debugfs_pf);
- if (IS_ERR(pf->ice_debugfs_pf_fwlog))
+ if (IS_ERR(fwlog->debugfs))
goto err_create_module_files;
- fw_modules_dir = debugfs_create_dir("modules",
- pf->ice_debugfs_pf_fwlog);
+ fw_modules_dir = debugfs_create_dir("modules", fwlog->debugfs);
if (IS_ERR(fw_modules_dir))
goto err_create_module_files;
for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
fw_modules[i] = debugfs_create_file(ice_fwlog_module_string[i],
- 0600, fw_modules_dir, pf,
+ 0600, fw_modules_dir, fwlog,
&ice_debugfs_module_fops);
if (IS_ERR(fw_modules[i]))
goto err_create_module_files;
}
- debugfs_create_file("nr_messages", 0600,
- pf->ice_debugfs_pf_fwlog, pf,
+ debugfs_create_file("nr_messages", 0600, fwlog->debugfs, fwlog,
&ice_debugfs_nr_messages_fops);
- pf->ice_debugfs_pf_fwlog_modules = fw_modules;
+ fwlog->debugfs_modules = fw_modules;
- debugfs_create_file("enable", 0600, pf->ice_debugfs_pf_fwlog,
- pf, &ice_debugfs_enable_fops);
+ debugfs_create_file("enable", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_enable_fops);
- debugfs_create_file("log_size", 0600, pf->ice_debugfs_pf_fwlog,
- pf, &ice_debugfs_log_size_fops);
+ debugfs_create_file("log_size", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_log_size_fops);
- debugfs_create_file("data", 0600, pf->ice_debugfs_pf_fwlog,
- pf, &ice_debugfs_data_fops);
+ debugfs_create_file("data", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_data_fops);
return;
err_create_module_files:
- debugfs_remove_recursive(pf->ice_debugfs_pf_fwlog);
+ debugfs_remove_recursive(fwlog->debugfs);
kfree(fw_modules);
}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index 634e3de3ae66..8a1fede98865 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -232,15 +232,13 @@ static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
/**
* ice_fwlog_init - Initialize FW logging configuration
- * @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog structure
* @api: api structure to init fwlog
*
* This function should be called on driver initialization during
* ice_init_hw().
*/
-int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
- struct ice_fwlog_api *api)
+int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api)
{
fwlog->api = *api;
@@ -273,7 +271,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
return status;
}
- ice_debugfs_fwlog_init(hw->back);
+ ice_debugfs_fwlog_init(fwlog, api->debugfs_root);
} else {
dev_warn(&fwlog->pdev->dev, "FW logging is not supported in this NVM image. Please update the NVM to get FW log support\n");
}
@@ -283,14 +281,12 @@ int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
/**
* ice_fwlog_deinit - unroll FW logging configuration
- * @hw: pointer to the HW structure
* @fwlog: pointer to the fwlog structure
*
* This function should be called in ice_deinit_hw().
*/
-void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
+void ice_fwlog_deinit(struct ice_fwlog *fwlog)
{
- struct ice_pf *pf = hw->back;
int status;
/* make sure FW logging is disabled to not put the FW in a weird state
@@ -302,9 +298,9 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
dev_warn(&fwlog->pdev->dev, "Unable to turn off FW logging, status: %d\n",
status);
- kfree(pf->ice_debugfs_pf_fwlog_modules);
+ kfree(fwlog->debugfs_modules);
- pf->ice_debugfs_pf_fwlog_modules = NULL;
+ fwlog->debugfs_modules = NULL;
status = ice_fwlog_unregister(fwlog);
if (status)
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index fe4b2ce6813f..22585ea9ec93 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -68,18 +68,21 @@ struct ice_fwlog {
struct ice_fwlog_cfg cfg;
bool supported; /* does hardware support FW logging? */
struct ice_fwlog_ring ring;
+ struct dentry *debugfs;
+ /* keep track of all the dentrys for FW log modules */
+ struct dentry **debugfs_modules;
struct_group_tagged(ice_fwlog_api, api,
struct pci_dev *pdev;
int (*send_cmd)(void *, struct libie_aq_desc *, void *, u16);
void *priv;
+ struct dentry *debugfs_root;
);
};
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
void ice_fwlog_ring_increment(u16 *item, u16 size);
-int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
- struct ice_fwlog_api *api);
-void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
+int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api);
+void ice_fwlog_deinit(struct ice_fwlog *fwlog);
int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg);
int ice_fwlog_register(struct ice_fwlog *fwlog);
int ice_fwlog_unregister(struct ice_fwlog *fwlog);
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH iwl-next v1 09/15] ice: drop driver specific structure from fwlog code
2025-07-22 10:45 ` [PATCH iwl-next v1 09/15] ice: drop driver specific structure from " Michal Swiatkowski
@ 2025-07-22 14:54 ` Simon Horman
2025-07-23 4:47 ` Michal Swiatkowski
2025-07-23 10:42 ` [Intel-wired-lan] " Loktionov, Aleksandr
1 sibling, 1 reply; 29+ messages in thread
From: Simon Horman @ 2025-07-22 14:54 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: intel-wired-lan, netdev, przemyslaw.kitszel, dawid.osuchowski
On Tue, Jul 22, 2025 at 12:45:54PM +0200, Michal Swiatkowski wrote:
> In debugfs pass ice_fwlog structure instead of ice_pf.
>
> The debgufs dirs specific for fwlog can be stored in fwlog structure.
>
> Add debugfs entry point to fwlog api.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
...
> diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
...
> @@ -580,9 +569,10 @@ static const struct file_operations ice_debugfs_data_fops = {
>
> /**
> * ice_debugfs_fwlog_init - setup the debugfs directory
> - * @pf: the ice that is starting up
> + * @fwlog: pointer to the fwlog structure
> + * @root: debugfs root entry on which fwlog director will be registered
> */
> -void ice_debugfs_fwlog_init(struct ice_pf *pf)
> +void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
> {
> struct dentry *fw_modules_dir;
> struct dentry **fw_modules;
> @@ -598,41 +588,39 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
>
> pf->ice_debugfs_pf_fwlog = debugfs_create_dir("fwlog",
> pf->ice_debugfs_pf);
pf no longer exists in this context.
> - if (IS_ERR(pf->ice_debugfs_pf_fwlog))
> + if (IS_ERR(fwlog->debugfs))
> goto err_create_module_files;
>
> - fw_modules_dir = debugfs_create_dir("modules",
> - pf->ice_debugfs_pf_fwlog);
> + fw_modules_dir = debugfs_create_dir("modules", fwlog->debugfs);
> if (IS_ERR(fw_modules_dir))
> goto err_create_module_files;
...
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH iwl-next v1 09/15] ice: drop driver specific structure from fwlog code
2025-07-22 14:54 ` Simon Horman
@ 2025-07-23 4:47 ` Michal Swiatkowski
0 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-23 4:47 UTC (permalink / raw)
To: Simon Horman
Cc: Michal Swiatkowski, intel-wired-lan, netdev, przemyslaw.kitszel,
dawid.osuchowski
On Tue, Jul 22, 2025 at 03:54:28PM +0100, Simon Horman wrote:
> On Tue, Jul 22, 2025 at 12:45:54PM +0200, Michal Swiatkowski wrote:
> > In debugfs pass ice_fwlog structure instead of ice_pf.
> >
> > The debgufs dirs specific for fwlog can be stored in fwlog structure.
> >
> > Add debugfs entry point to fwlog api.
> >
> > Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> > Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>
> ...
>
> > diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
>
> ...
>
> > @@ -580,9 +569,10 @@ static const struct file_operations ice_debugfs_data_fops = {
> >
> > /**
> > * ice_debugfs_fwlog_init - setup the debugfs directory
> > - * @pf: the ice that is starting up
> > + * @fwlog: pointer to the fwlog structure
> > + * @root: debugfs root entry on which fwlog director will be registered
> > */
> > -void ice_debugfs_fwlog_init(struct ice_pf *pf)
> > +void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
> > {
> > struct dentry *fw_modules_dir;
> > struct dentry **fw_modules;
> > @@ -598,41 +588,39 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
> >
> > pf->ice_debugfs_pf_fwlog = debugfs_create_dir("fwlog",
> > pf->ice_debugfs_pf);
>
> pf no longer exists in this context.
>
Right, sorry, I missed that. I will build check each commit before
sending v2.
Thanks
> > - if (IS_ERR(pf->ice_debugfs_pf_fwlog))
> > + if (IS_ERR(fwlog->debugfs))
> > goto err_create_module_files;
> >
> > - fw_modules_dir = debugfs_create_dir("modules",
> > - pf->ice_debugfs_pf_fwlog);
> > + fw_modules_dir = debugfs_create_dir("modules", fwlog->debugfs);
> > if (IS_ERR(fw_modules_dir))
> > goto err_create_module_files;
>
> ...
^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: [Intel-wired-lan] [PATCH iwl-next v1 09/15] ice: drop driver specific structure from fwlog code
2025-07-22 10:45 ` [PATCH iwl-next v1 09/15] ice: drop driver specific structure from " Michal Swiatkowski
2025-07-22 14:54 ` Simon Horman
@ 2025-07-23 10:42 ` Loktionov, Aleksandr
1 sibling, 0 replies; 29+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-23 10:42 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Kitszel, Przemyslaw,
dawid.osuchowski@linux.intel.com
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Michal Swiatkowski
> Sent: Tuesday, July 22, 2025 12:46 PM
> To: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; dawid.osuchowski@linux.intel.com;
> Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v1 09/15] ice: drop driver
> specific structure from fwlog code
>
> In debugfs pass ice_fwlog structure instead of ice_pf.
>
> The debgufs dirs specific for fwlog can be stored in fwlog structure.
>
> Add debugfs entry point to fwlog api.
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice.h | 5 +-
> drivers/net/ethernet/intel/ice/ice_common.c | 6 +-
> drivers/net/ethernet/intel/ice/ice_debugfs.c | 128 +++++++++---------
> -
> drivers/net/ethernet/intel/ice/ice_fwlog.c | 14 +-
> drivers/net/ethernet/intel/ice/ice_fwlog.h | 9 +-
> 5 files changed, 74 insertions(+), 88 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice.h
> b/drivers/net/ethernet/intel/ice/ice.h
> index ee2ae0cbc25e..9ed4197ee7bc 100644
> --- a/drivers/net/ethernet/intel/ice/ice.h
> +++ b/drivers/net/ethernet/intel/ice/ice.h
> @@ -568,9 +568,6 @@ struct ice_pf {
> struct ice_sw *first_sw; /* first switch created by firmware
> */
> u16 eswitch_mode; /* current mode of eswitch */
> struct dentry *ice_debugfs_pf;
> - struct dentry *ice_debugfs_pf_fwlog;
> - /* keep track of all the dentrys for FW log modules */
> - struct dentry **ice_debugfs_pf_fwlog_modules;
> struct ice_vfs vfs;
> DECLARE_BITMAP(features, ICE_F_MAX);
> DECLARE_BITMAP(state, ICE_STATE_NBITS); @@ -908,7 +905,7 @@
> static inline bool ice_is_adq_active(struct ice_pf *pf)
> return false;
> }
>
> -void ice_debugfs_fwlog_init(struct ice_pf *pf);
> +void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry
> +*root);
> int ice_debugfs_pf_init(struct ice_pf *pf); void
> ice_debugfs_pf_deinit(struct ice_pf *pf); void
> ice_debugfs_init(void); diff --git
> a/drivers/net/ethernet/intel/ice/ice_common.c
> b/drivers/net/ethernet/intel/ice/ice_common.c
> index 2666e59b0786..5a365f65c0e3 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -1010,7 +1010,9 @@ static int __fwlog_init(struct ice_hw *hw)
> if (err)
> return err;
>
> - return ice_fwlog_init(hw, &hw->fwlog, &api);
> + api.debugfs_root = pf->ice_debugfs_pf;
> +
> + return ice_fwlog_init(&hw->fwlog, &api);
> }
>
> /**
> @@ -1195,7 +1197,7 @@ static void __fwlog_deinit(struct ice_hw *hw)
> return;
>
> ice_debugfs_pf_deinit(hw->back);
> - ice_fwlog_deinit(hw, &hw->fwlog);
> + ice_fwlog_deinit(&hw->fwlog);
> }
>
> /**
> diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c
> b/drivers/net/ethernet/intel/ice/ice_debugfs.c
> index e5b63b6bd44d..c0258302d5d5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
> +++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
> @@ -74,14 +74,14 @@ static const char * const ice_fwlog_log_size[] = {
>
> /**
> * ice_fwlog_print_module_cfg - print current FW logging module
> configuration
> - * @hw: pointer to the HW structure
> + * @cfg: pointer to the fwlog cfg structure
> * @module: module to print
> * @s: the seq file to put data into
> */
> static void
> -ice_fwlog_print_module_cfg(struct ice_hw *hw, int module, struct
> seq_file *s)
> +ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
> + struct seq_file *s)
> {
> - struct ice_fwlog_cfg *cfg = &hw->fwlog.cfg;
> struct ice_fwlog_module_entry *entry;
>
> if (module != ICE_AQC_FW_LOG_ID_MAX) { @@ -103,14 +103,14 @@
> ice_fwlog_print_module_cfg(struct ice_hw *hw, int module, struct
> seq_file *s)
> }
> }
>
> -static int ice_find_module_by_dentry(struct ice_pf *pf, struct dentry
> *d)
> +static int ice_find_module_by_dentry(struct dentry **modules, struct
> +dentry *d)
> {
> int i, module;
>
> module = -1;
> /* find the module based on the dentry */
> for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
> - if (d == pf->ice_debugfs_pf_fwlog_modules[i]) {
> + if (d == modules[i]) {
> module = i;
> break;
> }
> @@ -126,21 +126,20 @@ static int ice_find_module_by_dentry(struct
> ice_pf *pf, struct dentry *d)
> */
> static int ice_debugfs_module_show(struct seq_file *s, void *v) {
> + struct ice_fwlog *fwlog = s->private;
> const struct file *filp = s->file;
> struct dentry *dentry;
> - struct ice_pf *pf;
> int module;
>
> dentry = file_dentry(filp);
> - pf = s->private;
>
> - module = ice_find_module_by_dentry(pf, dentry);
> + module = ice_find_module_by_dentry(fwlog->debugfs_modules,
> dentry);
> if (module < 0) {
> - dev_info(ice_pf_to_dev(pf), "unknown module\n");
> + dev_info(&fwlog->pdev->dev, "unknown module\n");
> return -EINVAL;
> }
>
> - ice_fwlog_print_module_cfg(&pf->hw, module, s);
> + ice_fwlog_print_module_cfg(&fwlog->cfg, module, s);
>
> return 0;
> }
> @@ -161,10 +160,9 @@ static ssize_t
> ice_debugfs_module_write(struct file *filp, const char __user *buf,
> size_t count, loff_t *ppos)
> {
> - struct ice_pf *pf = file_inode(filp)->i_private;
> + struct ice_fwlog *fwlog = file_inode(filp)->i_private;
> struct dentry *dentry = file_dentry(filp);
> - struct device *dev = ice_pf_to_dev(pf);
> - struct ice_hw *hw = &pf->hw;
> + struct device *dev = &fwlog->pdev->dev;
> char user_val[16], *cmd_buf;
> int module, log_level, cnt;
>
> @@ -176,7 +174,7 @@ ice_debugfs_module_write(struct file *filp, const
> char __user *buf,
> if (IS_ERR(cmd_buf))
> return PTR_ERR(cmd_buf);
>
> - module = ice_find_module_by_dentry(pf, dentry);
> + module = ice_find_module_by_dentry(fwlog->debugfs_modules,
> dentry);
> if (module < 0) {
> dev_info(dev, "unknown module\n");
> return -EINVAL;
> @@ -193,7 +191,7 @@ ice_debugfs_module_write(struct file *filp, const
> char __user *buf,
> }
>
> if (module != ICE_AQC_FW_LOG_ID_MAX) {
> - hw->fwlog.cfg.module_entries[module].log_level =
> log_level;
> + fwlog->cfg.module_entries[module].log_level = log_level;
> } else {
> /* the module 'all' is a shortcut so that we can set
> * all of the modules to the same level quickly @@ -
> 201,7 +199,7 @@ ice_debugfs_module_write(struct file *filp, const char
> __user *buf,
> int i;
>
> for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++)
> - hw->fwlog.cfg.module_entries[i].log_level =
> log_level;
> + fwlog->cfg.module_entries[i].log_level =
> log_level;
> }
>
> return count;
> @@ -226,12 +224,11 @@ static ssize_t
> ice_debugfs_nr_messages_read(struct file *filp,
> char __user *buffer, size_t
> count,
> loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> char buff[32] = {};
>
> snprintf(buff, sizeof(buff), "%d\n",
> - hw->fwlog.cfg.log_resolution);
> + fwlog->cfg.log_resolution);
>
> return simple_read_from_buffer(buffer, count, ppos, buff,
> strlen(buff)); } @@ -247,9 +244,8 @@ static ssize_t
> ice_debugfs_nr_messages_write(struct file *filp, const char __user
> *buf,
> size_t count, loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct device *dev = ice_pf_to_dev(pf);
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> + struct device *dev = &fwlog->pdev->dev;
> char user_val[8], *cmd_buf;
> s16 nr_messages;
> ssize_t ret;
> @@ -278,7 +274,7 @@ ice_debugfs_nr_messages_write(struct file *filp,
> const char __user *buf,
> return -EINVAL;
> }
>
> - hw->fwlog.cfg.log_resolution = nr_messages;
> + fwlog->cfg.log_resolution = nr_messages;
>
> return count;
> }
> @@ -301,12 +297,11 @@ static ssize_t ice_debugfs_enable_read(struct
> file *filp,
> char __user *buffer, size_t count,
> loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> char buff[32] = {};
>
> snprintf(buff, sizeof(buff), "%u\n",
> - (u16)(hw->fwlog.cfg.options &
> + (u16)(fwlog->cfg.options &
> ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
>
> return simple_read_from_buffer(buffer, count, ppos, buff,
> strlen(buff)); @@ -323,8 +318,7 @@ static ssize_t
> ice_debugfs_enable_write(struct file *filp, const char __user *buf,
> size_t count, loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> char user_val[8], *cmd_buf;
> bool enable;
> ssize_t ret;
> @@ -346,18 +340,18 @@ ice_debugfs_enable_write(struct file *filp,
> const char __user *buf,
> goto enable_write_error;
>
> if (enable)
> - hw->fwlog.cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
> + fwlog->cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
> else
> - hw->fwlog.cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
> + fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
>
> - ret = ice_fwlog_set(&hw->fwlog, &hw->fwlog.cfg);
> + ret = ice_fwlog_set(fwlog, &fwlog->cfg);
> if (ret)
> goto enable_write_error;
>
> if (enable)
> - ret = ice_fwlog_register(&hw->fwlog);
> + ret = ice_fwlog_register(fwlog);
> else
> - ret = ice_fwlog_unregister(&hw->fwlog);
> + ret = ice_fwlog_unregister(fwlog);
>
> if (ret)
> goto enable_write_error;
> @@ -396,12 +390,11 @@ static ssize_t ice_debugfs_log_size_read(struct
> file *filp,
> char __user *buffer, size_t count,
> loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> char buff[32] = {};
> int index;
>
> - index = hw->fwlog.ring.index;
> + index = fwlog->ring.index;
> snprintf(buff, sizeof(buff), "%s\n",
> ice_fwlog_log_size[index]);
>
> return simple_read_from_buffer(buffer, count, ppos, buff,
> strlen(buff)); @@ -418,9 +411,8 @@ static ssize_t
> ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
> size_t count, loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct device *dev = ice_pf_to_dev(pf);
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> + struct device *dev = &fwlog->pdev->dev;
> char user_val[8], *cmd_buf;
> ssize_t ret;
> int index;
> @@ -443,14 +435,14 @@ ice_debugfs_log_size_write(struct file *filp,
> const char __user *buf,
> user_val);
> ret = -EINVAL;
> goto log_size_write_error;
> - } else if (hw->fwlog.cfg.options &
> ICE_FWLOG_OPTION_IS_REGISTERED) {
> + } else if (fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)
> {
> dev_info(dev, "FW logging is currently running. Please
> disable FW logging to change log_size\n");
> ret = -EINVAL;
> goto log_size_write_error;
> }
>
> /* free all the buffers and the tracking info and resize */
> - ice_fwlog_realloc_rings(&hw->fwlog, index);
> + ice_fwlog_realloc_rings(fwlog, index);
>
> /* if we get here, nothing went wrong; return count since we
> didn't
> * really write anything
> @@ -485,19 +477,18 @@ static const struct file_operations
> ice_debugfs_log_size_fops = { static ssize_t
> ice_debugfs_data_read(struct file *filp, char __user *buffer,
> size_t count, loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> int data_copied = 0;
> bool done = false;
>
> - if (ice_fwlog_ring_empty(&hw->fwlog.ring))
> + if (ice_fwlog_ring_empty(&fwlog->ring))
> return 0;
>
> - while (!ice_fwlog_ring_empty(&hw->fwlog.ring) && !done) {
> + while (!ice_fwlog_ring_empty(&fwlog->ring) && !done) {
> struct ice_fwlog_data *log;
> u16 cur_buf_len;
>
> - log = &hw->fwlog.ring.rings[hw->fwlog.ring.head];
> + log = &fwlog->ring.rings[fwlog->ring.head];
> cur_buf_len = log->data_size;
> if (cur_buf_len >= count) {
> done = true;
> @@ -516,8 +507,7 @@ static ssize_t ice_debugfs_data_read(struct file
> *filp, char __user *buffer,
> buffer += cur_buf_len;
> count -= cur_buf_len;
> *ppos += cur_buf_len;
> - ice_fwlog_ring_increment(&hw->fwlog.ring.head,
> - hw->fwlog.ring.size);
> + ice_fwlog_ring_increment(&fwlog->ring.head, fwlog-
> >ring.size);
> }
>
> return data_copied;
> @@ -534,9 +524,8 @@ static ssize_t
> ice_debugfs_data_write(struct file *filp, const char __user *buf,
> size_t count,
> loff_t *ppos)
> {
> - struct ice_pf *pf = filp->private_data;
> - struct device *dev = ice_pf_to_dev(pf);
> - struct ice_hw *hw = &pf->hw;
> + struct ice_fwlog *fwlog = filp->private_data;
> + struct device *dev = &fwlog->pdev->dev;
> ssize_t ret;
>
> /* don't allow partial writes */
> @@ -546,9 +535,9 @@ ice_debugfs_data_write(struct file *filp, const
> char __user *buf, size_t count,
> /* any value is allowed to clear the buffer so no need to even
> look at
> * what the value is
> */
> - if (!(hw->fwlog.cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED))
> {
> - hw->fwlog.ring.head = 0;
> - hw->fwlog.ring.tail = 0;
> + if (!(fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
> + fwlog->ring.head = 0;
> + fwlog->ring.tail = 0;
> } else {
> dev_info(dev, "Can't clear FW log data while FW log
> running\n");
> ret = -EINVAL;
> @@ -580,9 +569,10 @@ static const struct file_operations
> ice_debugfs_data_fops = {
>
> /**
> * ice_debugfs_fwlog_init - setup the debugfs directory
> - * @pf: the ice that is starting up
> + * @fwlog: pointer to the fwlog structure
> + * @root: debugfs root entry on which fwlog director will be
> registered
> */
> -void ice_debugfs_fwlog_init(struct ice_pf *pf)
> +void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry
> +*root)
> {
> struct dentry *fw_modules_dir;
> struct dentry **fw_modules;
> @@ -598,41 +588,39 @@ void ice_debugfs_fwlog_init(struct ice_pf *pf)
>
> pf->ice_debugfs_pf_fwlog = debugfs_create_dir("fwlog",
> pf->ice_debugfs_pf);
> - if (IS_ERR(pf->ice_debugfs_pf_fwlog))
> + if (IS_ERR(fwlog->debugfs))
> goto err_create_module_files;
>
> - fw_modules_dir = debugfs_create_dir("modules",
> - pf->ice_debugfs_pf_fwlog);
> + fw_modules_dir = debugfs_create_dir("modules", fwlog->debugfs);
> if (IS_ERR(fw_modules_dir))
> goto err_create_module_files;
>
> for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
> fw_modules[i] =
> debugfs_create_file(ice_fwlog_module_string[i],
> - 0600, fw_modules_dir, pf,
> + 0600, fw_modules_dir,
> fwlog,
>
> &ice_debugfs_module_fops);
> if (IS_ERR(fw_modules[i]))
> goto err_create_module_files;
> }
>
> - debugfs_create_file("nr_messages", 0600,
> - pf->ice_debugfs_pf_fwlog, pf,
> + debugfs_create_file("nr_messages", 0600, fwlog->debugfs, fwlog,
> &ice_debugfs_nr_messages_fops);
>
> - pf->ice_debugfs_pf_fwlog_modules = fw_modules;
> + fwlog->debugfs_modules = fw_modules;
>
> - debugfs_create_file("enable", 0600, pf->ice_debugfs_pf_fwlog,
> - pf, &ice_debugfs_enable_fops);
> + debugfs_create_file("enable", 0600, fwlog->debugfs, fwlog,
> + &ice_debugfs_enable_fops);
>
> - debugfs_create_file("log_size", 0600, pf->ice_debugfs_pf_fwlog,
> - pf, &ice_debugfs_log_size_fops);
> + debugfs_create_file("log_size", 0600, fwlog->debugfs, fwlog,
> + &ice_debugfs_log_size_fops);
>
> - debugfs_create_file("data", 0600, pf->ice_debugfs_pf_fwlog,
> - pf, &ice_debugfs_data_fops);
> + debugfs_create_file("data", 0600, fwlog->debugfs, fwlog,
> + &ice_debugfs_data_fops);
>
> return;
>
> err_create_module_files:
> - debugfs_remove_recursive(pf->ice_debugfs_pf_fwlog);
> + debugfs_remove_recursive(fwlog->debugfs);
> kfree(fw_modules);
> }
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> index 634e3de3ae66..8a1fede98865 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
> @@ -232,15 +232,13 @@ static void ice_fwlog_set_supported(struct
> ice_fwlog *fwlog)
>
> /**
> * ice_fwlog_init - Initialize FW logging configuration
> - * @hw: pointer to the HW structure
> * @fwlog: pointer to the fwlog structure
> * @api: api structure to init fwlog
> *
> * This function should be called on driver initialization during
> * ice_init_hw().
> */
> -int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
> - struct ice_fwlog_api *api)
> +int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api
> *api)
> {
>
> fwlog->api = *api;
> @@ -273,7 +271,7 @@ int ice_fwlog_init(struct ice_hw *hw, struct
> ice_fwlog *fwlog,
> return status;
> }
>
> - ice_debugfs_fwlog_init(hw->back);
> + ice_debugfs_fwlog_init(fwlog, api->debugfs_root);
> } else {
> dev_warn(&fwlog->pdev->dev, "FW logging is not supported
> in this NVM image. Please update the NVM to get FW log support\n");
> }
> @@ -283,14 +281,12 @@ int ice_fwlog_init(struct ice_hw *hw, struct
> ice_fwlog *fwlog,
>
> /**
> * ice_fwlog_deinit - unroll FW logging configuration
> - * @hw: pointer to the HW structure
> * @fwlog: pointer to the fwlog structure
> *
> * This function should be called in ice_deinit_hw().
> */
> -void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
> +void ice_fwlog_deinit(struct ice_fwlog *fwlog)
> {
> - struct ice_pf *pf = hw->back;
> int status;
>
> /* make sure FW logging is disabled to not put the FW in a
> weird state @@ -302,9 +298,9 @@ void ice_fwlog_deinit(struct ice_hw
> *hw, struct ice_fwlog *fwlog)
> dev_warn(&fwlog->pdev->dev, "Unable to turn off FW
> logging, status: %d\n",
> status);
>
> - kfree(pf->ice_debugfs_pf_fwlog_modules);
> + kfree(fwlog->debugfs_modules);
>
> - pf->ice_debugfs_pf_fwlog_modules = NULL;
> + fwlog->debugfs_modules = NULL;
>
> status = ice_fwlog_unregister(fwlog);
> if (status)
> diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h
> b/drivers/net/ethernet/intel/ice/ice_fwlog.h
> index fe4b2ce6813f..22585ea9ec93 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
> +++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
> @@ -68,18 +68,21 @@ struct ice_fwlog {
> struct ice_fwlog_cfg cfg;
> bool supported; /* does hardware support FW logging? */
> struct ice_fwlog_ring ring;
> + struct dentry *debugfs;
> + /* keep track of all the dentrys for FW log modules */
> + struct dentry **debugfs_modules;
> struct_group_tagged(ice_fwlog_api, api,
> struct pci_dev *pdev;
> int (*send_cmd)(void *, struct libie_aq_desc *, void *,
> u16);
> void *priv;
> + struct dentry *debugfs_root;
> );
> };
>
> bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings); void
> ice_fwlog_ring_increment(u16 *item, u16 size); -int
> ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
> - struct ice_fwlog_api *api);
> -void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
> +int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api
> *api);
> +void ice_fwlog_deinit(struct ice_fwlog *fwlog);
> int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg
> *cfg); int ice_fwlog_register(struct ice_fwlog *fwlog); int
> ice_fwlog_unregister(struct ice_fwlog *fwlog);
> --
> 2.49.0
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 10/15] libie, ice: move fwlog admin queue to libie
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (8 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 09/15] ice: drop driver specific structure from " Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 11/15] ice: move debugfs code to fwlog Michal Swiatkowski
` (5 subsequent siblings)
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Copy the code and:
- change ICE_AQC to LIBIE_AQC
- change ice_aqc to libie_aqc
- move definitions outside the structures
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
.../net/ethernet/intel/ice/ice_adminq_cmd.h | 78 ----------------
drivers/net/ethernet/intel/ice/ice_debugfs.c | 21 ++---
drivers/net/ethernet/intel/ice/ice_fwlog.c | 46 +++++-----
drivers/net/ethernet/intel/ice/ice_fwlog.h | 2 +-
include/linux/net/intel/libie/adminq.h | 89 +++++++++++++++++++
5 files changed, 124 insertions(+), 112 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
index caae1780fd37..93aedb35fd17 100644
--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
@@ -2399,42 +2399,6 @@ 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,
- ICE_AQC_FW_LOG_ID_MDLVER,
- ICE_AQC_FW_LOG_ID_MAX,
-};
-
enum ice_aqc_health_status_mask {
ICE_AQC_HEALTH_STATUS_SET_PF_SPECIFIC_MASK = BIT(0),
ICE_AQC_HEALTH_STATUS_SET_ALL_PF_MASK = BIT(1),
@@ -2516,48 +2480,6 @@ struct ice_aqc_health_status_elem {
__le32 internal_data2;
};
-/* Set FW Logging configuration (indirect 0xFF30)
- * Register for FW Logging (indirect 0xFF31)
- * Query FW Logging (indirect 0xFF32)
- * FW Log Event (indirect 0xFF33)
- */
-struct ice_aqc_fw_log {
- u8 cmd_flags;
-#define ICE_AQC_FW_LOG_CONF_UART_EN BIT(0)
-#define ICE_AQC_FW_LOG_CONF_AQ_EN BIT(1)
-#define ICE_AQC_FW_LOG_QUERY_REGISTERED BIT(2)
-#define ICE_AQC_FW_LOG_CONF_SET_VALID BIT(3)
-#define ICE_AQC_FW_LOG_AQ_REGISTER BIT(0)
-#define ICE_AQC_FW_LOG_AQ_QUERY BIT(2)
-
- u8 rsp_flag;
- __le16 fw_rt_msb;
- union {
- struct {
- __le32 fw_rt_lsb;
- } sync;
- struct {
- __le16 log_resolution;
-#define ICE_AQC_FW_LOG_MIN_RESOLUTION (1)
-#define ICE_AQC_FW_LOG_MAX_RESOLUTION (128)
-
- __le16 mdl_cnt;
- } cfg;
- } ops;
- __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;
-};
-
/* Admin Queue command opcodes */
enum ice_adminq_opc {
/* AQ commands */
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index c0258302d5d5..5d623cea9ef5 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -12,10 +12,11 @@ static struct dentry *ice_debugfs_root;
/* create a define that has an extra module that doesn't really exist. this
* is so we can add a module 'all' to easily enable/disable all the modules
*/
-#define ICE_NR_FW_LOG_MODULES (ICE_AQC_FW_LOG_ID_MAX + 1)
+#define ICE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1)
/* the ordering in this array is important. it matches the ordering of the
- * values in the FW so the index is the same value as in ice_aqc_fw_logging_mod
+ * values in the FW so the index is the same value as in
+ * libie_aqc_fw_logging_mod
*/
static const char * const ice_fwlog_module_string[] = {
"general",
@@ -84,7 +85,7 @@ ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
{
struct ice_fwlog_module_entry *entry;
- if (module != ICE_AQC_FW_LOG_ID_MAX) {
+ if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
entry = &cfg->module_entries[module];
seq_printf(s, "\tModule: %s, Log Level: %s\n",
@@ -93,7 +94,7 @@ ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
} else {
int i;
- for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++) {
+ for (i = 0; i < LIBIE_AQC_FW_LOG_ID_MAX; i++) {
entry = &cfg->module_entries[i];
seq_printf(s, "\tModule: %s, Log Level: %s\n",
@@ -190,7 +191,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
return -EINVAL;
}
- if (module != ICE_AQC_FW_LOG_ID_MAX) {
+ if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
fwlog->cfg.module_entries[module].log_level = log_level;
} else {
/* the module 'all' is a shortcut so that we can set
@@ -198,7 +199,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
*/
int i;
- for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++)
+ for (i = 0; i < LIBIE_AQC_FW_LOG_ID_MAX; i++)
fwlog->cfg.module_entries[i].log_level = log_level;
}
@@ -266,11 +267,11 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
if (ret)
return ret;
- if (nr_messages < ICE_AQC_FW_LOG_MIN_RESOLUTION ||
- nr_messages > ICE_AQC_FW_LOG_MAX_RESOLUTION) {
+ if (nr_messages < LIBIE_AQC_FW_LOG_MIN_RESOLUTION ||
+ nr_messages > LIBIE_AQC_FW_LOG_MAX_RESOLUTION) {
dev_err(dev, "Invalid FW log number of messages %d, value must be between %d - %d\n",
- nr_messages, ICE_AQC_FW_LOG_MIN_RESOLUTION,
- ICE_AQC_FW_LOG_MAX_RESOLUTION);
+ nr_messages, LIBIE_AQC_FW_LOG_MIN_RESOLUTION,
+ LIBIE_AQC_FW_LOG_MAX_RESOLUTION);
return -EINVAL;
}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index 8a1fede98865..0e4d0da86e0a 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -142,8 +142,8 @@ static bool ice_fwlog_supported(struct ice_fwlog *fwlog)
*/
static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
{
- struct ice_aqc_fw_log_cfg_resp *fw_modules;
- struct ice_aqc_fw_log *cmd;
+ struct libie_aqc_fw_log_cfg_resp *fw_modules;
+ struct libie_aqc_fw_log *cmd;
struct libie_aq_desc desc;
u16 module_id_cnt;
int status;
@@ -156,10 +156,10 @@ static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
if (!buf)
return -ENOMEM;
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_fw_logs_query);
+ ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_query);
cmd = libie_aq_raw(&desc);
- cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_QUERY;
+ cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_QUERY;
status = fwlog->send_cmd(fwlog->priv, &desc, buf, ICE_AQ_MAX_BUF_LEN);
if (status) {
@@ -168,26 +168,26 @@ static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
}
module_id_cnt = le16_to_cpu(cmd->ops.cfg.mdl_cnt);
- if (module_id_cnt < ICE_AQC_FW_LOG_ID_MAX) {
+ if (module_id_cnt < LIBIE_AQC_FW_LOG_ID_MAX) {
dev_dbg(&fwlog->pdev->dev, "FW returned less than the expected number of FW log module IDs\n");
- } else if (module_id_cnt > ICE_AQC_FW_LOG_ID_MAX) {
+ } else if (module_id_cnt > LIBIE_AQC_FW_LOG_ID_MAX) {
dev_dbg(&fwlog->pdev->dev, "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;
+ LIBIE_AQC_FW_LOG_ID_MAX);
+ module_id_cnt = LIBIE_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)
+ if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_CONF_AQ_EN)
cfg->options |= ICE_FWLOG_OPTION_ARQ_ENA;
- if (cmd->cmd_flags & ICE_AQC_FW_LOG_CONF_UART_EN)
+ if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_CONF_UART_EN)
cfg->options |= ICE_FWLOG_OPTION_UART_ENA;
- if (cmd->cmd_flags & ICE_AQC_FW_LOG_QUERY_REGISTERED)
+ if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_QUERY_REGISTERED)
cfg->options |= ICE_FWLOG_OPTION_IS_REGISTERED;
- fw_modules = (struct ice_aqc_fw_log_cfg_resp *)buf;
+ fw_modules = (struct libie_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];
+ struct libie_aqc_fw_log_cfg_resp *fw_module = &fw_modules[i];
cfg->module_entries[i].module_id =
le16_to_cpu(fw_module->module_identifier);
@@ -326,8 +326,8 @@ ice_aq_fwlog_set(struct ice_fwlog *fwlog,
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 libie_aqc_fw_log_cfg_resp *fw_modules;
+ struct libie_aqc_fw_log *cmd;
struct libie_aq_desc desc;
int status;
int i;
@@ -342,19 +342,19 @@ ice_aq_fwlog_set(struct ice_fwlog *fwlog,
fw_modules[i].log_level = entries[i].log_level;
}
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_fw_logs_config);
+ ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_config);
desc.flags |= cpu_to_le16(LIBIE_AQ_FLAG_RD);
cmd = libie_aq_raw(&desc);
- cmd->cmd_flags = ICE_AQC_FW_LOG_CONF_SET_VALID;
+ cmd->cmd_flags = LIBIE_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;
+ cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_AQ_EN;
if (options & ICE_FWLOG_OPTION_UART_ENA)
- cmd->cmd_flags |= ICE_AQC_FW_LOG_CONF_UART_EN;
+ cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_UART_EN;
status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules,
sizeof(*fw_modules) * num_entries);
@@ -383,7 +383,7 @@ int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
return -EOPNOTSUPP;
return ice_aq_fwlog_set(fwlog, cfg->module_entries,
- ICE_AQC_FW_LOG_ID_MAX, cfg->options,
+ LIBIE_AQC_FW_LOG_ID_MAX, cfg->options,
cfg->log_resolution);
}
@@ -394,14 +394,14 @@ int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
*/
static int ice_aq_fwlog_register(struct ice_fwlog *fwlog, bool reg)
{
- struct ice_aqc_fw_log *cmd;
+ struct libie_aqc_fw_log *cmd;
struct libie_aq_desc desc;
- ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_fw_logs_register);
+ ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_register);
cmd = libie_aq_raw(&desc);
if (reg)
- cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_REGISTER;
+ cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_REGISTER;
return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0);
}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 22585ea9ec93..9efa4a83c957 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -29,7 +29,7 @@ struct ice_fwlog_module_entry {
struct ice_fwlog_cfg {
/* list of modules for configuring log level */
- struct ice_fwlog_module_entry module_entries[ICE_AQC_FW_LOG_ID_MAX];
+ struct ice_fwlog_module_entry module_entries[LIBIE_AQC_FW_LOG_ID_MAX];
/* options used to configure firmware logging */
u16 options;
#define ICE_FWLOG_OPTION_ARQ_ENA BIT(0)
diff --git a/include/linux/net/intel/libie/adminq.h b/include/linux/net/intel/libie/adminq.h
index 1dd5d5924aee..f7d90e9acfe4 100644
--- a/include/linux/net/intel/libie/adminq.h
+++ b/include/linux/net/intel/libie/adminq.h
@@ -222,6 +222,94 @@ struct libie_aqc_list_caps_elem {
};
LIBIE_CHECK_STRUCT_LEN(32, libie_aqc_list_caps_elem);
+/* Admin Queue command opcodes */
+enum libie_adminq_opc {
+ /* FW Logging Commands */
+ libie_aqc_opc_fw_logs_config = 0xFF30,
+ libie_aqc_opc_fw_logs_register = 0xFF31,
+ libie_aqc_opc_fw_logs_query = 0xFF32,
+ libie_aqc_opc_fw_logs_event = 0xFF33,
+};
+
+enum libie_aqc_fw_logging_mod {
+ LIBIE_AQC_FW_LOG_ID_GENERAL = 0,
+ LIBIE_AQC_FW_LOG_ID_CTRL,
+ LIBIE_AQC_FW_LOG_ID_LINK,
+ LIBIE_AQC_FW_LOG_ID_LINK_TOPO,
+ LIBIE_AQC_FW_LOG_ID_DNL,
+ LIBIE_AQC_FW_LOG_ID_I2C,
+ LIBIE_AQC_FW_LOG_ID_SDP,
+ LIBIE_AQC_FW_LOG_ID_MDIO,
+ LIBIE_AQC_FW_LOG_ID_ADMINQ,
+ LIBIE_AQC_FW_LOG_ID_HDMA,
+ LIBIE_AQC_FW_LOG_ID_LLDP,
+ LIBIE_AQC_FW_LOG_ID_DCBX,
+ LIBIE_AQC_FW_LOG_ID_DCB,
+ LIBIE_AQC_FW_LOG_ID_XLR,
+ LIBIE_AQC_FW_LOG_ID_NVM,
+ LIBIE_AQC_FW_LOG_ID_AUTH,
+ LIBIE_AQC_FW_LOG_ID_VPD,
+ LIBIE_AQC_FW_LOG_ID_IOSF,
+ LIBIE_AQC_FW_LOG_ID_PARSER,
+ LIBIE_AQC_FW_LOG_ID_SW,
+ LIBIE_AQC_FW_LOG_ID_SCHEDULER,
+ LIBIE_AQC_FW_LOG_ID_TXQ,
+ LIBIE_AQC_FW_LOG_ID_RSVD,
+ LIBIE_AQC_FW_LOG_ID_POST,
+ LIBIE_AQC_FW_LOG_ID_WATCHDOG,
+ LIBIE_AQC_FW_LOG_ID_TASK_DISPATCH,
+ LIBIE_AQC_FW_LOG_ID_MNG,
+ LIBIE_AQC_FW_LOG_ID_SYNCE,
+ LIBIE_AQC_FW_LOG_ID_HEALTH,
+ LIBIE_AQC_FW_LOG_ID_TSDRV,
+ LIBIE_AQC_FW_LOG_ID_PFREG,
+ LIBIE_AQC_FW_LOG_ID_MDLVER,
+ LIBIE_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)
+ */
+#define LIBIE_AQC_FW_LOG_CONF_UART_EN BIT(0)
+#define LIBIE_AQC_FW_LOG_CONF_AQ_EN BIT(1)
+#define LIBIE_AQC_FW_LOG_QUERY_REGISTERED BIT(2)
+#define LIBIE_AQC_FW_LOG_CONF_SET_VALID BIT(3)
+#define LIBIE_AQC_FW_LOG_AQ_REGISTER BIT(0)
+#define LIBIE_AQC_FW_LOG_AQ_QUERY BIT(2)
+
+#define LIBIE_AQC_FW_LOG_MIN_RESOLUTION (1)
+#define LIBIE_AQC_FW_LOG_MAX_RESOLUTION (128)
+
+struct libie_aqc_fw_log {
+ u8 cmd_flags;
+
+ u8 rsp_flag;
+ __le16 fw_rt_msb;
+ union {
+ struct {
+ __le32 fw_rt_lsb;
+ } sync;
+ struct {
+ __le16 log_resolution;
+ __le16 mdl_cnt;
+ } cfg;
+ } ops;
+ __le32 addr_high;
+ __le32 addr_low;
+};
+
+/* Response Buffer for:
+ * Set Firmware Logging Configuration (0xFF30)
+ * Query FW Logging (0xFF32)
+ */
+struct libie_aqc_fw_log_cfg_resp {
+ __le16 module_identifier;
+ u8 log_level;
+ u8 rsvd0;
+};
+
/**
* struct libie_aq_desc - Admin Queue (AQ) descriptor
* @flags: LIBIE_AQ_FLAG_* flags
@@ -253,6 +341,7 @@ struct libie_aq_desc {
struct libie_aqc_driver_ver driver_ver;
struct libie_aqc_req_res res_owner;
struct libie_aqc_list_caps get_cap;
+ struct libie_aqc_fw_log fw_log;
} params;
};
LIBIE_CHECK_STRUCT_LEN(32, libie_aq_desc);
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 11/15] ice: move debugfs code to fwlog
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (9 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 10/15] libie, ice: move fwlog admin queue to libie Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 12/15] ice: prepare for moving file to libie Michal Swiatkowski
` (4 subsequent siblings)
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
This code is only used in fwlog. Moved it there for easier lib creation.
There is a circular dependency between debugfs and fwlog. Moving to one
file is fixing it.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice.h | 1 -
drivers/net/ethernet/intel/ice/ice_debugfs.c | 619 ------------------
drivers/net/ethernet/intel/ice/ice_fwlog.c | 652 ++++++++++++++++++-
drivers/net/ethernet/intel/ice/ice_fwlog.h | 3 -
4 files changed, 635 insertions(+), 640 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 9ed4197ee7bc..d35eb6404524 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -905,7 +905,6 @@ static inline bool ice_is_adq_active(struct ice_pf *pf)
return false;
}
-void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root);
int ice_debugfs_pf_init(struct ice_pf *pf);
void ice_debugfs_pf_deinit(struct ice_pf *pf);
void ice_debugfs_init(void);
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index 5d623cea9ef5..f3f6bcb752b3 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -1,630 +1,11 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022, Intel Corporation. */
-#include <linux/fs.h>
#include <linux/debugfs.h>
-#include <linux/random.h>
-#include <linux/vmalloc.h>
#include "ice.h"
static struct dentry *ice_debugfs_root;
-/* create a define that has an extra module that doesn't really exist. this
- * is so we can add a module 'all' to easily enable/disable all the modules
- */
-#define ICE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1)
-
-/* the ordering in this array is important. it matches the ordering of the
- * values in the FW so the index is the same value as in
- * libie_aqc_fw_logging_mod
- */
-static const char * const ice_fwlog_module_string[] = {
- "general",
- "ctrl",
- "link",
- "link_topo",
- "dnl",
- "i2c",
- "sdp",
- "mdio",
- "adminq",
- "hdma",
- "lldp",
- "dcbx",
- "dcb",
- "xlr",
- "nvm",
- "auth",
- "vpd",
- "iosf",
- "parser",
- "sw",
- "scheduler",
- "txq",
- "rsvd",
- "post",
- "watchdog",
- "task_dispatch",
- "mng",
- "synce",
- "health",
- "tsdrv",
- "pfreg",
- "mdlver",
- "all",
-};
-
-/* the ordering in this array is important. it matches the ordering of the
- * values in the FW so the index is the same value as in ice_fwlog_level
- */
-static const char * const ice_fwlog_level_string[] = {
- "none",
- "error",
- "warning",
- "normal",
- "verbose",
-};
-
-static const char * const ice_fwlog_log_size[] = {
- "128K",
- "256K",
- "512K",
- "1M",
- "2M",
-};
-
-/**
- * ice_fwlog_print_module_cfg - print current FW logging module configuration
- * @cfg: pointer to the fwlog cfg structure
- * @module: module to print
- * @s: the seq file to put data into
- */
-static void
-ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
- struct seq_file *s)
-{
- struct ice_fwlog_module_entry *entry;
-
- if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
- entry = &cfg->module_entries[module];
-
- seq_printf(s, "\tModule: %s, Log Level: %s\n",
- ice_fwlog_module_string[entry->module_id],
- ice_fwlog_level_string[entry->log_level]);
- } else {
- int i;
-
- for (i = 0; i < LIBIE_AQC_FW_LOG_ID_MAX; i++) {
- entry = &cfg->module_entries[i];
-
- seq_printf(s, "\tModule: %s, Log Level: %s\n",
- ice_fwlog_module_string[entry->module_id],
- ice_fwlog_level_string[entry->log_level]);
- }
- }
-}
-
-static int ice_find_module_by_dentry(struct dentry **modules, struct dentry *d)
-{
- int i, module;
-
- module = -1;
- /* find the module based on the dentry */
- for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
- if (d == modules[i]) {
- module = i;
- break;
- }
- }
-
- return module;
-}
-
-/**
- * ice_debugfs_module_show - read from 'module' file
- * @s: the opened file
- * @v: pointer to the offset
- */
-static int ice_debugfs_module_show(struct seq_file *s, void *v)
-{
- struct ice_fwlog *fwlog = s->private;
- const struct file *filp = s->file;
- struct dentry *dentry;
- int module;
-
- dentry = file_dentry(filp);
-
- module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
- if (module < 0) {
- dev_info(&fwlog->pdev->dev, "unknown module\n");
- return -EINVAL;
- }
-
- ice_fwlog_print_module_cfg(&fwlog->cfg, module, s);
-
- return 0;
-}
-
-static int ice_debugfs_module_open(struct inode *inode, struct file *filp)
-{
- return single_open(filp, ice_debugfs_module_show, inode->i_private);
-}
-
-/**
- * ice_debugfs_module_write - write into 'module' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
- */
-static ssize_t
-ice_debugfs_module_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct ice_fwlog *fwlog = file_inode(filp)->i_private;
- struct dentry *dentry = file_dentry(filp);
- struct device *dev = &fwlog->pdev->dev;
- char user_val[16], *cmd_buf;
- int module, log_level, cnt;
-
- /* don't allow partial writes or invalid input */
- if (*ppos != 0 || count > 8)
- return -EINVAL;
-
- cmd_buf = memdup_user_nul(buf, count);
- if (IS_ERR(cmd_buf))
- return PTR_ERR(cmd_buf);
-
- module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
- if (module < 0) {
- dev_info(dev, "unknown module\n");
- return -EINVAL;
- }
-
- cnt = sscanf(cmd_buf, "%s", user_val);
- if (cnt != 1)
- return -EINVAL;
-
- log_level = sysfs_match_string(ice_fwlog_level_string, user_val);
- if (log_level < 0) {
- dev_info(dev, "unknown log level '%s'\n", user_val);
- return -EINVAL;
- }
-
- if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
- fwlog->cfg.module_entries[module].log_level = log_level;
- } else {
- /* the module 'all' is a shortcut so that we can set
- * all of the modules to the same level quickly
- */
- int i;
-
- for (i = 0; i < LIBIE_AQC_FW_LOG_ID_MAX; i++)
- fwlog->cfg.module_entries[i].log_level = log_level;
- }
-
- return count;
-}
-
-static const struct file_operations ice_debugfs_module_fops = {
- .owner = THIS_MODULE,
- .open = ice_debugfs_module_open,
- .read = seq_read,
- .release = single_release,
- .write = ice_debugfs_module_write,
-};
-
-/**
- * ice_debugfs_nr_messages_read - read from 'nr_messages' file
- * @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_nr_messages_read(struct file *filp,
- char __user *buffer, size_t count,
- loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- char buff[32] = {};
-
- snprintf(buff, sizeof(buff), "%d\n",
- fwlog->cfg.log_resolution);
-
- return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
-}
-
-/**
- * ice_debugfs_nr_messages_write - write into 'nr_messages' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
- */
-static ssize_t
-ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- struct device *dev = &fwlog->pdev->dev;
- char user_val[8], *cmd_buf;
- s16 nr_messages;
- ssize_t ret;
-
- /* don't allow partial writes or invalid input */
- if (*ppos != 0 || count > 4)
- return -EINVAL;
-
- cmd_buf = memdup_user_nul(buf, count);
- if (IS_ERR(cmd_buf))
- return PTR_ERR(cmd_buf);
-
- ret = sscanf(cmd_buf, "%s", user_val);
- if (ret != 1)
- return -EINVAL;
-
- ret = kstrtos16(user_val, 0, &nr_messages);
- if (ret)
- return ret;
-
- if (nr_messages < LIBIE_AQC_FW_LOG_MIN_RESOLUTION ||
- nr_messages > LIBIE_AQC_FW_LOG_MAX_RESOLUTION) {
- dev_err(dev, "Invalid FW log number of messages %d, value must be between %d - %d\n",
- nr_messages, LIBIE_AQC_FW_LOG_MIN_RESOLUTION,
- LIBIE_AQC_FW_LOG_MAX_RESOLUTION);
- return -EINVAL;
- }
-
- fwlog->cfg.log_resolution = nr_messages;
-
- return count;
-}
-
-static const struct file_operations ice_debugfs_nr_messages_fops = {
- .owner = THIS_MODULE,
- .open = simple_open,
- .read = ice_debugfs_nr_messages_read,
- .write = ice_debugfs_nr_messages_write,
-};
-
-/**
- * ice_debugfs_enable_read - read from 'enable' file
- * @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_enable_read(struct file *filp,
- char __user *buffer, size_t count,
- loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- char buff[32] = {};
-
- snprintf(buff, sizeof(buff), "%u\n",
- (u16)(fwlog->cfg.options &
- ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
-
- return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
-}
-
-/**
- * ice_debugfs_enable_write - write into 'enable' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
- */
-static ssize_t
-ice_debugfs_enable_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- char user_val[8], *cmd_buf;
- bool enable;
- ssize_t ret;
-
- /* don't allow partial writes or invalid input */
- if (*ppos != 0 || count > 2)
- return -EINVAL;
-
- cmd_buf = memdup_user_nul(buf, count);
- if (IS_ERR(cmd_buf))
- return PTR_ERR(cmd_buf);
-
- ret = sscanf(cmd_buf, "%s", user_val);
- if (ret != 1)
- return -EINVAL;
-
- ret = kstrtobool(user_val, &enable);
- if (ret)
- goto enable_write_error;
-
- if (enable)
- fwlog->cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
- else
- fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
-
- ret = ice_fwlog_set(fwlog, &fwlog->cfg);
- if (ret)
- goto enable_write_error;
-
- if (enable)
- ret = ice_fwlog_register(fwlog);
- else
- ret = ice_fwlog_unregister(fwlog);
-
- if (ret)
- goto enable_write_error;
-
- /* if we get here, nothing went wrong; return count since we didn't
- * really write anything
- */
- ret = (ssize_t)count;
-
-enable_write_error:
- /* This function always consumes all of the written input, or produces
- * an error. Check and enforce this. Otherwise, the write operation
- * won't complete properly.
- */
- if (WARN_ON(ret != (ssize_t)count && ret >= 0))
- ret = -EIO;
-
- return ret;
-}
-
-static const struct file_operations ice_debugfs_enable_fops = {
- .owner = THIS_MODULE,
- .open = simple_open,
- .read = ice_debugfs_enable_read,
- .write = ice_debugfs_enable_write,
-};
-
-/**
- * ice_debugfs_log_size_read - read from 'log_size' file
- * @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_log_size_read(struct file *filp,
- char __user *buffer, size_t count,
- loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- char buff[32] = {};
- int index;
-
- index = fwlog->ring.index;
- snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]);
-
- return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
-}
-
-/**
- * ice_debugfs_log_size_write - write into 'log_size' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
- */
-static ssize_t
-ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- struct device *dev = &fwlog->pdev->dev;
- char user_val[8], *cmd_buf;
- ssize_t ret;
- int index;
-
- /* don't allow partial writes or invalid input */
- if (*ppos != 0 || count > 5)
- return -EINVAL;
-
- cmd_buf = memdup_user_nul(buf, count);
- if (IS_ERR(cmd_buf))
- return PTR_ERR(cmd_buf);
-
- ret = sscanf(cmd_buf, "%s", user_val);
- if (ret != 1)
- return -EINVAL;
-
- index = sysfs_match_string(ice_fwlog_log_size, user_val);
- if (index < 0) {
- dev_info(dev, "Invalid log size '%s'. The value must be one of 128K, 256K, 512K, 1M, 2M\n",
- user_val);
- ret = -EINVAL;
- goto log_size_write_error;
- } else if (fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
- dev_info(dev, "FW logging is currently running. Please disable FW logging to change log_size\n");
- ret = -EINVAL;
- goto log_size_write_error;
- }
-
- /* free all the buffers and the tracking info and resize */
- ice_fwlog_realloc_rings(fwlog, index);
-
- /* if we get here, nothing went wrong; return count since we didn't
- * really write anything
- */
- ret = (ssize_t)count;
-
-log_size_write_error:
- /* This function always consumes all of the written input, or produces
- * an error. Check and enforce this. Otherwise, the write operation
- * won't complete properly.
- */
- if (WARN_ON(ret != (ssize_t)count && ret >= 0))
- ret = -EIO;
-
- return ret;
-}
-
-static const struct file_operations ice_debugfs_log_size_fops = {
- .owner = THIS_MODULE,
- .open = simple_open,
- .read = ice_debugfs_log_size_read,
- .write = ice_debugfs_log_size_write,
-};
-
-/**
- * ice_debugfs_data_read - read from 'data' file
- * @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_data_read(struct file *filp, char __user *buffer,
- size_t count, loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- int data_copied = 0;
- bool done = false;
-
- if (ice_fwlog_ring_empty(&fwlog->ring))
- return 0;
-
- while (!ice_fwlog_ring_empty(&fwlog->ring) && !done) {
- struct ice_fwlog_data *log;
- u16 cur_buf_len;
-
- log = &fwlog->ring.rings[fwlog->ring.head];
- cur_buf_len = log->data_size;
- if (cur_buf_len >= count) {
- done = true;
- continue;
- }
-
- if (copy_to_user(buffer, log->data, cur_buf_len)) {
- /* if there is an error then bail and return whatever
- * the driver has copied so far
- */
- done = true;
- continue;
- }
-
- data_copied += cur_buf_len;
- buffer += cur_buf_len;
- count -= cur_buf_len;
- *ppos += cur_buf_len;
- ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
- }
-
- return data_copied;
-}
-
-/**
- * ice_debugfs_data_write - write into 'data' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
- */
-static ssize_t
-ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
- loff_t *ppos)
-{
- struct ice_fwlog *fwlog = filp->private_data;
- struct device *dev = &fwlog->pdev->dev;
- ssize_t ret;
-
- /* don't allow partial writes */
- if (*ppos != 0)
- return 0;
-
- /* any value is allowed to clear the buffer so no need to even look at
- * what the value is
- */
- if (!(fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
- fwlog->ring.head = 0;
- fwlog->ring.tail = 0;
- } else {
- dev_info(dev, "Can't clear FW log data while FW log running\n");
- ret = -EINVAL;
- goto nr_buffs_write_error;
- }
-
- /* if we get here, nothing went wrong; return count since we didn't
- * really write anything
- */
- ret = (ssize_t)count;
-
-nr_buffs_write_error:
- /* This function always consumes all of the written input, or produces
- * an error. Check and enforce this. Otherwise, the write operation
- * won't complete properly.
- */
- if (WARN_ON(ret != (ssize_t)count && ret >= 0))
- ret = -EIO;
-
- return ret;
-}
-
-static const struct file_operations ice_debugfs_data_fops = {
- .owner = THIS_MODULE,
- .open = simple_open,
- .read = ice_debugfs_data_read,
- .write = ice_debugfs_data_write,
-};
-
-/**
- * ice_debugfs_fwlog_init - setup the debugfs directory
- * @fwlog: pointer to the fwlog structure
- * @root: debugfs root entry on which fwlog director will be registered
- */
-void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
-{
- struct dentry *fw_modules_dir;
- struct dentry **fw_modules;
- int i;
-
- /* allocate space for this first because if it fails then we don't
- * need to unwind
- */
- fw_modules = kcalloc(ICE_NR_FW_LOG_MODULES, sizeof(*fw_modules),
- GFP_KERNEL);
- if (!fw_modules)
- return;
-
- pf->ice_debugfs_pf_fwlog = debugfs_create_dir("fwlog",
- pf->ice_debugfs_pf);
- if (IS_ERR(fwlog->debugfs))
- goto err_create_module_files;
-
- fw_modules_dir = debugfs_create_dir("modules", fwlog->debugfs);
- if (IS_ERR(fw_modules_dir))
- goto err_create_module_files;
-
- for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
- fw_modules[i] = debugfs_create_file(ice_fwlog_module_string[i],
- 0600, fw_modules_dir, fwlog,
- &ice_debugfs_module_fops);
- if (IS_ERR(fw_modules[i]))
- goto err_create_module_files;
- }
-
- debugfs_create_file("nr_messages", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_nr_messages_fops);
-
- fwlog->debugfs_modules = fw_modules;
-
- debugfs_create_file("enable", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_enable_fops);
-
- debugfs_create_file("log_size", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_log_size_fops);
-
- debugfs_create_file("data", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_data_fops);
-
- return;
-
-err_create_module_files:
- debugfs_remove_recursive(fwlog->debugfs);
- kfree(fw_modules);
-}
-
/**
* ice_debugfs_pf_init - create PF's debugfs
* @pf: pointer to the PF struct
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index 0e4d0da86e0a..aaf6e20f934f 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -1,32 +1,84 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022, Intel Corporation. */
+#include <linux/debugfs.h>
+#include <linux/fs.h>
+#include <linux/random.h>
#include <linux/vmalloc.h>
#include "ice.h"
#include "ice_common.h"
#include "ice_fwlog.h"
-static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
-{
- u16 head, tail;
-
- head = rings->head;
- tail = rings->tail;
-
- if (head < tail && (tail - head == (rings->size - 1)))
- return true;
- else if (head > tail && (tail == (head - 1)))
- return true;
-
- return false;
-}
+/* create a define that has an extra module that doesn't really exist. this
+ * is so we can add a module 'all' to easily enable/disable all the modules
+ */
+#define ICE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1)
-bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings)
+/* the ordering in this array is important. it matches the ordering of the
+ * values in the FW so the index is the same value as in
+ * libie_aqc_fw_logging_mod
+ */
+static const char * const ice_fwlog_module_string[] = {
+ "general",
+ "ctrl",
+ "link",
+ "link_topo",
+ "dnl",
+ "i2c",
+ "sdp",
+ "mdio",
+ "adminq",
+ "hdma",
+ "lldp",
+ "dcbx",
+ "dcb",
+ "xlr",
+ "nvm",
+ "auth",
+ "vpd",
+ "iosf",
+ "parser",
+ "sw",
+ "scheduler",
+ "txq",
+ "rsvd",
+ "post",
+ "watchdog",
+ "task_dispatch",
+ "mng",
+ "synce",
+ "health",
+ "tsdrv",
+ "pfreg",
+ "mdlver",
+ "all",
+};
+
+/* the ordering in this array is important. it matches the ordering of the
+ * values in the FW so the index is the same value as in ice_fwlog_level
+ */
+static const char * const ice_fwlog_level_string[] = {
+ "none",
+ "error",
+ "warning",
+ "normal",
+ "verbose",
+};
+
+static const char * const ice_fwlog_log_size[] = {
+ "128K",
+ "256K",
+ "512K",
+ "1M",
+ "2M",
+};
+
+static bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings)
{
return rings->head == rings->tail;
}
-void ice_fwlog_ring_increment(u16 *item, u16 size)
+static void ice_fwlog_ring_increment(u16 *item, u16 size)
{
*item = (*item + 1) & (size - 1);
}
@@ -77,7 +129,7 @@ static void ice_fwlog_free_ring_buffs(struct ice_fwlog_ring *rings)
* @index: the new index to use to allocate memory for the log data
*
*/
-void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
+static void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
{
struct ice_fwlog_ring ring;
int status, ring_size;
@@ -123,6 +175,572 @@ void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
fwlog->ring.tail = 0;
}
+/**
+ * ice_fwlog_print_module_cfg - print current FW logging module configuration
+ * @cfg: pointer to the fwlog cfg structure
+ * @module: module to print
+ * @s: the seq file to put data into
+ */
+static void
+ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
+ struct seq_file *s)
+{
+ struct ice_fwlog_module_entry *entry;
+
+ if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
+ entry = &cfg->module_entries[module];
+
+ seq_printf(s, "\tModule: %s, Log Level: %s\n",
+ ice_fwlog_module_string[entry->module_id],
+ ice_fwlog_level_string[entry->log_level]);
+ } else {
+ int i;
+
+ for (i = 0; i < LIBIE_AQC_FW_LOG_ID_MAX; i++) {
+ entry = &cfg->module_entries[i];
+
+ seq_printf(s, "\tModule: %s, Log Level: %s\n",
+ ice_fwlog_module_string[entry->module_id],
+ ice_fwlog_level_string[entry->log_level]);
+ }
+ }
+}
+
+static int ice_find_module_by_dentry(struct dentry **modules, struct dentry *d)
+{
+ int i, module;
+
+ module = -1;
+ /* find the module based on the dentry */
+ for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
+ if (d == modules[i]) {
+ module = i;
+ break;
+ }
+ }
+
+ return module;
+}
+
+/**
+ * ice_debugfs_module_show - read from 'module' file
+ * @s: the opened file
+ * @v: pointer to the offset
+ */
+static int ice_debugfs_module_show(struct seq_file *s, void *v)
+{
+ struct ice_fwlog *fwlog = s->private;
+ const struct file *filp = s->file;
+ struct dentry *dentry;
+ int module;
+
+ dentry = file_dentry(filp);
+
+ module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
+ if (module < 0) {
+ dev_info(&fwlog->pdev->dev, "unknown module\n");
+ return -EINVAL;
+ }
+
+ ice_fwlog_print_module_cfg(&fwlog->cfg, module, s);
+
+ return 0;
+}
+
+static int ice_debugfs_module_open(struct inode *inode, struct file *filp)
+{
+ return single_open(filp, ice_debugfs_module_show, inode->i_private);
+}
+
+/**
+ * ice_debugfs_module_write - write into 'module' file
+ * @filp: the opened file
+ * @buf: where to find the user's data
+ * @count: the length of the user's data
+ * @ppos: file position offset
+ */
+static ssize_t
+ice_debugfs_module_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = file_inode(filp)->i_private;
+ struct dentry *dentry = file_dentry(filp);
+ struct device *dev = &fwlog->pdev->dev;
+ char user_val[16], *cmd_buf;
+ int module, log_level, cnt;
+
+ /* don't allow partial writes or invalid input */
+ if (*ppos != 0 || count > 8)
+ return -EINVAL;
+
+ cmd_buf = memdup_user_nul(buf, count);
+ if (IS_ERR(cmd_buf))
+ return PTR_ERR(cmd_buf);
+
+ module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
+ if (module < 0) {
+ dev_info(dev, "unknown module\n");
+ return -EINVAL;
+ }
+
+ cnt = sscanf(cmd_buf, "%s", user_val);
+ if (cnt != 1)
+ return -EINVAL;
+
+ log_level = sysfs_match_string(ice_fwlog_level_string, user_val);
+ if (log_level < 0) {
+ dev_info(dev, "unknown log level '%s'\n", user_val);
+ return -EINVAL;
+ }
+
+ if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
+ fwlog->cfg.module_entries[module].log_level = log_level;
+ } else {
+ /* the module 'all' is a shortcut so that we can set
+ * all of the modules to the same level quickly
+ */
+ int i;
+
+ for (i = 0; i < LIBIE_AQC_FW_LOG_ID_MAX; i++)
+ fwlog->cfg.module_entries[i].log_level = log_level;
+ }
+
+ return count;
+}
+
+static const struct file_operations ice_debugfs_module_fops = {
+ .owner = THIS_MODULE,
+ .open = ice_debugfs_module_open,
+ .read = seq_read,
+ .release = single_release,
+ .write = ice_debugfs_module_write,
+};
+
+/**
+ * ice_debugfs_nr_messages_read - read from 'nr_messages' file
+ * @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_nr_messages_read(struct file *filp,
+ char __user *buffer, size_t count,
+ loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ char buff[32] = {};
+
+ snprintf(buff, sizeof(buff), "%d\n",
+ fwlog->cfg.log_resolution);
+
+ return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
+}
+
+/**
+ * ice_debugfs_nr_messages_write - write into 'nr_messages' file
+ * @filp: the opened file
+ * @buf: where to find the user's data
+ * @count: the length of the user's data
+ * @ppos: file position offset
+ */
+static ssize_t
+ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ struct device *dev = &fwlog->pdev->dev;
+ char user_val[8], *cmd_buf;
+ s16 nr_messages;
+ ssize_t ret;
+
+ /* don't allow partial writes or invalid input */
+ if (*ppos != 0 || count > 4)
+ return -EINVAL;
+
+ cmd_buf = memdup_user_nul(buf, count);
+ if (IS_ERR(cmd_buf))
+ return PTR_ERR(cmd_buf);
+
+ ret = sscanf(cmd_buf, "%s", user_val);
+ if (ret != 1)
+ return -EINVAL;
+
+ ret = kstrtos16(user_val, 0, &nr_messages);
+ if (ret)
+ return ret;
+
+ if (nr_messages < LIBIE_AQC_FW_LOG_MIN_RESOLUTION ||
+ nr_messages > LIBIE_AQC_FW_LOG_MAX_RESOLUTION) {
+ dev_err(dev, "Invalid FW log number of messages %d, value must be between %d - %d\n",
+ nr_messages, LIBIE_AQC_FW_LOG_MIN_RESOLUTION,
+ LIBIE_AQC_FW_LOG_MAX_RESOLUTION);
+ return -EINVAL;
+ }
+
+ fwlog->cfg.log_resolution = nr_messages;
+
+ return count;
+}
+
+static const struct file_operations ice_debugfs_nr_messages_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = ice_debugfs_nr_messages_read,
+ .write = ice_debugfs_nr_messages_write,
+};
+
+/**
+ * ice_debugfs_enable_read - read from 'enable' file
+ * @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_enable_read(struct file *filp,
+ char __user *buffer, size_t count,
+ loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ char buff[32] = {};
+
+ snprintf(buff, sizeof(buff), "%u\n",
+ (u16)(fwlog->cfg.options &
+ ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
+
+ return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
+}
+
+/**
+ * ice_debugfs_enable_write - write into 'enable' file
+ * @filp: the opened file
+ * @buf: where to find the user's data
+ * @count: the length of the user's data
+ * @ppos: file position offset
+ */
+static ssize_t
+ice_debugfs_enable_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ char user_val[8], *cmd_buf;
+ bool enable;
+ ssize_t ret;
+
+ /* don't allow partial writes or invalid input */
+ if (*ppos != 0 || count > 2)
+ return -EINVAL;
+
+ cmd_buf = memdup_user_nul(buf, count);
+ if (IS_ERR(cmd_buf))
+ return PTR_ERR(cmd_buf);
+
+ ret = sscanf(cmd_buf, "%s", user_val);
+ if (ret != 1)
+ return -EINVAL;
+
+ ret = kstrtobool(user_val, &enable);
+ if (ret)
+ goto enable_write_error;
+
+ if (enable)
+ fwlog->cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
+ else
+ fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
+
+ ret = ice_fwlog_set(fwlog, &fwlog->cfg);
+ if (ret)
+ goto enable_write_error;
+
+ if (enable)
+ ret = ice_fwlog_register(fwlog);
+ else
+ ret = ice_fwlog_unregister(fwlog);
+
+ if (ret)
+ goto enable_write_error;
+
+ /* if we get here, nothing went wrong; return count since we didn't
+ * really write anything
+ */
+ ret = (ssize_t)count;
+
+enable_write_error:
+ /* This function always consumes all of the written input, or produces
+ * an error. Check and enforce this. Otherwise, the write operation
+ * won't complete properly.
+ */
+ if (WARN_ON(ret != (ssize_t)count && ret >= 0))
+ ret = -EIO;
+
+ return ret;
+}
+
+static const struct file_operations ice_debugfs_enable_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = ice_debugfs_enable_read,
+ .write = ice_debugfs_enable_write,
+};
+
+/**
+ * ice_debugfs_log_size_read - read from 'log_size' file
+ * @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_log_size_read(struct file *filp,
+ char __user *buffer, size_t count,
+ loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ char buff[32] = {};
+ int index;
+
+ index = fwlog->ring.index;
+ snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]);
+
+ return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
+}
+
+/**
+ * ice_debugfs_log_size_write - write into 'log_size' file
+ * @filp: the opened file
+ * @buf: where to find the user's data
+ * @count: the length of the user's data
+ * @ppos: file position offset
+ */
+static ssize_t
+ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ struct device *dev = &fwlog->pdev->dev;
+ char user_val[8], *cmd_buf;
+ ssize_t ret;
+ int index;
+
+ /* don't allow partial writes or invalid input */
+ if (*ppos != 0 || count > 5)
+ return -EINVAL;
+
+ cmd_buf = memdup_user_nul(buf, count);
+ if (IS_ERR(cmd_buf))
+ return PTR_ERR(cmd_buf);
+
+ ret = sscanf(cmd_buf, "%s", user_val);
+ if (ret != 1)
+ return -EINVAL;
+
+ index = sysfs_match_string(ice_fwlog_log_size, user_val);
+ if (index < 0) {
+ dev_info(dev, "Invalid log size '%s'. The value must be one of 128K, 256K, 512K, 1M, 2M\n",
+ user_val);
+ ret = -EINVAL;
+ goto log_size_write_error;
+ } else if (fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
+ dev_info(dev, "FW logging is currently running. Please disable FW logging to change log_size\n");
+ ret = -EINVAL;
+ goto log_size_write_error;
+ }
+
+ /* free all the buffers and the tracking info and resize */
+ ice_fwlog_realloc_rings(fwlog, index);
+
+ /* if we get here, nothing went wrong; return count since we didn't
+ * really write anything
+ */
+ ret = (ssize_t)count;
+
+log_size_write_error:
+ /* This function always consumes all of the written input, or produces
+ * an error. Check and enforce this. Otherwise, the write operation
+ * won't complete properly.
+ */
+ if (WARN_ON(ret != (ssize_t)count && ret >= 0))
+ ret = -EIO;
+
+ return ret;
+}
+
+static const struct file_operations ice_debugfs_log_size_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = ice_debugfs_log_size_read,
+ .write = ice_debugfs_log_size_write,
+};
+
+/**
+ * ice_debugfs_data_read - read from 'data' file
+ * @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_data_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ int data_copied = 0;
+ bool done = false;
+
+ if (ice_fwlog_ring_empty(&fwlog->ring))
+ return 0;
+
+ while (!ice_fwlog_ring_empty(&fwlog->ring) && !done) {
+ struct ice_fwlog_data *log;
+ u16 cur_buf_len;
+
+ log = &fwlog->ring.rings[fwlog->ring.head];
+ cur_buf_len = log->data_size;
+ if (cur_buf_len >= count) {
+ done = true;
+ continue;
+ }
+
+ if (copy_to_user(buffer, log->data, cur_buf_len)) {
+ /* if there is an error then bail and return whatever
+ * the driver has copied so far
+ */
+ done = true;
+ continue;
+ }
+
+ data_copied += cur_buf_len;
+ buffer += cur_buf_len;
+ count -= cur_buf_len;
+ *ppos += cur_buf_len;
+ ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
+ }
+
+ return data_copied;
+}
+
+/**
+ * ice_debugfs_data_write - write into 'data' file
+ * @filp: the opened file
+ * @buf: where to find the user's data
+ * @count: the length of the user's data
+ * @ppos: file position offset
+ */
+static ssize_t
+ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
+ loff_t *ppos)
+{
+ struct ice_fwlog *fwlog = filp->private_data;
+ struct device *dev = &fwlog->pdev->dev;
+ ssize_t ret;
+
+ /* don't allow partial writes */
+ if (*ppos != 0)
+ return 0;
+
+ /* any value is allowed to clear the buffer so no need to even look at
+ * what the value is
+ */
+ if (!(fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
+ fwlog->ring.head = 0;
+ fwlog->ring.tail = 0;
+ } else {
+ dev_info(dev, "Can't clear FW log data while FW log running\n");
+ ret = -EINVAL;
+ goto nr_buffs_write_error;
+ }
+
+ /* if we get here, nothing went wrong; return count since we didn't
+ * really write anything
+ */
+ ret = (ssize_t)count;
+
+nr_buffs_write_error:
+ /* This function always consumes all of the written input, or produces
+ * an error. Check and enforce this. Otherwise, the write operation
+ * won't complete properly.
+ */
+ if (WARN_ON(ret != (ssize_t)count && ret >= 0))
+ ret = -EIO;
+
+ return ret;
+}
+
+static const struct file_operations ice_debugfs_data_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = ice_debugfs_data_read,
+ .write = ice_debugfs_data_write,
+};
+
+/**
+ * ice_debugfs_fwlog_init - setup the debugfs directory
+ * @fwlog: pointer to the fwlog structure
+ * @root: debugfs root entry on which fwlog director will be registered
+ */
+static void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
+{
+ struct dentry *fw_modules_dir;
+ struct dentry **fw_modules;
+ int i;
+
+ /* allocate space for this first because if it fails then we don't
+ * need to unwind
+ */
+ fw_modules = kcalloc(ICE_NR_FW_LOG_MODULES, sizeof(*fw_modules),
+ GFP_KERNEL);
+ if (!fw_modules)
+ return;
+
+ fwlog->debugfs = debugfs_create_dir("fwlog", root);
+ if (IS_ERR(fwlog->debugfs))
+ goto err_create_module_files;
+
+ fw_modules_dir = debugfs_create_dir("modules", fwlog->debugfs);
+ if (IS_ERR(fw_modules_dir))
+ goto err_create_module_files;
+
+ for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
+ fw_modules[i] = debugfs_create_file(ice_fwlog_module_string[i],
+ 0600, fw_modules_dir, fwlog,
+ &ice_debugfs_module_fops);
+ if (IS_ERR(fw_modules[i]))
+ goto err_create_module_files;
+ }
+
+ debugfs_create_file("nr_messages", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_nr_messages_fops);
+
+ fwlog->debugfs_modules = fw_modules;
+
+ debugfs_create_file("enable", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_enable_fops);
+
+ debugfs_create_file("log_size", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_log_size_fops);
+
+ debugfs_create_file("data", 0600, fwlog->debugfs, fwlog,
+ &ice_debugfs_data_fops);
+
+ return;
+
+err_create_module_files:
+ debugfs_remove_recursive(fwlog->debugfs);
+ kfree(fw_modules);
+}
+
+static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
+{
+ u16 head, tail;
+
+ head = rings->head;
+ tail = rings->tail;
+
+ if (head < tail && (tail - head == (rings->size - 1)))
+ return true;
+ else if (head > tail && (tail == (head - 1)))
+ return true;
+
+ return false;
+}
+
/**
* ice_fwlog_supported - Cached for whether FW supports FW logging or not
* @fwlog: pointer to the fwlog structure
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 9efa4a83c957..d5868b9e4de6 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -79,13 +79,10 @@ struct ice_fwlog {
);
};
-bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
-void ice_fwlog_ring_increment(u16 *item, u16 size);
int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api);
void ice_fwlog_deinit(struct ice_fwlog *fwlog);
int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg);
int ice_fwlog_register(struct ice_fwlog *fwlog);
int ice_fwlog_unregister(struct ice_fwlog *fwlog);
-void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index);
void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
#endif /* _ICE_FWLOG_H_ */
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 12/15] ice: prepare for moving file to libie
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (10 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 11/15] ice: move debugfs code to fwlog Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 13/15] ice: reregister fwlog after driver reinit Michal Swiatkowski
` (3 subsequent siblings)
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
s/ice/libie
There is no function for filling default descriptor in libie. Zero
descriptor structure and set opcode without calling the function.
Make functions that are caled only in ice_fwlog.c static.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 6 +-
drivers/net/ethernet/intel/ice/ice_fwlog.c | 624 ++++++++++----------
drivers/net/ethernet/intel/ice/ice_fwlog.h | 78 ++-
drivers/net/ethernet/intel/ice/ice_main.c | 4 +-
drivers/net/ethernet/intel/ice/ice_type.h | 2 +-
include/linux/net/intel/libie/adminq.h | 1 +
6 files changed, 359 insertions(+), 356 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 5a365f65c0e3..30675cd6b08b 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -995,7 +995,7 @@ static int __fwlog_send_cmd(void *priv, struct libie_aq_desc *desc, void *buf,
static int __fwlog_init(struct ice_hw *hw)
{
struct ice_pf *pf = hw->back;
- struct ice_fwlog_api api = {
+ struct libie_fwlog_api api = {
.pdev = pf->pdev,
.send_cmd = __fwlog_send_cmd,
.priv = hw,
@@ -1012,7 +1012,7 @@ static int __fwlog_init(struct ice_hw *hw)
api.debugfs_root = pf->ice_debugfs_pf;
- return ice_fwlog_init(&hw->fwlog, &api);
+ return libie_fwlog_init(&hw->fwlog, &api);
}
/**
@@ -1197,7 +1197,7 @@ static void __fwlog_deinit(struct ice_hw *hw)
return;
ice_debugfs_pf_deinit(hw->back);
- ice_fwlog_deinit(&hw->fwlog);
+ libie_fwlog_deinit(&hw->fwlog);
}
/**
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index aaf6e20f934f..775581163e04 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -12,13 +12,13 @@
/* create a define that has an extra module that doesn't really exist. this
* is so we can add a module 'all' to easily enable/disable all the modules
*/
-#define ICE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1)
+#define LIBIE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1)
/* the ordering in this array is important. it matches the ordering of the
* values in the FW so the index is the same value as in
* libie_aqc_fw_logging_mod
*/
-static const char * const ice_fwlog_module_string[] = {
+static const char * const libie_fwlog_module_string[] = {
"general",
"ctrl",
"link",
@@ -55,9 +55,9 @@ static const char * const ice_fwlog_module_string[] = {
};
/* the ordering in this array is important. it matches the ordering of the
- * values in the FW so the index is the same value as in ice_fwlog_level
+ * values in the FW so the index is the same value as in libie_fwlog_level
*/
-static const char * const ice_fwlog_level_string[] = {
+static const char * const libie_fwlog_level_string[] = {
"none",
"error",
"warning",
@@ -65,7 +65,7 @@ static const char * const ice_fwlog_level_string[] = {
"verbose",
};
-static const char * const ice_fwlog_log_size[] = {
+static const char * const libie_fwlog_log_size[] = {
"128K",
"256K",
"512K",
@@ -73,43 +73,43 @@ static const char * const ice_fwlog_log_size[] = {
"2M",
};
-static bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings)
+static bool libie_fwlog_ring_empty(struct libie_fwlog_ring *rings)
{
return rings->head == rings->tail;
}
-static void ice_fwlog_ring_increment(u16 *item, u16 size)
+static void libie_fwlog_ring_increment(u16 *item, u16 size)
{
*item = (*item + 1) & (size - 1);
}
-static int ice_fwlog_alloc_ring_buffs(struct ice_fwlog_ring *rings)
+static int libie_fwlog_alloc_ring_buffs(struct libie_fwlog_ring *rings)
{
int i, nr_bytes;
u8 *mem;
- nr_bytes = rings->size * ICE_AQ_MAX_BUF_LEN;
+ nr_bytes = rings->size * LIBIE_AQ_MAX_BUF_LEN;
mem = vzalloc(nr_bytes);
if (!mem)
return -ENOMEM;
for (i = 0; i < rings->size; i++) {
- struct ice_fwlog_data *ring = &rings->rings[i];
+ struct libie_fwlog_data *ring = &rings->rings[i];
- ring->data_size = ICE_AQ_MAX_BUF_LEN;
+ ring->data_size = LIBIE_AQ_MAX_BUF_LEN;
ring->data = mem;
- mem += ICE_AQ_MAX_BUF_LEN;
+ mem += LIBIE_AQ_MAX_BUF_LEN;
}
return 0;
}
-static void ice_fwlog_free_ring_buffs(struct ice_fwlog_ring *rings)
+static void libie_fwlog_free_ring_buffs(struct libie_fwlog_ring *rings)
{
int i;
for (i = 0; i < rings->size; i++) {
- struct ice_fwlog_data *ring = &rings->rings[i];
+ struct libie_fwlog_data *ring = &rings->rings[i];
/* the first ring is the base memory for the whole range so
* free it
@@ -122,16 +122,16 @@ static void ice_fwlog_free_ring_buffs(struct ice_fwlog_ring *rings)
}
}
-#define ICE_FWLOG_INDEX_TO_BYTES(n) ((128 * 1024) << (n))
+#define LIBIE_FWLOG_INDEX_TO_BYTES(n) ((128 * 1024) << (n))
/**
- * ice_fwlog_realloc_rings - reallocate the FW log rings
+ * libie_fwlog_realloc_rings - reallocate the FW log rings
* @fwlog: pointer to the fwlog structure
* @index: the new index to use to allocate memory for the log data
*
*/
-static void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
+static void libie_fwlog_realloc_rings(struct libie_fwlog *fwlog, int index)
{
- struct ice_fwlog_ring ring;
+ struct libie_fwlog_ring ring;
int status, ring_size;
/* convert the number of bytes into a number of 4K buffers. externally
@@ -143,7 +143,7 @@ static void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
* the user the driver knows that the data is correct and the FW log
* can be correctly parsed by the tools
*/
- ring_size = ICE_FWLOG_INDEX_TO_BYTES(index) / ICE_AQ_MAX_BUF_LEN;
+ ring_size = LIBIE_FWLOG_INDEX_TO_BYTES(index) / LIBIE_AQ_MAX_BUF_LEN;
if (ring_size == fwlog->ring.size)
return;
@@ -157,15 +157,15 @@ static void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
ring.size = ring_size;
- status = ice_fwlog_alloc_ring_buffs(&ring);
+ status = libie_fwlog_alloc_ring_buffs(&ring);
if (status) {
dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log ring data buffers\n");
- ice_fwlog_free_ring_buffs(&ring);
+ libie_fwlog_free_ring_buffs(&ring);
kfree(ring.rings);
return;
}
- ice_fwlog_free_ring_buffs(&fwlog->ring);
+ libie_fwlog_free_ring_buffs(&fwlog->ring);
kfree(fwlog->ring.rings);
fwlog->ring.rings = ring.rings;
@@ -176,23 +176,174 @@ static void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index)
}
/**
- * ice_fwlog_print_module_cfg - print current FW logging module configuration
+ * libie_fwlog_supported - Cached for whether FW supports FW logging or not
+ * @fwlog: pointer to the fwlog structure
+ *
+ * This will always return false if called before libie_init_hw(), so it must be
+ * called after libie_init_hw().
+ */
+static bool libie_fwlog_supported(struct libie_fwlog *fwlog)
+{
+ return fwlog->supported;
+}
+
+/**
+ * libie_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30)
+ * @fwlog: pointer to the fwlog structure
+ * @entries: entries to configure
+ * @num_entries: number of @entries
+ * @options: options from libie_fwlog_cfg->options structure
+ * @log_resolution: logging resolution
+ */
+static int
+libie_aq_fwlog_set(struct libie_fwlog *fwlog,
+ struct libie_fwlog_module_entry *entries, u16 num_entries,
+ u16 options, u16 log_resolution)
+{
+ struct libie_aqc_fw_log_cfg_resp *fw_modules;
+ struct libie_aq_desc desc = {0};
+ struct libie_aqc_fw_log *cmd;
+ int status;
+ int 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;
+ }
+
+ desc.opcode = cpu_to_le16(libie_aqc_opc_fw_logs_config);
+ desc.flags = cpu_to_le16(LIBIE_AQ_FLAG_SI) |
+ cpu_to_le16(LIBIE_AQ_FLAG_RD);
+
+ cmd = libie_aq_raw(&desc);
+
+ cmd->cmd_flags = LIBIE_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 & LIBIE_FWLOG_OPTION_ARQ_ENA)
+ cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_AQ_EN;
+ if (options & LIBIE_FWLOG_OPTION_UART_ENA)
+ cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_UART_EN;
+
+ status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules,
+ sizeof(*fw_modules) * num_entries);
+
+ kfree(fw_modules);
+
+ return status;
+}
+
+/**
+ * libie_fwlog_set - Set the firmware logging settings
+ * @fwlog: pointer to the fwlog 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
+ * libie_fwlog_register. Note, that libie_fwlog_register does not need to be called
+ * for init.
+ */
+static int libie_fwlog_set(struct libie_fwlog *fwlog,
+ struct libie_fwlog_cfg *cfg)
+{
+ if (!libie_fwlog_supported(fwlog))
+ return -EOPNOTSUPP;
+
+ return libie_aq_fwlog_set(fwlog, cfg->module_entries,
+ LIBIE_AQC_FW_LOG_ID_MAX, cfg->options,
+ cfg->log_resolution);
+}
+
+/**
+ * libie_aq_fwlog_register - Register PF for firmware logging events (0xFF31)
+ * @fwlog: pointer to the fwlog structure
+ * @reg: true to register and false to unregister
+ */
+static int libie_aq_fwlog_register(struct libie_fwlog *fwlog, bool reg)
+{
+ struct libie_aq_desc desc = {0};
+ struct libie_aqc_fw_log *cmd;
+
+ desc.opcode = cpu_to_le16(libie_aqc_opc_fw_logs_register);
+ desc.flags = cpu_to_le16(LIBIE_AQ_FLAG_SI);
+ cmd = libie_aq_raw(&desc);
+
+ if (reg)
+ cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_REGISTER;
+
+ return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0);
+}
+
+/**
+ * libie_fwlog_register - Register the PF for firmware logging
+ * @fwlog: pointer to the fwlog structure
+ *
+ * After this call the PF will start to receive firmware logging based on the
+ * configuration set in libie_fwlog_set.
+ */
+int libie_fwlog_register(struct libie_fwlog *fwlog)
+{
+ int status;
+
+ if (!libie_fwlog_supported(fwlog))
+ return -EOPNOTSUPP;
+
+ status = libie_aq_fwlog_register(fwlog, true);
+ if (status)
+ dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n");
+ else
+ fwlog->cfg.options |= LIBIE_FWLOG_OPTION_IS_REGISTERED;
+
+ return status;
+}
+
+/**
+ * libie_fwlog_unregister - Unregister the PF from firmware logging
+ * @fwlog: pointer to the fwlog structure
+ */
+static int libie_fwlog_unregister(struct libie_fwlog *fwlog)
+{
+ int status;
+
+ if (!libie_fwlog_supported(fwlog))
+ return -EOPNOTSUPP;
+
+ status = libie_aq_fwlog_register(fwlog, false);
+ if (status)
+ dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n");
+ else
+ fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_IS_REGISTERED;
+
+ return status;
+}
+
+/**
+ * libie_fwlog_print_module_cfg - print current FW logging module configuration
* @cfg: pointer to the fwlog cfg structure
* @module: module to print
* @s: the seq file to put data into
*/
static void
-ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
- struct seq_file *s)
+libie_fwlog_print_module_cfg(struct libie_fwlog_cfg *cfg, int module,
+ struct seq_file *s)
{
- struct ice_fwlog_module_entry *entry;
+ struct libie_fwlog_module_entry *entry;
if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
entry = &cfg->module_entries[module];
seq_printf(s, "\tModule: %s, Log Level: %s\n",
- ice_fwlog_module_string[entry->module_id],
- ice_fwlog_level_string[entry->log_level]);
+ libie_fwlog_module_string[entry->module_id],
+ libie_fwlog_level_string[entry->log_level]);
} else {
int i;
@@ -200,19 +351,19 @@ ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module,
entry = &cfg->module_entries[i];
seq_printf(s, "\tModule: %s, Log Level: %s\n",
- ice_fwlog_module_string[entry->module_id],
- ice_fwlog_level_string[entry->log_level]);
+ libie_fwlog_module_string[entry->module_id],
+ libie_fwlog_level_string[entry->log_level]);
}
}
}
-static int ice_find_module_by_dentry(struct dentry **modules, struct dentry *d)
+static int libie_find_module_by_dentry(struct dentry **modules, struct dentry *d)
{
int i, module;
module = -1;
/* find the module based on the dentry */
- for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
+ for (i = 0; i < LIBIE_NR_FW_LOG_MODULES; i++) {
if (d == modules[i]) {
module = i;
break;
@@ -223,47 +374,47 @@ static int ice_find_module_by_dentry(struct dentry **modules, struct dentry *d)
}
/**
- * ice_debugfs_module_show - read from 'module' file
+ * libie_debugfs_module_show - read from 'module' file
* @s: the opened file
* @v: pointer to the offset
*/
-static int ice_debugfs_module_show(struct seq_file *s, void *v)
+static int libie_debugfs_module_show(struct seq_file *s, void *v)
{
- struct ice_fwlog *fwlog = s->private;
+ struct libie_fwlog *fwlog = s->private;
const struct file *filp = s->file;
struct dentry *dentry;
int module;
dentry = file_dentry(filp);
- module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
+ module = libie_find_module_by_dentry(fwlog->debugfs_modules, dentry);
if (module < 0) {
dev_info(&fwlog->pdev->dev, "unknown module\n");
return -EINVAL;
}
- ice_fwlog_print_module_cfg(&fwlog->cfg, module, s);
+ libie_fwlog_print_module_cfg(&fwlog->cfg, module, s);
return 0;
}
-static int ice_debugfs_module_open(struct inode *inode, struct file *filp)
+static int libie_debugfs_module_open(struct inode *inode, struct file *filp)
{
- return single_open(filp, ice_debugfs_module_show, inode->i_private);
+ return single_open(filp, libie_debugfs_module_show, inode->i_private);
}
/**
- * ice_debugfs_module_write - write into 'module' file
+ * libie_debugfs_module_write - write into 'module' file
* @filp: the opened file
* @buf: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
*/
static ssize_t
-ice_debugfs_module_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+libie_debugfs_module_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
{
- struct ice_fwlog *fwlog = file_inode(filp)->i_private;
+ struct libie_fwlog *fwlog = file_inode(filp)->i_private;
struct dentry *dentry = file_dentry(filp);
struct device *dev = &fwlog->pdev->dev;
char user_val[16], *cmd_buf;
@@ -277,7 +428,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
if (IS_ERR(cmd_buf))
return PTR_ERR(cmd_buf);
- module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry);
+ module = libie_find_module_by_dentry(fwlog->debugfs_modules, dentry);
if (module < 0) {
dev_info(dev, "unknown module\n");
return -EINVAL;
@@ -287,7 +438,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
if (cnt != 1)
return -EINVAL;
- log_level = sysfs_match_string(ice_fwlog_level_string, user_val);
+ log_level = sysfs_match_string(libie_fwlog_level_string, user_val);
if (log_level < 0) {
dev_info(dev, "unknown log level '%s'\n", user_val);
return -EINVAL;
@@ -308,26 +459,26 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
return count;
}
-static const struct file_operations ice_debugfs_module_fops = {
+static const struct file_operations libie_debugfs_module_fops = {
.owner = THIS_MODULE,
- .open = ice_debugfs_module_open,
+ .open = libie_debugfs_module_open,
.read = seq_read,
.release = single_release,
- .write = ice_debugfs_module_write,
+ .write = libie_debugfs_module_write,
};
/**
- * ice_debugfs_nr_messages_read - read from 'nr_messages' file
+ * libie_debugfs_nr_messages_read - read from 'nr_messages' file
* @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_nr_messages_read(struct file *filp,
- char __user *buffer, size_t count,
- loff_t *ppos)
+static ssize_t libie_debugfs_nr_messages_read(struct file *filp,
+ char __user *buffer, size_t count,
+ loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
char buff[32] = {};
snprintf(buff, sizeof(buff), "%d\n",
@@ -337,17 +488,17 @@ static ssize_t ice_debugfs_nr_messages_read(struct file *filp,
}
/**
- * ice_debugfs_nr_messages_write - write into 'nr_messages' file
+ * libie_debugfs_nr_messages_write - write into 'nr_messages' file
* @filp: the opened file
* @buf: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
*/
static ssize_t
-ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+libie_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
struct device *dev = &fwlog->pdev->dev;
char user_val[8], *cmd_buf;
s16 nr_messages;
@@ -382,46 +533,46 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
return count;
}
-static const struct file_operations ice_debugfs_nr_messages_fops = {
+static const struct file_operations libie_debugfs_nr_messages_fops = {
.owner = THIS_MODULE,
.open = simple_open,
- .read = ice_debugfs_nr_messages_read,
- .write = ice_debugfs_nr_messages_write,
+ .read = libie_debugfs_nr_messages_read,
+ .write = libie_debugfs_nr_messages_write,
};
/**
- * ice_debugfs_enable_read - read from 'enable' file
+ * libie_debugfs_enable_read - read from 'enable' file
* @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_enable_read(struct file *filp,
- char __user *buffer, size_t count,
- loff_t *ppos)
+static ssize_t libie_debugfs_enable_read(struct file *filp,
+ char __user *buffer, size_t count,
+ loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
char buff[32] = {};
snprintf(buff, sizeof(buff), "%u\n",
(u16)(fwlog->cfg.options &
- ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
+ LIBIE_FWLOG_OPTION_IS_REGISTERED) >> 3);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
}
/**
- * ice_debugfs_enable_write - write into 'enable' file
+ * libie_debugfs_enable_write - write into 'enable' file
* @filp: the opened file
* @buf: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
*/
static ssize_t
-ice_debugfs_enable_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+libie_debugfs_enable_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
char user_val[8], *cmd_buf;
bool enable;
ssize_t ret;
@@ -443,18 +594,18 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
goto enable_write_error;
if (enable)
- fwlog->cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA;
+ fwlog->cfg.options |= LIBIE_FWLOG_OPTION_ARQ_ENA;
else
- fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
+ fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_ARQ_ENA;
- ret = ice_fwlog_set(fwlog, &fwlog->cfg);
+ ret = libie_fwlog_set(fwlog, &fwlog->cfg);
if (ret)
goto enable_write_error;
if (enable)
- ret = ice_fwlog_register(fwlog);
+ ret = libie_fwlog_register(fwlog);
else
- ret = ice_fwlog_unregister(fwlog);
+ ret = libie_fwlog_unregister(fwlog);
if (ret)
goto enable_write_error;
@@ -475,46 +626,46 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
return ret;
}
-static const struct file_operations ice_debugfs_enable_fops = {
+static const struct file_operations libie_debugfs_enable_fops = {
.owner = THIS_MODULE,
.open = simple_open,
- .read = ice_debugfs_enable_read,
- .write = ice_debugfs_enable_write,
+ .read = libie_debugfs_enable_read,
+ .write = libie_debugfs_enable_write,
};
/**
- * ice_debugfs_log_size_read - read from 'log_size' file
+ * libie_debugfs_log_size_read - read from 'log_size' file
* @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_log_size_read(struct file *filp,
- char __user *buffer, size_t count,
- loff_t *ppos)
+static ssize_t libie_debugfs_log_size_read(struct file *filp,
+ char __user *buffer, size_t count,
+ loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
char buff[32] = {};
int index;
index = fwlog->ring.index;
- snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]);
+ snprintf(buff, sizeof(buff), "%s\n", libie_fwlog_log_size[index]);
return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
}
/**
- * ice_debugfs_log_size_write - write into 'log_size' file
+ * libie_debugfs_log_size_write - write into 'log_size' file
* @filp: the opened file
* @buf: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
*/
static ssize_t
-ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *ppos)
+libie_debugfs_log_size_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
struct device *dev = &fwlog->pdev->dev;
char user_val[8], *cmd_buf;
ssize_t ret;
@@ -532,20 +683,20 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
if (ret != 1)
return -EINVAL;
- index = sysfs_match_string(ice_fwlog_log_size, user_val);
+ index = sysfs_match_string(libie_fwlog_log_size, user_val);
if (index < 0) {
dev_info(dev, "Invalid log size '%s'. The value must be one of 128K, 256K, 512K, 1M, 2M\n",
user_val);
ret = -EINVAL;
goto log_size_write_error;
- } else if (fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) {
+ } else if (fwlog->cfg.options & LIBIE_FWLOG_OPTION_IS_REGISTERED) {
dev_info(dev, "FW logging is currently running. Please disable FW logging to change log_size\n");
ret = -EINVAL;
goto log_size_write_error;
}
/* free all the buffers and the tracking info and resize */
- ice_fwlog_realloc_rings(fwlog, index);
+ libie_fwlog_realloc_rings(fwlog, index);
/* if we get here, nothing went wrong; return count since we didn't
* really write anything
@@ -563,32 +714,32 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
return ret;
}
-static const struct file_operations ice_debugfs_log_size_fops = {
+static const struct file_operations libie_debugfs_log_size_fops = {
.owner = THIS_MODULE,
.open = simple_open,
- .read = ice_debugfs_log_size_read,
- .write = ice_debugfs_log_size_write,
+ .read = libie_debugfs_log_size_read,
+ .write = libie_debugfs_log_size_write,
};
/**
- * ice_debugfs_data_read - read from 'data' file
+ * libie_debugfs_data_read - read from 'data' file
* @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_data_read(struct file *filp, char __user *buffer,
- size_t count, loff_t *ppos)
+static ssize_t libie_debugfs_data_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
int data_copied = 0;
bool done = false;
- if (ice_fwlog_ring_empty(&fwlog->ring))
+ if (libie_fwlog_ring_empty(&fwlog->ring))
return 0;
- while (!ice_fwlog_ring_empty(&fwlog->ring) && !done) {
- struct ice_fwlog_data *log;
+ while (!libie_fwlog_ring_empty(&fwlog->ring) && !done) {
+ struct libie_fwlog_data *log;
u16 cur_buf_len;
log = &fwlog->ring.rings[fwlog->ring.head];
@@ -610,24 +761,24 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
buffer += cur_buf_len;
count -= cur_buf_len;
*ppos += cur_buf_len;
- ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
+ libie_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
}
return data_copied;
}
/**
- * ice_debugfs_data_write - write into 'data' file
+ * libie_debugfs_data_write - write into 'data' file
* @filp: the opened file
* @buf: where to find the user's data
* @count: the length of the user's data
* @ppos: file position offset
*/
static ssize_t
-ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
- loff_t *ppos)
+libie_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
+ loff_t *ppos)
{
- struct ice_fwlog *fwlog = filp->private_data;
+ struct libie_fwlog *fwlog = filp->private_data;
struct device *dev = &fwlog->pdev->dev;
ssize_t ret;
@@ -638,7 +789,7 @@ ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
/* any value is allowed to clear the buffer so no need to even look at
* what the value is
*/
- if (!(fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) {
+ if (!(fwlog->cfg.options & LIBIE_FWLOG_OPTION_IS_REGISTERED)) {
fwlog->ring.head = 0;
fwlog->ring.tail = 0;
} else {
@@ -663,19 +814,20 @@ ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
return ret;
}
-static const struct file_operations ice_debugfs_data_fops = {
+static const struct file_operations libie_debugfs_data_fops = {
.owner = THIS_MODULE,
.open = simple_open,
- .read = ice_debugfs_data_read,
- .write = ice_debugfs_data_write,
+ .read = libie_debugfs_data_read,
+ .write = libie_debugfs_data_write,
};
/**
- * ice_debugfs_fwlog_init - setup the debugfs directory
+ * libie_debugfs_fwlog_init - setup the debugfs directory
* @fwlog: pointer to the fwlog structure
* @root: debugfs root entry on which fwlog director will be registered
*/
-static void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
+static void libie_debugfs_fwlog_init(struct libie_fwlog *fwlog,
+ struct dentry *root)
{
struct dentry *fw_modules_dir;
struct dentry **fw_modules;
@@ -684,7 +836,7 @@ static void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
/* allocate space for this first because if it fails then we don't
* need to unwind
*/
- fw_modules = kcalloc(ICE_NR_FW_LOG_MODULES, sizeof(*fw_modules),
+ fw_modules = kcalloc(LIBIE_NR_FW_LOG_MODULES, sizeof(*fw_modules),
GFP_KERNEL);
if (!fw_modules)
return;
@@ -697,27 +849,27 @@ static void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
if (IS_ERR(fw_modules_dir))
goto err_create_module_files;
- for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) {
- fw_modules[i] = debugfs_create_file(ice_fwlog_module_string[i],
+ for (i = 0; i < LIBIE_NR_FW_LOG_MODULES; i++) {
+ fw_modules[i] = debugfs_create_file(libie_fwlog_module_string[i],
0600, fw_modules_dir, fwlog,
- &ice_debugfs_module_fops);
+ &libie_debugfs_module_fops);
if (IS_ERR(fw_modules[i]))
goto err_create_module_files;
}
debugfs_create_file("nr_messages", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_nr_messages_fops);
+ &libie_debugfs_nr_messages_fops);
fwlog->debugfs_modules = fw_modules;
debugfs_create_file("enable", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_enable_fops);
+ &libie_debugfs_enable_fops);
debugfs_create_file("log_size", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_log_size_fops);
+ &libie_debugfs_log_size_fops);
debugfs_create_file("data", 0600, fwlog->debugfs, fwlog,
- &ice_debugfs_data_fops);
+ &libie_debugfs_data_fops);
return;
@@ -726,7 +878,7 @@ static void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root)
kfree(fw_modules);
}
-static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
+static bool libie_fwlog_ring_full(struct libie_fwlog_ring *rings)
{
u16 head, tail;
@@ -742,27 +894,16 @@ static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings)
}
/**
- * ice_fwlog_supported - Cached for whether FW supports FW logging or not
- * @fwlog: pointer to the fwlog structure
- *
- * This will always return false if called before ice_init_hw(), so it must be
- * called after ice_init_hw().
- */
-static bool ice_fwlog_supported(struct ice_fwlog *fwlog)
-{
- return fwlog->supported;
-}
-
-/**
- * ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32)
+ * libie_aq_fwlog_get - Get the current firmware logging configuration (0xFF32)
* @fwlog: pointer to the fwlog structure
* @cfg: firmware logging configuration to populate
*/
-static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
+static int libie_aq_fwlog_get(struct libie_fwlog *fwlog,
+ struct libie_fwlog_cfg *cfg)
{
struct libie_aqc_fw_log_cfg_resp *fw_modules;
+ struct libie_aq_desc desc = {0};
struct libie_aqc_fw_log *cmd;
- struct libie_aq_desc desc;
u16 module_id_cnt;
int status;
void *buf;
@@ -770,16 +911,17 @@ static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
memset(cfg, 0, sizeof(*cfg));
- buf = kzalloc(ICE_AQ_MAX_BUF_LEN, GFP_KERNEL);
+ buf = kzalloc(LIBIE_AQ_MAX_BUF_LEN, GFP_KERNEL);
if (!buf)
return -ENOMEM;
- ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_query);
+ desc.opcode = cpu_to_le16(libie_aqc_opc_fw_logs_query);
+ desc.flags = cpu_to_le16(LIBIE_AQ_FLAG_SI);
cmd = libie_aq_raw(&desc);
cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_QUERY;
- status = fwlog->send_cmd(fwlog->priv, &desc, buf, ICE_AQ_MAX_BUF_LEN);
+ status = fwlog->send_cmd(fwlog->priv, &desc, buf, LIBIE_AQ_MAX_BUF_LEN);
if (status) {
dev_dbg(&fwlog->pdev->dev, "Failed to get FW log configuration\n");
goto status_out;
@@ -796,11 +938,11 @@ static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
cfg->log_resolution = le16_to_cpu(cmd->ops.cfg.log_resolution);
if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_CONF_AQ_EN)
- cfg->options |= ICE_FWLOG_OPTION_ARQ_ENA;
+ cfg->options |= LIBIE_FWLOG_OPTION_ARQ_ENA;
if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_CONF_UART_EN)
- cfg->options |= ICE_FWLOG_OPTION_UART_ENA;
+ cfg->options |= LIBIE_FWLOG_OPTION_UART_ENA;
if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_QUERY_REGISTERED)
- cfg->options |= ICE_FWLOG_OPTION_IS_REGISTERED;
+ cfg->options |= LIBIE_FWLOG_OPTION_IS_REGISTERED;
fw_modules = (struct libie_aqc_fw_log_cfg_resp *)buf;
@@ -818,18 +960,18 @@ static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
}
/**
- * ice_fwlog_set_supported - Set if FW logging is supported by FW
+ * libie_fwlog_set_supported - Set if FW logging is supported by FW
* @fwlog: pointer to the fwlog structure
*
- * If FW returns success to the ice_aq_fwlog_get call then it supports FW
+ * If FW returns success to the libie_aq_fwlog_get call then it supports FW
* logging, else it doesn't. Set the fwlog_supported flag accordingly.
*
* This function is only meant to be called during driver init to determine if
* the FW support FW logging.
*/
-static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
+static void libie_fwlog_set_supported(struct libie_fwlog *fwlog)
{
- struct ice_fwlog_cfg *cfg;
+ struct libie_fwlog_cfg *cfg;
int status;
fwlog->supported = false;
@@ -838,9 +980,9 @@ static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
if (!cfg)
return;
- status = ice_aq_fwlog_get(fwlog, cfg);
+ status = libie_aq_fwlog_get(fwlog, cfg);
if (status)
- dev_dbg(&fwlog->pdev->dev, "ice_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n",
+ dev_dbg(&fwlog->pdev->dev, "libie_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n",
status);
else
fwlog->supported = true;
@@ -849,28 +991,28 @@ static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
}
/**
- * ice_fwlog_init - Initialize FW logging configuration
+ * libie_fwlog_init - Initialize FW logging configuration
* @fwlog: pointer to the fwlog structure
* @api: api structure to init fwlog
*
* This function should be called on driver initialization during
- * ice_init_hw().
+ * libie_init_hw().
*/
-int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api)
+int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api)
{
fwlog->api = *api;
- ice_fwlog_set_supported(fwlog);
+ libie_fwlog_set_supported(fwlog);
- if (ice_fwlog_supported(fwlog)) {
+ if (libie_fwlog_supported(fwlog)) {
int status;
/* read the current config from the FW and store it */
- status = ice_aq_fwlog_get(fwlog, &fwlog->cfg);
+ status = libie_aq_fwlog_get(fwlog, &fwlog->cfg);
if (status)
return status;
- fwlog->ring.rings = kcalloc(ICE_FWLOG_RING_SIZE_DFLT,
+ fwlog->ring.rings = kcalloc(LIBIE_FWLOG_RING_SIZE_DFLT,
sizeof(*fwlog->ring.rings),
GFP_KERNEL);
if (!fwlog->ring.rings) {
@@ -878,18 +1020,18 @@ int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api)
return -ENOMEM;
}
- fwlog->ring.size = ICE_FWLOG_RING_SIZE_DFLT;
- fwlog->ring.index = ICE_FWLOG_RING_SIZE_INDEX_DFLT;
+ fwlog->ring.size = LIBIE_FWLOG_RING_SIZE_DFLT;
+ fwlog->ring.index = LIBIE_FWLOG_RING_SIZE_INDEX_DFLT;
- status = ice_fwlog_alloc_ring_buffs(&fwlog->ring);
+ status = libie_fwlog_alloc_ring_buffs(&fwlog->ring);
if (status) {
dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log ring data buffers\n");
- ice_fwlog_free_ring_buffs(&fwlog->ring);
+ libie_fwlog_free_ring_buffs(&fwlog->ring);
kfree(fwlog->ring.rings);
return status;
}
- ice_debugfs_fwlog_init(fwlog, api->debugfs_root);
+ libie_debugfs_fwlog_init(fwlog, api->debugfs_root);
} else {
dev_warn(&fwlog->pdev->dev, "FW logging is not supported in this NVM image. Please update the NVM to get FW log support\n");
}
@@ -898,20 +1040,20 @@ int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api)
}
/**
- * ice_fwlog_deinit - unroll FW logging configuration
+ * libie_fwlog_deinit - unroll FW logging configuration
* @fwlog: pointer to the fwlog structure
*
- * This function should be called in ice_deinit_hw().
+ * This function should be called in libie_deinit_hw().
*/
-void ice_fwlog_deinit(struct ice_fwlog *fwlog)
+void libie_fwlog_deinit(struct libie_fwlog *fwlog)
{
int status;
/* make sure FW logging is disabled to not put the FW in a weird state
* for the next driver load
*/
- fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
- status = ice_fwlog_set(fwlog, &fwlog->cfg);
+ fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_ARQ_ENA;
+ status = libie_fwlog_set(fwlog, &fwlog->cfg);
if (status)
dev_warn(&fwlog->pdev->dev, "Unable to turn off FW logging, status: %d\n",
status);
@@ -920,162 +1062,26 @@ void ice_fwlog_deinit(struct ice_fwlog *fwlog)
fwlog->debugfs_modules = NULL;
- status = ice_fwlog_unregister(fwlog);
+ status = libie_fwlog_unregister(fwlog);
if (status)
dev_warn(&fwlog->pdev->dev, "Unable to unregister FW logging, status: %d\n",
status);
if (fwlog->ring.rings) {
- ice_fwlog_free_ring_buffs(&fwlog->ring);
+ libie_fwlog_free_ring_buffs(&fwlog->ring);
kfree(fwlog->ring.rings);
}
}
/**
- * ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30)
- * @fwlog: pointer to the fwlog 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_fwlog *fwlog,
- struct ice_fwlog_module_entry *entries, u16 num_entries,
- u16 options, u16 log_resolution)
-{
- struct libie_aqc_fw_log_cfg_resp *fw_modules;
- struct libie_aqc_fw_log *cmd;
- struct libie_aq_desc desc;
- int status;
- int 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, libie_aqc_opc_fw_logs_config);
- desc.flags |= cpu_to_le16(LIBIE_AQ_FLAG_RD);
-
- cmd = libie_aq_raw(&desc);
-
- cmd->cmd_flags = LIBIE_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 |= LIBIE_AQC_FW_LOG_CONF_AQ_EN;
- if (options & ICE_FWLOG_OPTION_UART_ENA)
- cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_UART_EN;
-
- status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules,
- sizeof(*fw_modules) * num_entries);
-
- kfree(fw_modules);
-
- return status;
-}
-
-/**
- * ice_fwlog_set - Set the firmware logging settings
- * @fwlog: pointer to the fwlog 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_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
-{
- if (!ice_fwlog_supported(fwlog))
- return -EOPNOTSUPP;
-
- return ice_aq_fwlog_set(fwlog, cfg->module_entries,
- LIBIE_AQC_FW_LOG_ID_MAX, cfg->options,
- cfg->log_resolution);
-}
-
-/**
- * ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31)
- * @fwlog: pointer to the fwlog structure
- * @reg: true to register and false to unregister
- */
-static int ice_aq_fwlog_register(struct ice_fwlog *fwlog, bool reg)
-{
- struct libie_aqc_fw_log *cmd;
- struct libie_aq_desc desc;
-
- ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_register);
- cmd = libie_aq_raw(&desc);
-
- if (reg)
- cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_REGISTER;
-
- return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0);
-}
-
-/**
- * ice_fwlog_register - Register the PF for firmware logging
- * @fwlog: pointer to the fwlog 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_fwlog *fwlog)
-{
- int status;
-
- if (!ice_fwlog_supported(fwlog))
- return -EOPNOTSUPP;
-
- status = ice_aq_fwlog_register(fwlog, true);
- if (status)
- dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n");
- else
- fwlog->cfg.options |= ICE_FWLOG_OPTION_IS_REGISTERED;
-
- return status;
-}
-
-/**
- * ice_fwlog_unregister - Unregister the PF from firmware logging
- * @fwlog: pointer to the fwlog structure
- */
-int ice_fwlog_unregister(struct ice_fwlog *fwlog)
-{
- int status;
-
- if (!ice_fwlog_supported(fwlog))
- return -EOPNOTSUPP;
-
- status = ice_aq_fwlog_register(fwlog, false);
- if (status)
- dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n");
- else
- fwlog->cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED;
-
- return status;
-}
-
-/**
- * ice_get_fwlog_data - copy the FW log data from ARQ event
+ * libie_get_fwlog_data - copy the FW log data from ARQ event
* @fwlog: fwlog that the FW log event is associated with
* @buf: event buffer pointer
* @len: len of event descriptor
*/
-void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len)
+void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len)
{
- struct ice_fwlog_data *log;
+ struct libie_fwlog_data *log;
log = &fwlog->ring.rings[fwlog->ring.tail];
@@ -1083,10 +1089,10 @@ void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len)
log->data_size = len;
memcpy(log->data, buf, log->data_size);
- ice_fwlog_ring_increment(&fwlog->ring.tail, fwlog->ring.size);
+ libie_fwlog_ring_increment(&fwlog->ring.tail, fwlog->ring.size);
- if (ice_fwlog_ring_full(&fwlog->ring)) {
+ if (libie_fwlog_ring_full(&fwlog->ring)) {
/* the rings are full so bump the head to create room */
- ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
+ libie_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
}
}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index d5868b9e4de6..3698759c8ebb 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -1,77 +1,75 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2022, Intel Corporation. */
-#ifndef _ICE_FWLOG_H_
-#define _ICE_FWLOG_H_
+#ifndef _LIBIE_FWLOG_H_
+#define _LIBIE_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)
+ * are enabled, e.g. if log level is set to LIBIE_FW_LOG_LEVEL_VERBOSE, then all
+ * other log levels are included (except LIBIE_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 */
+enum libie_fwlog_level {
+ LIBIE_FWLOG_LEVEL_NONE = 0,
+ LIBIE_FWLOG_LEVEL_ERROR = 1,
+ LIBIE_FWLOG_LEVEL_WARNING = 2,
+ LIBIE_FWLOG_LEVEL_NORMAL = 3,
+ LIBIE_FWLOG_LEVEL_VERBOSE = 4,
+ LIBIE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */
};
-struct ice_fwlog_module_entry {
+struct libie_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 {
+struct libie_fwlog_cfg {
/* list of modules for configuring log level */
- struct ice_fwlog_module_entry module_entries[LIBIE_AQC_FW_LOG_ID_MAX];
+ struct libie_fwlog_module_entry module_entries[LIBIE_AQC_FW_LOG_ID_MAX];
/* options used to configure firmware logging */
u16 options;
-#define ICE_FWLOG_OPTION_ARQ_ENA BIT(0)
-#define ICE_FWLOG_OPTION_UART_ENA BIT(1)
- /* set before calling ice_fwlog_init() so the PF registers for firmware
- * logging on initialization
+#define LIBIE_FWLOG_OPTION_ARQ_ENA BIT(0)
+#define LIBIE_FWLOG_OPTION_UART_ENA BIT(1)
+ /* set before calling libie_fwlog_init() so the PF registers for
+ * firmware logging on initialization
*/
-#define ICE_FWLOG_OPTION_REGISTER_ON_INIT BIT(2)
- /* set in the ice_aq_fwlog_get() response if the PF is registered for FW
- * logging events over ARQ
+#define LIBIE_FWLOG_OPTION_REGISTER_ON_INIT BIT(2)
+ /* set in the libie_aq_fwlog_get() response if the PF is registered for
+ * FW logging events over ARQ
*/
-#define ICE_FWLOG_OPTION_IS_REGISTERED BIT(3)
+#define LIBIE_FWLOG_OPTION_IS_REGISTERED BIT(3)
/* minimum number of log events sent per Admin Receive Queue event */
u16 log_resolution;
};
-struct ice_fwlog_data {
+struct libie_fwlog_data {
u16 data_size;
u8 *data;
};
-struct ice_fwlog_ring {
- struct ice_fwlog_data *rings;
+struct libie_fwlog_ring {
+ struct libie_fwlog_data *rings;
u16 index;
u16 size;
u16 head;
u16 tail;
};
-#define ICE_FWLOG_RING_SIZE_INDEX_DFLT 3
-#define ICE_FWLOG_RING_SIZE_DFLT 256
-#define ICE_FWLOG_RING_SIZE_MAX 512
+#define LIBIE_FWLOG_RING_SIZE_INDEX_DFLT 3
+#define LIBIE_FWLOG_RING_SIZE_DFLT 256
+#define LIBIE_FWLOG_RING_SIZE_MAX 512
-struct ice_fwlog {
- struct ice_fwlog_cfg cfg;
+struct libie_fwlog {
+ struct libie_fwlog_cfg cfg;
bool supported; /* does hardware support FW logging? */
- struct ice_fwlog_ring ring;
+ struct libie_fwlog_ring ring;
struct dentry *debugfs;
/* keep track of all the dentrys for FW log modules */
struct dentry **debugfs_modules;
- struct_group_tagged(ice_fwlog_api, api,
+ struct_group_tagged(libie_fwlog_api, api,
struct pci_dev *pdev;
int (*send_cmd)(void *, struct libie_aq_desc *, void *, u16);
void *priv;
@@ -79,10 +77,8 @@ struct ice_fwlog {
);
};
-int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api);
-void ice_fwlog_deinit(struct ice_fwlog *fwlog);
-int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg);
-int ice_fwlog_register(struct ice_fwlog *fwlog);
-int ice_fwlog_unregister(struct ice_fwlog *fwlog);
-void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
-#endif /* _ICE_FWLOG_H_ */
+int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api);
+void libie_fwlog_deinit(struct libie_fwlog *fwlog);
+int libie_fwlog_register(struct libie_fwlog *fwlog);
+void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len);
+#endif /* _LIBIE_FWLOG_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 976aca5dc90f..e307d72f05d3 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1540,8 +1540,8 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
}
break;
case ice_aqc_opc_fw_logs_event:
- ice_get_fwlog_data(&hw->fwlog, event.msg_buf,
- le16_to_cpu(event.desc.datalen));
+ libie_get_fwlog_data(&hw->fwlog, event.msg_buf,
+ le16_to_cpu(event.desc.datalen));
break;
case ice_aqc_opc_lldp_set_mib_change:
ice_dcb_process_lldp_set_mib_change(pf, &event);
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index e4cc91e50643..288415e48c05 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -954,7 +954,7 @@ struct ice_hw {
u8 fw_patch; /* firmware patch version */
u32 fw_build; /* firmware build number */
- struct ice_fwlog fwlog;
+ struct libie_fwlog fwlog;
/* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL
* register. Used for determining the ITR/INTRL granularity during
diff --git a/include/linux/net/intel/libie/adminq.h b/include/linux/net/intel/libie/adminq.h
index f7d90e9acfe4..0df4c9326621 100644
--- a/include/linux/net/intel/libie/adminq.h
+++ b/include/linux/net/intel/libie/adminq.h
@@ -9,6 +9,7 @@
#define LIBIE_CHECK_STRUCT_LEN(n, X) \
static_assert((n) == sizeof(struct X))
+#define LIBIE_AQ_MAX_BUF_LEN 4096
/**
* struct libie_aqc_generic - Generic structure used in adminq communication
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 13/15] ice: reregister fwlog after driver reinit
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (11 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 12/15] ice: prepare for moving file to libie Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:45 ` [PATCH iwl-next v1 14/15] ice, libie: move fwlog code to libie Michal Swiatkowski
` (2 subsequent siblings)
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Wrap libie_fwlog_register() by libie_fwlog_reregister(), which checks
first if the registration is needed. This simplifies the code and makes
the former function static.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/ice/ice_fwlog.c | 11 ++++++++++-
drivers/net/ethernet/intel/ice/ice_fwlog.h | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/ice/ice_fwlog.c
index 775581163e04..e76397ade68b 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.c
@@ -290,7 +290,7 @@ static int libie_aq_fwlog_register(struct libie_fwlog *fwlog, bool reg)
* After this call the PF will start to receive firmware logging based on the
* configuration set in libie_fwlog_set.
*/
-int libie_fwlog_register(struct libie_fwlog *fwlog)
+static int libie_fwlog_register(struct libie_fwlog *fwlog)
{
int status;
@@ -1096,3 +1096,12 @@ void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len)
libie_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
}
}
+
+void libie_fwlog_reregister(struct libie_fwlog *fwlog)
+{
+ if (!(fwlog->cfg.options & LIBIE_FWLOG_OPTION_IS_REGISTERED))
+ return;
+
+ if (libie_fwlog_register(fwlog))
+ fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_IS_REGISTERED;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/drivers/net/ethernet/intel/ice/ice_fwlog.h
index 3698759c8ebb..e534205a2d04 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/drivers/net/ethernet/intel/ice/ice_fwlog.h
@@ -79,6 +79,6 @@ struct libie_fwlog {
int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api);
void libie_fwlog_deinit(struct libie_fwlog *fwlog);
-int libie_fwlog_register(struct libie_fwlog *fwlog);
+void libie_fwlog_reregister(struct libie_fwlog *fwlog);
void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len);
#endif /* _LIBIE_FWLOG_H_ */
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 14/15] ice, libie: move fwlog code to libie
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (12 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 13/15] ice: reregister fwlog after driver reinit Michal Swiatkowski
@ 2025-07-22 10:45 ` Michal Swiatkowski
2025-07-22 10:46 ` [PATCH iwl-next v1 15/15] ixgbe: fwlog support for e610 Michal Swiatkowski
2025-07-23 12:12 ` [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Jiri Pirko
15 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:45 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
Move whole code from ice_fwlog.c/h to libie/fwlog.c/h.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/Kconfig | 1 +
drivers/net/ethernet/intel/ice/Makefile | 1 -
drivers/net/ethernet/intel/ice/ice_main.c | 1 +
drivers/net/ethernet/intel/ice/ice_type.h | 2 +-
drivers/net/ethernet/intel/libie/Kconfig | 7 +++++++
drivers/net/ethernet/intel/libie/Makefile | 4 ++++
.../intel/{ice/ice_fwlog.c => libie/fwlog.c} | 12 +++++++++---
include/linux/net/intel/libie/adminq.h | 6 +++---
.../linux/net/intel/libie/fwlog.h | 3 ++-
9 files changed, 28 insertions(+), 9 deletions(-)
rename drivers/net/ethernet/intel/{ice/ice_fwlog.c => libie/fwlog.c} (98%)
rename drivers/net/ethernet/intel/ice/ice_fwlog.h => include/linux/net/intel/libie/fwlog.h (98%)
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index b05cc0d7a15d..09f0af386af1 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -297,6 +297,7 @@ config ICE
select DIMLIB
select LIBIE
select LIBIE_ADMINQ
+ select LIBIE_FWLOG
select NET_DEVLINK
select PACKING
select PLDMFW
diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile
index d0f9c9492363..e8cd30da6d53 100644
--- a/drivers/net/ethernet/intel/ice/Makefile
+++ b/drivers/net/ethernet/intel/ice/Makefile
@@ -42,7 +42,6 @@ ice-y := ice_main.o \
ice_ethtool.o \
ice_repr.o \
ice_tc_lib.o \
- ice_fwlog.o \
ice_debugfs.o \
ice_adapter.o
ice-$(CONFIG_PCI_IOV) += \
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index e307d72f05d3..d501e45eae62 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -39,6 +39,7 @@ static const char ice_copyright[] = "Copyright (c) 2018, Intel Corporation.";
MODULE_DESCRIPTION(DRV_SUMMARY);
MODULE_IMPORT_NS("LIBIE");
MODULE_IMPORT_NS("LIBIE_ADMINQ");
+MODULE_IMPORT_NS("LIBIE_FWLOG");
MODULE_LICENSE("GPL v2");
MODULE_FIRMWARE(ICE_DDP_PKG_FILE);
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index 288415e48c05..4213a2b9fa9d 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -17,7 +17,7 @@
#include "ice_protocol_type.h"
#include "ice_sbq_cmd.h"
#include "ice_vlan_mode.h"
-#include "ice_fwlog.h"
+#include <linux/net/intel/libie/fwlog.h>
#include <linux/wait.h>
#include <net/dscp.h>
diff --git a/drivers/net/ethernet/intel/libie/Kconfig b/drivers/net/ethernet/intel/libie/Kconfig
index e6072758e3d8..679974797dcb 100644
--- a/drivers/net/ethernet/intel/libie/Kconfig
+++ b/drivers/net/ethernet/intel/libie/Kconfig
@@ -14,3 +14,10 @@ config LIBIE_ADMINQ
help
Helper functions used by Intel Ethernet drivers for administration
queue command interface (aka adminq).
+
+config LIBIE_FWLOG
+ tristate
+ select LIBIE_ADMINQ
+ help
+ Library to support firmware logging on device that have support
+ for it.
diff --git a/drivers/net/ethernet/intel/libie/Makefile b/drivers/net/ethernet/intel/libie/Makefile
index e98f00b865d3..db57fc6780ea 100644
--- a/drivers/net/ethernet/intel/libie/Makefile
+++ b/drivers/net/ethernet/intel/libie/Makefile
@@ -8,3 +8,7 @@ libie-y := rx.o
obj-$(CONFIG_LIBIE_ADMINQ) += libie_adminq.o
libie_adminq-y := adminq.o
+
+obj-$(CONFIG_LIBIE_FWLOG) += libie_fwlog.o
+
+libie_fwlog-y := fwlog.o
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.c b/drivers/net/ethernet/intel/libie/fwlog.c
similarity index 98%
rename from drivers/net/ethernet/intel/ice/ice_fwlog.c
rename to drivers/net/ethernet/intel/libie/fwlog.c
index e76397ade68b..2cc41bbcbead 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.c
+++ b/drivers/net/ethernet/intel/libie/fwlog.c
@@ -3,11 +3,10 @@
#include <linux/debugfs.h>
#include <linux/fs.h>
+#include <linux/net/intel/libie/fwlog.h>
+#include <linux/pci.h>
#include <linux/random.h>
#include <linux/vmalloc.h>
-#include "ice.h"
-#include "ice_common.h"
-#include "ice_fwlog.h"
/* create a define that has an extra module that doesn't really exist. this
* is so we can add a module 'all' to easily enable/disable all the modules
@@ -1038,6 +1037,7 @@ int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api)
return 0;
}
+EXPORT_SYMBOL_NS_GPL(libie_fwlog_init, "LIBIE_FWLOG");
/**
* libie_fwlog_deinit - unroll FW logging configuration
@@ -1072,6 +1072,7 @@ void libie_fwlog_deinit(struct libie_fwlog *fwlog)
kfree(fwlog->ring.rings);
}
}
+EXPORT_SYMBOL_NS_GPL(libie_fwlog_deinit, "LIBIE_FWLOG");
/**
* libie_get_fwlog_data - copy the FW log data from ARQ event
@@ -1096,6 +1097,7 @@ void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len)
libie_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size);
}
}
+EXPORT_SYMBOL_NS_GPL(libie_get_fwlog_data, "LIBIE_FWLOG");
void libie_fwlog_reregister(struct libie_fwlog *fwlog)
{
@@ -1105,3 +1107,7 @@ void libie_fwlog_reregister(struct libie_fwlog *fwlog)
if (libie_fwlog_register(fwlog))
fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_IS_REGISTERED;
}
+EXPORT_SYMBOL_NS_GPL(libie_fwlog_reregister, "LIBIE_FWLOG");
+
+MODULE_DESCRIPTION("Intel(R) Ethernet common library");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/net/intel/libie/adminq.h b/include/linux/net/intel/libie/adminq.h
index 0df4c9326621..970b50fd898a 100644
--- a/include/linux/net/intel/libie/adminq.h
+++ b/include/linux/net/intel/libie/adminq.h
@@ -265,7 +265,7 @@ enum libie_aqc_fw_logging_mod {
LIBIE_AQC_FW_LOG_ID_TSDRV,
LIBIE_AQC_FW_LOG_ID_PFREG,
LIBIE_AQC_FW_LOG_ID_MDLVER,
- LIBIE_AQC_FW_LOG_ID_MAX,
+ LIBIE_AQC_FW_LOG_ID_MAX
};
/* Set FW Logging configuration (indirect 0xFF30)
@@ -280,8 +280,8 @@ enum libie_aqc_fw_logging_mod {
#define LIBIE_AQC_FW_LOG_AQ_REGISTER BIT(0)
#define LIBIE_AQC_FW_LOG_AQ_QUERY BIT(2)
-#define LIBIE_AQC_FW_LOG_MIN_RESOLUTION (1)
-#define LIBIE_AQC_FW_LOG_MAX_RESOLUTION (128)
+#define LIBIE_AQC_FW_LOG_MIN_RESOLUTION 1
+#define LIBIE_AQC_FW_LOG_MAX_RESOLUTION 128
struct libie_aqc_fw_log {
u8 cmd_flags;
diff --git a/drivers/net/ethernet/intel/ice/ice_fwlog.h b/include/linux/net/intel/libie/fwlog.h
similarity index 98%
rename from drivers/net/ethernet/intel/ice/ice_fwlog.h
rename to include/linux/net/intel/libie/fwlog.h
index e534205a2d04..36b13fabca9e 100644
--- a/drivers/net/ethernet/intel/ice/ice_fwlog.h
+++ b/include/linux/net/intel/libie/fwlog.h
@@ -3,7 +3,8 @@
#ifndef _LIBIE_FWLOG_H_
#define _LIBIE_FWLOG_H_
-#include "ice_adminq_cmd.h"
+
+#include <linux/net/intel/libie/adminq.h>
/* 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 LIBIE_FW_LOG_LEVEL_VERBOSE, then all
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH iwl-next v1 15/15] ixgbe: fwlog support for e610
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (13 preceding siblings ...)
2025-07-22 10:45 ` [PATCH iwl-next v1 14/15] ice, libie: move fwlog code to libie Michal Swiatkowski
@ 2025-07-22 10:46 ` Michal Swiatkowski
2025-07-23 0:45 ` [Intel-wired-lan] " kernel test robot
2025-07-23 12:12 ` [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Jiri Pirko
15 siblings, 1 reply; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-22 10:46 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, przemyslaw.kitszel, dawid.osuchowski, Michal Swiatkowski
The device support firmware logging feature. Use libie code to
initialize it and allow reading the logs using debugfs.
The commands are the same as in ice driver. Look at the description in
commit 96a9a9341cda ("ice: configure FW logging") for more info.
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
---
drivers/net/ethernet/intel/Kconfig | 1 +
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 32 +++++++++++++++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h | 2 ++
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 ++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 2 ++
5 files changed, 47 insertions(+)
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index 09f0af386af1..a563a94e2780 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -146,6 +146,7 @@ config IXGBE
tristate "Intel(R) 10GbE PCI Express adapters support"
depends on PCI
depends on PTP_1588_CLOCK_OPTIONAL
+ select LIBIE_FWLOG
select MDIO
select NET_DEVLINK
select PLDMFW
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
index b202639b92c7..6dd530a64bd6 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
@@ -3900,6 +3900,38 @@ static int ixgbe_read_pba_string_e610(struct ixgbe_hw *hw, u8 *pba_num,
return err;
}
+static int __fwlog_send_cmd(void *priv, struct libie_aq_desc *desc, void *buf,
+ u16 size)
+{
+ struct ixgbe_hw *hw = priv;
+
+ return ixgbe_aci_send_cmd(hw, desc, buf, size);
+}
+
+int ixgbe_fwlog_init(struct ixgbe_hw *hw)
+{
+ struct ixgbe_adapter *adapter = hw->back;
+ struct libie_fwlog_api api = {
+ .pdev = adapter->pdev,
+ .send_cmd = __fwlog_send_cmd,
+ .debugfs_root = adapter->ixgbe_dbg_adapter,
+ .priv = hw,
+ };
+
+ if (hw->mac.type != ixgbe_mac_e610)
+ return -EOPNOTSUPP;
+
+ return libie_fwlog_init(&hw->fwlog, &api);
+}
+
+void ixgbe_fwlog_deinit(struct ixgbe_hw *hw)
+{
+ if (hw->mac.type != ixgbe_mac_e610)
+ return;
+
+ libie_fwlog_deinit(&hw->fwlog);
+}
+
static const struct ixgbe_mac_operations mac_ops_e610 = {
.init_hw = ixgbe_init_hw_generic,
.start_hw = ixgbe_start_hw_e610,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h
index 782c489b0fa7..11916b979d28 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h
@@ -96,5 +96,7 @@ int ixgbe_aci_update_nvm(struct ixgbe_hw *hw, u16 module_typeid,
bool last_command, u8 command_flags);
int ixgbe_nvm_write_activate(struct ixgbe_hw *hw, u16 cmd_flags,
u8 *response_flags);
+int ixgbe_fwlog_init(struct ixgbe_hw *hw);
+void ixgbe_fwlog_deinit(struct ixgbe_hw *hw);
#endif /* _IXGBE_E610_H_ */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 692b095b5c16..11d0f6f97b02 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -172,6 +172,7 @@ static int debug = -1;
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
+MODULE_IMPORT_NS("LIBIE_FWLOG");
MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");
MODULE_LICENSE("GPL v2");
@@ -3361,6 +3362,10 @@ static void ixgbe_handle_fw_event(struct ixgbe_adapter *adapter)
e_crit(drv, "%s\n", ixgbe_overheat_msg);
ixgbe_down(adapter);
break;
+ case libie_aqc_opc_fw_logs_event:
+ libie_get_fwlog_data(&hw->fwlog, event.msg_buf,
+ le16_to_cpu(event.desc.datalen));
+ break;
default:
e_warn(hw, "unknown FW async event captured\n");
break;
@@ -12011,6 +12016,10 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ixgbe_devlink_init_regions(adapter);
devl_register(adapter->devlink);
devl_unlock(adapter->devlink);
+
+ if (ixgbe_fwlog_init(hw))
+ e_dev_info("Firmware logging not supported\n");
+
return 0;
err_netdev:
@@ -12068,6 +12077,7 @@ static void ixgbe_remove(struct pci_dev *pdev)
devl_lock(adapter->devlink);
devl_unregister(adapter->devlink);
ixgbe_devlink_destroy_regions(adapter);
+ ixgbe_fwlog_deinit(&adapter->hw);
ixgbe_dbg_adapter_exit(adapter);
set_bit(__IXGBE_REMOVING, &adapter->state);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 36577091cd9e..b1bfeb21537a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -7,6 +7,7 @@
#include <linux/types.h>
#include <linux/mdio.h>
#include <linux/netdevice.h>
+#include <linux/net/intel/libie/fwlog.h>
#include "ixgbe_type_e610.h"
/* Device IDs */
@@ -3752,6 +3753,7 @@ struct ixgbe_hw {
struct ixgbe_flash_info flash;
struct ixgbe_hw_dev_caps dev_caps;
struct ixgbe_hw_func_caps func_caps;
+ struct libie_fwlog fwlog;
};
struct ixgbe_info {
--
2.49.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Intel-wired-lan] [PATCH iwl-next v1 15/15] ixgbe: fwlog support for e610
2025-07-22 10:46 ` [PATCH iwl-next v1 15/15] ixgbe: fwlog support for e610 Michal Swiatkowski
@ 2025-07-23 0:45 ` kernel test robot
0 siblings, 0 replies; 29+ messages in thread
From: kernel test robot @ 2025-07-23 0:45 UTC (permalink / raw)
To: Michal Swiatkowski, intel-wired-lan
Cc: llvm, oe-kbuild-all, netdev, przemyslaw.kitszel, dawid.osuchowski,
Michal Swiatkowski
Hi Michal,
kernel test robot noticed the following build errors:
[auto build test ERROR on tnguy-next-queue/dev-queue]
url: https://github.com/intel-lab-lkp/linux/commits/Michal-Swiatkowski/ice-make-fwlog-functions-static/20250722-191011
base: https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git dev-queue
patch link: https://lore.kernel.org/r/20250722104600.10141-16-michal.swiatkowski%40linux.intel.com
patch subject: [Intel-wired-lan] [PATCH iwl-next v1 15/15] ixgbe: fwlog support for e610
config: powerpc-randconfig-002-20250722 (https://download.01.org/0day-ci/archive/20250723/202507230823.PGjL5fXz-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 853c343b45b3e83cc5eeef5a52fc8cc9d8a09252)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/202507230823.PGjL5fXz-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507230823.PGjL5fXz-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "libie_aq_str" [drivers/net/ethernet/intel/i40e/i40e.ko] undefined!
>> ERROR: modpost: "libie_aq_str" [drivers/net/ethernet/intel/iavf/iavf.ko] undefined!
>> ERROR: modpost: "libie_aq_str" [drivers/net/ethernet/intel/ice/ice.ko] undefined!
>> ERROR: modpost: "libie_get_fwlog_data" [drivers/net/ethernet/intel/ice/ice.ko] undefined!
>> ERROR: modpost: "libie_fwlog_init" [drivers/net/ethernet/intel/ice/ice.ko] undefined!
>> ERROR: modpost: "libie_fwlog_deinit" [drivers/net/ethernet/intel/ice/ice.ko] undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH iwl-next v1 00/15] Fwlog support in ixgbe
2025-07-22 10:45 [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Michal Swiatkowski
` (14 preceding siblings ...)
2025-07-22 10:46 ` [PATCH iwl-next v1 15/15] ixgbe: fwlog support for e610 Michal Swiatkowski
@ 2025-07-23 12:12 ` Jiri Pirko
2025-07-23 12:48 ` Michal Swiatkowski
15 siblings, 1 reply; 29+ messages in thread
From: Jiri Pirko @ 2025-07-23 12:12 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: intel-wired-lan, netdev, przemyslaw.kitszel, dawid.osuchowski
Tue, Jul 22, 2025 at 12:45:45PM +0200, michal.swiatkowski@linux.intel.com wrote:
>Hi,
>
>Firmware logging is a feature that allow user to dump firmware log using
>debugfs interface. It is supported on device that can handle specific
Did you consider using devlink health reporter for dumping this?
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH iwl-next v1 00/15] Fwlog support in ixgbe
2025-07-23 12:12 ` [PATCH iwl-next v1 00/15] Fwlog support in ixgbe Jiri Pirko
@ 2025-07-23 12:48 ` Michal Swiatkowski
0 siblings, 0 replies; 29+ messages in thread
From: Michal Swiatkowski @ 2025-07-23 12:48 UTC (permalink / raw)
To: Jiri Pirko
Cc: Michal Swiatkowski, intel-wired-lan, netdev, przemyslaw.kitszel,
dawid.osuchowski
On Wed, Jul 23, 2025 at 02:12:56PM +0200, Jiri Pirko wrote:
> Tue, Jul 22, 2025 at 12:45:45PM +0200, michal.swiatkowski@linux.intel.com wrote:
> >Hi,
> >
> >Firmware logging is a feature that allow user to dump firmware log using
> >debugfs interface. It is supported on device that can handle specific
>
> Did you consider using devlink health reporter for dumping this?
This is only moving already implemented code to the lib to reuse it in
another driver (which supports the same interface).
First implementation was added here [1]. And there was a discussion
about using devlink for it [2].
[1] https://lore.kernel.org/netdev/20230810170109.1963832-1-anthony.l.nguyen@intel.com/
[2] https://lore.kernel.org/netdev/fea3e7bc-db75-ce15-1330-d80483267ee2@intel.com/
^ permalink raw reply [flat|nested] 29+ messages in thread