[iwl-net,3/5] ice: Do not add LLDP-specific filter

Message ID 20240228155957.408036-4-larysa.zaremba@intel.com
State New
Headers
Series ice: LLDP support for VFs |

Commit Message

Larysa Zaremba Feb. 28, 2024, 3:59 p.m. UTC
  Commit 34295a3696fbd0d90ee7 ("ice: implement new LLDP filter command")
has introduced the ability to use LLDP-specific filter that directs all
LLDP traffic to a single VSI. However, current goal is for all trusted VFs
to be able to see LLDP neighbors. Therefore, replace the functionality with
previously used generic ethernet protocol filter.

The command was added as a way to solve an "issue with some NVMs where an
already existent LLDP filter is blocking the creation of a filter to allow
LLDP packets". Preserve this utility and remove LLDP-specific filter
before configuring another one.

Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  1 -
 drivers/net/ethernet/intel/ice/ice_common.c   | 26 ---------------
 drivers/net/ethernet/intel/ice/ice_common.h   |  2 --
 drivers/net/ethernet/intel/ice/ice_lib.c      | 33 +++++++++++++++----
 4 files changed, 26 insertions(+), 36 deletions(-)
  

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
index 8040317c9561..2855c955d8b4 100644
--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
@@ -1883,7 +1883,6 @@  struct ice_aqc_lldp_stop_start_specific_agent {
 /* LLDP Filter Control (direct 0x0A0A) */
 struct ice_aqc_lldp_filter_ctrl {
 	u8 cmd_flags;
-#define ICE_AQC_LLDP_FILTER_ACTION_ADD		0x0
 #define ICE_AQC_LLDP_FILTER_ACTION_DELETE	0x1
 	u8 reserved1;
 	__le16 vsi_num;
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 9266f25a9978..f5cca0e2ead6 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -5911,32 +5911,6 @@  bool ice_fw_supports_lldp_fltr_ctrl(struct ice_hw *hw)
 				     ICE_FW_API_LLDP_FLTR_PATCH);
 }
 
-/**
- * ice_lldp_fltr_add_remove - add or remove a LLDP Rx switch filter
- * @hw: pointer to HW struct
- * @vsi_num: absolute HW index for VSI
- * @add: boolean for if adding or removing a filter
- */
-int
-ice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add)
-{
-	struct ice_aqc_lldp_filter_ctrl *cmd;
-	struct ice_aq_desc desc;
-
-	cmd = &desc.params.lldp_filter_ctrl;
-
-	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_filter_ctrl);
-
-	if (add)
-		cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_ADD;
-	else
-		cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_DELETE;
-
-	cmd->vsi_num = cpu_to_le16(vsi_num);
-
-	return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
-}
-
 /**
  * ice_lldp_execute_pending_mib - execute LLDP pending MIB request
  * @hw: pointer to HW struct
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index 32fd10de620c..900926e6414c 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -267,8 +267,6 @@  int
 ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
 		    struct ice_sq_cd *cd);
 bool ice_fw_supports_lldp_fltr_ctrl(struct ice_hw *hw);
-int
-ice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add);
 int ice_lldp_execute_pending_mib(struct ice_hw *hw);
 int
 ice_aq_read_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 60e0d824195e..a774bcdcc0c4 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -2039,6 +2039,27 @@  static void ice_vsi_set_tc_cfg(struct ice_vsi *vsi)
 	ice_vsi_set_dcb_tc_cfg(vsi);
 }
 
+/**
+ * ice_lldp_fltr_remove_from_port - Remove a LLDP Rx filter from the port
+ * @hw: port
+ *
+ * Remove a LLDP Rx switch filter from the port. For some NVMs,
+ * such leftover filter can prevent us from configuring another one.
+ */
+static void ice_lldp_fltr_remove_from_port(struct ice_hw *hw)
+{
+	struct ice_aqc_lldp_filter_ctrl *cmd;
+	struct ice_aq_desc desc;
+
+	cmd = &desc.params.lldp_filter_ctrl;
+
+	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_filter_ctrl);
+
+	cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_DELETE;
+
+	ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
+}
+
 /**
  * ice_cfg_sw_lldp - Config switch rules for LLDP packet handling
  * @vsi: the VSI being configured
@@ -2060,13 +2081,11 @@  void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create)
 		status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_TX,
 				  ICE_DROP_PACKET);
 	} else {
-		if (ice_fw_supports_lldp_fltr_ctrl(&pf->hw)) {
-			status = ice_lldp_fltr_add_remove(&pf->hw, vsi->vsi_num,
-							  create);
-		} else {
-			status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_RX,
-					  ICE_FWD_TO_VSI);
-		}
+		if (create && ice_fw_supports_lldp_fltr_ctrl(&pf->hw))
+			ice_lldp_fltr_remove_from_port(&vsi->back->hw);
+
+		status = eth_fltr(vsi, ETH_P_LLDP, ICE_FLTR_RX,
+				  ICE_FWD_TO_VSI);
 	}
 
 	if (status)