1319974Shselasky#ifndef DEF_RDMAVT_INCCQ_H 2319974Shselasky#define DEF_RDMAVT_INCCQ_H 3319974Shselasky 4331772Shselasky/*- 5331772Shselasky * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 6319974Shselasky * 7319974Shselasky * This file is provided under a dual BSD/GPLv2 license. When using or 8319974Shselasky * redistributing this file, you may do so under either license. 9319974Shselasky * 10319974Shselasky * GPL LICENSE SUMMARY 11319974Shselasky * 12319974Shselasky * Copyright(c) 2016 Intel Corporation. 13319974Shselasky * 14319974Shselasky * This program is free software; you can redistribute it and/or modify 15319974Shselasky * it under the terms of version 2 of the GNU General Public License as 16319974Shselasky * published by the Free Software Foundation. 17319974Shselasky * 18319974Shselasky * This program is distributed in the hope that it will be useful, but 19319974Shselasky * WITHOUT ANY WARRANTY; without even the implied warranty of 20319974Shselasky * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21319974Shselasky * General Public License for more details. 22319974Shselasky * 23319974Shselasky * BSD LICENSE 24319974Shselasky * 25319974Shselasky * Copyright(c) 2015 Intel Corporation. 26319974Shselasky * 27319974Shselasky * Redistribution and use in source and binary forms, with or without 28319974Shselasky * modification, are permitted provided that the following conditions 29319974Shselasky * are met: 30319974Shselasky * 31319974Shselasky * - Redistributions of source code must retain the above copyright 32319974Shselasky * notice, this list of conditions and the following disclaimer. 33319974Shselasky * - Redistributions in binary form must reproduce the above copyright 34319974Shselasky * notice, this list of conditions and the following disclaimer in 35319974Shselasky * the documentation and/or other materials provided with the 36319974Shselasky * distribution. 37319974Shselasky * - Neither the name of Intel Corporation nor the names of its 38319974Shselasky * contributors may be used to endorse or promote products derived 39319974Shselasky * from this software without specific prior written permission. 40319974Shselasky * 41319974Shselasky * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 42319974Shselasky * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 43319974Shselasky * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 44319974Shselasky * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 45319974Shselasky * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46319974Shselasky * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 47319974Shselasky * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 48319974Shselasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 49319974Shselasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 50319974Shselasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 51319974Shselasky * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52319974Shselasky * 53331772Shselasky * $FreeBSD: stable/11/sys/ofed/include/rdma/rdmavt_cq.h 331772 2018-03-30 18:17:33Z hselasky $ 54319974Shselasky */ 55319974Shselasky 56319974Shselasky#include <linux/kthread.h> 57319974Shselasky#include <rdma/ib_user_verbs.h> 58319974Shselasky 59319974Shselasky/* 60319974Shselasky * Define an ib_cq_notify value that is not valid so we know when CQ 61319974Shselasky * notifications are armed. 62319974Shselasky */ 63319974Shselasky#define RVT_CQ_NONE (IB_CQ_NEXT_COMP + 1) 64319974Shselasky 65319974Shselasky/* 66319974Shselasky * This structure is used to contain the head pointer, tail pointer, 67319974Shselasky * and completion queue entries as a single memory allocation so 68319974Shselasky * it can be mmap'ed into user space. 69319974Shselasky */ 70319974Shselaskystruct rvt_cq_wc { 71319974Shselasky u32 head; /* index of next entry to fill */ 72319974Shselasky u32 tail; /* index of next ib_poll_cq() entry */ 73319974Shselasky union { 74319974Shselasky /* these are actually size ibcq.cqe + 1 */ 75319974Shselasky struct ib_uverbs_wc uqueue[0]; 76319974Shselasky struct ib_wc kqueue[0]; 77319974Shselasky }; 78319974Shselasky}; 79319974Shselasky 80319974Shselasky/* 81319974Shselasky * The completion queue structure. 82319974Shselasky */ 83319974Shselaskystruct rvt_cq { 84319974Shselasky struct ib_cq ibcq; 85319974Shselasky struct kthread_work comptask; 86319974Shselasky spinlock_t lock; /* protect changes in this struct */ 87319974Shselasky u8 notify; 88319974Shselasky u8 triggered; 89319974Shselasky struct rvt_dev_info *rdi; 90319974Shselasky struct rvt_cq_wc *queue; 91319974Shselasky struct rvt_mmap_info *ip; 92319974Shselasky}; 93319974Shselasky 94319974Shselaskystatic inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq) 95319974Shselasky{ 96319974Shselasky return container_of(ibcq, struct rvt_cq, ibcq); 97319974Shselasky} 98319974Shselasky 99319974Shselaskyvoid rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited); 100319974Shselasky 101319974Shselasky#endif /* DEF_RDMAVT_INCCQH */ 102