[v4,4/8] vdpa/ifc: write queue count to MQ register

Message ID 1665650674-291949-5-git-send-email-andy.pei@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vdpa/ifc: add multi queue support |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pei, Andy Oct. 13, 2022, 8:44 a.m. UTC
  Write queue count to IFCVF_MQ_OFFSET register
to enable multi-queue feature.

Signed-off-by: Andy Pei <andy.pei@intel.com>
Signed-off-by: Huang Wei <wei.huang@intel.com>
---
 drivers/vdpa/ifc/base/ifcvf.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
  

Comments

Chenbo Xia Oct. 17, 2022, 6:23 a.m. UTC | #1
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Thursday, October 13, 2022 4:45 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Huang, Wei <wei.huang@intel.com>; Cao, Gang <gang.cao@intel.com>;
> maxime.coquelin@redhat.com
> Subject: [PATCH v4 4/8] vdpa/ifc: write queue count to MQ register
> 
> Write queue count to IFCVF_MQ_OFFSET register
> to enable multi-queue feature.
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> Signed-off-by: Huang Wei <wei.huang@intel.com>
> ---
>  drivers/vdpa/ifc/base/ifcvf.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
> index 81c68c0..60c7017 100644
> --- a/drivers/vdpa/ifc/base/ifcvf.c
> +++ b/drivers/vdpa/ifc/base/ifcvf.c
> @@ -202,6 +202,37 @@
>  	IFCVF_WRITE_REG32(val >> 32, hi);
>  }
> 
> +STATIC void
> +ifcvf_enable_mq(struct ifcvf_hw *hw)
> +{
> +	u8 *mq_cfg;
> +	u8 qid;
> +	int nr_queue = 0;
> +
> +	for (qid = 0; qid < hw->nr_vring; qid++) {
> +		if (!hw->vring[qid].enable)
> +			continue;
> +		nr_queue++;
> +	}
> +
> +	if (nr_queue == 0) {
> +		WARNINGOUT("no enabled vring\n");
> +		return;
> +	}
> +
> +	mq_cfg = hw->mq_cfg;
> +	if (mq_cfg) {
> +		if (hw->device_type == IFCVF_BLK) {
> +			*(u32 *)mq_cfg = nr_queue;
> +			RTE_LOG(INFO, PMD, "%d queue are enabled\n", nr_queue);

queue -> queues

With this fixed:

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

> +		} else {
> +			*(u32 *)mq_cfg = nr_queue / 2;
> +			RTE_LOG(INFO, PMD, "%d queue pairs are enabled\n",
> +				nr_queue / 2);
> +		}
> +	}
> +}
> +
>  STATIC int
>  ifcvf_hw_enable(struct ifcvf_hw *hw)
>  {
> @@ -219,6 +250,7 @@
>  		return -1;
>  	}
> 
> +	ifcvf_enable_mq(hw);
>  	for (i = 0; i < hw->nr_vring; i++) {
>  		IFCVF_WRITE_REG16(i, &cfg->queue_select);
>  		io_write64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,
> --
> 1.8.3.1
  
Pei, Andy Oct. 17, 2022, 6:36 a.m. UTC | #2
Hi Chenbo,

Thanks for your effort.
I will send a new version to fix this.

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Monday, October 17, 2022 2:24 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: Xu, Rosen <rosen.xu@intel.com>; Huang, Wei <wei.huang@intel.com>;
> Cao, Gang <gang.cao@intel.com>; maxime.coquelin@redhat.com
> Subject: RE: [PATCH v4 4/8] vdpa/ifc: write queue count to MQ register
> 
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Thursday, October 13, 2022 4:45 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen
> > <rosen.xu@intel.com>; Huang, Wei <wei.huang@intel.com>; Cao, Gang
> > <gang.cao@intel.com>; maxime.coquelin@redhat.com
> > Subject: [PATCH v4 4/8] vdpa/ifc: write queue count to MQ register
> >
> > Write queue count to IFCVF_MQ_OFFSET register to enable multi-queue
> > feature.
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > Signed-off-by: Huang Wei <wei.huang@intel.com>
> > ---
> >  drivers/vdpa/ifc/base/ifcvf.c | 32 ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> >
> > diff --git a/drivers/vdpa/ifc/base/ifcvf.c
> > b/drivers/vdpa/ifc/base/ifcvf.c index 81c68c0..60c7017 100644
> > --- a/drivers/vdpa/ifc/base/ifcvf.c
> > +++ b/drivers/vdpa/ifc/base/ifcvf.c
> > @@ -202,6 +202,37 @@
> >  	IFCVF_WRITE_REG32(val >> 32, hi);
> >  }
> >
> > +STATIC void
> > +ifcvf_enable_mq(struct ifcvf_hw *hw)
> > +{
> > +	u8 *mq_cfg;
> > +	u8 qid;
> > +	int nr_queue = 0;
> > +
> > +	for (qid = 0; qid < hw->nr_vring; qid++) {
> > +		if (!hw->vring[qid].enable)
> > +			continue;
> > +		nr_queue++;
> > +	}
> > +
> > +	if (nr_queue == 0) {
> > +		WARNINGOUT("no enabled vring\n");
> > +		return;
> > +	}
> > +
> > +	mq_cfg = hw->mq_cfg;
> > +	if (mq_cfg) {
> > +		if (hw->device_type == IFCVF_BLK) {
> > +			*(u32 *)mq_cfg = nr_queue;
> > +			RTE_LOG(INFO, PMD, "%d queue are enabled\n",
> nr_queue);
> 
> queue -> queues
> 
> With this fixed:
> 
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
> 
> > +		} else {
> > +			*(u32 *)mq_cfg = nr_queue / 2;
> > +			RTE_LOG(INFO, PMD, "%d queue pairs are
> enabled\n",
> > +				nr_queue / 2);
> > +		}
> > +	}
> > +}
> > +
> >  STATIC int
> >  ifcvf_hw_enable(struct ifcvf_hw *hw)
> >  {
> > @@ -219,6 +250,7 @@
> >  		return -1;
> >  	}
> >
> > +	ifcvf_enable_mq(hw);
> >  	for (i = 0; i < hw->nr_vring; i++) {
> >  		IFCVF_WRITE_REG16(i, &cfg->queue_select);
> >  		io_write64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,
> > --
> > 1.8.3.1
  

Patch

diff --git a/drivers/vdpa/ifc/base/ifcvf.c b/drivers/vdpa/ifc/base/ifcvf.c
index 81c68c0..60c7017 100644
--- a/drivers/vdpa/ifc/base/ifcvf.c
+++ b/drivers/vdpa/ifc/base/ifcvf.c
@@ -202,6 +202,37 @@ 
 	IFCVF_WRITE_REG32(val >> 32, hi);
 }
 
