Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net v4] ice: Fix VSIs unable to share unicast MAC
@ 2022-07-18  6:56 Jedrzej Jagielski
  2022-07-18  9:37 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Jedrzej Jagielski @ 2022-07-18  6:56 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Sylwester Dziedziuch, Jedrzej Jagielski

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

The driver currently does not allow two VSIs in the same PF domain
to have the same unicast MAC address. This is incorrect in the sense
that a policy decision is being made in the driver when it must be
left to the user. This approach was causing issues when rebooting
the system with VFs spawned not being able to change their MAC addresses.
Such errors were present in dmesg:

[ 7921.068237] ice 0000:b6:00.2 ens2f2: Unicast MAC 6a:0d:e4:70:ca:d1 already
exists on this PF. Preventing setting VF 7 unicast MAC address to 6a:0d:e4:70:ca:d1

Fix that by removing this restriction. Doing this also allows
use to remove some additional code that's checking if a unicast MAC
filter already exists.

Remove ucast_shared and all the related stuff as it is no longer needed.

Fixes: 47ebc7b02485 ("ice: Check if unicast MAC exists before setting VF MAC")
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
v2: amend the commit msg
v3: removed ucast_shared
v4: remove if statements depending on ucast_shared
---
 drivers/net/ethernet/intel/ice/ice_sriov.c  | 40 ------------------
 drivers/net/ethernet/intel/ice/ice_switch.c | 46 ++++-----------------
 drivers/net/ethernet/intel/ice/ice_type.h   |  2 -
 3 files changed, 8 insertions(+), 80 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index bb1721f1321d..f4907a3c2d19 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -1309,39 +1309,6 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)
 	return ret;
 }
 
-/**
- * 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
@@ -1376,13 +1343,6 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
 	if (ret)
 		goto out_put_vf;
 
-	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);
-		ret = -EINVAL;
-		goto out_put_vf;
-	}
-
 	mutex_lock(&vf->cfg_lock);
 
 	/* VF is notified of its new MAC via the PF's response to the
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index fc231446c641..c348e3413f33 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -3424,13 +3424,7 @@ bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle)
  * ice_add_mac - Add a MAC address based filter rule
  * @hw: pointer to the hardware structure
  * @m_list: list of MAC addresses and forwarding information
- *
- * IMPORTANT: When the ucast_shared flag is set to false and m_list has
- * multiple unicast addresses, the function assumes that all the
- * addresses are unique in a given add_mac call. It doesn't
- * check for duplicates in this case, removing duplicates from a given
- * list should be taken care of in the caller of this function.
- */
+  */
 int ice_add_mac(struct ice_hw *hw, struct list_head *m_list)
 {
 	struct ice_sw_rule_lkup_rx_tx *s_rule, *r_iter;
@@ -3467,24 +3461,12 @@ int ice_add_mac(struct ice_hw *hw, struct list_head *m_list)
 		if (m_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_MAC ||
 		    is_zero_ether_addr(add))
 			return -EINVAL;
-		if (is_unicast_ether_addr(add) && !hw->ucast_shared) {
-			/* Don't overwrite the unicast address */
-			mutex_lock(rule_lock);
-			if (ice_find_rule_entry(hw, ICE_SW_LKUP_MAC,
-						&m_list_itr->fltr_info)) {
-				mutex_unlock(rule_lock);
-				return -EEXIST;
-			}
-			mutex_unlock(rule_lock);
-			num_unicast++;
-		} else if (is_multicast_ether_addr(add) ||
-			   (is_unicast_ether_addr(add) && hw->ucast_shared)) {
-			m_list_itr->status =
-				ice_add_rule_internal(hw, ICE_SW_LKUP_MAC,
-						      m_list_itr);
-			if (m_list_itr->status)
-				return m_list_itr->status;
-		}
+
+		m_list_itr->status =
+			ice_add_rule_internal(hw, ICE_SW_LKUP_MAC,
+					      m_list_itr);
+		if (m_list_itr->status)
+			return m_list_itr->status;
 	}
 
 	mutex_lock(rule_lock);
@@ -4000,19 +3982,7 @@ int ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)
 
 		list_itr->fltr_info.fwd_id.hw_vsi_id =
 					ice_get_hw_vsi_num(hw, vsi_handle);
-		if (is_unicast_ether_addr(add) && !hw->ucast_shared) {
-			/* Don't remove the unicast address that belongs to
-			 * another VSI on the switch, since it is not being
-			 * shared...
-			 */
-			mutex_lock(rule_lock);
-			if (!ice_find_ucast_rule_entry(hw, ICE_SW_LKUP_MAC,
-						       &list_itr->fltr_info)) {
-				mutex_unlock(rule_lock);
-				return -ENOENT;
-			}
-			mutex_unlock(rule_lock);
-		}
+
 		list_itr->status = ice_remove_rule_internal(hw,
 							    ICE_SW_LKUP_MAC,
 							    list_itr);
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index f2a518a1fd94..2ca24df10433 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -889,8 +889,6 @@ struct ice_hw {
 	/* INTRL granularity in 1 us */
 	u8 intrl_gran;
 
-	u8 ucast_shared;	/* true if VSIs can share unicast addr */
-
 #define ICE_PHY_PER_NAC		1
 #define ICE_MAX_QUAD		2
 #define ICE_NUM_QUAD_TYPE	2
-- 
2.27.0

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v4] ice: Fix VSIs unable to share unicast MAC
  2022-07-18  6:56 [Intel-wired-lan] [PATCH net v4] ice: Fix VSIs unable to share unicast MAC Jedrzej Jagielski
