net/bnxt: reset filter indices on free
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Tue, 10 Dec 2019 15:05:28 +0000 (20:35 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:45:23 +0000 (19:45 +0100)
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 Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_filter.c
drivers/net/bnxt/bnxt_flow.c

index 2f84794..146f04b 100644 (file)
@@ -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;
 }
index da1a6c2..0c410f8 100644 (file)
@@ -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);
 }
index 447a51b..7bd6811 100644 (file)
@@ -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);