#ifndef DEF_RDMAVT_INCCQ_H1#define DEF_RDMAVT_INCCQ_H23/*-4* SPDX-License-Identifier: BSD-2-Clause OR GPL-2.05*6* This file is provided under a dual BSD/GPLv2 license. When using or7* redistributing this file, you may do so under either license.8*9* GPL LICENSE SUMMARY10*11* Copyright(c) 2016 Intel Corporation.12*13* This program is free software; you can redistribute it and/or modify14* it under the terms of version 2 of the GNU General Public License as15* published by the Free Software Foundation.16*17* This program is distributed in the hope that it will be useful, but18* WITHOUT ANY WARRANTY; without even the implied warranty of19* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20* General Public License for more details.21*22* BSD LICENSE23*24* Copyright(c) 2015 Intel Corporation.25*26* Redistribution and use in source and binary forms, with or without27* modification, are permitted provided that the following conditions28* are met:29*30* - Redistributions of source code must retain the above copyright31* notice, this list of conditions and the following disclaimer.32* - Redistributions in binary form must reproduce the above copyright33* notice, this list of conditions and the following disclaimer in34* the documentation and/or other materials provided with the35* distribution.36* - Neither the name of Intel Corporation nor the names of its37* contributors may be used to endorse or promote products derived38* from this software without specific prior written permission.39*40* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS41* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT42* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR43* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT44* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,45* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT46* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,47* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY48* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT49* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE50* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.51*/5253#include <linux/kthread.h>54#include <rdma/ib_user_verbs.h>5556/*57* Define an ib_cq_notify value that is not valid so we know when CQ58* notifications are armed.59*/60#define RVT_CQ_NONE (IB_CQ_NEXT_COMP + 1)6162/*63* This structure is used to contain the head pointer, tail pointer,64* and completion queue entries as a single memory allocation so65* it can be mmap'ed into user space.66*/67struct rvt_cq_wc {68u32 head; /* index of next entry to fill */69u32 tail; /* index of next ib_poll_cq() entry */70union {71/* these are actually size ibcq.cqe + 1 */72struct ib_uverbs_wc uqueue[0];73struct ib_wc kqueue[0];74};75};7677/*78* The completion queue structure.79*/80struct rvt_cq {81struct ib_cq ibcq;82struct kthread_work comptask;83spinlock_t lock; /* protect changes in this struct */84u8 notify;85u8 triggered;86struct rvt_dev_info *rdi;87struct rvt_cq_wc *queue;88struct rvt_mmap_info *ip;89};9091static inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq)92{93return container_of(ibcq, struct rvt_cq, ibcq);94}9596void rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited);9798#endif /* DEF_RDMAVT_INCCQH */99100101