History

net/mlx5: E-Switch, Properly refer to host PF vport as other vport

Commands referring to vports use the following scheme: 1. When referring to my own vport, put 0 in vport and 0 in other_vport. 2. When referring to another vport, put the vport number of the referred vport and put 1 in other_vport. It was assumed that driver is accessing other vport when vport number is greater than 0. With the above scheme, the case that ECPF eswitch manager is trying to access host PF vport will fall over with scheme 1 as the vport number is 0. This is apparently wrong as driver is trying to refer other vport. As such usage can only happen in the eswitch context, change relevant functions to provide other vport input properly.

Bodong Wang committed 7 years ago

Commit cbc44e71 parent a1b38394 files · +16 −17Browse files

Unified · Split

4 files
  1. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +4 −2
  2. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +6 −7
  3. drivers/net/ethernet/mellanox/mlx5/core/vport.c +4 −6
  4. include/linux/mlx5/vport.h +2 −2
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+4−2
@@ -1083,7 +1083,8 @@ static int mlx5e_vf_rep_open(struct net_device *dev) · 1082 unmodified lines
1083 1083
1084 if (!mlx5_modify_vport_admin_state(priv->mdev,1084 if (!mlx5_modify_vport_admin_state(priv->mdev,
1085 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,1085 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1086 rep->vport, MLX5_VPORT_ADMIN_STATE_UP))1086 rep->vport, 1,
1087 MLX5_VPORT_ADMIN_STATE_UP))
1087 netif_carrier_on(dev);1088 netif_carrier_on(dev);
1088 1089
1089unlock:1090unlock:
@@ -1101,7 +1102,8 @@ static int mlx5e_vf_rep_close(struct net_device *dev) · 11 unmodified lines
1101 mutex_lock(&priv->state_lock);1102 mutex_lock(&priv->state_lock);
1102 mlx5_modify_vport_admin_state(priv->mdev,1103 mlx5_modify_vport_admin_state(priv->mdev,
1103 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,1104 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1104 rep->vport, MLX5_VPORT_ADMIN_STATE_DOWN);1105 rep->vport, 1,
1106 MLX5_VPORT_ADMIN_STATE_DOWN);
1105 ret = mlx5e_close_locked(dev);1107 ret = mlx5e_close_locked(dev);
1106 mutex_unlock(&priv->state_lock);1108 mutex_unlock(&priv->state_lock);
1107 return ret;1109 return ret;
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+6−7
@@ -1462,7 +1462,7 @@ static void esw_apply_vport_conf(struct mlx5_eswitch *esw, · 1461 unmodified lines
1462 1462
1463 mlx5_modify_vport_admin_state(esw->dev,1463 mlx5_modify_vport_admin_state(esw->dev,
1464 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,1464 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1465 vport_num,1465 vport_num, 1,
1466 vport->info.link_state);1466 vport->info.link_state);
1467 1467
1468 /* Host PF has its own mac/guid. */1468 /* Host PF has its own mac/guid. */
@@ -1581,10 +1581,10 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num) · 112 unmodified lines
1581 esw_vport_change_handle_locked(vport);1581 esw_vport_change_handle_locked(vport);
1582 vport->enabled_events = 0;1582 vport->enabled_events = 0;
1583 esw_vport_disable_qos(esw, vport_num);1583 esw_vport_disable_qos(esw, vport_num);
1584 if (vport_num && esw->mode == SRIOV_LEGACY) {1584 if (esw->mode == SRIOV_LEGACY) {
1585 mlx5_modify_vport_admin_state(esw->dev,1585 mlx5_modify_vport_admin_state(esw->dev,
1586 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,1586 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1587 vport_num,1587 vport_num, 1,
1588 MLX5_VPORT_ADMIN_STATE_DOWN);1588 MLX5_VPORT_ADMIN_STATE_DOWN);
1589 esw_vport_disable_egress_acl(esw, vport);1589 esw_vport_disable_egress_acl(esw, vport);
1590 esw_vport_disable_ingress_acl(esw, vport);1590 esw_vport_disable_ingress_acl(esw, vport);
@@ -1875,7 +1875,7 @@ int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw, · 284 unmodified lines
1875 1875
1876 err = mlx5_modify_vport_admin_state(esw->dev,1876 err = mlx5_modify_vport_admin_state(esw->dev,
1877 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,1877 MLX5_VPORT_STATE_OP_MOD_ESW_VPORT,
1878 vport, link_state);1878 vport, 1, link_state);
1879 if (err) {1879 if (err) {
1880 mlx5_core_warn(esw->dev,1880 mlx5_core_warn(esw->dev,
1881 "Failed to set vport %d link state, err = %d",1881 "Failed to set vport %d link state, err = %d",
@@ -2137,7 +2137,7 @@ static int mlx5_eswitch_query_vport_drop_stats(struct mlx5_core_dev *dev, · 255 unmodified lines
2137 !MLX5_CAP_GEN(dev, transmit_discard_vport_down))2137 !MLX5_CAP_GEN(dev, transmit_discard_vport_down))
2138 return 0;2138 return 0;
2139 2139
2140 err = mlx5_query_vport_down_stats(dev, vport_idx,2140 err = mlx5_query_vport_down_stats(dev, vport_idx, 1,
2141 &rx_discard_vport_down,2141 &rx_discard_vport_down,
2142 &tx_discard_vport_down);2142 &tx_discard_vport_down);
2143 if (err)2143 if (err)
@@ -2174,8 +2174,7 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw, · 30 unmodified lines
2174 MLX5_CMD_OP_QUERY_VPORT_COUNTER);2174 MLX5_CMD_OP_QUERY_VPORT_COUNTER);
2175 MLX5_SET(query_vport_counter_in, in, op_mod, 0);2175 MLX5_SET(query_vport_counter_in, in, op_mod, 0);
2176 MLX5_SET(query_vport_counter_in, in, vport_number, vport);2176 MLX5_SET(query_vport_counter_in, in, vport_number, vport);
2177 if (vport)2177 MLX5_SET(query_vport_counter_in, in, other_vport, 1);
2178 MLX5_SET(query_vport_counter_in, in, other_vport, 1);
2179 2178
2180 memset(out, 0, outlen);2179 memset(out, 0, outlen);
2181 err = mlx5_cmd_exec(esw->dev, in, sizeof(in), out, outlen);2180 err = mlx5_cmd_exec(esw->dev, in, sizeof(in), out, outlen);
drivers/net/ethernet/mellanox/mlx5/core/vport.c+4−6
@@ -64,7 +64,7 @@ u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport) · 63 unmodified lines
64}64}
65 65
66int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,66int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
67 u16 vport, u8 state)67 u16 vport, u8 other_vport, u8 state)
68{68{
69 u32 in[MLX5_ST_SZ_DW(modify_vport_state_in)] = {0};69 u32 in[MLX5_ST_SZ_DW(modify_vport_state_in)] = {0};
70 u32 out[MLX5_ST_SZ_DW(modify_vport_state_out)] = {0};70 u32 out[MLX5_ST_SZ_DW(modify_vport_state_out)] = {0};
@@ -73,8 +73,7 @@ int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, · 2 unmodified lines
73 MLX5_CMD_OP_MODIFY_VPORT_STATE);73 MLX5_CMD_OP_MODIFY_VPORT_STATE);
74 MLX5_SET(modify_vport_state_in, in, op_mod, opmod);74 MLX5_SET(modify_vport_state_in, in, op_mod, opmod);
75 MLX5_SET(modify_vport_state_in, in, vport_number, vport);75 MLX5_SET(modify_vport_state_in, in, vport_number, vport);
76 if (vport)76 MLX5_SET(modify_vport_state_in, in, other_vport, other_vport);
77 MLX5_SET(modify_vport_state_in, in, other_vport, 1);
78 MLX5_SET(modify_vport_state_in, in, admin_state, state);77 MLX5_SET(modify_vport_state_in, in, admin_state, state);
79 78
80 return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));79 return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
@@ -1057,7 +1056,7 @@ free: · 976 unmodified lines
1057EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter);1056EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter);
1058 1057
1059int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport,1058int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport,
1060 u64 *rx_discard_vport_down,1059 u8 other_vport, u64 *rx_discard_vport_down,
1061 u64 *tx_discard_vport_down)1060 u64 *tx_discard_vport_down)
1062{1061{
1063 u32 out[MLX5_ST_SZ_DW(query_vnic_env_out)] = {0};1062 u32 out[MLX5_ST_SZ_DW(query_vnic_env_out)] = {0};
@@ -1068,8 +1067,7 @@ int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport, · 4 unmodified lines
1068 MLX5_CMD_OP_QUERY_VNIC_ENV);1067 MLX5_CMD_OP_QUERY_VNIC_ENV);
1069 MLX5_SET(query_vnic_env_in, in, op_mod, 0);1068 MLX5_SET(query_vnic_env_in, in, op_mod, 0);
1070 MLX5_SET(query_vnic_env_in, in, vport_number, vport);1069 MLX5_SET(query_vnic_env_in, in, vport_number, vport);
1071 if (vport)1070 MLX5_SET(query_vnic_env_in, in, other_vport, other_vport);
1072 MLX5_SET(query_vnic_env_in, in, other_vport, 1);
1073 1071
1074 err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));1072 err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
1075 if (err)1073 if (err)
include/linux/mlx5/vport.h+2−2
@@ -59,7 +59,7 @@ enum { · 58 unmodified lines
59 59
60u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport);60u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport);
61int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,61int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
62 u16 vport, u8 state);62 u16 vport, u8 other_vport, u8 state);
63int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,63int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
64 u16 vport, u8 *addr);64 u16 vport, u8 *addr);
65int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,65int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
@@ -121,7 +121,7 @@ int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev, · 55 unmodified lines
121int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);121int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);
122int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev);122int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev);
123int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport,123int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport,
124 u64 *rx_discard_vport_down,124 u8 other_vport, u64 *rx_discard_vport_down,
125 u64 *tx_discard_vport_down);125 u64 *tx_discard_vport_down);
126int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,126int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
127 int vf, u8 port_num, void *out,127 int vf, u8 port_num, void *out,

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