Commit b37391e6 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlx4'

Or Gerlitz says:

====================
Here's a batch of mlx4 driver fixes for 3.9, mostly SRIOV/Flow-steering
related. Series done against the net tree as of commit 5a3da1fe
"inet: limit length of fragment queue hash table bucket lists
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ce16294f 2c473ae7
...@@ -1637,6 +1637,17 @@ void mlx4_en_stop_port(struct net_device *dev, int detach) ...@@ -1637,6 +1637,17 @@ void mlx4_en_stop_port(struct net_device *dev, int detach)
/* Flush multicast filter */ /* Flush multicast filter */
mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 1, MLX4_MCAST_CONFIG); mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 1, MLX4_MCAST_CONFIG);
/* Remove flow steering rules for the port*/
if (mdev->dev->caps.steering_mode ==
MLX4_STEERING_MODE_DEVICE_MANAGED) {
ASSERT_RTNL();
list_for_each_entry_safe(flow, tmp_flow,
&priv->ethtool_list, list) {
mlx4_flow_detach(mdev->dev, flow->id);
list_del(&flow->list);
}
}
mlx4_en_destroy_drop_qp(priv); mlx4_en_destroy_drop_qp(priv);
/* Free TX Rings */ /* Free TX Rings */
...@@ -1657,17 +1668,6 @@ void mlx4_en_stop_port(struct net_device *dev, int detach) ...@@ -1657,17 +1668,6 @@ void mlx4_en_stop_port(struct net_device *dev, int detach)
if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAGS2_REASSIGN_MAC_EN)) if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAGS2_REASSIGN_MAC_EN))
mdev->mac_removed[priv->port] = 1; mdev->mac_removed[priv->port] = 1;
/* Remove flow steering rules for the port*/
if (mdev->dev->caps.steering_mode ==
MLX4_STEERING_MODE_DEVICE_MANAGED) {
ASSERT_RTNL();
list_for_each_entry_safe(flow, tmp_flow,
&priv->ethtool_list, list) {
mlx4_flow_detach(mdev->dev, flow->id);
list_del(&flow->list);
}
}
/* Free RX Rings */ /* Free RX Rings */
for (i = 0; i < priv->rx_ring_num; i++) { for (i = 0; i < priv->rx_ring_num; i++) {
mlx4_en_deactivate_rx_ring(priv, &priv->rx_ring[i]); mlx4_en_deactivate_rx_ring(priv, &priv->rx_ring[i]);
......
...@@ -771,7 +771,7 @@ int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave, ...@@ -771,7 +771,7 @@ int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
struct mlx4_slave_event_eq_info *event_eq = struct mlx4_slave_event_eq_info *event_eq =
priv->mfunc.master.slave_state[slave].event_eq; priv->mfunc.master.slave_state[slave].event_eq;
u32 in_modifier = vhcr->in_modifier; u32 in_modifier = vhcr->in_modifier;
u32 eqn = in_modifier & 0x1FF; u32 eqn = in_modifier & 0x3FF;
u64 in_param = vhcr->in_param; u64 in_param = vhcr->in_param;
int err = 0; int err = 0;
int i; int i;
......
...@@ -99,6 +99,7 @@ struct res_qp { ...@@ -99,6 +99,7 @@ struct res_qp {
struct list_head mcg_list; struct list_head mcg_list;
spinlock_t mcg_spl; spinlock_t mcg_spl;
int local_qpn; int local_qpn;
atomic_t ref_count;
}; };
enum res_mtt_states { enum res_mtt_states {
...@@ -197,6 +198,7 @@ enum res_fs_rule_states { ...@@ -197,6 +198,7 @@ enum res_fs_rule_states {
struct res_fs_rule { struct res_fs_rule {
struct res_common com; struct res_common com;
int qpn;
}; };
static void *res_tracker_lookup(struct rb_root *root, u64 res_id) static void *res_tracker_lookup(struct rb_root *root, u64 res_id)
...@@ -355,7 +357,7 @@ static int mpt_mask(struct mlx4_dev *dev) ...@@ -355,7 +357,7 @@ static int mpt_mask(struct mlx4_dev *dev)
return dev->caps.num_mpts - 1; return dev->caps.num_mpts - 1;
} }
static void *find_res(struct mlx4_dev *dev, int res_id, static void *find_res(struct mlx4_dev *dev, u64 res_id,
enum mlx4_resource type) enum mlx4_resource type)
{ {
struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_priv *priv = mlx4_priv(dev);
...@@ -447,6 +449,7 @@ static struct res_common *alloc_qp_tr(int id) ...@@ -447,6 +449,7 @@ static struct res_common *alloc_qp_tr(int id)
ret->local_qpn = id; ret->local_qpn = id;
INIT_LIST_HEAD(&ret->mcg_list); INIT_LIST_HEAD(&ret->mcg_list);
spin_lock_init(&ret->mcg_spl); spin_lock_init(&ret->mcg_spl);
atomic_set(&ret->ref_count, 0);
return &ret->com; return &ret->com;
} }
...@@ -554,7 +557,7 @@ static struct res_common *alloc_xrcdn_tr(int id) ...@@ -554,7 +557,7 @@ static struct res_common *alloc_xrcdn_tr(int id)
return &ret->com; return &ret->com;
} }
static struct res_common *alloc_fs_rule_tr(u64 id) static struct res_common *alloc_fs_rule_tr(u64 id, int qpn)
{ {
struct res_fs_rule *ret; struct res_fs_rule *ret;
...@@ -564,7 +567,7 @@ static struct res_common *alloc_fs_rule_tr(u64 id) ...@@ -564,7 +567,7 @@ static struct res_common *alloc_fs_rule_tr(u64 id)
ret->com.res_id = id; ret->com.res_id = id;
ret->com.state = RES_FS_RULE_ALLOCATED; ret->com.state = RES_FS_RULE_ALLOCATED;
ret->qpn = qpn;
return &ret->com; return &ret->com;
} }
...@@ -602,7 +605,7 @@ static struct res_common *alloc_tr(u64 id, enum mlx4_resource type, int slave, ...@@ -602,7 +605,7 @@ static struct res_common *alloc_tr(u64 id, enum mlx4_resource type, int slave,
ret = alloc_xrcdn_tr(id); ret = alloc_xrcdn_tr(id);
break; break;
case RES_FS_RULE: case RES_FS_RULE:
ret = alloc_fs_rule_tr(id); ret = alloc_fs_rule_tr(id, extra);
break; break;
default: default:
return NULL; return NULL;
...@@ -671,10 +674,14 @@ static int add_res_range(struct mlx4_dev *dev, int slave, u64 base, int count, ...@@ -671,10 +674,14 @@ static int add_res_range(struct mlx4_dev *dev, int slave, u64 base, int count,
static int remove_qp_ok(struct res_qp *res) static int remove_qp_ok(struct res_qp *res)
{ {
if (res->com.state == RES_QP_BUSY) if (res->com.state == RES_QP_BUSY || atomic_read(&res->ref_count) ||
!list_empty(&res->mcg_list)) {
pr_err("resource tracker: fail to remove qp, state %d, ref_count %d\n",
res->com.state, atomic_read(&res->ref_count));
return -EBUSY; return -EBUSY;
else if (res->com.state != RES_QP_RESERVED) } else if (res->com.state != RES_QP_RESERVED) {
return -EPERM; return -EPERM;
}
return 0; return 0;
} }
...@@ -3124,6 +3131,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -3124,6 +3131,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
struct list_head *rlist = &tracker->slave_list[slave].res_list[RES_MAC]; struct list_head *rlist = &tracker->slave_list[slave].res_list[RES_MAC];
int err; int err;
int qpn; int qpn;
struct res_qp *rqp;
struct mlx4_net_trans_rule_hw_ctrl *ctrl; struct mlx4_net_trans_rule_hw_ctrl *ctrl;
struct _rule_hw *rule_header; struct _rule_hw *rule_header;
int header_id; int header_id;
...@@ -3134,7 +3142,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -3134,7 +3142,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf; ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf;
qpn = be32_to_cpu(ctrl->qpn) & 0xffffff; qpn = be32_to_cpu(ctrl->qpn) & 0xffffff;
err = get_res(dev, slave, qpn, RES_QP, NULL); err = get_res(dev, slave, qpn, RES_QP, &rqp);
if (err) { if (err) {
pr_err("Steering rule with qpn 0x%x rejected.\n", qpn); pr_err("Steering rule with qpn 0x%x rejected.\n", qpn);
return err; return err;
...@@ -3175,14 +3183,16 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -3175,14 +3183,16 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
if (err) if (err)
goto err_put; goto err_put;
err = add_res_range(dev, slave, vhcr->out_param, 1, RES_FS_RULE, 0); err = add_res_range(dev, slave, vhcr->out_param, 1, RES_FS_RULE, qpn);
if (err) { if (err) {
mlx4_err(dev, "Fail to add flow steering resources.\n "); mlx4_err(dev, "Fail to add flow steering resources.\n ");
/* detach rule*/ /* detach rule*/
mlx4_cmd(dev, vhcr->out_param, 0, 0, mlx4_cmd(dev, vhcr->out_param, 0, 0,
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A, MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
MLX4_CMD_NATIVE); MLX4_CMD_NATIVE);
goto err_put;
} }
atomic_inc(&rqp->ref_count);
err_put: err_put:
put_res(dev, slave, qpn, RES_QP); put_res(dev, slave, qpn, RES_QP);
return err; return err;
...@@ -3195,20 +3205,35 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -3195,20 +3205,35 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
struct mlx4_cmd_info *cmd) struct mlx4_cmd_info *cmd)
{ {
int err; int err;
struct res_qp *rqp;
struct res_fs_rule *rrule;
if (dev->caps.steering_mode != if (dev->caps.steering_mode !=
MLX4_STEERING_MODE_DEVICE_MANAGED) MLX4_STEERING_MODE_DEVICE_MANAGED)
return -EOPNOTSUPP; return -EOPNOTSUPP;
err = get_res(dev, slave, vhcr->in_param, RES_FS_RULE, &rrule);
if (err)
return err;
/* Release the rule form busy state before removal */
put_res(dev, slave, vhcr->in_param, RES_FS_RULE);
err = get_res(dev, slave, rrule->qpn, RES_QP, &rqp);
if (err)
return err;
err = rem_res_range(dev, slave, vhcr->in_param, 1, RES_FS_RULE, 0); err = rem_res_range(dev, slave, vhcr->in_param, 1, RES_FS_RULE, 0);
if (err) { if (err) {
mlx4_err(dev, "Fail to remove flow steering resources.\n "); mlx4_err(dev, "Fail to remove flow steering resources.\n ");
return err; goto out;
} }
err = mlx4_cmd(dev, vhcr->in_param, 0, 0, err = mlx4_cmd(dev, vhcr->in_param, 0, 0,
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A, MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
MLX4_CMD_NATIVE); MLX4_CMD_NATIVE);
if (!err)
atomic_dec(&rqp->ref_count);
out:
put_res(dev, slave, rrule->qpn, RES_QP);
return err; return err;
} }
...@@ -3806,6 +3831,7 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave) ...@@ -3806,6 +3831,7 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave)
mutex_lock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex); mutex_lock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex);
/*VLAN*/ /*VLAN*/
rem_slave_macs(dev, slave); rem_slave_macs(dev, slave);
rem_slave_fs_rule(dev, slave);
rem_slave_qps(dev, slave); rem_slave_qps(dev, slave);
rem_slave_srqs(dev, slave); rem_slave_srqs(dev, slave);
rem_slave_cqs(dev, slave); rem_slave_cqs(dev, slave);
...@@ -3814,6 +3840,5 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave) ...@@ -3814,6 +3840,5 @@ void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave)
rem_slave_mtts(dev, slave); rem_slave_mtts(dev, slave);
rem_slave_counters(dev, slave); rem_slave_counters(dev, slave);
rem_slave_xrcdns(dev, slave); rem_slave_xrcdns(dev, slave);
rem_slave_fs_rule(dev, slave);
mutex_unlock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex); mutex_unlock(&priv->mfunc.master.res_tracker.slave_list[slave].mutex);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment