patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/virtio: fix advertised Rx offload capabilities
@ 2017-01-11 17:05 Olivier Matz
  2017-01-16  6:12 ` Yuanhan Liu
  2017-01-17 10:35 ` [dpdk-stable] [PATCH v2] " Olivier Matz
  0 siblings, 2 replies; 6+ messages in thread
From: Olivier Matz @ 2017-01-11 17:05 UTC (permalink / raw)
  To: dev, yuanhan.liu; +Cc: stable

When the virtio PMD is used on top of a vhost that does not support
offloads, Rx offload capabilities are still advertised by
virtio_dev_info_get(). But if an application tries to start the PMD with
Rx offloads enabled (rxmode.hw_ip_checksum = 1), the initialization of
the device will fail with -ENOTSUP and the following log:

  rx ip checksum not available on this host

This patch fixes the Rx offload capabilities returned by
virtio_dev_info_get() to be consistent with features advertised by the
host.

Fixes: 96cb6711939e ("net/virtio: support Rx checksum offload")
Fixes: 86d59b21468a ("net/virtio: support LRO")

CC: stable@dpdk.org
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 drivers/net/virtio/virtio_ethdev.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 817fedf..0d7f587 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1629,7 +1629,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 static void
 virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-	uint64_t tso_mask;
+	uint64_t tso_mask, host_features;
 	struct virtio_hw *hw = dev->data->dev_private;
 
 	dev_info->pci_dev = hw->dev;
@@ -1643,18 +1643,25 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.txq_flags = ETH_TXQ_FLAGS_NOOFFLOADS
 	};
-	dev_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_TCP_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_LRO;
-	dev_info->tx_offload_capa = 0;
 
