[dpdk-stable] patch 'net/virtio: fix link update in speed feature' has been queued to stable release 20.11.4

Xueming Li xuemingl at nvidia.com
Wed Nov 10 07:31:41 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/33dcf11cc953ddf9add582cc9f4356474657940f

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 33dcf11cc953ddf9add582cc9f4356474657940f Mon Sep 17 00:00:00 2001
From: Ivan Ilchenko <ivan.ilchenko at oktetlabs.ru>
Date: Fri, 22 Oct 2021 16:17:54 +0300
Subject: [PATCH] net/virtio: fix link update in speed feature
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 3c3c54cfa6b38b48e9b817653fde32631aec024d ]

Link update callback reports speed/duplex based on data
filled on device initialization. This is wrong in case of
VIRTIO_NET_F_SPEED_DUPLEX is negotiated since link could
be down at this time. Fix this function to actually
update the HW data in this case with respect to the fact
that specifying speed via devarg is a highest priority.

Fixes: 1357b4b36246 ("net/virtio: support Virtio link speed feature")

Signed-off-by: Ivan Ilchenko <ivan.ilchenko at oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 drivers/net/virtio/virtio_ethdev.c | 47 +++++++++++++++++++++---------
 drivers/net/virtio/virtio_pci.h    |  5 ++++
 2 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index afa9fb591f..be6a687d54 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1745,6 +1745,32 @@ virtio_configure_intr(struct rte_eth_dev *dev)
 
 	return 0;
 }
+
+static void
+virtio_get_speed_duplex(struct rte_eth_dev *eth_dev,
+			struct rte_eth_link *link)
+{
+	struct virtio_hw *hw = eth_dev->data->dev_private;
+	struct virtio_net_config *config;
+	struct virtio_net_config local_config;
+
+	config = &local_config;
+	vtpci_read_dev_config(hw,
+		offsetof(struct virtio_net_config, speed),
+		&config->speed, sizeof(config->speed));
+	vtpci_read_dev_config(hw,
+		offsetof(struct virtio_net_config, duplex),
+		&config->duplex, sizeof(config->duplex));
+	hw->speed = config->speed;
+	hw->duplex = config->duplex;
+	if (link != NULL) {
+		link->link_duplex = hw->duplex;
+		link->link_speed  = hw->speed;
+	}
+	PMD_INIT_LOG(DEBUG, "link speed = %d, duplex = %d",
+		     hw->speed, hw->duplex);
+}
+
 #define DUPLEX_UNKNOWN   0xff
 /* reset device and renegotiate features if needed */
 static int
@@ -1803,19 +1829,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
 		     hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2],
 		     hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]);
 
