vdpa/ifcvf: fix the calculation of queuepair
authorAngus Chen <angus.chen@jaguarmicro.com>
Fri, 23 Sep 2022 09:10:13 +0000 (17:10 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 27 Sep 2022 22:30:48 +0000 (18:30 -0400)
The q_pair_id to address a queue pair in the lm bar should be
calculated by queue_id / 2 rather than queue_id / nr_vring.

Fixes: 2ddae773c93b ("vDPA/ifcvf: detect and use the onboard number of queues directly")
Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Zhu Lingshan <lingshan.zhu@intel.com>
Message-Id: <20220923091013.191-1-angus.chen@jaguarmicro.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vdpa/ifcvf/ifcvf_base.c

index 75a703b803a240bdb966acac2d6bfe0bc8cdded7..3e4486bfa0b71266c43eb5920c778ba40e9cface 100644 (file)
@@ -323,7 +323,7 @@ u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid)
        u32 q_pair_id;
 
        ifcvf_lm = (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg;
-       q_pair_id = qid / hw->nr_vring;
+       q_pair_id = qid / 2;
        avail_idx_addr = &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2];
        last_avail_idx = vp_ioread16(avail_idx_addr);
 
@@ -337,7 +337,7 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)
        u32 q_pair_id;
 
        ifcvf_lm = (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg;
-       q_pair_id = qid / hw->nr_vring;
+       q_pair_id = qid / 2;
        avail_idx_addr = &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2];
        hw->vring[qid].last_avail_idx = num;
        vp_iowrite16(num, avail_idx_addr);