net/ice/base: add functions for ethertype filter
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 25 Mar 2019 05:44:24 +0000 (13:44 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 29 Mar 2019 16:25:31 +0000 (17:25 +0100)
Add API ice_remove_eth_mac and ice_add_eth_mac to support
adding / removing ethertype (or MAC) based filter rules.

PMD driver can use these APIs to enable related rte_flow rule.

Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Reviewed-by: Qiming Yang <qiming.yang@intel.com>
Reviewed-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/ice/base/ice_switch.c
drivers/net/ice/base/ice_switch.h

index 4b53636..4af6a32 100644 (file)
@@ -2415,6 +2415,63 @@ ice_add_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *mv_list)
 }
 #endif
 
+/**
+ * ice_add_eth_mac - Add ethertype and MAC based filter rule
+ * @hw: pointer to the hardware structure
+ * @em_list: list of ether type MAC filter, MAC is optional
+ */
+enum ice_status
+ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list)
+{
+       struct ice_fltr_list_entry *em_list_itr;
+
+       LIST_FOR_EACH_ENTRY(em_list_itr, em_list, ice_fltr_list_entry,
+                           list_entry) {
+               enum ice_sw_lkup_type l_type =
+                       em_list_itr->fltr_info.lkup_type;
+
+               if (l_type != ICE_SW_LKUP_ETHERTYPE_MAC &&
+                   l_type != ICE_SW_LKUP_ETHERTYPE)
+                       return ICE_ERR_PARAM;
+
+               em_list_itr->fltr_info.flag = ICE_FLTR_TX;
+               em_list_itr->status = ice_add_rule_internal(hw, l_type,
+                                                           em_list_itr);
+               if (em_list_itr->status)
+                       return em_list_itr->status;
+       }
+       return ICE_SUCCESS;
+}
+
+/**
+ * ice_remove_eth_mac - Remove an ethertype (or MAC) based filter rule
+ * @hw: pointer to the hardware structure
+ * @em_list: list of ethertype or ethertype MAC entries
+ */
+enum ice_status
+ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list)
+{
+       struct ice_fltr_list_entry *em_list_itr, *tmp;
+
+       if (!em_list || !hw)
+               return ICE_ERR_PARAM;
+
+       LIST_FOR_EACH_ENTRY_SAFE(em_list_itr, tmp, em_list, ice_fltr_list_entry,
+                                list_entry) {
+               enum ice_sw_lkup_type l_type =
+                       em_list_itr->fltr_info.lkup_type;
+
+               if (l_type != ICE_SW_LKUP_ETHERTYPE_MAC &&
+                   l_type != ICE_SW_LKUP_ETHERTYPE)
+                       return ICE_ERR_PARAM;
+
+               em_list_itr->status = ice_remove_rule_internal(hw, l_type,
+                                                              em_list_itr);
+               if (em_list_itr->status)
+                       return em_list_itr->status;
+       }
+       return ICE_SUCCESS;
+}
 
 
 /**
index c6d3147..f331621 100644 (file)
@@ -347,6 +347,10 @@ ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list);
 enum ice_status ice_add_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status ice_remove_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_lst);
 enum ice_status
+ice_add_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
+enum ice_status
+ice_remove_eth_mac(struct ice_hw *hw, struct LIST_HEAD_TYPE *em_list);
+enum ice_status
 ice_remove_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);
 #ifndef NO_MACVLAN_SUPPORT
 enum ice_status