mlx4: decreasing ref count when removing mac
authorYevgeny Petrilin <yevgenyp@mellanox.co.il>
Thu, 4 Aug 2011 01:05:12 +0000 (01:05 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Aug 2011 10:36:07 +0000 (03:36 -0700)
For older FW versions, when a Mac address removed from Mac table,
we should set 0 for reference count for the corresponding Mac index.
Fixes a bug where removing Mac from the table still left that entry as
invalid.

Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Tested-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/mlx4/port.c

index 1f95afda68410ad9794c0425366b6dd9c6aa7663..609e0ec14ceebf495c6ddff49ea2cff09738e2cd 100644 (file)
@@ -258,9 +258,12 @@ void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int qpn)
        if (validate_index(dev, table, index))
                goto out;
 
-       table->entries[index] = 0;
-       mlx4_set_port_mac_table(dev, port, table->entries);
-       --table->total;
+       /* Check whether this address has reference count */
+       if (!(--table->refs[index])) {
+               table->entries[index] = 0;
+               mlx4_set_port_mac_table(dev, port, table->entries);
+               --table->total;
+       }
 out:
        mutex_unlock(&table->mutex);
 }