From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7F213A0548; Thu, 4 Nov 2021 11:15:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D70C40E5A; Thu, 4 Nov 2021 11:15:47 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 2349540DFD for ; Thu, 4 Nov 2021 11:15:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636020944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oHk83knO0kxz2Be/ZQF6P2Yo6tgNOhS2uGokC7GvYoU=; b=DaqrDC3yHWEtJ04PSPWhslSshcniZ+CYGLK/T9WnjuxnKf2ly0EnnzQFxdpMW7uCnpIL3K jqgQH10LpF2xqros+/QnHa2JBZqMYAIFTQgN09BzhALUlWzsJiNksuApPDVHevp1bbZi6c NNS0joEu4xTvYlz3Wcj2xSZ/bBWAsxQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-rM_ElPCQO7Cz9c9NpD7uZg-1; Thu, 04 Nov 2021 06:15:43 -0400 X-MC-Unique: rM_ElPCQO7Cz9c9NpD7uZg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DCEE8066FB; Thu, 4 Nov 2021 10:15:42 +0000 (UTC) Received: from [10.39.208.16] (unknown [10.39.208.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD22C60C04; Thu, 4 Nov 2021 10:15:39 +0000 (UTC) Message-ID: Date: Thu, 4 Nov 2021 11:15:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Vijay Srivastava , dev@dpdk.org Cc: chenbo.xia@intel.com, andrew.rybchenko@oktetlabs.ru, Vijay Kumar Srivastava References: <20210706164418.32615-1-vsrivast@xilinx.com> <20211103135754.17411-1-vsrivast@xilinx.com> <20211103135754.17411-7-vsrivast@xilinx.com> From: Maxime Coquelin In-Reply-To: <20211103135754.17411-7-vsrivast@xilinx.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 06/10] vdpa/sfc: add support for dev conf and dev close ops X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 11/3/21 14:57, Vijay Srivastava wrote: > From: Vijay Kumar Srivastava > > Implement vDPA ops dev_conf and dev_close for DMA mapping, > interrupt and virtqueue configurations. > > Signed-off-by: Vijay Kumar Srivastava > Acked-by: Andrew Rybchenko > --- > v2: > * Removed redundant null check while calling free(). > * Added error handling for rte_vhost_get_vhost_vring(). > > v4: > * Removed rc for rte_vfio_container_dma_unmap from label failed_vfio_dma_map. > * Updated VFIO_DEVICE_SET_IRQS parameter fields for intr disable. > * Removed goto label fail_vring_map. > > drivers/vdpa/sfc/sfc_vdpa.c | 6 + > drivers/vdpa/sfc/sfc_vdpa.h | 43 ++++ > drivers/vdpa/sfc/sfc_vdpa_hw.c | 69 ++++++ > drivers/vdpa/sfc/sfc_vdpa_ops.c | 525 ++++++++++++++++++++++++++++++++++++++-- > drivers/vdpa/sfc/sfc_vdpa_ops.h | 28 +++ > 5 files changed, 651 insertions(+), 20 deletions(-) > ... > +static uint64_t > +hva_to_gpa(int vid, uint64_t hva) > +{ > + struct rte_vhost_memory *vhost_mem = NULL; > + struct rte_vhost_mem_region *mem_reg = NULL; > + uint32_t i; > + uint64_t gpa = 0; > + > + if (rte_vhost_get_mem_table(vid, &vhost_mem) < 0) > + goto error; > + > + for (i = 0; i < vhost_mem->nregions; i++) { > + mem_reg = &vhost_mem->regions[i]; > + > + if (hva >= mem_reg->host_user_addr && > + hva < mem_reg->host_user_addr + mem_reg->size) { > + gpa = (hva - mem_reg->host_user_addr) + > + mem_reg->guest_phys_addr; > + break; > + } > + } > + > +error: > + free(vhost_mem); > + return gpa; > +} It would be done later, but all the vDPA drivers have (almost) the same function, so it would make sense to add a Vhost API that would make use of Vhost's hva_to_gpa. Reviewed-by: Maxime Coquelin Thanks, Maxime