drivers/infiniband/core/smi.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/smi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/smi.c- Extension
.c- Size
- 10123 bytes
- Lines
- 339
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
rdma/ib_smi.hsmi.hopa_smi.h
Detected Declarations
function Copyrightfunction smi_handle_dr_smp_sendfunction opa_smi_handle_dr_smp_sendfunction __smi_handle_dr_smp_recvfunction smi_handle_dr_smp_recvfunction opa_smi_handle_dr_smp_recvfunction __smi_check_forward_dr_smpfunction smi_check_forward_dr_smpfunction opa_smi_check_forward_dr_smpfunction smi_get_fwd_portfunction opa_smi_get_fwd_port
Annotated Snippet
if (hop_cnt && *hop_ptr == 0) {
(*hop_ptr)++;
return (initial_path[*hop_ptr] ==
port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
}
/* C14-9:2 */
if (*hop_ptr && *hop_ptr < hop_cnt) {
if (!is_switch)
return IB_SMI_DISCARD;
/* return_path set when received */
(*hop_ptr)++;
return (initial_path[*hop_ptr] ==
port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
}
/* C14-9:3 -- We're at the end of the DR segment of path */
if (*hop_ptr == hop_cnt) {
/* return_path set when received */
(*hop_ptr)++;
return (is_switch ||
dr_dlid_is_permissive ?
IB_SMI_HANDLE : IB_SMI_DISCARD);
}
/* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
/* C14-9:5 -- Fail unreasonable hop pointer */
return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
} else {
/* C14-13:1 */
if (hop_cnt && *hop_ptr == hop_cnt + 1) {
(*hop_ptr)--;
return (return_path[*hop_ptr] ==
port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
}
/* C14-13:2 */
if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
if (!is_switch)
return IB_SMI_DISCARD;
(*hop_ptr)--;
return (return_path[*hop_ptr] ==
port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
}
/* C14-13:3 -- at the end of the DR segment of path */
if (*hop_ptr == 1) {
(*hop_ptr)--;
/* C14-13:3 -- SMPs destined for SM shouldn't be here */
return (is_switch ||
dr_slid_is_permissive ?
IB_SMI_HANDLE : IB_SMI_DISCARD);
}
/* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */
if (*hop_ptr == 0)
return IB_SMI_HANDLE;
/* C14-13:5 -- Check for unreasonable hop pointer */
return IB_SMI_DISCARD;
}
}
/*
* Fixup a directed route SMP for sending
* Return IB_SMI_DISCARD if the SMP should be discarded
*/
enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
bool is_switch, u32 port_num)
{
return __smi_handle_dr_smp_send(is_switch, port_num,
&smp->hop_ptr, smp->hop_cnt,
smp->initial_path,
smp->return_path,
ib_get_smp_direction(smp),
smp->dr_dlid == IB_LID_PERMISSIVE,
smp->dr_slid == IB_LID_PERMISSIVE);
}
enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp,
bool is_switch, u32 port_num)
{
return __smi_handle_dr_smp_send(is_switch, port_num,
&smp->hop_ptr, smp->hop_cnt,
smp->route.dr.initial_path,
smp->route.dr.return_path,
opa_get_smp_direction(smp),
Annotation
- Immediate include surface: `rdma/ib_smi.h`, `smi.h`, `opa_smi.h`.
- Detected declarations: `function Copyright`, `function smi_handle_dr_smp_send`, `function opa_smi_handle_dr_smp_send`, `function __smi_handle_dr_smp_recv`, `function smi_handle_dr_smp_recv`, `function opa_smi_handle_dr_smp_recv`, `function __smi_check_forward_dr_smp`, `function smi_check_forward_dr_smp`, `function opa_smi_check_forward_dr_smp`, `function smi_get_fwd_port`.
- 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.