/* create a define that has an extra module that doesn't really exist. this *issowecanaddamodule'all'toeasilyenable/disableallthemodules
*/ #define ICE_NR_FW_LOG_MODULES (ICE_AQC_FW_LOG_ID_MAX + 1)
/* the ordering in this array is important. it matches the ordering of the *valuesintheFWsotheindexisthesamevalueasinice_aqc_fw_logging_mod
*/ staticconstchar * 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 *valuesintheFWsotheindexisthesamevalueasinice_fwlog_level
*/ staticconstchar * const ice_fwlog_level_string[] = { "none", "error", "warning", "normal", "verbose",
};
staticint ice_find_module_by_dentry(struct ice_pf *pf, 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]) {
module = i; break;
}
}
if (module != ICE_AQC_FW_LOG_ID_MAX) {
ice_pf_fwlog_update_module(pf, log_level, module);
} else { /* the module 'all' is a shortcut so that we can set *allofthemodulestothesamelevelquickly
*/ int i;
for (i = 0; i < ICE_AQC_FW_LOG_ID_MAX; i++)
ice_pf_fwlog_update_module(pf, log_level, i);
}
/* 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 < ICE_AQC_FW_LOG_MIN_RESOLUTION ||
nr_messages > ICE_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); return -EINVAL;
}
/* 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)
hw->fwlog_cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA; else
hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
ret = ice_fwlog_set(hw, &hw->fwlog_cfg); if (ret) goto enable_write_error;
if (enable)
ret = ice_fwlog_register(hw); else
ret = ice_fwlog_unregister(hw);
if (ret) goto enable_write_error;
/* if we get here, nothing went wrong; return count since we didn't *reallywriteanything
*/
ret = (ssize_t)count;
enable_write_error: /* This function always consumes all of the written input, or produces *anerror.Checkandenforcethis.Otherwise,thewriteoperation *won'tcompleteproperly.
*/ if (WARN_ON(ret != (ssize_t)count && ret >= 0))
ret = -EIO;
/* 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;
} elseif (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);
/* if we get here, nothing went wrong; return count since we didn't *reallywriteanything
*/
ret = (ssize_t)count;
log_size_write_error: /* This function always consumes all of the written input, or produces *anerror.Checkandenforcethis.Otherwise,thewriteoperation *won'tcompleteproperly.
*/ if (WARN_ON(ret != (ssize_t)count && ret >= 0))
ret = -EIO;
if (copy_to_user(buffer, log->data, cur_buf_len)) { /* if there is an error then bail and return whatever *thedriverhascopiedsofar
*/
done = true; continue;
}
/* any value is allowed to clear the buffer so no need to even look at *whatthevalueis
*/ 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; goto nr_buffs_write_error;
}
/* if we get here, nothing went wrong; return count since we didn't *reallywriteanything
*/
ret = (ssize_t)count;
nr_buffs_write_error: /* This function always consumes all of the written input, or produces *anerror.Checkandenforcethis.Otherwise,thewriteoperation *won'tcompleteproperly.
*/ if (WARN_ON(ret != (ssize_t)count && ret >= 0))
ret = -EIO;
/* 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 *needtounwind
*/
fw_modules = kcalloc(ICE_NR_FW_LOG_MODULES, sizeof(*fw_modules),
GFP_KERNEL); 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)) goto err_create_module_files;
fw_modules_dir = debugfs_create_dir("modules",
pf->ice_debugfs_pf_fwlog); 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,
&ice_debugfs_module_fops); if (IS_ERR(fw_modules[i])) goto err_create_module_files;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.