drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c- Extension
.c- Size
- 36848 bytes
- Lines
- 1262
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
lib/eq.hfw_tracer.hfw_tracer_tracepoint.hlinux/ctype.h
Detected Declarations
function Copyrightfunction mlx5_set_mtrc_caps_trace_ownerfunction mlx5_fw_tracer_ownership_acquirefunction mlx5_fw_tracer_ownership_releasefunction mlx5_fw_tracer_create_log_buffunction mlx5_fw_tracer_destroy_log_buffunction mlx5_fw_tracer_create_mkeyfunction mlx5_fw_tracer_free_strings_dbfunction mlx5_fw_tracer_allocate_strings_dbfunction mlx5_fw_tracer_init_saved_traces_arrayfunction mlx5_fw_tracer_clean_saved_traces_arrayfunction mlx5_tracer_read_strings_dbfunction mlx5_fw_tracer_armfunction mlx5_is_valid_specfunction mlx5_tracer_validate_paramsfunction mlx5_tracer_message_hashfunction mlx5_tracer_clean_messagefunction mlx5_tracer_get_num_of_paramsfunction poll_tracefunction get_block_timestampfunction mlx5_fw_tracer_clean_print_hashfunction mlx5_fw_tracer_clean_ready_listfunction mlx5_fw_tracer_save_tracefunction mlx5_tracer_print_tracefunction mlx5_tracer_handle_raw_stringfunction mlx5_tracer_handle_bad_format_stringfunction mlx5_tracer_handle_string_tracefunction mlx5_tracer_handle_timestamp_tracefunction list_for_each_entry_safefunction mlx5_tracer_handle_tracefunction mlx5_fw_tracer_handle_tracesfunction mlx5_fw_tracer_set_mtrc_conffunction mlx5_fw_tracer_set_mtrc_ctrlfunction mlx5_fw_tracer_startfunction mlx5_fw_tracer_ownership_changefunction mlx5_fw_tracer_set_core_dump_regfunction mlx5_fw_tracer_trigger_core_dump_generalfunction mlx5_devlink_fmsg_fill_tracefunction mlx5_fw_tracer_get_saved_traces_objectsfunction mlx5_fw_tracer_update_dbfunction mlx5_fw_tracer_initfunction mlx5_fw_tracer_cleanupfunction mlx5_fw_tracer_destroyfunction mlx5_fw_tracer_recreate_strings_dbfunction mlx5_fw_tracer_reloadfunction fw_tracer_event
Annotated Snippet
if (err) {
mlx5_core_dbg(dev, "FWTracer: Failed to read strings DB %d\n",
err);
goto out_free;
}
out_value = MLX5_ADDR_OF(mtrc_stdb, out, string_db_data);
memcpy(tracer->str_db.buffer[i] + offset, out_value,
STRINGS_DB_READ_SIZE_BYTES);
offset += STRINGS_DB_READ_SIZE_BYTES;
}
/* Strings database is aligned to 64, need to read leftovers*/
MLX5_SET(mtrc_stdb, in, read_size,
STRINGS_DB_LEFTOVER_SIZE_BYTES);
for (j = 0; j < leftovers; j++) {
MLX5_SET(mtrc_stdb, in, start_offset, offset);
err = mlx5_core_access_reg(dev, in, sizeof(in), out,
outlen, MLX5_REG_MTRC_STDB,
0, 1);
if (err) {
mlx5_core_dbg(dev, "FWTracer: Failed to read strings DB %d\n",
err);
goto out_free;
}
out_value = MLX5_ADDR_OF(mtrc_stdb, out, string_db_data);
memcpy(tracer->str_db.buffer[i] + offset, out_value,
STRINGS_DB_LEFTOVER_SIZE_BYTES);
offset += STRINGS_DB_LEFTOVER_SIZE_BYTES;
}
}
tracer->str_db.loaded = true;
out_free:
kfree(out);
out:
return;
}
static void mlx5_fw_tracer_arm(struct mlx5_core_dev *dev)
{
u32 out[MLX5_ST_SZ_DW(mtrc_ctrl)] = {0};
u32 in[MLX5_ST_SZ_DW(mtrc_ctrl)] = {0};
int err;
MLX5_SET(mtrc_ctrl, in, arm_event, 1);
err = mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out),
MLX5_REG_MTRC_CTRL, 0, 1);
if (err)
mlx5_core_warn(dev, "FWTracer: Failed to arm tracer event %d\n", err);
}
static const char *VAL_PARM = "%llx";
static const char *REPLACE_64_VAL_PARM = "%x%x";
static const char *PARAM_CHAR = "%";
static bool mlx5_is_valid_spec(const char *str)
{
/* Parse format specifiers to find the actual type.
* Structure: %[flags][width][.precision][length]type
* Skip flags, width, precision & length.
*/
while (isdigit(*str) || *str == '#' || *str == '.' || *str == 'l')
str++;
/* Check if it's a valid integer/hex specifier or %%:
* Valid formats: %x, %d, %i, %u, etc.
*/
if (*str != 'x' && *str != 'X' && *str != 'd' && *str != 'i' &&
*str != 'u' && *str != 'c' && *str != '%')
return false;
return true;
}
static bool mlx5_tracer_validate_params(const char *str)
{
const char *substr = str;
if (!str)
return false;
substr = strstr(substr, PARAM_CHAR);
while (substr) {
if (!mlx5_is_valid_spec(substr + 1))
return false;
Annotation
- Immediate include surface: `lib/eq.h`, `fw_tracer.h`, `fw_tracer_tracepoint.h`, `linux/ctype.h`.
- Detected declarations: `function Copyright`, `function mlx5_set_mtrc_caps_trace_owner`, `function mlx5_fw_tracer_ownership_acquire`, `function mlx5_fw_tracer_ownership_release`, `function mlx5_fw_tracer_create_log_buf`, `function mlx5_fw_tracer_destroy_log_buf`, `function mlx5_fw_tracer_create_mkey`, `function mlx5_fw_tracer_free_strings_db`, `function mlx5_fw_tracer_allocate_strings_db`, `function mlx5_fw_tracer_init_saved_traces_array`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.