/* * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of EITHER the GNU General Public License * version 2 as published by the Free Software Foundation or the BSD * 2-Clause License. This program is distributed in the hope that it * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License version 2 for more details at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. * * You should have received a copy of the GNU General Public License * along with this program available in the file COPYING in the main * directory of this source tree. * * The BSD 2-Clause License * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <asm/page.h> #include <linux/io.h> #include <linux/wait.h> #include <rdma/ib_addr.h> #include <rdma/ib_smi.h> #include <rdma/ib_user_verbs.h> #include "pvrdma.h" static void __pvrdma_destroy_qp(struct pvrdma_dev *dev, struct pvrdma_qp *qp); static inline void get_cqs(struct pvrdma_qp *qp, struct pvrdma_cq **send_cq, struct pvrdma_cq **recv_cq) { … } static void pvrdma_lock_cqs(struct pvrdma_cq *scq, struct pvrdma_cq *rcq, unsigned long *scq_flags, unsigned long *rcq_flags) __acquires(scq->cq_lock) __acquires(rcq->cq_lock) { … } static void pvrdma_unlock_cqs(struct pvrdma_cq *scq, struct pvrdma_cq *rcq, unsigned long *scq_flags, unsigned long *rcq_flags) __releases(scq->cq_lock) __releases(rcq->cq_lock) { … } static void pvrdma_reset_qp(struct pvrdma_qp *qp) { … } static int pvrdma_set_rq_size(struct pvrdma_dev *dev, struct ib_qp_cap *req_cap, struct pvrdma_qp *qp) { … } static int pvrdma_set_sq_size(struct pvrdma_dev *dev, struct ib_qp_cap *req_cap, struct pvrdma_qp *qp) { … } /** * pvrdma_create_qp - create queue pair * @ibqp: queue pair * @init_attr: queue pair attributes * @udata: user data * * @return: the 0 on success, otherwise returns an errno. */ int pvrdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr, struct ib_udata *udata) { … } static void _pvrdma_free_qp(struct pvrdma_qp *qp) { … } static void pvrdma_free_qp(struct pvrdma_qp *qp) { … } static inline void _pvrdma_destroy_qp_work(struct pvrdma_dev *dev, u32 qp_handle) { … } /** * pvrdma_destroy_qp - destroy a queue pair * @qp: the queue pair to destroy * @udata: user data or null for kernel object * * @return: always 0. */ int pvrdma_destroy_qp(struct ib_qp *qp, struct ib_udata *udata) { … } static void __pvrdma_destroy_qp(struct pvrdma_dev *dev, struct pvrdma_qp *qp) { … } /** * pvrdma_modify_qp - modify queue pair attributes * @ibqp: the queue pair * @attr: the new queue pair's attributes * @attr_mask: attributes mask * @udata: user data * * @returns 0 on success, otherwise returns an errno. */ int pvrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata) { … } static inline void *get_sq_wqe(struct pvrdma_qp *qp, unsigned int n) { … } static inline void *get_rq_wqe(struct pvrdma_qp *qp, unsigned int n) { … } static int set_reg_seg(struct pvrdma_sq_wqe_hdr *wqe_hdr, const struct ib_reg_wr *wr) { … } /** * pvrdma_post_send - post send work request entries on a QP * @ibqp: the QP * @wr: work request list to post * @bad_wr: the first bad WR returned * * @return: 0 on success, otherwise errno returned. */ int pvrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr, const struct ib_send_wr **bad_wr) { … } /** * pvrdma_post_recv - post receive work request entries on a QP * @ibqp: the QP * @wr: the work request list to post * @bad_wr: the first bad WR returned * * @return: 0 on success, otherwise errno returned. */ int pvrdma_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, const struct ib_recv_wr **bad_wr) { … } /** * pvrdma_query_qp - query a queue pair's attributes * @ibqp: the queue pair to query * @attr: the queue pair's attributes * @attr_mask: attributes mask * @init_attr: initial queue pair attributes * * @returns 0 on success, otherwise returns an errno. */ int pvrdma_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, struct ib_qp_init_attr *init_attr) { … }