]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mlxsw: core: Push minor/subminor fw version check into helper
authorVadim Pasternak <vadimp@mellanox.com>
Sun, 6 Oct 2019 06:34:51 +0000 (09:34 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 6 Oct 2019 16:31:39 +0000 (18:31 +0200)
Add new API for FW "minor" and "subminor" version validation for
sharing it between "spectrum" and "minimal" drivers.
Use it in "spectrum" driver.

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/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index 1c29522a2af3a7da7fe6e8cb7a6fd4edbcdc1657..2b59f84b14f956ab752c2a4c72171b83a0fe0877 100644 (file)
@@ -127,6 +127,16 @@ bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core)
 }
 EXPORT_SYMBOL(mlxsw_core_res_query_enabled);
 
+bool
+mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
+                                         const struct mlxsw_fw_rev *req_rev)
+{
+       return rev->minor > req_rev->minor ||
+              (rev->minor == req_rev->minor &&
+               rev->subminor >= req_rev->subminor);
+}
+EXPORT_SYMBOL(mlxsw_core_fw_rev_minor_subminor_validate);
+
 struct mlxsw_rx_listener_item {
        struct list_head list;
        struct mlxsw_rx_listener rxl;
index 3377a1b39b03d3c5da85c9670efdbfadb0c3c86f..f25037074e2d46b82da2f0944c07d2cd220e09d7 100644 (file)
@@ -24,6 +24,7 @@ struct mlxsw_core_port;
 struct mlxsw_driver;
 struct mlxsw_bus;
 struct mlxsw_bus_info;
+struct mlxsw_fw_rev;
 
 unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
 
@@ -31,6 +32,10 @@ void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
 
 bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);
 
+bool
+mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
+                                         const struct mlxsw_fw_rev *req_rev);
+
 int mlxsw_core_driver_register(struct mlxsw_driver *mlxsw_driver);
 void mlxsw_core_driver_unregister(struct mlxsw_driver *mlxsw_driver);
 
index c91b8238c8c50721511cb52c698e800063c615d5..3c5154e559b2122595b3a6d9c3dd05d58622d269 100644 (file)
@@ -409,9 +409,7 @@ static int mlxsw_sp_fw_rev_validate(struct mlxsw_sp *mlxsw_sp)
        }
        if (MLXSW_SP_FWREV_MINOR_TO_BRANCH(rev->minor) ==
            MLXSW_SP_FWREV_MINOR_TO_BRANCH(req_rev->minor) &&
-           (rev->minor > req_rev->minor ||
-            (rev->minor == req_rev->minor &&
-             rev->subminor >= req_rev->subminor)))
+           mlxsw_core_fw_rev_minor_subminor_validate(rev, req_rev))
                return 0;
 
        dev_info(mlxsw_sp->bus_info->dev, "The firmware version %d.%d.%d is incompatible with the driver\n",