drivers/net/ethernet/qlogic/qed/qed_roce.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qed/qed_roce.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qlogic/qed/qed_roce.c- Extension
.c- Size
- 33711 bytes
- Lines
- 1144
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hasm/byteorder.hlinux/bitops.hlinux/delay.hlinux/dma-mapping.hlinux/errno.hlinux/io.hlinux/kernel.hlinux/list.hlinux/module.hlinux/mutex.hlinux/pci.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/if_vlan.hqed.hqed_cxt.hqed_dcbx.hqed_hsi.hqed_hw.hqed_init_ops.hqed_int.hqed_ll2.hqed_mcp.hqed_reg_addr.hlinux/qed/qed_rdma_if.hqed_rdma.hqed_roce.hqed_sp.h
Detected Declarations
function qed_roce_async_eventfunction qed_roce_stopfunction qed_rdma_copy_gidsfunction qed_roce_mode_to_flavorfunction qed_roce_free_cid_pairfunction qed_roce_alloc_cidfunction qed_roce_set_real_cidfunction qed_roce_get_qp_tcfunction qed_roce_sp_create_responderfunction qed_roce_sp_create_requesterfunction qed_roce_sp_modify_responderfunction qed_roce_sp_modify_requesterfunction qed_roce_sp_destroy_qp_responderfunction qed_roce_sp_destroy_qp_requesterfunction qed_roce_query_qpfunction qed_roce_destroy_qpfunction qed_roce_modify_qpfunction qed_roce_free_real_icidfunction qed_roce_dpm_dcbxfunction qed_roce_setupfunction qed_roce_init_hw
Annotated Snippet
if (wait_count++ > 20) {
DP_NOTICE(p_hwfn, "cid bitmap wait timed out\n");
break;
}
}
}
static void qed_rdma_copy_gids(struct qed_rdma_qp *qp, __le32 *src_gid,
__le32 *dst_gid)
{
u32 i;
if (qp->roce_mode == ROCE_V2_IPV4) {
/* The IPv4 addresses shall be aligned to the highest word.
* The lower words must be zero.
*/
memset(src_gid, 0, sizeof(union qed_gid));
memset(dst_gid, 0, sizeof(union qed_gid));
src_gid[3] = cpu_to_le32(qp->sgid.ipv4_addr);
dst_gid[3] = cpu_to_le32(qp->dgid.ipv4_addr);
} else {
/* GIDs and IPv6 addresses coincide in location and size */
for (i = 0; i < ARRAY_SIZE(qp->sgid.dwords); i++) {
src_gid[i] = cpu_to_le32(qp->sgid.dwords[i]);
dst_gid[i] = cpu_to_le32(qp->dgid.dwords[i]);
}
}
}
static enum roce_flavor qed_roce_mode_to_flavor(enum roce_mode roce_mode)
{
switch (roce_mode) {
case ROCE_V1:
return PLAIN_ROCE;
case ROCE_V2_IPV4:
return RROCE_IPV4;
case ROCE_V2_IPV6:
return RROCE_IPV6;
default:
return MAX_ROCE_FLAVOR;
}
}
static void qed_roce_free_cid_pair(struct qed_hwfn *p_hwfn, u16 cid)
{
spin_lock_bh(&p_hwfn->p_rdma_info->lock);
qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->cid_map, cid);
qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->cid_map, cid + 1);
spin_unlock_bh(&p_hwfn->p_rdma_info->lock);
}
int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid)
{
struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info;
u32 responder_icid;
u32 requester_icid;
int rc;
spin_lock_bh(&p_hwfn->p_rdma_info->lock);
rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_rdma_info->cid_map,
&responder_icid);
if (rc) {
spin_unlock_bh(&p_rdma_info->lock);
return rc;
}
rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_rdma_info->cid_map,
&requester_icid);
spin_unlock_bh(&p_rdma_info->lock);
if (rc)
goto err;
/* the two icid's should be adjacent */
if ((requester_icid - responder_icid) != 1) {
DP_NOTICE(p_hwfn, "Failed to allocate two adjacent qp's'\n");
rc = -EINVAL;
goto err;
}
responder_icid += qed_cxt_get_proto_cid_start(p_hwfn,
p_rdma_info->proto);
requester_icid += qed_cxt_get_proto_cid_start(p_hwfn,
p_rdma_info->proto);
/* If these icids require a new ILT line allocate DMA-able context for
* an ILT page
*/
rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_CXT, responder_icid);
if (rc)
Annotation
- Immediate include surface: `linux/types.h`, `asm/byteorder.h`, `linux/bitops.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/errno.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `function qed_roce_async_event`, `function qed_roce_stop`, `function qed_rdma_copy_gids`, `function qed_roce_mode_to_flavor`, `function qed_roce_free_cid_pair`, `function qed_roce_alloc_cid`, `function qed_roce_set_real_cid`, `function qed_roce_get_qp_tc`, `function qed_roce_sp_create_responder`, `function qed_roce_sp_create_requester`.
- Atlas domain: Driver Families / drivers/net.
- 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.