From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Change-Id: Ia4166db3a0b572aaefb59d1d4a2e418a028d7092
---
 .../net/ethernet/mellanox/mlx5/core/eswitch.h | 84 ++++++++++++++-----
 1 file changed, 62 insertions(+), 22 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -71,10 +71,11 @@ struct mlx5_mapped_obj {
 	};
 };
 
-#ifdef CONFIG_MLX5_ESWITCH
-
 #define ESW_OFFLOADS_DEFAULT_NUM_GROUPS 15
 
+#ifdef CONFIG_MLX5_ESWITCH
+#include "en/tc_ct.h"
+
 #define MLX5_MAX_UC_PER_VPORT(dev) \
 	(1 << MLX5_CAP_GEN(dev, log_max_current_uc_list))
 
@@ -617,11 +618,17 @@ struct mlx5_esw_flow_attr {
 	struct mlx5_pkt_reformat *decap_pkt_reformat;
 };
 
-int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
-				  struct netlink_ext_ack *extack);
+int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode
+#ifdef HAVE_DEVLINK_ESWITCH_MODE_SET_EXTACK
+				 , struct netlink_ext_ack *extack
+#endif
+				 );
 int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode);
-int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
-					 struct netlink_ext_ack *extack);
+int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode
+#ifdef HAVE_DEVLINK_ESWITCH_MODE_SET_EXTACK
+					, struct netlink_ext_ack *extack
+#endif
+					);
 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode);
 
 int mlx5_eswitch_vport_modify_other_hca_cap_roce(struct mlx5_eswitch *esw,
@@ -630,21 +637,45 @@ int mlx5_eswitch_vport_get_other_hca_cap
 					      struct mlx5_vport *vport, bool *value);
 
 int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
-					enum devlink_eswitch_encap_mode encap,
-					struct netlink_ext_ack *extack);
+#ifdef HAVE_DEVLINK_HAS_ESWITCH_ENCAP_MODE_SET_GET_WITH_ENUM
+					enum devlink_eswitch_encap_mode encap
+#else
+					u8 encap
+#endif
+#ifdef HAVE_DEVLINK_ESWITCH_MODE_SET_EXTACK
+					, struct netlink_ext_ack *extack
+#endif
+					);
 int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
+#ifdef HAVE_DEVLINK_HAS_ESWITCH_ENCAP_MODE_SET_GET_WITH_ENUM
 					enum devlink_eswitch_encap_mode *encap);
+#else
+					u8 *encap);
+#endif
 int mlx5_devlink_eswitch_ipsec_mode_set(struct devlink *devlink,
-					enum devlink_eswitch_ipsec_mode ipsec,
-					struct netlink_ext_ack *extack);
+					enum devlink_eswitch_ipsec_mode ipsec
+#ifdef HAVE_DEVLINK_ESWITCH_MODE_SET_EXTACK
+					, struct netlink_ext_ack *extack
+#endif
+					);
 int mlx5_devlink_eswitch_ipsec_mode_get(struct devlink *devlink,
 					enum devlink_eswitch_ipsec_mode *ipsec);
-int mlx5_devlink_port_function_hw_addr_get(struct devlink_port *port,
-					   u8 *hw_addr, int *hw_addr_len,
-					   struct netlink_ext_ack *extack);
-int mlx5_devlink_port_function_hw_addr_set(struct devlink_port *port,
-					   const u8 *hw_addr, int hw_addr_len,
-					   struct netlink_ext_ack *extack);
+#ifdef HAVE_PORT_FUNCTION_HW_ADDR_GET_GET_4_PARAM
+int mlx5_devlink_port_function_hw_addr_get(
+#else
+int mlx5_devlink_port_function_hw_addr_get(struct devlink *devlink,
+#endif
+ 					   struct devlink_port *port,
+ 					   u8 *hw_addr, int *hw_addr_len,
+ 					   struct netlink_ext_ack *extack);
+#ifdef HAVE_PORT_FUNCTION_HW_ADDR_GET_GET_4_PARAM
+int mlx5_devlink_port_function_hw_addr_set(
+#else
+int mlx5_devlink_port_function_hw_addr_set(struct devlink *devlink,
+#endif
+ 					   struct devlink_port *port,
+ 					   const u8 *hw_addr, int hw_addr_len,
+ 					   struct netlink_ext_ack *extack);
 int mlx5_devlink_rate_node_tx_max_set(struct devlink *devlink,
 				      const char *group, u64 tx_max,
 				      struct netlink_ext_ack *extack);
@@ -910,6 +941,10 @@ struct mlx5_esw_event_info {
 
 int mlx5_esw_event_notifier_register(struct mlx5_eswitch *esw, struct notifier_block *n);
 void mlx5_esw_event_notifier_unregister(struct mlx5_eswitch *esw, struct notifier_block *n);
+int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
+			       u16 vport, const u8 *mac);
+int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
+				 u16 vport, int link_state);
 bool mlx5e_esw_offloads_pet_enabled(const struct mlx5_eswitch *esw);
 int mlx5e_esw_offloads_pet_setup(struct mlx5_eswitch *esw, struct mlx5_flow_table *ft);
 void mlx5e_esw_offloads_pet_cleanup(struct mlx5_eswitch *esw);
@@ -970,12 +1005,6 @@ static inline const u32 *mlx5_esw_query_
 static inline void mlx5_esw_unlock(struct mlx5_eswitch *esw) { return; }
 static inline void mlx5_esw_lock(struct mlx5_eswitch *esw) { return; }
 
-static inline struct mlx5_flow_handle *
-esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
-{
-	return ERR_PTR(-EOPNOTSUPP);
-}
-
 static inline bool
 mlx5_esw_is_manager_vport(const struct mlx5_eswitch *esw, u16 vport_num)
 {
@@ -1006,10 +1035,21 @@ mlx5_eswitch_reload_reps(struct mlx5_esw
 	return 0;
 }
 
+static inline bool mlx5e_esw_offloads_pet_enabled(const struct mlx5_eswitch *esw)
+{
+	return false;
+};
+
 static inline bool mlx5_esw_host_functions_enabled(const struct mlx5_core_dev *dev)
 {
 	return true;
 }
+
+static inline int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
+		                                             u16 vport, u8 mac[ETH_ALEN]){ return 0; }
+static inline int mlx5_eswitch_get_vport_mac(struct mlx5_eswitch *esw,
+		                                             u16 vport, u8 *mac){ return 0; }
+ 
 #endif /* CONFIG_MLX5_ESWITCH */
 
 int mlx5_eswitch_compat_sysfs_init(struct net_device *netdev);
