Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
0002 /*
0003  * Copyright(c) 2016 - 2018 Intel Corporation.
0004  */
0005 
0006 #ifndef DEF_RDMAVT_INCCQ_H
0007 #define DEF_RDMAVT_INCCQ_H
0008 
0009 #include <linux/kthread.h>
0010 #include <rdma/ib_user_verbs.h>
0011 #include <rdma/ib_verbs.h>
0012 
0013 /*
0014  * Define an ib_cq_notify value that is not valid so we know when CQ
0015  * notifications are armed.
0016  */
0017 #define RVT_CQ_NONE      (IB_CQ_NEXT_COMP + 1)
0018 
0019 /*
0020  * Define read macro that apply smp_load_acquire memory barrier
0021  * when reading indice of circular buffer that mmaped to user space.
0022  */
0023 #define RDMA_READ_UAPI_ATOMIC(member) smp_load_acquire(&(member).val)
0024 
0025 /*
0026  * Define write macro that uses smp_store_release memory barrier
0027  * when writing indice of circular buffer that mmaped to user space.
0028  */
0029 #define RDMA_WRITE_UAPI_ATOMIC(member, x) smp_store_release(&(member).val, x)
0030 #include <rdma/rvt-abi.h>
0031 
0032 /*
0033  * This structure is used to contain the head pointer, tail pointer,
0034  * and completion queue entries as a single memory allocation so
0035  * it can be mmap'ed into user space.
0036  */
0037 struct rvt_k_cq_wc {
0038     u32 head;               /* index of next entry to fill */
0039     u32 tail;               /* index of next ib_poll_cq() entry */
0040     struct ib_wc kqueue[];
0041 };
0042 
0043 /*
0044  * The completion queue structure.
0045  */
0046 struct rvt_cq {
0047     struct ib_cq ibcq;
0048     struct work_struct comptask;
0049     spinlock_t lock; /* protect changes in this struct */
0050     u8 notify;
0051     u8 triggered;
0052     u8 cq_full;
0053     int comp_vector_cpu;
0054     struct rvt_dev_info *rdi;
0055     struct rvt_cq_wc *queue;
0056     struct rvt_mmap_info *ip;
0057     struct rvt_k_cq_wc *kqueue;
0058 };
0059 
0060 static inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq)
0061 {
0062     return container_of(ibcq, struct rvt_cq, ibcq);
0063 }
0064 
0065 bool rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited);
0066 
0067 #endif          /* DEF_RDMAVT_INCCQH */