From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH S43 04/15] ice: Check if unicast MAC exists before setting VF MAC
Date: Fri, 15 May 2020 17:36:33 -0700 [thread overview]
Message-ID: <20200516003644.4658-4-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20200516003644.4658-1-anthony.l.nguyen@intel.com>
From: Brett Creeley <brett.creeley@intel.com>
Currently if a unicast MAC is set via ndo_set_vf_mac, the PF driver will
set the VF's dflt_lan_addr.addr once some basic checks have passed. The
VF is then reset. During reset the PF driver will attempt to program the
VF's MAC from the dflt_lan_addr.addr field. This fails when the MAC
already exists on the PF's switch.
This is causing the VF to be completely disabled until removing/enabling
any VFs via sysfs.
Fix this by checking if the unicast MAC exists before triggering a VF
reset directly in ndo_set_vf_mac. Also, add a check if the unicast MAC
is set to the same value as before and return 0 if that is the case.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
---
.../net/ethernet/intel/ice/ice_virtchnl_pf.c | 43 +++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 2e6c81555668..6ea3d15e1a6d 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -3648,6 +3648,39 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)
return 0;
}
+/**
+ * ice_unicast_mac_exists - check if the unicast MAC exists on the PF's switch
+ * @pf: PF used to reference the switch's rules
+ * @umac: unicast MAC to compare against existing switch rules
+ *
+ * Return true on the first/any match, else return false
+ */
+static bool ice_unicast_mac_exists(struct ice_pf *pf, u8 *umac)
+{
+ struct ice_sw_recipe *mac_recipe_list =
+ &pf->hw.switch_info->recp_list[ICE_SW_LKUP_MAC];
+ struct ice_fltr_mgmt_list_entry *list_itr;
+ struct list_head *rule_head;
+ struct mutex *rule_lock; /* protect MAC filter list access */
+
+ rule_head = &mac_recipe_list->filt_rules;
+ rule_lock = &mac_recipe_list->filt_rule_lock;
+
+ mutex_lock(rule_lock);
+ list_for_each_entry(list_itr, rule_head, list_entry) {
+ u8 *existing_mac = &list_itr->fltr_info.l_data.mac.mac_addr[0];
+
+ if (ether_addr_equal(existing_mac, umac)) {
+ mutex_unlock(rule_lock);
+ return true;
+ }
+ }
+
+ mutex_unlock(rule_lock);
+
+ return false;
+}
+
/**
* ice_set_vf_mac
* @netdev: network interface device structure
@@ -3671,10 +3704,20 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
}
vf = &pf->vf[vf_id];
+ /* nothing left to do, unicast MAC already set */
+ if (ether_addr_equal(vf->dflt_lan_addr.addr, mac))
+ return 0;
+
ret = ice_check_vf_ready_for_cfg(vf);
if (ret)
return ret;
+ if (ice_unicast_mac_exists(pf, mac)) {
+ netdev_err(netdev, "Unicast MAC %pM already exists on this PF. Preventing setting VF %u unicast MAC address to %pM\n",
+ mac, vf_id, mac);
+ return -EINVAL;
+ }
+
/* copy MAC into dflt_lan_addr and trigger a VF reset. The reset
* flow will use the updated dflt_lan_addr and add a MAC filter
* using ice_add_mac. Also set pf_set_mac to indicate that the PF has
--
2.20.1
next prev parent reply other threads:[~2020-05-16 0:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 0:36 [Intel-wired-lan] [PATCH S43 01/15] ice: Call ice_aq_set_mac_cfg Tony Nguyen
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 02/15] ice: print Rx MDD auto reset message before VF reset Tony Nguyen
2020-05-22 19:27 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 03/15] ice: Fix Tx timeout when link is toggled on a VF's interface Tony Nguyen
2020-05-22 19:30 ` Bowers, AndrewX
2020-05-16 0:36 ` Tony Nguyen [this message]
2020-05-22 19:30 ` [Intel-wired-lan] [PATCH S43 04/15] ice: Check if unicast MAC exists before setting VF MAC Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 05/15] ice: check for compatibility between DDP package and firmware Tony Nguyen
2020-05-22 19:31 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 06/15] ice: Fix bad register reads Tony Nguyen
2020-05-22 19:56 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 07/15] ice: fix usage of incorrect variable Tony Nguyen
2020-05-22 19:58 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 08/15] ice: cleanup unsigned loops Tony Nguyen
2020-05-22 19:58 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 09/15] ice: fix signed vs unsigned comparisons Tony Nguyen
2020-05-22 19:58 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 10/15] ice: remove unused macro Tony Nguyen
2020-05-22 20:06 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 11/15] ice: set VF default LAN address Tony Nguyen
2020-05-22 20:07 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 12/15] ice: fix MAC write command Tony Nguyen
2020-05-22 20:07 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 13/15] ice: Fix memory leak Tony Nguyen
2020-05-22 20:08 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 14/15] ice: Fix for memory leaks and modify ICE_FREE_CQ_BUFS Tony Nguyen
2020-05-22 20:09 ` Bowers, AndrewX
2020-05-16 0:36 ` [Intel-wired-lan] [PATCH S43 15/15] ice: Add more Rx errors to netdev's rx_error counter Tony Nguyen
2020-05-22 20:09 ` Bowers, AndrewX
2020-05-22 19:14 ` [Intel-wired-lan] [PATCH S43 01/15] ice: Call ice_aq_set_mac_cfg Bowers, AndrewX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200516003644.4658-4-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox