From fa4e59c0fe5e6e2fd8ba29cdcaa03988b3d301c6 Mon Sep 17 00:00:00 2001
From: Bogdan Purcareata <bogdan.purcareata@nxp.com>
Date: Mon, 23 Oct 2017 08:31:25 +0000
Subject: [PATCH] dpaa2-eth: Update dpni_get_statistics

Statistics struct now contains an addditional page, with CEETM stats.
Also update the cmd version, and the call where it's used.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c     | 2 +-
 drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c | 2 +-
 drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h      | 3 ++-
 drivers/net/ethernet/freescale/dpaa2/dpni.c          | 4 ++++
 drivers/net/ethernet/freescale/dpaa2/dpni.h          | 1 +
 5 files changed, 9 insertions(+), 3 deletions(-)

--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1479,7 +1479,7 @@ static void wait_for_egress_fq_empty(str
 		goto out;
 
 	do {
-		err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token, 6,
+		err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token, 6, 0,
 					  &stats);
 		if (err)
 			goto out;
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
@@ -211,7 +211,7 @@ static void dpaa2_eth_get_ethtool_stats(
 		if (j == 4 || j == 5)
 			continue;
 		err = dpni_get_statistics(priv->mc_io, 0, priv->mc_token,
-					  j, &dpni_stats);
+					  j, 0, &dpni_stats);
 		if (err == -EINVAL)
 			/* Older firmware versions don't support all pages */
 			memset(&dpni_stats, 0, sizeof(dpni_stats));
--- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
@@ -70,7 +70,7 @@
 #define DPNI_CMDID_CLR_FS_ENT				DPNI_CMD(0x246)
 
 #define DPNI_CMDID_SET_TX_PRIORITIES			DPNI_CMD_V2(0x250)
-#define DPNI_CMDID_GET_STATISTICS			DPNI_CMD(0x25D)
+#define DPNI_CMDID_GET_STATISTICS			DPNI_CMD_V2(0x25D)
 #define DPNI_CMDID_RESET_STATISTICS			DPNI_CMD(0x25E)
 #define DPNI_CMDID_GET_QUEUE				DPNI_CMD(0x25F)
 #define DPNI_CMDID_SET_QUEUE				DPNI_CMD(0x260)
@@ -287,6 +287,7 @@ struct dpni_rsp_get_tx_data_offset {
 
 struct dpni_cmd_get_statistics {
 	u8 page_number;
+	u8 param;
 };
 
 struct dpni_rsp_get_statistics {
--- a/drivers/net/ethernet/freescale/dpaa2/dpni.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpni.c
@@ -1604,6 +1604,8 @@ int dpni_get_queue(struct fsl_mc_io *mc_
  * @token:	Token of DPNI object
  * @page:	Selects the statistics page to retrieve, see
  *		DPNI_GET_STATISTICS output. Pages are numbered 0 to 6.
+ * @param:	Custom parameter for some pages used to select a certain
+ *		statistic source, for example the TC.
  * @stat:	Structure containing the statistics
  *
  * Return:	'0' on Success; Error code otherwise.
@@ -1612,6 +1614,7 @@ int dpni_get_statistics(struct fsl_mc_io
 			u32 cmd_flags,
 			u16 token,
 			u8 page,
+			u8 param,
 			union dpni_statistics *stat)
 {
 	struct fsl_mc_command cmd = { 0 };
@@ -1625,6 +1628,7 @@ int dpni_get_statistics(struct fsl_mc_io
 					  token);
 	cmd_params = (struct dpni_cmd_get_statistics *)cmd.params;
 	cmd_params->page_number = page;
+	cmd_params->param = param;
 
 	/* send command to mc */
 	err = mc_send_command(mc_io, &cmd);
--- a/drivers/net/ethernet/freescale/dpaa2/dpni.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpni.h
@@ -494,6 +494,7 @@ int dpni_get_statistics(struct fsl_mc_io
 			u32			cmd_flags,
 			u16			token,
 			u8			page,
+			u8			param,
 			union dpni_statistics	*stat);
 
 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
