Skip to contentSkip to conversation

net/ice: fix incorrect mbuf cleanup function

PATCH In review Bruce Richardson 2 participants 3 messages Feb 21, 2025 – Feb 25, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: fix incorrect mbuf cleanup function

The mbuf cleanup function is not being called correctly on close of the driver, due to the vector_tx flag not being set correctly on each Tx queue. Normally, this causes no visible problems, because the default is to have the vector flag unset, which means that, if vector Tx path is chosen, we only free every second mbuf in the descriptor vector ring - a subtle memory leak.

The reverse case - where we initially configure a port to use a vector driver, and then later reconfigure it for scalar - causes a segfault on close, as the vector cleanup is used on a scalar SW ring, and that vector path treats the extra metadata in the SW ring as mbufs to be freed.

This is due to an inconsistency across drivers on port start: in e.g. the i40e driver, the Rx and Tx functions are chosen before the individual queues are started, while in ice driver the order is reversed. Because the Tx function selection is done after the queues are initialized, the initialized queues use an old value of the overall flag indicating if a vector Tx path is being used.

Fix the issue by moving the Rx and Tx path selection before queue start.

Fixes 552979dfb1c9 ("net/intel: create common Tx queue mbuf cleanup")
---
 drivers/net/intel/ice/ice_ethdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/intel/ice/ice_ethdev.c +3 -3
index 0e092702cc..3cdfa16f77 100644
@@ -3961,6 +3961,9 @@ ice_dev_start(struct rte_eth_dev *dev)
 	ice_declare_bitmap(pmask, ICE_PROMISC_MAX);
 	ice_zero_bitmap(pmask, ICE_PROMISC_MAX);
 
+	ice_set_rx_function(dev);
+	ice_set_tx_function(dev);
+
 	/* program Tx queues' context in hardware */
 	for (nb_txq = 0; nb_txq < data->nb_tx_queues; nb_txq++) {
 		ret = ice_tx_queue_start(dev, nb_txq);
@@ -3989,9 +3992,6 @@ ice_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
-	ice_set_rx_function(dev);
-	ice_set_tx_function(dev);
-
 	mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
 			RTE_ETH_VLAN_EXTEND_MASK;
 	if (ice_is_dvm_ena(hw))
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Bruce Richardson

The mbuf cleanup function is not being called correctly on close of the driver, due to the vector_tx flag not being set correctly on each Tx queue. Normally, this causes no visible problems, because the default is to have the vector flag unset, which means that, if vector Tx path is chosen, we only free every second mbuf in the descriptor vector ring - a subtle memory leak.

The reverse case - where we initially configure a port to use a vector driver, and then later reconfigure it for scalar - causes a segfault on close, as the vector cleanup is used on a scalar SW ring, and that vector path treats the extra metadata in the SW ring as mbufs to be freed.

This is due to an inconsistency across drivers on port start: in e.g. the i40e driver, the Rx and Tx functions are chosen before the individual queues are started, while in ice driver the order is reversed. Because the Tx function selection is done after the queues are initialized, the initialized queues use an old value of the overall flag indicating if a vector Tx path is being used.

Quoted 6 lines

Fix the issue by moving the Rx and Tx path selection before queue start.

Fixes 552979dfb1c9 ("net/intel: create common Tx queue mbuf cleanup")

---

Signature · 2 lines
Thanks,
Anatoly
author Applied
#2 lore raw
Quoted 21 lines · Anatoly
Quoted 20 lines · Bruce Richardson

The mbuf cleanup function is not being called correctly on close of the driver, due to the vector_tx flag not being set correctly on each Tx queue. Normally, this causes no visible problems, because the default is to have the vector flag unset, which means that, if vector Tx path is chosen, we only free every second mbuf in the descriptor vector ring - a subtle memory leak.

The reverse case - where we initially configure a port to use a vector driver, and then later reconfigure it for scalar - causes a segfault on close, as the vector cleanup is used on a scalar SW ring, and that vector path treats the extra metadata in the SW ring as mbufs to be freed.

This is due to an inconsistency across drivers on port start: in e.g. the i40e driver, the Rx and Tx functions are chosen before the individual queues are started, while in ice driver the order is reversed. Because the Tx function selection is done after the queues are initialized, the initialized queues use an old value of the overall flag indicating if a vector Tx path is being used.

Quoted 8 lines
Quoted 6 lines

Fix the issue by moving the Rx and Tx path selection before queue start.

Fixes 552979dfb1c9 ("net/intel: create common Tx queue mbuf cleanup")

---

Applied to dpdk-next-net-intel.

/Bruce