staging: fsl-dpaa2/eth: Add firmware version
authorIoana Radulescu <ruxandra.radulescu@nxp.com>
Wed, 11 Oct 2017 13:29:51 +0000 (08:29 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Oct 2017 14:45:19 +0000 (16:45 +0200)
Include firmware version in the driver information exported
through ethtool.

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h
drivers/staging/fsl-dpaa2/ethernet/dpni.c
drivers/staging/fsl-dpaa2/ethernet/dpni.h

index 031179ab3a22fd3cc38879acc4d143ac488734ea..ebe8fd6ccf2cc526e1d50b69b70b9cf08311c10f 100644 (file)
@@ -76,10 +76,22 @@ static char dpaa2_ethtool_extras[][ETH_GSTRING_LEN] = {
 static void dpaa2_eth_get_drvinfo(struct net_device *net_dev,
                                  struct ethtool_drvinfo *drvinfo)
 {
+       struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
+       u16 fw_major, fw_minor;
+       int err;
+
        strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
        strlcpy(drvinfo->version, dpaa2_eth_drv_version,
                sizeof(drvinfo->version));
-       strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
+
+       err =  dpni_get_api_version(priv->mc_io, 0, &fw_major, &fw_minor);
+       if (!err)
+               snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+                        "%u.%u", fw_major, fw_minor);
+       else
+               strlcpy(drvinfo->fw_version, "N/A",
+                       sizeof(drvinfo->fw_version));
+
        strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent),
                sizeof(drvinfo->bus_info));
 }
index 57df222922332202665a1a2325bd81d36541e031..3120e22496d05ede2b68e8e543ca7a6f5cf901d7 100644 (file)
@@ -538,4 +538,9 @@ struct dpni_rsp_get_taildrop {
        __le32 threshold;
 };
 
+struct dpni_rsp_get_api_version {
+       u16 major;
+       u16 minor;
+};
+
 #endif /* _FSL_DPNI_CMD_H */
index 04a5b14bc1c5539c920d37643c31aacb285546bb..e8be76181c36299b95de03b0487a6296d6c33d99 100644 (file)
@@ -1594,3 +1594,35 @@ int dpni_get_taildrop(struct fsl_mc_io *mc_io,
 
        return 0;
 }
+
+/**
+ * dpni_get_api_version() - Get Data Path Network Interface API version
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver: Major version of data path network interface API
+ * @minor_ver: Minor version of data path network interface API
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpni_get_api_version(struct fsl_mc_io *mc_io,
+                        u32 cmd_flags,
+                        u16 *major_ver,
+                        u16 *minor_ver)
+{
+       struct dpni_rsp_get_api_version *rsp_params;
+       struct mc_command cmd = { 0 };
+       int err;
+
+       cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
+                                         cmd_flags, 0);
+
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       rsp_params = (struct dpni_rsp_get_api_version *)cmd.params;
+       *major_ver = le16_to_cpu(rsp_params->major);
+       *minor_ver = le16_to_cpu(rsp_params->minor);
+
+       return 0;
+}
index 282e5e85ffa7cb5f48a575fc8f663d4e9dacf117..ce86a816af45963ffc8b1db47b6460febf03a849 100644 (file)
@@ -829,4 +829,9 @@ struct dpni_rule_cfg {
        u8      key_size;
 };
 
+int dpni_get_api_version(struct fsl_mc_io *mc_io,
+                        u32 cmd_flags,
+                        u16 *major_ver,
+                        u16 *minor_ver);
+
 #endif /* __FSL_DPNI_H */