mirror of https://gitee.com/openkylin/linux.git
ice: Refactor switch rule management structures and functions
This patch is an adaptation of the work originally done by Grishma Kotecha <grishma.kotecha@intel.com> that in summary refactors the switch filtering logic in the driver. More specifically, - Update the recipe structure to also store list of rules - Update the existing code for recipes like MAC, VLAN, ethtype etc to use list head that is attached to switch recipe structure - Add a common function to search for a rule entry and add a new rule entry. Update the code to use this new function. - Refactor the rem_handle_vsi_list function to simplify the logic CC: Shannon Nelson <shannon.nelson@oracle.com> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Tony Brelinski <tonyx.brelinski@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
parent
74118f7af0
commit
80d144c9ac
|
@ -443,6 +443,8 @@ struct ice_aqc_vsi_props {
|
|||
u8 reserved[24];
|
||||
};
|
||||
|
||||
#define ICE_MAX_NUM_RECIPES 64
|
||||
|
||||
/* Add/Update/Remove/Get switch rules (indirect 0x02A0, 0x02A1, 0x02A2, 0x02A3)
|
||||
*/
|
||||
struct ice_aqc_sw_rules {
|
||||
|
|
|
@ -388,20 +388,7 @@ static enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw)
|
|||
|
||||
INIT_LIST_HEAD(&sw->vsi_list_map_head);
|
||||
|
||||
mutex_init(&sw->mac_list_lock);
|
||||
INIT_LIST_HEAD(&sw->mac_list_head);
|
||||
|
||||
mutex_init(&sw->vlan_list_lock);
|
||||
INIT_LIST_HEAD(&sw->vlan_list_head);
|
||||
|
||||
mutex_init(&sw->eth_m_list_lock);
|
||||
INIT_LIST_HEAD(&sw->eth_m_list_head);
|
||||
|
||||
mutex_init(&sw->promisc_list_lock);
|
||||
INIT_LIST_HEAD(&sw->promisc_list_head);
|
||||
|
||||
mutex_init(&sw->mac_vlan_list_lock);
|
||||
INIT_LIST_HEAD(&sw->mac_vlan_list_head);
|
||||
ice_init_def_sw_recp(hw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -415,19 +402,28 @@ static void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw)
|
|||
struct ice_switch_info *sw = hw->switch_info;
|
||||
struct ice_vsi_list_map_info *v_pos_map;
|
||||
struct ice_vsi_list_map_info *v_tmp_map;
|
||||
struct ice_sw_recipe *recps;
|
||||
u8 i;
|
||||
|
||||
list_for_each_entry_safe(v_pos_map, v_tmp_map, &sw->vsi_list_map_head,
|
||||
list_entry) {
|
||||
list_del(&v_pos_map->list_entry);
|
||||
devm_kfree(ice_hw_to_dev(hw), v_pos_map);
|
||||
}
|
||||
recps = hw->switch_info->recp_list;
|
||||
for (i = 0; i < ICE_SW_LKUP_LAST; i++) {
|
||||
struct ice_fltr_mgmt_list_entry *lst_itr, *tmp_entry;
|
||||
|
||||
mutex_destroy(&sw->mac_list_lock);
|
||||
mutex_destroy(&sw->vlan_list_lock);
|
||||
mutex_destroy(&sw->eth_m_list_lock);
|
||||
mutex_destroy(&sw->promisc_list_lock);
|
||||
mutex_destroy(&sw->mac_vlan_list_lock);
|
||||
recps[i].root_rid = i;
|
||||
mutex_destroy(&recps[i].filt_rule_lock);
|
||||
list_for_each_entry_safe(lst_itr, tmp_entry,
|
||||
&recps[i].filt_rules, list_entry) {
|
||||
list_del(&lst_itr->list_entry);
|
||||
devm_kfree(ice_hw_to_dev(hw), lst_itr);
|
||||
}
|
||||
}
|
||||
|
||||
devm_kfree(ice_hw_to_dev(hw), sw->recp_list);
|
||||
devm_kfree(ice_hw_to_dev(hw), sw);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -39,6 +39,7 @@ enum ice_sw_lkup_type {
|
|||
ICE_SW_LKUP_DFLT = 5,
|
||||
ICE_SW_LKUP_ETHERTYPE_MAC = 8,
|
||||
ICE_SW_LKUP_PROMISC_VLAN = 9,
|
||||
ICE_SW_LKUP_LAST
|
||||
};
|
||||
|
||||
struct ice_fltr_info {
|
||||
|
@ -98,6 +99,31 @@ struct ice_fltr_info {
|
|||
u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
|
||||
};
|
||||
|
||||
struct ice_sw_recipe {
|
||||
struct list_head l_entry;
|
||||
|
||||
/* To protect modification of filt_rule list
|
||||
* defined below
|
||||
*/
|
||||
struct mutex filt_rule_lock;
|
||||
|
||||
/* List of type ice_fltr_mgmt_list_entry */
|
||||
struct list_head filt_rules;
|
||||
|
||||
/* linked list of type recipe_list_entry */
|
||||
struct list_head rg_list;
|
||||
/* linked list of type ice_sw_fv_list_entry*/
|
||||
struct list_head fv_list;
|
||||
struct ice_aqc_recipe_data_elem *r_buf;
|
||||
u8 recp_count;
|
||||
u8 root_rid;
|
||||
u8 num_profs;
|
||||
u8 *prof_ids;
|
||||
|
||||
/* recipe bitmap: what all recipes makes this recipe */
|
||||
DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
|
||||
};
|
||||
|
||||
/* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */
|
||||
struct ice_vsi_list_map_info {
|
||||
struct list_head list_entry;
|
||||
|
@ -105,15 +131,9 @@ struct ice_vsi_list_map_info {
|
|||
u16 vsi_list_id;
|
||||
};
|
||||
|
||||
enum ice_sw_fltr_status {
|
||||
ICE_FLTR_STATUS_NEW = 0,
|
||||
ICE_FLTR_STATUS_FW_SUCCESS,
|
||||
ICE_FLTR_STATUS_FW_FAIL,
|
||||
};
|
||||
|
||||
struct ice_fltr_list_entry {
|
||||
struct list_head list_entry;
|
||||
enum ice_sw_fltr_status status;
|
||||
enum ice_status status;
|
||||
struct ice_fltr_info fltr_info;
|
||||
};
|
||||
|
||||
|
@ -157,5 +177,6 @@ enum ice_status ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
|
|||
enum ice_status ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
|
||||
enum ice_status
|
||||
ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_id, bool set, u8 direction);
|
||||
enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
|
||||
|
||||
#endif /* _ICE_SWITCH_H_ */
|
||||
|
|
|
@ -253,19 +253,8 @@ struct ice_port_info {
|
|||
};
|
||||
|
||||
struct ice_switch_info {
|
||||
/* Switch VSI lists to MAC/VLAN translation */
|
||||
struct mutex mac_list_lock; /* protect MAC list */
|
||||
struct list_head mac_list_head;
|
||||
struct mutex vlan_list_lock; /* protect VLAN list */
|
||||
struct list_head vlan_list_head;
|
||||
struct mutex eth_m_list_lock; /* protect ethtype list */
|
||||
struct list_head eth_m_list_head;
|
||||
struct mutex promisc_list_lock; /* protect promisc mode list */
|
||||
struct list_head promisc_list_head;
|
||||
struct mutex mac_vlan_list_lock; /* protect MAC-VLAN list */
|
||||
struct list_head mac_vlan_list_head;
|
||||
|
||||
struct list_head vsi_list_map_head;
|
||||
struct ice_sw_recipe *recp_list;
|
||||
};
|
||||
|
||||
/* Port hardware description */
|
||||
|
|
Loading…
Reference in New Issue