drivers/net/ethernet/mellanox/mlx4/cmd.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/cmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/cmd.c- Extension
.c- Size
- 93133 bytes
- Lines
- 3423
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/sched.hlinux/slab.hlinux/export.hlinux/pci.hlinux/errno.hlinux/mlx4/cmd.hlinux/mlx4/device.hlinux/semaphore.hrdma/ib_smi.hlinux/delay.hlinux/etherdevice.hasm/io.hmlx4.hfw.hfw_qos.hmlx4_stats.h
Detected Declarations
struct mlx4_cmd_contextenum mlx4_vlan_transitionfunction mlx4_status_to_errnofunction mlx4_errno_to_statusfunction mlx4_internal_err_ret_valuefunction mlx4_closing_cmd_fatal_errorfunction mlx4_cmd_reset_flowfunction comm_pendingfunction mlx4_comm_cmd_postfunction mlx4_comm_cmd_pollfunction mlx4_comm_cmd_waitfunction mlx4_comm_cmdfunction cmd_pendingfunction mlx4_cmd_postfunction mlx4_slave_cmdfunction mlx4_cmd_pollfunction mlx4_cmd_eventfunction mlx4_cmd_waitfunction __mlx4_cmdfunction mlx4_ARM_COMM_CHANNELfunction mlx4_ACCESS_MEMfunction query_pkey_blockfunction get_full_pkey_tablefunction vf_port_statefunction mlx4_MAD_IFC_wrapperfunction verbsfunction mlx4_CMD_EPERM_wrapperfunction mlx4_DMA_wrapperfunction mlx4_master_process_vhcrfunction mlx4_master_immediate_activate_vlan_qosfunction mlx4_set_default_port_qosfunction mlx4_allocate_port_vppsfunction mlx4_master_activate_admin_statefunction for_each_set_bitfunction mlx4_master_deactivate_admin_statefunction for_each_set_bitfunction mlx4_master_do_cmdfunction mlx4_master_comm_channelfunction sync_togglesfunction mlx4_multi_func_initfunction mlx4_cmd_initfunction mlx4_report_internal_err_comm_eventfunction mlx4_multi_func_cleanupfunction mlx4_cmd_cleanupfunction commandsfunction pollingfunction mlx4_free_cmd_mailboxfunction mlx4_comm_get_version
Annotated Snippet
struct mlx4_cmd_context {
struct completion done;
int result;
int next;
u64 out_param;
u16 token;
u8 fw_status;
};
static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
struct mlx4_vhcr_cmd *in_vhcr);
static int mlx4_status_to_errno(u8 status)
{
static const int trans_table[] = {
[CMD_STAT_INTERNAL_ERR] = -EIO,
[CMD_STAT_BAD_OP] = -EPERM,
[CMD_STAT_BAD_PARAM] = -EINVAL,
[CMD_STAT_BAD_SYS_STATE] = -ENXIO,
[CMD_STAT_BAD_RESOURCE] = -EBADF,
[CMD_STAT_RESOURCE_BUSY] = -EBUSY,
[CMD_STAT_EXCEED_LIM] = -ENOMEM,
[CMD_STAT_BAD_RES_STATE] = -EBADF,
[CMD_STAT_BAD_INDEX] = -EBADF,
[CMD_STAT_BAD_NVMEM] = -EFAULT,
[CMD_STAT_ICM_ERROR] = -ENFILE,
[CMD_STAT_BAD_QP_STATE] = -EINVAL,
[CMD_STAT_BAD_SEG_PARAM] = -EFAULT,
[CMD_STAT_REG_BOUND] = -EBUSY,
[CMD_STAT_LAM_NOT_PRE] = -EAGAIN,
[CMD_STAT_BAD_PKT] = -EINVAL,
[CMD_STAT_BAD_SIZE] = -ENOMEM,
[CMD_STAT_MULTI_FUNC_REQ] = -EACCES,
};
if (status >= ARRAY_SIZE(trans_table) ||
(status != CMD_STAT_OK && trans_table[status] == 0))
return -EIO;
return trans_table[status];
}
static u8 mlx4_errno_to_status(int errno)
{
switch (errno) {
case -EPERM:
return CMD_STAT_BAD_OP;
case -EINVAL:
return CMD_STAT_BAD_PARAM;
case -ENXIO:
return CMD_STAT_BAD_SYS_STATE;
case -EBUSY:
return CMD_STAT_RESOURCE_BUSY;
case -ENOMEM:
return CMD_STAT_EXCEED_LIM;
case -ENFILE:
return CMD_STAT_ICM_ERROR;
default:
return CMD_STAT_INTERNAL_ERR;
}
}
static int mlx4_internal_err_ret_value(struct mlx4_dev *dev, u16 op,
u8 op_modifier)
{
switch (op) {
case MLX4_CMD_UNMAP_ICM:
case MLX4_CMD_UNMAP_ICM_AUX:
case MLX4_CMD_UNMAP_FA:
case MLX4_CMD_2RST_QP:
case MLX4_CMD_HW2SW_EQ:
case MLX4_CMD_HW2SW_CQ:
case MLX4_CMD_HW2SW_SRQ:
case MLX4_CMD_HW2SW_MPT:
case MLX4_CMD_CLOSE_HCA:
case MLX4_QP_FLOW_STEERING_DETACH:
case MLX4_CMD_FREE_RES:
case MLX4_CMD_CLOSE_PORT:
return CMD_STAT_OK;
case MLX4_CMD_QP_ATTACH:
/* On Detach case return success */
if (op_modifier == 0)
return CMD_STAT_OK;
return mlx4_status_to_errno(CMD_STAT_INTERNAL_ERR);
default:
return mlx4_status_to_errno(CMD_STAT_INTERNAL_ERR);
}
}
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/export.h`, `linux/pci.h`, `linux/errno.h`, `linux/mlx4/cmd.h`, `linux/mlx4/device.h`, `linux/semaphore.h`.
- Detected declarations: `struct mlx4_cmd_context`, `enum mlx4_vlan_transition`, `function mlx4_status_to_errno`, `function mlx4_errno_to_status`, `function mlx4_internal_err_ret_value`, `function mlx4_closing_cmd_fatal_error`, `function mlx4_cmd_reset_flow`, `function comm_pending`, `function mlx4_comm_cmd_post`, `function mlx4_comm_cmd_poll`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.