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

Change-Id: Ie138b78588024764c1adebd52b5a7d2ab547bfb9
---
 .../mellanox/mlx5/core/en/reporter_rx.c       | 596 ++++++++++++++++--
 1 file changed, 545 insertions(+), 51 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
@@ -21,6 +21,7 @@ static const char * const rq_sw_state_ty
 	[MLX5E_RQ_STATE_XSK] = "xsk",
 };
 
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
 static int mlx5e_query_rq_state(struct mlx5_core_dev *dev, u32 rqn, u8 *state)
 {
 	int outlen = MLX5_ST_SZ_BYTES(query_rq_out);
@@ -43,6 +44,7 @@ out:
 	kvfree(out);
 	return err;
 }
+#endif
 
 static int mlx5e_wait_for_icosq_flush(struct mlx5e_icosq *icosq)
 {
@@ -89,8 +91,10 @@ static int mlx5e_rx_reporter_err_icosq_c
 
 	/* mlx5e_close_rq cancels this work before RQ and ICOSQ are killed. */
 	rq = &icosq->channel->rq;
+#ifdef HAVE_XSK_ZERO_COPY_SUPPORT
 	if (test_bit(MLX5E_RQ_STATE_ENABLED, &icosq->channel->xskrq.state))
 		xskrq = &icosq->channel->xskrq;
+#endif
 	mdev = icosq->channel->mdev;
 	dev = icosq->channel->netdev;
 	err = mlx5_core_query_sq_state(mdev, icosq->sqn, &state);
@@ -121,9 +125,17 @@ static int mlx5e_rx_reporter_err_icosq_c
 
 	mlx5e_reset_icosq_cc_pc(icosq);
 
+#ifdef HAVE_PAGE_POOL_DEFRAG_PAGE
 	mlx5e_free_rx_missing_descs(rq);
+#else
+	mlx5e_free_rx_in_progress_descs(rq);
+#endif
 	if (xskrq)
+#ifdef HAVE_PAGE_POOL_DEFRAG_PAGE
 		mlx5e_free_rx_missing_descs(xskrq);
+#else
+		mlx5e_free_rx_in_progress_descs(xskrq);
+#endif
 
 	clear_bit(MLX5E_SQ_STATE_RECOVERING, &icosq->state);
 	mlx5e_activate_icosq(icosq);
@@ -183,32 +195,22 @@ static int mlx5e_rx_reporter_timeout_rec
 	return err;
 }
 
-static int mlx5e_rx_reporter_recover_from_ctx(struct mlx5e_err_ctx *err_ctx)
-{
-	return err_ctx->recover(err_ctx->ctx);
-}
-
-static int mlx5e_rx_reporter_recover(struct devlink_health_reporter *reporter,
-				     void *context,
-				     struct netlink_ext_ack *extack)
-{
-	struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
-	struct mlx5e_err_ctx *err_ctx = context;
-
-	return err_ctx ? mlx5e_rx_reporter_recover_from_ctx(err_ctx) :
-			 mlx5e_health_recover_channels(priv);
-}
-
-static void mlx5e_reporter_icosq_diagnose(struct mlx5e_icosq *icosq, u8 hw_state,
-					  struct devlink_fmsg *fmsg)
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+static void
+#else
+static int
+#endif
+mlx5e_reporter_icosq_diagnose(struct mlx5e_icosq *icosq, u8 hw_state,
+					 struct devlink_fmsg *fmsg)
 {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
 	devlink_fmsg_u32_pair_put(fmsg, "sqn", icosq->sqn);
 	devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state);
 	devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cc);
 	devlink_fmsg_u32_pair_put(fmsg, "pc", icosq->pc);
 	devlink_fmsg_u32_pair_put(fmsg, "WQE size", mlx5_wq_cyc_get_size(&icosq->wq));
-
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ");
 	devlink_fmsg_u32_pair_put(fmsg, "cqn", icosq->cq.mcq.cqn);
 	devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cq.wq.cc);
