mlxsw: i2c: Extend initialization with querying firmware info
authorVadim Pasternak <vadimp@mellanox.com>
Wed, 29 May 2019 08:47:15 +0000 (11:47 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 May 2019 19:59:46 +0000 (12:59 -0700)
Extend initialization flow with query request for firmware info in
order to obtain firmware version info.
This info is to be provided to minimal driver to support ethtool
get_drvinfo() interface.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/i2c.c
drivers/net/ethernet/mellanox/mlxsw/minimal.c

index 06aea199951882c9d83d20ff0032f86f3c423d47..803ce9623205b7287893fbf689cdb4f9188cb525 100644 (file)
@@ -509,8 +509,20 @@ mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
        if (!mbox)
                return -ENOMEM;
 
+       err = mlxsw_cmd_query_fw(mlxsw_core, mbox);
+       if (err)
+               goto mbox_put;
+
+       mlxsw_i2c->bus_info.fw_rev.major =
+               mlxsw_cmd_mbox_query_fw_fw_rev_major_get(mbox);
+       mlxsw_i2c->bus_info.fw_rev.minor =
+               mlxsw_cmd_mbox_query_fw_fw_rev_minor_get(mbox);
+       mlxsw_i2c->bus_info.fw_rev.subminor =
+               mlxsw_cmd_mbox_query_fw_fw_rev_subminor_get(mbox);
+
        err = mlxsw_core_resources_query(mlxsw_core, mbox, res);
 
+mbox_put:
        mlxsw_cmd_mbox_free(mbox);
        return err;
 }
index cf2114273b72aae2446a233f2c945246857492f5..471b0ca6d69a2cec5b6768bf0f12834bf6ca4340 100644 (file)
@@ -67,6 +67,23 @@ static const struct net_device_ops mlxsw_m_port_netdev_ops = {
        .ndo_get_devlink_port   = mlxsw_m_port_get_devlink_port,
 };
 
+static void mlxsw_m_module_get_drvinfo(struct net_device *dev,
+                                      struct ethtool_drvinfo *drvinfo)
+{
+       struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
+       struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
+
+       strlcpy(drvinfo->driver, mlxsw_m->bus_info->device_kind,
+               sizeof(drvinfo->driver));
+       snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
+                "%d.%d.%d",
+                mlxsw_m->bus_info->fw_rev.major,
+                mlxsw_m->bus_info->fw_rev.minor,
+                mlxsw_m->bus_info->fw_rev.subminor);
+       strlcpy(drvinfo->bus_info, mlxsw_m->bus_info->device_name,
+               sizeof(drvinfo->bus_info));
+}
+
 static int mlxsw_m_get_module_info(struct net_device *netdev,
                                   struct ethtool_modinfo *modinfo)
 {
@@ -88,6 +105,7 @@ mlxsw_m_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee,
 }
 
 static const struct ethtool_ops mlxsw_m_port_ethtool_ops = {
+       .get_drvinfo            = mlxsw_m_module_get_drvinfo,
        .get_module_info        = mlxsw_m_get_module_info,
        .get_module_eeprom      = mlxsw_m_get_module_eeprom,
 };