Skip to contentSkip to conversation

driver: net: fsl-mc: Add version check for MC objects

PATCH New Prabhakar Kushwaha 3 participants 4 messages Dec 24, 2015 – Jan 27, 2016 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 driver: net: fsl-mc: Add version check for MC objects

Check and compare version of management complex's object with the version supported by Freescale ldpaa2 ethernet driver.

---
 drivers/net/fsl-mc/mc.c           | 51 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)
drivers/net/fsl-mc/mc.c +50 -1
index bac4610..b773e35 100644
@@ -655,6 +655,26 @@ int fsl_mc_ldpaa_init(bd_t *bis)
 	return 0;
 }
 
+static int dprc_version_check(struct fsl_mc_io *mc_io, uint16_t handle)
+{
+	struct dprc_attributes attr;
+	int error;
+
+	memset(&attr, 0, sizeof(struct dprc_attributes));
+	error = dprc_get_attributes(mc_io, MC_CMD_NO_FLAGS, handle, &attr);
+	if (error == 0) {
+		if ((attr.version.major != DPRC_VER_MAJOR) ||
+		    (attr.version.minor != DPRC_VER_MINOR)) {
+			printf("DPRC version mismatch found %u.%u,",
+			       attr.version.major,
+			       attr.version.minor);
+			printf("supported version is %u.%u\n",
+			       DPRC_VER_MAJOR, DPRC_VER_MINOR);
+		}
+	}
+	return error;
+}
+
 static int dpio_init(void)
 {
 	struct qbman_swp_desc p_des;
@@ -688,11 +708,18 @@ static int dpio_init(void)
 		goto err_get_attr;
 	}
 
+	if ((attr.version.major != DPIO_VER_MAJOR) ||
+	    (attr.version.minor != DPIO_VER_MINOR)) {
+		printf("DPIO version mismatch found %u.%u,",
+		       attr.version.major, attr.version.minor);
+		printf("supported version is %u.%u\n",
+		       DPIO_VER_MAJOR, DPIO_VER_MINOR);
+	}
+
 	dflt_dpio->dpio_id = attr.id;
 #ifdef DEBUG
 	printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id);
 #endif
-
 	err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
 	if (err < 0) {
 		printf("dpio_enable() failed %d\n", err);
@@ -784,6 +811,12 @@ static int dprc_init(void)
 		goto err_root_open;
 	}
 
+	err = dprc_version_check(root_mc_io, root_dprc_handle);
+	if (err < 0) {
+		printf("dprc_version_check() failed: %d\n", err);
+		goto err_root_open;
+	}
+
 	cfg.options = DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED |
 		      DPRC_CFG_OPT_OBJ_CREATE_ALLOWED |
 		      DPRC_CFG_OPT_ALLOC_ALLOWED;
@@ -906,6 +939,14 @@ static int dpbp_init(void)
 		goto err_get_attr;
 	}
 
+	if ((dpbp_attr.version.major != DPBP_VER_MAJOR) ||
+	    (dpbp_attr.version.minor != DPBP_VER_MINOR)) {
+		printf("DPBP version mismatch found %u.%u,",
+		       dpbp_attr.version.major, dpbp_attr.version.minor);
+		printf("supported version is %u.%u\n",
+		       DPBP_VER_MAJOR, DPBP_VER_MINOR);
+	}
+
 	dflt_dpbp->dpbp_attr.id = dpbp_attr.id;
 #ifdef DEBUG
 	printf("Init: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id);
@@ -994,6 +1035,14 @@ static int dpni_init(void)
 		goto err_get_attr;
 	}
 
+	if ((dpni_attr.version.major != DPNI_VER_MAJOR) ||
+	    (dpni_attr.version.minor != DPNI_VER_MINOR)) {
+		printf("DPNI version mismatch found %u.%u,",
+		       dpni_attr.version.major, dpni_attr.version.minor);
+		printf("supported version is %u.%u\n",
+		       DPNI_VER_MAJOR, DPNI_VER_MINOR);
+	}
+
 	dflt_dpni->dpni_id = dpni_attr.id;
 #ifdef DEBUG
 	printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id);
drivers/net/ldpaa_eth/ldpaa_eth.c +28 -0
index 69530b1..47a3a23 100644
@@ -599,6 +599,29 @@ static void ldpaa_dpbp_free(void)
 	dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
 }
 
+static int ldpaa_dpmac_version_check(struct fsl_mc_io *mc_io,
+				     struct ldpaa_eth_priv *priv)
+{
+	struct dpmac_attr attr;
+	int error;
+
+	memset(&attr, 0, sizeof(struct dpmac_attr));
+	error = dpmac_get_attributes(mc_io, MC_CMD_NO_FLAGS,
+				     priv->dpmac_handle,
+				     &attr);
+	if (error == 0) {
+		if ((attr.version.major != DPMAC_VER_MAJOR) ||
+		    (attr.version.minor != DPMAC_VER_MINOR)) {
+			printf("DPMAC version mismatch found %u.%u,",
+			       attr.version.major, attr.version.minor);
+			printf("supported version is %u.%u\n",
+			       DPMAC_VER_MAJOR, DPMAC_VER_MINOR);
+		}
+	}
+
+	return error;
+}
+
 static int ldpaa_dpmac_setup(struct ldpaa_eth_priv *priv)
 {
 	int err = 0;
@@ -609,6 +632,11 @@ static int ldpaa_dpmac_setup(struct ldpaa_eth_priv *priv)
 			  &priv->dpmac_handle);
 	if (err)
 		printf("dpmac_create() failed\n");
+
+	err = ldpaa_dpmac_version_check(dflt_mc_io, priv);
+	if (err < 0)
+		printf("ldpaa_dpmac_version_check() failed: %d\n", err);
+
 	return err;
 }
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/7 driver: net: fsl-mc: Add version check for MC objects

Quoted 9 lines · Prabhakar Kushwaha

Check and compare version of management complex's object with the version supported by Freescale ldpaa2 ethernet driver.

---
 drivers/net/fsl-mc/mc.c           | 51 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

The driver is not backward compatible, is it? Looks like every time the firmware upgrades, the driver changes.

York

#2 lore raw

PATCH 1/7 driver: net: fsl-mc: Add version check for MC objects

Quoted 16 lines

-----Original Message-----
From: york sun [mailto:york.sun at nxp.com]
Sent: Monday, January 25, 2016 10:49 PM
To: Prabhakar Kushwaha <[email protected]>; u-boot at lists.denx.de
Cc: Yusong Sun <[email protected]>
Subject: Re: [PATCH 1/7] driver: net: fsl-mc: Add version check for MC objects

Quoted 6 lines · Prabhakar Kushwaha

Check and compare version of management complex's object with the version supported by Freescale ldpaa2 ethernet driver.

---
 drivers/net/fsl-mc/mc.c           | 51
Quoted 8 lines

++++++++++++++++++++++++++++++++++++++-

Quoted 3 lines
 drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

The driver is not backward compatible, is it? Looks like every time the firmware upgrades, the driver changes.

Yes, driver is not backward compatible.
Each Firmware new version changes lots of things including APIs. It is still getting stable.

--prabhakar

#3 lore raw

PATCH 1/7 driver: net: fsl-mc: Add version check for MC objects

In reply to Prabhakar Kushwaha
Quoted 8 lines · Prabhakar Kushwaha

Check and compare version of management complex's object with the version supported by Freescale ldpaa2 ethernet driver.

---
 drivers/net/fsl-mc/mc.c           | 51 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

Slightly reformat commit message.
Applied to u-boot-fsl-qoriq master. Awaiting upstream.

Thanks.

York