Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 266856
b: refs/heads/master
c: e72ebf5
h: refs/heads/master
v: v3
  • Loading branch information
Yevgeny Petrilin authored and David S. Miller committed Oct 19, 2011
1 parent d2ddf4b commit aa346b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5ea2ef5f8b006ff9e970327e7fea78f1f5841c44
refs/heads/master: e72ebf5a578464204c8418d7d9b375333bb33161
15 changes: 8 additions & 7 deletions trunk/drivers/net/ethernet/mellanox/mlx4/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table)
table->entries[i] = 0;
table->refs[i] = 0;
}
table->max = 1 << dev->caps.log_num_vlans;
table->max = (1 << dev->caps.log_num_vlans) - MLX4_VLAN_REGULAR;
table->total = 0;
}

Expand Down Expand Up @@ -354,6 +354,13 @@ int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
int free = -1;

mutex_lock(&table->mutex);

if (table->total == table->max) {
/* No free vlan entries */
err = -ENOSPC;
goto out;
}

for (i = MLX4_VLAN_REGULAR; i < MLX4_MAX_VLAN_NUM; i++) {
if (free < 0 && (table->refs[i] == 0)) {
free = i;
Expand All @@ -375,12 +382,6 @@ int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index)
goto out;
}

if (table->total == table->max) {
/* No free vlan entries */
err = -ENOSPC;
goto out;
}

/* Register new MAC */
table->refs[free] = 1;
table->entries[free] = cpu_to_be32(vlan | MLX4_VLAN_VALID);
Expand Down

0 comments on commit aa346b7

Please sign in to comment.