From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Brett Creeley <brett.creeley@intel.com>,
netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
Andrew Bowers <andrewx.bowers@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 12/16] ice: Check if unicast MAC exists before setting VF MAC
Date: Fri, 22 May 2020 23:48:43 -0700 [thread overview]
Message-ID: <20200523064847.3972158-13-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20200523064847.3972158-1-jeffrey.t.kirsher@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>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@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 a12fce73efbc..95e8bca562e5 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -3640,6 +3640,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
@@ -3663,10 +3696,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.26.2
next prev parent reply other threads:[~2020-05-23 6:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-23 6:48 [net-next 00/16][pull request] 100GbE Intel Wired LAN Driver Updates 2020-05-22 Jeff Kirsher
2020-05-23 6:48 ` [net-next 01/16] virtchnl: Add missing explicit padding to structures Jeff Kirsher
2020-05-23 6:48 ` [net-next 02/16] ice: Initialize Flow Director resources Jeff Kirsher
2020-05-23 6:48 ` [net-next 03/16] ice: Support displaying ntuple rules Jeff Kirsher
2020-05-23 6:48 ` [net-next 04/16] ice: Support IPv4 Flow Director filters Jeff Kirsher
2020-05-23 6:48 ` [net-next 05/16] ice: Support IPv6 " Jeff Kirsher
2020-05-23 6:48 ` [net-next 06/16] ice: Enable flex-bytes support Jeff Kirsher
2020-05-23 6:48 ` [net-next 07/16] ice: Restore filters following reset Jeff Kirsher
2020-05-23 6:48 ` [net-next 08/16] ice: Implement aRFS Jeff Kirsher
2020-05-23 6:48 ` [net-next 09/16] ice: Call ice_aq_set_mac_cfg Jeff Kirsher
2020-05-23 6:48 ` [net-next 10/16] ice: print Rx MDD auto reset message before VF reset Jeff Kirsher
2020-05-23 6:48 ` [net-next 11/16] ice: Fix Tx timeout when link is toggled on a VF's interface Jeff Kirsher
2020-05-23 6:48 ` Jeff Kirsher [this message]
2020-05-23 6:48 ` [net-next 13/16] ice: check for compatibility between DDP package and firmware Jeff Kirsher
2020-05-23 6:48 ` [net-next 14/16] ice: Fix bad register reads Jeff Kirsher
2020-05-23 6:48 ` [net-next 15/16] ice: fix usage of incorrect variable Jeff Kirsher
2020-05-23 6:48 ` [net-next 16/16] ice: cleanup unsigned loops Jeff Kirsher
2020-05-23 23:51 ` [net-next 00/16][pull request] 100GbE Intel Wired LAN Driver Updates 2020-05-22 David Miller
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=20200523064847.3972158-13-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=andrewx.bowers@intel.com \
--cc=brett.creeley@intel.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=sassmann@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).