drivers/infiniband/sw/siw/siw_cq.c

Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/siw/siw_cq.c

File Facts

System
Linux kernel
Corpus path
drivers/infiniband/sw/siw/siw_cq.c
Extension
.c
Size
3279 bytes
Lines
123
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (likely(rdma_is_kernel_res(&cq->base_cq.res))) {
			if (cqe->flags & SIW_WQE_REM_INVAL) {
				wc->ex.invalidate_rkey = cqe->inval_stag;
				wc->wc_flags = IB_WC_WITH_INVALIDATE;
			}
			wc->qp = cqe->base_qp;
			wc->opcode = map_wc_opcode[cqe->opcode];
			wc->status = map_cqe_status[cqe->status].ib;
			siw_dbg_cq(cq,
				   "idx %u, type %d, flags %2x, id 0x%p\n",
				   cq->cq_get % cq->num_cqe, cqe->opcode,
				   cqe->flags, (void *)(uintptr_t)cqe->id);
		} else {
			/*
			 * A malicious user may set invalid opcode or
			 * status in the user mmapped CQE array.
			 * Sanity check and correct values in that case
			 * to avoid out-of-bounds access to global arrays
			 * for opcode and status mapping.
			 */
			u8 opcode = cqe->opcode;
			u16 status = cqe->status;

			if (opcode >= SIW_NUM_OPCODES) {
				opcode = 0;
				status = SIW_WC_GENERAL_ERR;
			} else if (status >= SIW_NUM_WC_STATUS) {
				status = SIW_WC_GENERAL_ERR;
			}
			wc->opcode = map_wc_opcode[opcode];
			wc->status = map_cqe_status[status].ib;

		}
		WRITE_ONCE(cqe->flags, 0);
		cq->cq_get++;

		spin_unlock_irqrestore(&cq->lock, flags);

		return 1;
	}
	spin_unlock_irqrestore(&cq->lock, flags);

	return 0;
}

/*
 * siw_cq_flush()
 *
 * Flush all CQ elements.
 */
void siw_cq_flush(struct siw_cq *cq)
{
	struct ib_wc wc;

	while (siw_reap_cqe(cq, &wc))
		;
}

Annotation

Implementation Notes