drivers/net/ethernet/mellanox/mlx5/core/port.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/port.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/port.c- Extension
.c- Size
- 34367 bytes
- Lines
- 1263
- 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.
- 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/mlx5/port.hmlx5_core.h
Detected Declarations
struct mlx5_reg_pcapfunction Copyrightfunction mlx5_core_access_regfunction mlx5_query_pcam_regfunction mlx5_query_mcam_regfunction mlx5_query_qcam_regfunction mlx5_set_port_capsfunction mlx5_query_port_ptysfunction mlx5_set_port_beaconfunction mlx5_query_ib_port_operfunction mlx5_toggle_port_linkfunction mlx5_set_port_admin_statusfunction mlx5_query_port_admin_statusfunction mlx5_query_port_mtufunction mlx5_set_port_mtufunction mlx5_query_port_max_mtufunction mlx5_query_port_oper_mtufunction mlx5_query_module_numfunction mlx5_query_module_idfunction mlx5_qsfp_eeprom_pagefunction mlx5_qsfp_eeprom_high_page_offsetfunction mlx5_qsfp_eeprom_params_setfunction mlx5_sfp_eeprom_params_setfunction mlx5_mcia_max_bytesfunction mlx5_query_mciafunction mlx5_query_module_eepromfunction mlx5_query_module_eeprom_by_pagefunction mlx5_query_port_pvlcfunction mlx5_query_port_vl_hw_capfunction mlx5_query_pfcc_regfunction mlx5_set_port_pausefunction mlx5_query_port_pausefunction mlx5_set_port_stall_watermarkfunction mlx5_query_port_stall_watermarkfunction mlx5_set_port_pfcfunction mlx5_query_port_pfcfunction mlx5_max_tcfunction mlx5_query_port_dcbx_paramfunction mlx5_set_port_dcbx_paramfunction mlx5_set_port_prio_tcfunction mlx5_query_port_prio_tcfunction mlx5_set_port_qetcr_regfunction mlx5_query_port_qetcr_regfunction mlx5_set_port_tc_groupfunction mlx5_query_port_tc_groupfunction mlx5_set_port_tc_bw_allocfunction mlx5_query_port_tc_bw_allocfunction mlx5_modify_port_ets_rate_limit
Annotated Snippet
struct mlx5_reg_pcap {
u8 rsvd0;
u8 port_num;
u8 rsvd1[2];
__be32 caps_127_96;
__be32 caps_95_64;
__be32 caps_63_32;
__be32 caps_31_0;
};
int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps)
{
struct mlx5_reg_pcap in;
struct mlx5_reg_pcap out;
memset(&in, 0, sizeof(in));
in.caps_127_96 = cpu_to_be32(caps);
in.port_num = port_num;
return mlx5_core_access_reg(dev, &in, sizeof(in), &out,
sizeof(out), MLX5_REG_PCAP, 0, 1);
}
EXPORT_SYMBOL_GPL(mlx5_set_port_caps);
int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
int ptys_size, int proto_mask,
u8 local_port, u8 plane_index)
{
u32 in[MLX5_ST_SZ_DW(ptys_reg)] = {0};
MLX5_SET(ptys_reg, in, local_port, local_port);
MLX5_SET(ptys_reg, in, plane_ind, plane_index);
MLX5_SET(ptys_reg, in, proto_mask, proto_mask);
return mlx5_core_access_reg(dev, in, sizeof(in), ptys,
ptys_size, MLX5_REG_PTYS, 0, 0);
}
EXPORT_SYMBOL_GPL(mlx5_query_port_ptys);
int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration)
{
u32 in[MLX5_ST_SZ_DW(mlcr_reg)] = {0};
u32 out[MLX5_ST_SZ_DW(mlcr_reg)];
MLX5_SET(mlcr_reg, in, local_port, 1);
MLX5_SET(mlcr_reg, in, beacon_duration, beacon_duration);
return mlx5_core_access_reg(dev, in, sizeof(in), out,
sizeof(out), MLX5_REG_MLCR, 0, 1);
}
int mlx5_query_ib_port_oper(struct mlx5_core_dev *dev, u16 *link_width_oper,
u16 *proto_oper, u8 local_port, u8 plane_index)
{
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
int err;
err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_IB,
local_port, plane_index);
if (err)
return err;
*link_width_oper = MLX5_GET(ptys_reg, out, ib_link_width_oper);
*proto_oper = MLX5_GET(ptys_reg, out, ib_proto_oper);
return 0;
}
EXPORT_SYMBOL(mlx5_query_ib_port_oper);
/* This function should be used after setting a port register only */
void mlx5_toggle_port_link(struct mlx5_core_dev *dev)
{
enum mlx5_port_status ps;
mlx5_query_port_admin_status(dev, &ps);
mlx5_set_port_admin_status(dev, MLX5_PORT_DOWN);
if (ps == MLX5_PORT_UP)
mlx5_set_port_admin_status(dev, MLX5_PORT_UP);
}
int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
enum mlx5_port_status status)
{
u32 in[MLX5_ST_SZ_DW(paos_reg)] = {0};
u32 out[MLX5_ST_SZ_DW(paos_reg)];
MLX5_SET(paos_reg, in, local_port, 1);
MLX5_SET(paos_reg, in, admin_status, status);
MLX5_SET(paos_reg, in, ase, 1);
return mlx5_core_access_reg(dev, in, sizeof(in), out,
sizeof(out), MLX5_REG_PAOS, 0, 1);
}
Annotation
- Immediate include surface: `linux/mlx5/port.h`, `mlx5_core.h`.
- Detected declarations: `struct mlx5_reg_pcap`, `function Copyright`, `function mlx5_core_access_reg`, `function mlx5_query_pcam_reg`, `function mlx5_query_mcam_reg`, `function mlx5_query_qcam_reg`, `function mlx5_set_port_caps`, `function mlx5_query_port_ptys`, `function mlx5_set_port_beacon`, `function mlx5_query_ib_port_oper`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
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.