drivers/infiniband/sw/rxe/rxe_queue.h

Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rxe/rxe_queue.h

File Facts

System
Linux kernel
Corpus path
drivers/infiniband/sw/rxe/rxe_queue.h
Extension
.h
Size
8045 bytes
Lines
285
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

struct rxe_queue {
	struct rxe_dev		*rxe;
	struct rxe_queue_buf	*buf;
	struct rxe_mmap_info	*ip;
	size_t			buf_size;
	size_t			elem_size;
	unsigned int		log2_elem_size;
	u32			index_mask;
	enum queue_type		type;
	/* private copy of index for shared queues between
	 * driver and clients. Driver reads and writes
	 * this copy and then replicates to rxe_queue_buf
	 * for read access by clients.
	 */
	u32			index;
};

int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
		 struct ib_udata *udata, struct rxe_queue_buf *buf,
		 size_t buf_size, struct rxe_mmap_info **ip_p);

void rxe_queue_reset(struct rxe_queue *q);

struct rxe_queue *rxe_queue_init(struct rxe_dev *rxe, int *num_elem,
			unsigned int elem_size, enum queue_type type);

int rxe_queue_resize(struct rxe_queue *q, unsigned int *num_elem_p,
		     unsigned int elem_size, struct ib_udata *udata,
		     struct mminfo __user *outbuf,
		     spinlock_t *producer_lock, spinlock_t *consumer_lock);

void rxe_queue_cleanup(struct rxe_queue *queue);

static inline u32 queue_next_index(struct rxe_queue *q, int index)
{
	return (index + 1) & q->index_mask;
}

static inline u32 queue_get_producer(const struct rxe_queue *q,
				     enum queue_type type)
{
	u32 prod;

	switch (type) {
	case QUEUE_TYPE_FROM_CLIENT:
		/* used by rxe, client owns the index */
		prod = smp_load_acquire(&q->buf->producer_index);
		break;
	case QUEUE_TYPE_TO_CLIENT:
		/* used by rxe which owns the index */
		prod = q->index;
		break;
	case QUEUE_TYPE_FROM_ULP:
		/* used by ulp which owns the index */
		prod = q->buf->producer_index;
		break;
	case QUEUE_TYPE_TO_ULP:
		/* used by ulp, rxe owns the index */
		prod = smp_load_acquire(&q->buf->producer_index);
		break;
	}

	return prod;
}

static inline u32 queue_get_consumer(const struct rxe_queue *q,
				     enum queue_type type)
{
	u32 cons;

	switch (type) {
	case QUEUE_TYPE_FROM_CLIENT:
		/* used by rxe which owns the index */
		cons = q->index;
		break;
	case QUEUE_TYPE_TO_CLIENT:
		/* used by rxe, client owns the index */
		cons = smp_load_acquire(&q->buf->consumer_index);
		break;
	case QUEUE_TYPE_FROM_ULP:
		/* used by ulp, rxe owns the index */
		cons = smp_load_acquire(&q->buf->consumer_index);
		break;
	case QUEUE_TYPE_TO_ULP:
		/* used by ulp which owns the index */
		cons = q->buf->consumer_index;
		break;
	}

	return cons;

Annotation

Implementation Notes