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) {
}
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
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;
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));
}
return -EINVAL;
}
- hw->fwlog_cfg.log_resolution = nr_messages;
+ hw->fwlog.cfg.log_resolution = nr_messages;
return count;
}
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));
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;
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));
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
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;
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;
/* 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;
/**
* 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;
* 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
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;
}
/**
/**
* 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.
* 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)
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);
}
/**
* 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;
}
/**
* 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;
/* 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);
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);
}
}
*/
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,
/**
* 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;
}
/**
* 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);
}
}