@@ -216,21 +218,97 @@ static void mlx5e_reporter_icosq_diagnos
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#else
+	int err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "sqn", icosq->sqn);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cc);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "pc", icosq->pc);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "WQE size",
+					mlx5_wq_cyc_get_size(&icosq->wq));
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ");
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "cqn", icosq->cq.mcq.cqn);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cq.wq.cc);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "size", mlx5_cqwq_get_size(&icosq->cq.wq));
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
-static void mlx5e_health_rq_put_sw_state(struct devlink_fmsg *fmsg, struct mlx5e_rq *rq)
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+static void
+#else
+static int
+#endif
+mlx5e_health_rq_put_sw_state(struct devlink_fmsg *fmsg, struct mlx5e_rq *rq)
 {
+#ifdef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+	int err;
+#endif
 	int i;
 
 	BUILD_BUG_ON_MSG(ARRAY_SIZE(rq_sw_state_type_name) != MLX5E_NUM_RQ_STATES,
 			 "rq_sw_state_type_name string array must be consistent with MLX5E_RQ_STATE_* enum in en.h");
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SW State");
+#else
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SW State");
+	if (err)
+		return err;
+#endif
 
-	for (i = 0; i < ARRAY_SIZE(rq_sw_state_type_name); ++i)
+	for (i = 0; i < ARRAY_SIZE(rq_sw_state_type_name); ++i) {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 		devlink_fmsg_u32_pair_put(fmsg, rq_sw_state_type_name[i],
-					  test_bit(i, &rq->state));
+				test_bit(i, &rq->state));
+#else
+		err = devlink_fmsg_u32_pair_put(fmsg, rq_sw_state_type_name[i],
+						test_bit(i, &rq->state));
+		if (err)
+			return err;
+#endif
+	}
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#else
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
 static int
@@ -250,7 +328,7 @@ mlx5e_rx_reporter_build_diagnose_output_
 	wqes_sz = mlx5e_rqwq_get_cur_sz(rq);
 	wq_head = mlx5e_rqwq_get_head(rq);
 	wqe_counter = mlx5e_rqwq_get_wqe_counter(rq);
-
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	devlink_fmsg_u32_pair_put(fmsg, "rqn", rq->rqn);
 	devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state);
 	devlink_fmsg_u32_pair_put(fmsg, "WQE counter", wqe_counter);
@@ -259,44 +337,131 @@ mlx5e_rx_reporter_build_diagnose_output_
 	mlx5e_health_rq_put_sw_state(fmsg, rq);
 	mlx5e_health_cq_diag_fmsg(&rq->cq, fmsg);
 	mlx5e_health_eq_diag_fmsg(rq->cq.mcq.eq, fmsg);
+#else
+	err = devlink_fmsg_u32_pair_put(fmsg, "rqn", rq->rqn);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "WQE counter", wqe_counter);
+	if (err)
+		return err;
 
+	err = devlink_fmsg_u32_pair_put(fmsg, "posted WQEs", wqes_sz);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "cc", wq_head);
+	if (err)
+		return err;
+
+	err = mlx5e_health_rq_put_sw_state(fmsg, rq);
+	if (err)
+		return err;
+
+	err = mlx5e_health_cq_diag_fmsg(&rq->cq, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_eq_diag_fmsg(rq->cq.mcq.eq, fmsg);
+	if (err)
+		return err;
+#endif
 	if (rq->icosq) {
 		struct mlx5e_icosq *icosq = rq->icosq;
 		u8 icosq_hw_state;
-		int err;
-
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+		mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state);
+		mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
+#else
 		err = mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state);
 		if (err)
 			return err;
 
-		mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
+		err = mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
+		if (err)
+			return err;
+#endif
 	}
 
 	return 0;
 }
 
-static void mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
-						    struct devlink_fmsg *fmsg)
+static int mlx5e_rx_reporter_recover_from_ctx(struct mlx5e_err_ctx *err_ctx)
+{
+	return err_ctx->recover(err_ctx->ctx);
+}
+
+static int mlx5e_rx_reporter_recover(struct devlink_health_reporter *reporter,
+				     void *context
+#ifdef HAVE_HEALTH_REPORTER_RECOVER_HAS_EXTACK
+				     , struct netlink_ext_ack *extack
+#endif
+				     )
+{
+	struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
+	struct mlx5e_err_ctx *err_ctx = context;
+
+	return err_ctx ? mlx5e_rx_reporter_recover_from_ctx(err_ctx) :
+			 mlx5e_health_recover_channels(priv);
+}
+
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+static void
+#else
+static int
+#endif
+mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
+						   struct devlink_fmsg *fmsg)
 {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	devlink_fmsg_obj_nest_start(fmsg);
 	devlink_fmsg_u32_pair_put(fmsg, "channel ix", rq->ix);
 	mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
 	devlink_fmsg_obj_nest_end(fmsg);
+#else
+	int err;
+
+	err = devlink_fmsg_obj_nest_start(fmsg);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "channel ix", rq->ix);
+	if (err)
+		return err;
+
+	err = mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
+	if (err)
+		return err;
+
+	return devlink_fmsg_obj_nest_end(fmsg);
+#endif
 }
 
