From patchwork Thu May 14 08:02:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 70212 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38F2EA00C3; Thu, 14 May 2020 10:03:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 094751D6BB; Thu, 14 May 2020 10:02:53 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 51E8C1D6B6 for ; Thu, 14 May 2020 10:02:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589443368; 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=hbqmmtxQ7RfGpinEDbuwHG/hbZUEf+JW+zZ9BQ0qDnk=; b=cf7OZLc0xRuNER/6P1jOQmU/c4Gfu50V5HBjGJrIov7crYjJKpkrbSQMo601F/Uos1wfDb /19HoNZlcygXwj3GFIef3NdAg17owN4QHM0zipU+g5Cu4k6761SjmeagWD4EevO3nGCVHk FnT8WlLyilsTuJy5CK31nPQkXSn7nKQ= 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-378-HFP5jqd8ObSQUOMFwDvHHg-1; Thu, 14 May 2020 04:02:46 -0400 X-MC-Unique: HFP5jqd8ObSQUOMFwDvHHg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27E4C100CCC0; Thu, 14 May 2020 08:02:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FEBE61538; Thu, 14 May 2020 08:02:42 +0000 (UTC) From: Maxime Coquelin To: xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, amorenoz@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com, dev@dpdk.org Cc: jasowang@redhat.com, lulu@redhat.com, Maxime Coquelin Date: Thu, 14 May 2020 10:02:12 +0200 Message-Id: <20200514080218.1435344-4-maxime.coquelin@redhat.com> In-Reply-To: <20200514080218.1435344-1-maxime.coquelin@redhat.com> References: <20200514080218.1435344-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 3/9] vdpa/ifc: add support to vDPA queue enable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" This patch adds support to enabling and disabling vrings on a per-vring granularity. Signed-off-by: Maxime Coquelin --- drivers/vdpa/ifc/base/ifcvf.c | 9 +++++++++ drivers/vdpa/ifc/base/ifcvf.h | 4 ++++ drivers/vdpa/ifc/ifcvf_vdpa.c | 23 ++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c index 3c0b2dff66..dd4e7468ae 100644 --- a/drivers/vdpa/ifc/base/ifcvf.c +++ b/drivers/vdpa/ifc/base/ifcvf.c @@ -327,3 +327,12 @@ ifcvf_get_queue_notify_off(struct ifcvf_hw *hw, int qid) return (u8 *)hw->notify_addr[qid] - (u8 *)hw->mem_resource[hw->notify_region].addr; } + +void +ifcvf_queue_enable(struct ifcvf_hw *hw, u16 qid, u16 enable) +{ + struct ifcvf_pci_common_cfg *cfg = hw->common_cfg; + + IFCVF_WRITE_REG16(qid, &cfg->queue_select); + IFCVF_WRITE_REG16(enable, &cfg->queue_enable); +} diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h index eb04a94067..bd85010eff 100644 --- a/drivers/vdpa/ifc/base/ifcvf.h +++ b/drivers/vdpa/ifc/base/ifcvf.h @@ -159,4 +159,8 @@ ifcvf_get_notify_region(struct ifcvf_hw *hw); u64 ifcvf_get_queue_notify_off(struct ifcvf_hw *hw, int qid); +void +ifcvf_queue_enable(struct ifcvf_hw *hw, u16 qid, u16 enable); + + #endif /* _IFCVF_H_ */ diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index ec97178dcb..55ce0cf13d 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -937,6 +937,27 @@ ifcvf_dev_close(int vid) return 0; } +static int +ifcvf_set_vring_state(int vid, int vring, int state) +{ + int did; + struct internal_list *list; + struct ifcvf_internal *internal; + + did = rte_vhost_get_vdpa_device_id(vid); + list = find_internal_resource_by_did(did); + if (list == NULL) { + DRV_LOG(ERR, "Invalid device id: %d", did); + return -1; + } + + internal = list->internal; + + ifcvf_queue_enable(&internal->hw, (uint16_t)vring, (uint16_t) state); + + return 0; +} + static int ifcvf_set_features(int vid) { @@ -1086,7 +1107,7 @@ static struct rte_vdpa_dev_ops ifcvf_ops = { .get_protocol_features = ifcvf_get_protocol_features, .dev_conf = ifcvf_dev_config, .dev_close = ifcvf_dev_close, - .set_vring_state = NULL, + .set_vring_state = ifcvf_set_vring_state, .set_features = ifcvf_set_features, .migration_done = NULL, .get_vfio_group_fd = ifcvf_get_vfio_group_fd,