+	host_features = hw->vtpci_ops->get_features(hw);
+	dev_info->rx_offload_capa = 0;
+	if (host_features & (1ULL << VIRTIO_NET_F_GUEST_CSUM)) {
+		dev_info->rx_offload_capa |=
+			DEV_RX_OFFLOAD_TCP_CKSUM |
+			DEV_RX_OFFLOAD_UDP_CKSUM;
+	}
+	tso_mask = (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
+		(1ULL << VIRTIO_NET_F_GUEST_TSO6);
+	if ((host_features & tso_mask) == tso_mask)
+		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
+
+	dev_info->tx_offload_capa = 0;
 	if (hw->guest_features & (1ULL << VIRTIO_NET_F_CSUM)) {
 		dev_info->tx_offload_capa |=
 			DEV_TX_OFFLOAD_UDP_CKSUM |
 			DEV_TX_OFFLOAD_TCP_CKSUM;
 	}
-
 	tso_mask = (1ULL << VIRTIO_NET_F_HOST_TSO4) |
 		(1ULL << VIRTIO_NET_F_HOST_TSO6);
 	if ((hw->guest_features & tso_mask) == tso_mask)
-- 
2.8.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio: fix advertised Rx offload capabilities
  2017-01-11 17:05 [dpdk-stable] [PATCH] net/virtio: fix advertised Rx offload capabilities Olivier Matz
@ 2017-01-16  6:12 ` Yuanhan Liu
  2017-01-17 10:33   ` Olivier Matz
  2017-01-17 10:35 ` [dpdk-stable] [PATCH v2] " Olivier Matz
  1 sibling, 1 reply; 6+ messages in thread
From: Yuanhan Liu @ 2017-01-16  6:12 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, stable

On Wed, Jan 11, 2017 at 06:05:25PM +0100, Olivier Matz wrote:
> When the virtio PMD is used on top of a vhost that does not support
> offloads, Rx offload capabilities are still advertised by
> virtio_dev_info_get(). But if an application tries to start the PMD with
> Rx offloads enabled (rxmode.hw_ip_checksum = 1), the initialization of
> the device will fail with -ENOTSUP and the following log:
> 
>   rx ip checksum not available on this host
> 
> This patch fixes the Rx offload capabilities returned by
> virtio_dev_info_get() to be consistent with features advertised by the
> host.
> 
> Fixes: 96cb6711939e ("net/virtio: support Rx checksum offload")
> Fixes: 86d59b21468a ("net/virtio: support LRO")

Hi Olivier,

This patch doesn't apply cleanly on top of next-virtio repo, would you
midn to send v2, so that I can apply?

Thanks.

	--yliu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio: fix advertised Rx offload capabilities
  2017-01-16  6:12 ` Yuanhan Liu
@ 2017-01-17 10:33   ` Olivier Matz
  0 siblings, 0 replies; 6+ messages in thread
From: Olivier Matz @ 2017-01-17 10:33 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev, stable

On Mon, 16 Jan 2017 14:12:43 +0800, Yuanhan Liu
<yuanhan.liu@linux.intel.com> wrote:
> On Wed, Jan 11, 2017 at 06:05:25PM +0100, Olivier Matz wrote:
> > When the virtio PMD is used on top of a vhost that does not support
> > offloads, Rx offload capabilities are still advertised by
> > virtio_dev_info_get(). But if an application tries to start the PMD
> > with Rx offloads enabled (rxmode.hw_ip_checksum = 1), the
> > initialization of the device will fail with -ENOTSUP and the
> > following log:
> > 
> >   rx ip checksum not available on this host
> > 
> > This patch fixes the Rx offload capabilities returned by
> > virtio_dev_info_get() to be consistent with features advertised by
> > the host.
> > 
> > Fixes: 96cb6711939e ("net/virtio: support Rx checksum offload")
> > Fixes: 86d59b21468a ("net/virtio: support LRO")  
> 
> Hi Olivier,
> 
> This patch doesn't apply cleanly on top of next-virtio repo, would you
> midn to send v2, so that I can apply?

Sure, will do.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-stable] [PATCH v2] net/virtio: fix advertised Rx offload capabilities
  2017-01-11 17:05 [dpdk-stable] [PATCH] net/virtio: fix advertised Rx offload capabilities Olivier Matz
  2017-01-16  6:12 ` Yuanhan Liu
@ 2017-01-17 10:35 ` Olivier Matz
  2017-01-17 11:08   ` Yuanhan Liu
  1 sibling, 1 reply; 6+ messages in thread
From: Olivier Matz @ 2017-01-17 10:35 UTC (permalink / raw)
  To: dev, yuanhan.liu; +Cc: stable

When the virtio PMD is used on top of a vhost that does not support
offloads, Rx offload capabilities are still advertised by
virtio_dev_info_get(). But if an application tries to start the PMD with
Rx offloads enabled (rxmode.hw_ip_checksum = 1), the initialization of
the device will fail with -ENOTSUP and the following log:

  rx ip checksum not available on this host

This patch fixes the Rx offload capabilities returned by
virtio_dev_info_get() to be consistent with features advertised by the
host.

Fixes: 96cb6711939e ("net/virtio: support Rx checksum offload")
Fixes: 86d59b21468a ("net/virtio: support LRO")

CC: stable@dpdk.org
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

v1 -> v2:
- rebase on top of virtio-net


 drivers/net/virtio/virtio_ethdev.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index d580257..df2c24b 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1829,7 +1829,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 static void
 virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
-	uint64_t tso_mask;
+	uint64_t tso_mask, host_features;
 	struct virtio_hw *hw = dev->data->dev_private;
 
 	dev_info->pci_dev = dev->device ? RTE_DEV_TO_PCI(dev->device) : NULL;
@@ -1843,18 +1843,25 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_txconf = (struct rte_eth_txconf) {
 		.txq_flags = ETH_TXQ_FLAGS_NOOFFLOADS
 	};
-	dev_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_TCP_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_LRO;
-	dev_info->tx_offload_capa = 0;
 
+	host_features = hw->vtpci_ops->get_features(hw);
+	dev_info->rx_offload_capa = 0;
+	if (host_features & (1ULL << VIRTIO_NET_F_GUEST_CSUM)) {
+		dev_info->rx_offload_capa |=
+			DEV_RX_OFFLOAD_TCP_CKSUM |
+			DEV_RX_OFFLOAD_UDP_CKSUM;
+	}
+	tso_mask = (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
+		(1ULL << VIRTIO_NET_F_GUEST_TSO6);
+	if ((host_features & tso_mask) == tso_mask)
+		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
+
+	dev_info->tx_offload_capa = 0;
 	if (hw->guest_features & (1ULL << VIRTIO_NET_F_CSUM)) {
 		dev_info->tx_offload_capa |=
 			DEV_TX_OFFLOAD_UDP_CKSUM |
 			DEV_TX_OFFLOAD_TCP_CKSUM;
 	}
-
 	tso_mask = (1ULL << VIRTIO_NET_F_HOST_TSO4) |
 		(1ULL << VIRTIO_NET_F_HOST_TSO6);
 	if ((hw->guest_features & tso_mask) == tso_mask)
-- 
2.8.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-stable] [PATCH v2] net/virtio: fix advertised Rx offload capabilities
  2017-01-17 10:35 ` [dpdk-stable] [PATCH v2] " Olivier Matz
@ 2017-01-17 11:08   ` Yuanhan Liu
  2017-01-17 11:20     ` Olivier Matz
  0 siblings, 1 reply; 6+ messages in thread
From: Yuanhan Liu @ 2017-01-17 11:08 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, stable

On Tue, Jan 17, 2017 at 11:35:53AM +0100, Olivier Matz wrote:
 
> +	host_features = hw->vtpci_ops->get_features(hw);

Note that hw->vtpci_ops doesn't exist any more, due to fixing the virtio
multiple process bugs. I changed it to:

        host_features = VTPCI_OPS(hw)->get_features(hw);

And applied to dpdk-next-virtio.

Thanks.

	--yliu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-stable] [PATCH v2] net/virtio: fix advertised Rx offload capabilities
  2017-01-17 11:08   ` Yuanhan Liu
@ 2017-01-17 11:20     ` Olivier Matz
  0 siblings, 0 replies; 6+ messages in thread
From: Olivier Matz @ 2017-01-17 11:20 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev, stable

On Tue, 17 Jan 2017 19:08:38 +0800, Yuanhan Liu
<yuanhan.liu@linux.intel.com> wrote:
> On Tue, Jan 17, 2017 at 11:35:53AM +0100, Olivier Matz wrote:
>  
> > +	host_features = hw->vtpci_ops->get_features(hw);  
> 
> Note that hw->vtpci_ops doesn't exist any more, due to fixing the
> virtio multiple process bugs. I changed it to:
> 
>         host_features = VTPCI_OPS(hw)->get_features(hw);
> 

Sorry I missed it. Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-17 11:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-11 17:05 [dpdk-stable] [PATCH] net/virtio: fix advertised Rx offload capabilities Olivier Matz
2017-01-16  6:12 ` Yuanhan Liu
2017-01-17 10:33   ` Olivier Matz
2017-01-17 10:35 ` [dpdk-stable] [PATCH v2] " Olivier Matz
2017-01-17 11:08   ` Yuanhan Liu
2017-01-17 11:20     ` Olivier Matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).