-	if (hw->speed == ETH_SPEED_NUM_UNKNOWN) {
-		if (vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) {
-			config = &local_config;
-			vtpci_read_dev_config(hw,
-				offsetof(struct virtio_net_config, speed),
-				&config->speed, sizeof(config->speed));
-			vtpci_read_dev_config(hw,
-				offsetof(struct virtio_net_config, duplex),
-				&config->duplex, sizeof(config->duplex));
-			hw->speed = config->speed;
-			hw->duplex = config->duplex;
-		}
-	}
+	hw->get_speed_via_feat = hw->speed == ETH_SPEED_NUM_UNKNOWN &&
+			     vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX);
+	if (hw->get_speed_via_feat)
+		virtio_get_speed_duplex(eth_dev, NULL);
 	if (hw->duplex == DUPLEX_UNKNOWN)
 		hw->duplex = ETH_LINK_FULL_DUPLEX;
 	PMD_INIT_LOG(DEBUG, "link speed = %d, duplex = %d",
@@ -2688,11 +2705,15 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 				     dev->data->port_id);
 		} else {
 			link.link_status = ETH_LINK_UP;
+			if (hw->get_speed_via_feat)
+				virtio_get_speed_duplex(dev, &link);
 			PMD_INIT_LOG(DEBUG, "Port %d is up",
 				     dev->data->port_id);
 		}
 	} else {
 		link.link_status = ETH_LINK_UP;
+		if (hw->get_speed_via_feat)
+			virtio_get_speed_duplex(dev, &link);
 	}
 
 	return rte_eth_linkstatus_set(dev, &link);
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index f56d3e8bb7..a1696bce1a 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -264,6 +264,11 @@ struct virtio_hw {
 	bool        has_rx_offload;
 	uint16_t    port_id;
 	uint8_t     mac_addr[RTE_ETHER_ADDR_LEN];
+	/*
+	 * Speed is specified via 'speed' devarg or
+	 * negotiated via VIRTIO_NET_F_SPEED_DUPLEX
+	 */
+	bool get_speed_via_feat;
 	uint32_t    notify_off_multiplier;
 	uint32_t    speed;  /* link speed in MB */
 	uint8_t     duplex;
-- 
2.33.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-10 14:17:11.484346588 +0800
+++ 0217-net-virtio-fix-link-update-in-speed-feature.patch	2021-11-10 14:17:02.030744782 +0800
@@ -1 +1 @@
-From 3c3c54cfa6b38b48e9b817653fde32631aec024d Mon Sep 17 00:00:00 2001
+From 33dcf11cc953ddf9add582cc9f4356474657940f Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 3c3c54cfa6b38b48e9b817653fde32631aec024d ]
@@ -14 +16,0 @@
-Cc: stable at dpdk.org
@@ -20,3 +22,3 @@
- drivers/net/virtio/virtio.h        |  5 ++++
- drivers/net/virtio/virtio_ethdev.c | 46 +++++++++++++++++++++---------
- 2 files changed, 38 insertions(+), 13 deletions(-)
+ drivers/net/virtio/virtio_ethdev.c | 47 +++++++++++++++++++++---------
+ drivers/net/virtio/virtio_pci.h    |  5 ++++
+ 2 files changed, 39 insertions(+), 13 deletions(-)
@@ -24,16 +25,0 @@
-diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h
-index 9a2ab2caea..5c8f71a44d 100644
---- a/drivers/net/virtio/virtio.h
-+++ b/drivers/net/virtio/virtio.h
-@@ -203,6 +203,11 @@ struct virtio_hw {
- 	uint8_t opened;
- 	uint16_t port_id;
- 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
-+	/*
-+	 * Speed is specified via 'speed' devarg or
-+	 * negotiated via VIRTIO_NET_F_SPEED_DUPLEX
-+	 */
-+	bool get_speed_via_feat;
- 	uint32_t speed;  /* link speed in MB */
- 	uint8_t duplex;
- 	uint8_t intr_lsc;
@@ -41 +27 @@
-index 4570bec057..c2588369b2 100644
+index afa9fb591f..be6a687d54 100644
@@ -44 +30,2 @@
-@@ -1843,6 +1843,31 @@ virtio_configure_intr(struct rte_eth_dev *dev)
+@@ -1745,6 +1745,32 @@ virtio_configure_intr(struct rte_eth_dev *dev)
+ 
@@ -47 +34 @@
- 
++
@@ -57 +44 @@
-+	virtio_read_dev_config(hw,
++	vtpci_read_dev_config(hw,
@@ -60 +47 @@
-+	virtio_read_dev_config(hw,
++	vtpci_read_dev_config(hw,
@@ -73,4 +60,4 @@
- static uint64_t
- ethdev_to_virtio_rss_offloads(uint64_t ethdev_hash_types)
- {
-@@ -2225,19 +2250,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
+ #define DUPLEX_UNKNOWN   0xff
+ /* reset device and renegotiate features if needed */
+ static int
+@@ -1803,19 +1829,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
@@ -80,2 +67,2 @@
--	if (hw->speed == RTE_ETH_SPEED_NUM_UNKNOWN) {
--		if (virtio_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) {
+-	if (hw->speed == ETH_SPEED_NUM_UNKNOWN) {
+-		if (vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) {
@@ -83 +70 @@
--			virtio_read_dev_config(hw,
+-			vtpci_read_dev_config(hw,
@@ -86 +73 @@
--			virtio_read_dev_config(hw,
+-			vtpci_read_dev_config(hw,
@@ -93,2 +80,2 @@
-+	hw->get_speed_via_feat = hw->speed == RTE_ETH_SPEED_NUM_UNKNOWN &&
-+			     virtio_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX);
++	hw->get_speed_via_feat = hw->speed == ETH_SPEED_NUM_UNKNOWN &&
++			     vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX);
@@ -98 +85 @@
- 		hw->duplex = RTE_ETH_LINK_FULL_DUPLEX;
+ 		hw->duplex = ETH_LINK_FULL_DUPLEX;
@@ -100 +87 @@
-@@ -2964,11 +2980,15 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
+@@ -2688,11 +2705,15 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
@@ -103 +90 @@
- 			link.link_status = RTE_ETH_LINK_UP;
+ 			link.link_status = ETH_LINK_UP;
@@ -110 +97 @@
- 		link.link_status = RTE_ETH_LINK_UP;
+ 		link.link_status = ETH_LINK_UP;
@@ -115,0 +103,16 @@
+diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
+index f56d3e8bb7..a1696bce1a 100644
+--- a/drivers/net/virtio/virtio_pci.h
++++ b/drivers/net/virtio/virtio_pci.h
+@@ -264,6 +264,11 @@ struct virtio_hw {
+ 	bool        has_rx_offload;
+ 	uint16_t    port_id;
+ 	uint8_t     mac_addr[RTE_ETHER_ADDR_LEN];
++	/*
++	 * Speed is specified via 'speed' devarg or
++	 * negotiated via VIRTIO_NET_F_SPEED_DUPLEX
++	 */
++	bool get_speed_via_feat;
+ 	uint32_t    notify_off_multiplier;
+ 	uint32_t    speed;  /* link speed in MB */
+ 	uint8_t     duplex;


More information about the stable mailing list