@ 2022-07-18  9:37 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-07-18  9:37 UTC (permalink / raw)
  To: Jedrzej Jagielski, intel-wired-lan
  Cc: Sylwester Dziedziuch, kbuild-all, Jedrzej Jagielski

Hi Jedrzej,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Jedrzej-Jagielski/ice-Fix-VSIs-unable-to-share-unicast-MAC/20220718-150030
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 11052589cf5c0bab3b4884d423d5f60c38fcf25d
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220718/202207181711.LUIFqImA-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/b3781a141e58204a573a255b21f3f7f8faecba58
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jedrzej-Jagielski/ice-Fix-VSIs-unable-to-share-unicast-MAC/20220718-150030
        git checkout b3781a141e58204a573a255b21f3f7f8faecba58
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/ethernet/intel/ice/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/intel/ice/ice_switch.c: In function 'ice_remove_mac':
>> drivers/net/ethernet/intel/ice/ice_switch.c:3973:21: warning: unused variable 'add' [-Wunused-variable]
    3973 |                 u8 *add = &list_itr->fltr_info.l_data.mac.mac_addr[0];
         |                     ^~~
   drivers/net/ethernet/intel/ice/ice_switch.c:3965:23: warning: variable 'rule_lock' set but not used [-Wunused-but-set-variable]
    3965 |         struct mutex *rule_lock; /* Lock to protect filter rule list */
         |                       ^~~~~~~~~
   At top level:
   drivers/net/ethernet/intel/ice/ice_switch.c:3930:1: warning: 'ice_find_ucast_rule_entry' defined but not used [-Wunused-function]
    3930 | ice_find_ucast_rule_entry(struct ice_hw *hw, u8 recp_id,
         | ^~~~~~~~~~~~~~~~~~~~~~~~~


vim +/add +3973 drivers/net/ethernet/intel/ice/ice_switch.c

8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3948  
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3949  /**
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3950   * ice_remove_mac - remove a MAC address based filter rule
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3951   * @hw: pointer to the hardware structure
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3952   * @m_list: list of MAC addresses and forwarding information
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3953   *
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3954   * This function removes either a MAC filter rule or a specific VSI from a
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3955   * VSI list for a multicast MAC address.
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3956   *
5518ac2a64423f Tony Nguyen            2021-10-07  3957   * Returns -ENOENT if a given entry was not added by ice_add_mac. Caller should
5518ac2a64423f Tony Nguyen            2021-10-07  3958   * be aware that this call will only work if all the entries passed into m_list
5518ac2a64423f Tony Nguyen            2021-10-07  3959   * were added previously. It will not attempt to do a partial remove of entries
5518ac2a64423f Tony Nguyen            2021-10-07  3960   * that were found.
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3961   */
5e24d5984c805c Tony Nguyen            2021-10-07  3962  int ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3963  {
072f0c3db9daf7 Dave Ertman            2018-09-19  3964  	struct ice_fltr_list_entry *list_itr, *tmp;
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3965  	struct mutex *rule_lock; /* Lock to protect filter rule list */
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3966  
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3967  	if (!m_list)
d54699e27d506f Tony Nguyen            2021-10-07  3968  		return -EINVAL;
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3969  
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3970  	rule_lock = &hw->switch_info->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;
072f0c3db9daf7 Dave Ertman            2018-09-19  3971  	list_for_each_entry_safe(list_itr, tmp, m_list, list_entry) {
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3972  		enum ice_sw_lkup_type l_type = list_itr->fltr_info.lkup_type;
8b2c858240aca4 Akeem G Abodunrin      2019-07-25 @3973  		u8 *add = &list_itr->fltr_info.l_data.mac.mac_addr[0];
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3974  		u16 vsi_handle;
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3975  
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3976  		if (l_type != ICE_SW_LKUP_MAC)
d54699e27d506f Tony Nguyen            2021-10-07  3977  			return -EINVAL;
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3978  
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3979  		vsi_handle = list_itr->fltr_info.vsi_handle;
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3980  		if (!ice_is_vsi_valid(hw, vsi_handle))
d54699e27d506f Tony Nguyen            2021-10-07  3981  			return -EINVAL;
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3982  
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3983  		list_itr->fltr_info.fwd_id.hw_vsi_id =
8b2c858240aca4 Akeem G Abodunrin      2019-07-25  3984  					ice_get_hw_vsi_num(hw, vsi_handle);
b3781a141e5820 Anirudh Venkataramanan 2022-07-18  3985  
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3986  		list_itr->status = ice_remove_rule_internal(hw,
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3987  							    ICE_SW_LKUP_MAC,
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3988  							    list_itr);
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3989  		if (list_itr->status)
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3990  			return list_itr->status;
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3991  	}
80d144c9ac82fd Anirudh Venkataramanan 2018-08-09  3992  	return 0;
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3993  }
d76a60ba7afb89 Anirudh Venkataramanan 2018-03-20  3994  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-18  9:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18  6:56 [Intel-wired-lan] [PATCH net v4] ice: Fix VSIs unable to share unicast MAC Jedrzej Jagielski
2022-07-18  9:37 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox