18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright(c) 2016 - 2018 Intel Corporation. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef DEF_RDMAVT_INCCQ_H 78c2ecf20Sopenharmony_ci#define DEF_RDMAVT_INCCQ_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/kthread.h> 108c2ecf20Sopenharmony_ci#include <rdma/ib_user_verbs.h> 118c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Define an ib_cq_notify value that is not valid so we know when CQ 158c2ecf20Sopenharmony_ci * notifications are armed. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci#define RVT_CQ_NONE (IB_CQ_NEXT_COMP + 1) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * Define read macro that apply smp_load_acquire memory barrier 218c2ecf20Sopenharmony_ci * when reading indice of circular buffer that mmaped to user space. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#define RDMA_READ_UAPI_ATOMIC(member) smp_load_acquire(&(member).val) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * Define write macro that uses smp_store_release memory barrier 278c2ecf20Sopenharmony_ci * when writing indice of circular buffer that mmaped to user space. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#define RDMA_WRITE_UAPI_ATOMIC(member, x) smp_store_release(&(member).val, x) 308c2ecf20Sopenharmony_ci#include <rdma/rvt-abi.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* 338c2ecf20Sopenharmony_ci * This structure is used to contain the head pointer, tail pointer, 348c2ecf20Sopenharmony_ci * and completion queue entries as a single memory allocation so 358c2ecf20Sopenharmony_ci * it can be mmap'ed into user space. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_cistruct rvt_k_cq_wc { 388c2ecf20Sopenharmony_ci u32 head; /* index of next entry to fill */ 398c2ecf20Sopenharmony_ci u32 tail; /* index of next ib_poll_cq() entry */ 408c2ecf20Sopenharmony_ci struct ib_wc kqueue[]; 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* 448c2ecf20Sopenharmony_ci * The completion queue structure. 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_cistruct rvt_cq { 478c2ecf20Sopenharmony_ci struct ib_cq ibcq; 488c2ecf20Sopenharmony_ci struct work_struct comptask; 498c2ecf20Sopenharmony_ci spinlock_t lock; /* protect changes in this struct */ 508c2ecf20Sopenharmony_ci u8 notify; 518c2ecf20Sopenharmony_ci u8 triggered; 528c2ecf20Sopenharmony_ci u8 cq_full; 538c2ecf20Sopenharmony_ci int comp_vector_cpu; 548c2ecf20Sopenharmony_ci struct rvt_dev_info *rdi; 558c2ecf20Sopenharmony_ci struct rvt_cq_wc *queue; 568c2ecf20Sopenharmony_ci struct rvt_mmap_info *ip; 578c2ecf20Sopenharmony_ci struct rvt_k_cq_wc *kqueue; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci return container_of(ibcq, struct rvt_cq, ibcq); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cibool rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#endif /* DEF_RDMAVT_INCCQH */ 68