From patchwork Tue Mar 20 19:00:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10297727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D7788600F6 for ; Tue, 20 Mar 2018 19:01:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C84692810E for ; Tue, 20 Mar 2018 19:01:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCC1A28D0E; Tue, 20 Mar 2018 19:01:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B93A28CF2 for ; Tue, 20 Mar 2018 19:01:50 +0000 (UTC) Received: from localhost ([::1]:51387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyMW5-00053v-Ee for patchwork-qemu-devel@patchwork.kernel.org; Tue, 20 Mar 2018 15:01:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyMV3-0004MU-D7 for qemu-devel@nongnu.org; Tue, 20 Mar 2018 15:00:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyMV0-0005Ej-69 for qemu-devel@nongnu.org; Tue, 20 Mar 2018 15:00:45 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39386) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyMUz-0005EW-TE for qemu-devel@nongnu.org; Tue, 20 Mar 2018 15:00:42 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2KIlK4L077027; Tue, 20 Mar 2018 19:00:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=WE9A398u6zFSKKGgd8RezFa8NBDJTC1CDqqq5EITHvY=; b=hv6hQHlwT9HQKMueWehHVAzDHGSBpvuvIT783lf1/VbgccW8Xt810zIq45gXlVdHOCg+ WQ9yE1rNz/12DOos1Gvcf3wSE1dm6YpPuVw1MMDLIm+cMsYWjPnDnG4H6fXZ6AWR6tHK M6pU9fV9Alx4MdcKzMz/5Yg/Wnzt2+Djv3MwgGOMsduIeSlmG3JRFzFVCXqNZu98cPkO dlyweCiwn3N2d1ZSxjgM678l3ljllf5gfh0cqw3koRiISttAI1Xps++HC2zbq45E+XEy gAGkXH4unB1YZbXOSfL5+onfDB9ctoFNsXBwfkVTgSjDwlkq/CdimDIBBjA7B6cEp2hR 4A== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2gu7vw024u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 19:00:40 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2KJ0d4m006387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 19:00:40 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w2KJ0d1I004197; Tue, 20 Mar 2018 19:00:39 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2018 12:00:39 -0700 From: Yuval Shaia To: yuval.shaia@oracle.com, marcel@redhat.com, qemu-devel@nongnu.org Date: Tue, 20 Mar 2018 21:00:22 +0200 Message-Id: <20180320190023.24077-2-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180320190023.24077-1-yuval.shaia@oracle.com> References: <20180320190023.24077-1-yuval.shaia@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8838 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.79 Subject: [Qemu-devel] [PATCH v1 1/2] hw/rdma: Add Query QP operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This operation is needed by rdma devices - implement it. Signed-off-by: Yuval Shaia --- hw/rdma/rdma_backend.c | 12 ++++++++++++ hw/rdma/rdma_backend.h | 2 ++ hw/rdma/rdma_rm.c | 18 ++++++++++++++++++ hw/rdma/rdma_rm.h | 3 +++ 4 files changed, 35 insertions(+) diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index ae7589c190..da2c8671e5 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -646,6 +646,18 @@ int rdma_backend_qp_state_rts(RdmaBackendQP *qp, uint8_t qp_type, return 0; } +int rdma_backend_query_qp(RdmaBackendQP *qp, struct ibv_qp_attr *attr, + int attr_mask, struct ibv_qp_init_attr *init_attr) +{ + if (!qp->ibqp) { + pr_dbg("QP1\n"); + attr->qp_state = IBV_QPS_RTS; + return 0; + } + + return ibv_query_qp(qp->ibqp, attr, attr_mask, init_attr); +} + void rdma_backend_destroy_qp(RdmaBackendQP *qp) { if (qp->ibqp) { diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h index 07f6fed768..6d9b45efe8 100644 --- a/hw/rdma/rdma_backend.h +++ b/hw/rdma/rdma_backend.h @@ -83,6 +83,8 @@ int rdma_backend_qp_state_rtr(RdmaBackendDev *backend_dev, RdmaBackendQP *qp, bool use_qkey); int rdma_backend_qp_state_rts(RdmaBackendQP *qp, uint8_t qp_type, uint32_t sq_psn, uint32_t qkey, bool use_qkey); +int rdma_backend_query_qp(RdmaBackendQP *qp, struct ibv_qp_attr *attr, + int attr_mask, struct ibv_qp_init_attr *init_attr); void rdma_backend_destroy_qp(RdmaBackendQP *qp); void rdma_backend_post_send(RdmaBackendDev *backend_dev, diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 296e40518e..a4e1de31fd 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -453,6 +453,24 @@ int rdma_rm_modify_qp(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, return 0; } +int rdma_rm_query_qp(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, + uint32_t qp_handle, struct ibv_qp_attr *attr, + int attr_mask, struct ibv_qp_init_attr *init_attr) +{ + RdmaRmQP *qp; + + pr_dbg("qpn=%d\n", qp_handle); + + qp = rdma_rm_get_qp(dev_res, qp_handle); + if (!qp) { + return -EINVAL; + } + + pr_dbg("qp_type=%d\n", qp->qp_type); + + return rdma_backend_query_qp(&qp->backend_qp, attr, attr_mask, init_attr); +} + void rdma_rm_dealloc_qp(RdmaDeviceResources *dev_res, uint32_t qp_handle) { RdmaRmQP *qp; diff --git a/hw/rdma/rdma_rm.h b/hw/rdma/rdma_rm.h index be95c1b0f4..0528c1972b 100644 --- a/hw/rdma/rdma_rm.h +++ b/hw/rdma/rdma_rm.h @@ -59,6 +59,9 @@ int rdma_rm_modify_qp(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, union ibv_gid *dgid, uint32_t dqpn, enum ibv_qp_state qp_state, uint32_t qkey, uint32_t rq_psn, uint32_t sq_psn); +int rdma_rm_query_qp(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, + uint32_t qp_handle, struct ibv_qp_attr *attr, + int attr_mask, struct ibv_qp_init_attr *init_attr); void rdma_rm_dealloc_qp(RdmaDeviceResources *dev_res, uint32_t qp_handle); int rdma_rm_alloc_cqe_ctx(RdmaDeviceResources *dev_res, uint32_t *cqe_ctx_id,