Skip to content

Commit 317ab5b

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: Configure the Time-Aware Scheduler via tc-taprio offload
This qdisc offload is the closest thing to what the SJA1105 supports in hardware for time-based egress shaping. The switch core really is built around SAE AS6802/TTEthernet (a TTTech standard) but can be made to operate similarly to IEEE 802.1Qbv with some constraints: - The gate control list is a global list for all ports. There are 8 execution threads that iterate through this global list in parallel. I don't know why 8, there are only 4 front-panel ports. - Care must be taken by the user to make sure that two execution threads never get to execute a GCL entry simultaneously. I created a O(n^4) checker for this hardware limitation, prior to accepting a taprio offload configuration as valid. - The spec says that if a GCL entry's interval is shorter than the frame length, you shouldn't send it (and end up in head-of-line blocking). Well, this switch does anyway. - The switch has no concept of ADMIN and OPER configurations. Because it's so simple, the TAS settings are loaded through the static config tables interface, so there isn't even place for any discussion about 'graceful switchover between ADMIN and OPER'. You just reset the switch and upload a new OPER config. - The switch accepts multiple time sources for the gate events. Right now I am using the standalone clock source as opposed to PTP. So the base time parameter doesn't really do much. Support for the PTP clock source will be added in a future series. Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f06c63 commit 317ab5b

File tree

6 files changed

+500
-1
lines changed

6 files changed

+500
-1
lines changed

drivers/net/dsa/sja1105/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ config NET_DSA_SJA1105_PTP
2323
help
2424
This enables support for timestamping and PTP clock manipulations in
2525
the SJA1105 DSA driver.
26+
27+
config NET_DSA_SJA1105_TAS
28+
bool "Support for the Time-Aware Scheduler on NXP SJA1105"
29+
depends on NET_DSA_SJA1105
30+
help
31+
This enables support for the TTEthernet-based egress scheduling
32+
engine in the SJA1105 DSA driver, which is controlled using a
33+
hardware offload of the tc-tqprio qdisc.

drivers/net/dsa/sja1105/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ sja1105-objs := \
1212
ifdef CONFIG_NET_DSA_SJA1105_PTP
1313
sja1105-objs += sja1105_ptp.o
1414
endif
15+
16+
ifdef CONFIG_NET_DSA_SJA1105_TAS
17+
sja1105-objs += sja1105_tas.o
18+
endif

drivers/net/dsa/sja1105/sja1105.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
#define SJA1105_AGEING_TIME_MS(ms) ((ms) / 10)
2222

23+
#include "sja1105_tas.h"
24+
2325
/* Keeps the different addresses between E/T and P/Q/R/S */
2426
struct sja1105_regs {
2527
u64 device_id;
@@ -104,6 +106,7 @@ struct sja1105_private {
104106
*/
105107
struct mutex mgmt_lock;
106108
struct sja1105_tagger_data tagger_data;
109+
struct sja1105_tas_data tas_data;
107110
};
108111

109112
#include "sja1105_dynamic_config.h"
@@ -120,6 +123,9 @@ typedef enum {
120123
SPI_WRITE = 1,
121124
} sja1105_spi_rw_mode_t;
122125

126+
/* From sja1105_main.c */
127+
int sja1105_static_config_reload(struct sja1105_private *priv);
128+
123129
/* From sja1105_spi.c */
124130
int sja1105_spi_send_packed_buf(const struct sja1105_private *priv,
125131
sja1105_spi_rw_mode_t rw, u64 reg_addr,

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/if_ether.h>
2323
#include <linux/dsa/8021q.h>
2424
#include "sja1105.h"
25+
#include "sja1105_tas.h"
2526

2627
static void sja1105_hw_reset(struct gpio_desc *gpio, unsigned int pulse_len,
2728
unsigned int startup_delay)
@@ -1382,7 +1383,7 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port,
13821383
* modify at runtime (currently only MAC) and restore them after uploading,
13831384
* such that this operation is relatively seamless.
13841385
*/
1385-
static int sja1105_static_config_reload(struct sja1105_private *priv)
1386+
int sja1105_static_config_reload(struct sja1105_private *priv)
13861387
{
13871388
struct sja1105_mac_config_entry *mac;
13881389
int speed_mbps[SJA1105_NUM_PORTS];
@@ -1727,6 +1728,7 @@ static void sja1105_teardown(struct dsa_switch *ds)
17271728
{
17281729
struct sja1105_private *priv = ds->priv;
17291730

1731+
sja1105_tas_teardown(ds);
17301732
cancel_work_sync(&priv->tagger_data.rxtstamp_work);
17311733
skb_queue_purge(&priv->tagger_data.skb_rxtstamp_queue);
17321734
sja1105_ptp_clock_unregister(priv);
@@ -2056,6 +2058,18 @@ static bool sja1105_port_txtstamp(struct dsa_switch *ds, int port,
20562058
return true;
20572059
}
20582060

2061+
static int sja1105_port_setup_tc(struct dsa_switch *ds, int port,
2062+
enum tc_setup_type type,
2063+
void *type_data)
2064+
{
2065+
switch (type) {
2066+
case TC_SETUP_QDISC_TAPRIO:
2067+
return sja1105_setup_tc_taprio(ds, port, type_data);
2068+
default:
2069+
return -EOPNOTSUPP;
2070+
}
2071+
}
2072+
20592073
static const struct dsa_switch_ops sja1105_switch_ops = {
20602074
.get_tag_protocol = sja1105_get_tag_protocol,
20612075
.setup = sja1105_setup,
@@ -2088,6 +2102,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = {
20882102
.port_hwtstamp_set = sja1105_hwtstamp_set,
20892103
.port_rxtstamp = sja1105_port_rxtstamp,
20902104
.port_txtstamp = sja1105_port_txtstamp,
2105+
.port_setup_tc = sja1105_port_setup_tc,
20912106
};
20922107

20932108
static int sja1105_check_device_id(struct sja1105_private *priv)
@@ -2197,6 +2212,8 @@ static int sja1105_probe(struct spi_device *spi)
21972212
}
21982213
mutex_init(&priv->mgmt_lock);
21992214

2215+
sja1105_tas_setup(ds);
2216+
22002217
return dsa_register_switch(priv->ds);
22012218
}
22022219

0 commit comments

Comments
 (0)