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.
Unified · Split
| @@ -789,7 +789,7 @@ static void cmd_status_print(struct mlx5_core_dev *dev, void *in, void *out) · 788 unmodified lines | |||
| 789 | cmd_status_str(status), status, syndrome, err); | 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 | /* aborted due to PCI error or via reset flow mlx5_cmd_trigger_completions() */ | 794 | /* aborted due to PCI error or via reset flow mlx5_cmd_trigger_completions() */ |
| 795 | if (err == -ENXIO) { | 795 | if (err == -ENXIO) { |
| @@ -806,7 +806,7 @@ static int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *ou · 10 unmodified lines | |||
| 806 | } | 806 | } |
| 807 | 807 | ||
| 808 | /* driver or FW delivery error */ | 808 | /* driver or FW delivery error */ |
| 809 | if (err) | 809 | if (err != -EREMOTEIO && err) |
| 810 | return err; | 810 | return err; |
| 811 | 811 | ||
| 812 | /* check outbox status */ | 812 | /* check outbox status */ |
| @@ -816,6 +816,7 @@ static int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *ou · 3 unmodified lines | |||
| 816 | 816 | ||
| 817 | return err; | 817 | return err; |
| 818 | } | 818 | } |
| 819 | EXPORT_SYMBOL(mlx5_cmd_check); | ||
| 819 | 820 | ||
| 820 | static void dump_command(struct mlx5_core_dev *dev, | 821 | static void dump_command(struct mlx5_core_dev *dev, |
| 821 | struct mlx5_cmd_work_ent *ent, int input) | 822 | struct mlx5_cmd_work_ent *ent, int input) |
| @@ -1869,6 +1870,38 @@ out_in: · 1047 unmodified lines | |||
| 1869 | return err; | 1870 | return err; |
| 1870 | } | 1871 | } |
| 1871 | 1872 | ||
| 1873 | /** | ||
| 1874 | * mlx5_cmd_do - Executes a fw command, wait for completion. | ||
| 1875 | * Unlike mlx5_cmd_exec, this function will not translate or intercept | ||
| 1876 | * outbox.status and will return -EREMOTEIO when | ||
| 1877 | * outbox.status != MLX5_CMD_STAT_OK | ||
| 1878 | * | ||
| 1879 | * @dev: mlx5 core device | ||
| 1880 | * @in: inbox mlx5_ifc command buffer | ||
| 1881 | * @in_size: inbox buffer size | ||
| 1882 | * @out: outbox mlx5_ifc buffer | ||
| 1883 | * @out_size: outbox size | ||
| 1884 | * | ||
| 1885 | * @return: | ||
| 1886 | * -EREMOTEIO : Command executed by FW, outbox.status != MLX5_CMD_STAT_OK. | ||
| 1887 | * Caller must check FW outbox status. | ||
| 1888 | * 0 : Command execution successful, outbox.status == MLX5_CMD_STAT_OK. | ||
| 1889 | * < 0 : Command execution couldn't be performed by firmware or driver | ||
| 1890 | */ | ||
| 1891 | int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int out_size) | ||
| 1892 | { | ||
| 1893 | int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, false); | ||
| 1894 | |||
| 1895 | if (err) /* -EREMOTEIO is preserved */ | ||
| 1896 | return err == -EREMOTEIO ? -EIO : err; | ||
| 1897 | |||
| 1898 | if (MLX5_GET(mbox_out, out, status) != MLX5_CMD_STAT_OK) | ||
| 1899 | return -EREMOTEIO; | ||
| 1900 | |||
| 1901 | return 0; | ||
| 1902 | } | ||
| 1903 | EXPORT_SYMBOL(mlx5_cmd_do); | ||
| 1904 | |||
| 1872 | /** | 1905 | /** |
| 1873 | * mlx5_cmd_exec - Executes a fw command, wait for completion | 1906 | * mlx5_cmd_exec - Executes a fw command, wait for completion |
| 1874 | * | 1907 | * |
| @@ -1878,18 +1911,47 @@ out_in: · 3 unmodified lines | |||
| 1878 | * @out: outbox mlx5_ifc buffer | 1911 | * @out: outbox mlx5_ifc buffer |
| 1879 | * @out_size: outbox size | 1912 | * @out_size: outbox size |
| 1880 | * | 1913 | * |
| 1881 | * @return: 0 if no error, FW command execution was successful, | 1914 | * @return: 0 if no error, FW command execution was successful |
| 1882 | * and outbox status is ok. | 1915 | * and outbox status is ok. |
| 1883 | */ | 1916 | */ |
| 1884 | int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, | 1917 | int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, |
| 1885 | int out_size) | 1918 | int out_size) |
| 1886 | { | 1919 | { |
| 1887 | int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, false); | 1920 | int err = mlx5_cmd_do(dev, in, in_size, out, out_size); |
| 1888 | 1921 | ||
| 1889 | return mlx5_cmd_check(dev, err, in, out); | 1922 | return mlx5_cmd_check(dev, err, in, out); |
| 1890 | } | 1923 | } |
| 1891 | EXPORT_SYMBOL(mlx5_cmd_exec); | 1924 | EXPORT_SYMBOL(mlx5_cmd_exec); |
| 1892 | 1925 | ||
| 1926 | /** | ||
| 1927 | * mlx5_cmd_exec_polling - Executes a fw command, poll for completion | ||
| 1928 | * Needed for driver force teardown, when command completion EQ | ||
| 1929 | * will not be available to complete the command | ||
| 1930 | * | ||
| 1931 | * @dev: mlx5 core device | ||
| 1932 | * @in: inbox mlx5_ifc command buffer | ||
| 1933 | * @in_size: inbox buffer size | ||
| 1934 | * @out: outbox mlx5_ifc buffer | ||
| 1935 | * @out_size: outbox size | ||
| 1936 | * | ||
| 1937 | * @return: 0 if no error, FW command execution was successful | ||
| 1938 | * and outbox status is ok. | ||
| 1939 | */ | ||
| 1940 | int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size, | ||
| 1941 | void *out, int out_size) | ||
| 1942 | { | ||
| 1943 | int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, true); | ||
| 1944 | |||
| 1945 | if (err) /* -EREMOTEIO is preserved */ | ||
| 1946 | return err == -EREMOTEIO ? -EIO : err; | ||
| 1947 | |||
| 1948 | if (MLX5_GET(mbox_out, out, status) != MLX5_CMD_STAT_OK) | ||
| 1949 | err = -EREMOTEIO; | ||
| 1950 | |||
| 1951 | return mlx5_cmd_check(dev, err, in, out); | ||
| 1952 | } | ||
| 1953 | EXPORT_SYMBOL(mlx5_cmd_exec_polling); | ||
| 1954 | |||
| 1893 | void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev, | 1955 | void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev, |
| 1894 | struct mlx5_async_ctx *ctx) | 1956 | struct mlx5_async_ctx *ctx) |
| 1895 | { | 1957 | { |
| @@ -1944,15 +2006,6 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size, · 48 unmodified lines | |||
| 1944 | } | 2006 | } |
| 1945 | EXPORT_SYMBOL(mlx5_cmd_exec_cb); | 2007 | EXPORT_SYMBOL(mlx5_cmd_exec_cb); |
| 1946 | 2008 | ||
| 1947 | int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size, | ||
| 1948 | void *out, int out_size) | ||
| 1949 | { | ||
| 1950 | int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, true); | ||
| 1951 | |||
| 1952 | return mlx5_cmd_check(dev, err, in, out); | ||
| 1953 | } | ||
| 1954 | EXPORT_SYMBOL(mlx5_cmd_exec_polling); | ||
| 1955 | |||
| 1956 | static void destroy_msg_cache(struct mlx5_core_dev *dev) | 2009 | static void destroy_msg_cache(struct mlx5_core_dev *dev) |
| 1957 | { | 2010 | { |
| 1958 | struct cmd_msg_cache *ch; | 2011 | struct cmd_msg_cache *ch; |
| @@ -964,6 +964,8 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size, · 963 unmodified lines | |||
| 964 | void *out, int out_size, mlx5_async_cbk_t callback, | 964 | void *out, int out_size, mlx5_async_cbk_t callback, |
| 965 | struct mlx5_async_work *work); | 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 | int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, | 969 | int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, |
| 968 | int out_size); | 970 | int out_size); |
| 969 | 971 | ||