Skip to content

Commit 25c4407

Browse files
ffainellidavem330
authored andcommitted
net: systemport: Simplify queue mapping logic
The use of a bitmap speeds up the finding of the first available queue to which we could start establishing the mapping for, but we still have to loop over all slave network devices to set them up. Simplify the logic to have a single loop, and use the fact that a correctly configured ring has inspect set to true. This will make things simpler to unwind during device unregistration. Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c04a17d commit 25c4407

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

drivers/net/ethernet/broadcom/bcmsysport.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,7 @@ static int bcm_sysport_map_queues(struct notifier_block *nb,
23242324
struct bcm_sysport_priv *priv;
23252325
struct net_device *slave_dev;
23262326
unsigned int num_tx_queues;
2327-
unsigned int q, start, port;
2327+
unsigned int q, qp, port;
23282328
struct net_device *dev;
23292329

23302330
priv = container_of(nb, struct bcm_sysport_priv, dsa_notifier);
@@ -2363,20 +2363,21 @@ static int bcm_sysport_map_queues(struct notifier_block *nb,
23632363

23642364
priv->per_port_num_tx_queues = num_tx_queues;
23652365

2366-
start = find_first_zero_bit(&priv->queue_bitmap, dev->num_tx_queues);
2367-
for (q = 0; q < num_tx_queues; q++) {
2368-
ring = &priv->tx_rings[q + start];
2366+
for (q = 0, qp = 0; q < dev->num_tx_queues && qp < num_tx_queues;
2367+
q++) {
2368+
ring = &priv->tx_rings[q];
2369+
2370+
if (ring->inspect)
2371+
continue;
23692372

23702373
/* Just remember the mapping actual programming done
23712374
* during bcm_sysport_init_tx_ring
23722375
*/
2373-
ring->switch_queue = q;
2376+
ring->switch_queue = qp;
23742377
ring->switch_port = port;
23752378
ring->inspect = true;
23762379
priv->ring_map[q + port * num_tx_queues] = ring;
2377-
2378-
/* Set all queues as being used now */
2379-
set_bit(q + start, &priv->queue_bitmap);
2380+
qp++;
23802381
}
23812382

23822383
return 0;

drivers/net/ethernet/broadcom/bcmsysport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ struct bcm_sysport_priv {
796796
/* map information between switch port queues and local queues */
797797
struct notifier_block dsa_notifier;
798798
unsigned int per_port_num_tx_queues;
799-
unsigned long queue_bitmap;
800799
struct bcm_sysport_tx_ring *ring_map[DSA_MAX_PORTS * 8];
801800

802801
};

0 commit comments

Comments
 (0)