Skip to contentSkip to conversation

ethdev: add speed capabilities and refactor link API

PATCH Superseded Marc Sune 19 participants 167 messages Oct 25, 2015 – Apr 6, 2016 1 message not in the archive Page 1 of 3

Subsystems (3)
lore
Share & tools
lore

Marc Sune

author
#1 lore raw

v6 cover ethdev: add speed capabilities and refactor link API

In reply to a message not in the archive

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Minor bugs expected.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment (checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a bitmap for defining the announced speeds, as suggested M. Brorup. Fixed spelling issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

Marc Sune (5):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes
ethdev: add rte_eth_speed_to_bm_flag() to ver. map

 app/test-pmd/cmdline.c                     | 124 +++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 doc/guides/rel_notes/release_2_2.rst       |  23 ++++++
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   4 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 109 ++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 104 +++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c           |   5 +-
 drivers/net/i40e/i40e_ethdev.c             |  78 ++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  74 ++++++++---------
 drivers/net/mlx4/mlx4.c                    |   6 ++
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              |  97 +++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map     |   6 ++
 38 files changed, 501 insertions(+), 322 deletions(-)
Signature · 1 line
2.1.4
author
#2 lore raw

PATCH v6 1/5 ethdev: Added ETH_SPEED_CAP bitmap for ports

Added constants and bitmap to struct rte_eth_dev_info to be used by PMDs.

---
 lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
lib/librte_ether/rte_ethdev.h +24 -0
index 8a8c82b..951a423 100644
@@ -811,6 +811,29 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
+/**
+ * Device supported speeds
+ */
+#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
+#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */
+#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */
+
+
+/**
+ * Ethernet device information
+ */
 struct rte_eth_dev_info {
 	struct rte_pci_device *pci_dev; /**< Device PCI information. */
 	const char *driver_name; /**< Device Driver name. */
@@ -837,6 +860,7 @@ struct rte_eth_dev_info {
 	uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
 	uint16_t vmdq_queue_num;  /**< Queue number for VMDQ pools. */
 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
+	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_SPEED_CAP_). */
 };
 
 /** Maximum name length for extended statistics counters */
Signature · 1 line
2.1.4
author
#5 lore raw

PATCH v6 2/5 ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* mlx4
* fm10k

---
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  3 +++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 6 files changed, 38 insertions(+)
drivers/net/e1000/em_ethdev.c +6 -0
index 912f5dd..72f792c 100644
@@ -933,6 +933,12 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->max_rx_queues = 1;
 	dev_info->max_tx_queues = 1;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 /* return 0 means link status changed, -1 means not changed */
drivers/net/e1000/igb_ethdev.c +6 -0
index 848ef6e..927f5d9 100644
@@ -1570,6 +1570,12 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		},
 		.txq_flags = 0,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 static void
drivers/net/fm10k/fm10k_ethdev.c +3 -0
index a69c990..ca6357c 100644
@@ -964,6 +964,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 				ETH_TXQ_FLAGS_NOOFFLOADS,
 	};
 
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
+					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
+					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +9 -0
index 2dd9fdc..8a5dfbf 100644
@@ -1624,6 +1624,7 @@ static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vsi *vsi = pf->main_vsi;
 
 	dev_info->max_rx_queues = vsi->nb_qps;
@@ -1683,6 +1684,14 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->max_rx_queues += dev_info->vmdq_queue_num;
 		dev_info->max_tx_queues += dev_info->vmdq_queue_num;
 	}
+
+	if (i40e_is_40G_device(hw->device_id))
+		/* For XL710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+	else
+		/* For X710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+
 }
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +10 -0
index ec2918c..3be84aa 100644
@@ -2399,6 +2399,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
 	dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
 	dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+
+	if (hw->mac.type == ixgbe_mac_X540 ||
+	    hw->mac.type == ixgbe_mac_X540_vf ||
+	    hw->mac.type == ixgbe_mac_X550 ||
+	    hw->mac.type == ixgbe_mac_X550_vf)
+
+		dev_info->speed_capa |= ETH_SPEED_CAP_100M_FD /*|
+					ETH_SPEED_CAP_100M_HD*/;
 }
 
 static void
drivers/net/mlx4/mlx4.c +4 -0
index 2f49ed5..b45e21a 100644
@@ -3847,6 +3847,10 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		  DEV_TX_OFFLOAD_UDP_CKSUM |
 		  DEV_TX_OFFLOAD_TCP_CKSUM) :
 		 0);
+
+	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }
 
Signature · 1 line
2.1.4
author
#6 lore raw

PATCH v6 3/5 ethdev: redesign link speed config API

In reply to Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.

---
 app/test-pmd/cmdline.c                     | 124 +++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   4 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 113 +++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 108 +++++++++++++------------
 drivers/net/fm10k/fm10k_ethdev.c           |   8 +-
 drivers/net/i40e/i40e_ethdev.c             |  73 ++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  72 ++++++++---------
 drivers/net/mlx4/mlx4.c                    |   2 +
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              | 113 ++++++++++++++++----------
 36 files changed, 449 insertions(+), 361 deletions(-)
app/test-pmd/cmdline.c +64 -60
index 0f8f48f..c62f5be 100644
@@ -897,14 +897,65 @@ struct cmd_config_speed_all {
 	cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *value1, char *value2, uint32_t *link_speed)
+{
+
+	int duplex;
+
+	if (!strcmp(value2, "half")) {
+		duplex = 0;
+	} else if (!strcmp(value2, "full")) {
+		duplex = 1;
+	} else if (!strcmp(value2, "auto")) {
+		duplex = 1;
+	} else {
+		printf("Unknown parameter\n");
+		return -1;
+	}
+
+	if (!strcmp(value1, "10")) {
+		*link_speed = (duplex) ? ETH_LINK_SPEED_10M :
+							ETH_LINK_SPEED_10M_HD;
+	} else if (!strcmp(value1, "100")) {
+		*link_speed = (duplex) ? ETH_LINK_SPEED_100M :
+							ETH_LINK_SPEED_100M_HD;
+	} else if (!strcmp(value1, "1000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_1G;
+	} else if (!strcmp(value1, "10000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_10G;
+	} else if (!strcmp(value1, "40000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_40G;
+	} else if (!strcmp(value1, "auto")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_AUTONEG;
+	} else {
+		printf("Unknown parameter\n");
+		return -1;
+	}
+
+	return 0;
+
+invalid_speed_param:
+
+	printf("Invalid speed parameter\n");
+	return -1;
+}
+
 static void
 cmd_config_speed_all_parsed(void *parsed_result,
 			__attribute__((unused)) struct cmdline *cl,
 			__attribute__((unused)) void *data)
 {
 	struct cmd_config_speed_all *res = parsed_result;
-	uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-	uint16_t link_duplex = 0;
+	uint32_t link_speed;
 	portid_t pid;
 
 	if (!all_ports_stopped()) {
@@ -912,40 +963,18 @@ cmd_config_speed_all_parsed(void *parsed_result,
 		return;
 	}
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10G;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1,
+						res->value2,
+						&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
 	FOREACH_PORT(pid, ports) {
-		ports[pid].dev_conf.link_speed = link_speed;
-		ports[pid].dev_conf.link_duplex = link_duplex;
+		ports[pid].dev_conf.link_speeds = link_speed;
 	}
 
 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+
+	return;
 }
 
 cmdline_parse_token_string_t cmd_config_speed_all_port =
@@ -1000,8 +1029,7 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 				__attribute__((unused)) void *data)
 {
 	struct cmd_config_speed_specific *res = parsed_result;
-	uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-	uint16_t link_duplex = 0;
+	uint32_t link_speed;
 
 	if (!all_ports_stopped()) {
 		printf("Please stop all ports first\n");
@@ -1011,36 +1039,12 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 	if (port_id_is_invalid(res->id, ENABLED_WARN))
 		return;
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10000;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1,
+						res->value2,
+						&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
-	ports[res->id].dev_conf.link_speed = link_speed;
-	ports[res->id].dev_conf.link_duplex = link_duplex;
+	ports[res->id].dev_conf.link_speeds = link_speed;
 
 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
 }
app/test/virtual_pmd.c +2 -2
index a538c8a..3c4040b 100644
@@ -603,8 +603,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
-	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
index bdd9628..a5d689d 100644
@@ -115,9 +115,10 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/bonding/rte_eth_bond_8023ad.c +7 -7
index c0f0b99..f375f95 100644
@@ -708,25 +708,25 @@ link_speed_key(uint16_t speed) {
 	uint16_t key_speed;
 
 	switch (speed) {
-	case ETH_LINK_SPEED_AUTONEG:
+	case ETH_SPEED_NUM_NONE:
 		key_speed = 0x00;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		key_speed = BOND_LINK_SPEED_KEY_10M;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		key_speed = BOND_LINK_SPEED_KEY_100M;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		key_speed = BOND_LINK_SPEED_KEY_1000M;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		key_speed = BOND_LINK_SPEED_KEY_10G;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		key_speed = BOND_LINK_SPEED_KEY_20G;
 		break;
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		key_speed = BOND_LINK_SPEED_KEY_40G;
 		break;
 	default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		if (stat & F_FW_PORT_CMD_TXPAUSE)
 			fc |= PAUSE_TX;
 		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-			speed = ETH_LINK_SPEED_100;
+			speed = ETH_SPEED_NUM_100M;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-			speed = ETH_LINK_SPEED_1000;
+			speed = ETH_SPEED_NUM_1G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-			speed = ETH_LINK_SPEED_10000;
+			speed = ETH_SPEED_NUM_10G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-			speed = ETH_LINK_SPEED_40G;
+			speed = ETH_SPEED_NUM_40G;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
drivers/net/e1000/base/e1000_80003es2lan.c +3 -3
index 72692d9..8ca66c4 100644
@@ -52,7 +52,7 @@ STATIC s32  e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
 STATIC s32  e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_get_cable_length_80003es2lan(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32 *speed,
 					       u16 *duplex);
 STATIC s32  e1000_reset_hw_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_80003es2lan(struct e1000_hw *hw);
@@ -789,7 +789,7 @@ STATIC s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
  *
  *  Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32 *speed,
 					      u16 *duplex)
 {
 	s32 ret_val;
@@ -1236,7 +1236,7 @@ STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
 {
 	s32 ret_val = E1000_SUCCESS;
-	u16 speed;
+	u32 speed;
 	u16 duplex;
 
 	DEBUGFUNC("e1000_configure_on_link_up");
drivers/net/e1000/base/e1000_82541.c +4 -4
index 952aea2..707b317 100644
@@ -47,7 +47,7 @@ STATIC s32  e1000_init_nvm_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_mac_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_reset_hw_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_82541(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
 					 u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_82541(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_82541(struct e1000_hw *hw);
@@ -437,7 +437,7 @@ out:
  *
  * Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
 					u16 *duplex)
 {
 	struct e1000_phy_info *phy = &hw->phy;
@@ -667,8 +667,8 @@ STATIC s32 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
 	struct e1000_phy_info *phy = &hw->phy;
 	struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
 	s32 ret_val;
-	u32 idle_errs = 0;
-	u16 phy_data, phy_saved_data, speed, duplex, i;
+	u32 idle_errs = 0, speed;
+	u16 phy_data, phy_saved_data, duplex, i;
 	u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
 	u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
 						IGP01E1000_PHY_AGC_PARAM_A,
drivers/net/e1000/base/e1000_82543.c +2 -2
index 36335ba..9ef3d80 100644
@@ -1192,9 +1192,9 @@ out:
 STATIC s32 e1000_check_for_copper_link_82543(struct e1000_hw *hw)
 {
 	struct e1000_mac_info *mac = &hw->mac;
-	u32 icr, rctl;
+	u32 icr, rctl, speed;
 	s32 ret_val;
-	u16 speed, duplex;
+	u16 duplex;
 	bool link;
 
 	DEBUGFUNC("e1000_check_for_copper_link_82543");
drivers/net/e1000/base/e1000_82575.c +6 -5
index 25fa672..386f058 100644
@@ -53,7 +53,7 @@ STATIC void e1000_release_nvm_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_media_swap(struct e1000_hw *hw);
 STATIC s32  e1000_get_cfg_done_82575(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
 					 u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
 STATIC s32  e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
@@ -80,7 +80,7 @@ STATIC s32  e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw,
 STATIC void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-						 u16 *speed, u16 *duplex);
+						 u32 *speed, u16 *duplex);
 STATIC s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
 STATIC void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC bool e1000_sgmii_active_82575(struct e1000_hw *hw);
@@ -1165,7 +1165,7 @@ STATIC s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
  *  interface, use PCS to retrieve the link speed and duplex information.
  *  Otherwise, use the generic function to get the link speed and duplex info.
  **/
-STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
 					u16 *duplex)
 {
 	s32 ret_val;
@@ -1192,7 +1192,8 @@ STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
 STATIC s32 e1000_check_for_link_82575(struct e1000_hw *hw)
 {
 	s32 ret_val;
-	u16 speed, duplex;
+	u32 speed;
+	u16 duplex;
 
 	DEBUGFUNC("e1000_check_for_link_82575");
 
@@ -1316,7 +1317,7 @@ STATIC void e1000_power_up_serdes_link_82575(struct e1000_hw *hw)
  *  duplex, then store the values in the pointers provided.
  **/
 STATIC s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-						u16 *speed, u16 *duplex)
+						u32 *speed, u16 *duplex)
 {
 	struct e1000_mac_info *mac = &hw->mac;
 	u32 pcs;
drivers/net/e1000/base/e1000_api.c +1 -1
index a064565..08e103a 100644
@@ -669,7 +669,7 @@ s32 e1000_setup_link(struct e1000_hw *hw)
  *  variables passed in. This is a function pointer entry point called
  *  by drivers.
  **/
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16 *duplex)
 {
 	if (hw->mac.ops.get_link_up_info)
 		return hw->mac.ops.get_link_up_info(hw, speed, duplex);
drivers/net/e1000/base/e1000_api.h +1 -1
index 02b16da..39579e0 100644
@@ -65,7 +65,7 @@ s32 e1000_check_for_link(struct e1000_hw *hw);
 s32 e1000_reset_hw(struct e1000_hw *hw);
 s32 e1000_init_hw(struct e1000_hw *hw);
 s32 e1000_setup_link(struct e1000_hw *hw);
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex);
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16 *duplex);
 s32 e1000_disable_pcie_master(struct e1000_hw *hw);
 void e1000_config_collision_dist(struct e1000_hw *hw);
 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
drivers/net/e1000/base/e1000_defines.h +2 -2
index 278c507..20c4153 100644
@@ -347,8 +347,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_2500	2500
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
+#define HALF_DUPLEX	0
+#define FULL_DUPLEX	1
 
 #define PHY_FORCE_TIME	20
 
drivers/net/e1000/base/e1000_hw.h +1 -1
index 4dd92a3..b48a759 100644
@@ -682,7 +682,7 @@ struct e1000_mac_operations {
 	void (*clear_vfta)(struct e1000_hw *);
 	s32  (*get_bus_info)(struct e1000_hw *);
 	void (*set_lan_id)(struct e1000_hw *);
-	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+	s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
 	s32  (*led_on)(struct e1000_hw *);
 	s32  (*led_off)(struct e1000_hw *);
 	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
drivers/net/e1000/base/e1000_ich8lan.c +2 -2
index 3b1627b..7fe9955 100644
@@ -104,7 +104,7 @@ STATIC s32  e1000_setup_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
 STATIC s32  e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
-					   u16 *speed, u16 *duplex);
+					   u32 *speed, u16 *duplex);
 STATIC s32  e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_on_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_off_ich8lan(struct e1000_hw *hw);
@@ -4561,7 +4561,7 @@ STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
  *  information and then calls the Kumeran lock loss workaround for links at
  *  gigabit speeds.
  **/
-STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u32 *speed,
 					  u16 *duplex)
 {
 	s32 ret_val;
drivers/net/e1000/base/e1000_mac.c +5 -4
index c8ec049..6703a17 100644
@@ -106,7 +106,7 @@ void e1000_null_mac_generic(struct e1000_hw E1000_UNUSEDARG *hw)
  *  @hw: pointer to the HW structure
  **/
 s32 e1000_null_link_info(struct e1000_hw E1000_UNUSEDARG *hw,
-			 u16 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
+			 u32 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
 {
 	DEBUGFUNC("e1000_null_link_info");
 	UNREFERENCED_3PARAMETER(hw, s, d);
@@ -1346,7 +1346,8 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
 	s32 ret_val = E1000_SUCCESS;
 	u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;
 	u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
-	u16 speed, duplex;
+	u32 speed;
+	u16 duplex;
 
 	DEBUGFUNC("e1000_config_fc_after_link_up_generic");
 
@@ -1648,7 +1649,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
  *  Read the status register for the current speed/duplex and store the current
  *  speed and duplex for copper connections.
  **/
-s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,
 					      u16 *duplex)
 {
 	u32 status;
@@ -1688,7 +1689,7 @@ s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
  *  for fiber/serdes links.
  **/
 s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw E1000_UNUSEDARG *hw,
-						    u16 *speed, u16 *duplex)
+						    u32 *speed, u16 *duplex)
 {
 	DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
 	UNREFERENCED_1PARAMETER(hw);
drivers/net/e1000/base/e1000_mac.h +3 -3
index 5a7ce4a..987df76 100644
@@ -40,7 +40,7 @@ void e1000_init_mac_ops_generic(struct e1000_hw *hw);
 #endif /* E1000_REMOVED */
 void e1000_null_mac_generic(struct e1000_hw *hw);
 s32  e1000_null_ops_generic(struct e1000_hw *hw);
-s32  e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d);
+s32  e1000_null_link_info(struct e1000_hw *hw, u32 *s, u16 *d);
 bool e1000_null_mng_mode(struct e1000_hw *hw);
 void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a);
 void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b);
@@ -61,10 +61,10 @@ s32  e1000_get_bus_info_pcie_generic(struct e1000_hw *hw);
 void e1000_set_lan_id_single_port(struct e1000_hw *hw);
 void e1000_set_lan_id_multi_port_pci(struct e1000_hw *hw);
 s32  e1000_get_hw_semaphore_generic(struct e1000_hw *hw);
-s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,
 					       u16 *duplex);
 s32  e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
-						     u16 *speed, u16 *duplex);
+						     u32 *speed, u16 *duplex);
 s32  e1000_id_led_init_generic(struct e1000_hw *hw);
 s32  e1000_led_on_generic(struct e1000_hw *hw);
 s32  e1000_led_off_generic(struct e1000_hw *hw);
drivers/net/e1000/base/e1000_vf.c +2 -2
index 778561e..2221f1c 100644
@@ -43,7 +43,7 @@ STATIC s32 e1000_setup_link_vf(struct e1000_hw *hw);
 STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
 STATIC s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
 STATIC s32 e1000_check_for_link_vf(struct e1000_hw *hw);
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
 				     u16 *duplex);
 STATIC s32 e1000_init_hw_vf(struct e1000_hw *hw);
 STATIC s32 e1000_reset_hw_vf(struct e1000_hw *hw);
@@ -220,7 +220,7 @@ STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw)
  *  Since we cannot read the PHY and get accurate link info, we must rely upon
  *  the status register's data which is often stale and inaccurate.
  **/
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
 				     u16 *duplex)
 {
 	s32 status;
drivers/net/e1000/base/e1000_vf.h +1 -1
index 6d5bd99..9d801ad 100644
@@ -201,7 +201,7 @@ struct e1000_mac_operations {
 	s32  (*check_for_link)(struct e1000_hw *);
 	void (*clear_vfta)(struct e1000_hw *);
 	s32  (*get_bus_info)(struct e1000_hw *);
-	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+	s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
 	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
 	s32  (*reset_hw)(struct e1000_hw *);
 	s32  (*init_hw)(struct e1000_hw *);
drivers/net/e1000/em_ethdev.c +54 -59

149 lines not on this page · raw message

drivers/net/e1000/igb_ethdev.c +57 -51

144 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +4 -4
index ca6357c..6e05355 100644
@@ -862,7 +862,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	 * is no 50Gbps Ethernet. */
 	dev->data->dev_link.link_speed  = 0;
 	dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
@@ -964,9 +964,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 				ETH_TXQ_FLAGS_NOOFFLOADS,
 	};
 
-	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
-					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
-					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+				ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+				ETH_LINK_SPEED_40G | ETH_LINK_SPEED_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +37 -36

146 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev_vf.c +6 -5
index b694400..8d3acae 100644
@@ -1635,13 +1635,14 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	 * DPDK pf host provide interfacet to acquire link status
 	 * while Linux driver does not
 	 */
-	if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
 		i40evf_get_link_status(dev, &new_link);
-	else {
+	} else {
 		/* Always assume it's up, for Linux driver PF host */
-		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-		new_link.link_speed  = ETH_LINK_SPEED_10000;
-		new_link.link_status = 1;
+		new_link.link_speed  = ETH_SPEED_NUM_10G;
+		new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+		new_link.link_autoneg = ETH_LINK_SPEED_NEG;
+		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +31 -41

135 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +2 -0
index b45e21a..96fe4b6 100644
@@ -4207,6 +4207,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)
 		dev_link.link_speed = link_speed;
 	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
+	dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
 		/* Link status changed. */
 		dev->data->dev_link = dev_link;
drivers/net/mpipe/mpipe_tilegx.c +4 -2
index 743feef..5875371 100644
@@ -388,14 +388,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 		speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+		new.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 		if (speed == GXIO_MPIPE_LINK_1G) {
 			new.link_speed = ETH_LINK_SPEED_1000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
 			new.link_speed = ETH_LINK_SPEED_10000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		}
 
 		rc = mpipe_link_compare(&old, &new);
drivers/net/null/rte_eth_null.c +3 -2
index e244595..7704fa6 100644
@@ -79,9 +79,10 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG,
 };
 
 static uint16_t
drivers/net/pcap/rte_eth_pcap.c +5 -4
index f2e4634..ea7a28f 100644
@@ -125,9 +125,10 @@ static int open_single_iface(const char *iface, pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED,
 };
 
 static int
@@ -430,7 +431,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -481,7 +482,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	}
 
 status_down:
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +3 -2
index 0ba36d5..626c381 100644
@@ -71,9 +71,10 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/virtio/virtio_ethdev.c +1 -1
index 465d3cd..ecbf9f2 100644
@@ -1517,7 +1517,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_read_link_status(dev, &link);
 	old = link;
-	link.link_duplex = FULL_DUPLEX;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	link.link_speed  = SPEED_10G;
 
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index 9026d42..424d650 100644
@@ -42,8 +42,6 @@
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_10G	10000
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -2
index a70be5c..6860360 100644
@@ -697,9 +697,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
 	if (ret & 0x1) {
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
+		link.link_autoneg = ETH_LINK_SPEED_FIXED;
 	}
 
 	vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -2
index 73e8bce..fb492ee 100644
@@ -70,9 +70,10 @@ static int virtio_idx = 0;
 static const char *drivername = "xen dummy virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED
 };
 
 static inline struct rte_mbuf *
examples/ip_pipeline/config_parse.c +1 -2
index c9b78f9..92e6a18 100644
@@ -83,8 +83,7 @@ static const struct app_link_params link_params_default = {
 	.mac_addr = 0,
 
 	.conf = {
-		.link_speed = 0,
-		.link_duplex = 0,
+		.link_speeds = 0,
 		.rxmode = {
 			.mq_mode = ETH_MQ_RX_NONE,
 
lib/librte_ether/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ether/rte_ethdev.h +73 -40

141 lines not on this page · raw message

Signature · 1 line
2.1.4
author
#10 lore raw

PATCH v6 4/5 doc: update with link changes

In reply to Marc Sune

Add new features, ABI changes and resolved issues notice for the refactored link patch.

---
 doc/guides/rel_notes/release_2_2.rst | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
doc/guides/rel_notes/release_2_2.rst +23 -0
index 5687676..e0d1741 100644
@@ -4,6 +4,17 @@ DPDK Release 2.2
 New Features
 ------------
 
+* **ethdev: define a set of advertised link speeds.**
+
+  Allowing to define a set of advertised speeds for auto-negociation,
+  explicitely disable link auto-negociation (single speed) and full
+  auto-negociation.
+
+* **ethdev: add speed_cap bitmap to recover eth device link speed capabilities
+  define a set of advertised link speeds.**
+
+  ``struct rte_eth_dev_info`` has now speed_cap bitmap, which allows the
+  application to recover the supported speeds for that ethernet device.
 
 Resolved Issues
 ---------------
@@ -48,6 +59,11 @@ Libraries
   Fixed issue where an incorrect Cuckoo Hash key table size could be
   calculated limiting the size to 4GB.
 
+* **ethdev: Fixed link_speed overflow in rte_eth_link for 100Gbps.**
+
+  100Gbps in Mbps (100000) exceeds 16 bit max value of ``link_speed`` in
+  ``rte_eth_link``.
+
 
 Examples
 ~~~~~~~~
@@ -81,6 +97,8 @@ API Changes
 * The deprecated ring PMD functions are removed:
   rte_eth_ring_pair_create() and rte_eth_ring_pair_attach().
 
+* New API call, rte_eth_speed_to_bm_flag(), in ethdev to map numerical speeds
+  to bitmap fields.
 
 ABI Changes
 -----------
@@ -91,6 +109,11 @@ ABI Changes
 * The ethdev flow director entries for SCTP were changed.
   It was already done in 2.1 for CONFIG_RTE_NEXT_ABI.
 
+* The ethdev rte_eth_link and rte_eth_conf structures were changed to
+  support the new link API, as well as ETH_LINK_HALF/FULL_DUPLEX.
+
+* The ethdev rte_eth_dev_info was changed to support device speed capabilities.
+
 * The mbuf structure was changed to support unified packet type.
   It was already done in 2.1 for CONFIG_RTE_NEXT_ABI.
 
Signature · 1 line
2.1.4
author
#11 lore raw

PATCH v6 5/5 ethdev: add rte_eth_speed_to_bm_flag() to ver. map

In reply to Marc Sune

Added rte_eth_speed_to_bm_flag() to DPDK2.2 version map.

---
 lib/librte_ether/rte_ether_version.map | 6 ++++++
 1 file changed, 6 insertions(+)
lib/librte_ether/rte_ether_version.map +6 -0
index 8345a6c..cbfe0c8 100644
@@ -127,3 +127,9 @@ DPDK_2.1 {
 	rte_eth_timesync_read_tx_timestamp;
 
 } DPDK_2.0;
+
+DPDK_2.2 {
+	global:
+
+	rte_eth_speed_to_bm_flag;
+} DPDK_2.1;
Signature · 1 line
2.1.4
author
#7 lore raw

Re: [PATCH v6 3/5] ethdev: redesign link speed config API

In reply to Marc Sune

While testing this patch with some XL710, it seems even with current HEAD, setting link speed into dev_conf to 10G does not work, it always takes autoneg with all speeds.

Besides, this patch in particular should be tested for the rest of drivers which I don't have HW for.

Regards
marc

2015-10-25 22:59 GMT+01:00 Marc Sune <[email protected]>:

Quoted 1,846 lines

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.

---
 app/test-pmd/cmdline.c                     | 124
+++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   4 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 113
+++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 108 +++++++++++++------------
 drivers/net/fm10k/fm10k_ethdev.c           |   8 +-
 drivers/net/i40e/i40e_ethdev.c             |  73 ++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  72 ++++++++---------
 drivers/net/mlx4/mlx4.c                    |   2 +
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              | 113
++++++++++++++++----------
 36 files changed, 449 insertions(+), 361 deletions(-)
app/test-pmd/cmdline.c +53 -2
index 0f8f48f..c62f5be 100644
@@ -897,14 +897,65 @@ struct cmd_config_speed_all {
        cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *value1, char *value2, uint32_t
 *link_speed)
+{
+
+       int duplex;
+
+       if (!strcmp(value2, "half")) {
+               duplex = 0;
+       } else if (!strcmp(value2, "full")) {
+               duplex = 1;
+       } else if (!strcmp(value2, "auto")) {
+               duplex = 1;
+       } else {
+               printf("Unknown parameter\n");
+               return -1;
+       }
+
+       if (!strcmp(value1, "10")) {
+               *link_speed = (duplex) ? ETH_LINK_SPEED_10M :
+
 ETH_LINK_SPEED_10M_HD;
+       } else if (!strcmp(value1, "100")) {
+               *link_speed = (duplex) ? ETH_LINK_SPEED_100M :
+
 ETH_LINK_SPEED_100M_HD;
+       } else if (!strcmp(value1, "1000")) {
+               if (!duplex)
+                       goto invalid_speed_param;
+               *link_speed = ETH_LINK_SPEED_1G;
+       } else if (!strcmp(value1, "10000")) {
+               if (!duplex)
+                       goto invalid_speed_param;
+               *link_speed = ETH_LINK_SPEED_10G;
+       } else if (!strcmp(value1, "40000")) {
+               if (!duplex)
+                       goto invalid_speed_param;
+               *link_speed = ETH_LINK_SPEED_40G;
+       } else if (!strcmp(value1, "auto")) {
+               if (!duplex)
+                       goto invalid_speed_param;
+               *link_speed = ETH_LINK_SPEED_AUTONEG;
+       } else {
+               printf("Unknown parameter\n");
+               return -1;
+       }
+
+       return 0;
+
+invalid_speed_param:
+
+       printf("Invalid speed parameter\n");
+       return -1;
+}
+
 static void
 cmd_config_speed_all_parsed(void *parsed_result,
                        __attribute__((unused)) struct cmdline *cl,
                        __attribute__((unused)) void *data)
 {
        struct cmd_config_speed_all *res = parsed_result;
-       uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-       uint16_t link_duplex = 0;
+       uint32_t link_speed;
        portid_t pid;

        if (!all_ports_stopped()) {
app/test-pmd/cmdline.c +11 -58
@@ -912,40 +963,18 @@ cmd_config_speed_all_parsed(void *parsed_result,
                return;
        }
 
-       if (!strcmp(res->value1, "10"))
-               link_speed = ETH_LINK_SPEED_10;
-       else if (!strcmp(res->value1, "100"))
-               link_speed = ETH_LINK_SPEED_100;
-       else if (!strcmp(res->value1, "1000"))
-               link_speed = ETH_LINK_SPEED_1000;
-       else if (!strcmp(res->value1, "10000"))
-               link_speed = ETH_LINK_SPEED_10G;
-       else if (!strcmp(res->value1, "40000"))
-               link_speed = ETH_LINK_SPEED_40G;
-       else if (!strcmp(res->value1, "auto"))
-               link_speed = ETH_LINK_SPEED_AUTONEG;
-       else {
-               printf("Unknown parameter\n");
+       if (parse_and_check_speed_duplex(res->value1,
+                                               res->value2,
+                                               &link_speed) < 0)
                return;
-       }
-
-       if (!strcmp(res->value2, "half"))
-               link_duplex = ETH_LINK_HALF_DUPLEX;
-       else if (!strcmp(res->value2, "full"))
-               link_duplex = ETH_LINK_FULL_DUPLEX;
-       else if (!strcmp(res->value2, "auto"))
-               link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-       else {
-               printf("Unknown parameter\n");
-               return;
-       }
 
        FOREACH_PORT(pid, ports) {
-               ports[pid].dev_conf.link_speed = link_speed;
-               ports[pid].dev_conf.link_duplex = link_duplex;
+               ports[pid].dev_conf.link_speeds = link_speed;
        }
 
        cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+
+       return;
 }
 
 cmdline_parse_token_string_t cmd_config_speed_all_port =
@@ -1000,8 +1029,7 @@ cmd_config_speed_specific_parsed(void *parsed_result,
                                __attribute__((unused)) void *data)
 {
        struct cmd_config_speed_specific *res = parsed_result;
-       uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-       uint16_t link_duplex = 0;
+       uint32_t link_speed;
 
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
@@ -1011,36 +1039,12 @@ cmd_config_speed_specific_parsed(void
 *parsed_result,
        if (port_id_is_invalid(res->id, ENABLED_WARN))
                return;
 
-       if (!strcmp(res->value1, "10"))
-               link_speed = ETH_LINK_SPEED_10;
-       else if (!strcmp(res->value1, "100"))
-               link_speed = ETH_LINK_SPEED_100;
-       else if (!strcmp(res->value1, "1000"))
-               link_speed = ETH_LINK_SPEED_1000;
-       else if (!strcmp(res->value1, "10000"))
-               link_speed = ETH_LINK_SPEED_10000;
-       else if (!strcmp(res->value1, "40000"))
-               link_speed = ETH_LINK_SPEED_40G;
-       else if (!strcmp(res->value1, "auto"))
-               link_speed = ETH_LINK_SPEED_AUTONEG;
-       else {
-               printf("Unknown parameter\n");
+       if (parse_and_check_speed_duplex(res->value1,
+                                               res->value2,
+                                               &link_speed) < 0)
                return;
-       }
-
-       if (!strcmp(res->value2, "half"))
-               link_duplex = ETH_LINK_HALF_DUPLEX;
-       else if (!strcmp(res->value2, "full"))
-               link_duplex = ETH_LINK_FULL_DUPLEX;
-       else if (!strcmp(res->value2, "auto"))
-               link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-       else {
-               printf("Unknown parameter\n");
-               return;
-       }
 
-       ports[res->id].dev_conf.link_speed = link_speed;
-       ports[res->id].dev_conf.link_duplex = link_duplex;
+       ports[res->id].dev_conf.link_speeds = link_speed;
 
        cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);

}

app/test/virtual_pmd.c +2 -2
index a538c8a..3c4040b 100644
@@ -603,8 +603,8 @@ virtual_ethdev_create(const char *name, struct
 ether_addr *mac_addr,
 
        TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-       eth_dev->data->dev_link.link_status = 0;
-       eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+       eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+       eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
        eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
        eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
index bdd9628..a5d689d 100644
@@ -115,9 +115,10 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-       .link_speed = 10000,
+       .link_speed = ETH_SPEED_NUM_10G,
        .link_duplex = ETH_LINK_FULL_DUPLEX,
-       .link_status = 0
+       .link_status = ETH_LINK_DOWN,
+       .link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/bonding/rte_eth_bond_8023ad.c +7 -7
index c0f0b99..f375f95 100644
@@ -708,25 +708,25 @@ link_speed_key(uint16_t speed) {
        uint16_t key_speed;
 
        switch (speed) {
-       case ETH_LINK_SPEED_AUTONEG:
+       case ETH_SPEED_NUM_NONE:
                key_speed = 0x00;
                break;
-       case ETH_LINK_SPEED_10:
+       case ETH_SPEED_NUM_10M:
                key_speed = BOND_LINK_SPEED_KEY_10M;
                break;
-       case ETH_LINK_SPEED_100:
+       case ETH_SPEED_NUM_100M:
                key_speed = BOND_LINK_SPEED_KEY_100M;
                break;
-       case ETH_LINK_SPEED_1000:
+       case ETH_SPEED_NUM_1G:
                key_speed = BOND_LINK_SPEED_KEY_1000M;
                break;
-       case ETH_LINK_SPEED_10G:
+       case ETH_SPEED_NUM_10G:
                key_speed = BOND_LINK_SPEED_KEY_10G;
                break;
-       case ETH_LINK_SPEED_20G:
+       case ETH_SPEED_NUM_20G:
                key_speed = BOND_LINK_SPEED_KEY_20G;
                break;
-       case ETH_LINK_SPEED_40G:
+       case ETH_SPEED_NUM_40G:
                key_speed = BOND_LINK_SPEED_KEY_40G;
                break;
        default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const
 __be64 *rpl)
                if (stat & F_FW_PORT_CMD_TXPAUSE)
                        fc |= PAUSE_TX;
                if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-                       speed = ETH_LINK_SPEED_100;
+                       speed = ETH_SPEED_NUM_100M;
                else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-                       speed = ETH_LINK_SPEED_1000;
+                       speed = ETH_SPEED_NUM_1G;
                else if (stat &
 V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-                       speed = ETH_LINK_SPEED_10000;
+                       speed = ETH_SPEED_NUM_10G;
                else if (stat &
 V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-                       speed = ETH_LINK_SPEED_40G;
+                       speed = ETH_SPEED_NUM_40G;
                for_each_port(adap, i) {
                        pi = adap2pinfo(adap, i);
drivers/net/e1000/base/e1000_80003es2lan.c +1 -1
index 72692d9..8ca66c4 100644
@@ -52,7 +52,7 @@ STATIC s32  e1000_write_nvm_80003es2lan(struct e1000_hw
 *hw, u16 offset,
 STATIC s32  e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_get_cable_length_80003es2lan(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16
 *speed,
+STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32
 *speed,
                                               u16 *duplex);

STATIC s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw); STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw);

drivers/net/e1000/base/e1000_80003es2lan.c +1 -1
@@ -789,7 +789,7 @@ STATIC s32 e1000_get_cable_length_80003es2lan(struct
 e1000_hw *hw)
  *
  *  Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16
 *speed,
+STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32
 *speed,
                                              u16 *duplex)
 {
        s32 ret_val;
drivers/net/e1000/base/e1000_80003es2lan.c +1 -1
@@ -1236,7 +1236,7 @@ STATIC s32
 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
 {
        s32 ret_val = E1000_SUCCESS;
-       u16 speed;
+       u32 speed;
        u16 duplex;
 
        DEBUGFUNC("e1000_configure_on_link_up");
drivers/net/e1000/base/e1000_82541.c +1 -1
index 952aea2..707b317 100644
@@ -47,7 +47,7 @@ STATIC s32  e1000_init_nvm_params_82541(struct e1000_hw
 *hw);
 STATIC s32  e1000_init_mac_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_reset_hw_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_82541(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
                                         u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_82541(struct e1000_hw *hw);

STATIC s32 e1000_setup_copper_link_82541(struct e1000_hw *hw);

drivers/net/e1000/base/e1000_82541.c +3 -3
@@ -437,7 +437,7 @@ out:
  *
  * Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
                                        u16 *duplex)
 {
        struct e1000_phy_info *phy = &hw->phy;
@@ -667,8 +667,8 @@ STATIC s32
 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
        struct e1000_phy_info *phy = &hw->phy;
        struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
        s32 ret_val;
-       u32 idle_errs = 0;
-       u16 phy_data, phy_saved_data, speed, duplex, i;
+       u32 idle_errs = 0, speed;
+       u16 phy_data, phy_saved_data, duplex, i;
        u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
        u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
                                                IGP01E1000_PHY_AGC_PARAM_A,
drivers/net/e1000/base/e1000_82543.c +2 -2
index 36335ba..9ef3d80 100644
@@ -1192,9 +1192,9 @@ out:
 STATIC s32 e1000_check_for_copper_link_82543(struct e1000_hw *hw)
 {
        struct e1000_mac_info *mac = &hw->mac;
-       u32 icr, rctl;
+       u32 icr, rctl, speed;
        s32 ret_val;
-       u16 speed, duplex;
+       u16 duplex;
        bool link;
 
        DEBUGFUNC("e1000_check_for_copper_link_82543");
drivers/net/e1000/base/e1000_82575.c +1 -1
index 25fa672..386f058 100644
@@ -53,7 +53,7 @@ STATIC void e1000_release_nvm_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_media_swap(struct e1000_hw *hw);
 STATIC s32  e1000_get_cfg_done_82575(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
                                         u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
 STATIC s32  e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32

offset,

drivers/net/e1000/base/e1000_82575.c +1 -1
@@ -80,7 +80,7 @@ STATIC s32  e1000_write_phy_reg_sgmii_82575(struct
 e1000_hw *hw,
 STATIC void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-                                                u16 *speed, u16 *duplex);
+                                                u32 *speed, u16 *duplex);
 STATIC s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
 STATIC void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);

STATIC bool e1000_sgmii_active_82575(struct e1000_hw *hw);

drivers/net/e1000/base/e1000_82575.c +0 -0
@@ -1165,7 +1165,7 @@ STATIC s32 e1000_get_cfg_done_82575(struct e1000_hw
 *hw)
  *  interface, use PCS to retrieve the link speed and duplex information.
  *  Otherwise, use the generic function to get the link speed and duplex

info.
**/

drivers/net/e1000/base/e1000_82575.c +4 -3
-STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
                                        u16 *duplex)
 {
        s32 ret_val;
@@ -1192,7 +1192,8 @@ STATIC s32 e1000_get_link_up_info_82575(struct
 e1000_hw *hw, u16 *speed,
 STATIC s32 e1000_check_for_link_82575(struct e1000_hw *hw)
 {
        s32 ret_val;
-       u16 speed, duplex;
+       u32 speed;
+       u16 duplex;
 
        DEBUGFUNC("e1000_check_for_link_82575");
@@ -1316,7 +1317,7 @@ STATIC void e1000_power_up_serdes_link_82575(struct
 e1000_hw *hw)
  *  duplex, then store the values in the pointers provided.
  **/
 STATIC s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-                                               u16 *speed, u16 *duplex)
+                                               u32 *speed, u16 *duplex)
 {
        struct e1000_mac_info *mac = &hw->mac;
        u32 pcs;
drivers/net/e1000/base/e1000_api.c +1 -1
index a064565..08e103a 100644
@@ -669,7 +669,7 @@ s32 e1000_setup_link(struct e1000_hw *hw)
  *  variables passed in. This is a function pointer entry point called
  *  by drivers.
  **/
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16
 *duplex)
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16
 *duplex)
 {
        if (hw->mac.ops.get_link_up_info)
                return hw->mac.ops.get_link_up_info(hw, speed, duplex);
drivers/net/e1000/base/e1000_api.h +1 -1
index 02b16da..39579e0 100644
@@ -65,7 +65,7 @@ s32 e1000_check_for_link(struct e1000_hw *hw);
 s32 e1000_reset_hw(struct e1000_hw *hw);
 s32 e1000_init_hw(struct e1000_hw *hw);
 s32 e1000_setup_link(struct e1000_hw *hw);
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16
 *duplex);
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16
 *duplex);
 s32 e1000_disable_pcie_master(struct e1000_hw *hw);

void e1000_config_collision_dist(struct e1000_hw *hw); void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);

drivers/net/e1000/base/e1000_defines.h +2 -2
index 278c507..20c4153 100644
@@ -347,8 +347,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define SPEED_100      100
 #define SPEED_1000     1000
 #define SPEED_2500     2500
-#define HALF_DUPLEX    1
-#define FULL_DUPLEX    2
+#define HALF_DUPLEX    0
+#define FULL_DUPLEX    1
 
 #define PHY_FORCE_TIME 20
 
drivers/net/e1000/base/e1000_hw.h +1 -1
index 4dd92a3..b48a759 100644
@@ -682,7 +682,7 @@ struct e1000_mac_operations {
        void (*clear_vfta)(struct e1000_hw *);
        s32  (*get_bus_info)(struct e1000_hw *);
        void (*set_lan_id)(struct e1000_hw *);
-       s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+       s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
        s32  (*led_on)(struct e1000_hw *);
        s32  (*led_off)(struct e1000_hw *);
        void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
drivers/net/e1000/base/e1000_ich8lan.c +1 -1
index 3b1627b..7fe9955 100644
@@ -104,7 +104,7 @@ STATIC s32  e1000_setup_link_ich8lan(struct e1000_hw
 *hw);
 STATIC s32  e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
 STATIC s32  e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
-                                          u16 *speed, u16 *duplex);
+                                          u32 *speed, u16 *duplex);
 STATIC s32  e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_on_ich8lan(struct e1000_hw *hw);

STATIC s32 e1000_led_off_ich8lan(struct e1000_hw *hw);

drivers/net/e1000/base/e1000_ich8lan.c +0 -0
@@ -4561,7 +4561,7 @@ STATIC s32 e1000_setup_copper_link_pch_lpt(struct
 e1000_hw *hw)
  *  information and then calls the Kumeran lock loss workaround for links

at
* gigabit speeds.
**/

drivers/net/e1000/base/e1000_ich8lan.c +1 -1
-STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u32 *speed,
                                          u16 *duplex)
 {
        s32 ret_val;
drivers/net/e1000/base/e1000_mac.c +1 -1
index c8ec049..6703a17 100644
@@ -106,7 +106,7 @@ void e1000_null_mac_generic(struct e1000_hw
 E1000_UNUSEDARG *hw)
  *  @hw: pointer to the HW structure
  **/
 s32 e1000_null_link_info(struct e1000_hw E1000_UNUSEDARG *hw,
-                        u16 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
+                        u32 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
 {
        DEBUGFUNC("e1000_null_link_info");
        UNREFERENCED_3PARAMETER(hw, s, d);
drivers/net/e1000/base/e1000_mac.c +2 -1
@@ -1346,7 +1346,8 @@ s32 e1000_config_fc_after_link_up_generic(struct
 e1000_hw *hw)
        s32 ret_val = E1000_SUCCESS;
        u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;
        u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
-       u16 speed, duplex;
+       u32 speed;
+       u16 duplex;
 
        DEBUGFUNC("e1000_config_fc_after_link_up_generic");
@@ -1648,7 +1649,7 @@ s32 e1000_config_fc_after_link_up_generic(struct
 e1000_hw *hw)
  *  Read the status register for the current speed/duplex and store the

current
* speed and duplex for copper connections.
**/
-s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,

                                              u16 *duplex)
 {
        u32 status;
drivers/net/e1000/base/e1000_mac.c +1 -1
@@ -1688,7 +1689,7 @@ s32 e1000_get_speed_and_duplex_copper_generic(struct
 e1000_hw *hw, u16 *speed,
  *  for fiber/serdes links.
  **/
 s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw
 E1000_UNUSEDARG *hw,
-                                                   u16 *speed, u16
 *duplex)
+                                                   u32 *speed, u16

*duplex)

 {
        DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
        UNREFERENCED_1PARAMETER(hw);
drivers/net/e1000/base/e1000_mac.h +2 -3
index 5a7ce4a..987df76 100644
@@ -40,7 +40,7 @@ void e1000_init_mac_ops_generic(struct e1000_hw *hw);
 #endif /* E1000_REMOVED */
 void e1000_null_mac_generic(struct e1000_hw *hw);
 s32  e1000_null_ops_generic(struct e1000_hw *hw);
-s32  e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d);
+s32  e1000_null_link_info(struct e1000_hw *hw, u32 *s, u16 *d);
 bool e1000_null_mng_mode(struct e1000_hw *hw);
 void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a);
 void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b);
@@ -61,10 +61,10 @@ s32  e1000_get_bus_info_pcie_generic(struct e1000_hw
 *hw);
 void e1000_set_lan_id_single_port(struct e1000_hw *hw);
 void e1000_set_lan_id_multi_port_pci(struct e1000_hw *hw);
 s32  e1000_get_hw_semaphore_generic(struct e1000_hw *hw);
-s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16
 *speed,
+s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32
 *speed,
                                               u16 *duplex);
 s32  e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
-                                                    u16 *speed, u16

*duplex);
+ u32 *speed, u16
*duplex);

 s32  e1000_id_led_init_generic(struct e1000_hw *hw);
 s32  e1000_led_on_generic(struct e1000_hw *hw);
 s32  e1000_led_off_generic(struct e1000_hw *hw);
drivers/net/e1000/base/e1000_vf.c +1 -1
index 778561e..2221f1c 100644
@@ -43,7 +43,7 @@ STATIC s32 e1000_setup_link_vf(struct e1000_hw *hw);
 STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
 STATIC s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
 STATIC s32 e1000_check_for_link_vf(struct e1000_hw *hw);
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
                                     u16 *duplex);
 STATIC s32 e1000_init_hw_vf(struct e1000_hw *hw);
 STATIC s32 e1000_reset_hw_vf(struct e1000_hw *hw);
@@ -220,7 +220,7 @@ STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw
 *hw)
  *  Since we cannot read the PHY and get accurate link info, we must rely

upon
* the status register's data which is often stale and inaccurate. **/

drivers/net/e1000/base/e1000_vf.c +1 -1
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
                                     u16 *duplex)
 {
        s32 status;
drivers/net/e1000/base/e1000_vf.h +1 -1
index 6d5bd99..9d801ad 100644
@@ -201,7 +201,7 @@ struct e1000_mac_operations {
        s32  (*check_for_link)(struct e1000_hw *);
        void (*clear_vfta)(struct e1000_hw *);
        s32  (*get_bus_info)(struct e1000_hw *);
-       s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+       s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
        void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
        s32  (*reset_hw)(struct e1000_hw *);
        s32  (*init_hw)(struct e1000_hw *);
drivers/net/e1000/em_ethdev.c +14 -35
index 72f792c..35ef558 100644
@@ -493,6 +493,9 @@ eth_em_start(struct rte_eth_dev *dev)
        struct e1000_hw *hw =
                E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        int ret, mask;
+       uint32_t *speeds;
+       int num_speeds;
+       bool autoneg;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -547,56 +550,46 @@ eth_em_start(struct rte_eth_dev *dev)
        E1000_WRITE_REG(hw, E1000_ITR, UINT16_MAX);
 
        /* Setup link speed and duplex */
-       switch (dev->data->dev_conf.link_speed) {
-       case ETH_LINK_SPEED_AUTONEG:
-               if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_AUTONEG_DUPLEX)
-                       hw->phy.autoneg_advertised =
 E1000_ALL_SPEED_DUPLEX;
-               else if (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_HALF_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
-               else if (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_FULL_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
-               else
-                       goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_10:
-               if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_AUTONEG_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
-               else if (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_HALF_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
-               else if (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_FULL_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
-               else
-                       goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_100:
-               if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_AUTONEG_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
-               else if (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_HALF_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
-               else if (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_FULL_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
-               else
+       speeds = &dev->data->dev_conf.link_speeds;
+       if (*speeds == ETH_LINK_SPEED_AUTONEG) {
+               hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
+       } else {
+               num_speeds = 0;
+               autoneg = ~(*speeds & ETH_LINK_SPEED_NO_AUTONEG);
+
+               /* Reset */
+               hw->phy.autoneg_advertised = 0;
+
+               if (*speeds & ~(ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M

|
+ ETH_LINK_SPEED_100M_HD |
ETH_LINK_SPEED_100M |

drivers/net/e1000/em_ethdev.c +27 -15
+                               ETH_LINK_SPEED_1G)) {
+                       num_speeds = -1;
                        goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_1000:
-               if ((dev->data->dev_conf.link_duplex ==
-                               ETH_LINK_AUTONEG_DUPLEX) ||
-                       (dev->data->dev_conf.link_duplex ==
-                                       ETH_LINK_FULL_DUPLEX))
-                       hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
-               else
+               }
+               if (*speeds & ETH_LINK_SPEED_10M_HD) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_10_HALF;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_10M) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_10_FULL;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_100M_HD) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_100_HALF;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_100M) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_100_FULL;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_1G) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
+                       num_speeds++;
+               }
+               if (num_speeds == 0 || (!autoneg && (num_speeds > 2)))
                        goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_10000:
-       default:
-               goto error_invalid_config;
        }
+
        e1000_setup_link(hw);
 
        /* check if lsc interrupt feature is enabled */
@@ -616,9 +609,8 @@ eth_em_start(struct rte_eth_dev *dev)
        return (0);
 
 error_invalid_config:
-       PMD_INIT_LOG(ERR, "Invalid link_speed/link_duplex (%u/%u) for port
 %u",
-                    dev->data->dev_conf.link_speed,
-                    dev->data->dev_conf.link_duplex, dev->data->port_id);
+       PMD_INIT_LOG(ERR, "Invalid advertised speeds (%u) for port %u",
+                    dev->data->dev_conf.link_speeds, dev->data->port_id);
        em_dev_clear_queues(dev);
        return (-EINVAL);

}

drivers/net/e1000/em_ethdev.c +5 -5
@@ -934,11 +926,11 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct
 rte_eth_dev_info *dev_info)
        dev_info->max_rx_queues = 1;
        dev_info->max_tx_queues = 1;
 
-       dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
-                                       ETH_SPEED_CAP_10M_FD |
-                                       ETH_SPEED_CAP_100M_HD |
-                                       ETH_SPEED_CAP_100M_FD |
-                                       ETH_SPEED_CAP_1G;
+       dev_info->speed_capa = ETH_LINK_SPEED_10M_HD |
+                                       ETH_LINK_SPEED_10M |
+                                       ETH_LINK_SPEED_100M_HD |
+                                       ETH_LINK_SPEED_100M |
+                                       ETH_LINK_SPEED_1G;
 }
 

/* return 0 means link status changed, -1 means not changed */

drivers/net/e1000/em_ethdev.c +7 -4
@@ -987,13 +979,16 @@ eth_em_link_update(struct rte_eth_dev *dev, int
 wait_to_complete)
 
        /* Now we check if a transition has happened */
        if (link_check && (link.link_status == 0)) {
+               uint16_t duplex;
                hw->mac.ops.get_link_up_info(hw, &link.link_speed,
-                       &link.link_duplex);
-               link.link_status = 1;
+                       &duplex);
+               link.link_duplex = (duplex) ? ETH_LINK_FULL_DUPLEX :
+                                               ETH_LINK_HALF_DUPLEX;
+               link.link_status = ETH_LINK_UP;
        } else if (!link_check && (link.link_status == 1)) {
                link.link_speed = 0;
-               link.link_duplex = 0;
-               link.link_status = 0;
+               link.link_duplex = ETH_LINK_HALF_DUPLEX;
+               link.link_status = ETH_LINK_DOWN;
        }
        rte_em_dev_atomic_write_link_status(dev, &link);
drivers/net/e1000/igb_ethdev.c +14 -29
index 927f5d9..2bbac02 100644
@@ -889,6 +889,9 @@ eth_igb_start(struct rte_eth_dev *dev)
        int ret, mask;
        uint32_t intr_vector = 0;
        uint32_t ctrl_ext;
+       uint32_t *speeds;
+       int num_speeds;
+       bool autoneg;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -984,48 +987,46 @@ eth_igb_start(struct rte_eth_dev *dev)
        }
 
        /* Setup link speed and duplex */
-       switch (dev->data->dev_conf.link_speed) {
-       case ETH_LINK_SPEED_AUTONEG:
-               if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_AUTONEG_DUPLEX)
-                       hw->phy.autoneg_advertised =
 E1000_ALL_SPEED_DUPLEX;
-               else if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_HALF_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
-               else if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_FULL_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
-               else
-                       goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_10:
-               if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_AUTONEG_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
-               else if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_HALF_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
-               else if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_FULL_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
-               else
-                       goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_100:
-               if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_AUTONEG_DUPLEX)
-                       hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
-               else if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_HALF_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
-               else if (dev->data->dev_conf.link_duplex ==
 ETH_LINK_FULL_DUPLEX)
-                       hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
-               else
+       speeds = &dev->data->dev_conf.link_speeds;
+       if (*speeds == ETH_LINK_SPEED_AUTONEG) {
+               hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
+       } else {
+               num_speeds = 0;
+               autoneg = ~(*speeds & ETH_LINK_SPEED_NO_AUTONEG);
+
+               /* Reset */
+               hw->phy.autoneg_advertised = 0;
+
+               if (*speeds & ~(ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M

|
+ ETH_LINK_SPEED_100M_HD |
ETH_LINK_SPEED_100M |

drivers/net/e1000/igb_ethdev.c +2 -3
+                               ETH_LINK_SPEED_1G)) {
+                       num_speeds = -1;
                        goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_1000:
-               if ((dev->data->dev_conf.link_duplex ==

ETH_LINK_AUTONEG_DUPLEX) ||
- (dev->data->dev_conf.link_duplex ==
ETH_LINK_FULL_DUPLEX))

drivers/net/e1000/igb_ethdev.c +25 -9
-                       hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
-               else
+               }
+               if (*speeds & ETH_LINK_SPEED_10M_HD) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_10_HALF;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_10M) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_10_FULL;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_100M_HD) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_100_HALF;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_100M) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_100_FULL;
+                       num_speeds++;
+               }
+               if (*speeds & ETH_LINK_SPEED_1G) {
+                       hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
+                       num_speeds++;
+               }
+               if (num_speeds == 0 || (!autoneg && (num_speeds > 2)))
                        goto error_invalid_config;
-               break;
-       case ETH_LINK_SPEED_10000:
-       default:
-               goto error_invalid_config;
        }
+
        e1000_setup_link(hw);
 
        /* check if lsc interrupt feature is enabled */
@@ -1055,9 +1056,8 @@ eth_igb_start(struct rte_eth_dev *dev)
        return (0);
 
 error_invalid_config:
-       PMD_INIT_LOG(ERR, "Invalid link_speed/link_duplex (%u/%u) for port
 %u",
-                    dev->data->dev_conf.link_speed,
-                    dev->data->dev_conf.link_duplex, dev->data->port_id);
+       PMD_INIT_LOG(ERR, "Invalid advertised speeds (%u) for port %u",
+                    dev->data->dev_conf.link_speeds, dev->data->port_id);
        igb_dev_clear_queues(dev);
        return (-EINVAL);

}

drivers/net/e1000/igb_ethdev.c +5 -5
@@ -1571,11 +1571,11 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct
 rte_eth_dev_info *dev_info)
                .txq_flags = 0,
        };
 
-       dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
-                                       ETH_SPEED_CAP_10M_FD |
-                                       ETH_SPEED_CAP_100M_HD |
-                                       ETH_SPEED_CAP_100M_FD |
-                                       ETH_SPEED_CAP_1G;
+       dev_info->speed_capa = ETH_LINK_SPEED_10M_HD |
+                                       ETH_LINK_SPEED_10M |
+                                       ETH_LINK_SPEED_100M_HD |
+                                       ETH_LINK_SPEED_100M |
+                                       ETH_LINK_SPEED_1G;
 }
 

static void

drivers/net/e1000/igb_ethdev.c +10 -4
@@ -1681,13 +1681,19 @@ eth_igb_link_update(struct rte_eth_dev *dev, int
 wait_to_complete)
 
        /* Now we check if a transition has happened */
        if (link_check) {
+               uint16_t duplex;
                hw->mac.ops.get_link_up_info(hw, &link.link_speed,
-                                         &link.link_duplex);
-               link.link_status = 1;
+                                         &duplex);
+               link.link_duplex = (duplex) ? ETH_LINK_FULL_DUPLEX :
+
 ETH_LINK_HALF_DUPLEX ;
+               link.link_status = ETH_LINK_UP;
+               link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+                                               ETH_LINK_SPEED_NO_AUTONEG);
        } else if (!link_check) {
                link.link_speed = 0;
-               link.link_duplex = 0;
-               link.link_status = 0;
+               link.link_duplex = ETH_LINK_HALF_DUPLEX;
+               link.link_status = ETH_LINK_DOWN;
+               link.link_autoneg = ETH_LINK_SPEED_FIXED;
        }
        rte_igb_dev_atomic_write_link_status(dev, &link);
drivers/net/fm10k/fm10k_ethdev.c +1 -3
index ca6357c..6e05355 100644
@@ -862,7 +862,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
         * is no 50Gbps Ethernet. */
        dev->data->dev_link.link_speed  = 0;
        dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-       dev->data->dev_link.link_status = 1;
+       dev->data->dev_link.link_status = ETH_LINK_UP;
 
        return 0;
 }
@@ -964,9 +964,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
                                ETH_TXQ_FLAGS_NOOFFLOADS,
        };
 
-       dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
-                                       ETH_SPEED_CAP_10G |

ETH_SPEED_CAP_25G |
- ETH_SPEED_CAP_40G |
ETH_SPEED_CAP_100G;

drivers/net/fm10k/fm10k_ethdev.c +3 -0
+       dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+                               ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+                               ETH_LINK_SPEED_40G | ETH_LINK_SPEED_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +13 -20
index 8a5dfbf..b18e81f 100644
@@ -835,27 +835,20 @@ i40e_vsi_disable_queues_intr(struct i40e_vsi *vsi)
 }
 
 static inline uint8_t
-i40e_parse_link_speed(uint16_t eth_link_speed)
+i40e_parse_link_speeds(uint16_t link_speeds)
 {
        uint8_t link_speed = I40E_LINK_SPEED_UNKNOWN;
 
-       switch (eth_link_speed) {
-       case ETH_LINK_SPEED_40G:
-               link_speed = I40E_LINK_SPEED_40GB;
-               break;
-       case ETH_LINK_SPEED_20G:
-               link_speed = I40E_LINK_SPEED_20GB;
-               break;
-       case ETH_LINK_SPEED_10G:
-               link_speed = I40E_LINK_SPEED_10GB;
-               break;
-       case ETH_LINK_SPEED_1000:
-               link_speed = I40E_LINK_SPEED_1GB;
-               break;
-       case ETH_LINK_SPEED_100:
-               link_speed = I40E_LINK_SPEED_100MB;
-               break;
-       }
+       if (link_speeds & ETH_LINK_SPEED_40G)
+               link_speed |= I40E_LINK_SPEED_40GB;
+       if (link_speeds & ETH_LINK_SPEED_20G)
+               link_speed |= I40E_LINK_SPEED_20GB;
+       if (link_speeds & ETH_LINK_SPEED_10G)
+               link_speed |= I40E_LINK_SPEED_10GB;
+       if (link_speeds & ETH_LINK_SPEED_1G)
+               link_speed |= I40E_LINK_SPEED_1GB;
+       if (link_speeds & ETH_LINK_SPEED_100M)
+               link_speed |= I40E_LINK_SPEED_100MB;
 
        return link_speed;
 }
@@ -924,9 +917,9 @@ i40e_apply_link_speed(struct rte_eth_dev *dev)
        struct i40e_hw *hw =
 I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct rte_eth_conf *conf = &dev->data->dev_conf;
 
-       speed = i40e_parse_link_speed(conf->link_speed);
+       speed = i40e_parse_link_speeds(conf->link_speeds);
        abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
-       if (conf->link_speed == ETH_LINK_SPEED_AUTONEG)
+       if (conf->link_speeds & ETH_LINK_SPEED_AUTONEG)
                abilities |= I40E_AQ_PHY_AN_ENABLED;
        else
                abilities |= I40E_AQ_PHY_LINK_ENABLED;
drivers/net/i40e/i40e_ethdev.c +2 -4
@@ -944,10 +937,8 @@ i40e_dev_start(struct rte_eth_dev *dev)
 
        hw->adapter_stopped = 0;
 
-       if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
-               (dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX))
 {
-               PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port
 %hhu",
-                            dev->data->dev_conf.link_duplex,
+       if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_NO_AUTONEG) {
+               PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu;
 autonegociation disabled",
                             dev->data->port_id);
                return -EINVAL;
        }
drivers/net/i40e/i40e_ethdev.c +8 -1
@@ -995,6 +986,13 @@ i40e_dev_start(struct rte_eth_dev *dev)
        }
 
        /* Apply link configure */
+       if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
+                               ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
+                               ETH_LINK_SPEED_20G | ETH_LINK_SPEED_40G)) {
+               PMD_DRV_LOG(ERR, "Invalid link setting");
+               goto err_up;
+       }
+
        ret = i40e_apply_link_speed(dev);
        if (I40E_SUCCESS != ret) {
                PMD_DRV_LOG(ERR, "Fail to apply link setting");
@@ -1209,7 +1207,7 @@ i40e_dev_link_update(struct rte_eth_dev *dev,
                /* Get link status information from hardware */
                status = i40e_aq_get_link_info(hw, false, &link_status,
 NULL);
                if (status != I40E_SUCCESS) {
-                       link.link_speed = ETH_LINK_SPEED_100;
+                       link.link_speed = ETH_SPEED_NUM_100M;
                        link.link_duplex = ETH_LINK_FULL_DUPLEX;
                        PMD_DRV_LOG(ERR, "Failed to get link info");
                        goto out;
drivers/net/i40e/i40e_ethdev.c +10 -8
@@ -1231,25 +1229,28 @@ i40e_dev_link_update(struct rte_eth_dev *dev,
        /* Parse the link status */
        switch (link_status.link_speed) {
        case I40E_LINK_SPEED_100MB:
-               link.link_speed = ETH_LINK_SPEED_100;
+               link.link_speed = ETH_SPEED_NUM_100M;
                break;
        case I40E_LINK_SPEED_1GB:
-               link.link_speed = ETH_LINK_SPEED_1000;
+               link.link_speed = ETH_SPEED_NUM_1G;
                break;
        case I40E_LINK_SPEED_10GB:
-               link.link_speed = ETH_LINK_SPEED_10G;
+               link.link_speed = ETH_SPEED_NUM_10G;
                break;
        case I40E_LINK_SPEED_20GB:
-               link.link_speed = ETH_LINK_SPEED_20G;
+               link.link_speed = ETH_SPEED_NUM_20G;
                break;
        case I40E_LINK_SPEED_40GB:
-               link.link_speed = ETH_LINK_SPEED_40G;
+               link.link_speed = ETH_SPEED_NUM_40G;
                break;
        default:
-               link.link_speed = ETH_LINK_SPEED_100;
+               link.link_speed = ETH_SPEED_NUM_100M;
                break;
        }
 
+       link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+                                               ETH_LINK_SPEED_NO_AUTONEG);
+
 out:
        rte_i40e_dev_atomic_write_link_status(dev, &link);
        if (link.link_status == old.link_status)
@@ -1687,10 +1688,10 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct
 rte_eth_dev_info *dev_info)
 
        if (i40e_is_40G_device(hw->device_id))
                /* For XL710 */
-               dev_info->speed_capa = ETH_SPEED_CAP_1G |
 ETH_SPEED_CAP_10G;
+               dev_info->speed_capa = ETH_LINK_SPEED_1G |
 ETH_LINK_SPEED_10G;
        else
                /* For X710 */
-               dev_info->speed_capa = ETH_SPEED_CAP_10G |

ETH_SPEED_CAP_40G;
+ dev_info->speed_capa = ETH_LINK_SPEED_10G |
ETH_LINK_SPEED_40G;

}

drivers/net/i40e/i40e_ethdev.c +3 -3
@@ -6195,15 +6196,15 @@ i40e_timesync_enable(struct rte_eth_dev *dev)
        uint32_t tsync_inc_h;
 
        switch (link->link_speed) {
-       case ETH_LINK_SPEED_40G:
+       case ETH_SPEED_NUM_40G:
                tsync_inc_l = I40E_PTP_40GB_INCVAL & 0xFFFFFFFF;
                tsync_inc_h = I40E_PTP_40GB_INCVAL >> 32;
                break;
-       case ETH_LINK_SPEED_10G:
+       case ETH_SPEED_NUM_10G:
                tsync_inc_l = I40E_PTP_10GB_INCVAL & 0xFFFFFFFF;
                tsync_inc_h = I40E_PTP_10GB_INCVAL >> 32;
                break;
-       case ETH_LINK_SPEED_1000:
+       case ETH_SPEED_NUM_1G:
                tsync_inc_l = I40E_PTP_1GB_INCVAL & 0xFFFFFFFF;
                tsync_inc_h = I40E_PTP_1GB_INCVAL >> 32;
                break;
drivers/net/i40e/i40e_ethdev_vf.c +6 -5
index b694400..8d3acae 100644
@@ -1635,13 +1635,14 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
         * DPDK pf host provide interfacet to acquire link status
         * while Linux driver does not
         */
-       if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+       if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
                i40evf_get_link_status(dev, &new_link);
-       else {
+       } else {
                /* Always assume it's up, for Linux driver PF host */
-               new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-               new_link.link_speed  = ETH_LINK_SPEED_10000;
-               new_link.link_status = 1;
+               new_link.link_speed  = ETH_SPEED_NUM_10G;
+               new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+               new_link.link_autoneg = ETH_LINK_SPEED_NEG;
+               new_link.link_status = ETH_LINK_UP;
        }
        i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +3 -4
index 3be84aa..f4dd1d2 100644
@@ -1676,14 +1676,13 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
        int mask = 0;
        int status;
        uint16_t vf, idx;
+       uint32_t *link_speeds;
 
        PMD_INIT_FUNC_TRACE();
 
        /* IXGBE devices don't support half duplex */
-       if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
-                       (dev->data->dev_conf.link_duplex !=
 ETH_LINK_FULL_DUPLEX)) {
-               PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port
 %hhu",
-                            dev->data->dev_conf.link_duplex,
+       if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_NO_AUTONEG) {
+               PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu;
 autonegociation disabled",
                             dev->data->port_id);
                return -EINVAL;
        }
drivers/net/ixgbe/ixgbe_ethdev.c +13 -23
@@ -1769,32 +1768,22 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
        if (err)
                goto error;
 
-       switch(dev->data->dev_conf.link_speed) {
-       case ETH_LINK_SPEED_AUTONEG:
-               speed = (hw->mac.type != ixgbe_mac_82598EB) ?
-                               IXGBE_LINK_SPEED_82599_AUTONEG :
-                               IXGBE_LINK_SPEED_82598_AUTONEG;
-               break;
-       case ETH_LINK_SPEED_100:
-               /*
-                * Invalid for 82598 but error will be detected by
-                * ixgbe_setup_link()
-                */
-               speed = IXGBE_LINK_SPEED_100_FULL;
-               break;
-       case ETH_LINK_SPEED_1000:
-               speed = IXGBE_LINK_SPEED_1GB_FULL;
-               break;
-       case ETH_LINK_SPEED_10000:
-               speed = IXGBE_LINK_SPEED_10GB_FULL;
-               break;
-       default:
-               PMD_INIT_LOG(ERR, "Invalid link_speed (%hu) for port %hhu",
-                            dev->data->dev_conf.link_speed,
-                            dev->data->port_id);
+       link_speeds = &dev->data->dev_conf.link_speeds;
+       if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
+
 ETH_LINK_SPEED_10G)) {
+               PMD_INIT_LOG(ERR, "Invalid link setting");
                goto error;
        }
 
+       speed = 0x0;
+
+       if (*link_speeds & ETH_LINK_SPEED_10G)
+               speed |= IXGBE_LINK_SPEED_10GB_FULL;
+       if (*link_speeds & ETH_LINK_SPEED_1G)
+               speed |= IXGBE_LINK_SPEED_1GB_FULL;
+       if (*link_speeds & ETH_LINK_SPEED_100M)
+               speed |= IXGBE_LINK_SPEED_100_FULL;
+
        err = ixgbe_setup_link(hw, speed, link_up);
        if (err)
                goto error;
drivers/net/ixgbe/ixgbe_ethdev.c +5 -4
@@ -2400,15 +2389,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct
 rte_eth_dev_info *dev_info)
        dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
        dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
 
-       dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+       dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
 
        if (hw->mac.type == ixgbe_mac_X540 ||
            hw->mac.type == ixgbe_mac_X540_vf ||
            hw->mac.type == ixgbe_mac_X550 ||
-           hw->mac.type == ixgbe_mac_X550_vf)
+           hw->mac.type == ixgbe_mac_X550_vf) {
 
-               dev_info->speed_capa |= ETH_SPEED_CAP_100M_FD /*|
-                                       ETH_SPEED_CAP_100M_HD*/;
+               dev_info->speed_capa |= ETH_LINK_SPEED_100M /*|
+                                       ETH_LINK_SPEED_100M_HD*/;
+       }
 }
 

static void

drivers/net/ixgbe/ixgbe_ethdev.c +4 -4
@@ -2471,9 +2461,9 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int
 wait_to_complete)
        int link_up;
        int diag;
 
-       link.link_status = 0;
+       link.link_status = ETH_LINK_DOWN;
        link.link_speed = 0;
-       link.link_duplex = 0;
+       link.link_duplex = ETH_LINK_HALF_DUPLEX;
        memset(&old, 0, sizeof(old));
        rte_ixgbe_dev_atomic_read_link_status(dev, &old);
@@ -2486,8 +2476,8 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int
 wait_to_complete)
                diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
 
        if (diag != 0) {
-               link.link_speed = ETH_LINK_SPEED_100;
-               link.link_duplex = ETH_LINK_HALF_DUPLEX;
+               link.link_speed = ETH_SPEED_NUM_100M;
+               link.link_duplex = ETH_LINK_FULL_DUPLEX;
                rte_ixgbe_dev_atomic_write_link_status(dev, &link);
                if (link.link_status == old.link_status)
                        return -1;
drivers/net/ixgbe/ixgbe_ethdev.c +6 -6
@@ -2500,26 +2490,26 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int
 wait_to_complete)
                        return -1;
                return 0;
        }
-       link.link_status = 1;
+       link.link_status = ETH_LINK_UP;
        link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
        switch (link_speed) {
        default:
        case IXGBE_LINK_SPEED_UNKNOWN:
-               link.link_duplex = ETH_LINK_HALF_DUPLEX;
-               link.link_speed = ETH_LINK_SPEED_100;
+               link.link_duplex = ETH_LINK_FULL_DUPLEX;
+               link.link_speed = ETH_SPEED_NUM_100M;
                break;
 
        case IXGBE_LINK_SPEED_100_FULL:
-               link.link_speed = ETH_LINK_SPEED_100;
+               link.link_speed = ETH_SPEED_NUM_100M;
                break;
 
        case IXGBE_LINK_SPEED_1GB_FULL:
-               link.link_speed = ETH_LINK_SPEED_1000;
+               link.link_speed = ETH_SPEED_NUM_1G;
                break;
 
        case IXGBE_LINK_SPEED_10GB_FULL:
-               link.link_speed = ETH_LINK_SPEED_10000;
+               link.link_speed = ETH_SPEED_NUM_10G;
                break;
        }
        rte_ixgbe_dev_atomic_write_link_status(dev, &link);
drivers/net/mlx4/mlx4.c +2 -0
index b45e21a..96fe4b6 100644
@@ -4207,6 +4207,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev,
 int wait_to_complete)
                dev_link.link_speed = link_speed;
        dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
                                ETH_LINK_HALF_DUPLEX :
 ETH_LINK_FULL_DUPLEX);
+       dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+                                               ETH_LINK_SPEED_NO_AUTONEG);
        if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
                /* Link status changed. */
                dev->data->dev_link = dev_link;
drivers/net/mpipe/mpipe_tilegx.c +4 -2
index 743feef..5875371 100644
@@ -388,14 +388,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int
 wait_to_complete)
 
                speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+               new.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+                                               ETH_LINK_SPEED_NO_AUTONEG);
                if (speed == GXIO_MPIPE_LINK_1G) {
                        new.link_speed = ETH_LINK_SPEED_1000;
                        new.link_duplex = ETH_LINK_FULL_DUPLEX;
-                       new.link_status = 1;
+                       new.link_status = ETH_LINK_UP;
                } else if (speed == GXIO_MPIPE_LINK_10G) {
                        new.link_speed = ETH_LINK_SPEED_10000;
                        new.link_duplex = ETH_LINK_FULL_DUPLEX;
-                       new.link_status = 1;
+                       new.link_status = ETH_LINK_UP;
                }
 
                rc = mpipe_link_compare(&old, &new);
drivers/net/null/rte_eth_null.c +3 -2
index e244595..7704fa6 100644
@@ -79,9 +79,10 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-       .link_speed = 10000,
+       .link_speed = ETH_SPEED_NUM_10G,
        .link_duplex = ETH_LINK_FULL_DUPLEX,
-       .link_status = 0
+       .link_status = ETH_LINK_DOWN,
+       .link_autoneg = ETH_LINK_SPEED_NEG,
 };
 
 static uint16_t
drivers/net/pcap/rte_eth_pcap.c +3 -2
index f2e4634..ea7a28f 100644
@@ -125,9 +125,10 @@ static int open_single_iface(const char *iface,
 pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2,
 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-               .link_speed = 10000,
+               .link_speed = ETH_SPEED_NUM_10G,
                .link_duplex = ETH_LINK_FULL_DUPLEX,
-               .link_status = 0
+               .link_status = ETH_LINK_DOWN,
+               .link_autoneg = ETH_LINK_SPEED_FIXED,
 };

static int

drivers/net/pcap/rte_eth_pcap.c +2 -2
@@ -430,7 +431,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-       dev->data->dev_link.link_status = 1;
+       dev->data->dev_link.link_status = ETH_LINK_UP;
        return 0;
 }
 
@@ -481,7 +482,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
        }
 
 status_down:
-       dev->data->dev_link.link_status = 0;
+       dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +3 -2
index 0ba36d5..626c381 100644
@@ -71,9 +71,10 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-               .link_speed = 10000,
+               .link_speed = ETH_SPEED_NUM_10G,
                .link_duplex = ETH_LINK_FULL_DUPLEX,
-               .link_status = 0
+               .link_status = ETH_LINK_DOWN,
+               .link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/virtio/virtio_ethdev.c +0 -0
index 465d3cd..ecbf9f2 100644
@@ -1517,7 +1517,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev,

__rte_unused int wait_to_complet

        memset(&link, 0, sizeof(link));
        virtio_dev_atomic_read_link_status(dev, &link);
        old = link;
drivers/net/virtio/virtio_ethdev.c +1 -1
-       link.link_duplex = FULL_DUPLEX;
+       link.link_duplex = ETH_LINK_FULL_DUPLEX;
        link.link_speed  = SPEED_10G;
 
        if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index 9026d42..424d650 100644
@@ -42,8 +42,6 @@
 #define SPEED_100      100
 #define SPEED_1000     1000
 #define SPEED_10G      10000
-#define HALF_DUPLEX    1
-#define FULL_DUPLEX    2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -0
index a70be5c..6860360 100644
@@ -697,9 +697,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev,

__attribute__((unused)) int wai

        ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);

        if (ret & 0x1) {
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -2
-               link.link_status = 1;
+               link.link_status = ETH_LINK_UP;
                link.link_duplex = ETH_LINK_FULL_DUPLEX;
-               link.link_speed = ETH_LINK_SPEED_10000;
+               link.link_speed = ETH_SPEED_NUM_10G;
+               link.link_autoneg = ETH_LINK_SPEED_FIXED;
        }
 
        vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -2
index 73e8bce..fb492ee 100644
@@ -70,9 +70,10 @@ static int virtio_idx = 0;
 static const char *drivername = "xen dummy virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-               .link_speed = 10000,
+               .link_speed = ETH_SPEED_NUM_10G,
                .link_duplex = ETH_LINK_FULL_DUPLEX,
-               .link_status = 0
+               .link_status = ETH_LINK_DOWN,
+               .link_autoneg = ETH_LINK_SPEED_FIXED
 };
 
 static inline struct rte_mbuf *
examples/ip_pipeline/config_parse.c +1 -2
index c9b78f9..92e6a18 100644
@@ -83,8 +83,7 @@ static const struct app_link_params link_params_default
 = {
        .mac_addr = 0,
 
        .conf = {
-               .link_speed = 0,
-               .link_duplex = 0,
+               .link_speeds = 0,
                .rxmode = {
                        .mq_mode = ETH_MQ_RX_NONE,
lib/librte_ether/rte_ethdev.c +49 -0
index f593f6e..29b2960 100644
@@ -1072,6 +1072,55 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t
 nb_rx_q, uint16_t nb_tx_q,
 }
 
 int
+rte_eth_speed_to_bm_flag(uint32_t speed, int duplex, uint32_t *flag)
+{
+       switch (speed) {
+       case ETH_SPEED_NUM_10M:
+               *flag = (duplex) ? ETH_LINK_SPEED_10M :
+
 ETH_LINK_SPEED_10M_HD;
+               break;
+       case ETH_SPEED_NUM_100M:
+               *flag = (duplex) ? ETH_LINK_SPEED_100M :
+
 ETH_LINK_SPEED_100M_HD;
+               break;
+       case ETH_SPEED_NUM_1G:
+               *flag = ETH_LINK_SPEED_1G;
+               break;
+       case ETH_SPEED_NUM_2_5G:
+               *flag = ETH_LINK_SPEED_2_5G;
+               break;
+       case ETH_SPEED_NUM_5G:
+               *flag = ETH_LINK_SPEED_5G;
+               break;
+       case ETH_SPEED_NUM_10G:
+               *flag = ETH_LINK_SPEED_10G;
+               break;
+       case ETH_SPEED_NUM_20G:
+               *flag = ETH_LINK_SPEED_20G;
+               break;
+       case ETH_SPEED_NUM_25G:
+               *flag = ETH_LINK_SPEED_25G;
+               break;
+       case ETH_SPEED_NUM_40G:
+               *flag = ETH_LINK_SPEED_40G;
+               break;
+       case ETH_SPEED_NUM_50G:
+               *flag = ETH_LINK_SPEED_50G;
+               break;
+       case ETH_SPEED_NUM_56G:
+               *flag = ETH_LINK_SPEED_56G;
+               break;
+       case ETH_SPEED_NUM_100G:
+               *flag = ETH_LINK_SPEED_100G;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+int

rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
const struct rte_eth_conf *dev_conf)
{

lib/librte_ether/rte_ethdev.h +3 -0
index 951a423..54ee6f9 100644
@@ -238,26 +238,59 @@ struct rte_eth_stats {
 };
 
 /**
+ * Device supported speeds bitmap flags
+ */
+#define ETH_LINK_SPEED_AUTONEG         (0 << 0)  /*< Autonegociate (all

speeds) */
+#define ETH_LINK_SPEED_NO_AUTONEG (1 << 0) /*< Disable autoneg
(fixed speed) */
+#define ETH_LINK_SPEED_10M_HD (1 << 1) /*< 10 Mbps half-duplex
*/
+#define ETH_LINK_SPEED_10M (1 << 2) /*< 10 Mbps full-duplex
*/
+#define ETH_LINK_SPEED_100M_HD (1 << 3) /*< 100 Mbps half-duplex
*/
+#define ETH_LINK_SPEED_100M (1 << 4) /*< 100 Mbps full-duplex
*/

lib/librte_ether/rte_ethdev.h +29 -0
+#define ETH_LINK_SPEED_1G              (1 << 5)  /*< 1 Gbps */
+#define ETH_LINK_SPEED_2_5G            (1 << 6)  /*< 2.5 Gbps */
+#define ETH_LINK_SPEED_5G              (1 << 7)  /*< 5 Gbps */
+#define ETH_LINK_SPEED_10G             (1 << 8)  /*< 10 Mbps */
+#define ETH_LINK_SPEED_20G             (1 << 9)  /*< 20 Gbps */
+#define ETH_LINK_SPEED_25G             (1 << 10)  /*< 25 Gbps */
+#define ETH_LINK_SPEED_40G             (1 << 11)  /*< 40 Gbps */
+#define ETH_LINK_SPEED_50G             (1 << 12)  /*< 50 Gbps */
+#define ETH_LINK_SPEED_56G             (1 << 13)  /*< 56 Gbps */
+#define ETH_LINK_SPEED_100G            (1 << 14)  /*< 100 Gbps */
+
+/**
+ * Ethernet numeric link speeds in Mbps
+ */
+#define ETH_SPEED_NUM_NONE     0      /*< Not defined */
+#define ETH_SPEED_NUM_10M      10     /*< 10 Mbps */
+#define ETH_SPEED_NUM_100M     100    /*< 100 Mbps */
+#define ETH_SPEED_NUM_1G       1000   /*< 1 Gbps */
+#define ETH_SPEED_NUM_2_5G     2500   /*< 2.5 Gbps */
+#define ETH_SPEED_NUM_5G       5000   /*< 5 Gbps */
+#define ETH_SPEED_NUM_10G      10000  /*< 10 Mbps */
+#define ETH_SPEED_NUM_20G      20000  /*< 20 Gbps */
+#define ETH_SPEED_NUM_25G      25000  /*< 25 Gbps */
+#define ETH_SPEED_NUM_40G      40000  /*< 40 Gbps */
+#define ETH_SPEED_NUM_50G      50000  /*< 50 Gbps */
+#define ETH_SPEED_NUM_56G      56000  /*< 56 Gbps */
+#define ETH_SPEED_NUM_100G     100000 /*< 100 Gbps */
+
+/**
  * A structure used to retrieve link-level information of an Ethernet

port.
*/
struct rte_eth_link {
- uint16_t link_speed; /**< ETH_LINK_SPEED_[10, 100, 1000,
10000] */
- uint16_t link_duplex; /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX]
*/

lib/librte_ether/rte_ethdev.h +0 -9
-       uint8_t  link_status : 1; /**< 1 -> link up, 0 -> link down */
-}__attribute__((aligned(8)));     /**< aligned for atomic64 read/write */
-
-#define ETH_LINK_SPEED_AUTONEG  0       /**< Auto-negotiate link speed. */
-#define ETH_LINK_SPEED_10       10      /**< 10 megabits/second. */
-#define ETH_LINK_SPEED_100      100     /**< 100 megabits/second. */
-#define ETH_LINK_SPEED_1000     1000    /**< 1 gigabits/second. */
-#define ETH_LINK_SPEED_10000    10000   /**< 10 gigabits/second. */
-#define ETH_LINK_SPEED_10G      10000   /**< alias of 10 gigabits/second.

*/

lib/librte_ether/rte_ethdev.h +2 -2
-#define ETH_LINK_SPEED_20G      20000   /**< 20 gigabits/second. */
-#define ETH_LINK_SPEED_40G      40000   /**< 40 gigabits/second. */
+       uint32_t link_speed;        /**< Link speed (ETH_SPEED_NUM_) */
+       uint16_t link_duplex  : 1;  /**< 1 -> full duplex, 0 -> half

duplex */
+ uint16_t link_autoneg : 1; /**< 1 -> link speed has been autoneg
*/

lib/librte_ether/rte_ethdev.h +2 -0
+       uint16_t link_status  : 1;  /**< 1 -> link up, 0 -> link down */
+} __attribute__((aligned(8)));      /**< aligned for atomic64 read/write

*/

lib/librte_ether/rte_ethdev.h +4 -3
-#define ETH_LINK_AUTONEG_DUPLEX 0       /**< Auto-negotiate duplex. */
-#define ETH_LINK_HALF_DUPLEX    1       /**< Half-duplex connection. */
-#define ETH_LINK_FULL_DUPLEX    2       /**< Full-duplex connection. */
+/* Utility constants */
+#define ETH_LINK_HALF_DUPLEX    0      /**< Half-duplex connection. */
+#define ETH_LINK_FULL_DUPLEX    1      /**< Full-duplex connection. */
+#define ETH_LINK_SPEED_FIXED    0      /**< Link speed was not

autonegociated. */
+#define ETH_LINK_SPEED_NEG 1 /**< Link speed was
autonegociated. */

lib/librte_ether/rte_ethdev.h +3 -4
+#define ETH_LINK_DOWN          0       /**< Link is down. */
+#define ETH_LINK_UP            1       /**< Link is up. */
 
 /**
  * A structure used to configure the ring threshold registers of an RX/TX
@@ -747,10 +780,14 @@ struct rte_intr_conf {
  * configuration settings may be needed.
  */
 struct rte_eth_conf {
-       uint16_t link_speed;
-       /**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */
-       uint16_t link_duplex;
-       /**< ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation */
+       uint32_t link_speeds; /**< bitmap of ETH_LINK_SPEED_XXX of speeds

to be
+ used. ETH_LINK_SPEED_NO_AUTONEG disables
link
+ autonegociation, and a unique speed shall
be
+ set. Otherwise, the bitmap defines the set
of
+ speeds to be advertised. If the special
value
+ ETH_LINK_SPEED_AUTONEG (0) is used, all
speeds

lib/librte_ether/rte_ethdev.h +2 -0
+                               supported are advertised.
+                               */
        struct rte_eth_rxmode rxmode; /**< Port RX configuration. */
        struct rte_eth_txmode txmode; /**< Port TX configuration. */
        uint32_t lpbk_mode; /**< Loopback operation mode. By default the

value

lib/librte_ether/rte_ethdev.h +16 -20
@@ -812,26 +849,6 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
 /**
- * Device supported speeds
- */
-#define ETH_SPEED_CAP_NOT_PHY  (0)  /*< No phy media > */
-#define ETH_SPEED_CAP_10M_HD   (1 << 0)  /*< 10 Mbps half-duplex> */
-#define ETH_SPEED_CAP_10M_FD   (1 << 1)  /*< 10 Mbps full-duplex> */
-#define ETH_SPEED_CAP_100M_HD  (1 << 2)  /*< 100 Mbps half-duplex> */
-#define ETH_SPEED_CAP_100M_FD  (1 << 3)  /*< 100 Mbps full-duplex> */
-#define ETH_SPEED_CAP_1G       (1 << 4)  /*< 1 Gbps > */
-#define ETH_SPEED_CAP_2_5G     (1 << 5)  /*< 2.5 Gbps > */
-#define ETH_SPEED_CAP_5G       (1 << 6)  /*< 5 Gbps > */
-#define ETH_SPEED_CAP_10G      (1 << 7)  /*< 10 Mbps > */
-#define ETH_SPEED_CAP_20G      (1 << 8)  /*< 20 Gbps > */
-#define ETH_SPEED_CAP_25G      (1 << 9)  /*< 25 Gbps > */
-#define ETH_SPEED_CAP_40G      (1 << 10)  /*< 40 Gbps > */
-#define ETH_SPEED_CAP_50G      (1 << 11)  /*< 50 Gbps > */
-#define ETH_SPEED_CAP_56G      (1 << 12)  /*< 56 Gbps > */
-#define ETH_SPEED_CAP_100G     (1 << 13)  /*< 100 Gbps > */
-
-
-/**
  * Ethernet device information
  */
 struct rte_eth_dev_info {
@@ -1667,6 +1684,22 @@ struct eth_driver {
 extern void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
+ * Convert a numerical speed in Mbps to a bitmap flag that can be used in
+ * the bitmap link_speeds of the struct rte_eth_conf
+ *
+ * @param
+ *   Numerical speed value in Mbps
+ * @param
+ *   Boolean is duplex (only for 10/100 speeds)
+ * @param
+ *   On success, the converted speed into a bitmap flag
+ * @return
+ *   0 on success, -EINVAL if the speed cannot be mapped
+ */
+extern int rte_eth_speed_to_bm_flag(uint32_t speed, int duplex,
+                                                       uint32_t *flag);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in

the
--
2.1.4

#8 lore raw

Re: [PATCH v6 3/5] ethdev: redesign link speed config API

In reply to Marc Sune

2015-10-25 22:59, Marc Sune:

Quoted 10 lines

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

Quoted 9 lines

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.

Having it split in several commits may help to understand the changes. And it must be explained in the release notes in the "API changes".

#3 lore raw

Re: [PATCH v6 1/5] ethdev: Added ETH_SPEED_CAP bitmap for ports

In reply to Marc Sune

2015-10-25 22:59, Marc Sune:

Quoted 5 lines
lib/librte_ether/rte_ethdev.h +5 -0
+#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
+#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */

lib/librte_ether/rte_ethdev.h struct rte_eth_conf { · line 831

Quoted 10 lines
lib/librte_ether/rte_ethdev.h +10 -0
+#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */

In the patch 3, you rename this flags. It would be easier to understand if the right names were used in the first patch.

lib/librte_ether/rte_ethdev.h struct rte_eth_dev_info { · line 863

Quoted 5 lines
lib/librte_ether/rte_ethdev.h +1 -0
@@ -837,6 +860,7 @@ struct rte_eth_dev_info {
 	uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
 	uint16_t vmdq_queue_num;  /**< Queue number for VMDQ pools. */
 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
+	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_SPEED_CAP_). */

When renaming ETH_SPEED_CAP, this line is not changed later.

author
#9 lore raw

Re: [PATCH v6 3/5] ethdev: redesign link speed config API

In reply to Thomas Monjalon

Hi Thomas,

2015-11-01 23:16 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 21 lines

2015-10-25 22:59, Marc Sune:

Quoted 10 lines

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

Quoted 9 lines

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.

Quoted 2 lines

Having it split in several commits may help to understand the changes.

Apologies for the late response... crazy days.

At least first and last point in the enumeration do not make sense alone. I can split the link_speed bug for 100G in another patch if you consider is necessary for the series to be merged in.

Quoted 2 lines

And it must be explained in the release notes in the "API changes".

Patch 4/5 in the series attempts to cover this:

http://dpdk.org/dev/patchwork/patch/7996/

Isn't it enough?

Marc

author
#4 lore raw

Re: [PATCH v6 1/5] ethdev: Added ETH_SPEED_CAP bitmap for ports

In reply to Thomas Monjalon

Hi Thomas,

2015-11-01 23:11 GMT+01:00 Thomas Monjalon <[email protected]>:

Quoted 22 lines

2015-10-25 22:59, Marc Sune:

lib/librte_ether/rte_ethdev.h struct rte_eth_conf {

Quoted 4 lines
lib/librte_ether/rte_ethdev.h +4 -0
+#define ETH_SPEED_CAP_NOT_PHY        (0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD (1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD (1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD        (1 << 2)  /*< 100 Mbps

half-duplex> */

Quoted 1 line

+#define ETH_SPEED_CAP_100M_FD (1 << 3) /*< 100 Mbps

full-duplex> */

lib/librte_ether/rte_ethdev.h struct rte_eth_conf { · line 831

Quoted 10 lines
lib/librte_ether/rte_ethdev.h +10 -0
+#define ETH_SPEED_CAP_1G     (1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G   (1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G     (1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G    (1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G    (1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G    (1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G    (1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G    (1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G    (1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G   (1 << 13)  /*< 100 Gbps > */

In the patch 3, you rename this flags. It would be easier to understand if the right names were used in the first patch.

Quoted 9 lines

lib/librte_ether/rte_ethdev.h struct rte_eth_dev_info { · line 863

Quoted 5 lines
lib/librte_ether/rte_ethdev.h +1 -0
@@ -837,6 +860,7 @@ struct rte_eth_dev_info {
      uint16_t vmdq_queue_base; /**< First queue ID for VMDQ pools. */
      uint16_t vmdq_queue_num;  /**< Queue number for VMDQ pools. */
      uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
+     uint32_t speed_capa;  /**< Supported speeds bitmap

(ETH_SPEED_CAP_). */

When renaming ETH_SPEED_CAP, this line is not changed later.

This is made in purpose.

In patch 3/5 the bitmap speeds are renamed to ETH_LINK_SPEED_XXX and numeric values are moved ETH_SPEED_NUM_XXX, to make clear the difference. I cannot, in this commit, rename them directly to ETH_LINK_SPEED_XXX since they would collide with the current numeric speeds.

Thanks
Marc

author
#12 lore raw
In reply to Marc Sune

2015-10-25 22:59 GMT+01:00 Marc Sune <[email protected]>:

Quoted 26 lines

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it
is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

Quoted 4 lines

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Minor bugs expected.

I will respin this patch to current HEAD targeting 2.3, but note that testing of PMDs other than i40 and e1000 (82540Em) is necessary for this patch to be merged.

I do not have all the HW to test it, so I would like to ask for some help here. Some (more) peer reviews would also help.

Regards
marc

Quoted 80 lines

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment (checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a
bitmap
for defining the announced speeds, as suggested M. Brorup. Fixed
spelling
issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current
HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

Marc Sune (5):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes
ethdev: add rte_eth_speed_to_bm_flag() to ver. map

 app/test-pmd/cmdline.c                     | 124
+++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 doc/guides/rel_notes/release_2_2.rst       |  23 ++++++
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   4 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 109 ++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 104 +++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c           |   5 +-
 drivers/net/i40e/i40e_ethdev.c             |  78 ++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  74 ++++++++---------
 drivers/net/mlx4/mlx4.c                    |   6 ++
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              |  97 +++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map     |   6 ++
 38 files changed, 501 insertions(+), 322 deletions(-)

--
2.1.4

#13 lore raw

We will test on Mellanox NICs

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marc Sune
Sent: Wednesday, December 16, 2015 10:38 PM
To: [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 0/5] ethdev: add speed capabilities and refactor link API

2015-10-25 22:59 GMT+01:00 Marc Sune <[email protected]>:

Quoted 25 lines

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

Quoted 4 lines

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Minor bugs expected.

I will respin this patch to current HEAD targeting 2.3, but note that testing of PMDs other than i40 and e1000 (82540Em) is necessary for this patch to be merged.

I do not have all the HW to test it, so I would like to ask for some help here. Some (more) peer reviews would also help.

Regards
marc

Quoted 80 lines

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment (checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a
bitmap
for defining the announced speeds, as suggested M. Brorup. Fixed
spelling
issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current
HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

Marc Sune (5):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes
ethdev: add rte_eth_speed_to_bm_flag() to ver. map

 app/test-pmd/cmdline.c                     | 124
+++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 doc/guides/rel_notes/release_2_2.rst       |  23 ++++++
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   4 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 109 ++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 104 +++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c           |   5 +-
 drivers/net/i40e/i40e_ethdev.c             |  78 ++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  74 ++++++++---------
 drivers/net/mlx4/mlx4.c                    |   6 ++
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              |  97 +++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map     |   6 ++
 38 files changed, 501 insertions(+), 322 deletions(-)

--
2.1.4

author
#14 lore raw

v7 cover ethdev: add speed capabilities and refactor link API

In reply to Marc Sune

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment (checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a bitmap for defining the announced speeds, as suggested M. Brorup. Fixed spelling issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

Marc Sune (5):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes
ethdev: add rte_eth_speed_to_bm_flag() to ver. map

 app/test-pmd/cmdline.c                     | 124 +++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 doc/guides/rel_notes/release_2_2.rst       |  23 ++++++
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   4 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 109 ++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 104 +++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c           |   5 +-
 drivers/net/i40e/i40e_ethdev.c             |  78 ++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  74 ++++++++---------
 drivers/net/mlx4/mlx4.c                    |   6 ++
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              |  97 +++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map     |   6 ++
 38 files changed, 501 insertions(+), 322 deletions(-)
Signature · 1 line
2.1.4
author
#15 lore raw

PATCH v7 1/5 ethdev: Added ETH_SPEED_CAP bitmap for ports

Added constants and bitmap to struct rte_eth_dev_info to be used by PMDs.

---
 lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
lib/librte_ether/rte_ethdev.h +24 -0
index 8710dd7..dbc1599 100644
@@ -824,6 +824,29 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
+/**
+ * Device supported speeds
+ */
+#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
+#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */
+#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */
+
+
+/**
+ * Ethernet device information
+ */
 struct rte_eth_dev_info {
 	struct rte_pci_device *pci_dev; /**< Device PCI information. */
 	const char *driver_name; /**< Device Driver name. */
@@ -852,6 +875,7 @@ struct rte_eth_dev_info {
 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
 	struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
 	struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
+	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_SPEED_CAP_). */
 };
 
 /**
Signature · 1 line
2.1.4
author
#16 lore raw

PATCH v7 2/5 ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* mlx4
* fm10k

---
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 6 files changed, 39 insertions(+)
drivers/net/e1000/em_ethdev.c +6 -0
index 66e8993..fd48bbf 100644
@@ -1023,6 +1023,12 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_min = E1000_MIN_RING_DESC,
 		.nb_align = EM_TXD_ALIGN,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 /* return 0 means link status changed, -1 means not changed */
drivers/net/e1000/igb_ethdev.c +6 -0
index d1bbcda..9c8dffa 100644
@@ -1908,6 +1908,12 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 static void
drivers/net/fm10k/fm10k_ethdev.c +4 -0
index e4aed94..aeb2962 100644
@@ -1333,6 +1333,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_min = FM10K_MIN_TX_DESC,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
+					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
+					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +9 -0
index bf6220d..d242973 100644
@@ -2233,6 +2233,7 @@ static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vsi *vsi = pf->main_vsi;
 
 	dev_info->max_rx_queues = vsi->nb_qps;
@@ -2304,6 +2305,14 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->max_rx_queues += dev_info->vmdq_queue_num;
 		dev_info->max_tx_queues += dev_info->vmdq_queue_num;
 	}
+
+	if (i40e_is_40G_device(hw->device_id))
+		/* For XL710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+	else
+		/* For X710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+
 }
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +10 -0
index 4c4c6df..4e3ab3d 100644
@@ -2827,6 +2827,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
 	dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
 	dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+
+	if (hw->mac.type == ixgbe_mac_X540 ||
+	    hw->mac.type == ixgbe_mac_X540_vf ||
+	    hw->mac.type == ixgbe_mac_X550 ||
+	    hw->mac.type == ixgbe_mac_X550_vf)
+
+		dev_info->speed_capa |= ETH_SPEED_CAP_100M_FD /*|
+					ETH_SPEED_CAP_100M_HD*/;
 }
 
 static void
drivers/net/mlx4/mlx4.c +4 -0
index 207bfe2..1f3ed59 100644
@@ -4265,6 +4265,10 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		 0);
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
+
+	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }
 
Signature · 1 line
2.1.4
author
#17 lore raw

PATCH v7 3/5 ethdev: redesign link speed config API

In reply to Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.

---
 app/test-pmd/cmdline.c                     | 124 +++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   7 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 113 +++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 108 +++++++++++++------------
 drivers/net/fm10k/fm10k_ethdev.c           |   8 +-
 drivers/net/i40e/i40e_ethdev.c             |  73 ++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  78 ++++++++----------
 drivers/net/mlx4/mlx4.c                    |   2 +
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              | 113 ++++++++++++++++----------
 36 files changed, 454 insertions(+), 365 deletions(-)
app/test-pmd/cmdline.c +64 -60
index 6d28c1b..00571bc 100644
@@ -956,14 +956,65 @@ struct cmd_config_speed_all {
 	cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *value1, char *value2, uint32_t *link_speed)
+{
+
+	int duplex;
+
+	if (!strcmp(value2, "half")) {
+		duplex = 0;
+	} else if (!strcmp(value2, "full")) {
+		duplex = 1;
+	} else if (!strcmp(value2, "auto")) {
+		duplex = 1;
+	} else {
+		printf("Unknown parameter\n");
+		return -1;
+	}
+
+	if (!strcmp(value1, "10")) {
+		*link_speed = (duplex) ? ETH_LINK_SPEED_10M :
+							ETH_LINK_SPEED_10M_HD;
+	} else if (!strcmp(value1, "100")) {
+		*link_speed = (duplex) ? ETH_LINK_SPEED_100M :
+							ETH_LINK_SPEED_100M_HD;
+	} else if (!strcmp(value1, "1000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_1G;
+	} else if (!strcmp(value1, "10000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_10G;
+	} else if (!strcmp(value1, "40000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_40G;
+	} else if (!strcmp(value1, "auto")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_AUTONEG;
+	} else {
+		printf("Unknown parameter\n");
+		return -1;
+	}
+
+	return 0;
+
+invalid_speed_param:
+
+	printf("Invalid speed parameter\n");
+	return -1;
+}
+
 static void
 cmd_config_speed_all_parsed(void *parsed_result,
 			__attribute__((unused)) struct cmdline *cl,
 			__attribute__((unused)) void *data)
 {
 	struct cmd_config_speed_all *res = parsed_result;
-	uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-	uint16_t link_duplex = 0;
+	uint32_t link_speed;
 	portid_t pid;
 
 	if (!all_ports_stopped()) {
@@ -971,40 +1022,18 @@ cmd_config_speed_all_parsed(void *parsed_result,
 		return;
 	}
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10G;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1,
+						res->value2,
+						&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
 	FOREACH_PORT(pid, ports) {
-		ports[pid].dev_conf.link_speed = link_speed;
-		ports[pid].dev_conf.link_duplex = link_duplex;
+		ports[pid].dev_conf.link_speeds = link_speed;
 	}
 
 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+
+	return;
 }
 
 cmdline_parse_token_string_t cmd_config_speed_all_port =
@@ -1059,8 +1088,7 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 				__attribute__((unused)) void *data)
 {
 	struct cmd_config_speed_specific *res = parsed_result;
-	uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-	uint16_t link_duplex = 0;
+	uint32_t link_speed;
 
 	if (!all_ports_stopped()) {
 		printf("Please stop all ports first\n");
@@ -1070,36 +1098,12 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 	if (port_id_is_invalid(res->id, ENABLED_WARN))
 		return;
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10000;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1,
+						res->value2,
+						&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
-	ports[res->id].dev_conf.link_speed = link_speed;
-	ports[res->id].dev_conf.link_duplex = link_duplex;
+	ports[res->id].dev_conf.link_speeds = link_speed;
 
 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
 }
app/test/virtual_pmd.c +2 -2
index a538c8a..3c4040b 100644
@@ -603,8 +603,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
-	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
index 767f36b..5db1db2 100644
@@ -116,9 +116,10 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/bonding/rte_eth_bond_8023ad.c +7 -7
index b3b30f6..3b446e1 100644
@@ -708,25 +708,25 @@ link_speed_key(uint16_t speed) {
 	uint16_t key_speed;
 
 	switch (speed) {
-	case ETH_LINK_SPEED_AUTONEG:
+	case ETH_SPEED_NUM_NONE:
 		key_speed = 0x00;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		key_speed = BOND_LINK_SPEED_KEY_10M;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		key_speed = BOND_LINK_SPEED_KEY_100M;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		key_speed = BOND_LINK_SPEED_KEY_1000M;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		key_speed = BOND_LINK_SPEED_KEY_10G;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		key_speed = BOND_LINK_SPEED_KEY_20G;
 		break;
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		key_speed = BOND_LINK_SPEED_KEY_40G;
 		break;
 	default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		if (stat & F_FW_PORT_CMD_TXPAUSE)
 			fc |= PAUSE_TX;
 		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-			speed = ETH_LINK_SPEED_100;
+			speed = ETH_SPEED_NUM_100M;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-			speed = ETH_LINK_SPEED_1000;
+			speed = ETH_SPEED_NUM_1G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-			speed = ETH_LINK_SPEED_10000;
+			speed = ETH_SPEED_NUM_10G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-			speed = ETH_LINK_SPEED_40G;
+			speed = ETH_SPEED_NUM_40G;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
drivers/net/e1000/base/e1000_80003es2lan.c +3 -3
index 5ac925e..ae11cac 100644
@@ -52,7 +52,7 @@ STATIC s32  e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
 STATIC s32  e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_get_cable_length_80003es2lan(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32 *speed,
 					       u16 *duplex);
 STATIC s32  e1000_reset_hw_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_80003es2lan(struct e1000_hw *hw);
@@ -789,7 +789,7 @@ STATIC s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
  *
  *  Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32 *speed,
 					      u16 *duplex)
 {
 	s32 ret_val;
@@ -1247,7 +1247,7 @@ STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
 {
 	s32 ret_val = E1000_SUCCESS;
-	u16 speed;
+	u32 speed;
 	u16 duplex;
 
 	DEBUGFUNC("e1000_configure_on_link_up");
drivers/net/e1000/base/e1000_82541.c +4 -4
index 9cdb91c..73f9234 100644
@@ -47,7 +47,7 @@ STATIC s32  e1000_init_nvm_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_mac_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_reset_hw_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_82541(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
 					 u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_82541(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_82541(struct e1000_hw *hw);
@@ -437,7 +437,7 @@ out:
  *
  * Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
 					u16 *duplex)
 {
 	struct e1000_phy_info *phy = &hw->phy;
@@ -667,8 +667,8 @@ STATIC s32 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
 	struct e1000_phy_info *phy = &hw->phy;
 	struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
 	s32 ret_val;
-	u32 idle_errs = 0;
-	u16 phy_data, phy_saved_data, speed, duplex, i;
+	u32 idle_errs = 0, speed;
+	u16 phy_data, phy_saved_data, duplex, i;
 	u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
 	u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
 						IGP01E1000_PHY_AGC_PARAM_A,
drivers/net/e1000/base/e1000_82543.c +2 -2
index fc96199..4402f63 100644
@@ -1192,9 +1192,9 @@ out:
 STATIC s32 e1000_check_for_copper_link_82543(struct e1000_hw *hw)
 {
 	struct e1000_mac_info *mac = &hw->mac;
-	u32 icr, rctl;
+	u32 icr, rctl, speed;
 	s32 ret_val;
-	u16 speed, duplex;
+	u16 duplex;
 	bool link;
 
 	DEBUGFUNC("e1000_check_for_copper_link_82543");
drivers/net/e1000/base/e1000_82575.c +6 -5
index 723885d..f8d61e4 100644
@@ -53,7 +53,7 @@ STATIC void e1000_release_nvm_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_media_swap(struct e1000_hw *hw);
 STATIC s32  e1000_get_cfg_done_82575(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
 					 u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
 STATIC s32  e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
@@ -80,7 +80,7 @@ STATIC s32  e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw,
 STATIC void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-						 u16 *speed, u16 *duplex);
+						 u32 *speed, u16 *duplex);
 STATIC s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
 STATIC void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC bool e1000_sgmii_active_82575(struct e1000_hw *hw);
@@ -1167,7 +1167,7 @@ STATIC s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
  *  interface, use PCS to retrieve the link speed and duplex information.
  *  Otherwise, use the generic function to get the link speed and duplex info.
  **/
-STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
 					u16 *duplex)
 {
 	s32 ret_val;
@@ -1194,7 +1194,8 @@ STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
 STATIC s32 e1000_check_for_link_82575(struct e1000_hw *hw)
 {
 	s32 ret_val;
-	u16 speed, duplex;
+	u32 speed;
+	u16 duplex;
 
 	DEBUGFUNC("e1000_check_for_link_82575");
 
@@ -1325,7 +1326,7 @@ STATIC void e1000_power_up_serdes_link_82575(struct e1000_hw *hw)
  *  duplex, then store the values in the pointers provided.
  **/
 STATIC s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-						u16 *speed, u16 *duplex)
+						u32 *speed, u16 *duplex)
 {
 	struct e1000_mac_info *mac = &hw->mac;
 	u32 pcs;
drivers/net/e1000/base/e1000_api.c +1 -1
index bbfcae8..3a066d5 100644
@@ -673,7 +673,7 @@ s32 e1000_setup_link(struct e1000_hw *hw)
  *  variables passed in. This is a function pointer entry point called
  *  by drivers.
  **/
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16 *duplex)
 {
 	if (hw->mac.ops.get_link_up_info)
 		return hw->mac.ops.get_link_up_info(hw, speed, duplex);
drivers/net/e1000/base/e1000_api.h +1 -1
index 0bc471d..7327750 100644
@@ -65,7 +65,7 @@ s32 e1000_check_for_link(struct e1000_hw *hw);
 s32 e1000_reset_hw(struct e1000_hw *hw);
 s32 e1000_init_hw(struct e1000_hw *hw);
 s32 e1000_setup_link(struct e1000_hw *hw);
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex);
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16 *duplex);
 s32 e1000_disable_pcie_master(struct e1000_hw *hw);
 void e1000_config_collision_dist(struct e1000_hw *hw);
 int e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
drivers/net/e1000/base/e1000_defines.h +2 -2
index 69aa1f2..692845d 100644
@@ -348,8 +348,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_2500	2500
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
+#define HALF_DUPLEX	0
+#define FULL_DUPLEX	1
 
 #define PHY_FORCE_TIME	20
 
drivers/net/e1000/base/e1000_hw.h +1 -1
index e4e4f76..30e7f3b 100644
@@ -686,7 +686,7 @@ struct e1000_mac_operations {
 	void (*clear_vfta)(struct e1000_hw *);
 	s32  (*get_bus_info)(struct e1000_hw *);
 	void (*set_lan_id)(struct e1000_hw *);
-	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+	s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
 	s32  (*led_on)(struct e1000_hw *);
 	s32  (*led_off)(struct e1000_hw *);
 	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
drivers/net/e1000/base/e1000_ich8lan.c +4 -3
index 89d07e9..a6e01c7 100644
@@ -108,7 +108,7 @@ STATIC s32  e1000_setup_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
 STATIC s32  e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
-					   u16 *speed, u16 *duplex);
+					   u32 *speed, u16 *duplex);
 STATIC s32  e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_on_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_off_ich8lan(struct e1000_hw *hw);
@@ -1458,7 +1458,8 @@ STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
 	 */
 	if (((hw->mac.type == e1000_pch2lan) ||
 	     (hw->mac.type == e1000_pch_lpt)) && link) {
-		u16 speed, duplex;
+		u16 duplex;
+		u32 speed;
 
 		e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
 		tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
@@ -4623,7 +4624,7 @@ STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
  *  information and then calls the Kumeran lock loss workaround for links at
  *  gigabit speeds.
  **/
-STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u32 *speed,
 					  u16 *duplex)
 {
 	s32 ret_val;
drivers/net/e1000/base/e1000_mac.c +5 -4
index a0f3a99..c66421c 100644
@@ -106,7 +106,7 @@ void e1000_null_mac_generic(struct e1000_hw E1000_UNUSEDARG *hw)
  *  @hw: pointer to the HW structure
  **/
 s32 e1000_null_link_info(struct e1000_hw E1000_UNUSEDARG *hw,
-			 u16 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
+			 u32 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
 {
 	DEBUGFUNC("e1000_null_link_info");
 	UNREFERENCED_3PARAMETER(hw, s, d);
@@ -1348,7 +1348,8 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
 	s32 ret_val = E1000_SUCCESS;
 	u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;
 	u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
-	u16 speed, duplex;
+	u32 speed;
+	u16 duplex;
 
 	DEBUGFUNC("e1000_config_fc_after_link_up_generic");
 
@@ -1650,7 +1651,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
  *  Read the status register for the current speed/duplex and store the current
  *  speed and duplex for copper connections.
  **/
-s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,
 					      u16 *duplex)
 {
 	u32 status;
@@ -1690,7 +1691,7 @@ s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
  *  for fiber/serdes links.
  **/
 s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw E1000_UNUSEDARG *hw,
-						    u16 *speed, u16 *duplex)
+						    u32 *speed, u16 *duplex)
 {
 	DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
 	UNREFERENCED_1PARAMETER(hw);
drivers/net/e1000/base/e1000_mac.h +3 -3
index 96a260c..fef862f 100644
@@ -40,7 +40,7 @@ void e1000_init_mac_ops_generic(struct e1000_hw *hw);
 #endif /* E1000_REMOVED */
 void e1000_null_mac_generic(struct e1000_hw *hw);
 s32  e1000_null_ops_generic(struct e1000_hw *hw);
-s32  e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d);
+s32  e1000_null_link_info(struct e1000_hw *hw, u32 *s, u16 *d);
 bool e1000_null_mng_mode(struct e1000_hw *hw);
 void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a);
 void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b);
@@ -61,10 +61,10 @@ s32  e1000_get_bus_info_pcie_generic(struct e1000_hw *hw);
 void e1000_set_lan_id_single_port(struct e1000_hw *hw);
 void e1000_set_lan_id_multi_port_pci(struct e1000_hw *hw);
 s32  e1000_get_hw_semaphore_generic(struct e1000_hw *hw);
-s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,
 					       u16 *duplex);
 s32  e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
-						     u16 *speed, u16 *duplex);
+						     u32 *speed, u16 *duplex);
 s32  e1000_id_led_init_generic(struct e1000_hw *hw);
 s32  e1000_led_on_generic(struct e1000_hw *hw);
 s32  e1000_led_off_generic(struct e1000_hw *hw);
drivers/net/e1000/base/e1000_vf.c +2 -2
index 7845b48..c7fc80f 100644
@@ -43,7 +43,7 @@ STATIC s32 e1000_setup_link_vf(struct e1000_hw *hw);
 STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
 STATIC s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
 STATIC s32 e1000_check_for_link_vf(struct e1000_hw *hw);
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
 				     u16 *duplex);
 STATIC s32 e1000_init_hw_vf(struct e1000_hw *hw);
 STATIC s32 e1000_reset_hw_vf(struct e1000_hw *hw);
@@ -220,7 +220,7 @@ STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw)
  *  Since we cannot read the PHY and get accurate link info, we must rely upon
  *  the status register's data which is often stale and inaccurate.
  **/
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
 				     u16 *duplex)
 {
 	s32 status;
drivers/net/e1000/base/e1000_vf.h +1 -1
index d6216de..f7b5ea8 100644
@@ -201,7 +201,7 @@ struct e1000_mac_operations {
 	s32  (*check_for_link)(struct e1000_hw *);
 	void (*clear_vfta)(struct e1000_hw *);
 	s32  (*get_bus_info)(struct e1000_hw *);
-	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+	s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
 	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
 	s32  (*reset_hw)(struct e1000_hw *);
 	s32  (*init_hw)(struct e1000_hw *);
drivers/net/e1000/em_ethdev.c +54 -59

149 lines not on this page · raw message

drivers/net/e1000/igb_ethdev.c +57 -51

144 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +4 -4
index aeb2962..702eb97 100644
@@ -1172,7 +1172,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	 * is no 50Gbps Ethernet. */
 	dev->data->dev_link.link_speed  = 0;
 	dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
@@ -1334,9 +1334,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
 
-	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
-					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
-					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+				ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+				ETH_LINK_SPEED_40G | ETH_LINK_SPEED_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +37 -36

146 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev_vf.c +6 -5
index 14d2a50..f06f828 100644
@@ -1911,13 +1911,14 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	 * DPDK pf host provide interfacet to acquire link status
 	 * while Linux driver does not
 	 */
-	if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
 		i40evf_get_link_status(dev, &new_link);
-	else {
+	} else {
 		/* Always assume it's up, for Linux driver PF host */
-		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-		new_link.link_speed  = ETH_LINK_SPEED_10000;
-		new_link.link_status = 1;
+		new_link.link_speed  = ETH_SPEED_NUM_10G;
+		new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+		new_link.link_autoneg = ETH_LINK_SPEED_NEG;
+		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +34 -44

153 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +2 -0
index 1f3ed59..4dbc8a9 100644
@@ -4637,6 +4637,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)
 		dev_link.link_speed = link_speed;
 	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
+	dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
 		/* Link status changed. */
 		dev->data->dev_link = dev_link;
drivers/net/mpipe/mpipe_tilegx.c +4 -2
index 35134ba..f42c1d4 100644
@@ -388,14 +388,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 		speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+		new.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 		if (speed == GXIO_MPIPE_LINK_1G) {
 			new.link_speed = ETH_LINK_SPEED_1000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
 			new.link_speed = ETH_LINK_SPEED_10000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		}
 
 		rc = mpipe_link_compare(&old, &new);
drivers/net/null/rte_eth_null.c +3 -2
index 77fc988..55e1fc8 100644
@@ -93,9 +93,10 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG,
 };
 
 static uint16_t
drivers/net/pcap/rte_eth_pcap.c +5 -4
index f9230eb..650b521 100644
@@ -125,9 +125,10 @@ static int open_single_iface(const char *iface, pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED,
 };
 
 static int
@@ -430,7 +431,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -481,7 +482,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	}
 
 status_down:
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +3 -2
index d92b088..043175a 100644
@@ -71,9 +71,10 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/virtio/virtio_ethdev.c +1 -1
index d928339..83a2ffe 100644
@@ -1631,7 +1631,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_read_link_status(dev, &link);
 	old = link;
-	link.link_duplex = FULL_DUPLEX;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	link.link_speed  = SPEED_10G;
 
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index ae2d47d..8598815 100644
@@ -42,8 +42,6 @@
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_10G	10000
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -2
index c363bf6..2bb6ee9 100644
@@ -736,9 +736,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
 	if (ret & 0x1) {
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
+		link.link_autoneg = ETH_LINK_SPEED_FIXED;
 	}
 
 	vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -2
index 3f31806..0fcf5d3 100644
@@ -70,9 +70,10 @@ static int virtio_idx = 0;
 static const char *drivername = "xen virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED
 };
 
 static void
examples/ip_pipeline/config_parse.c +1 -2
index 1bedbe4..c581d41 100644
@@ -84,8 +84,7 @@ static const struct app_link_params link_params_default = {
 	.mac_addr = 0,
 
 	.conf = {
-		.link_speed = 0,
-		.link_duplex = 0,
+		.link_speeds = 0,
 		.rxmode = {
 			.mq_mode = ETH_MQ_RX_NONE,
 
lib/librte_ether/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ether/rte_ethdev.h +73 -40

141 lines not on this page · raw message

Signature · 1 line
2.1.4
author
#29 lore raw

PATCH v7 4/5 doc: update with link changes

In reply to Marc Sune

Add new features, ABI changes and resolved issues notice for the refactored link patch.

---
 doc/guides/rel_notes/release_2_3.rst | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
doc/guides/rel_notes/release_2_3.rst +26 -0
index 99de186..b10c3bb 100644
@@ -4,10 +4,28 @@ DPDK Release 2.3
 New Features
 ------------
 
+* **ethdev: define a set of advertised link speeds.**
+
+  Allowing to define a set of advertised speeds for auto-negociation,
+  explicitely disable link auto-negociation (single speed) and full
+  auto-negociation.
+
+* **ethdev: add speed_cap bitmap to recover eth device link speed capabilities
+  define a set of advertised link speeds.**
+
+  ``struct rte_eth_dev_info`` has now speed_cap bitmap, which allows the
+  application to recover the supported speeds for that ethernet device.
+
 
 Resolved Issues
 ---------------
 
+* **ethdev: Fixed link_speed overflow in rte_eth_link for 100Gbps.**
+
+  100Gbps in Mbps (100000) exceeds 16 bit max value of ``link_speed`` in
+  ``rte_eth_link``.
+
+
 EAL
 ~~~
 
@@ -23,6 +41,9 @@ Libraries
 Examples
 ~~~~~~~~
 
+* New API call, rte_eth_speed_to_bm_flag(), in ethdev to map numerical speeds
+  to bitmap fields.
+
 
 Other
 ~~~~~
@@ -39,6 +60,11 @@ API Changes
 ABI Changes
 -----------
 
+* The ethdev rte_eth_link and rte_eth_conf structures were changed to
+  support the new link API, as well as ETH_LINK_HALF/FULL_DUPLEX.
+
+* The ethdev rte_eth_dev_info was changed to support device speed capabilities.
+
 
 Shared Library Versions
 -----------------------
Signature · 1 line
2.1.4
author
#30 lore raw

PATCH v7 5/5 ethdev: add rte_eth_speed_to_bm_flag() to ver. map

In reply to Marc Sune

Added rte_eth_speed_to_bm_flag() to DPDK2.2 version map.

---
 lib/librte_ether/rte_ether_version.map | 6 ++++++
 1 file changed, 6 insertions(+)
lib/librte_ether/rte_ether_version.map +6 -0
index d8db24d..2c14ad7 100644
@@ -117,3 +117,9 @@ DPDK_2.2 {
 
 	local: *;
 };
+
+DPDK_2.3 {
+	global:
+
+	rte_eth_speed_to_bm_flag;
+}DPDK_2.2;
Signature · 1 line
2.1.4
#18 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

In reply to Marc Sune

Hi Marc,

Quoted 16 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marc Sune
Sent: Friday, January 29, 2016 12:42 AM
To: [email protected]; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D
Subject: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

Quoted 9 lines

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick it up from them. Thanks
Konstantin

Quoted 1,693 lines
---
 app/test-pmd/cmdline.c                     | 124 +++++++++++++++--------------
 app/test/virtual_pmd.c                     |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c  |   5 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c  |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c             |   8 +-
 drivers/net/e1000/base/e1000_80003es2lan.c |   6 +-
 drivers/net/e1000/base/e1000_82541.c       |   8 +-
 drivers/net/e1000/base/e1000_82543.c       |   4 +-
 drivers/net/e1000/base/e1000_82575.c       |  11 +--
 drivers/net/e1000/base/e1000_api.c         |   2 +-
 drivers/net/e1000/base/e1000_api.h         |   2 +-
 drivers/net/e1000/base/e1000_defines.h     |   4 +-
 drivers/net/e1000/base/e1000_hw.h          |   2 +-
 drivers/net/e1000/base/e1000_ich8lan.c     |   7 +-
 drivers/net/e1000/base/e1000_mac.c         |   9 ++-
 drivers/net/e1000/base/e1000_mac.h         |   6 +-
 drivers/net/e1000/base/e1000_vf.c          |   4 +-
 drivers/net/e1000/base/e1000_vf.h          |   2 +-
 drivers/net/e1000/em_ethdev.c              | 113 +++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c             | 108 +++++++++++++------------
 drivers/net/fm10k/fm10k_ethdev.c           |   8 +-
 drivers/net/i40e/i40e_ethdev.c             |  73 ++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c          |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c           |  78 ++++++++----------
 drivers/net/mlx4/mlx4.c                    |   2 +
 drivers/net/mpipe/mpipe_tilegx.c           |   6 +-
 drivers/net/null/rte_eth_null.c            |   5 +-
 drivers/net/pcap/rte_eth_pcap.c            |   9 ++-
 drivers/net/ring/rte_eth_ring.c            |   5 +-
 drivers/net/virtio/virtio_ethdev.c         |   2 +-
 drivers/net/virtio/virtio_ethdev.h         |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c       |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c      |   5 +-
 examples/ip_pipeline/config_parse.c        |   3 +-
 lib/librte_ether/rte_ethdev.c              |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h              | 113 ++++++++++++++++----------
 36 files changed, 454 insertions(+), 365 deletions(-)
app/test-pmd/cmdline.c +64 -60
index 6d28c1b..00571bc 100644
@@ -956,14 +956,65 @@ struct cmd_config_speed_all {
 	cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *value1, char *value2, uint32_t *link_speed)
+{
+
+	int duplex;
+
+	if (!strcmp(value2, "half")) {
+		duplex = 0;
+	} else if (!strcmp(value2, "full")) {
+		duplex = 1;
+	} else if (!strcmp(value2, "auto")) {
+		duplex = 1;
+	} else {
+		printf("Unknown parameter\n");
+		return -1;
+	}
+
+	if (!strcmp(value1, "10")) {
+		*link_speed = (duplex) ? ETH_LINK_SPEED_10M :
+							ETH_LINK_SPEED_10M_HD;
+	} else if (!strcmp(value1, "100")) {
+		*link_speed = (duplex) ? ETH_LINK_SPEED_100M :
+							ETH_LINK_SPEED_100M_HD;
+	} else if (!strcmp(value1, "1000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_1G;
+	} else if (!strcmp(value1, "10000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_10G;
+	} else if (!strcmp(value1, "40000")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_40G;
+	} else if (!strcmp(value1, "auto")) {
+		if (!duplex)
+			goto invalid_speed_param;
+		*link_speed = ETH_LINK_SPEED_AUTONEG;
+	} else {
+		printf("Unknown parameter\n");
+		return -1;
+	}
+
+	return 0;
+
+invalid_speed_param:
+
+	printf("Invalid speed parameter\n");
+	return -1;
+}
+
 static void
 cmd_config_speed_all_parsed(void *parsed_result,
 			__attribute__((unused)) struct cmdline *cl,
 			__attribute__((unused)) void *data)
 {
 	struct cmd_config_speed_all *res = parsed_result;
-	uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-	uint16_t link_duplex = 0;
+	uint32_t link_speed;
 	portid_t pid;
 
 	if (!all_ports_stopped()) {
@@ -971,40 +1022,18 @@ cmd_config_speed_all_parsed(void *parsed_result,
 		return;
 	}
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10G;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1,
+						res->value2,
+						&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
 	FOREACH_PORT(pid, ports) {
-		ports[pid].dev_conf.link_speed = link_speed;
-		ports[pid].dev_conf.link_duplex = link_duplex;
+		ports[pid].dev_conf.link_speeds = link_speed;
 	}
 
 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+
+	return;
 }
 
 cmdline_parse_token_string_t cmd_config_speed_all_port =
@@ -1059,8 +1088,7 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 				__attribute__((unused)) void *data)
 {
 	struct cmd_config_speed_specific *res = parsed_result;
-	uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-	uint16_t link_duplex = 0;
+	uint32_t link_speed;
 
 	if (!all_ports_stopped()) {
 		printf("Please stop all ports first\n");
@@ -1070,36 +1098,12 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 	if (port_id_is_invalid(res->id, ENABLED_WARN))
 		return;
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10000;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1,
+						res->value2,
+						&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
-	ports[res->id].dev_conf.link_speed = link_speed;
-	ports[res->id].dev_conf.link_duplex = link_duplex;
+	ports[res->id].dev_conf.link_speeds = link_speed;
 
 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
 }
app/test/virtual_pmd.c +2 -2
index a538c8a..3c4040b 100644
@@ -603,8 +603,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
-	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
index 767f36b..5db1db2 100644
@@ -116,9 +116,10 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/bonding/rte_eth_bond_8023ad.c +7 -7
index b3b30f6..3b446e1 100644
@@ -708,25 +708,25 @@ link_speed_key(uint16_t speed) {
 	uint16_t key_speed;
 
 	switch (speed) {
-	case ETH_LINK_SPEED_AUTONEG:
+	case ETH_SPEED_NUM_NONE:
 		key_speed = 0x00;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		key_speed = BOND_LINK_SPEED_KEY_10M;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		key_speed = BOND_LINK_SPEED_KEY_100M;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		key_speed = BOND_LINK_SPEED_KEY_1000M;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		key_speed = BOND_LINK_SPEED_KEY_10G;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		key_speed = BOND_LINK_SPEED_KEY_20G;
 		break;
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		key_speed = BOND_LINK_SPEED_KEY_40G;
 		break;
 	default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		if (stat & F_FW_PORT_CMD_TXPAUSE)
 			fc |= PAUSE_TX;
 		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-			speed = ETH_LINK_SPEED_100;
+			speed = ETH_SPEED_NUM_100M;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-			speed = ETH_LINK_SPEED_1000;
+			speed = ETH_SPEED_NUM_1G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-			speed = ETH_LINK_SPEED_10000;
+			speed = ETH_SPEED_NUM_10G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-			speed = ETH_LINK_SPEED_40G;
+			speed = ETH_SPEED_NUM_40G;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
drivers/net/e1000/base/e1000_80003es2lan.c +3 -3
index 5ac925e..ae11cac 100644
@@ -52,7 +52,7 @@ STATIC s32  e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
 STATIC s32  e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_get_cable_length_80003es2lan(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32 *speed,
 					       u16 *duplex);
 STATIC s32  e1000_reset_hw_80003es2lan(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_80003es2lan(struct e1000_hw *hw);
@@ -789,7 +789,7 @@ STATIC s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
  *
  *  Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u32 *speed,
 					      u16 *duplex)
 {
 	s32 ret_val;
@@ -1247,7 +1247,7 @@ STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
 {
 	s32 ret_val = E1000_SUCCESS;
-	u16 speed;
+	u32 speed;
 	u16 duplex;
 
 	DEBUGFUNC("e1000_configure_on_link_up");
drivers/net/e1000/base/e1000_82541.c +4 -4
index 9cdb91c..73f9234 100644
@@ -47,7 +47,7 @@ STATIC s32  e1000_init_nvm_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_mac_params_82541(struct e1000_hw *hw);
 STATIC s32  e1000_reset_hw_82541(struct e1000_hw *hw);
 STATIC s32  e1000_init_hw_82541(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
 					 u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_82541(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_82541(struct e1000_hw *hw);
@@ -437,7 +437,7 @@ out:
  *
  * Retrieve the current speed and duplex configuration.
  **/
-STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u32 *speed,
 					u16 *duplex)
 {
 	struct e1000_phy_info *phy = &hw->phy;
@@ -667,8 +667,8 @@ STATIC s32 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
 	struct e1000_phy_info *phy = &hw->phy;
 	struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
 	s32 ret_val;
-	u32 idle_errs = 0;
-	u16 phy_data, phy_saved_data, speed, duplex, i;
+	u32 idle_errs = 0, speed;
+	u16 phy_data, phy_saved_data, duplex, i;
 	u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
 	u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
 						IGP01E1000_PHY_AGC_PARAM_A,
drivers/net/e1000/base/e1000_82543.c +2 -2
index fc96199..4402f63 100644
@@ -1192,9 +1192,9 @@ out:
 STATIC s32 e1000_check_for_copper_link_82543(struct e1000_hw *hw)
 {
 	struct e1000_mac_info *mac = &hw->mac;
-	u32 icr, rctl;
+	u32 icr, rctl, speed;
 	s32 ret_val;
-	u16 speed, duplex;
+	u16 duplex;
 	bool link;
 
 	DEBUGFUNC("e1000_check_for_copper_link_82543");
drivers/net/e1000/base/e1000_82575.c +6 -5
index 723885d..f8d61e4 100644
@@ -53,7 +53,7 @@ STATIC void e1000_release_nvm_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_82575(struct e1000_hw *hw);
 STATIC s32  e1000_check_for_link_media_swap(struct e1000_hw *hw);
 STATIC s32  e1000_get_cfg_done_82575(struct e1000_hw *hw);
-STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32  e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
 					 u16 *duplex);
 STATIC s32  e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
 STATIC s32  e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
@@ -80,7 +80,7 @@ STATIC s32  e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw,
 STATIC void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
 STATIC s32  e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC s32  e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-						 u16 *speed, u16 *duplex);
+						 u32 *speed, u16 *duplex);
 STATIC s32  e1000_get_phy_id_82575(struct e1000_hw *hw);
 STATIC void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
 STATIC bool e1000_sgmii_active_82575(struct e1000_hw *hw);
@@ -1167,7 +1167,7 @@ STATIC s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
  *  interface, use PCS to retrieve the link speed and duplex information.
  *  Otherwise, use the generic function to get the link speed and duplex info.
  **/
-STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u32 *speed,
 					u16 *duplex)
 {
 	s32 ret_val;
@@ -1194,7 +1194,8 @@ STATIC s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
 STATIC s32 e1000_check_for_link_82575(struct e1000_hw *hw)
 {
 	s32 ret_val;
-	u16 speed, duplex;
+	u32 speed;
+	u16 duplex;
 
 	DEBUGFUNC("e1000_check_for_link_82575");
 
@@ -1325,7 +1326,7 @@ STATIC void e1000_power_up_serdes_link_82575(struct e1000_hw *hw)
  *  duplex, then store the values in the pointers provided.
  **/
 STATIC s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
-						u16 *speed, u16 *duplex)
+						u32 *speed, u16 *duplex)
 {
 	struct e1000_mac_info *mac = &hw->mac;
 	u32 pcs;
drivers/net/e1000/base/e1000_api.c +1 -1
index bbfcae8..3a066d5 100644
@@ -673,7 +673,7 @@ s32 e1000_setup_link(struct e1000_hw *hw)
  *  variables passed in. This is a function pointer entry point called
  *  by drivers.
  **/
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16 *duplex)
 {
 	if (hw->mac.ops.get_link_up_info)
 		return hw->mac.ops.get_link_up_info(hw, speed, duplex);
drivers/net/e1000/base/e1000_api.h +1 -1
index 0bc471d..7327750 100644
@@ -65,7 +65,7 @@ s32 e1000_check_for_link(struct e1000_hw *hw);
 s32 e1000_reset_hw(struct e1000_hw *hw);
 s32 e1000_init_hw(struct e1000_hw *hw);
 s32 e1000_setup_link(struct e1000_hw *hw);
-s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex);
+s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u32 *speed, u16 *duplex);
 s32 e1000_disable_pcie_master(struct e1000_hw *hw);
 void e1000_config_collision_dist(struct e1000_hw *hw);
 int e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
drivers/net/e1000/base/e1000_defines.h +2 -2
index 69aa1f2..692845d 100644
@@ -348,8 +348,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_2500	2500
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
+#define HALF_DUPLEX	0
+#define FULL_DUPLEX	1
 
 #define PHY_FORCE_TIME	20
 
drivers/net/e1000/base/e1000_hw.h +1 -1
index e4e4f76..30e7f3b 100644
@@ -686,7 +686,7 @@ struct e1000_mac_operations {
 	void (*clear_vfta)(struct e1000_hw *);
 	s32  (*get_bus_info)(struct e1000_hw *);
 	void (*set_lan_id)(struct e1000_hw *);
-	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+	s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
 	s32  (*led_on)(struct e1000_hw *);
 	s32  (*led_off)(struct e1000_hw *);
 	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
drivers/net/e1000/base/e1000_ich8lan.c +4 -3
index 89d07e9..a6e01c7 100644
@@ -108,7 +108,7 @@ STATIC s32  e1000_setup_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
 STATIC s32  e1000_get_link_up_info_ich8lan(struct e1000_hw *hw,
-					   u16 *speed, u16 *duplex);
+					   u32 *speed, u16 *duplex);
 STATIC s32  e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_on_ich8lan(struct e1000_hw *hw);
 STATIC s32  e1000_led_off_ich8lan(struct e1000_hw *hw);
@@ -1458,7 +1458,8 @@ STATIC s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
 	 */
 	if (((hw->mac.type == e1000_pch2lan) ||
 	     (hw->mac.type == e1000_pch_lpt)) && link) {
-		u16 speed, duplex;
+		u16 duplex;
+		u32 speed;
 
 		e1000_get_speed_and_duplex_copper_generic(hw, &speed, &duplex);
 		tipg_reg = E1000_READ_REG(hw, E1000_TIPG);
@@ -4623,7 +4624,7 @@ STATIC s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
  *  information and then calls the Kumeran lock loss workaround for links at
  *  gigabit speeds.
  **/
-STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u32 *speed,
 					  u16 *duplex)
 {
 	s32 ret_val;
drivers/net/e1000/base/e1000_mac.c +5 -4
index a0f3a99..c66421c 100644
@@ -106,7 +106,7 @@ void e1000_null_mac_generic(struct e1000_hw E1000_UNUSEDARG *hw)
  *  @hw: pointer to the HW structure
  **/
 s32 e1000_null_link_info(struct e1000_hw E1000_UNUSEDARG *hw,
-			 u16 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
+			 u32 E1000_UNUSEDARG *s, u16 E1000_UNUSEDARG *d)
 {
 	DEBUGFUNC("e1000_null_link_info");
 	UNREFERENCED_3PARAMETER(hw, s, d);
@@ -1348,7 +1348,8 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
 	s32 ret_val = E1000_SUCCESS;
 	u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;
 	u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
-	u16 speed, duplex;
+	u32 speed;
+	u16 duplex;
 
 	DEBUGFUNC("e1000_config_fc_after_link_up_generic");
 
@@ -1650,7 +1651,7 @@ s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw)
  *  Read the status register for the current speed/duplex and store the current
  *  speed and duplex for copper connections.
  **/
-s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,
 					      u16 *duplex)
 {
 	u32 status;
@@ -1690,7 +1691,7 @@ s32 e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
  *  for fiber/serdes links.
  **/
 s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw E1000_UNUSEDARG *hw,
-						    u16 *speed, u16 *duplex)
+						    u32 *speed, u16 *duplex)
 {
 	DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic");
 	UNREFERENCED_1PARAMETER(hw);
drivers/net/e1000/base/e1000_mac.h +3 -3
index 96a260c..fef862f 100644
@@ -40,7 +40,7 @@ void e1000_init_mac_ops_generic(struct e1000_hw *hw);
 #endif /* E1000_REMOVED */
 void e1000_null_mac_generic(struct e1000_hw *hw);
 s32  e1000_null_ops_generic(struct e1000_hw *hw);
-s32  e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d);
+s32  e1000_null_link_info(struct e1000_hw *hw, u32 *s, u16 *d);
 bool e1000_null_mng_mode(struct e1000_hw *hw);
 void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a);
 void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b);
@@ -61,10 +61,10 @@ s32  e1000_get_bus_info_pcie_generic(struct e1000_hw *hw);
 void e1000_set_lan_id_single_port(struct e1000_hw *hw);
 void e1000_set_lan_id_multi_port_pci(struct e1000_hw *hw);
 s32  e1000_get_hw_semaphore_generic(struct e1000_hw *hw);
-s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
+s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u32 *speed,
 					       u16 *duplex);
 s32  e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
-						     u16 *speed, u16 *duplex);
+						     u32 *speed, u16 *duplex);
 s32  e1000_id_led_init_generic(struct e1000_hw *hw);
 s32  e1000_led_on_generic(struct e1000_hw *hw);
 s32  e1000_led_off_generic(struct e1000_hw *hw);
drivers/net/e1000/base/e1000_vf.c +2 -2
index 7845b48..c7fc80f 100644
@@ -43,7 +43,7 @@ STATIC s32 e1000_setup_link_vf(struct e1000_hw *hw);
 STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
 STATIC s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
 STATIC s32 e1000_check_for_link_vf(struct e1000_hw *hw);
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
 				     u16 *duplex);
 STATIC s32 e1000_init_hw_vf(struct e1000_hw *hw);
 STATIC s32 e1000_reset_hw_vf(struct e1000_hw *hw);
@@ -220,7 +220,7 @@ STATIC s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw)
  *  Since we cannot read the PHY and get accurate link info, we must rely upon
  *  the status register's data which is often stale and inaccurate.
  **/
-STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
+STATIC s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u32 *speed,
 				     u16 *duplex)
 {
 	s32 status;
drivers/net/e1000/base/e1000_vf.h +1 -1
index d6216de..f7b5ea8 100644
@@ -201,7 +201,7 @@ struct e1000_mac_operations {
 	s32  (*check_for_link)(struct e1000_hw *);
 	void (*clear_vfta)(struct e1000_hw *);
 	s32  (*get_bus_info)(struct e1000_hw *);
-	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
+	s32  (*get_link_up_info)(struct e1000_hw *, u32 *, u16 *);
 	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
 	s32  (*reset_hw)(struct e1000_hw *);
 	s32  (*init_hw)(struct e1000_hw *);
drivers/net/e1000/em_ethdev.c +54 -59
index fd48bbf..a041710 100644
@@ -509,6 +509,9 @@ eth_em_start(struct rte_eth_dev *dev)
 	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
 	int ret, mask;
 	uint32_t intr_vector = 0;
+	uint32_t *speeds;
+	int num_speeds;
+	bool autoneg;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -583,56 +586,46 @@ eth_em_start(struct rte_eth_dev *dev)
 	E1000_WRITE_REG(hw, E1000_ITR, UINT16_MAX);
 
 	/* Setup link speed and duplex */
-	switch (dev->data->dev_conf.link_speed) {
-	case ETH_LINK_SPEED_AUTONEG:
-		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
-		else if (dev->data->dev_conf.link_duplex ==
-					ETH_LINK_HALF_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
-		else if (dev->data->dev_conf.link_duplex ==
-					ETH_LINK_FULL_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
-		else
-			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_10:
-		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
-		else if (dev->data->dev_conf.link_duplex ==
-					ETH_LINK_HALF_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
-		else if (dev->data->dev_conf.link_duplex ==
-					ETH_LINK_FULL_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
-		else
-			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_100:
-		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
-		else if (dev->data->dev_conf.link_duplex ==
-					ETH_LINK_HALF_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
-		else if (dev->data->dev_conf.link_duplex ==
-					ETH_LINK_FULL_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
-		else
+	speeds = &dev->data->dev_conf.link_speeds;
+	if (*speeds == ETH_LINK_SPEED_AUTONEG) {
+		hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
+	} else {
+		num_speeds = 0;
+		autoneg = ~(*speeds & ETH_LINK_SPEED_NO_AUTONEG);
+
+		/* Reset */
+		hw->phy.autoneg_advertised = 0;
+
+		if (*speeds & ~(ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M |
+				ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M |
+				ETH_LINK_SPEED_1G)) {
+			num_speeds = -1;
 			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_1000:
-		if ((dev->data->dev_conf.link_duplex ==
-				ETH_LINK_AUTONEG_DUPLEX) ||
-			(dev->data->dev_conf.link_duplex ==
-					ETH_LINK_FULL_DUPLEX))
-			hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
-		else
+		}
+		if (*speeds & ETH_LINK_SPEED_10M_HD) {
+			hw->phy.autoneg_advertised |= ADVERTISE_10_HALF;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_10M) {
+			hw->phy.autoneg_advertised |= ADVERTISE_10_FULL;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_100M_HD) {
+			hw->phy.autoneg_advertised |= ADVERTISE_100_HALF;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_100M) {
+			hw->phy.autoneg_advertised |= ADVERTISE_100_FULL;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_1G) {
+			hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
+			num_speeds++;
+		}
+		if (num_speeds == 0 || (!autoneg && (num_speeds > 2)))
 			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_10000:
-	default:
-		goto error_invalid_config;
 	}
+
 	e1000_setup_link(hw);
 
 	if (rte_intr_allow_others(intr_handle)) {
@@ -665,9 +658,8 @@ eth_em_start(struct rte_eth_dev *dev)
 	return (0);
 
 error_invalid_config:
-	PMD_INIT_LOG(ERR, "Invalid link_speed/link_duplex (%u/%u) for port %u",
-		     dev->data->dev_conf.link_speed,
-		     dev->data->dev_conf.link_duplex, dev->data->port_id);
+	PMD_INIT_LOG(ERR, "Invalid advertised speeds (%u) for port %u",
+		     dev->data->dev_conf.link_speeds, dev->data->port_id);
 	em_dev_clear_queues(dev);
 	return (-EINVAL);
 }
@@ -1024,11 +1016,11 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_align = EM_TXD_ALIGN,
 	};
 
-	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
-					ETH_SPEED_CAP_10M_FD |
-					ETH_SPEED_CAP_100M_HD |
-					ETH_SPEED_CAP_100M_FD |
-					ETH_SPEED_CAP_1G;
+	dev_info->speed_capa = ETH_LINK_SPEED_10M_HD |
+					ETH_LINK_SPEED_10M |
+					ETH_LINK_SPEED_100M_HD |
+					ETH_LINK_SPEED_100M |
+					ETH_LINK_SPEED_1G;
 }
 
 /* return 0 means link status changed, -1 means not changed */
@@ -1077,13 +1069,16 @@ eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 	/* Now we check if a transition has happened */
 	if (link_check && (link.link_status == 0)) {
+		uint16_t duplex;
 		hw->mac.ops.get_link_up_info(hw, &link.link_speed,
-			&link.link_duplex);
-		link.link_status = 1;
+			&duplex);
+		link.link_duplex = (duplex) ? ETH_LINK_FULL_DUPLEX :
+						ETH_LINK_HALF_DUPLEX;
+		link.link_status = ETH_LINK_UP;
 	} else if (!link_check && (link.link_status == 1)) {
 		link.link_speed = 0;
-		link.link_duplex = 0;
-		link.link_status = 0;
+		link.link_duplex = ETH_LINK_HALF_DUPLEX;
+		link.link_status = ETH_LINK_DOWN;
 	}
 	rte_em_dev_atomic_write_link_status(dev, &link);
 
drivers/net/e1000/igb_ethdev.c +57 -51
index 9c8dffa..c1c41b3 100644
@@ -1119,6 +1119,9 @@ eth_igb_start(struct rte_eth_dev *dev)
 	int ret, mask;
 	uint32_t intr_vector = 0;
 	uint32_t ctrl_ext;
+	uint32_t *speeds;
+	int num_speeds;
+	bool autoneg;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1219,48 +1222,46 @@ eth_igb_start(struct rte_eth_dev *dev)
 	}
 
 	/* Setup link speed and duplex */
-	switch (dev->data->dev_conf.link_speed) {
-	case ETH_LINK_SPEED_AUTONEG:
-		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
-		else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
-		else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
-		else
-			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_10:
-		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
-		else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
-		else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
-		else
-			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_100:
-		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
-			hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
-		else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
-		else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
-			hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
-		else
+	speeds = &dev->data->dev_conf.link_speeds;
+	if (*speeds == ETH_LINK_SPEED_AUTONEG) {
+		hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
+	} else {
+		num_speeds = 0;
+		autoneg = ~(*speeds & ETH_LINK_SPEED_NO_AUTONEG);
+
+		/* Reset */
+		hw->phy.autoneg_advertised = 0;
+
+		if (*speeds & ~(ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M |
+				ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M |
+				ETH_LINK_SPEED_1G)) {
+			num_speeds = -1;
 			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_1000:
-		if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) ||
-				(dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX))
-			hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
-		else
+		}
+		if (*speeds & ETH_LINK_SPEED_10M_HD) {
+			hw->phy.autoneg_advertised |= ADVERTISE_10_HALF;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_10M) {
+			hw->phy.autoneg_advertised |= ADVERTISE_10_FULL;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_100M_HD) {
+			hw->phy.autoneg_advertised |= ADVERTISE_100_HALF;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_100M) {
+			hw->phy.autoneg_advertised |= ADVERTISE_100_FULL;
+			num_speeds++;
+		}
+		if (*speeds & ETH_LINK_SPEED_1G) {
+			hw->phy.autoneg_advertised |= ADVERTISE_1000_FULL;
+			num_speeds++;
+		}
+		if (num_speeds == 0 || (!autoneg && (num_speeds > 2)))
 			goto error_invalid_config;
-		break;
-	case ETH_LINK_SPEED_10000:
-	default:
-		goto error_invalid_config;
 	}
+
 	e1000_setup_link(hw);
 
 	if (rte_intr_allow_others(intr_handle)) {
@@ -1292,9 +1293,8 @@ eth_igb_start(struct rte_eth_dev *dev)
 	return (0);
 
 error_invalid_config:
-	PMD_INIT_LOG(ERR, "Invalid link_speed/link_duplex (%u/%u) for port %u",
-		     dev->data->dev_conf.link_speed,
-		     dev->data->dev_conf.link_duplex, dev->data->port_id);
+	PMD_INIT_LOG(ERR, "Invalid advertised speeds (%u) for port %u",
+		     dev->data->dev_conf.link_speeds, dev->data->port_id);
 	igb_dev_clear_queues(dev);
 	return (-EINVAL);
 }
@@ -1909,11 +1909,11 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
 
-	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
-					ETH_SPEED_CAP_10M_FD |
-					ETH_SPEED_CAP_100M_HD |
-					ETH_SPEED_CAP_100M_FD |
-					ETH_SPEED_CAP_1G;
+	dev_info->speed_capa = ETH_LINK_SPEED_10M_HD |
+					ETH_LINK_SPEED_10M |
+					ETH_LINK_SPEED_100M_HD |
+					ETH_LINK_SPEED_100M |
+					ETH_LINK_SPEED_1G;
 }
 
 static void
@@ -2023,13 +2023,19 @@ eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 	/* Now we check if a transition has happened */
 	if (link_check) {
+		uint16_t duplex;
 		hw->mac.ops.get_link_up_info(hw, &link.link_speed,
-					  &link.link_duplex);
-		link.link_status = 1;
+					  &duplex);
+		link.link_duplex = (duplex) ? ETH_LINK_FULL_DUPLEX :
+							ETH_LINK_HALF_DUPLEX ;
+		link.link_status = ETH_LINK_UP;
+		link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	} else if (!link_check) {
 		link.link_speed = 0;
-		link.link_duplex = 0;
-		link.link_status = 0;
+		link.link_duplex = ETH_LINK_HALF_DUPLEX;
+		link.link_status = ETH_LINK_DOWN;
+		link.link_autoneg = ETH_LINK_SPEED_FIXED;
 	}
 	rte_igb_dev_atomic_write_link_status(dev, &link);
 
drivers/net/fm10k/fm10k_ethdev.c +4 -4
index aeb2962..702eb97 100644
@@ -1172,7 +1172,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	 * is no 50Gbps Ethernet. */
 	dev->data->dev_link.link_speed  = 0;
 	dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
@@ -1334,9 +1334,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
 
-	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
-					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
-					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+				ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+				ETH_LINK_SPEED_40G | ETH_LINK_SPEED_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +37 -36
index d242973..34bc2c9 100644
@@ -1326,27 +1326,20 @@ i40e_vsi_disable_queues_intr(struct i40e_vsi *vsi)
 }
 
 static inline uint8_t
-i40e_parse_link_speed(uint16_t eth_link_speed)
+i40e_parse_link_speeds(uint16_t link_speeds)
 {
 	uint8_t link_speed = I40E_LINK_SPEED_UNKNOWN;
 
-	switch (eth_link_speed) {
-	case ETH_LINK_SPEED_40G:
-		link_speed = I40E_LINK_SPEED_40GB;
-		break;
-	case ETH_LINK_SPEED_20G:
-		link_speed = I40E_LINK_SPEED_20GB;
-		break;
-	case ETH_LINK_SPEED_10G:
-		link_speed = I40E_LINK_SPEED_10GB;
-		break;
-	case ETH_LINK_SPEED_1000:
-		link_speed = I40E_LINK_SPEED_1GB;
-		break;
-	case ETH_LINK_SPEED_100:
-		link_speed = I40E_LINK_SPEED_100MB;
-		break;
-	}
+	if (link_speeds & ETH_LINK_SPEED_40G)
+		link_speed |= I40E_LINK_SPEED_40GB;
+	if (link_speeds & ETH_LINK_SPEED_20G)
+		link_speed |= I40E_LINK_SPEED_20GB;
+	if (link_speeds & ETH_LINK_SPEED_10G)
+		link_speed |= I40E_LINK_SPEED_10GB;
+	if (link_speeds & ETH_LINK_SPEED_1G)
+		link_speed |= I40E_LINK_SPEED_1GB;
+	if (link_speeds & ETH_LINK_SPEED_100M)
+		link_speed |= I40E_LINK_SPEED_100MB;
 
 	return link_speed;
 }
@@ -1372,9 +1365,9 @@ i40e_apply_link_speed(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 
-	speed = i40e_parse_link_speed(conf->link_speed);
+	speed = i40e_parse_link_speeds(conf->link_speeds);
 	abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK;
-	if (conf->link_speed == ETH_LINK_SPEED_AUTONEG)
+	if (conf->link_speeds & ETH_LINK_SPEED_AUTONEG)
 		abilities |= I40E_AQ_PHY_AN_ENABLED;
 	else
 		abilities |= I40E_AQ_PHY_LINK_ENABLED;
@@ -1394,10 +1387,8 @@ i40e_dev_start(struct rte_eth_dev *dev)
 
 	hw->adapter_stopped = 0;
 
-	if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
-		(dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX)) {
-		PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
-			     dev->data->dev_conf.link_duplex,
+	if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_NO_AUTONEG) {
+		PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; autonegociation disabled",
 			     dev->data->port_id);
 		return -EINVAL;
 	}
@@ -1470,6 +1461,13 @@ i40e_dev_start(struct rte_eth_dev *dev)
 	}
 
 	/* Apply link configure */
+	if (dev->data->dev_conf.link_speeds & ~(ETH_LINK_SPEED_100M |
+				ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
+				ETH_LINK_SPEED_20G | ETH_LINK_SPEED_40G)) {
+		PMD_DRV_LOG(ERR, "Invalid link setting");
+		goto err_up;
+	}
+
 	ret = i40e_apply_link_speed(dev);
 	if (I40E_SUCCESS != ret) {
 		PMD_DRV_LOG(ERR, "Fail to apply link setting");
@@ -1713,7 +1711,7 @@ i40e_dev_link_update(struct rte_eth_dev *dev,
 		/* Get link status information from hardware */
 		status = i40e_aq_get_link_info(hw, false, &link_status, NULL);
 		if (status != I40E_SUCCESS) {
-			link.link_speed = ETH_LINK_SPEED_100;
+			link.link_speed = ETH_SPEED_NUM_100M;
 			link.link_duplex = ETH_LINK_FULL_DUPLEX;
 			PMD_DRV_LOG(ERR, "Failed to get link info");
 			goto out;
@@ -1735,25 +1733,28 @@ i40e_dev_link_update(struct rte_eth_dev *dev,
 	/* Parse the link status */
 	switch (link_status.link_speed) {
 	case I40E_LINK_SPEED_100MB:
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 	case I40E_LINK_SPEED_1GB:
-		link.link_speed = ETH_LINK_SPEED_1000;
+		link.link_speed = ETH_SPEED_NUM_1G;
 		break;
 	case I40E_LINK_SPEED_10GB:
-		link.link_speed = ETH_LINK_SPEED_10G;
+		link.link_speed = ETH_SPEED_NUM_10G;
 		break;
 	case I40E_LINK_SPEED_20GB:
-		link.link_speed = ETH_LINK_SPEED_20G;
+		link.link_speed = ETH_SPEED_NUM_20G;
 		break;
 	case I40E_LINK_SPEED_40GB:
-		link.link_speed = ETH_LINK_SPEED_40G;
+		link.link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 	}
 
+	link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
+
 out:
 	rte_i40e_dev_atomic_write_link_status(dev, &link);
 	if (link.link_status == old.link_status)
@@ -2308,10 +2309,10 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	if (i40e_is_40G_device(hw->device_id))
 		/* For XL710 */
-		dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+		dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
 	else
 		/* For X710 */
-		dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+		dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G;
 
 }
 
@@ -7835,15 +7836,15 @@ i40e_start_timecounters(struct rte_eth_dev *dev)
 	rte_i40e_dev_atomic_read_link_status(dev, &link);
 
 	switch (link.link_speed) {
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		tsync_inc_l = I40E_PTP_40GB_INCVAL & 0xFFFFFFFF;
 		tsync_inc_h = I40E_PTP_40GB_INCVAL >> 32;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		tsync_inc_l = I40E_PTP_10GB_INCVAL & 0xFFFFFFFF;
 		tsync_inc_h = I40E_PTP_10GB_INCVAL >> 32;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		tsync_inc_l = I40E_PTP_1GB_INCVAL & 0xFFFFFFFF;
 		tsync_inc_h = I40E_PTP_1GB_INCVAL >> 32;
 		break;
drivers/net/i40e/i40e_ethdev_vf.c +6 -5
index 14d2a50..f06f828 100644
@@ -1911,13 +1911,14 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	 * DPDK pf host provide interfacet to acquire link status
 	 * while Linux driver does not
 	 */
-	if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
 		i40evf_get_link_status(dev, &new_link);
-	else {
+	} else {
 		/* Always assume it's up, for Linux driver PF host */
-		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-		new_link.link_speed  = ETH_LINK_SPEED_10000;
-		new_link.link_status = 1;
+		new_link.link_speed  = ETH_SPEED_NUM_10G;
+		new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+		new_link.link_autoneg = ETH_LINK_SPEED_NEG;
+		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +34 -44
index 4e3ab3d..14a03e1 100644
@@ -1979,14 +1979,13 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	int mask = 0;
 	int status;
 	uint16_t vf, idx;
+	uint32_t *link_speeds;
 
 	PMD_INIT_FUNC_TRACE();
 
 	/* IXGBE devices don't support half duplex */
-	if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
-			(dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX)) {
-		PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
-			     dev->data->dev_conf.link_duplex,
+	if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_NO_AUTONEG) {
+		PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; autonegociation disabled",
 			     dev->data->port_id);
 		return -EINVAL;
 	}
@@ -2076,32 +2075,22 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	if (err)
 		goto error;
 
-	switch(dev->data->dev_conf.link_speed) {
-	case ETH_LINK_SPEED_AUTONEG:
-		speed = (hw->mac.type != ixgbe_mac_82598EB) ?
-				IXGBE_LINK_SPEED_82599_AUTONEG :
-				IXGBE_LINK_SPEED_82598_AUTONEG;
-		break;
-	case ETH_LINK_SPEED_100:
-		/*
-		 * Invalid for 82598 but error will be detected by
-		 * ixgbe_setup_link()
-		 */
-		speed = IXGBE_LINK_SPEED_100_FULL;
-		break;
-	case ETH_LINK_SPEED_1000:
-		speed = IXGBE_LINK_SPEED_1GB_FULL;
-		break;
-	case ETH_LINK_SPEED_10000:
-		speed = IXGBE_LINK_SPEED_10GB_FULL;
-		break;
-	default:
-		PMD_INIT_LOG(ERR, "Invalid link_speed (%hu) for port %hhu",
-			     dev->data->dev_conf.link_speed,
-			     dev->data->port_id);
+	link_speeds = &dev->data->dev_conf.link_speeds;
+	if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
+							ETH_LINK_SPEED_10G)) {
+		PMD_INIT_LOG(ERR, "Invalid link setting");
 		goto error;
 	}
 
+	speed = 0x0;
+
+	if (*link_speeds & ETH_LINK_SPEED_10G)
+		speed |= IXGBE_LINK_SPEED_10GB_FULL;
+	if (*link_speeds & ETH_LINK_SPEED_1G)
+		speed |= IXGBE_LINK_SPEED_1GB_FULL;
+	if (*link_speeds & ETH_LINK_SPEED_100M)
+		speed |= IXGBE_LINK_SPEED_100_FULL;
+
 	err = ixgbe_setup_link(hw, speed, link_up);
 	if (err)
 		goto error;
@@ -2828,15 +2817,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
 	dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
 
-	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
 
 	if (hw->mac.type == ixgbe_mac_X540 ||
 	    hw->mac.type == ixgbe_mac_X540_vf ||
 	    hw->mac.type == ixgbe_mac_X550 ||
-	    hw->mac.type == ixgbe_mac_X550_vf)
+	    hw->mac.type == ixgbe_mac_X550_vf) {
 
-		dev_info->speed_capa |= ETH_SPEED_CAP_100M_FD /*|
-					ETH_SPEED_CAP_100M_HD*/;
+		dev_info->speed_capa |= ETH_LINK_SPEED_100M /*|
+					ETH_LINK_SPEED_100M_HD*/;
+	}
 }
 
 static void
@@ -2903,9 +2893,9 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	int link_up;
 	int diag;
 
-	link.link_status = 0;
+	link.link_status = ETH_LINK_DOWN;
 	link.link_speed = 0;
-	link.link_duplex = 0;
+	link.link_duplex = ETH_LINK_HALF_DUPLEX;
 	memset(&old, 0, sizeof(old));
 	rte_ixgbe_dev_atomic_read_link_status(dev, &old);
 
@@ -2918,8 +2908,8 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 		diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
 
 	if (diag != 0) {
-		link.link_speed = ETH_LINK_SPEED_100;
-		link.link_duplex = ETH_LINK_HALF_DUPLEX;
+		link.link_speed = ETH_SPEED_NUM_100M;
+		link.link_duplex = ETH_LINK_FULL_DUPLEX;
 		rte_ixgbe_dev_atomic_write_link_status(dev, &link);
 		if (link.link_status == old.link_status)
 			return -1;
@@ -2932,26 +2922,26 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 			return -1;
 		return 0;
 	}
-	link.link_status = 1;
+	link.link_status = ETH_LINK_UP;
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	switch (link_speed) {
 	default:
 	case IXGBE_LINK_SPEED_UNKNOWN:
-		link.link_duplex = ETH_LINK_HALF_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_duplex = ETH_LINK_FULL_DUPLEX;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 
 	case IXGBE_LINK_SPEED_100_FULL:
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 
 	case IXGBE_LINK_SPEED_1GB_FULL:
-		link.link_speed = ETH_LINK_SPEED_1000;
+		link.link_speed = ETH_SPEED_NUM_1G;
 		break;
 
 	case IXGBE_LINK_SPEED_10GB_FULL:
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
 		break;
 	}
 	rte_ixgbe_dev_atomic_write_link_status(dev, &link);
@@ -5725,15 +5715,15 @@ ixgbe_start_timecounters(struct rte_eth_dev *dev)
 	rte_ixgbe_dev_atomic_read_link_status(dev, &link);
 
 	switch (link.link_speed) {
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		incval = IXGBE_INCVAL_100;
 		shift = IXGBE_INCVAL_SHIFT_100;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		incval = IXGBE_INCVAL_1GB;
 		shift = IXGBE_INCVAL_SHIFT_1GB;
 		break;
-	case ETH_LINK_SPEED_10000:
+	case ETH_SPEED_NUM_10G:
 	default:
 		incval = IXGBE_INCVAL_10GB;
 		shift = IXGBE_INCVAL_SHIFT_10GB;
drivers/net/mlx4/mlx4.c +2 -0
index 1f3ed59..4dbc8a9 100644
@@ -4637,6 +4637,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)
 		dev_link.link_speed = link_speed;
 	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
+	dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
 		/* Link status changed. */
 		dev->data->dev_link = dev_link;
drivers/net/mpipe/mpipe_tilegx.c +4 -2
index 35134ba..f42c1d4 100644
@@ -388,14 +388,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 		speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+		new.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 		if (speed == GXIO_MPIPE_LINK_1G) {
 			new.link_speed = ETH_LINK_SPEED_1000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
 			new.link_speed = ETH_LINK_SPEED_10000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		}
 
 		rc = mpipe_link_compare(&old, &new);
drivers/net/null/rte_eth_null.c +3 -2
index 77fc988..55e1fc8 100644
@@ -93,9 +93,10 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG,
 };
 
 static uint16_t
drivers/net/pcap/rte_eth_pcap.c +5 -4
index f9230eb..650b521 100644
@@ -125,9 +125,10 @@ static int open_single_iface(const char *iface, pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED,
 };
 
 static int
@@ -430,7 +431,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -481,7 +482,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	}
 
 status_down:
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +3 -2
index d92b088..043175a 100644
@@ -71,9 +71,10 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/virtio/virtio_ethdev.c +1 -1
index d928339..83a2ffe 100644
@@ -1631,7 +1631,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_read_link_status(dev, &link);
 	old = link;
-	link.link_duplex = FULL_DUPLEX;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	link.link_speed  = SPEED_10G;
 
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index ae2d47d..8598815 100644
@@ -42,8 +42,6 @@
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_10G	10000
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -2
index c363bf6..2bb6ee9 100644
@@ -736,9 +736,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
 	if (ret & 0x1) {
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
+		link.link_autoneg = ETH_LINK_SPEED_FIXED;
 	}
 
 	vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -2
index 3f31806..0fcf5d3 100644
@@ -70,9 +70,10 @@ static int virtio_idx = 0;
 static const char *drivername = "xen virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED
 };
 
 static void
examples/ip_pipeline/config_parse.c +1 -2
index 1bedbe4..c581d41 100644
@@ -84,8 +84,7 @@ static const struct app_link_params link_params_default = {
 	.mac_addr = 0,
 
 	.conf = {
-		.link_speed = 0,
-		.link_duplex = 0,
+		.link_speeds = 0,
 		.rxmode = {
 			.mq_mode = ETH_MQ_RX_NONE,
 
lib/librte_ether/rte_ethdev.c +49 -0
index 756b234..7b0214d 100644
@@ -865,6 +865,55 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 }
 
 int
+rte_eth_speed_to_bm_flag(uint32_t speed, int duplex, uint32_t *flag)
+{
+	switch (speed) {
+	case ETH_SPEED_NUM_10M:
+		*flag = (duplex) ? ETH_LINK_SPEED_10M :
+							ETH_LINK_SPEED_10M_HD;
+		break;
+	case ETH_SPEED_NUM_100M:
+		*flag = (duplex) ? ETH_LINK_SPEED_100M :
+							ETH_LINK_SPEED_100M_HD;
+		break;
+	case ETH_SPEED_NUM_1G:
+		*flag = ETH_LINK_SPEED_1G;
+		break;
+	case ETH_SPEED_NUM_2_5G:
+		*flag = ETH_LINK_SPEED_2_5G;
+		break;
+	case ETH_SPEED_NUM_5G:
+		*flag = ETH_LINK_SPEED_5G;
+		break;
+	case ETH_SPEED_NUM_10G:
+		*flag = ETH_LINK_SPEED_10G;
+		break;
+	case ETH_SPEED_NUM_20G:
+		*flag = ETH_LINK_SPEED_20G;
+		break;
+	case ETH_SPEED_NUM_25G:
+		*flag = ETH_LINK_SPEED_25G;
+		break;
+	case ETH_SPEED_NUM_40G:
+		*flag = ETH_LINK_SPEED_40G;
+		break;
+	case ETH_SPEED_NUM_50G:
+		*flag = ETH_LINK_SPEED_50G;
+		break;
+	case ETH_SPEED_NUM_56G:
+		*flag = ETH_LINK_SPEED_56G;
+		break;
+	case ETH_SPEED_NUM_100G:
+		*flag = ETH_LINK_SPEED_100G;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+int
 rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
 {
lib/librte_ether/rte_ethdev.h +73 -41
index dbc1599..9b32de5 100644
@@ -242,26 +242,59 @@ struct rte_eth_stats {
 };
 
 /**
+ * Device supported speeds bitmap flags
+ */
+#define ETH_LINK_SPEED_AUTONEG		(0 << 0)  /*< Autonegociate (all speeds)  */
+#define ETH_LINK_SPEED_NO_AUTONEG	(1 << 0)  /*< Disable autoneg (fixed speed)  */
+#define ETH_LINK_SPEED_10M_HD		(1 << 1)  /*< 10 Mbps half-duplex */
+#define ETH_LINK_SPEED_10M		(1 << 2)  /*< 10 Mbps full-duplex */
+#define ETH_LINK_SPEED_100M_HD		(1 << 3)  /*< 100 Mbps half-duplex */
+#define ETH_LINK_SPEED_100M		(1 << 4)  /*< 100 Mbps full-duplex */
+#define ETH_LINK_SPEED_1G		(1 << 5)  /*< 1 Gbps */
+#define ETH_LINK_SPEED_2_5G		(1 << 6)  /*< 2.5 Gbps */
+#define ETH_LINK_SPEED_5G		(1 << 7)  /*< 5 Gbps */
+#define ETH_LINK_SPEED_10G		(1 << 8)  /*< 10 Mbps */
+#define ETH_LINK_SPEED_20G		(1 << 9)  /*< 20 Gbps */
+#define ETH_LINK_SPEED_25G		(1 << 10)  /*< 25 Gbps */
+#define ETH_LINK_SPEED_40G		(1 << 11)  /*< 40 Gbps */
+#define ETH_LINK_SPEED_50G		(1 << 12)  /*< 50 Gbps */
+#define ETH_LINK_SPEED_56G		(1 << 13)  /*< 56 Gbps */
+#define ETH_LINK_SPEED_100G		(1 << 14)  /*< 100 Gbps */
+
+/**
+ * Ethernet numeric link speeds in Mbps
+ */
+#define ETH_SPEED_NUM_NONE	0      /*< Not defined */
+#define ETH_SPEED_NUM_10M	10     /*< 10 Mbps */
+#define ETH_SPEED_NUM_100M	100    /*< 100 Mbps */
+#define ETH_SPEED_NUM_1G	1000   /*< 1 Gbps */
+#define ETH_SPEED_NUM_2_5G	2500   /*< 2.5 Gbps */
+#define ETH_SPEED_NUM_5G	5000   /*< 5 Gbps */
+#define ETH_SPEED_NUM_10G	10000  /*< 10 Mbps */
+#define ETH_SPEED_NUM_20G	20000  /*< 20 Gbps */
+#define ETH_SPEED_NUM_25G	25000  /*< 25 Gbps */
+#define ETH_SPEED_NUM_40G	40000  /*< 40 Gbps */
+#define ETH_SPEED_NUM_50G	50000  /*< 50 Gbps */
+#define ETH_SPEED_NUM_56G	56000  /*< 56 Gbps */
+#define ETH_SPEED_NUM_100G	100000 /*< 100 Gbps */
+
+/**
  * A structure used to retrieve link-level information of an Ethernet port.
  */
 struct rte_eth_link {
-	uint16_t link_speed;      /**< ETH_LINK_SPEED_[10, 100, 1000, 10000] */
-	uint16_t link_duplex;     /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX] */
-	uint8_t  link_status : 1; /**< 1 -> link up, 0 -> link down */
-}__attribute__((aligned(8)));     /**< aligned for atomic64 read/write */
-
-#define ETH_LINK_SPEED_AUTONEG  0       /**< Auto-negotiate link speed. */
-#define ETH_LINK_SPEED_10       10      /**< 10 megabits/second. */
-#define ETH_LINK_SPEED_100      100     /**< 100 megabits/second. */
-#define ETH_LINK_SPEED_1000     1000    /**< 1 gigabits/second. */
-#define ETH_LINK_SPEED_10000    10000   /**< 10 gigabits/second. */
-#define ETH_LINK_SPEED_10G      10000   /**< alias of 10 gigabits/second. */
-#define ETH_LINK_SPEED_20G      20000   /**< 20 gigabits/second. */
-#define ETH_LINK_SPEED_40G      40000   /**< 40 gigabits/second. */
+	uint32_t link_speed;        /**< Link speed (ETH_SPEED_NUM_) */
+	uint16_t link_duplex  : 1;  /**< 1 -> full duplex, 0 -> half duplex */
+	uint16_t link_autoneg : 1;  /**< 1 -> link speed has been autoneg */
+	uint16_t link_status  : 1;  /**< 1 -> link up, 0 -> link down */
+} __attribute__((aligned(8)));      /**< aligned for atomic64 read/write */
 
-#define ETH_LINK_AUTONEG_DUPLEX 0       /**< Auto-negotiate duplex. */
-#define ETH_LINK_HALF_DUPLEX    1       /**< Half-duplex connection. */
-#define ETH_LINK_FULL_DUPLEX    2       /**< Full-duplex connection. */
+/* Utility constants */
+#define ETH_LINK_HALF_DUPLEX    0	/**< Half-duplex connection. */
+#define ETH_LINK_FULL_DUPLEX    1	/**< Full-duplex connection. */
+#define ETH_LINK_SPEED_FIXED    0	/**< Link speed was not autonegociated. */
+#define ETH_LINK_SPEED_NEG      1	/**< Link speed was autonegociated. */
+#define ETH_LINK_DOWN		0	/**< Link is down. */
+#define ETH_LINK_UP		1	/**< Link is up. */
 
 /**
  * A structure used to configure the ring threshold registers of an RX/TX
@@ -760,10 +793,14 @@ struct rte_intr_conf {
  * configuration settings may be needed.
  */
 struct rte_eth_conf {
-	uint16_t link_speed;
-	/**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */
-	uint16_t link_duplex;
-	/**< ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation */
+	uint32_t link_speeds; /**< bitmap of ETH_LINK_SPEED_XXX of speeds to be
+				used. ETH_LINK_SPEED_NO_AUTONEG disables link
+				autonegociation, and a unique speed shall be
+				set. Otherwise, the bitmap defines the set of
+				speeds to be advertised. If the special value
+				ETH_LINK_SPEED_AUTONEG (0) is used, all speeds
+				supported are advertised.
+				*/
 	struct rte_eth_rxmode rxmode; /**< Port RX configuration. */
 	struct rte_eth_txmode txmode; /**< Port TX configuration. */
 	uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
@@ -825,26 +862,6 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
 /**
- * Device supported speeds
- */
-#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
-#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
-#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
-#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
-#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */
-#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
-#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
-#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
-#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
-#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
-#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
-#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
-#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
-#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
-#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */
-
-
-/**
  * Ethernet device information
  */
 struct rte_eth_dev_info {
@@ -1811,6 +1828,22 @@ struct eth_driver {
 void rte_eth_driver_register(struct eth_driver *eth_drv);
 
 /**
+ * Convert a numerical speed in Mbps to a bitmap flag that can be used in
+ * the bitmap link_speeds of the struct rte_eth_conf
+ *
+ * @param
+ *   Numerical speed value in Mbps
+ * @param
+ *   Boolean is duplex (only for 10/100 speeds)
+ * @param
+ *   On success, the converted speed into a bitmap flag
+ * @return
+ *   0 on success, -EINVAL if the speed cannot be mapped
+ */
+extern int rte_eth_speed_to_bm_flag(uint32_t speed, int duplex,
+							uint32_t *flag);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
--

2.1.4

#19 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick it up from them.

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?
May it be documented in the DPDK doc?

Thanks

#20 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

Hi Thomas,

Quoted 8 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, January 29, 2016 9:38 AM
To: Ananyev, Konstantin
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 8 lines
Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick it up from them.

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?

I meant not to the ND directly, but probably to the freebsd e1000 kernel driver. As I remember, that is the closest one to what we have.

Quoted 1 line

From my understanding (I might be wrong here):

If they will be accepted, we should see these changes In next code drops from ND. Konstantin

Quoted 6 lines

May it be documented in the DPDK doc?

Thanks

#21 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

2016-01-29 09:47, Ananyev, Konstantin:

Quoted 8 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 7 lines

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick it up from them.

Quoted 7 lines
Quoted 2 lines

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?

I meant not to the ND directly, but probably to the freebsd e1000 kernel driver. As I remember, that is the closest one to what we have.
From my understanding (I might be wrong here):
If they will be accepted, we should see these changes In next code drops from ND.

These base drivers are used in several places.
We are allowed to submit a patch in Linux or FreeBSD but not in DPDK where the base driver is verbatim?
We have an agreement to not touch them in DPDK but I still think the ND team could consider some patches from dpdk.org.

#22 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 21 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, January 29, 2016 9:54 AM
To: Ananyev, Konstantin
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

2016-01-29 09:47, Ananyev, Konstantin:

Quoted 11 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 9 lines

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick it up from them.

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?

Quoted 8 lines
Quoted 4 lines

I meant not to the ND directly, but probably to the freebsd e1000 kernel driver. As I remember, that is the closest one to what we have.
From my understanding (I might be wrong here):
If they will be accepted, we should see these changes In next code drops from ND.

These base drivers are used in several places.
We are allowed to submit a patch in Linux or FreeBSD but not in DPDK where the base driver is verbatim?

Yes, that's my understanding.

Quoted 1 line

We have an agreement to not touch them in DPDK

Yes.

Quoted 2 lines

but I still think the
ND team could consider some patches from dpdk.org.

I personally think that would be a good thing,
but it is up to ND guys to make such decision.

Konstantin

author
#23 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 16 lines · Konstantin
Quoted 7 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, January 29, 2016 9:54 AM
To: Ananyev, Konstantin
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil;

Chen, Jing D; Mcnamara, John

Quoted 1 line

Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed

config API

Quoted 5 lines

2016-01-29 09:47, Ananyev, Konstantin:

Quoted 3 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 2 lines

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 1 line

Can you avoid modifications in the e1000/base code?

Yes I can. It was just to save intermediate variables and conversions. Previously u16 was used to store numeric throughput in mbps in ethdev, and passed to the inner functions in e1000/base, but it cannot accommodate 100G values, so I moved it to uint32_t. But I can do the conversion outside of e1000/base.

Quoted 25 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

We do not modify (and maintain) that part on our own.

Quoted 2 lines

Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please

submit a patch

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to ND first, and if your changes will be applied, will pick it up

from them.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?

I meant not to the ND directly, but probably to the freebsd e1000

kernel driver.

Quoted 3 lines
Quoted 3 lines

As I remember, that is the closest one to what we have. From my understanding (I might be wrong here):
If they will be accepted, we should see these changes In next code

drops from ND.

Quoted 4 lines

These base drivers are used in several places.
We are allowed to submit a patch in Linux or FreeBSD but not in DPDK where the base driver is verbatim?

Yes, that's my understanding.

Quoted 1 line

We have an agreement to not touch them in DPDK

Quoted 7 lines

Yes.

Quoted 2 lines

but I still think the
ND team could consider some patches from dpdk.org.

I personally think that would be a good thing,
but it is up to ND guys to make such decision.

Agree, but:

Besides documenting (which is necessary), why not importing the sources via a git submodule pointing to the base project where these files are obtained (e.g. in drivers/net/e1000/ext/ or even in the root folder under ext/ and making symlinks to that in e1000 driver), and just use the raw sources and headers from there?

That would make it more explicit that these files should not be modified by DPDK by strictly forbidding so, and that changes should be done via the repository pointed in drivers/net/e1000/ext/, hence following that repository's workflow.

marc

Quoted 4 lines

Konstantin

#31 lore raw

Re: [PATCH v7 5/5] ethdev: add rte_eth_speed_to_bm_flag() to ver. map

In reply to Marc Sune
Quoted 13 lines · Marc Sune

Added rte_eth_speed_to_bm_flag() to DPDK2.2 version map.

---
  lib/librte_ether/rte_ether_version.map | 6 ++++++
  1 file changed, 6 insertions(+)
lib/librte_ether/rte_ether_version.map +0 -0
index d8db24d..2c14ad7 100644

lib/librte_ether/rte_ether_version.map DPDK_2.2 { · line 125

Quoted 9 lines
lib/librte_ether/rte_ether_version.map +6 -0
@@ -117,3 +117,9 @@ DPDK_2.2 {
 
  	local: *;
  };
+
+DPDK_2.3 {
+	global:
+
+	rte_eth_speed_to_bm_flag;
+}DPDK_2.2;

The version map must be updated in the patch that adds the symbol(s) in question to the code, not separately.

- Panu -

#27 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

In reply to Marc Sune

Hi Marc,

Quoted 10 lines · Marc Sune

[...]
/**
- * Device supported speeds
- */

lib/librte_ether/rte_ethdev.h +0 -6
-#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
-#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
-#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
-#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
-#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */
-#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */

lib/librte_ether/rte_ethdev.h struct rte_eth_conf { · line 844

Quoted 10 lines
lib/librte_ether/rte_ethdev.h +0 -9
-#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
-#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
-#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
-#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
-#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
-#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
-#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
-#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
-#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */
[...]

In the previous commit you update mlx4.c to use those define, in this commit it should update it again.

Regards,

Signature · 2 lines
Nélio Laranjeiro
6WIND
author
#32 lore raw

Re: [PATCH v7 5/5] ethdev: add rte_eth_speed_to_bm_flag() to ver. map

In reply to Panu Matilainen
Quoted 16 lines · Panu Matilainen
Quoted 14 lines · Marc Sune

Added rte_eth_speed_to_bm_flag() to DPDK2.2 version map.

---
  lib/librte_ether/rte_ether_version.map | 6 ++++++
  1 file changed, 6 insertions(+)
lib/librte_ether/rte_ether_version.map +0 -0
index d8db24d..2c14ad7 100644
@@ -117,3 +117,9 @@ DPDK_2.2 {
 
Quoted 12 lines

lib/librte_ether/rte_ether_version.map DPDK_2.2 { · line 125

Quoted 10 lines
lib/librte_ether/rte_ether_version.map +6 -0
        local: *;
  };
+
+DPDK_2.3 {
+       global:
+
+       rte_eth_speed_to_bm_flag;
+}DPDK_2.2;

The version map must be updated in the patch that adds the symbol(s) in question to the code, not separately.

Panu,

I will merge it with patch 3.

Marc

Quoted 4 lines

- Panu -

author
#28 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

In reply to Nélio Laranjeiro
Quoted 14 lines · Nélio Laranjeiro

Hi Marc,

lib/librte_ether/rte_ethdev.h struct rte_eth_conf {

Quoted 8 lines · Marc Sune

[...]
/**
- * Device supported speeds
- */

lib/librte_ether/rte_ethdev.h +0 -4
-#define ETH_SPEED_CAP_NOT_PHY        (0)  /*< No phy media > */
-#define ETH_SPEED_CAP_10M_HD (1 << 0)  /*< 10 Mbps half-duplex> */
-#define ETH_SPEED_CAP_10M_FD (1 << 1)  /*< 10 Mbps full-duplex> */
-#define ETH_SPEED_CAP_100M_HD        (1 << 2)  /*< 100 Mbps

half-duplex> */

Quoted 1 line

-#define ETH_SPEED_CAP_100M_FD (1 << 3) /*< 100 Mbps

full-duplex> */

Quoted 15 lines

lib/librte_ether/rte_ethdev.h struct rte_eth_conf { · line 844

Quoted 11 lines
lib/librte_ether/rte_ethdev.h +0 -10
-#define ETH_SPEED_CAP_1G     (1 << 4)  /*< 1 Gbps > */
-#define ETH_SPEED_CAP_2_5G   (1 << 5)  /*< 2.5 Gbps > */
-#define ETH_SPEED_CAP_5G     (1 << 6)  /*< 5 Gbps > */
-#define ETH_SPEED_CAP_10G    (1 << 7)  /*< 10 Mbps > */
-#define ETH_SPEED_CAP_20G    (1 << 8)  /*< 20 Gbps > */
-#define ETH_SPEED_CAP_25G    (1 << 9)  /*< 25 Gbps > */
-#define ETH_SPEED_CAP_40G    (1 << 10)  /*< 40 Gbps > */
-#define ETH_SPEED_CAP_50G    (1 << 11)  /*< 50 Gbps > */
-#define ETH_SPEED_CAP_56G    (1 << 12)  /*< 56 Gbps > */
-#define ETH_SPEED_CAP_100G   (1 << 13)  /*< 100 Gbps > */
[...]

In the previous commit you update mlx4.c to use those define, in this commit it should update it again.

Neilo,

You are right, thanks. I will fix that in a new version.

marc

Quoted 7 lines

Regards,

--
Nélio Laranjeiro
6WIND

#24 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

In reply to Ananyev, Konstantin
Quoted 50 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Friday, January 29, 2016 6:18 PM
To: Thomas Monjalon
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: RE: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 9 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, January 29, 2016 9:54 AM
To: Ananyev, Konstantin
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 8 lines

2016-01-29 09:47, Ananyev, Konstantin:

Quoted 7 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 6 lines

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick

it up from them.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?

I meant not to the ND directly, but probably to the freebsd e1000 kernel

driver.

Quoted 3 lines
Quoted 3 lines

As I remember, that is the closest one to what we have.
From my understanding (I might be wrong here):
If they will be accepted, we should see these changes In next code drops

from ND.

Quoted 4 lines

These base drivers are used in several places.
We are allowed to submit a patch in Linux or FreeBSD but not in DPDK where the base driver is verbatim?

Yes, that's my understanding.

Quoted 1 line

We have an agreement to not touch them in DPDK

Quoted 7 lines

Yes.

Quoted 2 lines

but I still think the
ND team could consider some patches from dpdk.org.

I personally think that would be a good thing, but it is up to ND guys to make such decision.

[Zhang, Helin] The key reason of not touching base driver is we don't want to maintain those source files, and just reuse others. This can help us a lot. We should try to avoid touching source files in base driver, but if you still insist something critical or a bug should be faced. First of all we can try to do something in the dpdk developed source files (e.g. i40e_ethdev.c, i40e_rxtx.c, i40e_osdep.h). This was what we have done for a long time, and it works quite well. If there is no other way to fix a bug in base driver, we can try the way like Konstantin indicated, or let me know, I will try to influence ND. But note that this might be the lowest efficiency way, due to the complicated process.

Sorry for any inconvenience! This the way we are using now might be the best for us right now.

Regards,
Heiln

Quoted 2 lines

Konstantin

author
#25 lore raw

Re: [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 60 lines · Helin
Quoted 7 lines

-----Original Message-----
From: Ananyev, Konstantin
Sent: Friday, January 29, 2016 6:18 PM
To: Thomas Monjalon
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil;

Chen,

Quoted 23 lines

Jing D; Mcnamara, John
Subject: RE: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 17 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, January 29, 2016 9:54 AM
To: Ananyev, Konstantin
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

2016-01-29 09:47, Ananyev, Konstantin:

Quoted 7 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 6 lines

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own. Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied,

will pick

Quoted 3 lines

it up from them.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I was not aware we can submit a change to ND for Intel base

drivers.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

What is the procedure please?

I meant not to the ND directly, but probably to the freebsd e1000

kernel

Quoted 4 lines

driver.

Quoted 3 lines
Quoted 3 lines

As I remember, that is the closest one to what we have. From my understanding (I might be wrong here):
If they will be accepted, we should see these changes In next code

drops

Quoted 15 lines

from ND.

Quoted 4 lines

These base drivers are used in several places.
We are allowed to submit a patch in Linux or FreeBSD but not in DPDK where the base driver is verbatim?

Yes, that's my understanding.

Quoted 1 line

We have an agreement to not touch them in DPDK

Yes.

Quoted 2 lines

but I still think the
ND team could consider some patches from dpdk.org.

Quoted 6 lines
Quoted 1 line

I personally think that would be a good thing, but it is up to ND guys

to make

Quoted 1 line

such decision.

[Zhang, Helin] The key reason of not touching base driver is we don't want to
maintain those source files, and just reuse others.

So files under base/ strictly copies of what is in this other Intel repository (ND) or there are modifications?

If IIRC rte_link was crafted so that matches e1000 (at least) so that link reads can be done atomically. I think it makes more sense that ethdev has a generic, device independent struct and that drivers handle the translation, if necessary. Do we agree on this?

This can help us a lot.

Quoted 14 lines

We should try to avoid touching source files in base driver, but if you still insist
something critical or a bug should be faced. First of all we can try to do something
in the dpdk developed source files (e.g. i40e_ethdev.c, i40e_rxtx.c, i40e_osdep.h).
This was what we have done for a long time, and it works quite well. If there is no other way to fix a bug in base driver, we can try the way like
Konstantin indicated, or let me know, I will try to influence ND. But note that this
might be the lowest efficiency way, due to the complicated process.

Quoted 4 lines

Sorry for any inconvenience! This the way we are using now might be the best for
us right now.

I will go back and redesign commit 3 in the series once more. I will need some time (other things in the pipeline). I would have appreciated rising this red flag in one of the 6 previous versions.

marc

Quoted 8 lines

Regards,
Heiln

Quoted 2 lines

Konstantin

#26 lore raw

PATCH v7 3/5 ethdev: redesign link speed config API

Quoted 66 lines

From: [email protected] [mailto:[email protected]] On Behalf Of Marc
Sent: Tuesday, February 2, 2016 8:04 AM
To: Zhang, Helin
Cc: Ananyev, Konstantin; Thomas Monjalon; [email protected]; Lu, Wenzhuo; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 53 lines · Helin

-----Original Message-----
From: Ananyev, Konstantin
Sent: Friday, January 29, 2016 6:18 PM
To: Thomas Monjalon
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: RE: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 9 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Friday, January 29, 2016 9:54 AM
To: Ananyev, Konstantin
Cc: [email protected]; Marc Sune; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D; Mcnamara, John
Subject: Re: [dpdk-dev] [PATCH v7 3/5] ethdev: redesign link speed config API

Quoted 8 lines

2016-01-29 09:47, Ananyev, Konstantin:

Quoted 7 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 6 lines

2016-01-29 09:24, Ananyev, Konstantin:

Quoted 5 lines

Can you avoid modifications in the e1000/base code?
We do not modify (and maintain) that part on our own.
Instead we take it straight from Intel ND.
So if you feel like these changes are really necessary - please submit a patch to ND first, and if your changes will be applied, will pick

it up from them.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

I was not aware we can submit a change to ND for Intel base drivers. What is the procedure please?

I meant not to the ND directly, but probably to the freebsd e1000 kernel

driver.

Quoted 3 lines
Quoted 3 lines

As I remember, that is the closest one to what we have.
From my understanding (I might be wrong here):
If they will be accepted, we should see these changes In next code drops

from ND.

Quoted 4 lines

These base drivers are used in several places.
We are allowed to submit a patch in Linux or FreeBSD but not in DPDK where the base driver is verbatim?

Yes, that's my understanding.

Quoted 1 line

We have an agreement to not touch them in DPDK

Yes.

Quoted 2 lines

but I still think the
ND team could consider some patches from dpdk.org.

Quoted 6 lines
Quoted 2 lines

I personally think that would be a good thing, but it is up to ND guys to make such decision.

[Zhang, Helin] The key reason of not touching base driver is we don't want to maintain those source files, and just reuse others.

So files under base/ strictly copies of what is in this other Intel repository (ND) or there are modifications?

Long time ago, those source files were copied from FreeBSD version of driver, without any modification. Though there is a bit different from that time, but they are similar.
Note that 'base/i40e_osdep.h or ixgbe_osdep.h' is the only file we can modify to support DPDK. Of cause, all other files than base driver are what we developed, and can be modified.

Quoted 2 lines

If IIRC rte_link was crafted so that matches e1000 (at least) so that link reads can be done atomically. I think it makes more sense that ethdev has a generic, device independent struct and that drivers handle the translation, if necessary. Do we agree on this?

I agree with you to have a generic structure in ethdev, and it can be filled with information obtained from base driver.

Quoted 10 lines

This can help us a lot.
We should try to avoid touching source files in base driver, but if you still insist something critical or a bug should be faced. First of all we can try to do something in the dpdk developed source files (e.g. i40e_ethdev.c, i40e_rxtx.c, i40e_osdep.h). This was what we have done for a long time, and it works quite well. If there is no other way to fix a bug in base driver, we can try the way like Konstantin indicated, or let me know, I will try to influence ND. But note that this might be the lowest efficiency way, due to the complicated process.

Quoted 4 lines

Sorry for any inconvenience! This the way we are using now might be the best for us right now.

I will go back and redesign commit 3 in the series once more. I will need some time (other things in the pipeline). I would have appreciated rising this red flag in one of the 6 previous versions.

Thank you very much for the helps, and patience!

Regards,
Helin

Quoted 10 lines

marc

Regards,
Heiln

Quoted 2 lines

Konstantin

author
#33 lore raw

v8 cover ethdev: add speed capabilities and refactor link API

In reply to Marc Sune

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment (checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a bitmap for defining the announced speeds, as suggested M. Brorup. Fixed spelling issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit value. Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

Marc Sune (4):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes

 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124 +++++++++++++++---------------
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 doc/guides/rel_notes/release_2_3.rst      | 102 ++++++++++++++++++++++++
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   7 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   1 +
 drivers/net/e1000/em_ethdev.c             | 112 ++++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c            | 107 +++++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c          |   6 +-
 drivers/net/i40e/i40e_ethdev.c            |  78 +++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  80 +++++++++----------
 drivers/net/mlx4/mlx4.c                   |   6 ++
 drivers/net/mlx5/mlx5_ethdev.c            |   5 ++
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             |  97 ++++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map    |   6 ++
 31 files changed, 573 insertions(+), 301 deletions(-)
 create mode 100644 doc/guides/rel_notes/release_2_3.rst
Signature · 1 line
2.1.4
author
#34 lore raw

PATCH v8 1/4 ethdev: Added ETH_SPEED_CAP bitmap for ports

Added constants and bitmap to struct rte_eth_dev_info to be used by PMDs.

---
 lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
lib/librte_ether/rte_ethdev.h +24 -0
index 16da821..83ddbb7 100644
@@ -824,6 +824,29 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
+/**
+ * Device supported speeds
+ */
+#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
+#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */
+#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */
+
+
+/**
+ * Ethernet device information
+ */
 struct rte_eth_dev_info {
 	struct rte_pci_device *pci_dev; /**< Device PCI information. */
 	const char *driver_name; /**< Device Driver name. */
@@ -852,6 +875,7 @@ struct rte_eth_dev_info {
 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
 	struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
 	struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
+	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_SPEED_CAP_). */
 };
 
 /**
Signature · 1 line
2.1.4
author
#36 lore raw

PATCH v8 2/4 ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k

---
 drivers/net/bnx2x/bnx2x_ethdev.c |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  1 +
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 drivers/net/mlx5/mlx5_ethdev.c   |  5 +++++
 drivers/net/nfp/nfp_net.c        |  2 ++
 10 files changed, 48 insertions(+)
drivers/net/bnx2x/bnx2x_ethdev.c +1 -0
index 69df02e..b547ac3 100644
@@ -347,6 +347,7 @@ bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_inf
 	dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
 	dev_info->max_rx_pktlen  = BNX2X_MAX_RX_PKT_LEN;
 	dev_info->max_mac_addrs  = BNX2X_MAX_MAC_ADDRS;
+	dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_20G;
 }
 
 static void
drivers/net/cxgbe/cxgbe_ethdev.c +1 -0
index 97ef152..203e119 100644
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 
 	device_info->rx_desc_lim = cxgbe_desc_lim;
 	device_info->tx_desc_lim = cxgbe_desc_lim;
+	device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
 }
 
 static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
drivers/net/e1000/em_ethdev.c +6 -0
index 4a843fe..e40dc37 100644
@@ -1023,6 +1023,12 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_min = E1000_MIN_RING_DESC,
 		.nb_align = EM_TXD_ALIGN,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 /* return 0 means link status changed, -1 means not changed */
drivers/net/e1000/igb_ethdev.c +6 -0
index 4ed5e95..7eac8ea 100644
@@ -1908,6 +1908,12 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 static void
drivers/net/fm10k/fm10k_ethdev.c +4 -0
index 421266b..2e6ec60 100644
@@ -1333,6 +1333,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_min = FM10K_MIN_TX_DESC,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
+					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
+					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +9 -0
index ef24122..78a0cbd 100644
@@ -2233,6 +2233,7 @@ static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vsi *vsi = pf->main_vsi;
 
 	dev_info->max_rx_queues = vsi->nb_qps;
@@ -2304,6 +2305,14 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->max_rx_queues += dev_info->vmdq_queue_num;
 		dev_info->max_tx_queues += dev_info->vmdq_queue_num;
 	}
+
+	if (i40e_is_40G_device(hw->device_id))
+		/* For XL710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+	else
+		/* For X710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+
 }
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +10 -0
index 3e6fe86..7e29c18 100644
@@ -2827,6 +2827,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
 	dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
 	dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+
+	if (hw->mac.type == ixgbe_mac_X540 ||
+	    hw->mac.type == ixgbe_mac_X540_vf ||
+	    hw->mac.type == ixgbe_mac_X550 ||
+	    hw->mac.type == ixgbe_mac_X550_vf)
+
+		dev_info->speed_capa |= ETH_SPEED_CAP_100M_FD /*|
+					ETH_SPEED_CAP_100M_HD*/;
 }
 
 static void
drivers/net/mlx4/mlx4.c +4 -0
index ee00151..c5688a7 100644
@@ -4264,6 +4264,10 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		 0);
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
+
+	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }
 
drivers/net/mlx5/mlx5_ethdev.c +5 -0
index 1159fa3..99dac09 100644
@@ -523,6 +523,11 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	 * size if it is not fixed.
 	 * The API should be updated to solve this problem. */
 	info->reta_size = priv->ind_table_max_size;
+
+	info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G |
+					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }
 
drivers/net/nfp/nfp_net.c +2 -0
index fd4dd39..98a957a 100644
@@ -1071,6 +1071,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 	dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_50G | ETH_SPEED_CAP_100G;
 }
 
 static uint32_t
Signature · 1 line
2.1.4
author
#43 lore raw

PATCH v8 3/4 ethdev: redesign link speed config API

In reply to Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint64_t to accomodate 100G speeds and beyond (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.
* Added rte_eth_speed_to_bm_flag() to version map.

---
 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124 +++++++++++++++---------------
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
 drivers/net/e1000/em_ethdev.c             | 116 ++++++++++++++--------------
 drivers/net/e1000/igb_ethdev.c            | 111 +++++++++++++-------------
 drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
 drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++-----------
 drivers/net/mlx4/mlx4.c                   |   6 +-
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             | 113 +++++++++++++++++----------
 lib/librte_ether/rte_ether_version.map    |   6 ++
 29 files changed, 443 insertions(+), 345 deletions(-)
app/test-pipeline/init.c +1 -1
index db2196b..08fb041 100644
@@ -200,7 +200,7 @@ app_ports_check_link(void)
 		port = (uint8_t) app.ports[i];
 		memset(&link, 0, sizeof(link));
 		rte_eth_link_get_nowait(port, &link);
-		RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n",
+		RTE_LOG(INFO, USER1, "Port %u (%" PRIu64 " Gbps) %s\n",
 			port,
 			link.link_speed / 1000,
 			link.link_status ? "UP" : "DOWN");
app/test-pmd/cmdline.c +64 -60

162 lines not on this page · raw message

app/test-pmd/config.c +2 -2
index 0062484..caeb2d9 100644
@@ -2241,7 +2241,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate)
 		return 1;
 	rte_eth_link_get_nowait(port_id, &link);
 	if (rate > link.link_speed) {
-		printf("Invalid rate value:%u bigger than link speed: %u\n",
+		printf("Invalid rate value:%u bigger than link speed: %" PRIu64 "\n",
 			rate, link.link_speed);
 		return 1;
 	}
@@ -2266,7 +2266,7 @@ set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk)
 		return 1;
 	rte_eth_link_get_nowait(port_id, &link);
 	if (rate > link.link_speed) {
-		printf("Invalid rate value:%u bigger than link speed: %u\n",
+		printf("Invalid rate value:%u bigger than link speed: %" PRIu64 "\n",
 			rate, link.link_speed);
 		return 1;
 	}
app/test/virtual_pmd.c +2 -2
index a538c8a..3c4040b 100644
@@ -603,8 +603,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
-	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
index 767f36b..5db1db2 100644
@@ -116,9 +116,10 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/bnx2x/bnx2x_ethdev.c +6 -2
index b547ac3..efefae6 100644
@@ -45,8 +45,12 @@ bnx2x_link_update(struct rte_eth_dev *dev)
 			dev->data->dev_link.link_duplex = ETH_LINK_HALF_DUPLEX;
 			break;
 		default:
-			dev->data->dev_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
+			break;
 	}
+
+	dev->data->dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
+
 	dev->data->dev_link.link_status = sc->link_vars.link_up;
 }
 
@@ -347,7 +351,7 @@ bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_inf
 	dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
 	dev_info->max_rx_pktlen  = BNX2X_MAX_RX_PKT_LEN;
 	dev_info->max_mac_addrs  = BNX2X_MAX_MAC_ADDRS;
-	dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_20G;
+	dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
 }
 
 static void
drivers/net/bonding/rte_eth_bond_8023ad.c +7 -7
index b3b30f6..3b446e1 100644
@@ -708,25 +708,25 @@ link_speed_key(uint16_t speed) {
 	uint16_t key_speed;
 
 	switch (speed) {
-	case ETH_LINK_SPEED_AUTONEG:
+	case ETH_SPEED_NUM_NONE:
 		key_speed = 0x00;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		key_speed = BOND_LINK_SPEED_KEY_10M;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		key_speed = BOND_LINK_SPEED_KEY_100M;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		key_speed = BOND_LINK_SPEED_KEY_1000M;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		key_speed = BOND_LINK_SPEED_KEY_10G;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		key_speed = BOND_LINK_SPEED_KEY_20G;
 		break;
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		key_speed = BOND_LINK_SPEED_KEY_40G;
 		break;
 	default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		if (stat & F_FW_PORT_CMD_TXPAUSE)
 			fc |= PAUSE_TX;
 		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-			speed = ETH_LINK_SPEED_100;
+			speed = ETH_SPEED_NUM_100M;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-			speed = ETH_LINK_SPEED_1000;
+			speed = ETH_SPEED_NUM_1G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-			speed = ETH_LINK_SPEED_10000;
+			speed = ETH_SPEED_NUM_10G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-			speed = ETH_LINK_SPEED_40G;
+			speed = ETH_SPEED_NUM_40G;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
drivers/net/cxgbe/cxgbe_ethdev.c +1 -1
index 203e119..05b954d 100644
@@ -171,7 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 
 	device_info->rx_desc_lim = cxgbe_desc_lim;
 	device_info->tx_desc_lim = cxgbe_desc_lim;
-	device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+	device_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G;
 }
 
 static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
drivers/net/e1000/em_ethdev.c +56 -60

151 lines not on this page · raw message

drivers/net/e1000/igb_ethdev.c +59 -52

146 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +4 -4
index 2e6ec60..f44818f 100644
@@ -1172,7 +1172,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	 * is no 50Gbps Ethernet. */
 	dev->data->dev_link.link_speed  = 0;
 	dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
@@ -1334,9 +1334,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
 
-	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
-					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
-					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+				ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+				ETH_LINK_SPEED_40G | ETH_LINK_SPEED_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +37 -36

146 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev_vf.c +6 -5
index 13c5b3d..dd8f1e2 100644
@@ -1911,13 +1911,14 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	 * DPDK pf host provide interfacet to acquire link status
 	 * while Linux driver does not
 	 */
-	if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
 		i40evf_get_link_status(dev, &new_link);
-	else {
+	} else {
 		/* Always assume it's up, for Linux driver PF host */
-		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-		new_link.link_speed  = ETH_LINK_SPEED_10000;
-		new_link.link_status = 1;
+		new_link.link_speed  = ETH_SPEED_NUM_10G;
+		new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+		new_link.link_autoneg = ETH_LINK_SPEED_NEG;
+		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +34 -44

153 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +4 -2
index c5688a7..01c3a5c 100644
@@ -4265,8 +4265,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
 
-	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
-					ETH_SPEED_CAP_56G;
+	info->speed_capa = ETH_LINK_SPEED_10G |ETH_LINK_SPEED_40G |
+					ETH_LINK_SPEED_56G;
 
 	priv_unlock(priv);
 }
@@ -4636,6 +4636,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)
 		dev_link.link_speed = link_speed;
 	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
+	dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
 		/* Link status changed. */
 		dev->data->dev_link = dev_link;
drivers/net/mpipe/mpipe_tilegx.c +4 -2
index 04f3c9f..ecb69b1 100644
@@ -388,14 +388,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 		speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+		new.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 		if (speed == GXIO_MPIPE_LINK_1G) {
 			new.link_speed = ETH_LINK_SPEED_1000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
 			new.link_speed = ETH_LINK_SPEED_10000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		}
 
 		rc = mpipe_link_compare(&old, &new);
drivers/net/nfp/nfp_net.c +2 -2
index 98a957a..adde1a2 100644
@@ -831,7 +831,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	/* Other cards can limit the tx and rx rate per VF */
-	link.link_speed = ETH_LINK_SPEED_40G;
+	link.link_speed = ETH_SPEED_NUM_40G;
 
 	if (old.link_status != link.link_status) {
 		nfp_net_dev_atomic_write_link_status(dev, &link);
@@ -1072,7 +1072,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 	dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
 
-	dev_info->speed_capa = ETH_SPEED_CAP_50G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G;
 }
 
 static uint32_t
drivers/net/null/rte_eth_null.c +3 -2
index 77fc988..55e1fc8 100644
@@ -93,9 +93,10 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG,
 };
 
 static uint16_t
drivers/net/pcap/rte_eth_pcap.c +5 -4
index f9230eb..650b521 100644
@@ -125,9 +125,10 @@ static int open_single_iface(const char *iface, pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED,
 };
 
 static int
@@ -430,7 +431,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -481,7 +482,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	}
 
 status_down:
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +3 -2
index d92b088..043175a 100644
@@ -71,9 +71,10 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/virtio/virtio_ethdev.c +1 -1
index caa970c..12e71af 100644
@@ -1381,7 +1381,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_read_link_status(dev, &link);
 	old = link;
-	link.link_duplex = FULL_DUPLEX;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	link.link_speed  = SPEED_10G;
 
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index fed9571..66423a0 100644
@@ -42,8 +42,6 @@
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_10G	10000
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -2
index c363bf6..2bb6ee9 100644
@@ -736,9 +736,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
 	if (ret & 0x1) {
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
+		link.link_autoneg = ETH_LINK_SPEED_FIXED;
 	}
 
 	vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -2
index 3f31806..0fcf5d3 100644
@@ -70,9 +70,10 @@ static int virtio_idx = 0;
 static const char *drivername = "xen virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED
 };
 
 static void
examples/ip_pipeline/config_parse.c +1 -2
index 1bedbe4..c581d41 100644
@@ -84,8 +84,7 @@ static const struct app_link_params link_params_default = {
 	.mac_addr = 0,
 
 	.conf = {
-		.link_speed = 0,
-		.link_duplex = 0,
+		.link_speeds = 0,
 		.rxmode = {
 			.mq_mode = ETH_MQ_RX_NONE,
 
lib/librte_ether/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ether/rte_ethdev.h +73 -40

141 lines not on this page · raw message

lib/librte_ether/rte_ether_version.map +6 -0
index d8db24d..2c14ad7 100644
@@ -117,3 +117,9 @@ DPDK_2.2 {
 
 	local: *;
 };
+
+DPDK_2.3 {
+	global:
+
+	rte_eth_speed_to_bm_flag;
+}DPDK_2.2;
Signature · 1 line
2.1.4
author
#49 lore raw

PATCH v8 4/4 doc: update with link changes

In reply to Marc Sune

Add new features, ABI changes and resolved issues notice for the refactored link patch.

---
 doc/guides/rel_notes/release_2_3.rst | 102 +++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 doc/guides/rel_notes/release_2_3.rst
doc/guides/rel_notes/release_2_3.rst new file +102 -0
new file mode 100644
index 0000000..b10c3bb
@@ -0,0 +1,102 @@
+DPDK Release 2.3
+================
+
+New Features
+------------
+
+* **ethdev: define a set of advertised link speeds.**
+
+  Allowing to define a set of advertised speeds for auto-negociation,
+  explicitely disable link auto-negociation (single speed) and full
+  auto-negociation.
+
+* **ethdev: add speed_cap bitmap to recover eth device link speed capabilities
+  define a set of advertised link speeds.**
+
+  ``struct rte_eth_dev_info`` has now speed_cap bitmap, which allows the
+  application to recover the supported speeds for that ethernet device.
+
+
+Resolved Issues
+---------------
+
+* **ethdev: Fixed link_speed overflow in rte_eth_link for 100Gbps.**
+
+  100Gbps in Mbps (100000) exceeds 16 bit max value of ``link_speed`` in
+  ``rte_eth_link``.
+
+
+EAL
+~~~
+
+
+Drivers
+~~~~~~~
+
+
+Libraries
+~~~~~~~~~
+
+
+Examples
+~~~~~~~~
+
+* New API call, rte_eth_speed_to_bm_flag(), in ethdev to map numerical speeds
+  to bitmap fields.
+
+
+Other
+~~~~~
+
+
+Known Issues
+------------
+
+
+API Changes
+-----------
+
+
+ABI Changes
+-----------
+
+* The ethdev rte_eth_link and rte_eth_conf structures were changed to
+  support the new link API, as well as ETH_LINK_HALF/FULL_DUPLEX.
+
+* The ethdev rte_eth_dev_info was changed to support device speed capabilities.
+
+
+Shared Library Versions
+-----------------------
+
+The libraries prepended with a plus sign were incremented in this version.
+
+.. code-block:: diff
+
+     libethdev.so.2
+     librte_acl.so.2
+     librte_cfgfile.so.2
+     librte_cmdline.so.1
+     librte_distributor.so.1
+     librte_eal.so.2
+     librte_hash.so.2
+     librte_ip_frag.so.1
+     librte_ivshmem.so.1
+     librte_jobstats.so.1
+     librte_kni.so.2
+     librte_kvargs.so.1
+     librte_lpm.so.2
+     librte_mbuf.so.2
+     librte_mempool.so.1
+     librte_meter.so.1
+     librte_pipeline.so.2
+     librte_pmd_bond.so.1
+     librte_pmd_ring.so.2
+     librte_port.so.2
+     librte_power.so.1
+     librte_reorder.so.1
+     librte_ring.so.1
+     librte_sched.so.1
+     librte_table.so.2
+     librte_timer.so.1
+     librte_vhost.so.2
Signature · 1 line
2.1.4
#37 lore raw

Re: [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc Sune
Quoted 17 lines · Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k
[...]

drivers/net/mlx5/mlx5_ethdev.c +0 -0
index 1159fa3..99dac09 100644

drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) · line 532

Quoted 10 lines
drivers/net/mlx5/mlx5_ethdev.c +5 -0
@@ -523,6 +523,11 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	 * size if it is not fixed.
 	 * The API should be updated to solve this problem. */
 	info->reta_size = priv->ind_table_max_size;
+
+	info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G |
+					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }

Hi Marc,

I have a question about this information, is it a list of the capabilities of the family or the capability of the NIC? Because with ConnectX4 family we have a range of NICs which does not support all this kind of speeds.

The speeds above are not completed the range is 1/10/25/40/50/100G.

Signature · 2 lines
Nélio Laranjeiro
6WIND
#44 lore raw

Re: [PATCH v8 3/4] ethdev: redesign link speed config API

In reply to Marc Sune
Quoted 25 lines · Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

[...]

drivers/net/mlx4/mlx4.c +2 -2
index c5688a7..01c3a5c 100644
@@ -4265,8 +4265,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
 
-	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
-					ETH_SPEED_CAP_56G;
+	info->speed_capa = ETH_LINK_SPEED_10G |ETH_LINK_SPEED_40G |
+					ETH_LINK_SPEED_56G;
 
 	priv_unlock(priv);
 }

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) · line 4643

Quoted 9 lines
drivers/net/mlx4/mlx4.c +2 -0
@@ -4636,6 +4636,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)
 		dev_link.link_speed = link_speed;
 	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
+	dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
 		/* Link status changed. */
 		dev->data->dev_link = dev_link;
[...]

The same modification are missing in mlx5.

Signature · 2 lines
Nélio Laranjeiro
6WIND
#38 lore raw

Re: [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

In reply to Nélio Laranjeiro

Hi, Marc,

Best Regards,
Mark

Quoted 42 lines

-----Original Message-----
From: Nélio Laranjeiro [mailto:[email protected]]
Sent: Monday, February 15, 2016 4:43 PM
To: Marc Sune
Cc: [email protected]; Lu, Wenzhuo; Zhang, Helin; Harish Patil; Chen, Jing D
Subject: Re: [dpdk-dev] [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

Quoted 12 lines · Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k
[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/mlx5/mlx5_ethdev.c

drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_infos_get(struct rte_eth_dev *dev,

Quoted 4 lines

index 1159fa3..99dac09 100644

drivers/net/mlx5/mlx5_ethdev.c +0 -0
@@ -523,6 +523,11 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev,

struct rte_eth_dev_info *info)

drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)

Quoted 6 lines
drivers/net/mlx5/mlx5_ethdev.c +3 -0
 	 * size if it is not fixed.
 	 * The API should be updated to solve this problem. */
 	info->reta_size = priv->ind_table_max_size;
+
+	info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G |
+					ETH_SPEED_CAP_10G |

ETH_SPEED_CAP_40G |

drivers/net/mlx5/mlx5_ethdev.c mlx5_dev_infos_get(struct rte_eth_dev *dev, · line 532

Quoted 4 lines
drivers/net/mlx5/mlx5_ethdev.c +2 -0
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }

Hi Marc,

Quoted 7 lines

I have a question about this information, is it a list of the capabilities of the family or the capability of the NIC? Because with ConnectX4 family we have a range of NICs which does not support all this kind of speeds.

The speeds above are not completed the range is 1/10/25/40/50/100G.

Fm10k also includes several cards and different ones are designed to have different speed. A better solution for fm10k is to acquire NIC type (like, BR card for 100G/40G, Atwood for 25/10G, etc) Then, return proper speed.

Quoted 3 lines

--
Nélio Laranjeiro
6WIND

author
#45 lore raw

Re: [PATCH v8 3/4] ethdev: redesign link speed config API

In reply to Nélio Laranjeiro
Quoted 32 lines · Nélio Laranjeiro

drivers/net/mlx4/mlx4.c mlx4_dev_infos_get(struct rte_eth_dev *dev, struct

Quoted 14 lines · Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

[...]

drivers/net/mlx4/mlx4.c +0 -0
index c5688a7..01c3a5c 100644
@@ -4265,8 +4265,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct

rte_eth_dev_info *info)

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev *dev,

Quoted 11 lines
drivers/net/mlx4/mlx4.c +2 -2
      if (priv_get_ifname(priv, &ifname) == 0)
              info->if_index = if_nametoindex(ifname);
 
-     info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
-                                     ETH_SPEED_CAP_56G;
+     info->speed_capa = ETH_LINK_SPEED_10G |ETH_LINK_SPEED_40G |
+                                     ETH_LINK_SPEED_56G;
 
      priv_unlock(priv);
 }
@@ -4636,6 +4636,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev,

int wait_to_complete)

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)

Quoted 3 lines
drivers/net/mlx4/mlx4.c +0 -0
              dev_link.link_speed = link_speed;
      dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
                              ETH_LINK_HALF_DUPLEX :

ETH_LINK_FULL_DUPLEX);

Quoted 10 lines

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete) · line 4643

Quoted 6 lines
drivers/net/mlx4/mlx4.c +2 -0
+     dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+                                             ETH_LINK_SPEED_NO_AUTONEG);
      if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
              /* Link status changed. */
              dev->data->dev_link = dev_link;
[...]

The same modification are missing in mlx5.

Damn.. are the required closed-source libraries for MLX4/5 available somewhere or is there a chance automatic builds can also compile drivers that require external dependencies (like this MLX)?

It is very prone to errors having to guess what is going to happen without being able to compile these drivers.

Marc

--

Quoted 3 lines

Nélio Laranjeiro
6WIND

#46 lore raw

Re: [PATCH v8 3/4] ethdev: redesign link speed config API

Hi Marc,

You can download MLNX_OFED from Mellanox web site:
http://www.mellanox.com/page/products_dyn?product_family=26&mtag=linux_sw_drivers

Best Regards,
Olga

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marc
Sent: Monday, February 15, 2016 1:00 PM
To: Nélio Laranjeiro
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v8 3/4] ethdev: redesign link speed config API

Quoted 34 lines · Nélio Laranjeiro
Quoted 14 lines · Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

[...]

drivers/net/mlx4/mlx4.c +0 -0
index c5688a7..01c3a5c 100644
@@ -4265,8 +4265,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, 
Quoted 1 line

struct

rte_eth_dev_info *info)

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev · line 4636

Quoted 12 lines
      if (priv_get_ifname(priv, &ifname) == 0)
              info->if_index = if_nametoindex(ifname);
drivers/net/mlx4/mlx4.c +2 -2
-     info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
-                                     ETH_SPEED_CAP_56G;
+     info->speed_capa = ETH_LINK_SPEED_10G |ETH_LINK_SPEED_40G |
+                                     ETH_LINK_SPEED_56G;
 
      priv_unlock(priv);
 }
@@ -4636,6 +4636,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev 
 *dev,

int wait_to_complete)

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)

Quoted 3 lines
drivers/net/mlx4/mlx4.c +0 -0
              dev_link.link_speed = link_speed;
      dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
                              ETH_LINK_HALF_DUPLEX :

ETH_LINK_FULL_DUPLEX);

Quoted 10 lines

drivers/net/mlx4/mlx4.c mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)

Quoted 6 lines
drivers/net/mlx4/mlx4.c +3 -0
+     dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+                                             
+ ETH_LINK_SPEED_NO_AUTONEG);
      if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
              /* Link status changed. */
              dev->data->dev_link = dev_link; [...]

The same modification are missing in mlx5.

Damn.. are the required closed-source libraries for MLX4/5 available somewhere or is there a chance automatic builds can also compile drivers that require external dependencies (like this MLX)?

It is very prone to errors having to guess what is going to happen without being able to compile these drivers.

Marc

--

Quoted 3 lines

Nélio Laranjeiro
6WIND

#39 lore raw

Re: [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc Sune

Hi Marc,

Quoted 26 lines · Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k

---
 drivers/net/bnx2x/bnx2x_ethdev.c |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  1 +
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 drivers/net/mlx5/mlx5_ethdev.c   |  5 +++++
 drivers/net/nfp/nfp_net.c        |  2 ++
 10 files changed, 48 insertions(+)

[...]

drivers/net/cxgbe/cxgbe_ethdev.c static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, · line 176

Quoted 11 lines
drivers/net/cxgbe/cxgbe_ethdev.c +1 -0
index 97ef152..203e119 100644
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 
 	device_info->rx_desc_lim = cxgbe_desc_lim;
 	device_info->tx_desc_lim = cxgbe_desc_lim;
+	device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
 }
 

Not all Chelsio NICs support _both_ 10G and 40G speed capabilities on a single card. You can query pi->link_cfg.supported to get the supported speeds. Check out print_port_info() in cxgbe_main.c to help you fill in your speed capabilities for Chelsio NICs.

Thanks,
Rahul

author
#40 lore raw

Re: [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

Rahul, Neilo, Jing D, et al

On 15 February 2016 at 15:43, Rahul Lakkireddy <[email protected]

Quoted 48 lines

wrote:

Hi Marc,

Quoted 26 lines · Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k

---
 drivers/net/bnx2x/bnx2x_ethdev.c |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  1 +
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 drivers/net/mlx5/mlx5_ethdev.c   |  5 +++++
 drivers/net/nfp/nfp_net.c        |  2 ++
 10 files changed, 48 insertions(+)

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/cxgbe/cxgbe_ethdev.c

drivers/net/cxgbe/cxgbe_ethdev.c static void cxgbe_dev_info_get(struct rte_eth_dev

Quoted 4 lines

index 97ef152..203e119 100644

drivers/net/cxgbe/cxgbe_ethdev.c +0 -0
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev

*eth_dev,

drivers/net/cxgbe/cxgbe_ethdev.c static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, · line 176

Quoted 6 lines
drivers/net/cxgbe/cxgbe_ethdev.c +1 -0
      device_info->rx_desc_lim = cxgbe_desc_lim;
      device_info->tx_desc_lim = cxgbe_desc_lim;
+     device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
 }
 
Quoted 5 lines

Not all Chelsio NICs support _both_ 10G and 40G speed capabilities on a single card. You can query pi->link_cfg.supported to get the supported speeds. Check out print_port_info() in cxgbe_main.c to help you fill in your speed capabilities for Chelsio NICs.

This patch series has been long delayed, and I've been requested to merge it for next release if possible. Most of the feedback has been coming late (not for cxgbe, which is introduced in this new v8, but it did for most of the rest of drivers).

My proposal is simply to add in this patch series ALL possible speeds for that driver. Other patches can be later submitted to adjust speeds according to specific device model.

marc

Quoted 4 lines

Thanks,
Rahul

#47 lore raw

Re: [PATCH v8 3/4] ethdev: redesign link speed config API

In reply to Marc Sune

Dňa 14.02.2016 o 23:17 Marc Sune napísal(a):

Quoted 54 lines

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint64_t to accomodate 100G speeds and beyond (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.
* Added rte_eth_speed_to_bm_flag() to version map.

---
  app/test-pipeline/init.c                  |   2 +-
  app/test-pmd/cmdline.c                    | 124 +++++++++++++++---------------
  app/test-pmd/config.c                     |   4 +-
  app/test/virtual_pmd.c                    |   4 +-
  drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
  drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
  drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
  drivers/net/cxgbe/base/t4_hw.c            |   8 +-
  drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
  drivers/net/e1000/em_ethdev.c             | 116 ++++++++++++++--------------
  drivers/net/e1000/igb_ethdev.c            | 111 +++++++++++++-------------
  drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
  drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++---------
  drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
  drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++-----------
  drivers/net/mlx4/mlx4.c                   |   6 +-
  drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
  drivers/net/nfp/nfp_net.c                 |   4 +-
  drivers/net/null/rte_eth_null.c           |   5 +-
  drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
  drivers/net/ring/rte_eth_ring.c           |   5 +-
  drivers/net/virtio/virtio_ethdev.c        |   2 +-
  drivers/net/virtio/virtio_ethdev.h        |   2 -
  drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
  drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
  examples/ip_pipeline/config_parse.c       |   3 +-
  lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
  lib/librte_ether/rte_ethdev.h             | 113 +++++++++++++++++----------
  lib/librte_ether/rte_ether_version.map    |   6 ++
  29 files changed, 443 insertions(+), 345 deletions(-)
Quoted 1 line

[...]

Hi,

some drivers (at least: e1000, i40e, ixgbe, mpipe, nfp, virtio, vmxnet3) use rte_atomic64_cmpset() to read and write link state like:

static inline int rte_em_dev_atomic_read_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)

{
        struct rte_eth_link *dst = link;
        struct rte_eth_link *src = &(dev->data->dev_link);

        if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
                                        *(uint64_t *)src) == 0)
                return -1;

        return 0;
}

static inline int rte_em_dev_atomic_write_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)

{
        struct rte_eth_link *dst = &(dev->data->dev_link);
        struct rte_eth_link *src = link;

        if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
                                        *(uint64_t *)src) == 0)
                return -1;

        return 0;
}

When link_speed is changed to uint64_t, struct rte_eth_link exceeds 64 bits. Shouldn't these functions be adapted in this patch series?

Szedata2 PMD will also use rte_atomic64_cmpset() after patch [1].
I can take care of this change in szedata2 PMD when patch [1] is accepted together with adjusting speeds in szedata2 PMD.

[1] http://dpdk.org/ml/archives/dev/2016-January/032281.html

Regards,
Matej

#41 lore raw

Re: [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc

Hi Marc,

Quoted 57 lines · Marc

Rahul, Neilo, Jing D, et al

On 15 February 2016 at 15:43, Rahul Lakkireddy <[email protected]

Quoted 48 lines

wrote:

Hi Marc,

Quoted 26 lines · Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k

---
 drivers/net/bnx2x/bnx2x_ethdev.c |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  1 +
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 drivers/net/mlx5/mlx5_ethdev.c   |  5 +++++
 drivers/net/nfp/nfp_net.c        |  2 ++
 10 files changed, 48 insertions(+)

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/cxgbe/cxgbe_ethdev.c

drivers/net/cxgbe/cxgbe_ethdev.c static void cxgbe_dev_info_get(struct rte_eth_dev

Quoted 4 lines

index 97ef152..203e119 100644

drivers/net/cxgbe/cxgbe_ethdev.c +0 -0
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev

*eth_dev,

drivers/net/cxgbe/cxgbe_ethdev.c static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev, · line 176

Quoted 6 lines
drivers/net/cxgbe/cxgbe_ethdev.c +1 -0
      device_info->rx_desc_lim = cxgbe_desc_lim;
      device_info->tx_desc_lim = cxgbe_desc_lim;
+     device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
 }
 
Quoted 5 lines

Not all Chelsio NICs support _both_ 10G and 40G speed capabilities on a single card. You can query pi->link_cfg.supported to get the supported speeds. Check out print_port_info() in cxgbe_main.c to help you fill in your speed capabilities for Chelsio NICs.

Quoted 8 lines

This patch series has been long delayed, and I've been requested to merge it for next release if possible. Most of the feedback has been coming late (not for cxgbe, which is introduced in this new v8, but it did for most of the rest of drivers).

My proposal is simply to add in this patch series ALL possible speeds for that driver. Other patches can be later submitted to adjust speeds according to specific device model.

I agree with this. I was asking in order to understand what your were expecting from this API, for me it is clear.

You should just maintain the current situation i.e. rte_eth_link.link_speed. This is already what your patches do.

For the link speed capability (aka device_info->speed_capa), you should add a new line "speed capability" in the doc/guides/nics/overview.rst. Those who think it is useful will implement it in their PMD.

Regards,

Signature · 2 lines
Nélio Laranjeiro
6WIND
#35 lore raw

Re: [PATCH v8 1/4] ethdev: Added ETH_SPEED_CAP bitmap for ports

In reply to Marc Sune
Quoted 23 lines · On Sun, 14 Feb 2016 23:17:36 +0100 Marc Sune <[email protected]> wrote:

Added constants and bitmap to struct rte_eth_dev_info to be used by PMDs.

---
 lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
lib/librte_ether/rte_ethdev.h +8 -0
index 16da821..83ddbb7 100644
@@ -824,6 +824,29 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
+/**
+ * Device supported speeds
+ */
+#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
+#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */

lib/librte_ether/rte_ethdev.h struct rte_eth_conf { · line 844

Quoted 10 lines
lib/librte_ether/rte_ethdev.h +10 -0
+#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */

Have you been following recent discussion about updates to ethtool in Linux https://lwn.net/Articles/667794/

author
#42 lore raw

Re: [PATCH v8 2/4] ethdev: Fill speed capability bitmaps in the PMDs

In reply to Nélio Laranjeiro
Quoted 76 lines · Nélio Laranjeiro

Hi Marc,

Quoted 3 lines · Marc

Rahul, Neilo, Jing D, et al

On 15 February 2016 at 15:43, Rahul Lakkireddy <

[email protected]

Quoted 42 lines
Quoted 42 lines

wrote:

Hi Marc,

Quoted 26 lines · Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k

---
 drivers/net/bnx2x/bnx2x_ethdev.c |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  1 +
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 drivers/net/mlx5/mlx5_ethdev.c   |  5 +++++
 drivers/net/nfp/nfp_net.c        |  2 ++
 10 files changed, 48 insertions(+)

[...]

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/cxgbe/cxgbe_ethdev.c

drivers/net/cxgbe/cxgbe_ethdev.c static void cxgbe_dev_info_get(struct rte_eth_dev

Quoted 4 lines

index 97ef152..203e119 100644

drivers/net/cxgbe/cxgbe_ethdev.c +0 -0
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev

*eth_dev,

Quoted 1 line
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
      device_info->rx_desc_lim = cxgbe_desc_lim;
      device_info->tx_desc_lim = cxgbe_desc_lim;

+ device_info->speed_capa = ETH_SPEED_CAP_10G |

ETH_SPEED_CAP_40G;

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

}

Not all Chelsio NICs support _both_ 10G and 40G speed capabilities on a single card. You can query pi->link_cfg.supported to get the supported speeds. Check out print_port_info() in cxgbe_main.c to help you fill in your speed capabilities for Chelsio NICs.

This patch series has been long delayed, and I've been requested to merge it for next release if possible. Most of the feedback has been coming

late

Quoted 1 line

(not for cxgbe, which is introduced in this new v8, but it did for most

of

Quoted 5 lines

the rest of drivers).

My proposal is simply to add in this patch series ALL possible speeds for that driver. Other patches can be later submitted to adjust speeds according to specific device model.

I agree with this. I was asking in order to understand what your were expecting from this API, for me it is clear.

Quoted 7 lines

You should just maintain the current situation i.e. rte_eth_link.link_speed. This is already what your patches do.

For the link speed capability (aka device_info->speed_capa), you should add a new line "speed capability" in the doc/guides/nics/overview.rst. Those who think it is useful will implement it in their PMD.

Noted for v9.

marc

Quoted 7 lines

Regards,

--
Nélio Laranjeiro
6WIND

author
#48 lore raw

Re: [PATCH v8 3/4] ethdev: redesign link speed config API

In reply to Matej Vido

Matej,

Quoted 97 lines · Matej Vido

Dňa 14.02.2016 o 23:17 Marc Sune napísal(a):

Quoted 58 lines

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint64_t to accomodate 100G speeds and beyond (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.
* Added rte_eth_speed_to_bm_flag() to version map.

---
  app/test-pipeline/init.c                  |   2 +-
  app/test-pmd/cmdline.c                    | 124
+++++++++++++++---------------
  app/test-pmd/config.c                     |   4 +-
  app/test/virtual_pmd.c                    |   4 +-
  drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
  drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
  drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
  drivers/net/cxgbe/base/t4_hw.c            |   8 +-
  drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
  drivers/net/e1000/em_ethdev.c             | 116
++++++++++++++--------------
  drivers/net/e1000/igb_ethdev.c            | 111
+++++++++++++-------------
  drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
  drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++---------
  drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
  drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++-----------
  drivers/net/mlx4/mlx4.c                   |   6 +-
  drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
  drivers/net/nfp/nfp_net.c                 |   4 +-
  drivers/net/null/rte_eth_null.c           |   5 +-
  drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
  drivers/net/ring/rte_eth_ring.c           |   5 +-
  drivers/net/virtio/virtio_ethdev.c        |   2 +-
  drivers/net/virtio/virtio_ethdev.h        |   2 -
  drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
  drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
  examples/ip_pipeline/config_parse.c       |   3 +-
  lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
  lib/librte_ether/rte_ethdev.h             | 113
+++++++++++++++++----------
  lib/librte_ether/rte_ether_version.map    |   6 ++
  29 files changed, 443 insertions(+), 345 deletions(-)
Quoted 2 lines

[...]

Hi,

some drivers (at least: e1000, i40e, ixgbe, mpipe, nfp, virtio, vmxnet3) use rte_atomic64_cmpset() to read and write link state like:

static inline int rte_em_dev_atomic_read_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)

{
        struct rte_eth_link *dst = link;
        struct rte_eth_link *src = &(dev->data->dev_link);

        if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
                                        *(uint64_t *)src) == 0)
                return -1;

        return 0;
}

static inline int rte_em_dev_atomic_write_link_status(struct rte_eth_dev *dev,
struct rte_eth_link *link)

{
        struct rte_eth_link *dst = &(dev->data->dev_link);
        struct rte_eth_link *src = link;

        if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
                                        *(uint64_t *)src) == 0)
                return -1;

        return 0;
}
Quoted 7 lines

When link_speed is changed to uint64_t, struct rte_eth_link exceeds 64 bits. Shouldn't these functions be adapted in this patch series?

Szedata2 PMD will also use rte_atomic64_cmpset() after patch [1]. I can take care of this change in szedata2 PMD when patch [1] is accepted together with adjusting speeds in szedata2 PMD.

Indeed, thanks. I will take care of them in v9 (incl. szedata2).

marc

Quoted 5 lines

[1] http://dpdk.org/ml/archives/dev/2016-January/032281.html

Regards,
Matej

#50 lore raw

Re: [PATCH v8 4/4] doc: update with link changes

In reply to Marc Sune

Hi,

Some minor comments below in order to get a consistent set of release notes.

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marc Sune
Sent: Sunday, February 14, 2016 10:18 PM
To: [email protected]; Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Harish Patil <[email protected]>; Chen, Jing D <[email protected]>
Subject: [dpdk-dev] [PATCH v8 4/4] doc: update with link changes

Quoted 6 lines

Add new features, ABI changes and resolved issues notice for the refactored link patch.

---
 doc/guides/rel_notes/release_2_3.rst | 102

This should be rebased and the notes added to doc/guides/rel_notes/release_16_04.rst.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+* **ethdev: define a set of advertised link speeds.**

The title and the text should be in the past tense.

See the hints/guidelines in the updated release notes:

    http://dpdk.org/browse/dpdk/tree/doc/guides/rel_notes/release_16_04.rst

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+  Allowing to define a set of advertised speeds for auto-negociation,

Maybe something like: Added functionality to allow the definition of advertised speeds for ...

Review

Quoted 3 lines
(quoted diff) +3 -0
+* **ethdev: add speed_cap bitmap to recover eth device link speed
+capabilities
+  define a set of advertised link speeds.**

The title is a little long. Just give a brief overview here and more the detail to the text sections.

Quoted 4 lines
(quoted diff) +3 -0
+
+  ``struct rte_eth_dev_info`` has now speed_cap bitmap, which allows
+ the  application to recover the supported speeds for that ethernet

device.

It would be good to use ```` quotes on speed_cap as well for consistency.

+

doc/guides/rel_notes/release_2_3.rst

Quoted 5 lines
doc/guides/rel_notes/release_2_3.rst new file +5 -0
+Examples
+~~~~~~~~
+
+* New API call, rte_eth_speed_to_bm_flag(), in ethdev to map numerical
+speeds  to bitmap fields.

I don't think this should be in the "Examples" section. Maybe as a sub-item in the "New Featrues" or in "API Changes" if it is a change.

Quoted 9 lines
doc/guides/rel_notes/release_2_3.rst new file +8 -0
+
+ABI Changes
+-----------
+
+* The ethdev rte_eth_link and rte_eth_conf structures were changed to
+  support the new link API, as well as ETH_LINK_HALF/FULL_DUPLEX.
+
+* The ethdev rte_eth_dev_info was changed to support device speed

capabilities.

Better to put the struct names and variables in ```` quotes.

Thanks,

John.
-

author
#51 lore raw

Re: [PATCH v8 4/4] doc: update with link changes

Quoted 82 lines · John

Hi,

Some minor comments below in order to get a consistent set of release notes.

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Marc Sune
Sent: Sunday, February 14, 2016 10:18 PM
To: [email protected]; Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Harish Patil <[email protected]>; Chen, Jing D <[email protected]>
Subject: [dpdk-dev] [PATCH v8 4/4] doc: update with link changes

Quoted 6 lines

Add new features, ABI changes and resolved issues notice for the refactored link patch.

---
 doc/guides/rel_notes/release_2_3.rst | 102

This should be rebased and the notes added to
doc/guides/rel_notes/release_16_04.rst.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+* **ethdev: define a set of advertised link speeds.**

The title and the text should be in the past tense.

See the hints/guidelines in the updated release notes:

http://dpdk.org/browse/dpdk/tree/doc/guides/rel_notes/release_16_04.rst

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+  Allowing to define a set of advertised speeds for auto-negociation,

Maybe something like: Added functionality to allow the definition of advertised speeds for ...

Review

Quoted 3 lines
(quoted diff) +3 -0
+* **ethdev: add speed_cap bitmap to recover eth device link speed
+capabilities
+  define a set of advertised link speeds.**

The title is a little long. Just give a brief overview here and more the detail
to the text sections.

Quoted 4 lines
(quoted diff) +3 -0
+
+  ``struct rte_eth_dev_info`` has now speed_cap bitmap, which allows
+ the  application to recover the supported speeds for that ethernet

device.

It would be good to use ```` quotes on speed_cap as well for consistency.

+

doc/guides/rel_notes/release_2_3.rst

Quoted 5 lines
doc/guides/rel_notes/release_2_3.rst new file +5 -0
+Examples
+~~~~~~~~
+
+* New API call, rte_eth_speed_to_bm_flag(), in ethdev to map numerical
+speeds  to bitmap fields.

I don't think this should be in the "Examples" section. Maybe as a sub-item in the "New Featrues" or in "API Changes" if it is a change.

Quoted 9 lines
doc/guides/rel_notes/release_2_3.rst new file +8 -0
+
+ABI Changes
+-----------
+
+* The ethdev rte_eth_link and rte_eth_conf structures were changed to
+  support the new link API, as well as ETH_LINK_HALF/FULL_DUPLEX.
+
+* The ethdev rte_eth_dev_info was changed to support device speed

capabilities.

Better to put the struct names and variables in ```` quotes.

Quoted 2 lines

Thanks,

Noted and fixed in v9.

Thanks
marc

Quoted 7 lines

John.
-

author
#52 lore raw

v9 cover ethdev: add speed capabilities and refactor link API

In reply to Marc Sune

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment
(checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a bitmap for defining the announced speeds, as suggested M. Brorup. Fixed spelling issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit value. Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in struct
rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver compilation and link speeds. Moved documentation to release_16_04.rst and fixed several issues. Upgrade NIC notes with speed capabilities.

Marc Sune (4):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes

 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124 +++++++++++++++---------------
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 doc/guides/nics/overview.rst              |   1 +
 doc/guides/rel_notes/release_16_04.rst    |  27 +++++++
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   7 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   1 +
 drivers/net/e1000/em_ethdev.c             | 112 ++++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c            | 107 +++++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c          |   6 +-
 drivers/net/i40e/i40e_ethdev.c            |  78 +++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  80 +++++++++----------
 drivers/net/mlx4/mlx4.c                   |   6 ++
 drivers/net/mlx5/mlx5_ethdev.c            |   7 ++
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             |  97 ++++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map    |   6 ++
 32 files changed, 501 insertions(+), 301 deletions(-)
Signature · 1 line
2.1.4
author
#53 lore raw

PATCH v9 1/4 ethdev: Added ETH_SPEED_CAP bitmap for ports

Added constants and bitmap to struct rte_eth_dev_info to be used by PMDs.

---
 lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
lib/librte_ether/rte_ethdev.h +24 -0
index 16da821..83ddbb7 100644
@@ -824,6 +824,29 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
+/**
+ * Device supported speeds
+ */
+#define ETH_SPEED_CAP_NOT_PHY	(0)  /*< No phy media > */
+#define ETH_SPEED_CAP_10M_HD	(1 << 0)  /*< 10 Mbps half-duplex> */
+#define ETH_SPEED_CAP_10M_FD	(1 << 1)  /*< 10 Mbps full-duplex> */
+#define ETH_SPEED_CAP_100M_HD	(1 << 2)  /*< 100 Mbps half-duplex> */
+#define ETH_SPEED_CAP_100M_FD	(1 << 3)  /*< 100 Mbps full-duplex> */
+#define ETH_SPEED_CAP_1G	(1 << 4)  /*< 1 Gbps > */
+#define ETH_SPEED_CAP_2_5G	(1 << 5)  /*< 2.5 Gbps > */
+#define ETH_SPEED_CAP_5G	(1 << 6)  /*< 5 Gbps > */
+#define ETH_SPEED_CAP_10G	(1 << 7)  /*< 10 Mbps > */
+#define ETH_SPEED_CAP_20G	(1 << 8)  /*< 20 Gbps > */
+#define ETH_SPEED_CAP_25G	(1 << 9)  /*< 25 Gbps > */
+#define ETH_SPEED_CAP_40G	(1 << 10)  /*< 40 Gbps > */
+#define ETH_SPEED_CAP_50G	(1 << 11)  /*< 50 Gbps > */
+#define ETH_SPEED_CAP_56G	(1 << 12)  /*< 56 Gbps > */
+#define ETH_SPEED_CAP_100G	(1 << 13)  /*< 100 Gbps > */
+
+
+/**
+ * Ethernet device information
+ */
 struct rte_eth_dev_info {
 	struct rte_pci_device *pci_dev; /**< Device PCI information. */
 	const char *driver_name; /**< Device Driver name. */
@@ -852,6 +875,7 @@ struct rte_eth_dev_info {
 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
 	struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
 	struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
+	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_SPEED_CAP_). */
 };
 
 /**
Signature · 1 line
2.1.4
author
#54 lore raw

PATCH v9 2/4 ethdev: Fill speed capability bitmaps in the PMDs

In reply to Marc Sune

Added speed capabilities to all pmds supporting physical NICs:

* e1000
* ixgbe
* i40
* bnx2x
* cxgbe
* mlx4
* mlx5
* nfp
* fm10k

---
 drivers/net/bnx2x/bnx2x_ethdev.c |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c |  1 +
 drivers/net/e1000/em_ethdev.c    |  6 ++++++
 drivers/net/e1000/igb_ethdev.c   |  6 ++++++
 drivers/net/fm10k/fm10k_ethdev.c |  4 ++++
 drivers/net/i40e/i40e_ethdev.c   |  9 +++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c | 10 ++++++++++
 drivers/net/mlx4/mlx4.c          |  4 ++++
 drivers/net/mlx5/mlx5_ethdev.c   |  7 +++++++
 drivers/net/nfp/nfp_net.c        |  2 ++
 10 files changed, 50 insertions(+)
drivers/net/bnx2x/bnx2x_ethdev.c +1 -0
index 69df02e..b547ac3 100644
@@ -347,6 +347,7 @@ bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_inf
 	dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
 	dev_info->max_rx_pktlen  = BNX2X_MAX_RX_PKT_LEN;
 	dev_info->max_mac_addrs  = BNX2X_MAX_MAC_ADDRS;
+	dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_20G;
 }
 
 static void
drivers/net/cxgbe/cxgbe_ethdev.c +1 -0
index 97ef152..203e119 100644
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 
 	device_info->rx_desc_lim = cxgbe_desc_lim;
 	device_info->tx_desc_lim = cxgbe_desc_lim;
+	device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
 }
 
 static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
drivers/net/e1000/em_ethdev.c +6 -0
index 4a843fe..e40dc37 100644
@@ -1023,6 +1023,12 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_min = E1000_MIN_RING_DESC,
 		.nb_align = EM_TXD_ALIGN,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 /* return 0 means link status changed, -1 means not changed */
drivers/net/e1000/igb_ethdev.c +6 -0
index 4ed5e95..7eac8ea 100644
@@ -1908,6 +1908,12 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_10M_HD |
+					ETH_SPEED_CAP_10M_FD |
+					ETH_SPEED_CAP_100M_HD |
+					ETH_SPEED_CAP_100M_FD |
+					ETH_SPEED_CAP_1G;
 }
 
 static void
drivers/net/fm10k/fm10k_ethdev.c +4 -0
index 421266b..2e6ec60 100644
@@ -1333,6 +1333,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_min = FM10K_MIN_TX_DESC,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
+					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
+					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +9 -0
index ef24122..78a0cbd 100644
@@ -2233,6 +2233,7 @@ static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vsi *vsi = pf->main_vsi;
 
 	dev_info->max_rx_queues = vsi->nb_qps;
@@ -2304,6 +2305,14 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->max_rx_queues += dev_info->vmdq_queue_num;
 		dev_info->max_tx_queues += dev_info->vmdq_queue_num;
 	}
+
+	if (i40e_is_40G_device(hw->device_id))
+		/* For XL710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+	else
+		/* For X710 */
+		dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+
 }
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +10 -0
index 3e6fe86..7e29c18 100644
@@ -2827,6 +2827,16 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
 	dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
 	dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G;
+
+	if (hw->mac.type == ixgbe_mac_X540 ||
+	    hw->mac.type == ixgbe_mac_X540_vf ||
+	    hw->mac.type == ixgbe_mac_X550 ||
+	    hw->mac.type == ixgbe_mac_X550_vf)
+
+		dev_info->speed_capa |= ETH_SPEED_CAP_100M_FD /*|
+					ETH_SPEED_CAP_100M_HD*/;
 }
 
 static void
drivers/net/mlx4/mlx4.c +4 -0
index ee00151..c5688a7 100644
@@ -4264,6 +4264,10 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		 0);
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
+
+	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_56G;
+
 	priv_unlock(priv);
 }
 
drivers/net/mlx5/mlx5_ethdev.c +7 -0
index 1159fa3..9c997c5 100644
@@ -523,6 +523,13 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	 * size if it is not fixed.
 	 * The API should be updated to solve this problem. */
 	info->reta_size = priv->ind_table_max_size;
+
+	info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G |
+					ETH_SPEED_CAP_25G |
+					ETH_SPEED_CAP_40G |
+					ETH_SPEED_CAP_50G |
+					ETH_SPEED_CAP_100G;
+
 	priv_unlock(priv);
 }
 
drivers/net/nfp/nfp_net.c +2 -0
index fd4dd39..98a957a 100644
@@ -1071,6 +1071,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 	dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+
+	dev_info->speed_capa = ETH_SPEED_CAP_50G | ETH_SPEED_CAP_100G;
 }
 
 static uint32_t
Signature · 1 line
2.1.4
author
#55 lore raw

PATCH v9 3/4 ethdev: redesign link speed config API

In reply to Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds and beyond (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.
* Added rte_eth_speed_to_bm_flag() to version map.

---
 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124 +++++++++++++++---------------
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
 drivers/net/e1000/em_ethdev.c             | 116 ++++++++++++++--------------
 drivers/net/e1000/igb_ethdev.c            | 111 +++++++++++++-------------
 drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
 drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++-----------
 drivers/net/mlx4/mlx4.c                   |   6 +-
 drivers/net/mlx5/mlx5_ethdev.c            |  10 +--
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             | 113 +++++++++++++++++----------
 lib/librte_ether/rte_ether_version.map    |   6 ++
 30 files changed, 448 insertions(+), 350 deletions(-)
app/test-pipeline/init.c +1 -1
index db2196b..6a69fe2 100644
@@ -200,7 +200,7 @@ app_ports_check_link(void)
 		port = (uint8_t) app.ports[i];
 		memset(&link, 0, sizeof(link));
 		rte_eth_link_get_nowait(port, &link);
-		RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n",
+		RTE_LOG(INFO, USER1, "Port %u (%d Gbps) %s\n",
 			port,
 			link.link_speed / 1000,
 			link.link_status ? "UP" : "DOWN");
app/test-pmd/cmdline.c +64 -60

162 lines not on this page · raw message

app/test-pmd/config.c +2 -2
index 0062484..d43f64f 100644
@@ -2241,7 +2241,7 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate)
 		return 1;
 	rte_eth_link_get_nowait(port_id, &link);
 	if (rate > link.link_speed) {
-		printf("Invalid rate value:%u bigger than link speed: %u\n",
+		printf("Invalid rate value:%u bigger than link speed: %d\n",
 			rate, link.link_speed);
 		return 1;
 	}
@@ -2266,7 +2266,7 @@ set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk)
 		return 1;
 	rte_eth_link_get_nowait(port_id, &link);
 	if (rate > link.link_speed) {
-		printf("Invalid rate value:%u bigger than link speed: %u\n",
+		printf("Invalid rate value:%u bigger than link speed: %d\n",
 			rate, link.link_speed);
 		return 1;
 	}
app/test/virtual_pmd.c +2 -2
index a538c8a..3c4040b 100644
@@ -603,8 +603,8 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
-	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +3 -2
index 767f36b..5db1db2 100644
@@ -116,9 +116,10 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/bnx2x/bnx2x_ethdev.c +6 -2
index b547ac3..efefae6 100644
@@ -45,8 +45,12 @@ bnx2x_link_update(struct rte_eth_dev *dev)
 			dev->data->dev_link.link_duplex = ETH_LINK_HALF_DUPLEX;
 			break;
 		default:
-			dev->data->dev_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
+			break;
 	}
+
+	dev->data->dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
+
 	dev->data->dev_link.link_status = sc->link_vars.link_up;
 }
 
@@ -347,7 +351,7 @@ bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_inf
 	dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
 	dev_info->max_rx_pktlen  = BNX2X_MAX_RX_PKT_LEN;
 	dev_info->max_mac_addrs  = BNX2X_MAX_MAC_ADDRS;
-	dev_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_20G;
+	dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
 }
 
 static void
drivers/net/bonding/rte_eth_bond_8023ad.c +7 -7
index b3b30f6..3b446e1 100644
@@ -708,25 +708,25 @@ link_speed_key(uint16_t speed) {
 	uint16_t key_speed;
 
 	switch (speed) {
-	case ETH_LINK_SPEED_AUTONEG:
+	case ETH_SPEED_NUM_NONE:
 		key_speed = 0x00;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		key_speed = BOND_LINK_SPEED_KEY_10M;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		key_speed = BOND_LINK_SPEED_KEY_100M;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		key_speed = BOND_LINK_SPEED_KEY_1000M;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		key_speed = BOND_LINK_SPEED_KEY_10G;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		key_speed = BOND_LINK_SPEED_KEY_20G;
 		break;
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		key_speed = BOND_LINK_SPEED_KEY_40G;
 		break;
 	default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		if (stat & F_FW_PORT_CMD_TXPAUSE)
 			fc |= PAUSE_TX;
 		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-			speed = ETH_LINK_SPEED_100;
+			speed = ETH_SPEED_NUM_100M;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-			speed = ETH_LINK_SPEED_1000;
+			speed = ETH_SPEED_NUM_1G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-			speed = ETH_LINK_SPEED_10000;
+			speed = ETH_SPEED_NUM_10G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-			speed = ETH_LINK_SPEED_40G;
+			speed = ETH_SPEED_NUM_40G;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
drivers/net/cxgbe/cxgbe_ethdev.c +1 -1
index 203e119..05b954d 100644
@@ -171,7 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 
 	device_info->rx_desc_lim = cxgbe_desc_lim;
 	device_info->tx_desc_lim = cxgbe_desc_lim;
-	device_info->speed_capa = ETH_SPEED_CAP_10G | ETH_SPEED_CAP_40G;
+	device_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G;
 }
 
 static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
drivers/net/e1000/em_ethdev.c +56 -60

151 lines not on this page · raw message

drivers/net/e1000/igb_ethdev.c +59 -52

146 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +4 -4
index 2e6ec60..f44818f 100644
@@ -1172,7 +1172,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	 * is no 50Gbps Ethernet. */
 	dev->data->dev_link.link_speed  = 0;
 	dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
@@ -1334,9 +1334,9 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
 
-	dev_info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_2_5G |
-					ETH_SPEED_CAP_10G | ETH_SPEED_CAP_25G |
-					ETH_SPEED_CAP_40G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+				ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+				ETH_LINK_SPEED_40G | ETH_LINK_SPEED_100G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +37 -36

146 lines not on this page · raw message

drivers/net/i40e/i40e_ethdev_vf.c +6 -5
index 13c5b3d..dd8f1e2 100644
@@ -1911,13 +1911,14 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	 * DPDK pf host provide interfacet to acquire link status
 	 * while Linux driver does not
 	 */
-	if (vf->version_major == I40E_DPDK_VERSION_MAJOR)
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
 		i40evf_get_link_status(dev, &new_link);
-	else {
+	} else {
 		/* Always assume it's up, for Linux driver PF host */
-		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-		new_link.link_speed  = ETH_LINK_SPEED_10000;
-		new_link.link_status = 1;
+		new_link.link_speed  = ETH_SPEED_NUM_10G;
+		new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+		new_link.link_autoneg = ETH_LINK_SPEED_NEG;
+		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +34 -44

153 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +4 -2
index c5688a7..01c3a5c 100644
@@ -4265,8 +4265,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
 
-	info->speed_capa = ETH_SPEED_CAP_10G |ETH_SPEED_CAP_40G |
-					ETH_SPEED_CAP_56G;
+	info->speed_capa = ETH_LINK_SPEED_10G |ETH_LINK_SPEED_40G |
+					ETH_LINK_SPEED_56G;
 
 	priv_unlock(priv);
 }
@@ -4636,6 +4636,8 @@ mlx4_link_update_unlocked(struct rte_eth_dev *dev, int wait_to_complete)
 		dev_link.link_speed = link_speed;
 	dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
+	dev_link.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 	if (memcmp(&dev_link, &dev->data->dev_link, sizeof(dev_link))) {
 		/* Link status changed. */
 		dev->data->dev_link = dev_link;
drivers/net/mlx5/mlx5_ethdev.c +5 -5
index 9c997c5..48de24e 100644
@@ -524,11 +524,11 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	 * The API should be updated to solve this problem. */
 	info->reta_size = priv->ind_table_max_size;
 
-	info->speed_capa = ETH_SPEED_CAP_1G | ETH_SPEED_CAP_10G |
-					ETH_SPEED_CAP_25G |
-					ETH_SPEED_CAP_40G |
-					ETH_SPEED_CAP_50G |
-					ETH_SPEED_CAP_100G;
+	info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
+						ETH_LINK_SPEED_25G |
+						ETH_LINK_SPEED_40G |
+						ETH_LINK_SPEED_50G |
+						ETH_LINK_SPEED_100G;
 
 	priv_unlock(priv);
 }
drivers/net/mpipe/mpipe_tilegx.c +4 -2
index 04f3c9f..ecb69b1 100644
@@ -388,14 +388,16 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 		speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
+		new.link_autoneg = ~(dev->data->dev_conf.link_speeds &
+						ETH_LINK_SPEED_NO_AUTONEG);
 		if (speed == GXIO_MPIPE_LINK_1G) {
 			new.link_speed = ETH_LINK_SPEED_1000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
 			new.link_speed = ETH_LINK_SPEED_10000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		}
 
 		rc = mpipe_link_compare(&old, &new);
drivers/net/nfp/nfp_net.c +2 -2
index 98a957a..adde1a2 100644
@@ -831,7 +831,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	/* Other cards can limit the tx and rx rate per VF */
-	link.link_speed = ETH_LINK_SPEED_40G;
+	link.link_speed = ETH_SPEED_NUM_40G;
 
 	if (old.link_status != link.link_status) {
 		nfp_net_dev_atomic_write_link_status(dev, &link);
@@ -1072,7 +1072,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 	dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
 
-	dev_info->speed_capa = ETH_SPEED_CAP_50G | ETH_SPEED_CAP_100G;
+	dev_info->speed_capa = ETH_LINK_SPEED_50G | ETH_LINK_SPEED_100G;
 }
 
 static uint32_t
drivers/net/null/rte_eth_null.c +3 -2
index 77fc988..55e1fc8 100644
@@ -93,9 +93,10 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
+	.link_autoneg = ETH_LINK_SPEED_NEG,
 };
 
 static uint16_t
drivers/net/pcap/rte_eth_pcap.c +5 -4
index f9230eb..650b521 100644
@@ -125,9 +125,10 @@ static int open_single_iface(const char *iface, pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED,
 };
 
 static int
@@ -430,7 +431,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -481,7 +482,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	}
 
 status_down:
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +3 -2
index d92b088..043175a 100644
@@ -71,9 +71,10 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_NEG
 };
 
 static uint16_t
drivers/net/virtio/virtio_ethdev.c +1 -1
index caa970c..12e71af 100644
@@ -1381,7 +1381,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_read_link_status(dev, &link);
 	old = link;
-	link.link_duplex = FULL_DUPLEX;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	link.link_speed  = SPEED_10G;
 
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index fed9571..66423a0 100644
@@ -42,8 +42,6 @@
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_10G	10000
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -2
index c363bf6..2bb6ee9 100644
@@ -736,9 +736,10 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
 	if (ret & 0x1) {
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
+		link.link_autoneg = ETH_LINK_SPEED_FIXED;
 	}
 
 	vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -2
index 3f31806..0fcf5d3 100644
@@ -70,9 +70,10 @@ static int virtio_idx = 0;
 static const char *drivername = "xen virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
+		.link_autoneg = ETH_LINK_SPEED_FIXED
 };
 
 static void
examples/ip_pipeline/config_parse.c +1 -2
index 1bedbe4..c581d41 100644
@@ -84,8 +84,7 @@ static const struct app_link_params link_params_default = {
 	.mac_addr = 0,
 
 	.conf = {
-		.link_speed = 0,
-		.link_duplex = 0,
+		.link_speeds = 0,
 		.rxmode = {
 			.mq_mode = ETH_MQ_RX_NONE,
 
lib/librte_ether/rte_ethdev.c +49 -0

55 lines not on this page · raw message

lib/librte_ether/rte_ethdev.h +73 -40

141 lines not on this page · raw message

lib/librte_ether/rte_ether_version.map +6 -0
index d8db24d..2c14ad7 100644
@@ -117,3 +117,9 @@ DPDK_2.2 {
 
 	local: *;
 };
+
+DPDK_2.3 {
+	global:
+
+	rte_eth_speed_to_bm_flag;
+}DPDK_2.2;
Signature · 1 line
2.1.4
author
#59 lore raw

PATCH v9 4/4 doc: update with link changes

In reply to Marc Sune

Add new features, ABI changes and resolved issues notice for the refactored link patch.

---
 doc/guides/nics/overview.rst           |  1 +
 doc/guides/rel_notes/release_16_04.rst | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
doc/guides/nics/overview.rst +1 -0
index d4c6ff4..6c1ae33 100644
@@ -88,6 +88,7 @@ Most of these differences are summarized below.
    ==================== = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    link status
    link status event
+   Speed capabilities
    Rx interrupt
    queue start/stop
    MTU update
doc/guides/rel_notes/release_16_04.rst +27 -0
index 64e913d..fd2d3cc 100644
@@ -20,6 +20,18 @@ Build the docs and view the output file to ensure the changes are correct::
 New Features
 ------------
 
+* **ethdev: define a set of advertised link speeds.**
+
+  Added functionality to Allow defining a set of advertised speeds for
+  auto-negociation, explicitely disabling link auto-negociation (single speed)
+  and full auto-negociation.
+
+* **ethdev: add speed_cap bitmap for link speed capabilities.**
+
+  ``struct rte_eth_dev_info`` has now ``speed_cap`` bitmap, which allows the
+  application to recover the supported speeds for that ethernet device.
+
+
 This section should contain new features added in this release. Sample format:
 
 * **Add a title in the past tense with a full stop.**
@@ -55,6 +67,11 @@ This section should contain new features added in this release. Sample format:
 Resolved Issues
 ---------------
 
+* **ethdev: Fixed link_speed overflow in rte_eth_link for 100Gbps.**
+
+  100Gbps in Mbps (100000) exceeds 16 bit max value of ``link_speed`` in
+  ``rte_eth_link``.
+
 This section should contain bug fixes added to the relevant sections. Sample format:
 
 * **code/section Fixed issue in the past tense with a full stop.**
@@ -87,6 +104,9 @@ Drivers
 Libraries
 ~~~~~~~~~
 
+* New API call, ``rte_eth_speed_to_bm_flag`` in ethdev to, map numerical speeds
+  to bitmap fields.
+
 
 Examples
 ~~~~~~~~
@@ -119,6 +139,13 @@ This section should contain API changes. Sample format:
 ABI Changes
 -----------
 
+* The ethdev ``rte_eth_link`` and ``rte_eth_conf`` structures were changed to
+  support the new link API, as well as ``ETH_LINK_HALF``/``FULL_DUPLEX``.
+
+* The ethdev ``rte_eth_dev_info`` was changed to support device speed
+  capabilities.
+
+
 * Add a short 1-2 sentence description of the ABI change that was announced in
   the previous releases and made in this release. Use fixed width quotes for
   ``rte_function_names`` or ``rte_struct_names``. Use the past tense.
Signature · 1 line
2.1.4
author
#60 lore raw
In reply to Marc Sune

2016-03-01 1:45 GMT+01:00 Marc Sune <[email protected]>:

Quoted 69 lines

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it
is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing
and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment
(checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a
bitmap
for defining the announced speeds, as suggested M. Brorup. Fixed
spelling
issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current
HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit
value.
Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

Quoted 7 lines

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in struct
rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver
compilation
and link speeds. Moved documentation to release_16_04.rst and fixed
several
issues. Upgrade NIC notes with speed capabilities.

Anyone interested in reviewing and _testing_ this series?

Thank you
Marc

Quoted 47 lines

Marc Sune (4):
ethdev: Added ETH_SPEED_CAP bitmap for ports
ethdev: Fill speed capability bitmaps in the PMDs
ethdev: redesign link speed config API
doc: update with link changes

 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124
+++++++++++++++---------------
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 doc/guides/nics/overview.rst              |   1 +
 doc/guides/rel_notes/release_16_04.rst    |  27 +++++++
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   7 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   1 +
 drivers/net/e1000/em_ethdev.c             | 112
++++++++++++++-------------
 drivers/net/e1000/igb_ethdev.c            | 107 +++++++++++++++-----------
 drivers/net/fm10k/fm10k_ethdev.c          |   6 +-
 drivers/net/i40e/i40e_ethdev.c            |  78 +++++++++++--------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  80 +++++++++----------
 drivers/net/mlx4/mlx4.c                   |   6 ++
 drivers/net/mlx5/mlx5_ethdev.c            |   7 ++
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             |  97 ++++++++++++++++++-----
 lib/librte_ether/rte_ether_version.map    |   6 ++
 32 files changed, 501 insertions(+), 301 deletions(-)

--
2.1.4

#61 lore raw
Quoted 79 lines · Marc Sune

2016-03-01 1:45 GMT+01:00 Marc Sune <[email protected]>:

Quoted 69 lines

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it
is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing
and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment
(checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a
bitmap
for defining the announced speeds, as suggested M. Brorup. Fixed
spelling
issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current
HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit
value.
Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

Quoted 7 lines

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in struct
rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver
compilation
and link speeds. Moved documentation to release_16_04.rst and fixed
several
issues. Upgrade NIC notes with speed capabilities.

Quoted 4 lines

Anyone interested in reviewing and _testing_ this series?

Thank you
Marc

Hi Marc,

I will take a look tomorrow morning and run test on Mellanox NICs (ConnectX 3 and 4).

I do not have access to the others NICs, if those who have can do it, could be really great.

Regards,

Signature · 2 lines
Nélio Laranjeiro
6WIND
#56 lore raw

Re: [PATCH v9 3/4] ethdev: redesign link speed config API

In reply to Marc Sune

Hi Marc,

A small remark bellow.

Quoted 73 lines · Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds and beyond (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.
* Added rte_eth_speed_to_bm_flag() to version map.

---
 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124 +++++++++++++++---------------
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
 drivers/net/e1000/em_ethdev.c             | 116 ++++++++++++++--------------
 drivers/net/e1000/igb_ethdev.c            | 111 +++++++++++++-------------
 drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
 drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++-----------
 drivers/net/mlx4/mlx4.c                   |   6 +-
 drivers/net/mlx5/mlx5_ethdev.c            |  10 +--
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             | 113 +++++++++++++++++----------
 lib/librte_ether/rte_ether_version.map    |   6 ++
 30 files changed, 448 insertions(+), 350 deletions(-)
app/test-pipeline/init.c +1 -1
index db2196b..6a69fe2 100644
@@ -200,7 +200,7 @@ app_ports_check_link(void)
 		port = (uint8_t) app.ports[i];
 		memset(&link, 0, sizeof(link));
 		rte_eth_link_get_nowait(port, &link);
-		RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n",
+		RTE_LOG(INFO, USER1, "Port %u (%d Gbps) %s\n",
 			port,
 			link.link_speed / 1000,
 			link.link_status ? "UP" : "DOWN");
app/test-pmd/cmdline.c +0 -0
index 52e9f5f..57ad25f 100644

app/test-pmd/cmdline.c struct cmd_config_speed_all { · line 960

Quoted 5 lines
app/test-pmd/cmdline.c +2 -0
@@ -956,14 +956,65 @@ struct cmd_config_speed_all {
 	cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *value1, char *value2, uint32_t *link_speed)

"value" variables should have the more friendly name, we need to read the code to understand what is value1 and value2.

Quoted 1 line

[...]

Signature · 2 lines
Nélio Laranjeiro
6WIND
#62 lore raw
In reply to Nélio Laranjeiro
Quoted 87 lines · Nélio Laranjeiro
Quoted 79 lines · Marc Sune

2016-03-01 1:45 GMT+01:00 Marc Sune <[email protected]>:

Quoted 69 lines

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it
is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing
and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment
(checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a
bitmap
for defining the announced speeds, as suggested M. Brorup. Fixed
spelling
issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current
HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit
value.
Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

Quoted 7 lines

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in struct
rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver
compilation
and link speeds. Moved documentation to release_16_04.rst and fixed
several
issues. Upgrade NIC notes with speed capabilities.

Quoted 4 lines

Anyone interested in reviewing and _testing_ this series?

Thank you
Marc

Hi Marc,

Quoted 7 lines

I will take a look tomorrow morning and run test on Mellanox NICs (ConnectX 3 and 4).

I do not have access to the others NICs, if those who have can do it, could be really great.

Regards,

It works as expected with Mellanox NICs.

Regards,

Signature · 2 lines
Nélio Laranjeiro
6WIND
#63 lore raw
Quoted 91 lines · Nélio Laranjeiro
Quoted 90 lines · Nélio Laranjeiro
Quoted 79 lines · Marc Sune

2016-03-01 1:45 GMT+01:00 Marc Sune <[email protected]>:

Quoted 69 lines

The current rte_eth_dev_info abstraction does not provide any mechanism to get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done based on the driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does not provide all the supported capabilities of the ethdev iii) for some drivers it
is impossible determine correctly the (max) speed by the application (e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of advertised link speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for most of the PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing
and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment
(checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a
bitmap
for defining the announced speeds, as suggested M. Brorup. Fixed
spelling
issues.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current
HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit
value.
Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

Quoted 7 lines

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in struct
rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver
compilation
and link speeds. Moved documentation to release_16_04.rst and fixed
several
issues. Upgrade NIC notes with speed capabilities.

Quoted 4 lines

Anyone interested in reviewing and _testing_ this series?

Thank you
Marc

Hi Marc,

I will take a look tomorrow morning and run test on Mellanox NICs (ConnectX 3 and 4).

Quoted 12 lines
Quoted 4 lines

I do not have access to the others NICs, if those who have can do it, could be really great.

Regards,

It works as expected with Mellanox NICs.

Regards,

Signature · 2 lines
Nélio Laranjeiro
6WIND

- OS/Kernel: Debian 8/3.16.0-4-amd64
- GCC: gcc (Debian 4.9.2-10) 4.9.2
- CPU: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
- MLNX OFED: 3.2-2.0.0.0
- NIC: ConnectX 4 100G

- OS/Kernel: Debian 7/3.16.0-0.bpo.4-amd64
- GCC: gcc (Debian 4.7.2-5) 4.7.2
- CPU: Intel(R) Xeon(R) CPU E5-2648L 0 @ 1.80GHz
- MLNX OFED: 3.2-2.0.0.0
- NIC: ConnectX 3 Pro

1. Link displayed at the correct negotiated speed:
- 40Gbps for ConnectX3 Pro
- 100Gbps for ConnectX4 100G
- 40Gbps for ConnectX4 100G on a 40G link.

2. Configuring speed:
- Not supported yet for Mellanox as expected.

Signature · 2 lines
Nélio Laranjeiro
6WIND
author
#57 lore raw

Re: [PATCH v9 3/4] ethdev: redesign link speed config API

In reply to Nélio Laranjeiro
Quoted 85 lines · Nélio Laranjeiro

Hi Marc,

A small remark bellow.

Quoted 21 lines · Marc Sune

This patch redesigns the API to set the link speed/s configure for an ethernet port. Specifically:

- it allows to define a set of advertised speeds for auto-negociation.
- it allows to disable link auto-negociation (single fixed speed).
- default: auto-negociate all supported speeds.

Other changes:

* Added utility MACROs ETH_SPEED_NUM_XXX with the numeric values of all supported link speeds, in Mbps.
* Converted link_speed to uint32_t to accomodate 100G speeds and beyond (bug).
* Added autoneg flag in struct rte_eth_link to indicate if link speed was a result of auto-negociation or was fixed by configuration.
* Added utility function to convert numeric speeds to bitmap fields.
* Added rte_eth_speed_to_bm_flag() to version map.

Quoted 4 lines
---
 app/test-pipeline/init.c                  |   2 +-
 app/test-pmd/cmdline.c                    | 124

+++++++++++++++---------------

Quoted 8 lines
 app/test-pmd/config.c                     |   4 +-
 app/test/virtual_pmd.c                    |   4 +-
 drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
 drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
 drivers/net/cxgbe/base/t4_hw.c            |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
 drivers/net/e1000/em_ethdev.c             | 116

++++++++++++++--------------

Quoted 1 line
 drivers/net/e1000/igb_ethdev.c            | 111

+++++++++++++-------------

Quoted 10 lines
 drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
 drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++---------
 drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
 drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++-----------
 drivers/net/mlx4/mlx4.c                   |   6 +-
 drivers/net/mlx5/mlx5_ethdev.c            |  10 +--
 drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
 drivers/net/nfp/nfp_net.c                 |   4 +-
 drivers/net/null/rte_eth_null.c           |   5 +-
 drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
Quoted 8 lines
 drivers/net/ring/rte_eth_ring.c           |   5 +-
 drivers/net/virtio/virtio_ethdev.c        |   2 +-
 drivers/net/virtio/virtio_ethdev.h        |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
 examples/ip_pipeline/config_parse.c       |   3 +-
 lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++
 lib/librte_ether/rte_ethdev.h             | 113

+++++++++++++++++----------

Quoted 24 lines
 lib/librte_ether/rte_ether_version.map    |   6 ++
 30 files changed, 448 insertions(+), 350 deletions(-)
app/test-pipeline/init.c +1 -1
index db2196b..6a69fe2 100644
@@ -200,7 +200,7 @@ app_ports_check_link(void)
              port = (uint8_t) app.ports[i];
              memset(&link, 0, sizeof(link));
              rte_eth_link_get_nowait(port, &link);
-             RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n",
+             RTE_LOG(INFO, USER1, "Port %u (%d Gbps) %s\n",
                      port,
                      link.link_speed / 1000,
                      link.link_status ? "UP" : "DOWN");
app/test-pmd/cmdline.c +0 -0
index 52e9f5f..57ad25f 100644
@@ -956,14 +956,65 @@ struct cmd_config_speed_all {
      cmdline_fixed_string_t value2;
 };
 
Quoted 8 lines

app/test-pmd/cmdline.c struct cmd_config_speed_all { · line 960

Quoted 2 lines
app/test-pmd/cmdline.c +2 -0
+static int
+parse_and_check_speed_duplex(char *value1, char *value2, uint32_t

*link_speed)

"value" variables should have the more friendly name, we need to read the code to understand what is value1 and value2.

Hello,

Ok, but note that the entire source code of cmdline.c uses value1 and value2 to reference speed and duplex mode. This is not something I introduced in this patch.

Marc

Quoted 6 lines
Quoted 1 line

[...]

--
Nélio Laranjeiro
6WIND

#58 lore raw

Re: [PATCH v9 3/4] ethdev: redesign link speed config API

Quoted 95 lines · Marc

On 9 March 2016 at 09:45, Nélio Laranjeiro <[1][email protected]> wrote:

Hi Marc,

A small remark bellow.
On Tue, Mar 01, 2016 at 01:45:50AM +0100, Marc Sune wrote:
> This patch redesigns the API to set the link speed/s configure > for an ethernet port. Specifically:
>
> - it allows to define a set of advertised speeds for
>   auto-negociation.
> - it allows to disable link auto-negociation (single fixed speed). > - default: auto-negociate all supported speeds.
>
> Other changes:
>
> * Added utility MACROs ETH_SPEED_NUM_XXX with the numeric >   values of all supported link speeds, in Mbps.
> * Converted link_speed to uint32_t to accomodate 100G speeds >   and beyond (bug).
> * Added autoneg flag in struct rte_eth_link to indicate if >   link speed was a result of auto-negociation or was fixed >   by configuration.
> * Added utility function to convert numeric speeds to bitmap >   fields.
> * Added rte_eth_speed_to_bm_flag() to version map.
>
> Signed-off-by: Marc Sune <[2][email protected]>
> ---
>  app/test-pipeline/init.c                  |   2 +-
>  app/test-pmd/cmdline.c                    | 124
+++++++++++++++---------------
>  app/test-pmd/config.c                     |   4 +-
>  app/test/virtual_pmd.c                    |   4 +-
>  drivers/net/af_packet/rte_eth_af_packet.c |   5 +-
>  drivers/net/bnx2x/bnx2x_ethdev.c          |   8 +-
>  drivers/net/bonding/rte_eth_bond_8023ad.c |  14 ++--
>  drivers/net/cxgbe/base/t4_hw.c            |   8 +-
>  drivers/net/cxgbe/cxgbe_ethdev.c          |   2 +-
>  drivers/net/e1000/em_ethdev.c             | 116
++++++++++++++--------------
>  drivers/net/e1000/igb_ethdev.c            | 111
+++++++++++++-------------
>  drivers/net/fm10k/fm10k_ethdev.c          |   8 +-
>  drivers/net/i40e/i40e_ethdev.c            |  73 +++++++++--------- >  drivers/net/i40e/i40e_ethdev_vf.c         |  11 +--
>  drivers/net/ixgbe/ixgbe_ethdev.c          |  78 ++++++++----------- >  drivers/net/mlx4/mlx4.c                   |   6 +-
>  drivers/net/mlx5/mlx5_ethdev.c            |  10 +--
>  drivers/net/mpipe/mpipe_tilegx.c          |   6 +-
>  drivers/net/nfp/nfp_net.c                 |   4 +-
>  drivers/net/null/rte_eth_null.c           |   5 +-
>  drivers/net/pcap/rte_eth_pcap.c           |   9 ++-
>  drivers/net/ring/rte_eth_ring.c           |   5 +-
>  drivers/net/virtio/virtio_ethdev.c        |   2 +-
>  drivers/net/virtio/virtio_ethdev.h        |   2 -
>  drivers/net/vmxnet3/vmxnet3_ethdev.c      |   5 +-
>  drivers/net/xenvirt/rte_eth_xenvirt.c     |   5 +-
>  examples/ip_pipeline/config_parse.c       |   3 +-
>  lib/librte_ether/rte_ethdev.c             |  49 ++++++++++++ >  lib/librte_ether/rte_ethdev.h             | 113
+++++++++++++++++----------
>  lib/librte_ether/rte_ether_version.map    |   6 ++
>  30 files changed, 448 insertions(+), 350 deletions(-)
>
> diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c > index db2196b..6a69fe2 100644
> --- a/app/test-pipeline/init.c
> +++ b/app/test-pipeline/init.c
> @@ -200,7 +200,7 @@ app_ports_check_link(void)
>               port = (uint8_t) app.ports[i];
>               memset(&link, 0, sizeof(link));
>               rte_eth_link_get_nowait(port, &link);
> -             RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n", > +             RTE_LOG(INFO, USER1, "Port %u (%d Gbps) %s\n", >                       port,
>                       link.link_speed / 1000,
>                       link.link_status ? "UP" : "DOWN"); > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 52e9f5f..57ad25f 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -956,14 +956,65 @@ struct cmd_config_speed_all {
>       cmdline_fixed_string_t value2;
>  };
>
> +static int
> +parse_and_check_speed_duplex(char *value1, char *value2, uint32_t *link_speed)

"value" variables should have the more friendly name, we need to read the
code to understand what is value1 and value2.

Quoted 5 lines

Hello,
Ok, but note that the entire source code of cmdline.c uses value1 and value2 to reference speed and duplex mode. This is not something I introduced in this patch.
Marc

Ok, I did not look in the whole file only in your patch. You kept the logic of the file, it is good for me.

Quoted 10 lines
     >[...]
     --
     Nélio Laranjeiro
     6WIND

References

Visible links
1. mailto:[email protected]
2. mailto:[email protected]

Signature · 2 lines
Nélio Laranjeiro
6WIND
author
#64 lore raw
In reply to Nélio Laranjeiro
Quoted 147 lines · Nélio Laranjeiro
Quoted 5 lines · Nélio Laranjeiro
Quoted 4 lines · Nélio Laranjeiro
Quoted 3 lines · Marc Sune

2016-03-01 1:45 GMT+01:00 Marc Sune <[email protected]>:

Quoted 1 line

The current rte_eth_dev_info abstraction does not provide any

mechanism to

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

get the supported speed(s) of an ethdev.

For some drivers (e.g. ixgbe), an educated guess could be done

based on the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

driver's name (driver_name in rte_eth_dev_info), see:

http://dpdk.org/ml/archives/dev/2013-August/000412.html

However, i) doing string comparisons is annoying, and can silently break existing applications if PMDs change their names ii) it does

not

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

provide all the supported capabilities of the ethdev iii) for some

drivers

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

it
is impossible determine correctly the (max) speed by the

application

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(e.g. in i40, distinguish between XL710 and X710).

In addition, the link APIs do not allow to define a set of

advertised link

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

speeds for autonegociation.

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the

PMDs

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the

advertised

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

link speeds, fix speed (no auto-negociation) or advertise all

supported

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

speeds (default).

WARNING: this patch series, specifically 3/4, is NOT tested for

most of the

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

PMDs, due to the lack of hardware. Only generic EM is tested (VM). Reviewing
and testing required by PMD maintainers.

* * * * *

v2: rebase, converted speed_capa into 32 bits bitmap, fixed

alignment

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

(checkpatch).

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to

allow a

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

bitmap
for defining the announced speeds, as suggested M. Brorup.

Fixed

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

spelling
issues.

v4: fixed errata in the documentation of field speeds of

rte_eth_conf, and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

commit 1/2 message. rebased to v2.1.0. v3 was incorrectly

based on

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
    ~2.1.0-rc1.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed

capabilities

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(thanks N. Laranjeiro). Refactored link speed API to allow

setting

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

advertised speeds (3/4). Added NO_AUTONEG option to

explicitely disable

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to

current

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

HEAD.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg

flag link

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

update code. Added rte_eth_speed_to_bm_flag() to .map file.

Fixed other

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

spelling issues. Rebased to current HEAD.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still

needs

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

testing
from PMD maintainers.

v8: Rebased to current HEAD. Modified em driver impl. to not touch

base

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

files.
Merged patch 5 into 3 (map file). Changed numeric speed to a

64 bit

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

value.
Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5

and nfp in

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

addition to the ones of previous patch sets.

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in

struct

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver
compilation
and link speeds. Moved documentation to release_16_04.rst and

fixed

Quoted 19 lines
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

several
issues. Upgrade NIC notes with speed capabilities.

Anyone interested in reviewing and _testing_ this series?

Thank you
Marc

Hi Marc,

Quoted 7 lines

I will take a look tomorrow morning and run test on Mellanox NICs (ConnectX 3 and 4).

I do not have access to the others NICs, if those who have can do it, could be really great.

Regards,

Quoted 7 lines

It works as expected with Mellanox NICs.

Regards,

--
Nélio Laranjeiro
6WIND

- OS/Kernel: Debian 8/3.16.0-4-amd64
- GCC: gcc (Debian 4.9.2-10) 4.9.2
- CPU: Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz
- MLNX OFED: 3.2-2.0.0.0
- NIC: ConnectX 4 100G

- OS/Kernel: Debian 7/3.16.0-0.bpo.4-amd64
- GCC: gcc (Debian 4.7.2-5) 4.7.2
- CPU: Intel(R) Xeon(R) CPU E5-2648L 0 @ 1.80GHz
- MLNX OFED: 3.2-2.0.0.0
- NIC: ConnectX 3 Pro

Quoted 8 lines

1. Link displayed at the correct negotiated speed:
- 40Gbps for ConnectX3 Pro
- 100Gbps for ConnectX4 100G
- 40Gbps for ConnectX4 100G on a 40G link.

2. Configuring speed:
- Not supported yet for Mellanox as expected.

Thanks Neilo,

It would be good that at least i40 and e1000/ixgbe is tested and acked, specially for the speed config part. Some more reviews would also help.

Marc

Quoted 5 lines

--
Nélio Laranjeiro
6WIND

#65 lore raw

v10 cover ethdev: 100G and link speed API refactoring

In reply to Marc Sune

Re-spin of the Marc's patchset.
The first version was sent 10 months ago!
There are still too few tests and reviews but it is now time to move forward with this rework.
Some issues were remaining in v9 and were difficult to see because it was mainly one big patch. That's why I've split it in several steps and fixed/reworked some pieces.
There will be an exception to integrate this feature in 16.04-rc2. Please test and review shortly, thanks!

--------

This series of patches adds the following capabilities:

* speed_capa bitmap in rte_eth_dev_info, which is filled by the PMDs according to the physical device capabilities.
* refactors link API in ethdev to allow the definition of the advertised link speeds, fix speed (no auto-negociation) or advertise all supported speeds (default).

WARNING: this patch series, specifically the patch 6/8, is NOT tested for most of the drivers.
Reviewing and testing are required by PMD maintainers.

--------

Marc Sune (6):
ethdev: use constants for link duplex app/testpmd: move speed and duplex parsing in a function
ethdev: rename link speed constants
ethdev: add speed capabilities
ethdev: redesign link speed config
ethdev: convert speed number to bitmap flag

Thomas Monjalon (2):
ethdev: use constants for link state
ethdev: add 100G link speed

v10:
- rebase
- rework release notes
- rearrange patch splitting
- fix doxygen comments
- fix typos
- removed log format of link.link_speed as %d (keep %u)
- complete ETH_LINK_[DOWN/UP] replacement from 0/1
- change ETH_LINK_SPEED_AUTONEG to 1
- replace ETH_LINK_SPEED_NEG by ETH_LINK_SPEED_AUTONEG (1)
- replace ETH_LINK_SPEED_NO_AUTONEG by ETH_LINK_SPEED_FIXED (0)
- rework rte_eth_speed_to_bm_flag to rte_eth_speed_bitflag
- complete 100G support in testpmd

v9: rebased to current HEAD. Reverted numeric speed to 32 bit in struct
rte_eth_link (no atomic link get > 64bit). Fixed mlx5 driver compilation and link speeds. Moved documentation to release_16_04.rst and fixed several issues. Upgrade NIC notes with speed capabilities.

v8: Rebased to current HEAD. Modified em driver impl. to not touch base files.
Merged patch 5 into 3 (map file). Changed numeric speed to a 64 bit value. Filled-in speed capabilities for drivers bnx2x, cxgbe, mlx5 and nfp in addition to the ones of previous patch sets.

v7: Rebased to current HEAD. Moved documentation to v2.3. Still needs testing
from PMD maintainers.

v6: Move link_duplex to be part of bitfield. Fixed i40 autoneg flag link
update code. Added rte_eth_speed_to_bm_flag() to .map file. Fixed other spelling issues. Rebased to current HEAD.

v5: revert to v2 speed capabilities patch. Fixed MLX4 speed capabilities
(thanks N. Laranjeiro). Refactored link speed API to allow setting advertised speeds (3/4). Added NO_AUTONEG option to explicitely disable auto-negociation. Updated 2.2 rel. notes (4/4). Rebased to current HEAD.

v4: fixed errata in the documentation of field speeds of rte_eth_conf, and
commit 1/2 message. rebased to v2.1.0. v3 was incorrectly based on ~2.1.0-rc1.

v3: rebase to v2.1. unified ETH_LINK_SPEED and ETH_SPEED_CAP into ETH_SPEED.
Converted field speed in struct rte_eth_conf to speed, to allow a bitmap for defining the announced speeds, as suggested M. Brorup. Fixed spelling issues.

v2: rebase, converted speed_capa into 32 bits bitmap, fixed alignment
(checkpatch).

 app/test-pipeline/init.c                           |   2 +-
 app/test-pmd/cmdline.c                             | 125 ++++++++++-----------
 app/test-pmd/testpmd.c                             |   2 +-
 app/test/test_pmd_perf.c                           |   2 +-
 app/test/virtual_pmd.c                             |   8 +-
 doc/guides/nics/overview.rst                       |   1 +
 doc/guides/rel_notes/release_16_04.rst             |  22 ++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst        |   2 +-
 drivers/net/af_packet/rte_eth_af_packet.c          |   9 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                   |   7 +-
 drivers/net/bnx2x/elink.c                          |   2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c          |  14 +--
 drivers/net/bonding/rte_eth_bond_api.c             |   4 +-
 drivers/net/bonding/rte_eth_bond_pmd.c             |  12 +-
 drivers/net/cxgbe/base/t4_hw.c                     |   8 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                   |   1 +
 drivers/net/e1000/em_ethdev.c                      | 111 +++++++++---------
 drivers/net/e1000/igb_ethdev.c                     | 104 +++++++++--------
 drivers/net/fm10k/fm10k_ethdev.c                   |   6 +-
 drivers/net/i40e/i40e_ethdev.c                     |  76 +++++++------
 drivers/net/i40e/i40e_ethdev_vf.c                  |  11 +-
 drivers/net/ixgbe/ixgbe_ethdev.c                   |  76 ++++++-------
 drivers/net/mlx4/mlx4.c                            |   4 +
 drivers/net/mlx5/mlx5_ethdev.c                     |   3 +
 drivers/net/mpipe/mpipe_tilegx.c                   |  18 +--
 drivers/net/nfp/nfp_net.c                          |   6 +-
 drivers/net/null/rte_eth_null.c                    |   9 +-
 drivers/net/pcap/rte_eth_pcap.c                    |   9 +-
 drivers/net/ring/rte_eth_ring.c                    |  13 ++-
 drivers/net/szedata2/rte_eth_szedata2.c            |   7 +-
 drivers/net/virtio/virtio_ethdev.c                 |   8 +-
 drivers/net/virtio/virtio_ethdev.h                 |   2 -
 drivers/net/vmxnet3/vmxnet3_ethdev.c               |   5 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c              |   9 +-
 examples/exception_path/main.c                     |   2 +-
 examples/ip_fragmentation/main.c                   |   2 +-
 examples/ip_pipeline/config_parse.c                |   3 +-
 examples/ip_pipeline/init.c                        |   2 +-
 examples/ip_reassembly/main.c                      |   2 +-
 examples/ipsec-secgw/ipsec-secgw.c                 |   2 +-
 examples/ipv4_multicast/main.c                     |   2 +-
 examples/kni/main.c                                |   2 +-
 examples/l2fwd-crypto/main.c                       |   2 +-
 examples/l2fwd-ivshmem/host/host.c                 |   2 +-
 examples/l2fwd-jobstats/main.c                     |   2 +-
 examples/l2fwd-keepalive/main.c                    |   2 +-
 examples/l2fwd/main.c                              |   2 +-
 examples/l3fwd-acl/main.c                          |   2 +-
 examples/l3fwd-power/main.c                        |   2 +-
 examples/l3fwd/main.c                              |   2 +-
 examples/link_status_interrupt/main.c              |   2 +-
 examples/load_balancer/init.c                      |   2 +-
 .../client_server_mp/mp_server/init.c              |   2 +-
 examples/multi_process/l2fwd_fork/main.c           |   2 +-
 examples/multi_process/symmetric_mp/main.c         |   2 +-
 examples/performance-thread/l3fwd-thread/main.c    |   2 +-
 lib/librte_ether/rte_ethdev.c                      |  33 ++++++
 lib/librte_ether/rte_ethdev.h                      |  91 +++++++++++----
 lib/librte_ether/rte_ether_version.map             |   1 +
 59 files changed, 503 insertions(+), 365 deletions(-)
Signature · 1 line
2.7.0
#66 lore raw

PATCH v10 1/8 ethdev: use constants for link state

Define and use ETH_LINK_UP and ETH_LINK_DOWN where appropriate.

---
 app/test-pipeline/init.c                                 |  2 +-
 app/test-pmd/testpmd.c                                   |  2 +-
 app/test/test_pmd_perf.c                                 |  2 +-
 app/test/virtual_pmd.c                                   |  6 +++---
 drivers/net/af_packet/rte_eth_af_packet.c                |  6 +++---
 drivers/net/bnx2x/bnx2x_ethdev.c                         |  2 +-
 drivers/net/bnx2x/elink.c                                |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c                   |  4 ++--
 drivers/net/bonding/rte_eth_bond_pmd.c                   | 12 ++++++------
 drivers/net/e1000/em_ethdev.c                            |  6 +++---
 drivers/net/e1000/igb_ethdev.c                           |  4 ++--
 drivers/net/fm10k/fm10k_ethdev.c                         |  2 +-
 drivers/net/i40e/i40e_ethdev_vf.c                        |  2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c                         |  4 ++--
 drivers/net/mpipe/mpipe_tilegx.c                         | 12 ++++++------
 drivers/net/nfp/nfp_net.c                                |  2 +-
 drivers/net/null/rte_eth_null.c                          |  6 +++---
 drivers/net/pcap/rte_eth_pcap.c                          |  6 +++---
 drivers/net/ring/rte_eth_ring.c                          | 10 +++++-----
 drivers/net/szedata2/rte_eth_szedata2.c                  |  6 +++---
 drivers/net/virtio/virtio_ethdev.c                       |  6 +++---
 drivers/net/vmxnet3/vmxnet3_ethdev.c                     |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c                    |  6 +++---
 examples/exception_path/main.c                           |  2 +-
 examples/ip_fragmentation/main.c                         |  2 +-
 examples/ip_pipeline/init.c                              |  2 +-
 examples/ip_reassembly/main.c                            |  2 +-
 examples/ipsec-secgw/ipsec-secgw.c                       |  2 +-
 examples/ipv4_multicast/main.c                           |  2 +-
 examples/kni/main.c                                      |  2 +-
 examples/l2fwd-crypto/main.c                             |  2 +-
 examples/l2fwd-ivshmem/host/host.c                       |  2 +-
 examples/l2fwd-jobstats/main.c                           |  2 +-
 examples/l2fwd-keepalive/main.c                          |  2 +-
 examples/l2fwd/main.c                                    |  2 +-
 examples/l3fwd-acl/main.c                                |  2 +-
 examples/l3fwd-power/main.c                              |  2 +-
 examples/l3fwd/main.c                                    |  2 +-
 examples/link_status_interrupt/main.c                    |  2 +-
 examples/load_balancer/init.c                            |  2 +-
 examples/multi_process/client_server_mp/mp_server/init.c |  2 +-
 examples/multi_process/l2fwd_fork/main.c                 |  2 +-
 examples/multi_process/symmetric_mp/main.c               |  2 +-
 examples/performance-thread/l3fwd-thread/main.c          |  2 +-
 lib/librte_ether/rte_ethdev.h                            |  5 ++++-
 45 files changed, 81 insertions(+), 78 deletions(-)
app/test-pipeline/init.c +1 -1
index db2196b..aef082f 100644
@@ -205,7 +205,7 @@ app_ports_check_link(void)
 			link.link_speed / 1000,
 			link.link_status ? "UP" : "DOWN");
 
-		if (link.link_status == 0)
+		if (link.link_status == ETH_LINK_DOWN)
 			all_ports_up = 0;
 	}
 
app/test-pmd/testpmd.c +1 -1
index 38b9051..f713f39 100644
@@ -1641,7 +1641,7 @@ check_all_ports_link_status(uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
app/test/test_pmd_perf.c +1 -1
index 48e16c9..59803f7 100644
@@ -192,7 +192,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
app/test/virtual_pmd.c +3 -3
index a538c8a..b1d40d7 100644
@@ -79,7 +79,7 @@ static void  virtual_ethdev_stop(struct rte_eth_dev *eth_dev __rte_unused)
 	void *pkt = NULL;
 	struct virtual_ethdev_private *prv = eth_dev->data->dev_private;
 
-	eth_dev->data->dev_link.link_status = 0;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	eth_dev->data->dev_started = 0;
 	while (rte_ring_dequeue(prv->rx_queue, &pkt) != -ENOENT)
 		rte_pktmbuf_free(pkt);
@@ -199,7 +199,7 @@ virtual_ethdev_link_update_success(struct rte_eth_dev *bonded_eth_dev,
 		int wait_to_complete __rte_unused)
 {
 	if (!bonded_eth_dev->data->dev_started)
-		bonded_eth_dev->data->dev_link.link_status = 0;
+		bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 
 	return 0;
 }
@@ -603,7 +603,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
drivers/net/af_packet/rte_eth_af_packet.c +3 -3
index 767f36b..24f909f 100644
@@ -118,7 +118,7 @@ static const char *drivername = "AF_PACKET PMD";
 static struct rte_eth_link pmd_link = {
 	.link_speed = 10000,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
 };
 
 static uint16_t
@@ -234,7 +234,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 static int
 eth_dev_start(struct rte_eth_dev *dev)
 {
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -257,7 +257,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 			close(sockfd);
 	}
 
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/bnx2x/bnx2x_ethdev.c +1 -1
index 69df02e..f109900 100644
@@ -286,7 +286,7 @@ bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_comple
 	if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
 		PMD_DRV_LOG(ERR, "PF indicated channel is down."
 				"VF device is no longer operational");
-		dev->data->dev_link.link_status = 0;
+		dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	}
 
 	return old_link_status == dev->data->dev_link.link_status ? -1 : 0;
drivers/net/bnx2x/elink.c +1 -1
index da2366e..b9149b8 100644
@@ -6312,7 +6312,7 @@ elink_status_t elink_link_update(struct elink_params * params,
 	for (phy_index = ELINK_INT_PHY; phy_index < params->num_phys;
 	     phy_index++) {
 		phy_vars[phy_index].flow_ctrl = 0;
-		phy_vars[phy_index].link_status = 0;
+		phy_vars[phy_index].link_status = ETH_LINK_DOWN;
 		phy_vars[phy_index].line_speed = 0;
 		phy_vars[phy_index].duplex = DUPLEX_FULL;
 		phy_vars[phy_index].phy_link_up = 0;
drivers/net/bonding/rte_eth_bond_api.c +2 -2
index 8a000c8..b0ebd35 100644
@@ -205,7 +205,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
-	eth_dev->data->dev_link.link_status = 0;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 
 	eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0,
 			socket_id);
@@ -427,7 +427,7 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id)
 	if (bonded_eth_dev->data->dev_started) {
 		rte_eth_link_get_nowait(slave_port_id, &link_props);
 
-		 if (link_props.link_status == 1)
+		 if (link_props.link_status == ETH_LINK_UP)
 			activate_slave(bonded_eth_dev, slave_port_id);
 	}
 	return 0;
drivers/net/bonding/rte_eth_bond_pmd.c +6 -6
index b63c886..e63a7d0 100644
@@ -1499,7 +1499,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)
 		return -1;
 	}
 
-	eth_dev->data->dev_link.link_status = 0;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	eth_dev->data->dev_started = 1;
 
 	internals = eth_dev->data->dev_private;
@@ -1616,7 +1616,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
 	internals->active_slave_count = 0;
 	internals->link_status_polling_enabled = 0;
 
-	eth_dev->data->dev_link.link_status = 0;
+	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	eth_dev->data->dev_started = 0;
 }
 
@@ -1782,7 +1782,7 @@ bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 
 	if (!bonded_eth_dev->data->dev_started ||
 		internals->active_slave_count == 0) {
-		bonded_eth_dev->data->dev_link.link_status = 0;
+		bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 		return 0;
 	} else {
 		struct rte_eth_dev *slave_eth_dev;
@@ -1793,7 +1793,7 @@ bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev,
 
 			(*slave_eth_dev->dev_ops->link_update)(slave_eth_dev,
 					wait_to_complete);
-			if (slave_eth_dev->data->dev_link.link_status == 1) {
+			if (slave_eth_dev->data->dev_link.link_status == ETH_LINK_UP) {
 				link_up = 1;
 				break;
 			}
@@ -1962,7 +1962,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		/* if no active slave ports then set this port to be primary port */
 		if (internals->active_slave_count < 1) {
 			/* If first active slave, then change link status */
-			bonded_eth_dev->data->dev_link.link_status = 1;
+			bonded_eth_dev->data->dev_link.link_status = ETH_LINK_UP;
 			internals->current_primary_port = port_id;
 			lsc_flag = 1;
 
@@ -1990,7 +1990,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
 		 * link properties */
 		if (internals->active_slave_count < 1) {
 			lsc_flag = 1;
-			bonded_eth_dev->data->dev_link.link_status = 0;
+			bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 
 			link_properties_reset(bonded_eth_dev);
 		}
drivers/net/e1000/em_ethdev.c +3 -3
index 4a843fe..58f9c7a 100644
@@ -1073,11 +1073,11 @@ eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	if (link_check && (link.link_status == 0)) {
 		hw->mac.ops.get_link_up_info(hw, &link.link_speed,
 			&link.link_duplex);
-		link.link_status = 1;
-	} else if (!link_check && (link.link_status == 1)) {
+		link.link_status = ETH_LINK_UP;
+	} else if (!link_check && (link.link_status == ETH_LINK_UP)) {
 		link.link_speed = 0;
 		link.link_duplex = 0;
-		link.link_status = 0;
+		link.link_status = ETH_LINK_DOWN;
 	}
 	rte_em_dev_atomic_write_link_status(dev, &link);
 
drivers/net/e1000/igb_ethdev.c +2 -2
index 2581995..614d8cb 100644
@@ -2021,11 +2021,11 @@ eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	if (link_check) {
 		hw->mac.ops.get_link_up_info(hw, &link.link_speed,
 					  &link.link_duplex);
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 	} else if (!link_check) {
 		link.link_speed = 0;
 		link.link_duplex = 0;
-		link.link_status = 0;
+		link.link_status = ETH_LINK_DOWN;
 	}
 	rte_igb_dev_atomic_write_link_status(dev, &link);
 
drivers/net/fm10k/fm10k_ethdev.c +1 -1
index 421266b..378faf2 100644
@@ -1172,7 +1172,7 @@ fm10k_link_update(struct rte_eth_dev *dev,
 	 * is no 50Gbps Ethernet. */
 	dev->data->dev_link.link_speed  = 0;
 	dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
index 13c5b3d..80dc920 100644
@@ -1917,7 +1917,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 		/* Always assume it's up, for Linux driver PF host */
 		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
 		new_link.link_speed  = ETH_LINK_SPEED_10000;
-		new_link.link_status = 1;
+		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
 
drivers/net/ixgbe/ixgbe_ethdev.c +2 -2
index 8431755..62a8dff 100644
@@ -2957,7 +2957,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	int link_up;
 	int diag;
 
-	link.link_status = 0;
+	link.link_status = ETH_LINK_DOWN;
 	link.link_speed = 0;
 	link.link_duplex = 0;
 	memset(&old, 0, sizeof(old));
@@ -2986,7 +2986,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 			return -1;
 		return 0;
 	}
-	link.link_status = 1;
+	link.link_status = ETH_LINK_UP;
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	switch (link_speed) {
drivers/net/mpipe/mpipe_tilegx.c +6 -6
index 04f3c9f..118d3a5 100644
@@ -391,11 +391,11 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 		if (speed == GXIO_MPIPE_LINK_1G) {
 			new.link_speed = ETH_LINK_SPEED_1000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
 			new.link_speed = ETH_LINK_SPEED_10000;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
-			new.link_status = 1;
+			new.link_status = ETH_LINK_UP;
 		}
 
 		rc = mpipe_link_compare(&old, &new);
@@ -847,9 +847,9 @@ mpipe_start(struct rte_eth_dev *dev)
 
 	/* Start xmit/recv on queues. */
 	for (queue = 0; queue < priv->nb_tx_queues; queue++)
-		mpipe_tx_queue(priv, queue)->q.link_status = 1;
+		mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_UP;
 	for (queue = 0; queue < priv->nb_rx_queues; queue++)
-		mpipe_rx_queue(priv, queue)->q.link_status = 1;
+		mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_UP;
 	priv->running = 1;
 
 	return 0;
@@ -864,9 +864,9 @@ mpipe_stop(struct rte_eth_dev *dev)
 	int rc;
 
 	for (queue = 0; queue < priv->nb_tx_queues; queue++)
-		mpipe_tx_queue(priv, queue)->q.link_status = 0;
+		mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN;
 	for (queue = 0; queue < priv->nb_rx_queues; queue++)
-		mpipe_rx_queue(priv, queue)->q.link_status = 0;
+		mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN;
 
 	/* Make sure the link_status writes land. */
 	rte_wmb();
drivers/net/nfp/nfp_net.c +1 -1
index 9c4f218..d1e004a 100644
@@ -827,7 +827,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 	memset(&link, 0, sizeof(struct rte_eth_link));
 
 	if (nn_link_status & NFP_NET_CFG_STS_LINK)
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	/* Other cards can limit the tx and rx rate per VF */
drivers/net/null/rte_eth_null.c +3 -3
index 77fc988..2e60823 100644
@@ -95,7 +95,7 @@ static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
 	.link_speed = 10000,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
-	.link_status = 0
+	.link_status = ETH_LINK_DOWN,
 };
 
 static uint16_t
@@ -208,7 +208,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 	if (dev == NULL)
 		return -EINVAL;
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -218,7 +218,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	if (dev == NULL)
 		return;
 
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/pcap/rte_eth_pcap.c +3 -3
index f9230eb..2b32e8d 100644
@@ -127,7 +127,7 @@ static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
 		.link_speed = 10000,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
 };
 
 static int
@@ -430,7 +430,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 
 status_up:
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -481,7 +481,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	}
 
 status_down:
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/ring/rte_eth_ring.c +5 -5
index d92b088..4fcc2aa 100644
@@ -73,7 +73,7 @@ static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
 		.link_speed = 10000,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
 };
 
 static uint16_t
@@ -113,27 +113,27 @@ eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { return 0; }
 static int
 eth_dev_start(struct rte_eth_dev *dev)
 {
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
 static void
 eth_dev_stop(struct rte_eth_dev *dev)
 {
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
 eth_dev_set_link_down(struct rte_eth_dev *dev)
 {
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	return 0;
 }
 
 static int
 eth_dev_set_link_up(struct rte_eth_dev *dev)
 {
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
drivers/net/szedata2/rte_eth_szedata2.c +3 -3
index 9f86c99..38be554 100644
@@ -113,7 +113,7 @@ static const char *drivername = "SZEdata2 PMD";
 static struct rte_eth_link pmd_link = {
 		.link_speed = ETH_LINK_SPEED_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN
 };
 
 
@@ -1158,7 +1158,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	return 0;
 }
 
@@ -1188,7 +1188,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 	dev->data->nb_rx_queues = (uint16_t)0;
 	dev->data->nb_tx_queues = (uint16_t)0;
 
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 }
 
 static int
drivers/net/virtio/virtio_ethdev.c +3 -3
index 06bddd7..76a0faf 100644
@@ -1392,16 +1392,16 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 				offsetof(struct virtio_net_config, status),
 				&status, sizeof(status));
 		if ((status & VIRTIO_NET_S_LINK_UP) == 0) {
-			link.link_status = 0;
+			link.link_status = ETH_LINK_DOWN;
 			PMD_INIT_LOG(DEBUG, "Port %d is down",
 				     dev->data->port_id);
 		} else {
-			link.link_status = 1;
+			link.link_status = ETH_LINK_UP;
 			PMD_INIT_LOG(DEBUG, "Port %d is up",
 				     dev->data->port_id);
 		}
 	} else {
-		link.link_status = 1;   /* Link up */
+		link.link_status = ETH_LINK_UP;
 	}
 	virtio_dev_atomic_write_link_status(dev, &link);
 
drivers/net/vmxnet3/vmxnet3_ethdev.c +1 -1
index c363bf6..06793a6 100644
@@ -736,7 +736,7 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD);
 
 	if (ret & 0x1) {
-		link.link_status = 1;
+		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
 		link.link_speed = ETH_LINK_SPEED_10000;
 	}
drivers/net/xenvirt/rte_eth_xenvirt.c +3 -3
index 3f31806..9453a06 100644
@@ -72,7 +72,7 @@ static const char *drivername = "xen virtio PMD";
 static struct rte_eth_link pmd_link = {
 		.link_speed = 10000,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
-		.link_status = 0
+		.link_status = ETH_LINK_DOWN,
 };
 
 static void
@@ -290,7 +290,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 	struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private;
 	int rv;
 
-	dev->data->dev_link.link_status = 1;
+	dev->data->dev_link.link_status = ETH_LINK_UP;
 	while (!virtqueue_full(rxvq)) {
 		m = rte_rxmbuf_alloc(rxvq->mpool);
 		if (m == NULL)
@@ -318,7 +318,7 @@ eth_dev_stop(struct rte_eth_dev *dev)
 {
 	struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private;
 
-	dev->data->dev_link.link_status = 0;
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	dev_stop_notify(pi->virtio_idx);
 }
 
examples/exception_path/main.c +1 -1
index b3fe170..bec9804 100644
@@ -485,7 +485,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/ip_fragmentation/main.c +1 -1
index 8021702..81a4918 100644
@@ -631,7 +631,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/ip_pipeline/init.c +1 -1
index e59a6b4..83422e8 100644
@@ -856,7 +856,7 @@ app_check_link(struct app_params *app)
 			link_params.link_speed / 1000,
 			link_params.link_status ? "UP" : "DOWN");
 
-		if (link_params.link_status == 0)
+		if (link_params.link_status == ETH_LINK_DOWN)
 			all_links_up = 0;
 	}
 
examples/ip_reassembly/main.c +1 -1
index 19ec46c..c27e735 100644
@@ -763,7 +763,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/ipsec-secgw/ipsec-secgw.c +1 -1
index d6c9a5d..393f9bd 100644
@@ -945,7 +945,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/ipv4_multicast/main.c +1 -1
index 5dbea1a..96b4157 100644
@@ -642,7 +642,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/kni/main.c +1 -1
index 6d434ad..a5297f2 100644
@@ -670,7 +670,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l2fwd-crypto/main.c +1 -1
index 762d22a..fef5b0c 100644
@@ -1238,7 +1238,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l2fwd-ivshmem/host/host.c +1 -1
index 6e6ed5e..4bd7c41 100644
@@ -371,7 +371,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l2fwd-jobstats/main.c +1 -1
index d1e9bf7..9f3a77d 100644
@@ -746,7 +746,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l2fwd-keepalive/main.c +1 -1
index 94b8677..8da89aa 100644
@@ -499,7 +499,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l2fwd/main.c +1 -1
index e175681..1ad9488 100644
@@ -480,7 +480,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l3fwd-acl/main.c +1 -1
index 3a895b7..621872f 100644
@@ -1858,7 +1858,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l3fwd-power/main.c +1 -1
index d4bb7a3..f0a72fc 100644
@@ -1508,7 +1508,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/l3fwd/main.c +1 -1
index 8520f71..04eae16 100644
@@ -746,7 +746,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/link_status_interrupt/main.c +1 -1
index cbc29bc..9981598 100644
@@ -523,7 +523,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/load_balancer/init.c +1 -1
index a96d778..e07850b 100644
@@ -395,7 +395,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/multi_process/client_server_mp/mp_server/init.c +1 -1
index 1078ffd..ecb61c6 100644
@@ -226,7 +226,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/multi_process/l2fwd_fork/main.c +1 -1
index aebf531..2dc8b82 100644
@@ -900,7 +900,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/multi_process/symmetric_mp/main.c +1 -1
index 72bad54..6bbff07 100644
@@ -388,7 +388,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
examples/performance-thread/l3fwd-thread/main.c +1 -1
index 7bcca37..aa1fdc3 100644
@@ -3407,7 +3407,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 				continue;
 			}
 			/* clear all_ports_up flag if any link down */
-			if (link.link_status == 0) {
+			if (link.link_status == ETH_LINK_DOWN) {
 				all_ports_up = 0;
 				break;
 			}
lib/librte_ether/rte_ethdev.h +4 -1
index d867976..6704a82 100644
@@ -247,7 +247,7 @@ struct rte_eth_stats {
 struct rte_eth_link {
 	uint16_t link_speed;      /**< ETH_LINK_SPEED_[10, 100, 1000, 10000] */
 	uint16_t link_duplex;     /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX] */
-	uint8_t  link_status : 1; /**< 1 -> link up, 0 -> link down */
+	uint8_t  link_status : 1; /**< ETH_LINK_[DOWN/UP] */
 }__attribute__((aligned(8)));     /**< aligned for atomic64 read/write */
 
 #define ETH_LINK_SPEED_AUTONEG  0       /**< Auto-negotiate link speed. */
@@ -259,9 +259,12 @@ struct rte_eth_link {
 #define ETH_LINK_SPEED_20G      20000   /**< 20 gigabits/second. */
 #define ETH_LINK_SPEED_40G      40000   /**< 40 gigabits/second. */
 
+/* Utility constants */
 #define ETH_LINK_AUTONEG_DUPLEX 0       /**< Auto-negotiate duplex. */
 #define ETH_LINK_HALF_DUPLEX    1       /**< Half-duplex connection. */
 #define ETH_LINK_FULL_DUPLEX    2       /**< Full-duplex connection. */
+#define ETH_LINK_DOWN           0 /**< Link is down. */
+#define ETH_LINK_UP             1 /**< Link is up. */
 
 /**
  * A structure used to configure the ring threshold registers of an RX/TX
Signature · 1 line
2.7.0
#68 lore raw

PATCH v10 2/8 ethdev: use constants for link duplex

In reply to Thomas Monjalon

From: Marc Sune <[email protected]>

Some duplex values are replaced from 0 to half-duplex when link is down.

Some drivers are still using their own constants for duplex modes.

---
 drivers/net/e1000/em_ethdev.c      | 2 +-
 drivers/net/e1000/igb_ethdev.c     | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c   | 2 +-
 drivers/net/virtio/virtio_ethdev.c | 2 +-
 drivers/net/virtio/virtio_ethdev.h | 2 --
 lib/librte_ether/rte_ethdev.h      | 2 +-
 6 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/e1000/em_ethdev.c +1 -1
index 58f9c7a..2f3529f 100644
@@ -1076,7 +1076,7 @@ eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 		link.link_status = ETH_LINK_UP;
 	} else if (!link_check && (link.link_status == ETH_LINK_UP)) {
 		link.link_speed = 0;
-		link.link_duplex = 0;
+		link.link_duplex = ETH_LINK_HALF_DUPLEX;
 		link.link_status = ETH_LINK_DOWN;
 	}
 	rte_em_dev_atomic_write_link_status(dev, &link);
drivers/net/e1000/igb_ethdev.c +1 -1
index 614d8cb..0e58fa9 100644
@@ -2024,7 +2024,7 @@ eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 		link.link_status = ETH_LINK_UP;
 	} else if (!link_check) {
 		link.link_speed = 0;
-		link.link_duplex = 0;
+		link.link_duplex = ETH_LINK_HALF_DUPLEX;
 		link.link_status = ETH_LINK_DOWN;
 	}
 	rte_igb_dev_atomic_write_link_status(dev, &link);
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
index 62a8dff..99c55bd 100644
@@ -2959,7 +2959,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 
 	link.link_status = ETH_LINK_DOWN;
 	link.link_speed = 0;
-	link.link_duplex = 0;
+	link.link_duplex = ETH_LINK_HALF_DUPLEX;
 	memset(&old, 0, sizeof(old));
 	rte_ixgbe_dev_atomic_read_link_status(dev, &old);
 
drivers/net/virtio/virtio_ethdev.c +1 -1
index 76a0faf..aa5ae10 100644
@@ -1383,7 +1383,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_read_link_status(dev, &link);
 	old = link;
-	link.link_duplex = FULL_DUPLEX;
+	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	link.link_speed  = SPEED_10G;
 
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
drivers/net/virtio/virtio_ethdev.h +0 -2
index fed9571..66423a0 100644
@@ -42,8 +42,6 @@
 #define SPEED_100	100
 #define SPEED_1000	1000
 #define SPEED_10G	10000
-#define HALF_DUPLEX	1
-#define FULL_DUPLEX	2
 
 #ifndef PAGE_SIZE
 #define PAGE_SIZE 4096
lib/librte_ether/rte_ethdev.h +1 -1
index 6704a82..12b552d 100644
@@ -246,7 +246,7 @@ struct rte_eth_stats {
  */
 struct rte_eth_link {
 	uint16_t link_speed;      /**< ETH_LINK_SPEED_[10, 100, 1000, 10000] */
-	uint16_t link_duplex;     /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX] */
+	uint16_t link_duplex;     /**< ETH_LINK_[HALF/FULL]_DUPLEX */
 	uint8_t  link_status : 1; /**< ETH_LINK_[DOWN/UP] */
 }__attribute__((aligned(8)));     /**< aligned for atomic64 read/write */
 
Signature · 1 line
2.7.0
#69 lore raw

PATCH v10 3/8 app/testpmd: move speed and duplex parsing in a function

In reply to Thomas Monjalon

From: Marc Sune <[email protected]>

The code for checking and parsing speed/duplex was duplicated. The new function is also checking the speed/duplex combination.

---
 app/test-pmd/cmdline.c | 99 ++++++++++++++++++++++++--------------------------
 1 file changed, 47 insertions(+), 52 deletions(-)
app/test-pmd/cmdline.c +47 -52
index 9d52b8c..37be5cd 100644
@@ -983,6 +983,49 @@ struct cmd_config_speed_all {
 	cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint16_t *speed)
+{
+
+	int duplex;
+
+	if (!strcmp(duplexstr, "half")) {
+		duplex = ETH_LINK_HALF_DUPLEX;
+	} else if (!strcmp(duplexstr, "full")) {
+		duplex = ETH_LINK_FULL_DUPLEX;
+	} else if (!strcmp(duplexstr, "auto")) {
+		duplex = ETH_LINK_FULL_DUPLEX;
+	} else {
+		printf("Unknown duplex parameter\n");
+		return -1;
+	}
+
+	if (!strcmp(speedstr, "10")) {
+		*speed = ETH_LINK_SPEED_10;
+	} else if (!strcmp(speedstr, "100")) {
+		*speed = ETH_LINK_SPEED_100;
+	} else {
+		if (duplex != ETH_LINK_FULL_DUPLEX) {
+			printf("Invalid speed/duplex parameters\n");
+			return -1;
+		}
+		if (!strcmp(speedstr, "1000")) {
+			*speed = ETH_LINK_SPEED_1000;
+		} else if (!strcmp(speedstr, "10000")) {
+			*speed = ETH_LINK_SPEED_10G;
+		} else if (!strcmp(speedstr, "40000")) {
+			*speed = ETH_LINK_SPEED_40G;
+		} else if (!strcmp(speedstr, "auto")) {
+			*speed = ETH_LINK_SPEED_AUTONEG;
+		} else {
+			printf("Unknown speed parameter\n");
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 static void
 cmd_config_speed_all_parsed(void *parsed_result,
 			__attribute__((unused)) struct cmdline *cl,
@@ -998,33 +1041,9 @@ cmd_config_speed_all_parsed(void *parsed_result,
 		return;
 	}
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10G;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1, res->value2,
+			&link_speed) < 0)
 		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
 
 	FOREACH_PORT(pid, ports) {
 		ports[pid].dev_conf.link_speed = link_speed;
@@ -1097,33 +1116,9 @@ cmd_config_speed_specific_parsed(void *parsed_result,
 	if (port_id_is_invalid(res->id, ENABLED_WARN))
 		return;
 
-	if (!strcmp(res->value1, "10"))
-		link_speed = ETH_LINK_SPEED_10;
-	else if (!strcmp(res->value1, "100"))
-		link_speed = ETH_LINK_SPEED_100;
-	else if (!strcmp(res->value1, "1000"))
-		link_speed = ETH_LINK_SPEED_1000;
-	else if (!strcmp(res->value1, "10000"))
-		link_speed = ETH_LINK_SPEED_10000;
-	else if (!strcmp(res->value1, "40000"))
-		link_speed = ETH_LINK_SPEED_40G;
-	else if (!strcmp(res->value1, "auto"))
-		link_speed = ETH_LINK_SPEED_AUTONEG;
-	else {
-		printf("Unknown parameter\n");
-		return;
-	}
-
-	if (!strcmp(res->value2, "half"))
-		link_duplex = ETH_LINK_HALF_DUPLEX;
-	else if (!strcmp(res->value2, "full"))
-		link_duplex = ETH_LINK_FULL_DUPLEX;
-	else if (!strcmp(res->value2, "auto"))
-		link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-	else {
-		printf("Unknown parameter\n");
+	if (parse_and_check_speed_duplex(res->value1, res->value2,
+			&link_speed) < 0)
 		return;
-	}
 
 	ports[res->id].dev_conf.link_speed = link_speed;
 	ports[res->id].dev_conf.link_duplex = link_duplex;
Signature · 1 line
2.7.0
#70 lore raw

PATCH v10 4/8 ethdev: rename link speed constants

In reply to Thomas Monjalon

From: Marc Sune <[email protected]>

The speed numbers ETH_LINK_SPEED_ are renamed ETH_SPEED_NUM_. The prefix ETH_LINK_SPEED_ is kept for AUTONEG and will be used for bit flags in next patch.

---
 app/test-pmd/cmdline.c                    | 10 +++++-----
 app/test/virtual_pmd.c                    |  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_8023ad.c | 12 ++++++------
 drivers/net/cxgbe/base/t4_hw.c            |  8 ++++----
 drivers/net/e1000/em_ethdev.c             |  8 ++++----
 drivers/net/e1000/igb_ethdev.c            |  8 ++++----
 drivers/net/i40e/i40e_ethdev.c            | 30 +++++++++++++++---------------
 drivers/net/i40e/i40e_ethdev_vf.c         |  2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c          | 22 +++++++++++-----------
 drivers/net/mpipe/mpipe_tilegx.c          |  4 ++--
 drivers/net/nfp/nfp_net.c                 |  2 +-
 drivers/net/null/rte_eth_null.c           |  2 +-
 drivers/net/pcap/rte_eth_pcap.c           |  2 +-
 drivers/net/ring/rte_eth_ring.c           |  2 +-
 drivers/net/szedata2/rte_eth_szedata2.c   |  2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c      |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  2 +-
 lib/librte_ether/rte_ethdev.h             | 29 ++++++++++++++++++-----------
 19 files changed, 79 insertions(+), 72 deletions(-)
app/test-pmd/cmdline.c +5 -5
index 37be5cd..874129a 100644
@@ -1001,20 +1001,20 @@ parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint16_t *speed)
 	}
 
 	if (!strcmp(speedstr, "10")) {
-		*speed = ETH_LINK_SPEED_10;
+		*speed = ETH_SPEED_NUM_10M;
 	} else if (!strcmp(speedstr, "100")) {
-		*speed = ETH_LINK_SPEED_100;
+		*speed = ETH_SPEED_NUM_100M;
 	} else {
 		if (duplex != ETH_LINK_FULL_DUPLEX) {
 			printf("Invalid speed/duplex parameters\n");
 			return -1;
 		}
 		if (!strcmp(speedstr, "1000")) {
-			*speed = ETH_LINK_SPEED_1000;
+			*speed = ETH_SPEED_NUM_1G;
 		} else if (!strcmp(speedstr, "10000")) {
-			*speed = ETH_LINK_SPEED_10G;
+			*speed = ETH_SPEED_NUM_10G;
 		} else if (!strcmp(speedstr, "40000")) {
-			*speed = ETH_LINK_SPEED_40G;
+			*speed = ETH_SPEED_NUM_40G;
 		} else if (!strcmp(speedstr, "auto")) {
 			*speed = ETH_LINK_SPEED_AUTONEG;
 		} else {
app/test/virtual_pmd.c +1 -1
index b1d40d7..b4bd2f2 100644
@@ -604,7 +604,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	TAILQ_INIT(&(eth_dev->link_intr_cbs));
 
 	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
-	eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000;
+	eth_dev->data->dev_link.link_speed = ETH_SPEED_NUM_10G;
 	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
 
 	eth_dev->data->mac_addrs = rte_zmalloc(name, ETHER_ADDR_LEN, 0);
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
index 24f909f..ff0d299 100644
@@ -116,7 +116,7 @@ static const char *valid_arguments[] = {
 static const char *drivername = "AF_PACKET PMD";
 
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
 	.link_status = ETH_LINK_DOWN,
 };
drivers/net/bonding/rte_eth_bond_8023ad.c +6 -6
index b3b30f6..5f9c9b3 100644
@@ -711,22 +711,22 @@ link_speed_key(uint16_t speed) {
 	case ETH_LINK_SPEED_AUTONEG:
 		key_speed = 0x00;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		key_speed = BOND_LINK_SPEED_KEY_10M;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		key_speed = BOND_LINK_SPEED_KEY_100M;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		key_speed = BOND_LINK_SPEED_KEY_1000M;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		key_speed = BOND_LINK_SPEED_KEY_10G;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		key_speed = BOND_LINK_SPEED_KEY_20G;
 		break;
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		key_speed = BOND_LINK_SPEED_KEY_40G;
 		break;
 	default:
drivers/net/cxgbe/base/t4_hw.c +4 -4
index 884d2cf..79af806 100644
@@ -2159,13 +2159,13 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
 		if (stat & F_FW_PORT_CMD_TXPAUSE)
 			fc |= PAUSE_TX;
 		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
-			speed = ETH_LINK_SPEED_100;
+			speed = ETH_SPEED_NUM_100M;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
-			speed = ETH_LINK_SPEED_1000;
+			speed = ETH_SPEED_NUM_1G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
-			speed = ETH_LINK_SPEED_10000;
+			speed = ETH_SPEED_NUM_10G;
 		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
-			speed = ETH_LINK_SPEED_40G;
+			speed = ETH_SPEED_NUM_40G;
 
 		for_each_port(adap, i) {
 			pi = adap2pinfo(adap, i);
drivers/net/e1000/em_ethdev.c +4 -4
index 2f3529f..84845e7 100644
@@ -596,7 +596,7 @@ eth_em_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
 			hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
 		else if (dev->data->dev_conf.link_duplex ==
@@ -608,7 +608,7 @@ eth_em_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
 			hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
 		else if (dev->data->dev_conf.link_duplex ==
@@ -620,7 +620,7 @@ eth_em_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		if ((dev->data->dev_conf.link_duplex ==
 				ETH_LINK_AUTONEG_DUPLEX) ||
 			(dev->data->dev_conf.link_duplex ==
@@ -629,7 +629,7 @@ eth_em_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_10000:
+	case ETH_SPEED_NUM_10G:
 	default:
 		goto error_invalid_config;
 	}
drivers/net/e1000/igb_ethdev.c +4 -4
index 0e58fa9..b4c8982 100644
@@ -1232,7 +1232,7 @@ eth_igb_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_10:
+	case ETH_SPEED_NUM_10M:
 		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
 			hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
 		else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
@@ -1242,7 +1242,7 @@ eth_igb_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
 			hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
 		else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
@@ -1252,14 +1252,14 @@ eth_igb_start(struct rte_eth_dev *dev)
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) ||
 				(dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX))
 			hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
 		else
 			goto error_invalid_config;
 		break;
-	case ETH_LINK_SPEED_10000:
+	case ETH_SPEED_NUM_10G:
 	default:
 		goto error_invalid_config;
 	}
drivers/net/i40e/i40e_ethdev.c +15 -15
index 2f676f6..17b58a8 100644
@@ -1363,19 +1363,19 @@ i40e_parse_link_speed(uint16_t eth_link_speed)
 	uint8_t link_speed = I40E_LINK_SPEED_UNKNOWN;
 
 	switch (eth_link_speed) {
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		link_speed = I40E_LINK_SPEED_40GB;
 		break;
-	case ETH_LINK_SPEED_20G:
+	case ETH_SPEED_NUM_20G:
 		link_speed = I40E_LINK_SPEED_20GB;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		link_speed = I40E_LINK_SPEED_10GB;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		link_speed = I40E_LINK_SPEED_1GB;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		link_speed = I40E_LINK_SPEED_100MB;
 		break;
 	}
@@ -1745,7 +1745,7 @@ i40e_dev_link_update(struct rte_eth_dev *dev,
 		/* Get link status information from hardware */
 		status = i40e_aq_get_link_info(hw, false, &link_status, NULL);
 		if (status != I40E_SUCCESS) {
-			link.link_speed = ETH_LINK_SPEED_100;
+			link.link_speed = ETH_SPEED_NUM_100M;
 			link.link_duplex = ETH_LINK_FULL_DUPLEX;
 			PMD_DRV_LOG(ERR, "Failed to get link info");
 			goto out;
@@ -1767,22 +1767,22 @@ i40e_dev_link_update(struct rte_eth_dev *dev,
 	/* Parse the link status */
 	switch (link_status.link_speed) {
 	case I40E_LINK_SPEED_100MB:
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 	case I40E_LINK_SPEED_1GB:
-		link.link_speed = ETH_LINK_SPEED_1000;
+		link.link_speed = ETH_SPEED_NUM_1G;
 		break;
 	case I40E_LINK_SPEED_10GB:
-		link.link_speed = ETH_LINK_SPEED_10G;
+		link.link_speed = ETH_SPEED_NUM_10G;
 		break;
 	case I40E_LINK_SPEED_20GB:
-		link.link_speed = ETH_LINK_SPEED_20G;
+		link.link_speed = ETH_SPEED_NUM_20G;
 		break;
 	case I40E_LINK_SPEED_40GB:
-		link.link_speed = ETH_LINK_SPEED_40G;
+		link.link_speed = ETH_SPEED_NUM_40G;
 		break;
 	default:
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 	}
 
@@ -7967,15 +7967,15 @@ i40e_start_timecounters(struct rte_eth_dev *dev)
 	rte_i40e_dev_atomic_read_link_status(dev, &link);
 
 	switch (link.link_speed) {
-	case ETH_LINK_SPEED_40G:
+	case ETH_SPEED_NUM_40G:
 		tsync_inc_l = I40E_PTP_40GB_INCVAL & 0xFFFFFFFF;
 		tsync_inc_h = I40E_PTP_40GB_INCVAL >> 32;
 		break;
-	case ETH_LINK_SPEED_10G:
+	case ETH_SPEED_NUM_10G:
 		tsync_inc_l = I40E_PTP_10GB_INCVAL & 0xFFFFFFFF;
 		tsync_inc_h = I40E_PTP_10GB_INCVAL >> 32;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		tsync_inc_l = I40E_PTP_1GB_INCVAL & 0xFFFFFFFF;
 		tsync_inc_h = I40E_PTP_1GB_INCVAL >> 32;
 		break;
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
index 80dc920..7ac5c48 100644
@@ -1916,7 +1916,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	else {
 		/* Always assume it's up, for Linux driver PF host */
 		new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-		new_link.link_speed  = ETH_LINK_SPEED_10000;
+		new_link.link_speed  = ETH_SPEED_NUM_10G;
 		new_link.link_status = ETH_LINK_UP;
 	}
 	i40evf_dev_atomic_write_link_status(dev, &new_link);
drivers/net/ixgbe/ixgbe_ethdev.c +11 -11
index 99c55bd..1fa17b5 100644
@@ -2138,17 +2138,17 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 				IXGBE_LINK_SPEED_82599_AUTONEG :
 				IXGBE_LINK_SPEED_82598_AUTONEG;
 		break;
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		/*
 		 * Invalid for 82598 but error will be detected by
 		 * ixgbe_setup_link()
 		 */
 		speed = IXGBE_LINK_SPEED_100_FULL;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		speed = IXGBE_LINK_SPEED_1GB_FULL;
 		break;
-	case ETH_LINK_SPEED_10000:
+	case ETH_SPEED_NUM_10G:
 		speed = IXGBE_LINK_SPEED_10GB_FULL;
 		break;
 	default:
@@ -2972,7 +2972,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 		diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
 
 	if (diag != 0) {
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		link.link_duplex = ETH_LINK_HALF_DUPLEX;
 		rte_ixgbe_dev_atomic_write_link_status(dev, &link);
 		if (link.link_status == old.link_status)
@@ -2993,19 +2993,19 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	default:
 	case IXGBE_LINK_SPEED_UNKNOWN:
 		link.link_duplex = ETH_LINK_HALF_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 
 	case IXGBE_LINK_SPEED_100_FULL:
-		link.link_speed = ETH_LINK_SPEED_100;
+		link.link_speed = ETH_SPEED_NUM_100M;
 		break;
 
 	case IXGBE_LINK_SPEED_1GB_FULL:
-		link.link_speed = ETH_LINK_SPEED_1000;
+		link.link_speed = ETH_SPEED_NUM_1G;
 		break;
 
 	case IXGBE_LINK_SPEED_10GB_FULL:
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
 		break;
 	}
 	rte_ixgbe_dev_atomic_write_link_status(dev, &link);
@@ -5782,15 +5782,15 @@ ixgbe_start_timecounters(struct rte_eth_dev *dev)
 	rte_ixgbe_dev_atomic_read_link_status(dev, &link);
 
 	switch (link.link_speed) {
-	case ETH_LINK_SPEED_100:
+	case ETH_SPEED_NUM_100M:
 		incval = IXGBE_INCVAL_100;
 		shift = IXGBE_INCVAL_SHIFT_100;
 		break;
-	case ETH_LINK_SPEED_1000:
+	case ETH_SPEED_NUM_1G:
 		incval = IXGBE_INCVAL_1GB;
 		shift = IXGBE_INCVAL_SHIFT_1GB;
 		break;
-	case ETH_LINK_SPEED_10000:
+	case ETH_SPEED_NUM_10G:
 	default:
 		incval = IXGBE_INCVAL_10GB;
 		shift = IXGBE_INCVAL_SHIFT_10GB;
drivers/net/mpipe/mpipe_tilegx.c +2 -2
index 118d3a5..fc1f90d 100644
@@ -389,11 +389,11 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 		speed = state & GXIO_MPIPE_LINK_SPEED_MASK;
 
 		if (speed == GXIO_MPIPE_LINK_1G) {
-			new.link_speed = ETH_LINK_SPEED_1000;
+			new.link_speed = ETH_SPEED_NUM_1G;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
 			new.link_status = ETH_LINK_UP;
 		} else if (speed == GXIO_MPIPE_LINK_10G) {
-			new.link_speed = ETH_LINK_SPEED_10000;
+			new.link_speed = ETH_SPEED_NUM_10G;
 			new.link_duplex = ETH_LINK_FULL_DUPLEX;
 			new.link_status = ETH_LINK_UP;
 		}
drivers/net/nfp/nfp_net.c +1 -1
index d1e004a..059b554 100644
@@ -831,7 +831,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)
 
 	link.link_duplex = ETH_LINK_FULL_DUPLEX;
 	/* Other cards can limit the tx and rx rate per VF */
-	link.link_speed = ETH_LINK_SPEED_40G;
+	link.link_speed = ETH_SPEED_NUM_40G;
 
 	if (old.link_status != link.link_status) {
 		nfp_net_dev_atomic_write_link_status(dev, &link);
drivers/net/null/rte_eth_null.c +1 -1
index 2e60823..3f37c54 100644
@@ -93,7 +93,7 @@ struct pmd_internals {
 static struct ether_addr eth_addr = { .addr_bytes = {0} };
 static const char *drivername = "Null PMD";
 static struct rte_eth_link pmd_link = {
-	.link_speed = 10000,
+	.link_speed = ETH_SPEED_NUM_10G,
 	.link_duplex = ETH_LINK_FULL_DUPLEX,
 	.link_status = ETH_LINK_DOWN,
 };
drivers/net/pcap/rte_eth_pcap.c +1 -1
index 2b32e8d..5251b9f 100644
@@ -125,7 +125,7 @@ static int open_single_iface(const char *iface, pcap_t **pcap);
 static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
 		.link_status = ETH_LINK_DOWN,
 };
drivers/net/ring/rte_eth_ring.c +1 -1
index 4fcc2aa..bd18508 100644
@@ -71,7 +71,7 @@ struct pmd_internals {
 
 static const char *drivername = "Rings PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
 		.link_status = ETH_LINK_DOWN,
 };
drivers/net/szedata2/rte_eth_szedata2.c +1 -1
index 38be554..9d46987 100644
@@ -111,7 +111,7 @@ static struct ether_addr eth_addr = {
 };
 static const char *drivername = "SZEdata2 PMD";
 static struct rte_eth_link pmd_link = {
-		.link_speed = ETH_LINK_SPEED_10G,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
 		.link_status = ETH_LINK_DOWN
 };
drivers/net/vmxnet3/vmxnet3_ethdev.c +1 -1
index 06793a6..64a035c 100644
@@ -738,7 +738,7 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai
 	if (ret & 0x1) {
 		link.link_status = ETH_LINK_UP;
 		link.link_duplex = ETH_LINK_FULL_DUPLEX;
-		link.link_speed = ETH_LINK_SPEED_10000;
+		link.link_speed = ETH_SPEED_NUM_10G;
 	}
 
 	vmxnet3_dev_atomic_write_link_status(dev, &link);
drivers/net/xenvirt/rte_eth_xenvirt.c +1 -1
index 9453a06..77d3ba1 100644
@@ -70,7 +70,7 @@ static int virtio_idx = 0;
 static const char *drivername = "xen virtio PMD";
 
 static struct rte_eth_link pmd_link = {
-		.link_speed = 10000,
+		.link_speed = ETH_SPEED_NUM_10G,
 		.link_duplex = ETH_LINK_FULL_DUPLEX,
 		.link_status = ETH_LINK_DOWN,
 };
lib/librte_ether/rte_ethdev.h +18 -11
index 12b552d..b68e017 100644
@@ -242,23 +242,30 @@ struct rte_eth_stats {
 };
 
 /**
+ * Ethernet numeric link speeds in Mbps
+ */
+#define ETH_LINK_SPEED_AUTONEG     0 /**< Auto-negotiate link speed. */
+#define ETH_SPEED_NUM_10M         10 /**<  10 Mbps */
+#define ETH_SPEED_NUM_100M       100 /**< 100 Mbps */
+#define ETH_SPEED_NUM_1G        1000 /**<   1 Gbps */
+#define ETH_SPEED_NUM_2_5G      2500 /**< 2.5 Gbps */
+#define ETH_SPEED_NUM_5G        5000 /**<   5 Gbps */
+#define ETH_SPEED_NUM_10G      10000 /**<  10 Gbps */
+#define ETH_SPEED_NUM_20G      20000 /**<  20 Gbps */
+#define ETH_SPEED_NUM_25G      25000 /**<  25 Gbps */
+#define ETH_SPEED_NUM_40G      40000 /**<  40 Gbps */
+#define ETH_SPEED_NUM_50G      50000 /**<  50 Gbps */
+#define ETH_SPEED_NUM_56G      56000 /**<  56 Gbps */
+
+/**
  * A structure used to retrieve link-level information of an Ethernet port.
  */
 struct rte_eth_link {
-	uint16_t link_speed;      /**< ETH_LINK_SPEED_[10, 100, 1000, 10000] */
+	uint16_t link_speed;      /**< ETH_SPEED_NUM_ */
 	uint16_t link_duplex;     /**< ETH_LINK_[HALF/FULL]_DUPLEX */
 	uint8_t  link_status : 1; /**< ETH_LINK_[DOWN/UP] */
 }__attribute__((aligned(8)));     /**< aligned for atomic64 read/write */
 
-#define ETH_LINK_SPEED_AUTONEG  0       /**< Auto-negotiate link speed. */
-#define ETH_LINK_SPEED_10       10      /**< 10 megabits/second. */
-#define ETH_LINK_SPEED_100      100     /**< 100 megabits/second. */
-#define ETH_LINK_SPEED_1000     1000    /**< 1 gigabits/second. */
-#define ETH_LINK_SPEED_10000    10000   /**< 10 gigabits/second. */
-#define ETH_LINK_SPEED_10G      10000   /**< alias of 10 gigabits/second. */
-#define ETH_LINK_SPEED_20G      20000   /**< 20 gigabits/second. */
-#define ETH_LINK_SPEED_40G      40000   /**< 40 gigabits/second. */
-
 /* Utility constants */
 #define ETH_LINK_AUTONEG_DUPLEX 0       /**< Auto-negotiate duplex. */
 #define ETH_LINK_HALF_DUPLEX    1       /**< Half-duplex connection. */
@@ -779,7 +786,7 @@ struct rte_intr_conf {
  */
 struct rte_eth_conf {
 	uint16_t link_speed;
-	/**< ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation */
+	/**< ETH_SPEED_NUM_ or 0 for autonegotiation */
 	uint16_t link_duplex;
 	/**< ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation */
 	struct rte_eth_rxmode rxmode; /**< Port RX configuration. */
Signature · 1 line
2.7.0
#71 lore raw

PATCH v10 5/8 ethdev: add speed capabilities

In reply to Thomas Monjalon

From: Marc Sune <[email protected]>

The speed capabilities of a device can be retrieved with rte_eth_dev_info_get().

The new field speed_capa is initialized in the drivers without taking care of device characteristics in this patch. When the capabilities of a driver are accurate, the table in overview.rst must be filled.

---
 doc/guides/nics/overview.rst           |  1 +
 doc/guides/rel_notes/release_16_04.rst |  8 ++++++++
 drivers/net/bnx2x/bnx2x_ethdev.c       |  1 +
 drivers/net/cxgbe/cxgbe_ethdev.c       |  1 +
 drivers/net/e1000/em_ethdev.c          |  4 ++++
 drivers/net/e1000/igb_ethdev.c         |  4 ++++
 drivers/net/fm10k/fm10k_ethdev.c       |  4 ++++
 drivers/net/i40e/i40e_ethdev.c         |  8 ++++++++
 drivers/net/ixgbe/ixgbe_ethdev.c       |  8 ++++++++
 drivers/net/mlx4/mlx4.c                |  2 ++
 drivers/net/mlx5/mlx5_ethdev.c         |  3 +++
 drivers/net/nfp/nfp_net.c              |  2 ++
 lib/librte_ether/rte_ethdev.h          | 21 +++++++++++++++++++++
 13 files changed, 67 insertions(+)
doc/guides/nics/overview.rst +1 -0
index 2d4f014..893da5f 100644
@@ -88,6 +88,7 @@ Most of these differences are summarized below.
    ==================== = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    link status                  X     X X                                   X
    link status event                  X X
+   speed capabilities
    Rx interrupt                       X X X X
    queue start/stop             X     X X X X                               X
    MTU update                   X
doc/guides/rel_notes/release_16_04.rst +8 -0
index b729b67..fd24a6f 100644
@@ -47,6 +47,11 @@ This section should contain new features added in this release. Sample format:
   A new function ``rte_pktmbuf_alloc_bulk()`` has been added to allow the user
   to allocate a bulk of mbufs.
 
+* **Added device link speed capabilities.**
+
+  The structure ``rte_eth_dev_info`` has now a ``speed_capa`` bitmap, which
+  allows the application to know the supported speeds of each device.
+
 * **Virtio 1.0.**
 
   Enabled virtio 1.0 support for virtio pmd driver.
@@ -208,6 +213,9 @@ This section should contain API changes. Sample format:
 * Add a short 1-2 sentence description of the API change. Use fixed width
   quotes for ``rte_function_names`` or ``rte_struct_names``. Use the past tense.
 
+* The ethdev structure ``rte_eth_dev_info`` was changed to support device
+  speed capabilities.
+
 * The functions ``rte_eth_dev_udp_tunnel_add`` and ``rte_eth_dev_udp_tunnel_delete``
   have been renamed into ``rte_eth_dev_udp_tunnel_port_add`` and
   ``rte_eth_dev_udp_tunnel_port_delete``.
drivers/net/bnx2x/bnx2x_ethdev.c +1 -0
index f109900..b86784e 100644
@@ -347,6 +347,7 @@ bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_inf
 	dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
 	dev_info->max_rx_pktlen  = BNX2X_MAX_RX_PKT_LEN;
 	dev_info->max_mac_addrs  = BNX2X_MAX_MAC_ADDRS;
+	dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
 }
 
 static void
drivers/net/cxgbe/cxgbe_ethdev.c +1 -0
index 97ef152..05b954d 100644
@@ -171,6 +171,7 @@ static void cxgbe_dev_info_get(struct rte_eth_dev *eth_dev,
 
 	device_info->rx_desc_lim = cxgbe_desc_lim;
 	device_info->tx_desc_lim = cxgbe_desc_lim;
+	device_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G;
 }
 
 static void cxgbe_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
drivers/net/e1000/em_ethdev.c +4 -0
index 84845e7..dddffff 100644
@@ -1023,6 +1023,10 @@ eth_em_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_min = E1000_MIN_RING_DESC,
 		.nb_align = EM_TXD_ALIGN,
 	};
+
+	dev_info->speed_capa = ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M |
+			ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M |
+			ETH_LINK_SPEED_1G;
 }
 
 /* return 0 means link status changed, -1 means not changed */
drivers/net/e1000/igb_ethdev.c +4 -0
index b4c8982..743fe1b 100644
@@ -1910,6 +1910,10 @@ eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->rx_desc_lim = rx_desc_lim;
 	dev_info->tx_desc_lim = tx_desc_lim;
+
+	dev_info->speed_capa = ETH_LINK_SPEED_10M_HD | ETH_LINK_SPEED_10M |
+			ETH_LINK_SPEED_100M_HD | ETH_LINK_SPEED_100M |
+			ETH_LINK_SPEED_1G;
 }
 
 static void
drivers/net/fm10k/fm10k_ethdev.c +4 -0
index 378faf2..4d8c6bf 100644
@@ -1333,6 +1333,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
 		.nb_min = FM10K_MIN_TX_DESC,
 		.nb_align = FM10K_MULT_TX_DESC,
 	};
+
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_2_5G |
+			ETH_LINK_SPEED_10G | ETH_LINK_SPEED_25G |
+			ETH_LINK_SPEED_40G;
 }
 
 static int
drivers/net/i40e/i40e_ethdev.c +8 -0
index 17b58a8..3b2a4ae 100644
@@ -2265,6 +2265,7 @@ static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vsi *vsi = pf->main_vsi;
 
 	dev_info->max_rx_queues = vsi->nb_qps;
@@ -2336,6 +2337,13 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->max_rx_queues += dev_info->vmdq_queue_num;
 		dev_info->max_tx_queues += dev_info->vmdq_queue_num;
 	}
+
+	if (i40e_is_40G_device(hw->device_id))
+		/* For XL710 */
+		dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
+	else
+		/* For X710 */
+		dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G;
 }
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +8 -0
index 1fa17b5..1c108a0 100644
@@ -2891,6 +2891,14 @@ ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
 	dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
 	dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
+
+	dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
+	if (hw->mac.type == ixgbe_mac_X540 ||
+	    hw->mac.type == ixgbe_mac_X540_vf ||
+	    hw->mac.type == ixgbe_mac_X550 ||
+	    hw->mac.type == ixgbe_mac_X550_vf) {
+		dev_info->speed_capa |= ETH_LINK_SPEED_100M;
+	}
 }
 
 static void
drivers/net/mlx4/mlx4.c +2 -0
index f41817b..7397cbf 100644
@@ -4264,6 +4264,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		 0);
 	if (priv_get_ifname(priv, &ifname) == 0)
 		info->if_index = if_nametoindex(ifname);
+	info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_40G |
+			ETH_LINK_SPEED_56G;
 	priv_unlock(priv);
 }
 
drivers/net/mlx5/mlx5_ethdev.c +3 -0
index 1159fa3..7494f69 100644
@@ -523,6 +523,9 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 	 * size if it is not fixed.
 	 * The API should be updated to solve this problem. */
 	info->reta_size = priv->ind_table_max_size;
+	info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
+			ETH_LINK_SPEED_25G | ETH_LINK_SPEED_40G |
+			ETH_LINK_SPEED_50G;
 	priv_unlock(priv);
 }
 
drivers/net/nfp/nfp_net.c +2 -0
index 059b554..be1a364 100644
@@ -1071,6 +1071,8 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 	dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+
+	dev_info->speed_capa = ETH_LINK_SPEED_50G;
 }
 
 static uint32_t
lib/librte_ether/rte_ethdev.h +21 -0
index b68e017..017e24b 100644
@@ -242,6 +242,23 @@ struct rte_eth_stats {
 };
 
 /**
+ * Device supported speeds bitmap flags
+ */
+#define ETH_LINK_SPEED_10M_HD   (1 <<  1)  /**<  10 Mbps half-duplex */
+#define ETH_LINK_SPEED_10M      (1 <<  2)  /**<  10 Mbps full-duplex */
+#define ETH_LINK_SPEED_100M_HD  (1 <<  3)  /**< 100 Mbps half-duplex */
+#define ETH_LINK_SPEED_100M     (1 <<  4)  /**< 100 Mbps full-duplex */
+#define ETH_LINK_SPEED_1G       (1 <<  5)  /**<   1 Gbps */
+#define ETH_LINK_SPEED_2_5G     (1 <<  6)  /**< 2.5 Gbps */
+#define ETH_LINK_SPEED_5G       (1 <<  7)  /**<   5 Gbps */
+#define ETH_LINK_SPEED_10G      (1 <<  8)  /**<  10 Gbps */
+#define ETH_LINK_SPEED_20G      (1 <<  9)  /**<  20 Gbps */
+#define ETH_LINK_SPEED_25G      (1 << 10)  /**<  25 Gbps */
+#define ETH_LINK_SPEED_40G      (1 << 11)  /**<  40 Gbps */
+#define ETH_LINK_SPEED_50G      (1 << 12)  /**<  50 Gbps */
+#define ETH_LINK_SPEED_56G      (1 << 13)  /**<  56 Gbps */
+
+/**
  * Ethernet numeric link speeds in Mbps
  */
 #define ETH_LINK_SPEED_AUTONEG     0 /**< Auto-negotiate link speed. */
@@ -850,6 +867,9 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
+/**
+ * Ethernet device information
+ */
 struct rte_eth_dev_info {
 	struct rte_pci_device *pci_dev; /**< Device PCI information. */
 	const char *driver_name; /**< Device Driver name. */
@@ -878,6 +898,7 @@ struct rte_eth_dev_info {
 	uint16_t vmdq_pool_base;  /**< First ID of VMDQ pools. */
 	struct rte_eth_desc_lim rx_desc_lim;  /**< RX descriptors limits */
 	struct rte_eth_desc_lim tx_desc_lim;  /**< TX descriptors limits */
+	uint32_t speed_capa;  /**< Supported speeds bitmap (ETH_LINK_SPEED_). */
 };
 
 /**
Signature · 1 line
2.7.0