+STATIC void
+ifcvf_enable_mq(struct ifcvf_hw *hw)
+{
+	u8 *mq_cfg;
+	u8 qid;
+	int nr_queue = 0;
+
+	for (qid = 0; qid < hw->nr_vring; qid++) {
+		if (!hw->vring[qid].enable)
+			continue;
+		nr_queue++;
+	}
+
+	if (nr_queue == 0) {
+		WARNINGOUT("no enabled vring\n");
+		return;
+	}
+
+	mq_cfg = hw->mq_cfg;
+	if (mq_cfg) {
+		if (hw->device_type == IFCVF_BLK) {
+			*(u32 *)mq_cfg = nr_queue;
+			RTE_LOG(INFO, PMD, "%d queue are enabled\n", nr_queue);
+		} else {
+			*(u32 *)mq_cfg = nr_queue / 2;
+			RTE_LOG(INFO, PMD, "%d queue pairs are enabled\n",
+				nr_queue / 2);
+		}
+	}
+}
+
 STATIC int
 ifcvf_hw_enable(struct ifcvf_hw *hw)
 {
@@ -219,6 +250,7 @@ 
 		return -1;
 	}
 
+	ifcvf_enable_mq(hw);
 	for (i = 0; i < hw->nr_vring; i++) {
 		IFCVF_WRITE_REG16(i, &cfg->queue_select);
 		io_write64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo,