net/mlx5: Update eswitch to new cmd interface

Do mass update of eswitch to reuse newly introduced
mlx5_cmd_exec_in*() interfaces.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:
Leon Romanovsky 2020-04-09 12:30:08 +03:00
parent a184cda1bb
commit e08a6832f9
3 changed files with 20 additions and 42 deletions

View File

@ -84,8 +84,7 @@ mlx5_eswitch_get_vport(struct mlx5_eswitch *esw, u16 vport_num)
static int arm_vport_context_events_cmd(struct mlx5_core_dev *dev, u16 vport, static int arm_vport_context_events_cmd(struct mlx5_core_dev *dev, u16 vport,
u32 events_mask) u32 events_mask)
{ {
int in[MLX5_ST_SZ_DW(modify_nic_vport_context_in)] = {0}; u32 in[MLX5_ST_SZ_DW(modify_nic_vport_context_in)] = {};
int out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)] = {0};
void *nic_vport_ctx; void *nic_vport_ctx;
MLX5_SET(modify_nic_vport_context_in, in, MLX5_SET(modify_nic_vport_context_in, in,
@ -108,40 +107,24 @@ static int arm_vport_context_events_cmd(struct mlx5_core_dev *dev, u16 vport,
MLX5_SET(nic_vport_context, nic_vport_ctx, MLX5_SET(nic_vport_context, nic_vport_ctx,
event_on_promisc_change, 1); event_on_promisc_change, 1);
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); return mlx5_cmd_exec_in(dev, modify_nic_vport_context, in);
} }
/* E-Switch vport context HW commands */ /* E-Switch vport context HW commands */
int mlx5_eswitch_modify_esw_vport_context(struct mlx5_core_dev *dev, u16 vport, int mlx5_eswitch_modify_esw_vport_context(struct mlx5_core_dev *dev, u16 vport,
bool other_vport, bool other_vport, void *in)
void *in, int inlen)
{ {
u32 out[MLX5_ST_SZ_DW(modify_esw_vport_context_out)] = {0};
MLX5_SET(modify_esw_vport_context_in, in, opcode, MLX5_SET(modify_esw_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT); MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT);
MLX5_SET(modify_esw_vport_context_in, in, vport_number, vport); MLX5_SET(modify_esw_vport_context_in, in, vport_number, vport);
MLX5_SET(modify_esw_vport_context_in, in, other_vport, other_vport); MLX5_SET(modify_esw_vport_context_in, in, other_vport, other_vport);
return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); return mlx5_cmd_exec_in(dev, modify_esw_vport_context, in);
}
int mlx5_eswitch_query_esw_vport_context(struct mlx5_core_dev *dev, u16 vport,
bool other_vport,
void *out, int outlen)
{
u32 in[MLX5_ST_SZ_DW(query_esw_vport_context_in)] = {};
MLX5_SET(query_esw_vport_context_in, in, opcode,
MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT);
MLX5_SET(modify_esw_vport_context_in, in, vport_number, vport);
MLX5_SET(modify_esw_vport_context_in, in, other_vport, other_vport);
return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
} }
static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u16 vport, static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u16 vport,
u16 vlan, u8 qos, u8 set_flags) u16 vlan, u8 qos, u8 set_flags)
{ {
u32 in[MLX5_ST_SZ_DW(modify_esw_vport_context_in)] = {0}; u32 in[MLX5_ST_SZ_DW(modify_esw_vport_context_in)] = {};
if (!MLX5_CAP_ESW(dev, vport_cvlan_strip) || if (!MLX5_CAP_ESW(dev, vport_cvlan_strip) ||
!MLX5_CAP_ESW(dev, vport_cvlan_insert_if_not_exist)) !MLX5_CAP_ESW(dev, vport_cvlan_insert_if_not_exist))
@ -170,8 +153,7 @@ static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u16 vport,
MLX5_SET(modify_esw_vport_context_in, in, MLX5_SET(modify_esw_vport_context_in, in,
field_select.vport_cvlan_insert, 1); field_select.vport_cvlan_insert, 1);
return mlx5_eswitch_modify_esw_vport_context(dev, vport, true, return mlx5_eswitch_modify_esw_vport_context(dev, vport, true, in);
in, sizeof(in));
} }
/* E-Switch FDB */ /* E-Switch FDB */
@ -1901,7 +1883,7 @@ const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)
MLX5_SET(query_esw_functions_in, in, opcode, MLX5_SET(query_esw_functions_in, in, opcode,
MLX5_CMD_OP_QUERY_ESW_FUNCTIONS); MLX5_CMD_OP_QUERY_ESW_FUNCTIONS);
err = mlx5_cmd_exec(dev, in, sizeof(in), out, outlen); err = mlx5_cmd_exec_inout(dev, query_esw_functions, in, out);
if (!err) if (!err)
return out; return out;
@ -2783,8 +2765,8 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
{ {
struct mlx5_vport *vport = mlx5_eswitch_get_vport(esw, vport_num); struct mlx5_vport *vport = mlx5_eswitch_get_vport(esw, vport_num);
int outlen = MLX5_ST_SZ_BYTES(query_vport_counter_out); int outlen = MLX5_ST_SZ_BYTES(query_vport_counter_out);
u32 in[MLX5_ST_SZ_DW(query_vport_counter_in)] = {0}; u32 in[MLX5_ST_SZ_DW(query_vport_counter_in)] = {};
struct mlx5_vport_drop_stats stats = {0}; struct mlx5_vport_drop_stats stats = {};
int err = 0; int err = 0;
u32 *out; u32 *out;
@ -2801,7 +2783,7 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
MLX5_SET(query_vport_counter_in, in, vport_number, vport->vport); MLX5_SET(query_vport_counter_in, in, vport_number, vport->vport);
MLX5_SET(query_vport_counter_in, in, other_vport, 1); MLX5_SET(query_vport_counter_in, in, other_vport, 1);
err = mlx5_cmd_exec(esw->dev, in, sizeof(in), out, outlen); err = mlx5_cmd_exec_inout(esw->dev, query_vport_counter, in, out);
if (err) if (err)
goto free_out; goto free_out;

View File

@ -329,11 +329,7 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
void mlx5_eswitch_del_send_to_vport_rule(struct mlx5_flow_handle *rule); void mlx5_eswitch_del_send_to_vport_rule(struct mlx5_flow_handle *rule);
int mlx5_eswitch_modify_esw_vport_context(struct mlx5_core_dev *dev, u16 vport, int mlx5_eswitch_modify_esw_vport_context(struct mlx5_core_dev *dev, u16 vport,
bool other_vport, bool other_vport, void *in);
void *in, int inlen);
int mlx5_eswitch_query_esw_vport_context(struct mlx5_core_dev *dev, u16 vport,
bool other_vport,
void *out, int outlen);
struct mlx5_flow_spec; struct mlx5_flow_spec;
struct mlx5_esw_flow_attr; struct mlx5_esw_flow_attr;

View File

@ -790,7 +790,8 @@ static bool mlx5_eswitch_reg_c1_loopback_supported(struct mlx5_eswitch *esw)
static int esw_set_passing_vport_metadata(struct mlx5_eswitch *esw, bool enable) static int esw_set_passing_vport_metadata(struct mlx5_eswitch *esw, bool enable)
{ {
u32 out[MLX5_ST_SZ_DW(query_esw_vport_context_out)] = {}; u32 out[MLX5_ST_SZ_DW(query_esw_vport_context_out)] = {};
u32 in[MLX5_ST_SZ_DW(modify_esw_vport_context_in)] = {}; u32 min[MLX5_ST_SZ_DW(modify_esw_vport_context_in)] = {};
u32 in[MLX5_ST_SZ_DW(query_esw_vport_context_in)] = {};
u8 curr, wanted; u8 curr, wanted;
int err; int err;
@ -798,8 +799,9 @@ static int esw_set_passing_vport_metadata(struct mlx5_eswitch *esw, bool enable)
!mlx5_eswitch_vport_match_metadata_enabled(esw)) !mlx5_eswitch_vport_match_metadata_enabled(esw))
return 0; return 0;
err = mlx5_eswitch_query_esw_vport_context(esw->dev, 0, false, MLX5_SET(query_esw_vport_context_in, in, opcode,
out, sizeof(out)); MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT);
err = mlx5_cmd_exec_inout(esw->dev, query_esw_vport_context, in, out);
if (err) if (err)
return err; return err;
@ -814,14 +816,12 @@ static int esw_set_passing_vport_metadata(struct mlx5_eswitch *esw, bool enable)
else else
curr &= ~wanted; curr &= ~wanted;
MLX5_SET(modify_esw_vport_context_in, in, MLX5_SET(modify_esw_vport_context_in, min,
esw_vport_context.fdb_to_vport_reg_c_id, curr); esw_vport_context.fdb_to_vport_reg_c_id, curr);
MLX5_SET(modify_esw_vport_context_in, min,
MLX5_SET(modify_esw_vport_context_in, in,
field_select.fdb_to_vport_reg_c_id, 1); field_select.fdb_to_vport_reg_c_id, 1);
err = mlx5_eswitch_modify_esw_vport_context(esw->dev, 0, false, in, err = mlx5_eswitch_modify_esw_vport_context(esw->dev, 0, false, min);
sizeof(in));
if (!err) { if (!err) {
if (enable && (curr & MLX5_FDB_TO_VPORT_REG_C_1)) if (enable && (curr & MLX5_FDB_TO_VPORT_REG_C_1))
esw->flags |= MLX5_ESWITCH_REG_C1_LOOPBACK_ENABLED; esw->flags |= MLX5_ESWITCH_REG_C1_LOOPBACK_ENABLED;
@ -1474,7 +1474,7 @@ static int mlx5_eswitch_inline_mode_get(const struct mlx5_eswitch *esw, u8 *mode
out: out:
*mode = mlx5_mode; *mode = mlx5_mode;
return 0; return 0;
} }
static void esw_destroy_restore_table(struct mlx5_eswitch *esw) static void esw_destroy_restore_table(struct mlx5_eswitch *esw)
{ {