OpenCloudOS-Kernel/net/dsa
Vladimir Oltean 6565243c06 net: mscc: ocelot: add locking for the port TX timestamp ID
The ocelot_port->ts_id is used to:
(a) populate skb->cb[0] for matching the TX timestamp in the PTP IRQ
    with an skb.
(b) populate the REW_OP from the injection header of the ongoing skb.
Only then is ocelot_port->ts_id incremented.

This is a problem because, at least theoretically, another timestampable
skb might use the same ocelot_port->ts_id before that is incremented.
Normally all transmit calls are serialized by the netdev transmit
spinlock, but in this case, ocelot_port_add_txtstamp_skb() is also
called by DSA, which has started declaring the NETIF_F_LLTX feature
since commit 2b86cb8299 ("net: dsa: declare lockless TX feature for
slave ports").  So the logic of using and incrementing the timestamp id
should be atomic per port.

The solution is to use the global ocelot_port->ts_id only while
protected by the associated ocelot_port->ts_id_lock. That's where we
populate skb->cb[0]. Note that for ocelot, ocelot_port_add_txtstamp_skb
is called for the actual skb, but for felix, it is called for the skb's
clone. That is something which will also be changed in the future.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-18 13:52:33 -07:00
..
Kconfig net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag 2020-07-08 15:36:19 -07:00
Makefile net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag 2020-07-08 15:36:19 -07:00
dsa.c net: dsa: introduce a dsa_port_from_netdev public helper 2020-05-07 17:31:57 -07:00
dsa2.c net: dsa: of: Allow ethernet-ports as encapsulating node 2020-07-22 16:56:43 -07:00
dsa_priv.h net: dsa: Add __percpu property to prevent warnings 2020-07-05 15:31:58 -07:00
master.c net: dsa: stop overriding master's ndo_get_phys_port_name 2020-07-23 15:14:58 -07:00
port.c net: dsa: provide an option for drivers to always receive bridge VLANs 2020-05-12 13:08:07 -07:00
slave.c net: dsa: link interfaces with the DSA master to get rid of lockdep warnings 2020-09-08 19:40:09 -07:00
switch.c net: dsa: permit cross-chip bridging between all trees in the system 2020-05-10 19:52:33 -07:00
tag_8021q.c net: dsa: tag_8021q: stop restoring VLANs from bridge 2020-05-29 16:45:46 -07:00
tag_ar9331.c net: dsa: tag_ar9331: Make sure there is headroom for tag 2020-02-14 07:34:51 -08:00
tag_brcm.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-03-25 18:58:11 -07:00
tag_dsa.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_edsa.c dsa: Allow forwarding of redirected IGMP traffic 2020-06-24 14:39:43 -07:00
tag_gswip.c net: dsa: tag_gswip: fix typo in tagger name 2020-01-16 13:58:26 +01:00
tag_ksz.c net: dsa: tag_ksz: Fix __be16 warnings 2020-07-05 15:31:58 -07:00
tag_lan9303.c net: dsa: tag_lan9303: Fix __be16 warnings 2020-07-05 15:31:58 -07:00
tag_mtk.c net: dsa: tag_mtk: Fix warnings for __be16 2020-07-05 15:31:58 -07:00
tag_ocelot.c net: mscc: ocelot: add locking for the port TX timestamp ID 2020-09-18 13:52:33 -07:00
tag_qca.c net: dsa: tag_qca.c: Fix warning for __be16 vs u16 2020-07-05 15:31:58 -07:00
tag_rtl4_a.c net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag 2020-07-08 15:36:19 -07:00
tag_sja1105.c net: dsa: tag_sja1105: appease sparse checks for ethertype accessors 2020-05-12 18:02:42 -07:00
tag_trailer.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00