[dpdk-dev,v2,2/7] net/virtio_user: postpone DRIVER OK notification
Checks
Commit Message
In driver probe phase, we obtain device information; and then virtio
driver will initialize device and stores info, like negotiated
features, in vhost_user layer; finally, vhost_user gets DRIVER_OK
notification from virtio driver, and then sync with backend device.
Previously, DRIVER_OK could be sent twice: 1. when ether layer invokes
eth_device_init to initialize device; 2. when user configures it with
different configuration from that of previous.
Since we can only depend on DRIVER_OK notification to sync with backend
device, we postpone it to virtio_dev_start when everything is settled.
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
drivers/net/virtio/virtio_ethdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Fri, Dec 23, 2016 at 07:14:21AM +0000, Jianfeng Tan wrote:
> In driver probe phase, we obtain device information; and then virtio
> driver will initialize device and stores info, like negotiated
> features, in vhost_user layer; finally, vhost_user gets DRIVER_OK
> notification from virtio driver, and then sync with backend device.
>
> Previously, DRIVER_OK could be sent twice: 1. when ether layer invokes
> eth_device_init to initialize device; 2. when user configures it with
> different configuration from that of previous.
Yes, but that's wrong. Now only 1) will be taken.
> Since we can only depend on DRIVER_OK notification to sync with backend
> device, we postpone it to virtio_dev_start when everything is settled.
I don't quite understand what you were going to fix here; you don't
state it in the commit log after all. Normally, when everything is
negotiated (when DRIVER_OK is set), we should not set it again, unless
a reset has been happened.
If you look at QEMU, qemu will simply ignore it once vhost has already
started.
--yliu
> -----Original Message-----
> From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> Sent: Monday, December 26, 2016 2:27 PM
> To: Tan, Jianfeng
> Cc: dev@dpdk.org; Yigit, Ferruh; Liang, Cunming
> Subject: Re: [PATCH v2 2/7] net/virtio_user: postpone DRIVER OK notification
>
> On Fri, Dec 23, 2016 at 07:14:21AM +0000, Jianfeng Tan wrote:
> > In driver probe phase, we obtain device information; and then virtio
> > driver will initialize device and stores info, like negotiated
> > features, in vhost_user layer; finally, vhost_user gets DRIVER_OK
> > notification from virtio driver, and then sync with backend device.
> >
> > Previously, DRIVER_OK could be sent twice: 1. when ether layer invokes
> > eth_device_init to initialize device; 2. when user configures it with
> > different configuration from that of previous.
>
> Yes, but that's wrong. Now only 1) will be taken.
From code in virtio_dev_configure() as below, if hw_ip_checksum or enable_lro is configured, the device will be reset and re-initialized.
if (rxmode->hw_ip_checksum)
req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM);
if (rxmode->enable_lro)
req_features |=
(1ULL << VIRTIO_NET_F_GUEST_TSO4) |
(1ULL << VIRTIO_NET_F_GUEST_TSO6);
/* if request features changed, reinit the device */
if (req_features != hw->req_guest_features) {
ret = virtio_init_device(dev, req_features);
if (ret < 0)
return ret;
}
>
> > Since we can only depend on DRIVER_OK notification to sync with backend
> > device, we postpone it to virtio_dev_start when everything is settled.
>
> I don't quite understand what you were going to fix here; you don't
> state it in the commit log after all. Normally, when everything is
> negotiated (when DRIVER_OK is set), we should not set it again, unless
> a reset has been happened.
I agree that DRIVER_OK should be set only if everything is settled. Under the case of hw_ip_checksum or enable_lro, a reset will be sent and the device will be re-initialized.
So my point is that since the configuration might be changed in dev_configure(), why not just send DRIVER_OK after everything is done.
>
> If you look at QEMU, qemu will simply ignore it once vhost has already
> started.
It does not apply here. The configuration is changed, and it cannot be ignored.
Thanks,
Jianfeng
>
> --yliu
On Mon, Dec 26, 2016 at 06:55:16AM +0000, Tan, Jianfeng wrote:
>
>
> > -----Original Message-----
> > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> > Sent: Monday, December 26, 2016 2:27 PM
> > To: Tan, Jianfeng
> > Cc: dev@dpdk.org; Yigit, Ferruh; Liang, Cunming
> > Subject: Re: [PATCH v2 2/7] net/virtio_user: postpone DRIVER OK notification
> >
> > On Fri, Dec 23, 2016 at 07:14:21AM +0000, Jianfeng Tan wrote:
> > > In driver probe phase, we obtain device information; and then virtio
> > > driver will initialize device and stores info, like negotiated
> > > features, in vhost_user layer; finally, vhost_user gets DRIVER_OK
> > > notification from virtio driver, and then sync with backend device.
> > >
> > > Previously, DRIVER_OK could be sent twice: 1. when ether layer invokes
> > > eth_device_init to initialize device; 2. when user configures it with
> > > different configuration from that of previous.
> >
> > Yes, but that's wrong. Now only 1) will be taken.
>
> >From code in virtio_dev_configure() as below, if hw_ip_checksum or enable_lro is configured, the device will be reset and re-initialized.
> if (rxmode->hw_ip_checksum)
> req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM);
> if (rxmode->enable_lro)
> req_features |=
> (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
> (1ULL << VIRTIO_NET_F_GUEST_TSO6);
>
> /* if request features changed, reinit the device */
> if (req_features != hw->req_guest_features) {
> ret = virtio_init_device(dev, req_features);
> if (ret < 0)
> return ret;
> }
Yes, I know. But virtio_init_device() will call vtpci_reinit_complete()
at the end, doesn't it?
> > > Since we can only depend on DRIVER_OK notification to sync with backend
> > > device, we postpone it to virtio_dev_start when everything is settled.
> >
> > I don't quite understand what you were going to fix here; you don't
> > state it in the commit log after all. Normally, when everything is
> > negotiated (when DRIVER_OK is set), we should not set it again, unless
> > a reset has been happened.
>
> I agree that DRIVER_OK should be set only if everything is settled. Under the case of hw_ip_checksum or enable_lro, a reset will be sent and the device will be re-initialized.
>
> So my point is that since the configuration might be changed in dev_configure(), why not just send DRIVER_OK after everything is done.
>
> >
> > If you look at QEMU, qemu will simply ignore it once vhost has already
> > started.
>
> It does not apply here. The configuration is changed, and it cannot be ignored.
Why it doesn't apply here? What makes virtio_user special? If it works
to QEMU and it doesn't to virtio_user, it basically means the virtio_user
is broken ...
--yliu
As discussed offline, this will lead to many DRIVER OK among dev_stop()/dev_start(). I'll remove this patch.
Thanks,
Jianfeng
> -----Original Message-----
> From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> Sent: Monday, December 26, 2016 4:02 PM
> To: Tan, Jianfeng
> Cc: dev@dpdk.org; Yigit, Ferruh; Liang, Cunming
> Subject: Re: [PATCH v2 2/7] net/virtio_user: postpone DRIVER OK notification
>
> On Mon, Dec 26, 2016 at 06:55:16AM +0000, Tan, Jianfeng wrote:
> >
> >
> > > -----Original Message-----
> > > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]
> > > Sent: Monday, December 26, 2016 2:27 PM
> > > To: Tan, Jianfeng
> > > Cc: dev@dpdk.org; Yigit, Ferruh; Liang, Cunming
> > > Subject: Re: [PATCH v2 2/7] net/virtio_user: postpone DRIVER OK
> notification
> > >
> > > On Fri, Dec 23, 2016 at 07:14:21AM +0000, Jianfeng Tan wrote:
> > > > In driver probe phase, we obtain device information; and then virtio
> > > > driver will initialize device and stores info, like negotiated
> > > > features, in vhost_user layer; finally, vhost_user gets DRIVER_OK
> > > > notification from virtio driver, and then sync with backend device.
> > > >
> > > > Previously, DRIVER_OK could be sent twice: 1. when ether layer
> invokes
> > > > eth_device_init to initialize device; 2. when user configures it with
> > > > different configuration from that of previous.
> > >
> > > Yes, but that's wrong. Now only 1) will be taken.
> >
> > >From code in virtio_dev_configure() as below, if hw_ip_checksum or
> enable_lro is configured, the device will be reset and re-initialized.
> > if (rxmode->hw_ip_checksum)
> > req_features |= (1ULL << VIRTIO_NET_F_GUEST_CSUM);
> > if (rxmode->enable_lro)
> > req_features |=
> > (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
> > (1ULL << VIRTIO_NET_F_GUEST_TSO6);
> >
> > /* if request features changed, reinit the device */
> > if (req_features != hw->req_guest_features) {
> > ret = virtio_init_device(dev, req_features);
> > if (ret < 0)
> > return ret;
> > }
>
> Yes, I know. But virtio_init_device() will call vtpci_reinit_complete()
> at the end, doesn't it?
>
> > > > Since we can only depend on DRIVER_OK notification to sync with
> backend
> > > > device, we postpone it to virtio_dev_start when everything is settled.
> > >
> > > I don't quite understand what you were going to fix here; you don't
> > > state it in the commit log after all. Normally, when everything is
> > > negotiated (when DRIVER_OK is set), we should not set it again, unless
> > > a reset has been happened.
> >
> > I agree that DRIVER_OK should be set only if everything is settled. Under
> the case of hw_ip_checksum or enable_lro, a reset will be sent and the
> device will be re-initialized.
> >
> > So my point is that since the configuration might be changed in
> dev_configure(), why not just send DRIVER_OK after everything is done.
> >
> > >
> > > If you look at QEMU, qemu will simply ignore it once vhost has already
> > > started.
> >
> > It does not apply here. The configuration is changed, and it cannot be
> ignored.
>
> Why it doesn't apply here? What makes virtio_user special? If it works
> to QEMU and it doesn't to virtio_user, it basically means the virtio_user
> is broken ...
>
> --yliu
@@ -1276,7 +1276,6 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
ret = virtio_alloc_queues(eth_dev);
if (ret < 0)
return ret;
- vtpci_reinit_complete(hw);
if (pci_dev)
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
@@ -1474,6 +1473,8 @@ virtio_dev_start(struct rte_eth_dev *dev)
struct virtnet_tx *txvq __rte_unused;
struct virtio_hw *hw = dev->data->dev_private;
+ vtpci_reinit_complete(hw);
+
/* check if lsc interrupt feature is enabled */
if (dev->data->dev_conf.intr_conf.lsc) {
if (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)) {