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 D293CA034F; Mon, 30 Aug 2021 15:22:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3074140F35; Mon, 30 Aug 2021 15:22:56 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B9058406A2 for ; Mon, 30 Aug 2021 15:22:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630329775; 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=xMxYgp+mnLOyJlL1yihMhGO8+NBp9UKyqmU5IWdrqF0=; b=chWOzFG5TPISU1rDmnZcy1u30zJ7NFyeBderqRgq7Ir5qaaGEpmwj4++q6/LeU7VTV/TSd HBefPc9qTEuso5WxLwnEiVu+H5N3DmfRa2l7EILvD+hVi6M9FYEAKdTtrQTNJbh4a4ywyQ 9fzloVh4TQmSBHxZDT+vOAoX994C3zk= 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-318-yfIkoGHkP0aruooslgrcQg-1; Mon, 30 Aug 2021 09:22:53 -0400 X-MC-Unique: yfIkoGHkP0aruooslgrcQg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3D30C7400; Mon, 30 Aug 2021 13:22:52 +0000 (UTC) Received: from [10.39.208.27] (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9498727C50; Mon, 30 Aug 2021 13:22:51 +0000 (UTC) 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> <20210706164418.32615-8-vsrivast@xilinx.com> From: Maxime Coquelin Message-ID: <13ae51b1-84c8-3e0e-dc28-8b0ebc098b03@redhat.com> Date: Mon, 30 Aug 2021 15:22:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210706164418.32615-8-vsrivast@xilinx.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 07/10] vdpa/sfc: add support to get queue notify area info 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 7/6/21 6:44 PM, Vijay Srivastava wrote: > From: Vijay Kumar Srivastava > > Implement the vDPA ops get_notify_area to get the notify > area info of the queue. > > Signed-off-by: Vijay Kumar Srivastava > --- > drivers/vdpa/sfc/sfc_vdpa_ops.c | 166 ++++++++++++++++++++++++++++++++++++++-- > drivers/vdpa/sfc/sfc_vdpa_ops.h | 2 + > 2 files changed, 162 insertions(+), 6 deletions(-) > > diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c ... > +static int > +sfc_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size) > +{ > + int ret; > + efx_nic_t *nic; > + int vfio_dev_fd; > + efx_rc_t rc; > + unsigned int bar_offset; > + struct rte_vdpa_device *vdpa_dev; > + struct sfc_vdpa_ops_data *ops_data; > + struct vfio_region_info reg = { .argsz = sizeof(reg) }; > + const efx_nic_cfg_t *encp; > + int max_vring_cnt; > + int64_t len; > + void *dev; > + > + vdpa_dev = rte_vhost_get_vdpa_device(vid); > + > + ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev); > + if (ops_data == NULL) > + return -1; > + > + dev = ops_data->dev_handle; > + > + vfio_dev_fd = sfc_vdpa_adapter_by_dev_handle(dev)->vfio_dev_fd; > + max_vring_cnt = > + (sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count * 2); > + > + nic = sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)->nic; > + encp = efx_nic_cfg_get(nic); > + > + if (qid >= max_vring_cnt) { > + sfc_vdpa_err(dev, "invalid qid : %d", qid); > + return -1; > + } > + > + if (ops_data->vq_cxt[qid].enable != B_TRUE) { > + sfc_vdpa_err(dev, "vq is not enabled"); > + return -1; > + } > + > + rc = efx_virtio_get_doorbell_offset(ops_data->vq_cxt[qid].vq, > + &bar_offset); > + if (rc != 0) { > + sfc_vdpa_err(dev, "failed to get doorbell offset: %s", > + rte_strerror(rc)); > + return rc; > + } > + > + reg.index = sfc_vdpa_adapter_by_dev_handle(dev)->mem_bar.esb_rid; > + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, ®); > + if (ret != 0) { > + sfc_vdpa_err(dev, "could not get device region info: %s", > + strerror(errno)); > + return ret; > + } > + > + *offset = reg.offset + bar_offset; > + > + len = (1U << encp->enc_vi_window_shift) / 2; > + if (len >= sysconf(_SC_PAGESIZE)) > + *size = sysconf(_SC_PAGESIZE); > + else > + return -1; This error case may deserve an error messageto be logged. > + > + sfc_vdpa_info(dev, "vDPA ops get_notify_area :: offset : 0x%" PRIx64, > + *offset); > + > + return 0; > +} > +