Skip to contentSkip to conversation

net/intel: fix blocking link wait on device start

PATCH In review Ciara Loftus 2 participants 8 messages Jun 3 – Jun 9 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/intel: fix blocking link wait on device start

Device start in both ice and i40e has historically blocked for up to two seconds waiting for link to come up before returning. This causes noticeable startup delay when a link partner is slow to come up or absent entirely. This series reverts the wait in ice, and removes the wait in i40e while ensuring that the MAC config is applied when the link is up which is a requirement for some devices.

Ciara Loftus (2):
net/ice: revert fix link up when starting device net/i40e: fix blocking link wait on device start

 drivers/net/intel/i40e/i40e_ethdev.c | 25 +++++++++++++++++++++----
 drivers/net/intel/i40e/i40e_ethdev.h |  2 ++
 drivers/net/intel/ice/ice_ethdev.c   |  2 +-
 3 files changed, 24 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 net/ice: revert fix link up when starting device

This reverts commit 6c76b76dc64183eb2f24a52b90d4ff9feb4872f4.

The reverted commit worked around a potential timing issue where the link could be reported down immediately after the link was enabled during device start. The commit introduced a blocking wait which gave the driver a better chance to read the correct link state before returning from device start. However, since the auto link update flag is set when setting the link up in device start, an adminq notification should arrive once the link is up, which will be handled and correctly set the link status. This means we can remove the delay from device start as it does not need to guarantee link up before returning.

---
 drivers/net/intel/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/ice/ice_ethdev.c +1 -1
index d2734b6688..da570d03cb 100644
@@ -4464,7 +4464,7 @@ ice_dev_start(struct rte_eth_dev *dev)
 	ice_dev_set_link_up(dev);
 
 	/* Call get_link_info aq command to enable/disable LSE */
-	ice_link_update(dev, 1);
+	ice_link_update(dev, 0);
 
 	pf->adapter_stopped = false;
 
Signature · 1 line
2.43.0
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] net/ice: revert fix link up when starting device

Quoted 12 lines · Ciara Loftus

This reverts commit 6c76b76dc64183eb2f24a52b90d4ff9feb4872f4.

The reverted commit worked around a potential timing issue where the link could be reported down immediately after the link was enabled during device start. The commit introduced a blocking wait which gave the driver a better chance to read the correct link state before returning from device start. However, since the auto link update flag is set when setting the link up in device start, an adminq notification should arrive once the link is up, which will be handled and correctly set the link status. This means we can remove the delay from device start as it does not need to guarantee link up before returning.

Quoted 2 lines

---

#3 lore raw

Re: [PATCH 1/2] net/ice: revert fix link up when starting device

In reply to Ciara Loftus
Quoted 12 lines · Ciara Loftus

This reverts commit 6c76b76dc64183eb2f24a52b90d4ff9feb4872f4.

The reverted commit worked around a potential timing issue where the link could be reported down immediately after the link was enabled during device start. The commit introduced a blocking wait which gave the driver a better chance to read the correct link state before returning from device start. However, since the auto link update flag is set when setting the link up in device start, an adminq notification should arrive once the link is up, which will be handled and correctly set the link status. This means we can remove the delay from device start as it does not need to guarantee link up before returning.

Quoted 5 lines
---
 drivers/net/intel/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Should this revert be marked for backport, or is it safer to keep the LTS's as they are?

#4 lore raw

RE: [PATCH 1/2] net/ice: revert fix link up when starting device

Quoted 15 lines

Subject: Re: [PATCH 1/2] net/ice: revert fix link up when starting device

Quoted 12 lines · Ciara Loftus

This reverts commit 6c76b76dc64183eb2f24a52b90d4ff9feb4872f4.

The reverted commit worked around a potential timing issue where the link could be reported down immediately after the link was enabled during device start. The commit introduced a blocking wait which gave the driver a better chance to read the correct link state before returning from device start. However, since the auto link update flag is set when setting the link up in device start, an adminq notification should arrive once the link is up, which will be handled and correctly set the link status. This means we can remove the delay from device start as it does not need to guarantee link up before returning.

Quoted 7 lines
Quoted 5 lines
---
 drivers/net/intel/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Should this revert be marked for backport, or is it safer to keep the LTS's as they are?

I think it shouldn't be marked for backport.
With this patch we now rely on the adminq link status notification to correct an incorrect link status read at dev_start. That requires commit e01265e4a9bf ("net/ice: get link status updates via adminq message") which was only introduced this year and not present in any LTS.

#5 lore raw

PATCH 2/2 net/i40e: fix blocking link wait on device start

In reply to Ciara Loftus

Currently, device start performs a synchronous link status update, blocking for up to one second if the link is not yet up. This causes unnecessary startup delay in scenarios where the link partner is slow to come up or unavailable.

The wait was introduced alongside the maximum frame size MAC config command. Some devices require the link to be up before issuing that command, so the solution was to block at device start until link was established.

To address the issue, remove the unconditional blocking wait. Take note if the link was down at the time of the MAC config command during device start and if it was, re-issue the command upon notification of the first link-up event.

