drivers/infiniband/hw/mlx5/mad.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/mad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/mad.c- Extension
.c- Size
- 19701 bytes
- Lines
- 714
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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
linux/mlx5/vport.hrdma/ib_mad.hrdma/ib_smi.hrdma/ib_pma.hmlx5_ib.hcmd.h
Detected Declarations
function can_do_mad_ifcfunction mlx5_MAD_IFCfunction pma_cnt_ext_assignfunction pma_cnt_assignfunction pma_cnt_ext_assign_ppcntfunction query_ib_ppcntfunction process_pma_cmdfunction mlx5_ib_process_madfunction mlx5_query_ext_port_capsfunction mlx5_query_mad_ifc_smp_attr_node_infofunction mlx5_query_mad_ifc_system_image_guidfunction mlx5_query_mad_ifc_max_pkeysfunction mlx5_query_mad_ifc_vendor_idfunction mlx5_query_mad_ifc_node_descfunction mlx5_query_mad_ifc_node_guidfunction mlx5_query_mad_ifc_pkeyfunction mlx5_query_mad_ifc_gidsfunction mlx5_query_mad_ifc_port
Annotated Snippet
if (!out_cnt) {
err = IB_MAD_RESULT_FAILURE;
goto done;
}
if (dev->ib_dev.type == RDMA_DEVICE_TYPE_SMI) {
err = query_ib_ppcnt(mdev, mdev_port_num,
port_num, out_cnt, sz, 1);
if (!err)
pma_cnt_ext_assign_ppcnt(pma_cnt_ext, out_cnt);
} else {
err = mlx5_core_query_vport_counter(mdev, 0, 0,
mdev_port_num,
out_cnt);
if (!err)
pma_cnt_ext_assign(pma_cnt_ext, out_cnt);
}
} else {
struct ib_pma_portcounters *pma_cnt =
(struct ib_pma_portcounters *)(out_mad->data + 40);
int sz = MLX5_ST_SZ_BYTES(ppcnt_reg);
out_cnt = kvzalloc(sz, GFP_KERNEL);
if (!out_cnt) {
err = IB_MAD_RESULT_FAILURE;
goto done;
}
if (dev->ib_dev.type == RDMA_DEVICE_TYPE_SMI)
err = query_ib_ppcnt(mdev, mdev_port_num, port_num,
out_cnt, sz, 0);
else
err = query_ib_ppcnt(mdev, mdev_port_num, 0,
out_cnt, sz, 0);
if (!err)
pma_cnt_assign(pma_cnt, out_cnt);
}
kvfree(out_cnt);
err = err ? IB_MAD_RESULT_FAILURE :
IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
done:
if (native_port)
mlx5_ib_put_native_port_mdev(dev, port_num);
return err;
}
int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u32 port_num,
const struct ib_wc *in_wc, const struct ib_grh *in_grh,
const struct ib_mad *in, struct ib_mad *out,
size_t *out_mad_size, u16 *out_mad_pkey_index)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
u8 mgmt_class = in->mad_hdr.mgmt_class;
u8 method = in->mad_hdr.method;
u16 slid;
int err;
slid = in_wc ? ib_lid_cpu16(in_wc->slid) :
be16_to_cpu(IB_LID_PERMISSIVE);
if (method == IB_MGMT_METHOD_TRAP && !slid)
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
switch (mgmt_class) {
case IB_MGMT_CLASS_SUBN_LID_ROUTED:
case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE: {
if (method != IB_MGMT_METHOD_GET &&
method != IB_MGMT_METHOD_SET &&
method != IB_MGMT_METHOD_TRAP_REPRESS)
return IB_MAD_RESULT_SUCCESS;
/* Don't process SMInfo queries -- the SMA can't handle them.
*/
if (in->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
return IB_MAD_RESULT_SUCCESS;
} break;
case IB_MGMT_CLASS_PERF_MGMT:
if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
method == IB_MGMT_METHOD_GET)
return process_pma_cmd(dev, port_num, in, out);
fallthrough;
case MLX5_IB_VENDOR_CLASS1:
case MLX5_IB_VENDOR_CLASS2:
case IB_MGMT_CLASS_CONG_MGMT: {
if (method != IB_MGMT_METHOD_GET &&
method != IB_MGMT_METHOD_SET)
return IB_MAD_RESULT_SUCCESS;
} break;
default:
Annotation
- Immediate include surface: `linux/mlx5/vport.h`, `rdma/ib_mad.h`, `rdma/ib_smi.h`, `rdma/ib_pma.h`, `mlx5_ib.h`, `cmd.h`.
- Detected declarations: `function can_do_mad_ifc`, `function mlx5_MAD_IFC`, `function pma_cnt_ext_assign`, `function pma_cnt_assign`, `function pma_cnt_ext_assign_ppcnt`, `function query_ib_ppcnt`, `function process_pma_cmd`, `function mlx5_ib_process_mad`, `function mlx5_query_ext_port_caps`, `function mlx5_query_mad_ifc_smp_attr_node_info`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.