On Fri, Oct 06, 2023 at 03:58:44PM +0200, Hanna Czenczek wrote: > On 06.10.23 15:55, Hanna Czenczek wrote: > > On 06.10.23 10:49, Michael S. Tsirkin wrote: > > > On Fri, Oct 06, 2023 at 09:53:53AM +0200, Hanna Czenczek wrote: > > > > On 05.10.23 19:38, Stefan Hajnoczi wrote: > > > > > On Wed, Oct 04, 2023 at 02:58:58PM +0200, Hanna Czenczek wrote: > > [...] > > > > > > ``VHOST_USER_GET_VRING_BASE`` > > > > > :id: 11 > > > > > :equivalent ioctl: ``VHOST_USER_GET_VRING_BASE`` > > > > > :request payload: vring state description > > > > > - :reply payload: vring state description > > > > > + :reply payload: vring descriptor index/indices > > > > > + > > > > > + Stops the vring and returns the current descriptor index > > > > > or indices: > > > > > + > > > > > + * For a split virtqueue, returns only the 16-bit next descriptor > > > > > + index in the *Available Ring*. The index in the *Used Ring* is > > > > > + controlled by the guest driver and can be read from the vring > > > > > I find "is controlled by the guest driver" confusing. The > > > > > device writes > > > > > the Used Ring index. The driver only reads it. The device is > > > > > the active > > > > > party here. > > > > Er, good point. That breaks the whole reasoning. Then I don’t > > > > understand > > > > why we do get/set the available ring index and not the used ring > > > > index. Do > > > > you know why? > > > It's simple. used ring index in memory is controlled by the device and > > > reflects device state. > > > > Exactly, it’s device state, that’s why I thought the front-end needs to > > ensure its read and restored around the reset we currently have in > > vhost_dev_stop()/start(). > > > > > device can just read it back to restore. > > > > I find it strange that the device is supposed to read its own state from > > memory. > > > > > available ring index in memory is controlled by driver and does > > > not reflect device state. > > > > Why can’t the device read the available index from memory? That value > > is put into memory by the driver precisely so the device can read it > > from there. > > Ah, wait, is the idea that the device may have an internal available index > counter that reflects what descriptor it has already fetched? I.e. this > index will lag behind the one in memory, and the difference are new > descriptors that the device still needs to read? If that internal counter is > the index that’s get/set here, then yes, that makes a lot of sense. > > Hanna
Exactly. And this gets eventually written out as used index. -- MST