-static void mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq,
-						  struct devlink_fmsg *fmsg)
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+static void
+#else
+static int
+#endif
+mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq,
+						 struct devlink_fmsg *fmsg)
 {
 	struct mlx5e_priv *priv = rq->priv;
 	struct mlx5e_params *params;
 	u32 rq_stride, rq_sz;
 	bool real_time;
-
+#ifdef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+	int err;
+#endif
 	params = &priv->channels.params;
 	rq_sz = mlx5e_rqwq_get_size(rq);
 	real_time =  mlx5_is_real_time_rq(rq->mdev);
 	rq_stride = BIT(mlx5e_mpwqe_get_log_stride_size(rq->mdev, params, NULL));
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
 	devlink_fmsg_u8_pair_put(fmsg, "type", params->rq_wq_type);
 	devlink_fmsg_u64_pair_put(fmsg, "stride size", rq_stride);
@@ -304,73 +469,214 @@ static void mlx5e_rx_reporter_diagnose_g
 	devlink_fmsg_string_pair_put(fmsg, "ts_format", real_time ? "RT" : "FRC");
 	mlx5e_health_cq_common_diag_fmsg(&rq->cq, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#else
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u8_pair_put(fmsg, "type", params->rq_wq_type);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u64_pair_put(fmsg, "stride size", rq_stride);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "size", rq_sz);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_string_pair_put(fmsg, "ts_format", real_time ? "RT" : "FRC");
+	if (err)
+		return err;
+
+	err = mlx5e_health_cq_common_diag_fmsg(&rq->cq, fmsg);
+	if (err)
+		return err;
+
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 static void
+#else
+static int
+#endif
 mlx5e_rx_reporter_diagnose_common_ptp_config(struct mlx5e_priv *priv, struct mlx5e_ptp *ptp_ch,
 					     struct devlink_fmsg *fmsg)
 {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP");
 	devlink_fmsg_u32_pair_put(fmsg, "filter_type", priv->tstamp.rx_filter);
 	mlx5e_rx_reporter_diagnose_generic_rq(&ptp_ch->rq, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#else
+	int err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP");
+	if (err)
+		return err;
+
+	err = devlink_fmsg_u32_pair_put(fmsg, "filter_type", priv->tstamp.rx_filter);
+	if (err)
+		return err;
+
+	err = mlx5e_rx_reporter_diagnose_generic_rq(&ptp_ch->rq, fmsg);
+	if (err)
+		return err;
+
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 static void
+#else
+static int
+#endif
 mlx5e_rx_reporter_diagnose_common_config(struct devlink_health_reporter *reporter,
 					 struct devlink_fmsg *fmsg)
 {
 	struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
 	struct mlx5e_rq *generic_rq = &priv->channels.c[0]->rq;
 	struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
+#ifdef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+	int err;
 
+#endif
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Common config");
 	mlx5e_rx_reporter_diagnose_generic_rq(generic_rq, fmsg);
 	if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state))
 		mlx5e_rx_reporter_diagnose_common_ptp_config(priv, ptp_ch, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#else
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Common config");
+	if (err)
+		return err;
+
+	err = mlx5e_rx_reporter_diagnose_generic_rq(generic_rq, fmsg);
+	if (err)
+		return err;
+
+	if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state)) {
+		err = mlx5e_rx_reporter_diagnose_common_ptp_config(priv, ptp_ch, fmsg);
+		if (err)
+			return err;
+	}
+
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
-static void mlx5e_rx_reporter_build_diagnose_output_ptp_rq(struct mlx5e_rq *rq,
-							   struct devlink_fmsg *fmsg)
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+static void
+#else
+static int
+#endif
+mlx5e_rx_reporter_build_diagnose_output_ptp_rq(struct mlx5e_rq *rq,
+							  struct devlink_fmsg *fmsg)
 {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	devlink_fmsg_obj_nest_start(fmsg);
 	devlink_fmsg_string_pair_put(fmsg, "channel", "ptp");
 	mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
 	devlink_fmsg_obj_nest_end(fmsg);
+#else
+	int err;
+
+	err = devlink_fmsg_obj_nest_start(fmsg);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_string_pair_put(fmsg, "channel", "ptp");
+	if (err)
+		return err;
+
+	err = mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	return 0;
+#endif
 }
 
 static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter,
-				      struct devlink_fmsg *fmsg,
-				      struct netlink_ext_ack *extack)
+				      struct devlink_fmsg *fmsg
+#ifdef HAVE_HEALTH_REPORTER_RECOVER_HAS_EXTACK
+				     , struct netlink_ext_ack *extack
+#endif
+				     )
 {
 	struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
 	struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	int i;
+#else
+	int i, err = 0;
+#endif
 
 	mutex_lock(&priv->state_lock);
 
 	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
 		goto unlock;
-
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_rx_reporter_diagnose_common_config(reporter, fmsg);
 	devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
+#else
+	err = mlx5e_rx_reporter_diagnose_common_config(reporter, fmsg);
+	if (err)
+		goto unlock;
+
+	err = devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
+	if (err)
+		goto unlock;
+#endif
 
 	for (i = 0; i < priv->channels.num; i++) {
 		struct mlx5e_channel *c = priv->channels.c[i];
 		struct mlx5e_rq *rq;
 
+#ifdef HAVE_XSK_ZERO_COPY_SUPPORT
 		rq = test_bit(MLX5E_CHANNEL_STATE_XSK, c->state) ?
 			&c->xskrq : &c->rq;
-
+#else
+		rq = &c->rq;
+#endif
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 		mlx5e_rx_reporter_build_diagnose_output(rq, fmsg);
+#else
+		err = mlx5e_rx_reporter_build_diagnose_output(rq, fmsg);
+		if (err)
+			goto unlock;
+#endif
 	}
-	if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state))
+	if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state)) {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 		mlx5e_rx_reporter_build_diagnose_output_ptp_rq(&ptp_ch->rq, fmsg);
+#else
+		err = mlx5e_rx_reporter_build_diagnose_output_ptp_rq(&ptp_ch->rq, fmsg);
+		if (err)
+			goto unlock;
+#endif
+	}
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	devlink_fmsg_arr_pair_nest_end(fmsg);
+#else
+	err = devlink_fmsg_arr_pair_nest_end(fmsg);
+#endif
 unlock:
 	mutex_unlock(&priv->state_lock);
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	return 0;
+#else
+	return err;
+#endif
 }
 
 static int mlx5e_rx_reporter_dump_icosq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
