drivers/net/ethernet/mellanox/mlx5/core/en/port.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/port.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/port.c- Extension
.c- Size
- 17827 bytes
- Lines
- 603
- 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.
- 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
port.h
Detected Declarations
enum mlx5e_fec_supported_link_modefunction Copyrightfunction mlx5_port_set_eth_ptysfunction mlx5e_port_linkspeedfunction mlx5e_port_query_pbmcfunction mlx5e_port_set_pbmcfunction mlx5e_port_query_sbprfunction mlx5e_port_set_sbprfunction mlx5e_port_query_sbcmfunction mlx5e_port_set_sbcmfunction mlx5e_port_query_priority2bufferfunction mlx5e_port_set_priority2bufferfunction mlx5e_is_fec_supported_link_modefunction mlx5e_fec_admin_fieldfunction mlx5e_get_fec_cap_fieldfunction mlx5e_fec_in_capsfunction mlx5e_get_fec_modefunction mlx5e_remap_fec_conf_modefunction mlx5e_set_fec_mode
Annotated Snippet
#include "port.h"
void mlx5_port_query_eth_autoneg(struct mlx5_core_dev *dev, u8 *an_status,
u8 *an_disable_cap, u8 *an_disable_admin)
{
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
*an_status = 0;
*an_disable_cap = 0;
*an_disable_admin = 0;
if (mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN, 1, 0))
return;
*an_status = MLX5_GET(ptys_reg, out, an_status);
*an_disable_cap = MLX5_GET(ptys_reg, out, an_disable_cap);
*an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin);
}
int mlx5_port_set_eth_ptys(struct mlx5_core_dev *dev, bool an_disable,
u32 proto_admin, bool ext)
{
u32 out[MLX5_ST_SZ_DW(ptys_reg)];
u32 in[MLX5_ST_SZ_DW(ptys_reg)];
u8 an_disable_admin;
u8 an_disable_cap;
u8 an_status;
mlx5_port_query_eth_autoneg(dev, &an_status, &an_disable_cap,
&an_disable_admin);
if (!an_disable_cap && an_disable)
return -EPERM;
memset(in, 0, sizeof(in));
MLX5_SET(ptys_reg, in, local_port, 1);
MLX5_SET(ptys_reg, in, an_disable_admin, an_disable);
MLX5_SET(ptys_reg, in, proto_mask, MLX5_PTYS_EN);
if (ext)
MLX5_SET(ptys_reg, in, ext_eth_proto_admin, proto_admin);
else
MLX5_SET(ptys_reg, in, eth_proto_admin, proto_admin);
return mlx5_core_access_reg(dev, in, sizeof(in), out,
sizeof(out), MLX5_REG_PTYS, 0, 1);
}
int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)
{
struct mlx5_port_eth_proto eproto;
const struct mlx5_link_info *info;
bool force_legacy = false;
bool ext;
int err;
ext = mlx5_ptys_ext_supported(mdev);
err = mlx5_port_query_eth_proto(mdev, 1, ext, &eproto);
if (err)
goto out;
if (ext && !eproto.admin) {
force_legacy = true;
err = mlx5_port_query_eth_proto(mdev, 1, false, &eproto);
if (err)
goto out;
}
info = mlx5_port_ptys2info(mdev, eproto.oper, force_legacy);
if (!info) {
*speed = SPEED_UNKNOWN;
err = -EINVAL;
goto out;
}
*speed = info->speed;
out:
return err;
}
int mlx5e_port_query_pbmc(struct mlx5_core_dev *mdev, void *out)
{
int sz = MLX5_ST_SZ_BYTES(pbmc_reg);
void *in;
int err;
in = kzalloc(sz, GFP_KERNEL);
if (!in)
return -ENOMEM;
MLX5_SET(pbmc_reg, in, local_port, 1);
err = mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PBMC, 0, 0);
Annotation
- Immediate include surface: `port.h`.
- Detected declarations: `enum mlx5e_fec_supported_link_mode`, `function Copyright`, `function mlx5_port_set_eth_ptys`, `function mlx5e_port_linkspeed`, `function mlx5e_port_query_pbmc`, `function mlx5e_port_set_pbmc`, `function mlx5e_port_query_sbpr`, `function mlx5e_port_set_sbpr`, `function mlx5e_port_query_sbcm`, `function mlx5e_port_set_sbcm`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.