drivers/net/ethernet/mellanox/mlx5/core/vport.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/vport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/vport.c- Extension
.c- Size
- 40725 bytes
- Lines
- 1434
- 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.
- 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/export.hlinux/etherdevice.hlinux/mlx5/driver.hlinux/mlx5/vport.hlinux/mlx5/eswitch.hmlx5_core.heswitch.hsf/sf.h
Detected Declarations
enum mlx5_vport_roce_statefunction mlx5_query_vport_statefunction mlx5_query_vport_admin_statefunction mlx5_modify_vport_admin_statefunction mlx5_modify_vport_max_tx_speedfunction mlx5_query_vport_max_tx_speedfunction mlx5_query_nic_vport_contextfunction mlx5_query_nic_vport_min_inlinefunction mlx5_query_min_inlinefunction mlx5_modify_nic_vport_min_inlinefunction mlx5_query_nic_vport_mac_addressfunction mlx5_query_mac_addressfunction mlx5_modify_nic_vport_mac_addressfunction mlx5_query_nic_vport_mtufunction mlx5_modify_nic_vport_mtufunction mlx5_vport_max_mac_list_sizefunction mlx5_query_nic_vport_mac_listfunction mlx5_modify_nic_vport_mac_listfunction mlx5_modify_nic_vport_vlansfunction mlx5_query_nic_vport_system_image_guidfunction mlx5_query_nic_vport_sd_groupfunction mlx5_query_nic_vport_node_guidfunction mlx5_modify_nic_vport_node_guidfunction mlx5_query_nic_vport_qkey_viol_cntrfunction mlx5_query_hca_vport_gidfunction mlx5_query_hca_vport_pkeyfunction mlx5_query_hca_vport_contextfunction mlx5_query_hca_vport_system_image_guidfunction mlx5_query_hca_vport_node_guidfunction mlx5_query_nic_vport_promiscfunction mlx5_modify_nic_vport_promiscfunction mlx5_nic_vport_update_local_lbfunction mlx5_nic_vport_query_local_lbfunction mlx5_nic_vport_update_roce_statefunction mlx5_nic_vport_enable_rocefunction mlx5_nic_vport_disable_rocefunction mlx5_core_query_vport_counterfunction mlx5_query_vport_down_statsfunction mlx5_core_modify_hca_vport_contextfunction mlx5_nic_vport_affiliate_multiportfunction mlx5_nic_vport_unaffiliate_multiportfunction mlx5_query_nic_system_image_guidfunction mlx5_query_nic_sw_system_image_guidfunction mlx5_vport_use_vhca_id_as_func_idfunction mlx5_vport_get_other_func_capfunction mlx5_vport_get_vhca_idfunction mlx5_vport_set_other_func_capexport mlx5_query_vport_max_tx_speed
Annotated Snippet
if (is_group_manager) {
MLX5_SET(query_hca_vport_gid_in, in, vport_number, vf_num);
MLX5_SET(query_hca_vport_gid_in, in, other_vport, 1);
} else {
err = -EPERM;
goto out;
}
}
MLX5_SET(query_hca_vport_gid_in, in, gid_index, gid_index);
if (MLX5_CAP_GEN(dev, num_ports) == 2)
MLX5_SET(query_hca_vport_gid_in, in, port_num, port_num);
err = mlx5_cmd_exec(dev, in, in_sz, out, out_sz);
if (err)
goto out;
tmp = out + MLX5_ST_SZ_BYTES(query_hca_vport_gid_out);
gid->global.subnet_prefix = tmp->global.subnet_prefix;
gid->global.interface_id = tmp->global.interface_id;
out:
kvfree(in);
kvfree(out);
return err;
}
EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_gid);
int mlx5_query_hca_vport_pkey(struct mlx5_core_dev *dev, u8 other_vport,
u8 port_num, u16 vf_num, u16 pkey_index,
u16 *pkey)
{
int in_sz = MLX5_ST_SZ_BYTES(query_hca_vport_pkey_in);
int out_sz = MLX5_ST_SZ_BYTES(query_hca_vport_pkey_out);
int is_group_manager;
void *out = NULL;
void *in = NULL;
void *pkarr;
int nout;
int tbsz;
int err;
int i;
is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager);
tbsz = mlx5_to_sw_pkey_sz(MLX5_CAP_GEN(dev, pkey_table_size));
if (pkey_index > tbsz && pkey_index != 0xffff)
return -EINVAL;
if (pkey_index == 0xffff)
nout = tbsz;
else
nout = 1;
out_sz += nout * MLX5_ST_SZ_BYTES(pkey);
in = kvzalloc(in_sz, GFP_KERNEL);
out = kvzalloc(out_sz, GFP_KERNEL);
if (!in || !out) {
err = -ENOMEM;
goto out;
}
MLX5_SET(query_hca_vport_pkey_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_VPORT_PKEY);
if (other_vport) {
if (is_group_manager) {
MLX5_SET(query_hca_vport_pkey_in, in, vport_number, vf_num);
MLX5_SET(query_hca_vport_pkey_in, in, other_vport, 1);
} else {
err = -EPERM;
goto out;
}
}
MLX5_SET(query_hca_vport_pkey_in, in, pkey_index, pkey_index);
if (MLX5_CAP_GEN(dev, num_ports) == 2)
MLX5_SET(query_hca_vport_pkey_in, in, port_num, port_num);
err = mlx5_cmd_exec(dev, in, in_sz, out, out_sz);
if (err)
goto out;
pkarr = MLX5_ADDR_OF(query_hca_vport_pkey_out, out, pkey);
for (i = 0; i < nout; i++, pkey++, pkarr += MLX5_ST_SZ_BYTES(pkey))
*pkey = MLX5_GET_PR(pkey, pkarr, pkey);
out:
kvfree(in);
kvfree(out);
return err;
Annotation
- Immediate include surface: `linux/export.h`, `linux/etherdevice.h`, `linux/mlx5/driver.h`, `linux/mlx5/vport.h`, `linux/mlx5/eswitch.h`, `mlx5_core.h`, `eswitch.h`, `sf/sf.h`.
- Detected declarations: `enum mlx5_vport_roce_state`, `function mlx5_query_vport_state`, `function mlx5_query_vport_admin_state`, `function mlx5_modify_vport_admin_state`, `function mlx5_modify_vport_max_tx_speed`, `function mlx5_query_vport_max_tx_speed`, `function mlx5_query_nic_vport_context`, `function mlx5_query_nic_vport_min_inline`, `function mlx5_query_min_inline`, `function mlx5_modify_nic_vport_min_inline`.
- 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.