Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: sja1105: allow RX timestamps to be taken on all ports for SJA1110

On SJA1105, there is support for a cascade port which is presumably
connected to a downstream SJA1105 switch. The upstream one does not take
PTP timestamps for packets received on this port, presumably because the
downstream switch already did (and for PTP, it only makes sense for the
leaf nodes in a DSA switch tree to do that).

I haven't been able to validate that feature in a fully assembled setup,
so I am disabling the feature by setting the cascade port to an unused
port value (ds->num_ports).

In SJA1110, multiple cascade ports are supported, and CASC_PORT became
a bit mask from a port number. So when CASC_PORT is set to ds->num_ports
(which is 11 on SJA1110), it is actually set to 0b1011, so ports 3, 1
and 0 are configured as cascade ports and we cannot take RX timestamps
on them.

So we need to introduce a check for SJA1110 and set things differently
(to zero there), so that the cascading feature is properly disabled and
RX timestamps can be taken on all ports.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
6c0de59b 29305260

+22 -10
+1
drivers/net/dsa/sja1105/sja1105.h
··· 109 109 int num_cbs_shapers; 110 110 int max_frame_mem; 111 111 int num_ports; 112 + bool multiple_cascade_ports; 112 113 const struct sja1105_dynamic_table_ops *dyn_ops; 113 114 const struct sja1105_table_ops *static_ops; 114 115 const struct sja1105_regs *regs;
+17 -10
drivers/net/dsa/sja1105/sja1105_main.c
··· 654 654 .host_port = priv->ds->num_ports, 655 655 /* Default to an invalid value */ 656 656 .mirr_port = priv->ds->num_ports, 657 - /* Link-local traffic received on casc_port will be forwarded 658 - * to host_port without embedding the source port and device ID 659 - * info in the destination MAC address (presumably because it 660 - * is a cascaded port and a downstream SJA switch already did 661 - * that). Default to an invalid port (to disable the feature) 662 - * and overwrite this if we find any DSA (cascaded) ports. 663 - */ 664 - .casc_port = priv->ds->num_ports, 665 657 /* No TTEthernet */ 666 658 .vllupformat = SJA1105_VL_FORMAT_PSFP, 667 659 .vlmarker = 0, ··· 668 676 /* Enable the TTEthernet engine on SJA1110 */ 669 677 .tte_en = true, 670 678 }; 679 + struct sja1105_general_params_entry *general_params; 671 680 struct dsa_switch *ds = priv->ds; 672 681 struct sja1105_table *table; 673 682 int port; ··· 694 701 695 702 table->entry_count = table->ops->max_entry_count; 696 703 704 + general_params = table->entries; 705 + 697 706 /* This table only has a single entry */ 698 - ((struct sja1105_general_params_entry *)table->entries)[0] = 699 - default_general_params; 707 + general_params[0] = default_general_params; 700 708 701 709 sja1110_select_tdmaconfigidx(priv); 710 + 711 + /* Link-local traffic received on casc_port will be forwarded 712 + * to host_port without embedding the source port and device ID 713 + * info in the destination MAC address, and no RX timestamps will be 714 + * taken either (presumably because it is a cascaded port and a 715 + * downstream SJA switch already did that). 716 + * To disable the feature, we need to do different things depending on 717 + * switch generation. On SJA1105 we need to set an invalid port, while 718 + * on SJA1110 which support multiple cascaded ports, this field is a 719 + * bitmask so it must be left zero. 720 + */ 721 + if (!priv->info->multiple_cascade_ports) 722 + general_params->casc_port = ds->num_ports; 702 723 703 724 return 0; 704 725 }
+4
drivers/net/dsa/sja1105/sja1105_spi.c
··· 763 763 .regs = &sja1110_regs, 764 764 .qinq_tpid = ETH_P_8021AD, 765 765 .can_limit_mcast_flood = true, 766 + .multiple_cascade_ports = true, 766 767 .ptp_ts_bits = 32, 767 768 .ptpegr_ts_bytes = 8, 768 769 .max_frame_mem = SJA1110_MAX_FRAME_MEMORY, ··· 809 808 .regs = &sja1110_regs, 810 809 .qinq_tpid = ETH_P_8021AD, 811 810 .can_limit_mcast_flood = true, 811 + .multiple_cascade_ports = true, 812 812 .ptp_ts_bits = 32, 813 813 .ptpegr_ts_bytes = 8, 814 814 .max_frame_mem = SJA1110_MAX_FRAME_MEMORY, ··· 855 853 .regs = &sja1110_regs, 856 854 .qinq_tpid = ETH_P_8021AD, 857 855 .can_limit_mcast_flood = true, 856 + .multiple_cascade_ports = true, 858 857 .ptp_ts_bits = 32, 859 858 .ptpegr_ts_bytes = 8, 860 859 .max_frame_mem = SJA1110_MAX_FRAME_MEMORY, ··· 901 898 .regs = &sja1110_regs, 902 899 .qinq_tpid = ETH_P_8021AD, 903 900 .can_limit_mcast_flood = true, 901 + .multiple_cascade_ports = true, 904 902 .ptp_ts_bits = 32, 905 903 .ptpegr_ts_bytes = 8, 906 904 .max_frame_mem = SJA1110_MAX_FRAME_MEMORY,