net: dsa: sja1105: offload the Credit-Based Shaper qdisc
Vladimir Oltean
maintainerPATCH v3 1/1 net: dsa: sja1105: offload the Credit-Based Shaper qdisc
From: Vladimir Oltean <[email protected]>
SJA1105, being AVB/TSN switches, provide hardware assist for the Credit-Based Shaper as described in the IEEE 8021Q-2018 document.
First generation has 10 shapers, freely assignable to any of the 4 external ports and 8 traffic classes, and second generation has 16 shapers.
The Credit-Based Shaper tables are accessed through the dynamic reconfiguration interface, so we have to restore them manually after a switch reset. The tables are backed up by the static config only on P/Q/R/S, and we don't want to add custom code only for that family, since the procedure that is in place now works for both.
Tested with the following commands:
data_rate_kbps=67000 port_transmit_rate_kbps=1000000 idleslope=$data_rate_kbps sendslope=$(($idleslope - $port_transmit_rate_kbps)) locredit=$((-0x80000000)) hicredit=$((0x7fffffff))
tc qdisc add dev swp2 root handle 1: mqprio hw 0 num_tc 8 \
map 0 1 2 3 4 5 6 7 \
queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7
tc qdisc replace dev swp2 parent 1:1 cbs \
idleslope $idleslope \
sendslope $sendslope \
hicredit $hicredit \
locredit $locredit \
offload 1---
Changes in v3:
- Removed obsolete comment about dummy mqprio offload.
Changes in v2:
- Removed bogus dummy mqprio hw offload.
- Made sure first-gen SJA1105E/T works properly (some bugs in sja1105et_cbs_entry_packing).
drivers/net/dsa/sja1105/sja1105.h | 2 + .../net/dsa/sja1105/sja1105_dynamic_config.c | 76 +++++++++++++ drivers/net/dsa/sja1105/sja1105_main.c | 100 ++++++++++++++++++ drivers/net/dsa/sja1105/sja1105_spi.c | 6 ++ .../net/dsa/sja1105/sja1105_static_config.h | 15 +++ 5 files changed, 199 insertions(+)
drivers/net/dsa/sja1105/sja1105.h +2 -0
@@ -84,6 +84,7 @@ struct sja1105_info {* the egress timestamps. */ int ptpegr_ts_bytes; +int num_cbs_shapers;const struct sja1105_dynamic_table_ops *dyn_ops;const struct sja1105_table_ops *static_ops;const struct sja1105_regs *regs;
@@ -218,6 +219,7 @@ struct sja1105_private {struct mutex mgmt_lock;bool expect_dsa_8021q;enum sja1105_vlan_state vlan_state; +struct sja1105_cbs_entry *cbs;struct sja1105_tagger_data tagger_data;struct sja1105_ptp_data ptp_data;struct sja1105_tas_data tas_data;
drivers/net/dsa/sja1105/sja1105_dynamic_config.c +76 -0
100 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_main.c +100 -0
124 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_spi.c +6 -0
@@ -515,6 +515,7 @@ struct sja1105_info sja1105e_info = { .qinq_tpid = ETH_P_8021Q, .ptp_ts_bits = 24, .ptpegr_ts_bytes = 4, + .num_cbs_shapers = SJA1105ET_MAX_CBS_COUNT, .reset_cmd = sja1105et_reset_cmd, .fdb_add_cmd = sja1105et_fdb_add, .fdb_del_cmd = sja1105et_fdb_del,
@@ -530,6 +531,7 @@ struct sja1105_info sja1105t_info = { .qinq_tpid = ETH_P_8021Q, .ptp_ts_bits = 24, .ptpegr_ts_bytes = 4, + .num_cbs_shapers = SJA1105ET_MAX_CBS_COUNT, .reset_cmd = sja1105et_reset_cmd, .fdb_add_cmd = sja1105et_fdb_add, .fdb_del_cmd = sja1105et_fdb_del,
@@ -545,6 +547,7 @@ struct sja1105_info sja1105p_info = { .qinq_tpid = ETH_P_8021AD, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, + .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT, .setup_rgmii_delay = sja1105pqrs_setup_rgmii_delay, .reset_cmd = sja1105pqrs_reset_cmd, .fdb_add_cmd = sja1105pqrs_fdb_add,
@@ -561,6 +564,7 @@ struct sja1105_info sja1105q_info = { .qinq_tpid = ETH_P_8021AD, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, + .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT, .setup_rgmii_delay = sja1105pqrs_setup_rgmii_delay, .reset_cmd = sja1105pqrs_reset_cmd, .fdb_add_cmd = sja1105pqrs_fdb_add,
@@ -577,6 +581,7 @@ struct sja1105_info sja1105r_info = { .qinq_tpid = ETH_P_8021AD, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, + .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT, .setup_rgmii_delay = sja1105pqrs_setup_rgmii_delay, .reset_cmd = sja1105pqrs_reset_cmd, .fdb_add_cmd = sja1105pqrs_fdb_add,
@@ -594,6 +599,7 @@ struct sja1105_info sja1105s_info = { .qinq_tpid = ETH_P_8021AD, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, + .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT, .setup_rgmii_delay = sja1105pqrs_setup_rgmii_delay, .reset_cmd = sja1105pqrs_reset_cmd, .fdb_add_cmd = sja1105pqrs_fdb_add,
drivers/net/dsa/sja1105/sja1105_static_config.h +15 -0
@@ -30,11 +30,13 @@#define SJA1105ET_SIZE_L2_LOOKUP_PARAMS_ENTRY 4#define SJA1105ET_SIZE_GENERAL_PARAMS_ENTRY 40#define SJA1105ET_SIZE_AVB_PARAMS_ENTRY 12 +#define SJA1105ET_SIZE_CBS_ENTRY 16#define SJA1105PQRS_SIZE_L2_LOOKUP_ENTRY 20#define SJA1105PQRS_SIZE_MAC_CONFIG_ENTRY 32#define SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_ENTRY 16#define SJA1105PQRS_SIZE_GENERAL_PARAMS_ENTRY 44#define SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY 16 +#define SJA1105PQRS_SIZE_CBS_ENTRY 20/* UM10944.pdf Page 11, Table 2. Configuration Blocks */ enum {
@@ -56,6 +58,7 @@ enum {BLKID_AVB_PARAMS =0x10 ,BLKID_GENERAL_PARAMS =0x11 ,BLKID_RETAGGING =0x12 , +BLKID_CBS =0x13 , BLKID_XMII_PARAMS = 0x4E, };
@@ -78,6 +81,7 @@ enum sja1105_blk_idx {BLK_IDX_AVB_PARAMS ,BLK_IDX_GENERAL_PARAMS ,BLK_IDX_RETAGGING , +BLK_IDX_CBS ,BLK_IDX_XMII_PARAMS , BLK_IDX_MAX,/* Fake block indices that are only valid for dynamic access */
@@ -105,6 +109,8 @@ enum sja1105_blk_idx {#define SJA1105_MAX_RETAGGING_COUNT 32#define SJA1105_MAX_XMII_PARAMS_COUNT 1#define SJA1105_MAX_AVB_PARAMS_COUNT 1 +#define SJA1105ET_MAX_CBS_COUNT 10 +#define SJA1105PQRS_MAX_CBS_COUNT 16#define SJA1105_MAX_FRAME_MEMORY 929#define SJA1105_MAX_FRAME_MEMORY_RETAGGING 910
@@ -289,6 +295,15 @@ struct sja1105_retagging_entry {u64 destports; }; +struct sja1105_cbs_entry { +u64 port; +u64 prio; +u64 credit_hi; +u64 credit_lo; +u64 send_slope; +u64 idle_slope; +}; +struct sja1105_xmii_params_entry {u64 phy_mac[5 ];u64 xmii_mode[5 ];
Signature · 1 line
2.25.1
From: Vladimir Oltean <[email protected]>
Date: Thu, 28 May 2020 03:27:58 +0300
Quoted 33 lines
From: Vladimir Oltean <[email protected]>
SJA1105, being AVB/TSN switches, provide hardware assist for the Credit-Based Shaper as described in the IEEE 8021Q-2018 document.
First generation has 10 shapers, freely assignable to any of the 4 external ports and 8 traffic classes, and second generation has 16 shapers.
The Credit-Based Shaper tables are accessed through the dynamic reconfiguration interface, so we have to restore them manually after a switch reset. The tables are backed up by the static config only on P/Q/R/S, and we don't want to add custom code only for that family, since the procedure that is in place now works for both.
Tested with the following commands:
data_rate_kbps=67000 port_transmit_rate_kbps=1000000 idleslope=$data_rate_kbps sendslope=$(($idleslope - $port_transmit_rate_kbps)) locredit=$((-0x80000000)) hicredit=$((0x7fffffff))
tc qdisc add dev swp2 root handle 1: mqprio hw 0 num_tc 8 \ map 0 1 2 3 4 5 6 7 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 tc qdisc replace dev swp2 parent 1:1 cbs \ idleslope $idleslope \ sendslope $sendslope \ hicredit $hicredit \ locredit $locredit \ offload 1
Quoted 1 line
Signed-off-by Vladimir Oltean <[email protected]>
Applied, thank you.