Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5: cmdif, Add new api for command execution

Add mlx5_cmd_do. Unlike mlx5_cmd_exec, this function will not modify
or translate outbox.status.

The function will return:

return = 0: Command was executed, outbox.status == MLX5_CMD_STAT_OK.

return = -EREMOTEIO: Executed, outbox.status != MLX5_CMD_STAT_OK.

return < 0: Command execution couldn't be performed by FW or driver.

And document other mlx5_cmd_exec functions.

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>

authored by

Saeed Mahameed and committed by
Saeed Mahameed
f23519e5 605bef00

+68 -13
+66 -13
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
··· 789 789 cmd_status_str(status), status, syndrome, err); 790 790 } 791 791 792 - static int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *out) 792 + int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *out) 793 793 { 794 794 /* aborted due to PCI error or via reset flow mlx5_cmd_trigger_completions() */ 795 795 if (err == -ENXIO) { ··· 806 806 } 807 807 808 808 /* driver or FW delivery error */ 809 - if (err) 809 + if (err != -EREMOTEIO && err) 810 810 return err; 811 811 812 812 /* check outbox status */ ··· 816 816 817 817 return err; 818 818 } 819 + EXPORT_SYMBOL(mlx5_cmd_check); 819 820 820 821 static void dump_command(struct mlx5_core_dev *dev, 821 822 struct mlx5_cmd_work_ent *ent, int input) ··· 1871 1870 } 1872 1871 1873 1872 /** 1873 + * mlx5_cmd_do - Executes a fw command, wait for completion. 1874 + * Unlike mlx5_cmd_exec, this function will not translate or intercept 1875 + * outbox.status and will return -EREMOTEIO when 1876 + * outbox.status != MLX5_CMD_STAT_OK 1877 + * 1878 + * @dev: mlx5 core device 1879 + * @in: inbox mlx5_ifc command buffer 1880 + * @in_size: inbox buffer size 1881 + * @out: outbox mlx5_ifc buffer 1882 + * @out_size: outbox size 1883 + * 1884 + * @return: 1885 + * -EREMOTEIO : Command executed by FW, outbox.status != MLX5_CMD_STAT_OK. 1886 + * Caller must check FW outbox status. 1887 + * 0 : Command execution successful, outbox.status == MLX5_CMD_STAT_OK. 1888 + * < 0 : Command execution couldn't be performed by firmware or driver 1889 + */ 1890 + int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size) 1891 + { 1892 + int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, false); 1893 + 1894 + if (err) /* -EREMOTEIO is preserved */ 1895 + return err == -EREMOTEIO ? -EIO : err; 1896 + 1897 + if (MLX5_GET(mbox_out, out, status) != MLX5_CMD_STAT_OK) 1898 + return -EREMOTEIO; 1899 + 1900 + return 0; 1901 + } 1902 + EXPORT_SYMBOL(mlx5_cmd_do); 1903 + 1904 + /** 1874 1905 * mlx5_cmd_exec - Executes a fw command, wait for completion 1875 1906 * 1876 1907 * @dev: mlx5 core device ··· 1911 1878 * @out: outbox mlx5_ifc buffer 1912 1879 * @out_size: outbox size 1913 1880 * 1914 - * @return: 0 if no error, FW command execution was successful, 1881 + * @return: 0 if no error, FW command execution was successful 1915 1882 * and outbox status is ok. 1916 1883 */ 1917 1884 int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, 1918 1885 int out_size) 1919 1886 { 1920 - int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, false); 1887 + int err = mlx5_cmd_do(dev, in, in_size, out, out_size); 1921 1888 1922 1889 return mlx5_cmd_check(dev, err, in, out); 1923 1890 } 1924 1891 EXPORT_SYMBOL(mlx5_cmd_exec); 1892 + 1893 + /** 1894 + * mlx5_cmd_exec_polling - Executes a fw command, poll for completion 1895 + * Needed for driver force teardown, when command completion EQ 1896 + * will not be available to complete the command 1897 + * 1898 + * @dev: mlx5 core device 1899 + * @in: inbox mlx5_ifc command buffer 1900 + * @in_size: inbox buffer size 1901 + * @out: outbox mlx5_ifc buffer 1902 + * @out_size: outbox size 1903 + * 1904 + * @return: 0 if no error, FW command execution was successful 1905 + * and outbox status is ok. 1906 + */ 1907 + int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size, 1908 + void *out, int out_size) 1909 + { 1910 + int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, true); 1911 + 1912 + if (err) /* -EREMOTEIO is preserved */ 1913 + return err == -EREMOTEIO ? -EIO : err; 1914 + 1915 + if (MLX5_GET(mbox_out, out, status) != MLX5_CMD_STAT_OK) 1916 + err = -EREMOTEIO; 1917 + 1918 + return mlx5_cmd_check(dev, err, in, out); 1919 + } 1920 + EXPORT_SYMBOL(mlx5_cmd_exec_polling); 1925 1921 1926 1922 void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev, 1927 1923 struct mlx5_async_ctx *ctx) ··· 2005 1943 return ret; 2006 1944 } 2007 1945 EXPORT_SYMBOL(mlx5_cmd_exec_cb); 2008 - 2009 - int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size, 2010 - void *out, int out_size) 2011 - { 2012 - int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, true); 2013 - 2014 - return mlx5_cmd_check(dev, err, in, out); 2015 - } 2016 - EXPORT_SYMBOL(mlx5_cmd_exec_polling); 2017 1946 2018 1947 static void destroy_msg_cache(struct mlx5_core_dev *dev) 2019 1948 {
+2
include/linux/mlx5/driver.h
··· 964 964 void *out, int out_size, mlx5_async_cbk_t callback, 965 965 struct mlx5_async_work *work); 966 966 967 + int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size); 968 + int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *out); 967 969 int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, 968 970 int out_size); 969 971