[5/6] net/bnxt: reset filter indices on free
diff mbox series

Message ID 20191210150529.27922-6-kalesh-anakkur.purayil@broadcom.com
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series
  • bnxt patchset
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Kalesh A P Dec. 10, 2019, 3:05 p.m. UTC
From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Fix bnxt_free_filter() to ensure that the filter indices
are reset correctly when a filter is freed.

This change helps in avoiding few duplicate code as well.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 10 ----------
 drivers/net/bnxt/bnxt_filter.c |  5 +++++
 drivers/net/bnxt/bnxt_flow.c   |  1 -
 3 files changed, 5 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 2f84794..146f04b 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1007,8 +1007,6 @@  static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev,
 				STAILQ_REMOVE(&vnic->filter, filter,
 						bnxt_filter_info, next);
 				bnxt_hwrm_clear_l2_filter(bp, filter);
-				filter->mac_index = INVALID_MAC_INDEX;
-				memset(&filter->l2_addr, 0, RTE_ETHER_ADDR_LEN);
 				bnxt_free_filter(bp, filter);
 			}
 			filter = temp_filter;
@@ -1055,7 +1053,6 @@  static int bnxt_add_mac_filter(struct bnxt *bp, struct bnxt_vnic_info *vnic,
 		else
 			STAILQ_INSERT_TAIL(&vnic->filter, filter, next);
 	} else {
-		memset(&filter->l2_addr, 0, RTE_ETHER_ADDR_LEN);
 		bnxt_free_filter(bp, filter);
 	}
 
@@ -1781,7 +1778,6 @@  static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id)
 		/* Free the newly allocated filter as we were
 		 * not able to create the filter in hardware.
 		 */
-		filter->fw_l2_filter_id = UINT64_MAX;
 		bnxt_free_filter(bp, filter);
 		return rc;
 	}
@@ -1831,7 +1827,6 @@  static int bnxt_del_dflt_mac_filter(struct bnxt *bp,
 				STAILQ_REMOVE(&vnic->filter, filter,
 					      bnxt_filter_info, next);
 				bnxt_free_filter(bp, filter);
-				filter->fw_l2_filter_id = UINT64_MAX;
 			}
 			return rc;
 		}
@@ -2705,14 +2700,11 @@  bnxt_cfg_ntuple_filter(struct bnxt *bp,
 
 		STAILQ_REMOVE(&vnic->filter, mfilter, bnxt_filter_info, next);
 		bnxt_free_filter(bp, mfilter);
-		mfilter->fw_l2_filter_id = -1;
 		bnxt_free_filter(bp, bfilter);
-		bfilter->fw_l2_filter_id = -1;
 	}
 
 	return 0;
 free_filter:
-	bfilter->fw_l2_filter_id = -1;
 	bnxt_free_filter(bp, bfilter);
 	return ret;
 }
@@ -3110,7 +3102,6 @@  bnxt_fdir_filter(struct rte_eth_dev *dev,
 			STAILQ_REMOVE(&vnic->filter, match,
 				      bnxt_filter_info, next);
 			bnxt_free_filter(bp, match);
-			filter->fw_l2_filter_id = -1;
 			bnxt_free_filter(bp, filter);
 		}
 		break;
@@ -3143,7 +3134,6 @@  bnxt_fdir_filter(struct rte_eth_dev *dev,
 	return ret;
 
 free_filter:
-	filter->fw_l2_filter_id = -1;
 	bnxt_free_filter(bp, filter);
 	return ret;
 }
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index da1a6c2..0c410f8 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -192,5 +192,10 @@  struct bnxt_filter_info *bnxt_get_unused_filter(struct bnxt *bp)
 
 void bnxt_free_filter(struct bnxt *bp, struct bnxt_filter_info *filter)
 {
+	memset(filter, 0, sizeof(*filter));
+	filter->mac_index = INVALID_MAC_INDEX;
+	filter->fw_l2_filter_id = UINT64_MAX;
+	filter->fw_ntuple_filter_id = UINT64_MAX;
+	filter->fw_em_filter_id = UINT64_MAX;
 	STAILQ_INSERT_TAIL(&bp->free_filter_list, filter, next);
 }
diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c
index 447a51b..7bd6811 100644
--- a/drivers/net/bnxt/bnxt_flow.c
+++ b/drivers/net/bnxt/bnxt_flow.c
@@ -1521,7 +1521,6 @@  bnxt_flow_validate(struct rte_eth_dev *dev,
 
 exit:
 	/* No need to hold on to this filter if we are just validating flow */
-	filter->fw_l2_filter_id = UINT64_MAX;
 	bnxt_free_filter(bp, filter);
 	bnxt_release_flow_lock(bp);