Skip to content

Commit 0a51826

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: Always send through management routes in slot 0
I finally found out how the 4 management route slots are supposed to be used, but.. it's not worth it. The description from the comment I've just deleted in this commit is still true: when more than 1 management slot is active at the same time, the switch will match frames incoming [from the CPU port] on the lowest numbered management slot that matches the frame's DMAC. My issue was that one was not supposed to statically assign each port a slot. Yes, there are 4 slots and also 4 non-CPU ports, but that is a mere coincidence. Instead, the switch can be used like this: every management frame gets a slot at the right of the most recently assigned slot: Send mgmt frame 1 through S0: S0 x x x Send mgmt frame 2 through S1: S0 S1 x x Send mgmt frame 3 through S2: S0 S1 S2 x Send mgmt frame 4 through S3: S0 S1 S2 S3 The difference compared to the old usage is that the transmission of frames 1-4 doesn't need to wait until the completion of the management route. It is safe to use a slot to the right of the most recently used one, because by protocol nobody will program a slot to your left and "steal" your route towards the correct egress port. So there is a potential throughput benefit here. But mgmt frame 5 has no more free slot to use, so it has to wait until _all_ of S0, S1, S2, S3 are full, in order to use S0 again. And that's actually exactly the problem: I was looking for something that would bring more predictable transmission latency, but this is exactly the opposite: 3 out of 4 frames would be transmitted quicker, but the 4th would draw the short straw and have a worse worst-case latency than before. Useless. Things are made even worse by PTP TX timestamping, which is something I won't go deeply into here. Suffice to say that the fact there is a driver-level lock on the SPI bus offsets any potential throughput gains that parallelism might bring. So there's no going back to the multi-slot scheme, remove the "mgmt_slot" variable from sja1105_port and the dummy static assignment made at probe time. While passing by, also remove the assignment to casc_port altogether. Don't pretend that we support cascaded setups. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8bd17dc commit 0a51826

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,6 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
426426
.tpid2 = ETH_P_SJA1105,
427427
};
428428
struct sja1105_table *table;
429-
int i, k = 0;
430-
431-
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
432-
if (dsa_is_dsa_port(priv->ds, i))
433-
default_general_params.casc_port = i;
434-
else if (dsa_is_user_port(priv->ds, i))
435-
priv->ports[i].mgmt_slot = k++;
436-
}
437429

438430
table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];
439431

@@ -1827,30 +1819,14 @@ static netdev_tx_t sja1105_port_deferred_xmit(struct dsa_switch *ds, int port,
18271819
struct sk_buff *skb)
18281820
{
18291821
struct sja1105_private *priv = ds->priv;
1830-
struct sja1105_port *sp = &priv->ports[port];
1831-
int slot = sp->mgmt_slot;
18321822
struct sk_buff *clone;
18331823

1834-
/* The tragic fact about the switch having 4x2 slots for installing
1835-
* management routes is that all of them except one are actually
1836-
* useless.
1837-
* If 2 slots are simultaneously configured for two BPDUs sent to the
1838-
* same (multicast) DMAC but on different egress ports, the switch
1839-
* would confuse them and redirect first frame it receives on the CPU
1840-
* port towards the port configured on the numerically first slot
1841-
* (therefore wrong port), then second received frame on second slot
1842-
* (also wrong port).
1843-
* So for all practical purposes, there needs to be a lock that
1844-
* prevents that from happening. The slot used here is utterly useless
1845-
* (could have simply been 0 just as fine), but we are doing it
1846-
* nonetheless, in case a smarter idea ever comes up in the future.
1847-
*/
18481824
mutex_lock(&priv->mgmt_lock);
18491825

18501826
/* The clone, if there, was made by dsa_skb_tx_timestamp */
18511827
clone = DSA_SKB_CB(skb)->clone;
18521828

1853-
sja1105_mgmt_xmit(ds, port, slot, skb, !!clone);
1829+
sja1105_mgmt_xmit(ds, port, 0, skb, !!clone);
18541830

18551831
if (!clone)
18561832
goto out;

include/linux/dsa/sja1105.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct sja1105_port {
5656
struct sja1105_tagger_data *data;
5757
struct dsa_port *dp;
5858
bool hwts_tx_en;
59-
int mgmt_slot;
6059
};
6160

6261
#endif /* _NET_DSA_SJA1105_H */

0 commit comments

Comments
 (0)