Skip to contentSkip to conversation

net/i40e: fix memory leaks

PATCH In review Anurag Mandal 2 participants 4 messages Oct 23 Network drivers

lore
Share & tools
lore
#0 lore raw

cover net/i40e: fix memory leaks

This series fixes few memory leaks in the i40e PMD:

1. When the main VSI was released, only the VSIs attached to the floating VEB were released, not the VEB itself, leaking the VEB structure and its switch element. This only affects setups with floating VEB enabled.

2. The flow director programming packet memzone was reserved at setup but never freed, so it leaked whenever the port was closed.

Anurag Mandal (2):
net/i40e: fix floating VEB leak
net/i40e: fix FDIR memzone leak

 drivers/net/intel/i40e/i40e_ethdev.c | 1 +
 drivers/net/intel/i40e/i40e_ethdev.h | 1 +
 drivers/net/intel/i40e/i40e_fdir.c   | 4 ++++
 3 files changed, 6 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 net/i40e: fix floating VEB leak

With floating VEB enabled, i40e_vsi_release() releases the VSIs attached to the floating VEB of the main VSI but not the floating VEB itself, leaking the VEB structure and its switch element.

Release it once its VSIs are gone, as is already done for the regular VEB.

Fixes 440499cf5376 ("net/i40e: support floating VEB")
---
 drivers/net/intel/i40e/i40e_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/intel/i40e/i40e_ethdev.c +1 -0
index e26a849764..9ca01ecd34 100644
@@ -5329,6 +5329,7 @@ i40e_vsi_release(struct i40e_vsi *vsi)
 			if (i40e_vsi_release(vsi_list->vsi) != I40E_SUCCESS)
 				return -1;
 		}
+		i40e_veb_release(vsi->floating_veb);
 	}
 
 	/* Remove all macvlan filters of the VSI */
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 net/i40e: fix FDIR memzone leak

In reply to Anurag Mandal

The memzone holding the flow director programming packets is reserved in i40e_fdir_setup() but never freed, as i40e_fdir_teardown() only releases the FDIR queues and VSI.
It is therefore leaked when the port is closed.

Store the memzone pointer and free it on teardown.

Fixes a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes 71d35259ff67 ("i40e: tear down flow director")
---
 drivers/net/intel/i40e/i40e_ethdev.h | 1 +
 drivers/net/intel/i40e/i40e_fdir.c   | 4 ++++
 2 files changed, 5 insertions(+)
drivers/net/intel/i40e/i40e_ethdev.h +1 -0
index 68bff99b5d..77f79fc7da 100644
@@ -790,6 +790,7 @@ struct i40e_fdir_info {
 	struct ci_rx_queue *rxq;
 	void *prg_pkt[I40E_FDIR_PRG_PKT_CNT];     /* memory for fdir program packet */
 	uint64_t dma_addr[I40E_FDIR_PRG_PKT_CNT]; /* physic address of packet memory*/
+	const struct rte_memzone *prg_mz;         /* memzone backing prg_pkt */
 	/*
 	 * txq available buffer counter, indicates how many available buffers
 	 * for fdir programming, initialized as I40E_FDIR_PRG_PKT_CNT
drivers/net/intel/i40e/i40e_fdir.c +4 -0
index 71cab77e83..2464eb47c2 100644
@@ -241,6 +241,8 @@ i40e_fdir_setup(struct i40e_pf *pf)
 			I40E_FDIR_PKT_LEN * i;
 	}
 
+	pf->fdir.prg_mz = mz;
+
 	pf->fdir.match_counter_index = I40E_COUNTER_INDEX_FDIR(hw->pf_id);
 
 	PMD_DRV_LOG(INFO, "FDIR setup successfully, with programming queue %u.",
@@ -297,6 +299,8 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 	pf->fdir.rxq = NULL;
 	i40e_tx_queue_release(pf->fdir.txq);
 	pf->fdir.txq = NULL;
+	rte_memzone_free(pf->fdir.prg_mz);
+	pf->fdir.prg_mz = NULL;
 	i40e_vsi_release(vsi);
 	pf->fdir.fdir_vsi = NULL;
 }
Signature · 1 line
2.25.1
Acked-by on the v1 series
#3 lore raw
In reply to Anurag Mandal
Quoted 11 lines · Anurag Mandal

This series fixes few memory leaks in the i40e PMD:

1. When the main VSI was released, only the VSIs attached to the floating VEB were released, not the VEB itself, leaking the VEB structure and its switch element. This only affects setups with floating VEB enabled.

2. The flow director programming packet memzone was reserved at setup but never freed, so it leaked whenever the port was closed.

Quoted 9 lines

Anurag Mandal (2):
net/i40e: fix floating VEB leak
net/i40e: fix FDIR memzone leak

 drivers/net/intel/i40e/i40e_ethdev.c | 1 +
 drivers/net/intel/i40e/i40e_ethdev.h | 1 +
 drivers/net/intel/i40e/i40e_fdir.c   | 4 ++++
 3 files changed, 6 insertions(+)

Series applied to dpdk-next-net-intel,
Thanks,
/Bruce