Skip to contentSkip to conversation

mlxsw: couple of fixes

PATCH Superseded Jiri Pirko 2 participants 4 messages Mar 7, 2016

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

v2 cover mlxsw: couple of fixes

From: Jiri Pirko <[email protected]>

Couple of fixes from Ido.

Ido Schimmel (2):
mlxsw: spectrum: Always decrement bridge's ref count
mlxsw: pci: Correctly determine if descriptor queue is full

 drivers/net/ethernet/mellanox/mlxsw/pci.c      | 2 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.5.0
author
#1 lore raw

PATCH v2 1/2 mlxsw: spectrum: Always decrement bridge's ref count

From: Ido Schimmel <[email protected]>

Since we only support one VLAN filtering bridge we need to associate a reference count with it, so that when the last port netdev leaves it, we would know that a different bridge can be offloaded to hardware.

When a LAG device is memeber in a bridge and port netdevs are leaving the LAG, we should always decrement the bridge's reference count, as it's incremented for any port in the LAG.

Fixes 4dc236c31733 ("mlxsw: spectrum: Handle port leaving LAG while bridged")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -3
index 09ce451..a94daa8 100644
@@ -2358,9 +2358,7 @@ static int mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,
 	if (mlxsw_sp_port->bridged) {
 		mlxsw_sp_port_active_vlans_del(mlxsw_sp_port);
 		mlxsw_sp_port_bridge_leave(mlxsw_sp_port, false);
-
-		if (lag->ref_count == 1)
-			mlxsw_sp_master_bridge_dec(mlxsw_sp, NULL);
+		mlxsw_sp_master_bridge_dec(mlxsw_sp, NULL);
 	}
 
 	if (lag->ref_count == 1) {
Signature · 1 line
2.5.0
author
#2 lore raw

PATCH v2 2/2 mlxsw: pci: Correctly determine if descriptor queue is full

In reply to Jiri Pirko

From: Ido Schimmel <[email protected]>

The descriptor queues for sending (SDQs) and receiving (RDQs) packets are managed by two counters - producer and consumer - which are both 16-bit in size. A queue is considered full when the difference between the two equals the queue's maximum number of descriptors.

However, if the producer counter overflows, then it's possible for the full queue check to fail, as it doesn't take the overflow into account. In such a case, descriptors already passed to the device - but for which a completion has yet to be posted - will be overwritten, thereby causing undefined behavior. The above can be achieved under heavy load (~30 netperf instances).

Fix that by casting the subtraction result to u16, preventing it from being treated as a signed integer.

Fixes eda6500a987a ("mlxsw: Add PCI bus implementation")

---
v1->v2: fixed typo in desc

---
 drivers/net/ethernet/mellanox/mlxsw/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/pci.c +1 -1
index c071077..7992c55 100644
@@ -215,7 +215,7 @@ mlxsw_pci_queue_elem_info_producer_get(struct mlxsw_pci_queue *q)
 {
 	int index = q->producer_counter & (q->count - 1);
 
-	if ((q->producer_counter - q->consumer_counter) == q->count)
+	if ((u16) (q->producer_counter - q->consumer_counter) == q->count)
 		return NULL;
 	return mlxsw_pci_queue_elem_info_get(q, index);
 }
Signature · 1 line
2.5.0