@@ -378,34 +684,88 @@ static int mlx5e_rx_reporter_dump_icosq(
 {
 	struct mlx5e_txqsq *icosq = ctx;
 	struct mlx5_rsc_key key = {};
+#ifdef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+	int err;
+#endif
 
 	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
 		return 0;
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice");
+#else
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice");
+	if (err)
+		return err;
+
+#endif
 	key.size = PAGE_SIZE;
 	key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
-
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
-
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
+	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
+	if (err)
+		return err;
+#endif
+
 	key.rsc = MLX5_SGMT_TYPE_FULL_QPC;
 	key.index1 = icosq->sqn;
 	key.num_of_obj1 = 1;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
-
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
+	if (err)
+		return err;
+#endif
+
 	key.rsc = MLX5_SGMT_TYPE_SND_BUFF;
 	key.num_of_obj2 = MLX5_RSC_DUMP_ALL;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	return 0;
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
 static int mlx5e_rx_reporter_dump_rq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
@@ -413,34 +773,89 @@ static int mlx5e_rx_reporter_dump_rq(str
 {
 	struct mlx5_rsc_key key = {};
 	struct mlx5e_rq *rq = ctx;
+#ifdef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+	int err;
+#endif
 
 	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
 		return 0;
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice");
+#else
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice");
+	if (err)
+		return err;
+#endif
 	key.size = PAGE_SIZE;
 	key.rsc = MLX5_SGMT_TYPE_RX_SLICE_ALL;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
 
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
+	if (err)
+		return err;
+#endif
+
 	key.rsc = MLX5_SGMT_TYPE_FULL_QPC;
 	key.index1 = rq->rqn;
 	key.num_of_obj1 = 1;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "receive_buff");
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "receive_buff");
+	if (err)
+		return err;
+#endif
+
 	key.rsc = MLX5_SGMT_TYPE_RCV_BUFF;
 	key.num_of_obj2 = MLX5_RSC_DUMP_ALL;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 
 	return 0;
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
+
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+#endif
 }
 
 static int mlx5e_rx_reporter_dump_all_rqs(struct mlx5e_priv *priv,
@@ -448,28 +863,69 @@ static int mlx5e_rx_reporter_dump_all_rq
 {
 	struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
 	struct mlx5_rsc_key key = {};
+	int i;
+#ifdef HAVE_INT_DEVLINK_FMSG_U8_PAIR
+	int err;
+#endif
 
 	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
 		return 0;
 
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice");
+#else
+	err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice");
+	if (err)
+		return err;
+
+#endif
+
 	key.size = PAGE_SIZE;
 	key.rsc = MLX5_SGMT_TYPE_RX_SLICE_ALL;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
 	mlx5e_health_fmsg_named_obj_nest_end(fmsg);
 	devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
 
-	for (int i = 0; i < priv->channels.num; i++) {
-		struct mlx5e_rq *rq = &priv->channels.c[i]->rq;
+#else
+	err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
+	if (err)
+		return err;
 
+	err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
+	if (err)
+		return err;
+
+	err = devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
+	if (err)
+		return err;
+#endif
+	for (i = 0; i < priv->channels.num; i++) {
+		struct mlx5e_rq *rq = &priv->channels.c[i]->rq;
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 		mlx5e_health_queue_dump(priv, fmsg, rq->rqn, "RQ");
+#else
+		err = mlx5e_health_queue_dump(priv, fmsg, rq->rqn, "RQ");
+		if (err)
+			return err;
+#endif
 	}
 
-	if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state))
+	if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state)) {
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 		mlx5e_health_queue_dump(priv, fmsg, ptp_ch->rq.rqn, "PTP RQ");
+#else
+		err = mlx5e_health_queue_dump(priv, fmsg, ptp_ch->rq.rqn, "PTP RQ");
+		if (err)
+			return err;
+#endif
+	}
 
