^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright(c) 2016 - 2018 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef DEF_RDMAVT_INCCQ_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define DEF_RDMAVT_INCCQ_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <rdma/ib_user_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <rdma/ib_verbs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Define an ib_cq_notify value that is not valid so we know when CQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * notifications are armed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define RVT_CQ_NONE (IB_CQ_NEXT_COMP + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Define read macro that apply smp_load_acquire memory barrier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * when reading indice of circular buffer that mmaped to user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define RDMA_READ_UAPI_ATOMIC(member) smp_load_acquire(&(member).val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Define write macro that uses smp_store_release memory barrier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * when writing indice of circular buffer that mmaped to user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define RDMA_WRITE_UAPI_ATOMIC(member, x) smp_store_release(&(member).val, x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <rdma/rvt-abi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * This structure is used to contain the head pointer, tail pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * and completion queue entries as a single memory allocation so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * it can be mmap'ed into user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct rvt_k_cq_wc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) u32 head; /* index of next entry to fill */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) u32 tail; /* index of next ib_poll_cq() entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct ib_wc kqueue[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * The completion queue structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct rvt_cq {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct ib_cq ibcq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct work_struct comptask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) spinlock_t lock; /* protect changes in this struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) u8 notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) u8 triggered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) u8 cq_full;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int comp_vector_cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct rvt_dev_info *rdi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct rvt_cq_wc *queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct rvt_mmap_info *ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct rvt_k_cq_wc *kqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return container_of(ibcq, struct rvt_cq, ibcq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) bool rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #endif /* DEF_RDMAVT_INCCQH */