From nobody Sat May 4 15:08:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1584714934; cv=none; d=zohomail.com; s=zohoarc; b=FXLwjey837AxFe7y3JRYmgF0iKRIFBPH/BUuQvvQ0LX3CR8fInlmsCXBIIkuYcuxgSSrDxAjt3NiXF8JiaHAzqvi25Ygv5XqWRhmNae+rLTuinokaqu7mRIBWTRPMTSZifYRFmX+B1WyuT6xeLSS7JEtF9x+WwYIsOa7x8bMMtE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584714934; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=izsjuPvFCwqcf0hTr6C/OKdh9vNSdRz4RAKvPm3nOGE=; b=GG+Ja4nTCN7oZzTL54ZZ92QE/PQw5WGhCCBjldihlTUdns8FJARnx/nlgVewnsv9d+F1ukxzQgP2TmcUKBrfGadsSPnv/H/txbZPEF3qYQkW2sj60vgsd+8KIoI60G7GjLQgMu8wEROYdg5zu9usgI9EjA8h5WT2sAdE4xqu/Vs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584714934811996.0565748948019; Fri, 20 Mar 2020 07:35:34 -0700 (PDT) Received: from localhost ([::1]:53606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFIkH-0002BK-IK for importer@patchew.org; Fri, 20 Mar 2020 10:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49661) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFIjP-0001Ct-7O for qemu-devel@nongnu.org; Fri, 20 Mar 2020 10:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFIjN-00070q-TC for qemu-devel@nongnu.org; Fri, 20 Mar 2020 10:34:39 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:33326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jFIjN-00070I-N8 for qemu-devel@nongnu.org; Fri, 20 Mar 2020 10:34:37 -0400 Received: by mail-wr1-x442.google.com with SMTP id a25so7785135wrd.0 for ; Fri, 20 Mar 2020 07:34:37 -0700 (PDT) Received: from localhost.localdomain ([2a00:a040:186:a1ad:5254:ff:fe84:1be0]) by smtp.gmail.com with ESMTPSA id s22sm7336694wmc.16.2020.03.20.07.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 07:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=izsjuPvFCwqcf0hTr6C/OKdh9vNSdRz4RAKvPm3nOGE=; b=KfQmQ71l30aZ4zg3BAqD/caXcDUdUBhIF/TJn/lyLqnLKzY1NlvUgBC5xADOOxB5jw JMJo8gCXGcfWV7lewyMEp6oN5/6uUEGuJ02FAnXnOmOtC3wqtmGzJD16AbypGYnuJHTw zo8tczWUg8cRJtnzXTfWve1wNpAI1mV5OjJbB0Kfg+a0BbizB2GjcGMAWAMDn+1TNseo W+z0cwO+XavOniXkM7gXSZA4u52m8uwBpYqQSR66KpCZJmbjWweyer50GQ5M3jcF84KD IqH8veQS8xAfo8fPKi180k/Cxhopz249FgVS5CYGHpe3nwGY8aaJm/v3OngEo5Fp6NVU rmeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=izsjuPvFCwqcf0hTr6C/OKdh9vNSdRz4RAKvPm3nOGE=; b=i7hncAM1Ja2DbG9gPNdr4DPNpJPQKirAoCvwZK/JKXaAzwQtNjm6JNwMpylEU5x1J9 Gz9ZY7pl3mHyCCCzEhLHMxXgu98Ghl/drCzQgI2hybnEjbp/P3KWZ8tRakr852pYVw4u P8dpFYbaGQlObR+ovIEr1+aAPRSWflF5qvCdTNphKvACTgogdnWPxm1U8pPMw7lTUsTN CKZ7rb4N7a+0eCsAQc7vWsUK2B0+A11LgSiMEMPctH22/T0ge17fStVP00SE4++EZGhy R5NgXuadHAu/4BHwFt2J3ys3S1yj9aRCa1iSQMOUck0vFZHog7QrdmfAIPUQqZrsF49C Su/g== X-Gm-Message-State: ANhLgQ38Pqidxic59Epjp2gnQBhbIDzveQOXDNn7SqSknG4Ne96kmkN6 Ji7WlzDZmLygb0lToQNsNXz5ddYr X-Google-Smtp-Source: ADFU+vuPU8r/qtKrkH+N0wHWkeYPxn5QKsKjyD3I0Tfc27KRAmHmBDsZPNVWuIHPDjLs7o6Njn7NEg== X-Received: by 2002:a5d:644c:: with SMTP id d12mr11690041wrw.54.1584714875717; Fri, 20 Mar 2020 07:34:35 -0700 (PDT) From: Yuval Shaia To: qemu-devel@nongnu.org, yuval.shaia.ml@gmail.com, marcel.apfelbaum@gmail.com Subject: [PATCH v1 1/2] hw/rdma: Cosmetic change - no need for two sge arrays Date: Fri, 20 Mar 2020 16:34:28 +0200 Message-Id: <20200320143429.9490-2-yuval.shaia.ml@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200320143429.9490-1-yuval.shaia.ml@gmail.com> References: <20200320143429.9490-1-yuval.shaia.ml@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" The function build_host_sge_array uses two sge arrays, one for input and one for output. Since the size of the two arrays is the same, the function can write directly to the given source array (i.e. input/output argument). Signed-off-by: Yuval Shaia Reviewed-by: Marcel Apfelbaum --- hw/rdma/rdma_backend.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index c346407cd3..b7ffbef9c0 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -378,30 +378,25 @@ static void ah_cache_init(void) } =20 static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res, - struct ibv_sge *dsge, struct ibv_sge *ssge, - uint8_t num_sge, uint64_t *total_length) + struct ibv_sge *sge, uint8_t num_sge, + uint64_t *total_length) { RdmaRmMR *mr; - int ssge_idx; + int idx; =20 - for (ssge_idx =3D 0; ssge_idx < num_sge; ssge_idx++) { - mr =3D rdma_rm_get_mr(rdma_dev_res, ssge[ssge_idx].lkey); + for (idx =3D 0; idx < num_sge; idx++) { + mr =3D rdma_rm_get_mr(rdma_dev_res, sge[idx].lkey); if (unlikely(!mr)) { - rdma_error_report("Invalid lkey 0x%x", ssge[ssge_idx].lkey); - return VENDOR_ERR_INVLKEY | ssge[ssge_idx].lkey; + rdma_error_report("Invalid lkey 0x%x", sge[idx].lkey); + return VENDOR_ERR_INVLKEY | sge[idx].lkey; } =20 #ifdef LEGACY_RDMA_REG_MR - dsge->addr =3D (uintptr_t)mr->virt + ssge[ssge_idx].addr - mr->sta= rt; -#else - dsge->addr =3D ssge[ssge_idx].addr; + sge[idx].addr =3D (uintptr_t)mr->virt + sge[idx].addr - mr->start; #endif - dsge->length =3D ssge[ssge_idx].length; - dsge->lkey =3D rdma_backend_mr_lkey(&mr->backend_mr); - - *total_length +=3D dsge->length; + sge[idx].lkey =3D rdma_backend_mr_lkey(&mr->backend_mr); =20 - dsge++; + *total_length +=3D sge[idx].length; } =20 return 0; @@ -484,7 +479,6 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev, void *ctx) { BackendCtx *bctx; - struct ibv_sge new_sge[MAX_SGE]; uint32_t bctx_id; int rc; struct ibv_send_wr wr =3D {}, *bad_wr; @@ -518,7 +512,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev, =20 rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id); =20 - rc =3D build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, n= um_sge, + rc =3D build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge, &backend_dev->rdma_dev_res->stats.tx_len); if (rc) { complete_work(IBV_WC_GENERAL_ERR, rc, ctx); @@ -538,7 +532,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev, wr.num_sge =3D num_sge; wr.opcode =3D IBV_WR_SEND; wr.send_flags =3D IBV_SEND_SIGNALED; - wr.sg_list =3D new_sge; + wr.sg_list =3D sge; wr.wr_id =3D bctx_id; =20 rc =3D ibv_post_send(qp->ibqp, &wr, &bad_wr); @@ -601,7 +595,6 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev, struct ibv_sge *sge, uint32_t num_sge, void *c= tx) { BackendCtx *bctx; - struct ibv_sge new_sge[MAX_SGE]; uint32_t bctx_id; int rc; struct ibv_recv_wr wr =3D {}, *bad_wr; @@ -635,7 +628,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev, =20 rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id); =20 - rc =3D build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, n= um_sge, + rc =3D build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge, &backend_dev->rdma_dev_res->stats.rx_bufs_le= n); if (rc) { complete_work(IBV_WC_GENERAL_ERR, rc, ctx); @@ -643,7 +636,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev, } =20 wr.num_sge =3D num_sge; - wr.sg_list =3D new_sge; + wr.sg_list =3D sge; wr.wr_id =3D bctx_id; rc =3D ibv_post_recv(qp->ibqp, &wr, &bad_wr); if (rc) { @@ -671,7 +664,6 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend= _dev, uint32_t num_sge, void *ctx) { BackendCtx *bctx; - struct ibv_sge new_sge[MAX_SGE]; uint32_t bctx_id; int rc; struct ibv_recv_wr wr =3D {}, *bad_wr; @@ -688,7 +680,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend= _dev, =20 rdma_protected_gslist_append_int32(&srq->cqe_ctx_list, bctx_id); =20 - rc =3D build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, n= um_sge, + rc =3D build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge, &backend_dev->rdma_dev_res->stats.rx_bufs_le= n); if (rc) { complete_work(IBV_WC_GENERAL_ERR, rc, ctx); @@ -696,7 +688,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend= _dev, } =20 wr.num_sge =3D num_sge; - wr.sg_list =3D new_sge; + wr.sg_list =3D sge; wr.wr_id =3D bctx_id; rc =3D ibv_post_srq_recv(srq->ibsrq, &wr, &bad_wr); if (rc) { --=20 2.20.1 From nobody Sat May 4 15:08:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1584715071; cv=none; d=zohomail.com; s=zohoarc; b=bRkFAZw4Qt9I+ypjY6+dcIzzTfTxTfzHYESoHHvJrJXAPR1vhYrFagiPub92ubcSpBcyVwi9IF3kbANRarUJDTE4kANoMo6e0gxWbOEcKqliTThsvhoWgSojikK85LOqHlMuuS41SMFqNiQLTPHTbZ1CSKgv2R1gHtKqaAuz2Tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584715071; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WLRGw4TSyydbZUMf9i34H/3aemcOZ131iJAvNdj19K4=; b=UvBzsGD3Mkm7U8J60rf01non+DW8+J9G60RhLYUqAYPqz+cVD9RBhHd1l+/bq6toXUe0kd9inGyYGNJ+1kduSkIVo6M3L69VUbaDxB2CnWiIN+0U4MjYUx7nhb1iehVde1pqpVmBBc3r+feSabTAvQ4M6X5Odc40lr0CskUr7Ks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584715071193805.7180455134566; Fri, 20 Mar 2020 07:37:51 -0700 (PDT) Received: from localhost ([::1]:53658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFImT-0005qh-Nj for importer@patchew.org; Fri, 20 Mar 2020 10:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFIjQ-0001E6-6R for qemu-devel@nongnu.org; Fri, 20 Mar 2020 10:34:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFIjO-00071T-T9 for qemu-devel@nongnu.org; Fri, 20 Mar 2020 10:34:40 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:52791) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jFIjO-000713-MO for qemu-devel@nongnu.org; Fri, 20 Mar 2020 10:34:38 -0400 Received: by mail-wm1-x343.google.com with SMTP id 11so6768320wmo.2 for ; Fri, 20 Mar 2020 07:34:38 -0700 (PDT) Received: from localhost.localdomain ([2a00:a040:186:a1ad:5254:ff:fe84:1be0]) by smtp.gmail.com with ESMTPSA id s22sm7336694wmc.16.2020.03.20.07.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 07:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WLRGw4TSyydbZUMf9i34H/3aemcOZ131iJAvNdj19K4=; b=nKbMEjXGyV8iMZUq+EK3PWV1ztetGErh4sfJi/xGAbTLdvdqZ5WPVOq2SzewfEIQbF miEckaPOg76xvKJ4rFd1wwuWjVmEjRokzsptzrE7k5wDPB3497dOdAMznRWu11mytGTD JjW7PFiRcn8OS84U0iCNKBNzJ9GbAp+N2YAi+cqJJYqK8ZM6ZmZoDPuptTsW+yOMtnvm KYnARP/JY8nkyUT2U3bp+tCKvJMb+sTKZAifxuxlNvY2bWuaSNM2kyxa1KKv+cbTuRlc P0TXRwDMaCF+z+t0kGrZsHcQ2KZBmc2CmEBNkTY+06S1h0b2f84EnmPRzyOGvSS07TP1 yFuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WLRGw4TSyydbZUMf9i34H/3aemcOZ131iJAvNdj19K4=; b=snQIpaHb/VYa+kk0qKwFGXZuXeRByefE7r3w/V+RHUplMw80qJWFxcfw2vcR+oGC11 lDIVLlwTfHSfF/VwGKvu17EwD2Wc/uDC2apePvAWaSI9Em6aa3RxFNINR7awh1fOeYKB vgHS3YNfkCIatvnnetP5VYjZKYZUPMOh4N2f3FO42gb1nkkIL8jaV6sZtlrB+sRiCwaM c4H+jAuEQDkYVasxxb4ce1/TnJkjbgfkjYCPS3uKVpc+buQtBQPcuXodO93fLQYMvZWq vUzOEkiN4rkN3kj1X5UzgEFQUst0wNwKbUWs2FKlDvTU2ifeQ0vW7pWUO2AkJgvZgv3/ T/QQ== X-Gm-Message-State: ANhLgQ2kpgmb5htDXwiM7iYpy8UZaauOy6mMebteD4V1ms8V1n8tT5bK wWPUTkLf6N2OGnWw7mQqHQbtkDJA X-Google-Smtp-Source: ADFU+vvZmSxcF+dvFo1sy+d9FdbkiOKpG3CLOPhQIyLqcytS4uL8zrsPwwFadPVNFLKTqRcvMf+xhQ== X-Received: by 2002:a7b:c0c7:: with SMTP id s7mr10316393wmh.187.1584714877341; Fri, 20 Mar 2020 07:34:37 -0700 (PDT) From: Yuval Shaia To: qemu-devel@nongnu.org, yuval.shaia.ml@gmail.com, marcel.apfelbaum@gmail.com Subject: [PATCH v1 2/2] hw/rdma: Skip data-path mr_id translation Date: Fri, 20 Mar 2020 16:34:29 +0200 Message-Id: <20200320143429.9490-3-yuval.shaia.ml@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200320143429.9490-1-yuval.shaia.ml@gmail.com> References: <20200320143429.9490-1-yuval.shaia.ml@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" With the change made in commit 68b89aee71 ("Utilize ibv_reg_mr_iova for memory registration") the MR emulation is no longer needed in order to translate the guest addresses into host addresses. With that, the next obvious step is to skip entirely the processing in data-path. To accomplish this, return the backend's lkey to driver so we will not need to do the emulated mr_id to backend mr_id translation in data-path. The function build_host_sge_array is still called in data-path but only for backward computability with statistics collection. While there, as a cosmetic change to make the code cleaner - make one copy of the function rdma_backend_create_mr and leave the redundant guest_start argument in the legacy code. Signed-off-by: Yuval Shaia Reviewed-by: Marcel Apfelbaum --- hw/rdma/rdma_backend.c | 21 ++++++++++++++------- hw/rdma/rdma_backend.h | 5 ----- hw/rdma/rdma_rm.c | 13 ++++++------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index b7ffbef9c0..3dd39fe1a7 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -377,6 +377,7 @@ static void ah_cache_init(void) destroy_ah_hash_key, destroy_ah_hast_d= ata); } =20 +#ifdef LEGACY_RDMA_REG_MR static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res, struct ibv_sge *sge, uint8_t num_sge, uint64_t *total_length) @@ -391,9 +392,7 @@ static int build_host_sge_array(RdmaDeviceResources *rd= ma_dev_res, return VENDOR_ERR_INVLKEY | sge[idx].lkey; } =20 -#ifdef LEGACY_RDMA_REG_MR sge[idx].addr =3D (uintptr_t)mr->virt + sge[idx].addr - mr->start; -#endif sge[idx].lkey =3D rdma_backend_mr_lkey(&mr->backend_mr); =20 *total_length +=3D sge[idx].length; @@ -401,6 +400,19 @@ static int build_host_sge_array(RdmaDeviceResources *r= dma_dev_res, =20 return 0; } +#else +static inline int build_host_sge_array(RdmaDeviceResources *rdma_dev_res, + struct ibv_sge *sge, uint8_t num_sg= e, + uint64_t *total_length) +{ + int idx; + + for (idx =3D 0; idx < num_sge; idx++) { + *total_length +=3D sge[idx].length; + } + return 0; +} +#endif =20 static void trace_mad_message(const char *title, char *buf, int len) { @@ -731,13 +743,8 @@ void rdma_backend_destroy_pd(RdmaBackendPD *pd) } } =20 -#ifdef LEGACY_RDMA_REG_MR -int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *add= r, - size_t length, int access) -#else int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *add= r, size_t length, uint64_t guest_start, int access) -#endif { #ifdef LEGACY_RDMA_REG_MR mr->ibmr =3D ibv_reg_mr(pd->ibpd, addr, length, access); diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h index 127f96e2d5..225af481e0 100644 --- a/hw/rdma/rdma_backend.h +++ b/hw/rdma/rdma_backend.h @@ -78,13 +78,8 @@ int rdma_backend_query_port(RdmaBackendDev *backend_dev, int rdma_backend_create_pd(RdmaBackendDev *backend_dev, RdmaBackendPD *pd); void rdma_backend_destroy_pd(RdmaBackendPD *pd); =20 -#ifdef LEGACY_RDMA_REG_MR -int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *add= r, - size_t length, int access); -#else int rdma_backend_create_mr(RdmaBackendMR *mr, RdmaBackendPD *pd, void *add= r, size_t length, uint64_t guest_start, int access= ); -#endif void rdma_backend_destroy_mr(RdmaBackendMR *mr); =20 int rdma_backend_create_cq(RdmaBackendDev *backend_dev, RdmaBackendCQ *cq, diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 1524dfaeaa..7e9ea283c9 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -227,21 +227,20 @@ int rdma_rm_alloc_mr(RdmaDeviceResources *dev_res, ui= nt32_t pd_handle, mr->length =3D guest_length; mr->virt +=3D (mr->start & (TARGET_PAGE_SIZE - 1)); =20 -#ifdef LEGACY_RDMA_REG_MR - ret =3D rdma_backend_create_mr(&mr->backend_mr, &pd->backend_pd, m= r->virt, - mr->length, access_flags); -#else ret =3D rdma_backend_create_mr(&mr->backend_mr, &pd->backend_pd, m= r->virt, mr->length, guest_start, access_flags= ); -#endif if (ret) { ret =3D -EIO; goto out_dealloc_mr; } +#ifdef LEGACY_RDMA_REG_MR + /* We keep mr_handle in lkey so send and recv get get mr ptr */ + *lkey =3D *mr_handle; +#else + *lkey =3D rdma_backend_mr_lkey(&mr->backend_mr); +#endif } =20 - /* We keep mr_handle in lkey so send and recv get get mr ptr */ - *lkey =3D *mr_handle; *rkey =3D -1; =20 mr->pd_handle =3D pd_handle; --=20 2.20.1