In the case where all interrupt vectors are consumed by Rx queues, no interrupt or alarm handler is available to process link-up events. The blocking wait is retained for this narrow case to preserve correctness.

Fixes 82fcf20d039c ("net/i40e: fix maximum frame size configuration")
---
 drivers/net/intel/i40e/i40e_ethdev.c | 25 +++++++++++++++++++++----
 drivers/net/intel/i40e/i40e_ethdev.h |  2 ++
 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +21 -4
index e818b6fc7c..a7c00033e5 100644
@@ -2565,15 +2565,19 @@ i40e_dev_start(struct rte_eth_dev *dev)
 					       I40E_AQ_EVENT_MEDIA_NA), NULL);
 		if (ret != I40E_SUCCESS)
 			PMD_DRV_LOG(WARNING, "Fail to set phy mask");
-
-		/* Call get_link_info aq command to enable/disable LSE */
-		i40e_dev_link_update(dev, 1);
 	}
 
 	if (dev->data->dev_conf.intr_conf.rxq == 0) {
+		i40e_dev_link_update(dev, 0);
+		pf->mac_config_on_link_up = !dev->data->dev_link.link_status;
 		rte_eal_alarm_set(I40E_ALARM_INTERVAL,
 				  i40e_dev_alarm_handler, dev);
 	} else {
+		/* Block if no interrupt handler can process link-up events, to help
+		 * ensure that MAC config is applied when the link is up.
+		 */
+		i40e_dev_link_update(dev, !rte_intr_allow_others(intr_handle));
+		pf->mac_config_on_link_up = !dev->data->dev_link.link_status;
 		/* enable uio intr after callback register */
 		rte_intr_enable(intr_handle);
 	}
@@ -6867,6 +6871,7 @@ static void
 i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_arq_event_info info;
 	uint16_t pending, opcode;
 	uint8_t msg_buf[I40E_AQ_BUF_SZ] = {0};
@@ -6899,9 +6904,21 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
 			break;
 		case i40e_aqc_opc_get_link_status:
 			ret = i40e_dev_link_update(dev, 0);
-			if (!ret)
+			/* Some devices require MAC config to be applied when the link comes up. */
+			if (!ret) {
+				if (pf->mac_config_on_link_up && dev->data->dev_link.link_status) {
+					uint16_t max_frame_size;
+
+					max_frame_size = dev->data->mtu ?
+						dev->data->mtu + I40E_ETH_OVERHEAD :
+						I40E_FRAME_SIZE_MAX;
+					i40e_aq_set_mac_config(hw, max_frame_size, TRUE,
+								false, 0, NULL);
+					pf->mac_config_on_link_up = false;
+				}
 				rte_eth_dev_callback_process(dev,
 					RTE_ETH_EVENT_INTR_LSC, NULL);
+			}
 			break;
 		default:
 			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
drivers/net/intel/i40e/i40e_ethdev.h +2 -0
index d57c53f661..7524defdb7 100644
@@ -1191,6 +1191,8 @@ struct i40e_pf {
 
 	/* When firmware > 8.3, the enable flag for outer VLAN processing */
 	bool fw8_3gt;
+	/* MAC config needs re-applying when link first comes up */
+	bool mac_config_on_link_up;
 
 	struct i40e_vf_msg_cfg vf_msg_cfg;
 	uint64_t prev_rx_bytes;
Signature · 1 line
2.43.0
Acked-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] net/i40e: fix blocking link wait on device start

Quoted 15 lines · Ciara Loftus

Currently, device start performs a synchronous link status update, blocking for up to one second if the link is not yet up. This causes unnecessary startup delay in scenarios where the link partner is slow to come up or unavailable.

The wait was introduced alongside the maximum frame size MAC config command. Some devices require the link to be up before issuing that command, so the solution was to block at device start until link was established.

To address the issue, remove the unconditional blocking wait. Take note if the link was down at the time of the MAC config command during device start and if it was, re-issue the command upon notification of the first link-up event.

Quoted 8 lines

In the case where all interrupt vectors are consumed by Rx queues, no interrupt or alarm handler is available to process link-up events. The blocking wait is retained for this narrow case to preserve correctness.

Fixes 82fcf20d039c ("net/i40e: fix maximum frame size configuration")
#7 lore raw
In reply to Ciara Loftus
Quoted 7 lines · Ciara Loftus

Device start in both ice and i40e has historically blocked for up to two seconds waiting for link to come up before returning. This causes noticeable startup delay when a link partner is slow to come up or absent entirely. This series reverts the wait in ice, and removes the wait in i40e while ensuring that the MAC config is applied when the link is up which is a requirement for some devices.

Quoted 10 lines

Ciara Loftus (2):
net/ice: revert fix link up when starting device net/i40e: fix blocking link wait on device start

 drivers/net/intel/i40e/i40e_ethdev.c | 25 +++++++++++++++++++++----
 drivers/net/intel/i40e/i40e_ethdev.h |  2 ++
 drivers/net/intel/ice/ice_ethdev.c   |  2 +-
 3 files changed, 24 insertions(+), 5 deletions(-)

Series applied to dpdk-next-net-intel.

Thanks,
/Bruce