Skip to contentSkip to conversation

net/i40e: fix ethertype filter restore diagnostics

PATCH Superseded Artem Novikov 2 participants 3 messages Sep 14 – Oct 5 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix ethertype filter restore diagnostics

The control packet filter command only fills its statistics output on success. The restore path logs the last output even when the command fails, and reads uninitialized statistics when the filter list is empty. It also ignores the command status.

Check each restore result and log failures with the affected filter. Only report statistics after a successful command, when all fields are valid. Continue restoring the remaining filters after an error, preserving the existing best-effort restore policy.

Fixes ddcd4d4dbbe0 ("net/i40e: restore ethertype filter")
---
 drivers/net/intel/i40e/i40e_ethdev.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +16 -7
index b6b2d291eee4f13ae59c80c5a281cee6d4be2f48..f135bd13dcfc885e030d17798159ae9b4bfb5f07 100644
@@ -11617,6 +11617,7 @@ i40e_ethertype_filter_restore(struct i40e_pf *pf)
 		*ethertype_list = &pf->ethertype.ethertype_list;
 	struct i40e_ethertype_filter *f;
 	struct i40e_control_filter_stats stats;
+	enum i40e_status_code ret;
 	uint16_t flags;
 
 	TAILQ_FOREACH(f, ethertype_list, rules) {
@@ -11627,18 +11628,26 @@ i40e_ethertype_filter_restore(struct i40e_pf *pf)
 			flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
 		flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
 
-		memset(&stats, 0, sizeof(stats));
-		i40e_aq_add_rem_control_packet_filter(hw,
+		ret = i40e_aq_add_rem_control_packet_filter(hw,
 					    f->input.mac_addr.addr_bytes,
 					    f->input.ether_type,
 					    flags, pf->main_vsi->seid,
 					    f->queue, 1, &stats, NULL);
+		if (ret != I40E_SUCCESS) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to restore ethertype filter, "
+				    "ether_type=0x%04x, queue=%u, vsi_seid=%u, err %d",
+				    f->input.ether_type, f->queue,
+				    pf->main_vsi->seid, ret);
+			continue;
+		}
+
+		PMD_DRV_LOG(INFO, "Ethertype filter:"
+			    " mac_etype_used = %u, etype_used = %u,"
+			    " mac_etype_free = %u, etype_free = %u",
+			    stats.mac_etype_used, stats.etype_used,
+			    stats.mac_etype_free, stats.etype_free);
 	}
-	PMD_DRV_LOG(INFO, "Ethertype filter:"
-		    " mac_etype_used = %u, etype_used = %u,"
-		    " mac_etype_free = %u, etype_free = %u",
-		    stats.mac_etype_used, stats.etype_used,
-		    stats.mac_etype_free, stats.etype_free);
 }
 
 /* Restore tunnel filter */
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/1 net/i40e: fix ethertype filter restore diagnostics

The control packet filter command only fills its statistics output on success. The restore path ignores command failures and logs statistics even if no command succeeds. With an empty filter list, it reads uninitialized statistics.

Check each restore result and log failures with the affected filter. Continue restoring the remaining filters after an error. Log resource usage once after the loop, using the last successful command's statistics, and skip this log if no command succeeded. The command helper leaves the statistics unchanged on failure.

Fixes ddcd4d4dbbe0 ("net/i40e: restore ethertype filter")

---
v2:
* Log resource statistics once, after the last successful restore.
* Keep per-filter error diagnostics and continue after failed commands.
* Keep the error format string on one line.

 drivers/net/intel/i40e/i40e_ethdev.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/net/intel/i40e/i40e_ethdev.c +20 -7
index d64d8dd7b5662cb79f52a3a256765a07588bac1e..208d72bac0d8c2acba080cb2f650084b8719ecd1 100644
@@ -11630,7 +11630,9 @@ i40e_ethertype_filter_restore(struct i40e_pf *pf)
 		*ethertype_list = &pf->ethertype.ethertype_list;
 	struct i40e_ethertype_filter *f;
 	struct i40e_control_filter_stats stats;
+	enum i40e_status_code ret;
 	uint16_t flags;
+	bool stats_valid = false;
 
 	TAILQ_FOREACH(f, ethertype_list, rules) {
 		flags = 0;
@@ -11640,18 +11642,29 @@ i40e_ethertype_filter_restore(struct i40e_pf *pf)
 			flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
 		flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
 
-		memset(&stats, 0, sizeof(stats));
-		i40e_aq_add_rem_control_packet_filter(hw,
+		ret = i40e_aq_add_rem_control_packet_filter(hw,
 					    f->input.mac_addr.addr_bytes,
 					    f->input.ether_type,
 					    flags, pf->main_vsi->seid,
 					    f->queue, 1, &stats, NULL);
+		if (ret != I40E_SUCCESS) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to restore ethertype filter, ether_type=0x%04x, queue=%u, vsi_seid=%u, err %d",
+				    f->input.ether_type, f->queue,
+				    pf->main_vsi->seid, ret);
+			continue;
+		}
+
+		stats_valid = true;
+	}
+
+	if (stats_valid) {
+		PMD_DRV_LOG(INFO, "Ethertype filter:"
+			    " mac_etype_used = %u, etype_used = %u,"
+			    " mac_etype_free = %u, etype_free = %u",
+			    stats.mac_etype_used, stats.etype_used,
+			    stats.mac_etype_free, stats.etype_free);
 	}
-	PMD_DRV_LOG(INFO, "Ethertype filter:"
-		    " mac_etype_used = %u, etype_used = %u,"
-		    " mac_etype_free = %u, etype_free = %u",
-		    stats.mac_etype_used, stats.etype_used,
-		    stats.mac_etype_free, stats.etype_free);
 }
 
 /* Restore tunnel filter */
Signature · 1 line
2.43.0
Acked-by on v2 1/1 Applied
#2 lore raw
Quoted 11 lines · Artem Novikov

The control packet filter command only fills its statistics output on success. The restore path ignores command failures and logs statistics even if no command succeeds. With an empty filter list, it reads uninitialized statistics.

Check each restore result and log failures with the affected filter. Continue restoring the remaining filters after an error. Log resource usage once after the loop, using the last successful command's statistics, and skip this log if no command succeeded. The command helper leaves the statistics unchanged on failure.

Quoted 6 lines
Fixes ddcd4d4dbbe0 ("net/i40e: restore ethertype filter")

---

Applied to dpdk-next-net-intel.
Thanks,
/Bruce