[v7,17/18] vdpa/ifc: blk device pause without no inflight IO
Checks
Commit Message
When virtio blk device is pause, make sure hardware last_avail_idx
and last_used_idx are the same.
Signed-off-by: Andy Pei <andy.pei@intel.com>
---
drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
Comments
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Wednesday, April 27, 2022 4:30 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com; Cao,
> Gang <gang.cao@intel.com>; Liu, Changpeng <changpeng.liu@intel.com>
> Subject: [PATCH v7 17/18] vdpa/ifc: blk device pause without no inflight
> IO
>
> When virtio blk device is pause, make sure hardware last_avail_idx
> and last_used_idx are the same.
Patch is good. But illustrate more on avoiding in-flight packet in commit log
Thanks,
Chenbo
>
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
> drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 4923bc1..def6adf 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -314,12 +314,12 @@ struct rte_vdpa_dev_info {
> vdpa_ifcvf_stop(struct ifcvf_internal *internal)
> {
> struct ifcvf_hw *hw = &internal->hw;
> - struct rte_vhost_vring vq;
> uint32_t i;
> int vid;
> uint64_t features = 0;
> uint64_t log_base = 0, log_size = 0;
> uint64_t len;
> + u32 ring_state = 0;
>
> vid = internal->vid;
>
> @@ -328,13 +328,22 @@ struct rte_vdpa_dev_info {
> */
> if (internal->device_type == IFCVF_BLK) {
> for (i = 0; i < hw->nr_vring; i++) {
> - rte_vhost_get_vhost_vring(internal->vid, i, &vq);
> - while (vq.avail->idx != vq.used->idx) {
> - ifcvf_notify_queue(hw, i);
> - usleep(10);
> - }
> - hw->vring[i].last_avail_idx = vq.avail->idx;
> - hw->vring[i].last_used_idx = vq.used->idx;
> + do {
> + if (hw->lm_cfg != NULL)
> + ring_state = *(u32 *)(hw->lm_cfg +
> + IFCVF_LM_RING_STATE_OFFSET +
> + i * IFCVF_LM_CFG_SIZE);
> + hw->vring[i].last_avail_idx =
> + (u16)(ring_state & IFCVF_16_BIT_MASK);
> + hw->vring[i].last_used_idx =
> + (u16)(ring_state >> 16);
> + if (hw->vring[i].last_avail_idx !=
> + hw->vring[i].last_used_idx) {
> + ifcvf_notify_queue(hw, i);
> + usleep(10);
> + }
> + } while (hw->vring[i].last_avail_idx !=
> + hw->vring[i].last_used_idx);
> }
> }
>
> --
> 1.8.3.1
Hi Chenbo,
Thanks for reply.
This will be addressed in next version.
> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Friday, May 13, 2022 10:59 AM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Cao, Gang <gang.cao@intel.com>; Liu,
> Changpeng <changpeng.liu@intel.com>
> Subject: RE: [PATCH v7 17/18] vdpa/ifc: blk device pause without no inflight
> IO
>
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Wednesday, April 27, 2022 4:30 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com;
> > Cao, Gang <gang.cao@intel.com>; Liu, Changpeng
> > <changpeng.liu@intel.com>
> > Subject: [PATCH v7 17/18] vdpa/ifc: blk device pause without no
> > inflight IO
> >
> > When virtio blk device is pause, make sure hardware last_avail_idx and
> > last_used_idx are the same.
>
> Patch is good. But illustrate more on avoiding in-flight packet in commit log
>
> Thanks,
> Chenbo
>
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> > drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++--------
> > 1 file changed, 17 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 4923bc1..def6adf 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -314,12 +314,12 @@ struct rte_vdpa_dev_info {
> > vdpa_ifcvf_stop(struct ifcvf_internal *internal) {
> > struct ifcvf_hw *hw = &internal->hw;
> > - struct rte_vhost_vring vq;
> > uint32_t i;
> > int vid;
> > uint64_t features = 0;
> > uint64_t log_base = 0, log_size = 0;
> > uint64_t len;
> > + u32 ring_state = 0;
> >
> > vid = internal->vid;
> >
> > @@ -328,13 +328,22 @@ struct rte_vdpa_dev_info {
> > */
> > if (internal->device_type == IFCVF_BLK) {
> > for (i = 0; i < hw->nr_vring; i++) {
> > - rte_vhost_get_vhost_vring(internal->vid, i, &vq);
> > - while (vq.avail->idx != vq.used->idx) {
> > - ifcvf_notify_queue(hw, i);
> > - usleep(10);
> > - }
> > - hw->vring[i].last_avail_idx = vq.avail->idx;
> > - hw->vring[i].last_used_idx = vq.used->idx;
> > + do {
> > + if (hw->lm_cfg != NULL)
> > + ring_state = *(u32 *)(hw->lm_cfg +
> > +
> IFCVF_LM_RING_STATE_OFFSET +
> > + i * IFCVF_LM_CFG_SIZE);
> > + hw->vring[i].last_avail_idx =
> > + (u16)(ring_state &
> IFCVF_16_BIT_MASK);
> > + hw->vring[i].last_used_idx =
> > + (u16)(ring_state >> 16);
> > + if (hw->vring[i].last_avail_idx !=
> > + hw->vring[i].last_used_idx) {
> > + ifcvf_notify_queue(hw, i);
> > + usleep(10);
> > + }
> > + } while (hw->vring[i].last_avail_idx !=
> > + hw->vring[i].last_used_idx);
> > }
> > }
> >
> > --
> > 1.8.3.1
>
@@ -314,12 +314,12 @@ struct rte_vdpa_dev_info {
vdpa_ifcvf_stop(struct ifcvf_internal *internal)
{
struct ifcvf_hw *hw = &internal->hw;
- struct rte_vhost_vring vq;
uint32_t i;
int vid;
uint64_t features = 0;
uint64_t log_base = 0, log_size = 0;
uint64_t len;
+ u32 ring_state = 0;
vid = internal->vid;
@@ -328,13 +328,22 @@ struct rte_vdpa_dev_info {
*/
if (internal->device_type == IFCVF_BLK) {
for (i = 0; i < hw->nr_vring; i++) {
- rte_vhost_get_vhost_vring(internal->vid, i, &vq);
- while (vq.avail->idx != vq.used->idx) {
- ifcvf_notify_queue(hw, i);
- usleep(10);
- }
- hw->vring[i].last_avail_idx = vq.avail->idx;
- hw->vring[i].last_used_idx = vq.used->idx;
+ do {
+ if (hw->lm_cfg != NULL)
+ ring_state = *(u32 *)(hw->lm_cfg +
+ IFCVF_LM_RING_STATE_OFFSET +
+ i * IFCVF_LM_CFG_SIZE);
+ hw->vring[i].last_avail_idx =
+ (u16)(ring_state & IFCVF_16_BIT_MASK);
+ hw->vring[i].last_used_idx =
+ (u16)(ring_state >> 16);
+ if (hw->vring[i].last_avail_idx !=
+ hw->vring[i].last_used_idx) {
+ ifcvf_notify_queue(hw, i);
+ usleep(10);
+ }
+ } while (hw->vring[i].last_avail_idx !=
+ hw->vring[i].last_used_idx);
}
}