From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: include/linux/mlx5/driver.h

Change-Id: I2f994fbf569b3ed183664461ea714d89c733a576
---
 include/linux/mlx5/driver.h | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -33,6 +33,8 @@
 #ifndef MLX5_DRIVER_H
 #define MLX5_DRIVER_H
 
+#include "../../../compat/config.h"
+
 #include <linux/kernel.h>
 #include <linux/completion.h>
 #include <linux/pci.h>
@@ -57,6 +59,9 @@
 #include <linux/timecounter.h>
 #include <linux/ptp_clock_kernel.h>
 #include <net/devlink.h>
+#include <linux/net_tstamp.h>
+#include <linux/llist.h>
+
 
 #define MLX5_ADEV_NAME "mlx5_core"
 
@@ -463,10 +468,12 @@ struct mlx5_core_health {
 	unsigned long			flags;
 	struct mlx5_fw_crdump		*crdump;
 	struct work_struct		fatal_report_work;
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
 	struct work_struct		report_work;
 	struct devlink_health_reporter *fw_reporter;
 	struct devlink_health_reporter *fw_fatal_reporter;
 	struct devlink_health_reporter *vnic_reporter;
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 	struct delayed_work		update_fw_log_ts_work;
 	/* failed recoveries in sequence*/
 	u32 failed_in_seq;
@@ -633,6 +640,12 @@ enum {
 	 * creation/deletion on drivers rescan. Unset during device attach.
 	 */
 	MLX5_PRIV_FLAGS_DETACH = 1 << 2,
+#ifdef HAVE_DEVL_PORT_REGISTER
+	/* Distinguish between mlx5e_probe/remove called by module init/cleanup
+	 * and called by other flows which can already hold devlink lock
+	 */
+	MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW = 1 << 3,
+#endif
 };
 
 struct mlx5_adev {
@@ -826,6 +839,9 @@ struct mlx5e_resources {
 		u32                        tisn[MLX5_MAX_PORTS][MLX5_MAX_NUM_TC];
 		bool			   tisn_valid;
 	} hw_objs;
+#ifndef HAVE_NET_DEVICE_DEVLINK_PORT
+	struct devlink_port dl_port;
+#endif
 	struct net_device *uplink_netdev;
 	struct mutex uplink_netdev_lock;
  	struct {
@@ -883,9 +899,11 @@ struct mlx5_clock {
 	struct mlx5_nb             pps_nb;
 	seqlock_t                  lock;
 	struct hwtstamp_config     hwtstamp_config;
+#if (defined (CONFIG_PTP_1588_CLOCK) || defined(CONFIG_PTP_1588_CLOCK_MODULE))
 	struct ptp_clock          *ptp;
 	struct ptp_clock_info      ptp_info;
 	struct mlx5_pps            pps_info;
+#endif
 	struct mlx5_timer          timer;
 };
 
@@ -984,7 +1002,9 @@ struct mlx5_core_dev {
 	enum mlx5_device_state	state;
 	/* sync interface state */
 	struct mutex		intf_state_mutex;
+#ifdef HAVE_LOCKDEP_UNREGISTER_KEY
 	struct lock_class_key	lock_key;
+#endif
 	unsigned long		intf_state;
 	struct mlx5_priv	priv;
 	struct mlx5_profile	profile;
@@ -1405,8 +1425,10 @@ int mlx5_dm_sw_icm_alloc(struct mlx5_cor
 int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type,
 			   u64 length, u16 uid, phys_addr_t addr, u32 obj_id);
 
+#ifdef HAVE_PCI_IOV_GET_PF_DRVDATA
 struct mlx5_core_dev *mlx5_vf_get_core_dev(struct pci_dev *pdev);
 void mlx5_vf_put_core_dev(struct mlx5_core_dev *mdev);
+#endif
 
 int mlx5_sriov_blocking_notifier_register(struct mlx5_core_dev *mdev,
 					  int vf_id,
@@ -1530,9 +1552,10 @@ bool mlx5_is_roce_on(struct mlx5_core_de
 
 static inline bool mlx5_get_roce_state(struct mlx5_core_dev *dev)
 {
+#if defined(HAVE_DEVLINK_PARAM_GENERIC_ID_ENABLE_ROCE)
 	if (MLX5_CAP_GEN(dev, roce_rw_supported))
 		return MLX5_CAP_GEN(dev, roce);
-
+#endif
 	/* If RoCE cap is read-only in FW, get RoCE state from devlink
 	 * in order to support RoCE enable/disable feature
 	 */
