drivers/net/ethernet/mellanox/mlx4/fw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/fw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/fw.c- Extension
.c- Size
- 102970 bytes
- Lines
- 3112
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/etherdevice.hlinux/mlx4/cmd.hlinux/module.hlinux/cache.hlinux/kernel.huapi/rdma/mlx4-abi.hfw.hicm.h
Detected Declarations
struct mlx4_config_devstruct mlx4_access_regenum mlx4_access_reg_masksenum mlx4_reg_idfunction dump_dev_cap_flagsfunction dump_dev_cap_flags2function mlx4_MOD_STAT_CFGfunction mlx4_QUERY_FUNCfunction mlx4_activate_vst_qinqfunction mlx4_handle_vst_qinqfunction mlx4_QUERY_FUNC_CAP_wrapperfunction mlx4_QUERY_FUNC_CAPfunction mlx4_QUERY_DEV_CAPfunction mlx4_dev_cap_dumpfunction mlx4_QUERY_PORTfunction mlx4_QUERY_DEV_CAP_wrapperfunction disable_unsupported_roce_capsfunction mlx4_QUERY_PORT_wrapperfunction mlx4_get_slave_pkey_gid_tbl_lenfunction mlx4_map_cmdfunction mlx4_icm_nextfunction mlx4_MAP_FAfunction mlx4_UNMAP_FAfunction mlx4_RUN_FWfunction mlx4_QUERY_FWfunction mlx4_QUERY_FW_wrapperfunction get_board_idfunction mlx4_QUERY_ADAPTERfunction mlx4_INIT_HCAfunction mlx4_QUERY_HCAfunction mlx4_hca_core_clock_updatefunction check_qp0_statefunction mlx4_INIT_PORT_wrapperfunction mlx4_INIT_PORTfunction mlx4_CLOSE_PORT_wrapperfunction mlx4_CLOSE_PORTfunction mlx4_CLOSE_HCAfunction mlx4_CONFIG_DEV_setfunction mlx4_CONFIG_DEV_getfunction mlx4_config_dev_retrievalfunction mlx4_config_vxlan_portfunction mlx4_disable_rx_port_checkfunction mlx4_config_roce_v2_portfunction mlx4_virt2phy_port_mapfunction mlx4_SET_ICM_SIZEfunction mlx4_NOPfunction mlx4_query_diag_countersfunction mlx4_get_phys_port_id
Annotated Snippet
struct mlx4_config_dev {
__be32 update_flags;
__be32 rsvd1[3];
__be16 vxlan_udp_dport;
__be16 rsvd2;
__be16 roce_v2_entropy;
__be16 roce_v2_udp_dport;
__be32 roce_flags;
__be32 rsvd4[25];
__be16 rsvd5;
u8 rsvd6;
u8 rx_checksum_val;
};
#define MLX4_VXLAN_UDP_DPORT (1 << 0)
#define MLX4_ROCE_V2_UDP_DPORT BIT(3)
#define MLX4_DISABLE_RX_PORT BIT(18)
static int mlx4_CONFIG_DEV_set(struct mlx4_dev *dev, struct mlx4_config_dev *config_dev)
{
int err;
struct mlx4_cmd_mailbox *mailbox;
mailbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
memcpy(mailbox->buf, config_dev, sizeof(*config_dev));
err = mlx4_cmd(dev, mailbox->dma, 0, 0, MLX4_CMD_CONFIG_DEV,
MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
mlx4_free_cmd_mailbox(dev, mailbox);
return err;
}
static int mlx4_CONFIG_DEV_get(struct mlx4_dev *dev, struct mlx4_config_dev *config_dev)
{
int err;
struct mlx4_cmd_mailbox *mailbox;
mailbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 1, MLX4_CMD_CONFIG_DEV,
MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
if (!err)
memcpy(config_dev, mailbox->buf, sizeof(*config_dev));
mlx4_free_cmd_mailbox(dev, mailbox);
return err;
}
/* Conversion between the HW values and the actual functionality.
* The value represented by the array index,
* and the functionality determined by the flags.
*/
static const u8 config_dev_csum_flags[] = {
[0] = 0,
[1] = MLX4_RX_CSUM_MODE_VAL_NON_TCP_UDP,
[2] = MLX4_RX_CSUM_MODE_VAL_NON_TCP_UDP |
MLX4_RX_CSUM_MODE_L4,
[3] = MLX4_RX_CSUM_MODE_L4 |
MLX4_RX_CSUM_MODE_IP_OK_IP_NON_TCP_UDP |
MLX4_RX_CSUM_MODE_MULTI_VLAN
};
int mlx4_config_dev_retrieval(struct mlx4_dev *dev,
struct mlx4_config_dev_params *params)
{
struct mlx4_config_dev config_dev = {0};
int err;
u8 csum_mask;
#define CONFIG_DEV_RX_CSUM_MODE_MASK 0x7
#define CONFIG_DEV_RX_CSUM_MODE_PORT1_BIT_OFFSET 0
#define CONFIG_DEV_RX_CSUM_MODE_PORT2_BIT_OFFSET 4
if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_CONFIG_DEV))
return -EOPNOTSUPP;
err = mlx4_CONFIG_DEV_get(dev, &config_dev);
if (err)
return err;
csum_mask = (config_dev.rx_checksum_val >> CONFIG_DEV_RX_CSUM_MODE_PORT1_BIT_OFFSET) &
CONFIG_DEV_RX_CSUM_MODE_MASK;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/mlx4/cmd.h`, `linux/module.h`, `linux/cache.h`, `linux/kernel.h`, `uapi/rdma/mlx4-abi.h`, `fw.h`, `icm.h`.
- Detected declarations: `struct mlx4_config_dev`, `struct mlx4_access_reg`, `enum mlx4_access_reg_masks`, `enum mlx4_reg_id`, `function dump_dev_cap_flags`, `function dump_dev_cap_flags2`, `function mlx4_MOD_STAT_CFG`, `function mlx4_QUERY_FUNC`, `function mlx4_activate_vst_qinq`, `function mlx4_handle_vst_qinq`.
- 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.
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.