drivers/infiniband/hw/hfi1/mad.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/hfi1/mad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/hfi1/mad.c- Extension
.c- Size
- 140547 bytes
- Lines
- 4896
- 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.
- 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/net.hrdma/opa_addr.hhfi.hmad.htrace.hqp.h
Detected Declarations
struct trap_nodestruct lcb_datumstruct opa_pma_madstruct opa_port_status_reqstruct opa_port_status_rspstruct _vls_pctrsstruct opa_clear_port_statusstruct opa_aggregatestruct opa_port_data_counters_msgstruct _port_dctrsstruct _vls_dctrsstruct opa_port_error_counters64_msgstruct _port_ectrsstruct _vls_ectrsstruct opa_port_error_info_msgstruct _port_eistruct opa_congestion_info_attrstruct opa_led_infoenum counter_selectsenum error_info_selectsfunction smp_length_checkfunction replyfunction clear_opa_smp_datafunction hfi1_lookup_pkey_valuefunction hfi1_event_pkey_changefunction cleanup_trapsfunction list_for_each_entry_safefunction list_for_each_entryfunction subn_handle_opa_trap_repressfunction hfi1_update_sm_ah_attrfunction hfi1_modify_qp0_ahfunction send_trapfunction hfi1_handle_trap_timerfunction trapfunction trapfunction trapfunction trapfunction trapfunction __subn_get_opa_nodedescfunction __subn_get_opa_nodeinfofunction smp_length_checkfunction subn_get_nodeinfofunction get_sguidfunction set_link_width_enabledfunction set_link_width_downgrade_enabledfunction set_link_speed_enabledfunction check_mkeyfunction time_after_eq
Annotated Snippet
struct trap_node {
struct list_head list;
struct opa_mad_notice_attr data;
__be64 tid;
int len;
u32 retry;
u8 in_use;
u8 repress;
};
static int smp_length_check(u32 data_size, u32 request_len)
{
if (unlikely(request_len < data_size))
return -EINVAL;
return 0;
}
static int reply(struct ib_mad_hdr *smp)
{
/*
* The verbs framework will handle the directed/LID route
* packet changes.
*/
smp->method = IB_MGMT_METHOD_GET_RESP;
if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
smp->status |= IB_SMP_DIRECTION;
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
}
static inline void clear_opa_smp_data(struct opa_smp *smp)
{
void *data = opa_get_smp_data(smp);
size_t size = opa_get_smp_data_size(smp);
memset(data, 0, size);
}
static u16 hfi1_lookup_pkey_value(struct hfi1_ibport *ibp, int pkey_idx)
{
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
if (pkey_idx < ARRAY_SIZE(ppd->pkeys))
return ppd->pkeys[pkey_idx];
return 0;
}
void hfi1_event_pkey_change(struct hfi1_devdata *dd, u32 port)
{
struct ib_event event;
event.event = IB_EVENT_PKEY_CHANGE;
event.device = &dd->verbs_dev.rdi.ibdev;
event.element.port_num = port;
ib_dispatch_event(&event);
}
/*
* If the port is down, clean up all pending traps. We need to be careful
* with the given trap, because it may be queued.
*/
static void cleanup_traps(struct hfi1_ibport *ibp, struct trap_node *trap)
{
struct trap_node *node, *q;
unsigned long flags;
struct list_head trap_list;
int i;
for (i = 0; i < RVT_MAX_TRAP_LISTS; i++) {
spin_lock_irqsave(&ibp->rvp.lock, flags);
list_replace_init(&ibp->rvp.trap_lists[i].list, &trap_list);
ibp->rvp.trap_lists[i].list_len = 0;
spin_unlock_irqrestore(&ibp->rvp.lock, flags);
/*
* Remove all items from the list, freeing all the non-given
* traps.
*/
list_for_each_entry_safe(node, q, &trap_list, list) {
list_del(&node->list);
if (node != trap)
kfree(node);
}
}
/*
* If this wasn't on one of the lists it would not be freed. If it
* was on the list, it is now safe to free.
*/
Annotation
- Immediate include surface: `linux/net.h`, `rdma/opa_addr.h`, `hfi.h`, `mad.h`, `trace.h`, `qp.h`.
- Detected declarations: `struct trap_node`, `struct lcb_datum`, `struct opa_pma_mad`, `struct opa_port_status_req`, `struct opa_port_status_rsp`, `struct _vls_pctrs`, `struct opa_clear_port_status`, `struct opa_aggregate`, `struct opa_port_data_counters_msg`, `struct _port_dctrs`.
- 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.
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.