@@ -3,6 +3,7 @@
#include "ice.h"
#include "ice_fltr.h"
+#include "ice_lib.h"
/**
* ice_fltr_free_list - free filter lists helper
@@ -221,10 +222,12 @@ void ice_fltr_remove_all(struct ice_vsi *vsi)
* @list: list to add filter info to
* @mac: MAC address to add
* @action: filter action
+ * @external: force the filter to enable lan destination
*/
int
ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,
- const u8 *mac, enum ice_sw_fwd_act_type action)
+ const u8 *mac, enum ice_sw_fwd_act_type action,
+ bool external)
{
struct ice_fltr_info info = { 0 };
@@ -233,6 +236,10 @@ ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,
info.lkup_type = ICE_SW_LKUP_MAC;
info.fltr_act = action;
info.vsi_handle = vsi->idx;
+ if (external) {
+ info.lb_en = ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED;
+ info.lan_en = ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED;
+ }
ether_addr_copy(info.l_data.mac.mac_addr, mac);
@@ -273,6 +280,62 @@ ice_fltr_add_mac_vlan_to_list(struct ice_vsi *vsi, struct list_head *list,
list);
}
+/**
+ * ice_fltr_add_macs_to_list - add MAC and MAC,VLAN filters info to an existing
+ * list
+ * @vsi: pointer to VSI struct
+ * @list: list to add filter info to
+ * @mac: MAC address to add
+ * @action: filter action
+ *
+ * Return:
+ * * 0 on success, or
+ * * %-ENOMEM if entry for filter could not be allocated.
+ */
+int
+ice_fltr_add_macs_to_list(struct ice_vsi *vsi, struct list_head *list,
+ const u8 *mac, enum ice_sw_fwd_act_type action)
+{
+ if (is_multicast_ether_addr(mac)) {
+ /* There is no point in doing the same gymnastics as below
+ * because multicast addresses are sent to both lan and lb then
+ * pruned as necessary.
+ */
+ return ice_fltr_add_mac_to_list(vsi, list, mac, action, false);
+ } else if (ice_vsi_has_pvid(vsi)) {
+ u16 pvid = ice_vsi_pvid(vsi);
+ int ret;
+
+ ret = ice_fltr_add_mac_to_list(vsi, list, mac, action, true);
+ if (ret)
+ return ret;
+
+ return ice_fltr_add_mac_vlan_to_list(vsi, list, mac, pvid,
+ action);
+ } else if (vsi->num_vlan != ice_vsi_num_non_zero_vlans(vsi)) {
+ /* If VSI has VLAN 0 filters, then the interface is prepared to
+ * receive untagged packets. As of now, we simply don't have
+ * heuristics to decide which MAC is and is not part of which
+ * VLAN so we put them all in the same bucket.
+ */
+ return ice_fltr_add_mac_to_list(vsi, list, mac, action, false);
+ }
+
+ /* This branch is a.s. dead. There are three cases that may happen:
+ *
+ * - no vlans in sight; this is the VLAN 0 branch,
+ * - VF is assigned PVID; this is ice_vsi_has_pvid branch,
+ * - PF or VF is under vlan device; this is the VLAN 0 branch.
+ *
+ * This is where you would implement support for multiple VLANs but
+ * without the VLAN 0. This could happen if vlan upper device is
+ * assigned a MAC that is unique compared to lower ice device that is
+ * forced to accept any VLAN. This would imply MAC-only filter for one
+ * MAC address (PF) and MAC,VLAN+MAC filters for another (vlan).
+ */
+ return ice_fltr_add_mac_to_list(vsi, list, mac, action, false);
+}
+
/**
* ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list
* @vsi: pointer to VSI struct
@@ -343,7 +406,7 @@ ice_fltr_prepare_mac(struct ice_vsi *vsi, const u8 *mac,
LIST_HEAD(tmp_list);
int result;
- if (ice_fltr_add_mac_to_list(vsi, &tmp_list, mac, action)) {
+ if (ice_fltr_add_macs_to_list(vsi, &tmp_list, mac, action)) {
ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
return -ENOMEM;
}
@@ -371,8 +434,8 @@ ice_fltr_prepare_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,
int result;
eth_broadcast_addr(broadcast);
- if (ice_fltr_add_mac_to_list(vsi, &tmp_list, mac, action) ||
- ice_fltr_add_mac_to_list(vsi, &tmp_list, broadcast, action)) {
+ if (ice_fltr_add_macs_to_list(vsi, &tmp_list, mac, action) ||
+ ice_fltr_add_macs_to_list(vsi, &tmp_list, broadcast, action)) {
ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
return -ENOMEM;
}
@@ -21,12 +21,16 @@ ice_fltr_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
u16 vid);
int
ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,
- const u8 *mac, enum ice_sw_fwd_act_type action);
+ const u8 *mac, enum ice_sw_fwd_act_type action,
+ bool external);
int
ice_fltr_add_mac_vlan_to_list(struct ice_vsi *vsi, struct list_head *list,
const u8 *mac, u16 vlan_id,
enum ice_sw_fwd_act_type action);
int
+ice_fltr_add_macs_to_list(struct ice_vsi *vsi, struct list_head *list,
+ const u8 *mac, enum ice_sw_fwd_act_type action);
+int
ice_fltr_add_mac(struct ice_vsi *vsi, const u8 *mac,
enum ice_sw_fwd_act_type action);
int
@@ -212,8 +212,8 @@ static int ice_add_mac_to_sync_list(struct net_device *netdev, const u8 *addr)
struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi;
- if (ice_fltr_add_mac_to_list(vsi, &vsi->tmp_sync_list, addr,
- ICE_FWD_TO_VSI))
+ if (ice_fltr_add_macs_to_list(vsi, &vsi->tmp_sync_list, addr,
+ ICE_FWD_TO_VSI))
return -EINVAL;
return 0;
@@ -242,8 +242,8 @@ static int ice_add_mac_to_unsync_list(struct net_device *netdev, const u8 *addr)
if (ether_addr_equal(addr, netdev->dev_addr))
return 0;
- if (ice_fltr_add_mac_to_list(vsi, &vsi->tmp_unsync_list, addr,
- ICE_FWD_TO_VSI))
+ if (ice_fltr_add_macs_to_list(vsi, &vsi->tmp_unsync_list, addr,
+ ICE_FWD_TO_VSI))
return -EINVAL;
return 0;
@@ -4018,7 +4018,7 @@ ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,
* @fm_entry: filter entry to inspect
* @vsi_handle: VSI handle to compare with filter info
*/
-static bool
+bool
ice_vsi_uses_fltr(struct ice_fltr_mgmt_list_entry *fm_entry, u16 vsi_handle)
{
return ((fm_entry->fltr_info.fltr_act == ICE_FWD_TO_VSI &&
@@ -346,6 +346,8 @@ ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
void ice_clear_all_vsi_ctx(struct ice_hw *hw);
+bool ice_vsi_uses_fltr(struct ice_fltr_mgmt_list_entry *fm_entry,
+ u16 vsi_handle);
/* Switch config */
int ice_get_initial_sw_cfg(struct ice_hw *hw);
@@ -501,14 +501,14 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)
ice_vf_set_host_trust_cfg(vf);
- if (ice_vf_rebuild_host_mac_cfg(vf))
- dev_err(dev, "failed to rebuild default MAC configuration for VF %d\n",
- vf->vf_id);
-
if (ice_vf_rebuild_host_vlan_cfg(vf, vsi))
dev_err(dev, "failed to rebuild VLAN configuration for VF %u\n",
vf->vf_id);
+ if (ice_vf_rebuild_host_mac_cfg(vf))
+ dev_err(dev, "failed to rebuild default MAC configuration for VF %d\n",
+ vf->vf_id);
+
if (ice_vf_rebuild_host_tx_rate_cfg(vf))
dev_err(dev, "failed to rebuild Tx rate limiting configuration for VF %u\n",
vf->vf_id);