aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@dev.mellanox.co.il>2013-11-03 03:03:19 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-04 16:19:07 -0500
commit2009d0059c084288f060b1ffe3d14229588acb67 (patch)
tree066b709ab7cdb70f26b8ab7fdd6a60eb9dee1158
parentacddd5dd44d4fd9b45dd5ee69cd8b183052b1cdc (diff)
net/mlx4_en: Use vlan id instead of vlan index for unregistration
Use of vlan_index created problems unregistering vlans on guests. In addition, tools delete vlan by tag, not by index, lets follow that. Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/port.c27
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c2
-rw-r--r--include/linux/mlx4/device.h2
6 files changed, 20 insertions, 21 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index ae8eb4c4fb6c..887d62576f54 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1687,7 +1687,7 @@ static void mlx4_master_deactivate_admin_state(struct mlx4_priv *priv, int slave
1687 vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port]; 1687 vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
1688 if (NO_INDX != vp_oper->vlan_idx) { 1688 if (NO_INDX != vp_oper->vlan_idx) {
1689 __mlx4_unregister_vlan(&priv->dev, 1689 __mlx4_unregister_vlan(&priv->dev,
1690 port, vp_oper->vlan_idx); 1690 port, vp_oper->state.default_vlan);
1691 vp_oper->vlan_idx = NO_INDX; 1691 vp_oper->vlan_idx = NO_INDX;
1692 } 1692 }
1693 if (NO_INDX != vp_oper->mac_idx) { 1693 if (NO_INDX != vp_oper->mac_idx) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 85d91665d400..b5554121aca4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -417,7 +417,6 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
417 struct mlx4_en_priv *priv = netdev_priv(dev); 417 struct mlx4_en_priv *priv = netdev_priv(dev);
418 struct mlx4_en_dev *mdev = priv->mdev; 418 struct mlx4_en_dev *mdev = priv->mdev;
419 int err; 419 int err;
420 int idx;
421 420
422 en_dbg(HW, priv, "Killing VID:%d\n", vid); 421 en_dbg(HW, priv, "Killing VID:%d\n", vid);
423 422
@@ -425,10 +424,7 @@ static int mlx4_en_vlan_rx_kill_vid(struct net_device *dev,
425 424
426 /* Remove VID from port VLAN filter */ 425 /* Remove VID from port VLAN filter */
427 mutex_lock(&mdev->state_lock); 426 mutex_lock(&mdev->state_lock);
428 if (!mlx4_find_cached_vlan(mdev->dev, priv->port, vid, &idx)) 427 mlx4_unregister_vlan(mdev->dev, priv->port, vid);
429 mlx4_unregister_vlan(mdev->dev, priv->port, idx);
430 else
431 en_dbg(HW, priv, "could not find vid %d in cache\n", vid);
432 428
433 if (mdev->device_up && priv->port_up) { 429 if (mdev->device_up && priv->port_up) {
434 err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); 430 err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 348bb8c7d9a7..f2ad4f61f58c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -1111,7 +1111,7 @@ int mlx4_change_port_types(struct mlx4_dev *dev,
1111 1111
1112void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table); 1112void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
1113void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table); 1113void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
1114void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index); 1114void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
1115int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 1115int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
1116 1116
1117int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz); 1117int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz);
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index 9433c1f6b0d4..caaa15470395 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -406,23 +406,26 @@ int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
406} 406}
407EXPORT_SYMBOL_GPL(mlx4_register_vlan); 407EXPORT_SYMBOL_GPL(mlx4_register_vlan);
408 408
409void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index) 409void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan)
410{ 410{
411 struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table; 411 struct mlx4_vlan_table *table = &mlx4_priv(dev)->port[port].vlan_table;
412 int index;
412 413
413 if (index < MLX4_VLAN_REGULAR) { 414 mutex_lock(&table->mutex);
414 mlx4_warn(dev, "Trying to free special vlan index %d\n", index); 415 if (mlx4_find_cached_vlan(dev, port, vlan, &index)) {
415 return; 416 mlx4_warn(dev, "vlan 0x%x is not in the vlan table\n", vlan);
417 goto out;
416 } 418 }
417 419
418 mutex_lock(&table->mutex); 420 if (index < MLX4_VLAN_REGULAR) {
419 if (!table->refs[index]) { 421 mlx4_warn(dev, "Trying to free special vlan index %d\n", index);
420 mlx4_warn(dev, "No vlan entry for index %d\n", index);
421 goto out; 422 goto out;
422 } 423 }
424
423 if (--table->refs[index]) { 425 if (--table->refs[index]) {
424 mlx4_dbg(dev, "Have more references for index %d," 426 mlx4_dbg(dev, "Have %d more references for index %d,"
425 "no need to modify vlan table\n", index); 427 "no need to modify vlan table\n", table->refs[index],
428 index);
426 goto out; 429 goto out;
427 } 430 }
428 table->entries[index] = 0; 431 table->entries[index] = 0;
@@ -432,19 +435,19 @@ out:
432 mutex_unlock(&table->mutex); 435 mutex_unlock(&table->mutex);
433} 436}
434 437
435void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index) 438void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan)
436{ 439{
437 u64 out_param = 0; 440 u64 out_param = 0;
438 441
439 if (mlx4_is_mfunc(dev)) { 442 if (mlx4_is_mfunc(dev)) {
440 (void) mlx4_cmd_imm(dev, index, &out_param, 443 (void) mlx4_cmd_imm(dev, vlan, &out_param,
441 ((u32) port) << 8 | (u32) RES_VLAN, 444 ((u32) port) << 8 | (u32) RES_VLAN,
442 RES_OP_RESERVE_AND_MAP, 445 RES_OP_RESERVE_AND_MAP,
443 MLX4_CMD_FREE_RES, MLX4_CMD_TIME_CLASS_A, 446 MLX4_CMD_FREE_RES, MLX4_CMD_TIME_CLASS_A,
444 MLX4_CMD_WRAPPED); 447 MLX4_CMD_WRAPPED);
445 return; 448 return;
446 } 449 }
447 __mlx4_unregister_vlan(dev, port, index); 450 __mlx4_unregister_vlan(dev, port, vlan);
448} 451}
449EXPORT_SYMBOL_GPL(mlx4_unregister_vlan); 452EXPORT_SYMBOL_GPL(mlx4_unregister_vlan);
450 453
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index a5aa3be554fe..993a2ef13866 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -4085,7 +4085,7 @@ void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work)
4085 if (work->flags & MLX4_VF_IMMED_VLAN_FLAG_VLAN && !errors && 4085 if (work->flags & MLX4_VF_IMMED_VLAN_FLAG_VLAN && !errors &&
4086 NO_INDX != work->orig_vlan_ix) 4086 NO_INDX != work->orig_vlan_ix)
4087 __mlx4_unregister_vlan(&work->priv->dev, work->port, 4087 __mlx4_unregister_vlan(&work->priv->dev, work->port,
4088 work->orig_vlan_ix); 4088 work->orig_vlan_id);
4089out: 4089out:
4090 kfree(work); 4090 kfree(work);
4091 return; 4091 return;
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 297a16309f00..e2e92885bdc1 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -1079,7 +1079,7 @@ int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
1079 u8 *pg, u16 *ratelimit); 1079 u8 *pg, u16 *ratelimit);
1080int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 1080int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
1081int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 1081int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
1082void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index); 1082void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
1083 1083
1084int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list, 1084int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list,
1085 int npages, u64 iova, u32 *lkey, u32 *rkey); 1085 int npages, u64 iova, u32 *lkey, u32 *rkey);