drivers/infiniband/hw/mlx4/mad.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx4/mad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx4/mad.c- Extension
.c- Size
- 68726 bytes
- Lines
- 2392
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
rdma/ib_mad.hrdma/ib_smi.hrdma/ib_sa.hrdma/ib_cache.hlinux/random.hlinux/mlx4/cmd.hlinux/gfp.hrdma/ib_pma.hlinux/ip.hnet/ipv6.hlinux/mlx4/driver.hmlx4_ib.h
Detected Declarations
struct mlx4_mad_rcv_bufstruct mlx4_mad_snd_bufstruct mlx4_tunnel_madstruct mlx4_rcv_tunnel_madfunction mlx4_ib_gen_node_guidfunction mlx4_ib_get_new_demux_tidfunction mlx4_MAD_IFCfunction update_sm_ahfunction smp_snoopfunction __propagate_pkey_evfunction node_desc_overridefunction forward_trapfunction mlx4_ib_demux_sa_handlerfunction mlx4_ib_find_real_gidfunction find_slave_port_pkey_ixfunction get_gids_from_l3_hdrfunction is_proxy_qp0function mlx4_ib_send_to_slavefunction mlx4_ib_demux_madfunction ib_process_madfunction edit_counterfunction iboe_process_mad_port_infofunction iboe_process_madfunction mlx4_ib_process_madfunction send_handlerfunction mlx4_ib_mad_initfunction mlx4_ib_mad_cleanupfunction handle_lid_change_eventfunction handle_client_rereg_eventfunction propagate_pkey_evfunction handle_slaves_guid_changefunction handle_port_mgmt_change_eventfunction mlx4_ib_dispatch_eventfunction mlx4_ib_tunnel_comp_handlerfunction mlx4_ib_wire_comp_handlerfunction mlx4_ib_post_pv_qp_buffunction mlx4_ib_multiplex_sa_handlerfunction mlx4_ib_send_to_wirefunction get_slave_base_gid_ixfunction fill_in_real_sgid_indexfunction mlx4_ib_multiplex_madfunction mlx4_ib_alloc_pv_bufsfunction mlx4_ib_free_pv_qp_bufsfunction mlx4_ib_tunnel_comp_workerfunction pv_qp_event_handlerfunction create_pv_sqpfunction mlx4_ib_sqp_comp_workerfunction alloc_pv_object
Annotated Snippet
struct mlx4_mad_rcv_buf {
struct ib_grh grh;
u8 payload[256];
} __packed;
struct mlx4_mad_snd_buf {
u8 payload[256];
} __packed;
struct mlx4_tunnel_mad {
struct ib_grh grh;
struct mlx4_ib_tunnel_header hdr;
struct ib_mad mad;
} __packed;
struct mlx4_rcv_tunnel_mad {
struct mlx4_rcv_tunnel_hdr hdr;
struct ib_grh grh;
struct ib_mad mad;
} __packed;
static void handle_client_rereg_event(struct mlx4_ib_dev *dev, u32 port_num);
static void handle_lid_change_event(struct mlx4_ib_dev *dev, u32 port_num);
static void __propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
int block, u32 change_bitmap);
__be64 mlx4_ib_gen_node_guid(void)
{
#define NODE_GUID_HI ((u64) (((u64)IB_OPENIB_OUI) << 40))
return cpu_to_be64(NODE_GUID_HI | get_random_u32());
}
__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
{
return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
cpu_to_be64(0xff00000000000000LL);
}
int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
int port, const struct ib_wc *in_wc,
const struct ib_grh *in_grh,
const void *in_mad, void *response_mad)
{
struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
void *inbox;
int err;
u32 in_modifier = port;
u8 op_modifier = 0;
inmailbox = mlx4_alloc_cmd_mailbox(dev->dev);
if (IS_ERR(inmailbox))
return PTR_ERR(inmailbox);
inbox = inmailbox->buf;
outmailbox = mlx4_alloc_cmd_mailbox(dev->dev);
if (IS_ERR(outmailbox)) {
mlx4_free_cmd_mailbox(dev->dev, inmailbox);
return PTR_ERR(outmailbox);
}
memcpy(inbox, in_mad, 256);
/*
* Key check traps can't be generated unless we have in_wc to
* tell us where to send the trap.
*/
if ((mad_ifc_flags & MLX4_MAD_IFC_IGNORE_MKEY) || !in_wc)
op_modifier |= 0x1;
if ((mad_ifc_flags & MLX4_MAD_IFC_IGNORE_BKEY) || !in_wc)
op_modifier |= 0x2;
if (mlx4_is_mfunc(dev->dev) &&
(mad_ifc_flags & MLX4_MAD_IFC_NET_VIEW || in_wc))
op_modifier |= 0x8;
if (in_wc) {
struct {
__be32 my_qpn;
u32 reserved1;
__be32 rqpn;
u8 sl;
u8 g_path;
u16 reserved2[2];
__be16 pkey;
u32 reserved3[11];
u8 grh[40];
} *ext_info;
memset(inbox + 256, 0, 256);
ext_info = inbox + 256;
Annotation
- Immediate include surface: `rdma/ib_mad.h`, `rdma/ib_smi.h`, `rdma/ib_sa.h`, `rdma/ib_cache.h`, `linux/random.h`, `linux/mlx4/cmd.h`, `linux/gfp.h`, `rdma/ib_pma.h`.
- Detected declarations: `struct mlx4_mad_rcv_buf`, `struct mlx4_mad_snd_buf`, `struct mlx4_tunnel_mad`, `struct mlx4_rcv_tunnel_mad`, `function mlx4_ib_gen_node_guid`, `function mlx4_ib_get_new_demux_tid`, `function mlx4_MAD_IFC`, `function update_sm_ah`, `function smp_snoop`, `function __propagate_pkey_ev`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.