net/virtio: add link speed tuning
diff mbox series

Message ID 20191212085012.9170-1-i.dyukov@samsung.com
State Superseded
Delegated to: Maxime Coquelin
Headers show
Series
  • net/virtio: add link speed tuning
Related show

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-testing fail Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot warning Travis build: failed
ci/checkpatch success coding style OK

Commit Message

Ivan Dyukov Dec. 12, 2019, 8:50 a.m. UTC
Some applications like pktgen use link_speed to calculate transmit
rate. It limits outcome traffic to hardcoded 10G.

This patch makes link_speed configurable at compile time.

Signed-off-by: Ivan Dyukov <i.dyukov@samsung.com>
---
 config/common_base                 |  1 +
 drivers/net/vhost/rte_eth_vhost.c  |  2 +-
 drivers/net/virtio/virtio_ethdev.c | 20 ++++++++++++++++----
 3 files changed, 18 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/config/common_base b/config/common_base
index 7dec7ed45..8589ca4ec 100644
--- a/config/common_base
+++ b/config/common_base
@@ -433,6 +433,7 @@  CONFIG_RTE_LIBRTE_AVP_DEBUG_BUFFERS=n
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
+CONFIG_RTE_LIBRTE_VIRTIO_LINK_SPEED=10000
 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_DUMP=n
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 46f01a7f4..38eaa5955 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -115,7 +115,7 @@  static struct internal_list_head internal_list =
 static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = RTE_LIBRTE_VIRTIO_LINK_SPEED,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
 		.link_status = ETH_LINK_DOWN
 };
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 044eb10a7..948091cc2 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -2371,7 +2371,7 @@  virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 
 	memset(&link, 0, sizeof(link));
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	link.link_speed  = ETH_SPEED_NUM_10G;
+	link.link_speed  = RTE_LIBRTE_VIRTIO_LINK_SPEED;
 	link.link_autoneg = ETH_LINK_FIXED;
 
 	if (!hw->started) {
@@ -2426,9 +2426,21 @@  virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	uint64_t tso_mask, host_features;
 	struct virtio_hw *hw = dev->data->dev_private;
-
-	dev_info->speed_capa = ETH_LINK_SPEED_10G; /* fake value */
-
+#if RTE_LIBRTE_VIRTIO_LINK_SPEED == ETH_LINK_SPEED_20G
+	dev_info->speed_capa = ETH_LINK_SPEED_20G;
+#elif RTE_LIBRTE_VIRTIO_LINK_SPEED == ETH_SPEED_NUM_25G
+	dev_info->speed_capa = ETH_LINK_SPEED_25G;
+#elif RTE_LIBRTE_VIRTIO_LINK_SPEED == ETH_SPEED_NUM_40G
+	dev_info->speed_capa = ETH_LINK_SPEED_40G;
+#elif RTE_LIBRTE_VIRTIO_LINK_SPEED == ETH_SPEED_NUM_50G
+	dev_info->speed_capa = ETH_LINK_SPEED_50G;
+#elif RTE_LIBRTE_VIRTIO_LINK_SPEED == ETH_SPEED_NUM_56G
+	dev_info->speed_capa = ETH_LINK_SPEED_56G;
+#elif RTE_LIBRTE_VIRTIO_LINK_SPEED == ETH_SPEED_NUM_100G
+	dev_info->speed_capa = ETH_LINK_SPEED_100G;
+#else
+	dev_info->speed_capa = ETH_LINK_SPEED_10G;
+#endif
 	dev_info->max_rx_queues =
 		RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES);
 	dev_info->max_tx_queues =