From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF115A0613 for ; Mon, 23 Sep 2019 10:14:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 942911BECA; Mon, 23 Sep 2019 10:14:56 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E383B1BEC9 for ; Mon, 23 Sep 2019 10:14:54 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 01:14:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="195303458" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.73]) by FMSMGA003.fm.intel.com with ESMTP; 23 Sep 2019 01:14:51 -0700 Date: Mon, 23 Sep 2019 16:12:05 +0800 From: Tiwei Bie To: Andy Pei Cc: dev@dpdk.org, rosen.xu@intel.com, xiaolong.ye@intel.com, xiao.w.wang@intel.com, maxime.coquelin@redhat.com, zhihong.wang@intel.com Message-ID: <20190923081205.GA29817@___> References: <1568711388-257817-1-git-send-email-andy.pei@intel.com> <1568711388-257817-2-git-send-email-andy.pei@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1568711388-257817-2-git-send-email-andy.pei@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v2 2/3] vhost: call vDPA callback at the end of vring enable handler 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" On Tue, Sep 17, 2019 at 05:09:47PM +0800, Andy Pei wrote: > vDPA's set_vring_state callback would need to know the virtqueues' > enable status to configure the hardware. > > Signed-off-by: Xiaolong Ye > Signed-off-by: Andy Pei > --- > v2: > add nr_active_vring as a parameter to ops function set_vring_state in > case of callback in set_vring_state() and avoid exposing new API. > > lib/librte_vhost/rte_vdpa.h | 4 ++-- > lib/librte_vhost/vhost_user.c | 27 +++++++++++++++++++++++++-- > 2 files changed, 27 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h > index 9a3deb3..6e55d4d 100644 > --- a/lib/librte_vhost/rte_vdpa.h > +++ b/lib/librte_vhost/rte_vdpa.h > @@ -54,8 +54,8 @@ struct rte_vdpa_dev_ops { > int (*dev_conf)(int vid); > int (*dev_close)(int vid); > > - /** Enable/disable this vring */ > - int (*set_vring_state)(int vid, int vring, int state); > + /** Enable/disable vring queue pairs */ > + int (*set_vring_state)(int vid, int nr_active_vring); We should avoid changing the API/ABI unless we have a very good justification. With the existing API, it should be easy to get the number of active rings by maintaining a bitmap or something similar in ifc driver. Besides, please keep other maintainers got from get-maintainer.sh in the Cc list as well. Thanks, Tiwei > > /** Set features when changed */ > int (*set_features)(int vid); > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index 0b72648..4d7de44 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -1325,6 +1325,25 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused, > return RTE_VHOST_MSG_RESULT_REPLY; > } > > +static uint16_t > +vhost_get_active_vring_num(int vid) > +{ > + struct virtio_net *dev = get_device(vid); > + struct vhost_virtqueue *vq; > + uint16_t qid; > + > + if (dev == NULL) > + return 0; > + > + for (qid = 0; qid < dev->nr_vring; qid++) { > + vq = dev->virtqueue[qid]; > + if (!vq->enabled) > + break; > + } > + > + return qid; > +} > + > /* > * when virtio queues are ready to work, qemu will send us to > * enable the virtio queue pair. > @@ -1339,6 +1358,7 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused, > int index = (int)msg->payload.state.index; > struct rte_vdpa_device *vdpa_dev; > int did = -1; > + int nr_active_vring; > > RTE_LOG(INFO, VHOST_CONFIG, > "set queue enable: %d to qp idx: %d\n", > @@ -1346,8 +1366,6 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused, > > did = dev->vdpa_dev_id; > vdpa_dev = rte_vdpa_get_device(did); > - if (vdpa_dev && vdpa_dev->ops->set_vring_state) > - vdpa_dev->ops->set_vring_state(dev->vid, index, enable); > > if (dev->notify_ops->vring_state_changed) > dev->notify_ops->vring_state_changed(dev->vid, > @@ -1359,6 +1377,11 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused, > > dev->virtqueue[index]->enabled = enable; > > + if (vdpa_dev && vdpa_dev->ops->set_vring_state) { > + nr_active_vring = vhost_get_active_vring_num(dev->vid); > + vdpa_dev->ops->set_vring_state(dev->vid, nr_active_vring); > + } > + > return RTE_VHOST_MSG_RESULT_OK; > } > > -- > 1.8.3.1 >