net/mlx5: Set driver version into firmware
authorHuy Nguyen <huyn@mellanox.com>
Thu, 17 Nov 2016 11:46:00 +0000 (13:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Nov 2016 17:08:57 +0000 (12:08 -0500)
If driver_version capability bit is enabled, set driver version
to firmware after the init HCA command, for display purposes.

Example of driver version: "Linux,mlx5_core,3.0-1"

Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/main.c

index c07493307a83d4870a4aa2c716750f8fb211953b..f28df33e2ef7681c7c318871efa3adb4c3df6ccf 100644 (file)
@@ -175,6 +175,41 @@ static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili)
        return err;
 }
 
+static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
+{
+       int driver_ver_sz = MLX5_FLD_SZ_BYTES(set_driver_version_in,
+                                             driver_version);
+       u8 in[MLX5_ST_SZ_BYTES(set_driver_version_in)] = {0};
+       u8 out[MLX5_ST_SZ_BYTES(set_driver_version_out)] = {0};
+       int remaining_size = driver_ver_sz;
+       char *string;
+
+       if (!MLX5_CAP_GEN(dev, driver_version))
+               return;
+
+       string = MLX5_ADDR_OF(set_driver_version_in, in, driver_version);
+
+       strncpy(string, "Linux", remaining_size);
+
+       remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
+       strncat(string, ",", remaining_size);
+
+       remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
+       strncat(string, DRIVER_NAME, remaining_size);
+
+       remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
+       strncat(string, ",", remaining_size);
+
+       remaining_size = max_t(int, 0, driver_ver_sz - strlen(string));
+       strncat(string, DRIVER_VERSION, remaining_size);
+
+       /*Send the command*/
+       MLX5_SET(set_driver_version_in, in, opcode,
+                MLX5_CMD_OP_SET_DRIVER_VERSION);
+
+       mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
+}
+
 static int set_dma_caps(struct pci_dev *pdev)
 {
        int err;
@@ -1015,6 +1050,8 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
                goto err_pagealloc_stop;
        }
 
+       mlx5_set_driver_version(dev);
+
        mlx5_start_health_poll(dev);
 
        err = mlx5_query_hca_caps(dev);