[6/6] net/ionic: correctly set link speed and autonegotiation

Message ID 20210111190209.70928-7-aboyer@pensando.io (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/ionic: fix device configuration and init |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Boyer Jan. 11, 2021, 7:02 p.m. UTC
  Don't assume autoneg in link_update().

Always call ionic_dev_cmd_port_autoneg() in start().

This allows the client to specify the link settings.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
---
 drivers/net/ionic/ionic_ethdev.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
  

Comments

Ferruh Yigit Jan. 18, 2021, 5:10 p.m. UTC | #1
On 1/11/2021 7:02 PM, Andrew Boyer wrote:
> Don't assume autoneg in link_update().
> 
> Always call ionic_dev_cmd_port_autoneg() in start().
> 
> This allows the client to specify the link settings.
> 
> Signed-off-by: Andrew Boyer <aboyer@pensando.io>

     Fixes: 598f6726390f ("net/ionic: add basic port operations")
     Cc: stable@dpdk.org
  

Patch

diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 838e93ef7..2face7c63 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -276,7 +276,10 @@  ionic_dev_link_update(struct rte_eth_dev *eth_dev,
 
 	/* Initialize */
 	memset(&link, 0, sizeof(link));
-	link.link_autoneg = ETH_LINK_AUTONEG;
+
+	if (adapter->idev.port_info->config.an_enable) {
+		link.link_autoneg = ETH_LINK_AUTONEG;
+	}
 
 	if (!adapter->link_up ||
 	    !(lif->state & IONIC_LIF_F_UP)) {
@@ -869,7 +872,8 @@  ionic_dev_start(struct rte_eth_dev *eth_dev)
 	struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
 	struct ionic_adapter *adapter = lif->adapter;
 	struct ionic_dev *idev = &adapter->idev;
-	uint32_t allowed_speeds;
+	uint32_t speed = 0, allowed_speeds;
+	uint8_t an_enable;
 	int err;
 
 	IONIC_PRINT_CALL();
@@ -896,11 +900,23 @@  ionic_dev_start(struct rte_eth_dev *eth_dev)
 		return err;
 	}
 
-	if (eth_dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
-		uint32_t speed = ionic_parse_link_speeds(dev_conf->link_speeds);
+	/* Configure link */
+	an_enable = (dev_conf->link_speeds & ETH_LINK_SPEED_FIXED) == 0;
 
-		if (speed)
-			ionic_dev_cmd_port_speed(idev, speed);
+	ionic_dev_cmd_port_autoneg(idev, an_enable);
+	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+	if (err)
+		IONIC_PRINT(WARNING, "Failed to %s autonegotiation",
+			an_enable ? "enable" : "disable");
+
+	if (!an_enable)
+		speed = ionic_parse_link_speeds(dev_conf->link_speeds);
+	if (speed) {
+		ionic_dev_cmd_port_speed(idev, speed);
+		err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+		if (err)
+			IONIC_PRINT(WARNING, "Failed to set link speed %u",
+				speed);
 	}
 
 	ionic_dev_link_update(eth_dev, 0);