Commit 6935af80 authored by Vadim Pasternak's avatar Vadim Pasternak Committed by David S. Miller

mlxsw: minimal: Add validation for FW version

Add validation for FW version in order to prevent driver initialization
in case FW version is older than expected. FW version validation is
necessary, because use of a new field 'num_of_modules' in MGPIR register
is not backward compatible. FW 'minor' and 'subminor' versions are
expected to be greater than or equal to 2000 and 1886, respectively.
Signed-off-by: default avatarVadim Pasternak <vadimp@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 762effaa
......@@ -16,6 +16,14 @@
static const char mlxsw_m_driver_name[] = "mlxsw_minimal";
#define MLXSW_M_FWREV_MINOR 2000
#define MLXSW_M_FWREV_SUBMINOR 1886
static const struct mlxsw_fw_rev mlxsw_m_fw_rev = {
.minor = MLXSW_M_FWREV_MINOR,
.subminor = MLXSW_M_FWREV_SUBMINOR,
};
struct mlxsw_m_port;
struct mlxsw_m {
......@@ -326,6 +334,24 @@ static void mlxsw_m_ports_remove(struct mlxsw_m *mlxsw_m)
kfree(mlxsw_m->ports);
}
static int mlxsw_m_fw_rev_validate(struct mlxsw_m *mlxsw_m)
{
const struct mlxsw_fw_rev *rev = &mlxsw_m->bus_info->fw_rev;
/* Validate driver and FW are compatible.
* Do not check major version, since it defines chip type, while
* driver is supposed to support any type.
*/
if (mlxsw_core_fw_rev_minor_subminor_validate(rev, &mlxsw_m_fw_rev))
return 0;
dev_err(mlxsw_m->bus_info->dev, "The firmware version %d.%d.%d is incompatible with the driver (required >= %d.%d.%d)\n",
rev->major, rev->minor, rev->subminor, rev->major,
mlxsw_m_fw_rev.minor, mlxsw_m_fw_rev.subminor);
return -EINVAL;
}
static int mlxsw_m_init(struct mlxsw_core *mlxsw_core,
const struct mlxsw_bus_info *mlxsw_bus_info,
struct netlink_ext_ack *extack)
......@@ -336,6 +362,10 @@ static int mlxsw_m_init(struct mlxsw_core *mlxsw_core,
mlxsw_m->core = mlxsw_core;
mlxsw_m->bus_info = mlxsw_bus_info;
err = mlxsw_m_fw_rev_validate(mlxsw_m);
if (err)
return err;
err = mlxsw_m_base_mac_get(mlxsw_m);
if (err) {
dev_err(mlxsw_m->bus_info->dev, "Failed to get base mac\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment