From: Kalesh AP Date: Tue, 10 Dec 2019 15:05:28 +0000 (+0530) Subject: net/bnxt: reset filter indices on free X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7105de7085b022a84ffefbfad6a140e493ee0612;p=dpdk.git net/bnxt: reset filter indices on free 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 Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 2f847942c8..146f04b619 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 da1a6c24a9..0c410f8baf 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 447a51bc33..7bd6811f16 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);