-	devlink_fmsg_arr_pair_nest_end(fmsg);
+#ifndef HAVE_INT_DEVLINK_FMSG_U8_PAIR
 	return 0;
+#else
+	return devlink_fmsg_arr_pair_nest_end(fmsg);
+#endif
 }
 
 static int mlx5e_rx_reporter_dump_from_ctx(struct mlx5e_priv *priv,
@@ -480,8 +936,11 @@ static int mlx5e_rx_reporter_dump_from_c
 }
 
 static int mlx5e_rx_reporter_dump(struct devlink_health_reporter *reporter,
-				  struct devlink_fmsg *fmsg, void *context,
-				  struct netlink_ext_ack *extack)
+				  struct devlink_fmsg *fmsg, void *context
+#ifdef HAVE_HEALTH_REPORTER_RECOVER_HAS_EXTACK
+                                  , struct netlink_ext_ack *extack
+#endif
+                                 )
 {
 	struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
 	struct mlx5e_err_ctx *err_ctx = context;
@@ -489,6 +948,7 @@ static int mlx5e_rx_reporter_dump(struct
 	return err_ctx ? mlx5e_rx_reporter_dump_from_ctx(priv, err_ctx, fmsg) :
 			 mlx5e_rx_reporter_dump_all_rqs(priv, fmsg);
 }
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 
 void mlx5e_reporter_rx_timeout(struct mlx5e_rq *rq)
 {
@@ -500,7 +960,9 @@ void mlx5e_reporter_rx_timeout(struct ml
 
 	err_ctx.ctx = rq;
 	err_ctx.recover = mlx5e_rx_reporter_timeout_recover;
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
 	err_ctx.dump = mlx5e_rx_reporter_dump_rq;
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 
 	if (icosq)
 		snprintf(icosq_str, sizeof(icosq_str), "ICOSQ: 0x%x, ", icosq->sqn);
@@ -519,7 +981,9 @@ void mlx5e_reporter_rq_cqe_err(struct ml
 
 	err_ctx.ctx = rq;
 	err_ctx.recover = mlx5e_rx_reporter_err_rq_cqe_recover;
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
 	err_ctx.dump = mlx5e_rx_reporter_dump_rq;
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 	snprintf(err_str, sizeof(err_str), "ERR CQE on RQ: 0x%x", rq->rqn);
 
 	mlx5e_health_report(priv, priv->rx_reporter, err_str, &err_ctx);
@@ -533,7 +997,9 @@ void mlx5e_reporter_icosq_cqe_err(struct
 
 	err_ctx.ctx = icosq;
 	err_ctx.recover = mlx5e_rx_reporter_err_icosq_cqe_recover;
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
 	err_ctx.dump = mlx5e_rx_reporter_dump_icosq;
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 	snprintf(err_str, sizeof(err_str), "ERR CQE on ICOSQ: 0x%x", icosq->sqn);
 
 	mlx5e_health_report(priv, priv->rx_reporter, err_str, &err_ctx);
@@ -549,6 +1015,7 @@ void mlx5e_reporter_icosq_resume_recover
 	mutex_unlock(&c->icosq_recovery_lock);
 }
 
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
 static const struct devlink_health_reporter_ops mlx5_rx_reporter_ops = {
 	.name = "rx",
 	.recover = mlx5e_rx_reporter_recover,
@@ -557,20 +1024,41 @@ static const struct devlink_health_repor
 };
 
 #define MLX5E_REPORTER_RX_GRACEFUL_PERIOD 500
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 
 void mlx5e_reporter_rx_create(struct mlx5e_priv *priv)
 {
-	struct devlink_health_reporter *reporter;
-
-	reporter = devlink_port_health_reporter_create(priv->netdev->devlink_port,
-						       &mlx5_rx_reporter_ops,
+#ifndef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
+	priv->rx_reporter = NULL;
+#else
+#ifndef HAVE_DEVLINK_PORT_HEALTH_REPORTER_CREATE
+	struct devlink *devlink = priv_to_devlink(priv->mdev);
+#endif
+ 	struct devlink_health_reporter *reporter;
+
+#ifdef HAVE_DEVLINK_PORT_HEALTH_REPORTER_CREATE
+#ifdef HAVE_NET_DEVICE_DEVLINK_PORT
+	reporter = devlink_port_health_reporter_create(priv->netdev->devlink_port, &mlx5_rx_reporter_ops,
+#else
+	reporter = devlink_port_health_reporter_create(mlx5e_devlink_get_dl_port(priv), &mlx5_rx_reporter_ops,
+#endif
 						       MLX5E_REPORTER_RX_GRACEFUL_PERIOD, priv);
+#else /* HAVE_DEVLINK_PORT_HEALTH_REPORTER_CREATE */
+	reporter = devlink_health_reporter_create(devlink,
+							&mlx5_rx_reporter_ops,
+							MLX5E_REPORTER_RX_GRACEFUL_PERIOD,
+#ifdef HAVE_DEVLINK_HEALTH_REPORTER_CREATE_5_ARGS
+							true,
+#endif
+							priv);
+#endif /* HAVE_DEVLINK_PORT_HEALTH_REPORTER_CREATE */
 	if (IS_ERR(reporter)) {
 		netdev_warn(priv->netdev, "Failed to create rx reporter, err = %ld\n",
 			    PTR_ERR(reporter));
 		return;
 	}
 	priv->rx_reporter = reporter;
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 }
 
 void mlx5e_reporter_rx_destroy(struct mlx5e_priv *priv)
@@ -578,6 +1066,12 @@ void mlx5e_reporter_rx_destroy(struct ml
 	if (!priv->rx_reporter)
 		return;
 
+#ifdef HAVE_DEVLINK_HEALTH_REPORT_SUPPORT
+#ifdef HAVE_DEVLINK_PORT_HEALTH_REPORTER_DESTROY
+	devlink_port_health_reporter_destroy(priv->rx_reporter);
+#else
 	devlink_health_reporter_destroy(priv->rx_reporter);
+#endif /* HAVE_DEVLINK_PORT_HEALTH_REPORTER_DESTROY */
+#endif /* HAVE_DEVLINK_HEALTH_REPORT_SUPPORT */
 	priv->rx_reporter = NULL;
 }
