On 9/2/19 9:07 AM, Tiwei Bie wrote:
> On Thu, Aug 29, 2019 at 09:59:56AM +0200, Maxime Coquelin wrote:
>> This patch implements the vDPA .dev_close() callback.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
>> ---
>> drivers/net/virtio/virtio_vdpa.c | 52 ++++++++++++++++++++++++++++++++
>> 1 file changed, 52 insertions(+)
>>
>> diff --git a/drivers/net/virtio/virtio_vdpa.c
>> b/drivers/net/virtio/virtio_vdpa.c
>> index 13b4dd07d..691844906 100644
>> --- a/drivers/net/virtio/virtio_vdpa.c
>> +++ b/drivers/net/virtio/virtio_vdpa.c
>> @@ -436,6 +436,33 @@ virtio_vdpa_start(struct virtio_vdpa_device *dev)
>> return ret;
>> }
>>
>> +static void
>> +virtio_vdpa_stop(struct virtio_vdpa_device *dev)
>> +{
>> + struct virtio_hw *hw = &dev->hw;
>> + uint32_t i, nr_vring;
>> + int vid = dev->vid;
>> + struct rte_vhost_vring vr;
>> + uint16_t last_used_idx, last_avail_idx;
>> +
>> + nr_vring = rte_vhost_get_vring_num(vid);
>> +
>> + vtpci_reset(hw);
>> +
>> + for (i = 0; i < nr_vring; i++) {
>> + rte_vhost_get_vhost_vring(vid, i, &vr);
>> +
>> + last_used_idx = vr.used->idx;
>> + last_avail_idx = vr.avail->idx;
>
> This only works in split ring.
Right, thanks for spotting it.
For the v2, I'll try to fix it and test it with Jason's Qemu series
adding packed ring support.
> Regards,
> Tiwei
>
>> +
>> + rte_vhost_set_vring_base(vid, i, last_avail_idx,
>> + last_used_idx);
>> + }
>> +
>> + rte_free(dev->vqs);
>> + dev->vqs = NULL;
>> +}
>> +