History

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.

Saeed Mahameed committed 7 years ago

Commit f23519e1 parent 605bef02 files · +68 −13Browse files

Unified · Split

2 files
  1. drivers/net/ethernet/mellanox/mlx5/core/cmd.c +66 −13
  2. include/linux/mlx5/driver.h +2 −0
drivers/net/ethernet/mellanox/mlx5/core/cmd.c+66−13
@@ -789,7 +789,7 @@ static void cmd_status_print(struct mlx5_core_dev *dev, void *in, void *out) · 788 unmodified lines
789789 cmd_status_str(status), status, syndrome, err);
790790 }
791791
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)
793793 {
794794 /* aborted due to PCI error or via reset flow mlx5_cmd_trigger_completions() */
795795 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
806806 }
807807
808808 /* driver or FW delivery error */
809− if (err)
809+ if (err != -EREMOTEIO && err)
810810 return err;
811811
812812 /* 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
816816
817817 return err;
818818 }
819+EXPORT_SYMBOL(mlx5_cmd_check);
819820
820821 static void dump_command(struct mlx5_core_dev *dev,
821822 struct mlx5_cmd_work_ent *ent, int input)
@@ -1869,6 +1870,38 @@ out_in: · 1047 unmodified lines
18691870 return err;
18701871 }
18711872
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+
18721905 /**
18731906 * mlx5_cmd_exec - Executes a fw command, wait for completion
18741907 *
@@ -1878,18 +1911,47 @@ out_in: · 3 unmodified lines
18781911 * @out: outbox mlx5_ifc buffer
18791912 * @out_size: outbox size
18801913 *
1881− * @return: 0 if no error, FW command execution was successful,
1914+ * @return: 0 if no error, FW command execution was successful
18821915 * and outbox status is ok.
18831916 */
18841917 int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
18851918 int out_size)
18861919 {
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);
18881921
18891922 return mlx5_cmd_check(dev, err, in, out);
18901923 }
18911924 EXPORT_SYMBOL(mlx5_cmd_exec);
18921925
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+
18931955 void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev,
18941956 struct mlx5_async_ctx *ctx)
18951957 {
@@ -1944,15 +2006,6 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size, · 48 unmodified lines
19442006 }
19452007 EXPORT_SYMBOL(mlx5_cmd_exec_cb);
19462008
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−
19562009 static void destroy_msg_cache(struct mlx5_core_dev *dev)
19572010 {
19582011 struct cmd_msg_cache *ch;
include/linux/mlx5/driver.h+2−0
@@ -964,6 +964,8 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size, · 963 unmodified lines
964964 void *out, int out_size, mlx5_async_cbk_t callback,
965965 struct mlx5_async_work *work);
966966
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);
967969 int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
968970 int out_size);
969971

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t