|
39 | 39 | #include <linux/errno.h> |
40 | 40 |
|
41 | 41 | #include <linux/mlx4/cmd.h> |
| 42 | +#include <linux/mlx4/device.h> |
42 | 43 | #include <linux/semaphore.h> |
43 | 44 | #include <rdma/ib_smi.h> |
44 | 45 |
|
@@ -2178,7 +2179,54 @@ int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_in |
2178 | 2179 | ivf->qos = s_info->default_qos; |
2179 | 2180 | ivf->tx_rate = s_info->tx_rate; |
2180 | 2181 | ivf->spoofchk = s_info->spoofchk; |
| 2182 | + ivf->linkstate = s_info->link_state; |
2181 | 2183 |
|
2182 | 2184 | return 0; |
2183 | 2185 | } |
2184 | 2186 | EXPORT_SYMBOL_GPL(mlx4_get_vf_config); |
| 2187 | + |
| 2188 | +int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int link_state) |
| 2189 | +{ |
| 2190 | + struct mlx4_priv *priv = mlx4_priv(dev); |
| 2191 | + struct mlx4_vport_state *s_info; |
| 2192 | + struct mlx4_vport_oper_state *vp_oper; |
| 2193 | + int slave; |
| 2194 | + u8 link_stat_event; |
| 2195 | + |
| 2196 | + slave = mlx4_get_slave_indx(dev, vf); |
| 2197 | + if (slave < 0) |
| 2198 | + return -EINVAL; |
| 2199 | + |
| 2200 | + switch (link_state) { |
| 2201 | + case IFLA_VF_LINK_STATE_AUTO: |
| 2202 | + /* get current link state */ |
| 2203 | + if (!priv->sense.do_sense_port[port]) |
| 2204 | + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_ACTIVE; |
| 2205 | + else |
| 2206 | + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_DOWN; |
| 2207 | + break; |
| 2208 | + |
| 2209 | + case IFLA_VF_LINK_STATE_ENABLE: |
| 2210 | + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_ACTIVE; |
| 2211 | + break; |
| 2212 | + |
| 2213 | + case IFLA_VF_LINK_STATE_DISABLE: |
| 2214 | + link_stat_event = MLX4_PORT_CHANGE_SUBTYPE_DOWN; |
| 2215 | + break; |
| 2216 | + |
| 2217 | + default: |
| 2218 | + mlx4_warn(dev, "unknown value for link_state %02x on slave %d port %d\n", |
| 2219 | + link_state, slave, port); |
| 2220 | + return -EINVAL; |
| 2221 | + }; |
| 2222 | + /* update the admin & oper state on the link state */ |
| 2223 | + s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; |
| 2224 | + vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; |
| 2225 | + s_info->link_state = link_state; |
| 2226 | + vp_oper->state.link_state = link_state; |
| 2227 | + |
| 2228 | + /* send event */ |
| 2229 | + mlx4_gen_port_state_change_eqe(dev, slave, port, link_stat_event); |
| 2230 | + return 0; |
| 2231 | +} |
| 2232 | +EXPORT_SYMBOL_GPL(mlx4_set_vf_link_state); |
0 commit comments