tag_8021q for Ocelot switches
Subsystems (4)
Vladimir Oltean
maintainerPATCH v3 4/15 net: dsa: felix: add new VLAN-based tagger
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
There are use cases for which the existing tagger, based on the NPI (Node Processor Interface) functionality, is insufficient.
Namely:
- Frames injected through the NPI port bypass the frame analyzer, so no source address learning is performed, no TSN stream classification, etc.
- Flow control is not functional over an NPI port (PAUSE frames are encapsulated in the same Extraction Frame Header as all other frames)
- There can be at most one NPI port configured for an Ocelot switch. But in NXP LS1028A and T1040 there are two Ethernet CPU ports. The non-NPI port is currently either disabled, or operated as a plain user port (albeit an internally-facing one). Having the ability to configure the two CPU ports symmetrically could pave the way for e.g. creating a LAG between them, to increase bandwidth seamlessly for the system.
So, there is a desire to have an alternative to the NPI mode.
This patch brings an implementation of the software-defined tag_8021q.c tagger format, which also preserves full functionality under a vlan_filtering bridge (unlike sja1105, the only other user of tag_8021q).
It does this by using the TCAM engines for:
- pushing the RX VLAN as a second, outer tag, on egress towards the CPU port
- redirecting towards the correct front port based on TX VLAN and popping that on egress
---
Changes in v3:
- Use a per-port bool is_dsa_8021q_cpu instead of a single dsa_8021q_cpu variable, to be compatible with future work where there may be potentially multiple tag_8021q CPU ports in a LAG.
- Initialize ocelot->npi = -1 in felix_8021q_cpu_port_init to ensure we don't mistakenly trigger NPI-specific code in ocelot.
Changes in v2:
Clean up the hardcoding of random VCAP filter IDs and the inclusion of a private ocelot header.
MAINTAINERS | 1 + drivers/net/dsa/ocelot/Kconfig | 4 +- drivers/net/dsa/ocelot/Makefile | 5 + drivers/net/dsa/ocelot/felix.c | 108 ++++++++++++-- drivers/net/dsa/ocelot/felix.h | 1 + drivers/net/dsa/ocelot/felix_tag_8021q.c | 173 +++++++++++++++++++++++ drivers/net/dsa/ocelot/felix_tag_8021q.h | 20 +++ drivers/net/ethernet/mscc/ocelot.c | 32 +++-- include/soc/mscc/ocelot.h | 1 + net/dsa/Kconfig | 34 +++++ net/dsa/Makefile | 3 +- net/dsa/tag_ocelot_8021q.c | 61 ++++++++ 12 files changed, 419 insertions(+), 24 deletions(-) create mode 100644 drivers/net/dsa/ocelot/felix_tag_8021q.c create mode 100644 drivers/net/dsa/ocelot/felix_tag_8021q.h create mode 100644 net/dsa/tag_ocelot_8021q.c
MAINTAINERS +1 -0
@@ -12842,6 +12842,7 @@ F: drivers/net/dsa/ocelot/* F: drivers/net/ethernet/mscc/ F: include/soc/mscc/ocelot* F: net/dsa/tag_ocelot.c +F: net/dsa/tag_ocelot_8021q.c F: tools/testing/selftests/drivers/net/ocelot/* OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER
drivers/net/dsa/ocelot/Kconfig +2 -2
@@ -2,11 +2,11 @@ config NET_DSA_MSCC_FELIX tristate "Ocelot / Felix Ethernet switch support" depends on NET_DSA && PCI + depends on NET_DSA_TAG_OCELOT_NPI || NET_DSA_TAG_OCELOT_8021Q depends on NET_VENDOR_MICROSEMI depends on NET_VENDOR_FREESCALE depends on HAS_IOMEM select MSCC_OCELOT_SWITCH_LIB - select NET_DSA_TAG_OCELOT select FSL_ENETC_MDIO select PCS_LYNX help
@@ -16,10 +16,10 @@ config NET_DSA_MSCC_FELIX config NET_DSA_MSCC_SEVILLE tristate "Ocelot / Seville Ethernet switch support" depends on NET_DSA + depends on NET_DSA_TAG_OCELOT_NPI || NET_DSA_TAG_OCELOT_8021Q depends on NET_VENDOR_MICROSEMI depends on HAS_IOMEM select MSCC_OCELOT_SWITCH_LIB - select NET_DSA_TAG_OCELOT select PCS_LYNX help This driver supports the VSC9953 (Seville) switch, which is embedded
drivers/net/dsa/ocelot/Makefile +5 -0
@@ -9,3 +9,8 @@ mscc_felix-objs := \ mscc_seville-objs := \ felix.o \ seville_vsc9953.o + +ifdef CONFIG_NET_DSA_TAG_OCELOT_8021Q +mscc_felix-objs += felix_tag_8021q.o +mscc_seville-objs += felix_tag_8021q.o +endif
drivers/net/dsa/ocelot/felix.c +95 -13
158 lines not on this page · raw message
drivers/net/dsa/ocelot/felix.h +1 -0
@@ -48,6 +48,7 @@ struct felix {struct lynx_pcs **pcs;resource_size_t switch_base;resource_size_t imdio_base; +struct dsa_8021q_context *dsa_8021q_ctx; };struct net_device *felix_port_to_netdev (struct ocelot *ocelot,int port);
drivers/net/dsa/ocelot/felix_tag_8021q.c new file +173 -0
173 lines not on this page · raw message
drivers/net/dsa/ocelot/felix_tag_8021q.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2020-2021 NXP Semiconductors +*/ +#ifndef _MSCC_FELIX_TAG_8021Q_H +#define _MSCC_FELIX_TAG_8021Q_H + +#if IS_ENABLED (CONFIG_NET_DSA_TAG_OCELOT_8021Q ) + +int felix_setup_8021q_tagging (struct ocelot *ocelot); + +#else + +static inline int felix_setup_8021q_tagging (struct ocelot *ocelot) +{ +return -EOPNOTSUPP ; +} + +#endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_OCELOT_8021Q) */ + +#endif /* _MSCC_FELIX_TAG_8021Q_H */
drivers/net/ethernet/mscc/ocelot.c +24 -8
@@ -878,6 +878,7 @@ EXPORT_SYMBOL(ocelot_get_ts_info);void ocelot_bridge_stp_state_set (struct ocelot *ocelot,int port,u8 state) { +unsigned long cpu_fwd_mask =0 ;u32 port_cfg;int p, i;
@@ -902,12 +903,31 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state)ocelot_write_gix (ocelot, port_cfg,ANA_PORT_PORT_CFG , port); +/* If a DSA tag_8021q CPU exists, it needs to be unconditionally +* (i.e. regardless of whether the port is bridged or standalone) +* included in the regular forwarding path, as opposed to the +* hardware-based CPU port module which can be a destination for +* packets even if it isn't part of PGID_SRC. +*/ +for (p =0 ; p < ocelot->num_phys_ports; p++) +if (ocelot->ports[p]->is_dsa_8021q_cpu) + cpu_fwd_mask |=BIT (p); +/* Apply FWD mask. The loop is needed to add/remove the current port as * a source for the other ports. */ for (p =0 ; p < ocelot->num_phys_ports; p++) { -if (ocelot->bridge_fwd_mask &BIT (p)) { -unsigned long mask = ocelot->bridge_fwd_mask & ~BIT (p); +/* Standalone ports forward only to DSA tag_8021q CPU ports */ +unsigned long mask = cpu_fwd_mask; + +/* The DSA tag_8021q CPU ports need to be able to forward +* packets to all other ports except for themselves +*/ +if (ocelot->ports[p]->is_dsa_8021q_cpu) { + mask =GENMASK (ocelot->num_phys_ports -1 ,0 ); + mask &= ~cpu_fwd_mask; + }else if (ocelot->bridge_fwd_mask &BIT (p)) { + mask |= ocelot->bridge_fwd_mask & ~BIT (p);for (i =0 ; i < ocelot->num_phys_ports; i++) {unsigned long bond_mask = ocelot->lags[i];
@@ -920,13 +940,9 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state)break ; } } - -ocelot_write_rix (ocelot, mask, -ANA_PGID_PGID ,PGID_SRC + p); - }else { -ocelot_write_rix (ocelot,0 , -ANA_PGID_PGID ,PGID_SRC + p); } + +ocelot_write_rix (ocelot, mask,ANA_PGID_PGID ,PGID_SRC + p); } }EXPORT_SYMBOL (ocelot_bridge_stp_state_set);
include/soc/mscc/ocelot.h +1 -0
@@ -610,6 +610,7 @@ struct ocelot_port {phy_interface_t phy_mode;u8 *xmit_template; +bool is_dsa_8021q_cpu; };struct ocelot {
net/dsa/Kconfig +34 -0
@@ -111,6 +111,40 @@ config NET_DSA_TAG_OCELOT Say Y or M if you want to enable support for tagging frames for the Ocelot switches (VSC7511, VSC7512, VSC7513, VSC7514, VSC9959). +choice + prompt "Tagging format" + depends on NET_DSA_TAG_OCELOT + default NET_DSA_TAG_OCELOT_NPI + help + Choose the tagging format for frames delivered by the Ocelot + switches to the CPU. + +config NET_DSA_TAG_OCELOT_NPI + bool "Native tagging over NPI" + help + Say Y if you want to enable NPI tagging for the Ocelot switches. + In this mode, the frames over the Ethernet CPU port are prepended + with a hardware-defined injection/extraction frame header. + Flow control (PAUSE frames) over the CPU port is not supported + when operating in this mode. + + If unsure, say Y. + +config NET_DSA_TAG_OCELOT_8021Q + bool "VLAN-based tagging" + select NET_DSA_TAG_8021Q + help + Say Y if you want to enable support for tagging frames with a custom + VLAN-based header. Frames that require timestamping, such as PTP, are + not delivered over Ethernet but over register-based MMIO. Flow + control over the CPU port is functional in this mode. When using this + mode, less TCAM resources (VCAP IS1, IS2, ES0) are available for use + with tc-flower. + + If unsure, say N. + +endchoice + config NET_DSA_TAG_QCA tristate "Tag driver for Qualcomm Atheros QCA8K switches" help
net/dsa/Makefile +2 -1
@@ -14,7 +14,8 @@ obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o -obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o +obj-$(CONFIG_NET_DSA_TAG_OCELOT_NPI) += tag_ocelot.o +obj-$(CONFIG_NET_DSA_TAG_OCELOT_8021Q) += tag_ocelot_8021q.o obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
net/dsa/tag_ocelot_8021q.c new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 5/15 net: mscc: ocelot: stop returning IRQ_NONE in ocelot_xtr_irq_handler
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Since the xtr (extraction) IRQ of the ocelot switch is not shared, then if it fired, it means that some data must be present in the queues of the CPU port module. So simplify the code.
---
Changes in v2:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/mscc/ocelot_vsc7514.c +2 -5
@@ -604,10 +604,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)int i =0 , grp =0 ;int err =0 ; -if (!(ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp))) -return IRQ_NONE ; - - do { +while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp)) {struct skb_shared_hwtstamps *shhwtstamps;struct ocelot_port_private *priv;struct ocelot_port *ocelot_port;
@@ -702,7 +699,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)netif_rx (skb); dev->stats.rx_bytes += len; dev->stats.rx_packets++; - }while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp)); + }if (err)while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp))
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 13/15 net: dsa: felix: setup MMIO filtering rules for PTP when using tag_8021q
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Since the tag_8021q tagger is software-defined, it has no means by itself for retrieving hardware timestamps of PTP event messages.
Because we do want to support PTP on ocelot even with tag_8021q, we need to use the CPU port module for that. The RX timestamp is present in the Extraction Frame Header. And because we can't use NPI mode which redirects the CPU queues to an "external CPU" (meaning the ARM CPU running Linux), then we need to poll the CPU port module through the MMIO registers to retrieve TX and RX timestamps.
Sadly, on NXP LS1028A, the Felix switch was integrated into the SoC without wiring the extraction IRQ line to the ARM GIC. So, if we want to be notified of any PTP packets received on the CPU port module, we have a problem.
There is a possible workaround, which is to use the Ethernet CPU port as a notification channel that packets are available on the CPU port module as well. When a PTP packet is received by the DSA tagger (without timestamp, of course), we go to the CPU extraction queues, poll for it there, then we drop the original Ethernet packet and masquerade the packet retrieved over MMIO (plus the timestamp) as the original when we inject it up the stack.
Create a quirk in struct felix is selected by the Felix driver (but not by Seville, since that doesn't support PTP at all). We want to do this such that the workaround is minimally invasive for future switches that don't require this workaround.
The only traffic for which we need timestamps is PTP traffic, so add a redirection rule to the CPU port module for this. Currently we only have the need for PTP over L2, so redirection rules for UDP ports 319 and 320 are TBD for now.
---
Changes in v3:
Make as much use as possible of dsa_is_cpu_port and dsa_upstream_port as possible instead of ocelot->dsa_8021q_cpu.
Changes in v2:
Patch is new.
drivers/net/dsa/ocelot/felix.h | 13 ++++ drivers/net/dsa/ocelot/felix_tag_8021q.c | 88 +++++++++++++++++++++++- drivers/net/dsa/ocelot/felix_vsc9959.c | 1 + 3 files changed, 101 insertions(+), 1 deletion(-)
drivers/net/dsa/ocelot/felix.h +13 -0
@@ -23,6 +23,19 @@ struct felix_info {int switch_pci_bar;int imdio_pci_bar;const struct ptp_clock_info *ptp_caps; + +/* Some Ocelot switches are integrated into the SoC without the +* extraction IRQ line connected to the ARM GIC. By enabling this +* workaround, the few packets that are delivered to the CPU port +* module (currently only PTP) are copied not only to the hardware CPU +* port module, but also to the 802.1Q Ethernet CPU port, and polling +* the extraction registers is triggered once the DSA tagger sees a PTP +* frame. The Ethernet frame is only used as a notification: it is +* dropped, and the original frame is extracted over MMIO and annotated +* with the RX timestamp. +*/ +bool quirk_no_xtr_irq; +int (*mdio_bus_alloc)(struct ocelot *ocelot);void (*mdio_bus_free)(struct ocelot *ocelot); void (*phylink_validate)(struct ocelot *ocelot, int port,
drivers/net/dsa/ocelot/felix_tag_8021q.c +87 -1
99 lines not on this page · raw message
drivers/net/dsa/ocelot/felix_vsc9959.c +1 -0
@@ -1379,6 +1379,7 @@ static const struct felix_info felix_info_vsc9959 = { .num_tx_queues = OCELOT_NUM_TC, .switch_pci_bar = 4, .imdio_pci_bar = 0, + .quirk_no_xtr_irq = true, .ptp_caps = &vsc9959_ptp_caps, .mdio_bus_alloc = vsc9959_mdio_bus_alloc, .mdio_bus_free = vsc9959_mdio_bus_free,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 15/15 net: dsa: tag_ocelot_8021q: add support for PTP timestamping
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
On TX, use the result of the ptp_classify_raw() BPF classifier from dsa_skb_tx_timestamp() to divert some frames over to the MMIO-based injection registers.
On RX, set up a VCAP IS2 rule that redirects the frames with an EtherType for 1588 to the CPU port module (for MMIO based extraction) and, if the "no XTR IRQ" workaround is in place, copies them to the dsa_8021q CPU port as well (for notification).
There is a conflict between the VCAP IS2 trapping rule and the semantics of the BPF classifier. Namely, ptp_classify_raw() deems general messages as non-timestampable, but still, those are trapped to the CPU port module since they have an EtherType of ETH_P_1588. So, if the "no XTR IRQ" workaround is in place, we need to run another BPF classifier on the frames extracted over MMIO, to avoid duplicates being sent to the stack (once over Ethernet, once over MMIO). It doesn't look like it's possible to install VCAP IS2 rules based on keys extracted from the 1588 frame headers.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/dsa/ocelot/felix.c | 12 +++++ drivers/net/dsa/ocelot/felix_tag_8021q.c | 61 ++++++++++++++++++++++++ drivers/net/dsa/ocelot/felix_tag_8021q.h | 7 +++ drivers/net/ethernet/mscc/ocelot.c | 3 ++ drivers/net/ethernet/mscc/ocelot.h | 8 ---- include/soc/mscc/ocelot.h | 9 ++++ net/dsa/tag_ocelot_8021q.c | 24 ++++++++++ 7 files changed, 116 insertions(+), 8 deletions(-)
drivers/net/dsa/ocelot/felix.c +12 -0
@@ -733,6 +733,18 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port,struct timespec64 ts;u64 tstamp, val; +/* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb +* for RX timestamping. Then free it, and poll for its copy through +* MMIO in the CPU port module, and inject that into the stack from +* ocelot_xtr_poll(). +* If the "no XTR IRQ" workaround isn't in use, this is a no-op and +* should be eliminated by the compiler as dead code. +*/ +if (felix_check_xtr_pkt (ocelot, type)) { +kfree_skb (skb); +return true; + } +ocelot_ptp_gettime64 (&ocelot->ptp_info, &ts); tstamp =ktime_set (ts.tv_sec, ts.tv_nsec);
drivers/net/dsa/ocelot/felix_tag_8021q.c +61 -0
70 lines not on this page · raw message
drivers/net/dsa/ocelot/felix_tag_8021q.h +7 -0
@@ -7,6 +7,7 @@#if IS_ENABLED (CONFIG_NET_DSA_TAG_OCELOT_8021Q )int felix_setup_8021q_tagging (struct ocelot *ocelot); +bool felix_check_xtr_pkt (struct ocelot *ocelot,unsigned int ptp_type);#else
@@ -15,6 +16,12 @@ static inline int felix_setup_8021q_tagging(struct ocelot *ocelot)return -EOPNOTSUPP ; } +static inline bool felix_check_xtr_pkt (struct ocelot *ocelot, +unsigned int ptp_type) +{ +return false; +} +#endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_OCELOT_8021Q) */ #endif /* _MSCC_FELIX_TAG_8021Q_H */
drivers/net/ethernet/mscc/ocelot.c +3 -0
@@ -646,6 +646,7 @@ int ocelot_xtr_poll_xfh(struct ocelot *ocelot, int grp,return 0 ; } +EXPORT_SYMBOL (ocelot_xtr_poll_xfh); int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct net_device *dev,
@@ -723,6 +724,7 @@ int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, out:return err; } +EXPORT_SYMBOL (ocelot_xtr_poll_frame);/* Generate the IFH for frame injection *
@@ -801,6 +803,7 @@ void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp, skb->dev->stats.tx_packets++; skb->dev->stats.tx_bytes += skb->len; } +EXPORT_SYMBOL (ocelot_port_inject_frame);int ocelot_fdb_add (struct ocelot *ocelot,int port,const unsigned char *addr,u16 vid)
drivers/net/ethernet/mscc/ocelot.h +0 -8
@@ -119,14 +119,6 @@ int ocelot_port_devlink_init(struct ocelot *ocelot, int port,void ocelot_port_devlink_teardown (struct ocelot *ocelot,int port);bool ocelot_can_inject (struct ocelot *ocelot,int grp); -void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp, -u32 rew_op,struct sk_buff *skb); -int ocelot_xtr_poll_xfh (struct ocelot *ocelot,int grp, -struct ocelot_frame_info *info); -int ocelot_xtr_poll_frame (struct ocelot *ocelot,int grp, -struct net_device *dev, -struct ocelot_frame_info *info, -struct sk_buff **skb);extern struct notifier_block ocelot_netdevice_nb;extern struct notifier_block ocelot_switchdev_nb;
include/soc/mscc/ocelot.h +9 -0
@@ -840,4 +840,13 @@ int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,enum devlink_sb_pool_type pool_type, u32 *p_cur, u32 *p_max); +void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp, +u32 rew_op,struct sk_buff *skb); +int ocelot_xtr_poll_xfh (struct ocelot *ocelot,int grp, +struct ocelot_frame_info *info); +int ocelot_xtr_poll_frame (struct ocelot *ocelot,int grp, +struct net_device *dev, +struct ocelot_frame_info *info, +struct sk_buff **skb); +#endif
net/dsa/tag_ocelot_8021q.c +24 -0
@@ -2,6 +2,8 @@/* Copyright 2020-2021 NXP Semiconductors */ #include <linux/dsa/8021q.h> +#include <soc/mscc/ocelot.h> +#include <soc/mscc/ocelot_ptp.h> #include "dsa_priv.h" static struct sk_buff *ocelot_xmit(struct sk_buff *skb,
@@ -11,6 +13,28 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb,u16 tx_vid =dsa_8021q_tx_vid (dp->ds, dp->index);u16 queue_mapping =skb_get_queue_mapping (skb);u8 pcp =netdev_txq_to_tc (netdev, queue_mapping); +struct sk_buff *clone =DSA_SKB_CB (skb)->clone; + +/* TX timestamping was requested, so inject through MMIO */ +if (clone) { +struct ocelot *ocelot = dp->ds->priv; +struct ocelot_port *ocelot_port; +int port = dp->index; +u32 rew_op; + + ocelot_port = ocelot->ports[port]; + rew_op = ocelot_port->ptp_cmd; + +/* Retrieve timestamp ID populated inside skb->cb[0] of the +* clone by ocelot_port_add_txtstamp_skb +*/ +if (ocelot_port->ptp_cmd ==IFH_REW_OP_TWO_STEP_PTP ) + rew_op |= clone->cb[0 ] <<3 ; + +ocelot_port_inject_frame (ocelot, dp->index,0 , rew_op, skb); + +return NULL ; + }return dsa_8021q_xmit (skb, netdev,ETH_P_8021Q , ((pcp <<VLAN_PRIO_SHIFT ) | tx_vid));
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 14/15 net: dsa: felix: use promisc on master for PTP with tag_8021q
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This is for the "no extraction IRQ" workaround, where the DSA master on LS1028A (enetc) serves as a de-facto irqchip.
It needs to be promiscuous so that it will never drop a PTP frame (sent to the 01-80-c2-00-00-0e multicast MAC address), otherwise the tagger will get confused about which Ethernet PTP frame corresponds to which PTP frame over the MMIO registers.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
net/dsa/tag_ocelot_8021q.c | 1 + 1 file changed, 1 insertion(+)
net/dsa/tag_ocelot_8021q.c +1 -0
@@ -53,6 +53,7 @@ static struct dsa_device_ops ocelot_netdev_ops = { .xmit = ocelot_xmit, .rcv = ocelot_rcv, .overhead = VLAN_HLEN, + .promisc_on_master = true, };MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 12/15 net: mscc: ocelot: refactor ocelot_xtr_irq_handler into ocelot_xtr_poll
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Since the felix DSA driver will need to poll the CPU port module for extracted frames as well, let's create some common functions that read an Extraction Frame Header, and then an skb, from a CPU extraction group.
This is so complicated, because the procedure to retrieve a struct net_device pointer based on the source port is different for DSA and switchdev. So this is the reason why the polling function is split in the middle. The ocelot_xtr_poll_xfh() permits the caller to get a struct net_device pointer based on the XFH port field, then pass this to the ocelot_xtr_poll_frame() function.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot.c | 163 +++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.h | 6 + drivers/net/ethernet/mscc/ocelot_vsc7514.c | 158 ++------------------ 3 files changed, 179 insertions(+), 148 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +163 -0
@@ -12,6 +12,9 @@#define TABLE_UPDATE_SLEEP_US 10#define TABLE_UPDATE_TIMEOUT_US 100000 +#define IFH_EXTRACT_BITFIELD64 (x, o, w) \ + (((x) >> (o)) & GENMASK_ULL((w) - 1, 0)) +struct ocelot_mact_entry {u8 mac[ETH_ALEN ];u16 vid;
@@ -561,6 +564,166 @@ void ocelot_get_txtstamp(struct ocelot *ocelot) }EXPORT_SYMBOL (ocelot_get_txtstamp); +static int ocelot_parse_xfh (u32 *_ifh,struct ocelot_frame_info *info) +{ +u8 llen, wlen; +u64 ifh[2 ]; + + ifh[0 ] =be64_to_cpu (((__force __be64 *)_ifh)[0 ]); + ifh[1 ] =be64_to_cpu (((__force __be64 *)_ifh)[1 ]); + + wlen =IFH_EXTRACT_BITFIELD64 (ifh[0 ],7 ,8 ); + llen =IFH_EXTRACT_BITFIELD64 (ifh[0 ],15 ,6 ); + + info->len =OCELOT_BUFFER_CELL_SZ * wlen + llen -80 ; + + info->timestamp =IFH_EXTRACT_BITFIELD64 (ifh[0 ],21 ,32 ); + + info->port =IFH_EXTRACT_BITFIELD64 (ifh[1 ],43 ,4 ); + + info->tag_type =IFH_EXTRACT_BITFIELD64 (ifh[1 ],16 ,1 ); + info->vid =IFH_EXTRACT_BITFIELD64 (ifh[1 ],0 ,12 ); + +return 0 ; +} + +static int ocelot_rx_frame_word (struct ocelot *ocelot,u8 grp,bool ifh, +u32 *rval) +{ +u32 val; +u32 bytes_valid; + + val =ocelot_read_rix (ocelot,QS_XTR_RD , grp); +if (val ==XTR_NOT_READY ) { +if (ifh) +return -EIO ; + +do { + val =ocelot_read_rix (ocelot,QS_XTR_RD , grp); + }while (val ==XTR_NOT_READY ); + } + +switch (val) { +case XTR_ABORT : +return -EIO ; +case XTR_EOF_0 : +case XTR_EOF_1 : +case XTR_EOF_2 : +case XTR_EOF_3 : +case XTR_PRUNED : + bytes_valid =XTR_VALID_BYTES (val); + val =ocelot_read_rix (ocelot,QS_XTR_RD , grp); +if (val ==XTR_ESCAPE ) + *rval =ocelot_read_rix (ocelot,QS_XTR_RD , grp); +else + *rval = val; + +return bytes_valid; +case XTR_ESCAPE : + *rval =ocelot_read_rix (ocelot,QS_XTR_RD , grp); + +return 4 ; +default : + *rval = val; + +return 4 ; + } +} + +int ocelot_xtr_poll_xfh (struct ocelot *ocelot,int grp, +struct ocelot_frame_info *info) +{ +u32 ifh[OCELOT_TAG_LEN /4 ]; +int i, err =0 ; + +for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++) { + err =ocelot_rx_frame_word (ocelot, grp, true, &ifh[i]); +if (err !=4 ) +return (err <0 ) ? err : -EIO ; + } + +ocelot_parse_xfh (ifh, info); + +return 0 ; +} + +int ocelot_xtr_poll_frame (struct ocelot *ocelot,int grp, +struct net_device *dev, +struct ocelot_frame_info *info, +struct sk_buff **nskb) +{ +struct skb_shared_hwtstamps *shhwtstamps; +u64 tod_in_ns, full_ts_in_ns; +struct timespec64 ts; +int sz, len, buf_len; +struct sk_buff *skb; +u32 val, *buf; +int err =0 ; + + skb =netdev_alloc_skb (dev, info->len); +if (unlikely (!skb)) { +netdev_err (dev,"Unable to allocate sk_buff\n" ); + err = -ENOMEM ; + goto out; + } + + buf_len = info->len -ETH_FCS_LEN ; + buf = (u32 *)skb_put (skb, buf_len); + + len =0 ; +do { + sz =ocelot_rx_frame_word (ocelot, grp, false, &val); +if (sz <0 ) { + err = sz; + goto out; + } + *buf++ = val; + len += sz; + }while (len < buf_len); + +/* Read the FCS */ + sz =ocelot_rx_frame_word (ocelot, grp, false, &val); +if (sz <0 ) { + err = sz; + goto out; + } + +/* Update the statistics if part of the FCS was read before */ + len -=ETH_FCS_LEN - sz; + +if (unlikely (dev->features &NETIF_F_RXFCS )) { + buf = (u32 *)skb_put (skb,ETH_FCS_LEN ); + *buf = val; + } + +if (ocelot->ptp) { +ocelot_ptp_gettime64 (&ocelot->ptp_info, &ts); + + tod_in_ns =ktime_set (ts.tv_sec, ts.tv_nsec); +if ((tod_in_ns &0xffffffff ) < info->timestamp) + full_ts_in_ns = (((tod_in_ns >>32 ) -1 ) <<32 ) | + info->timestamp; +else + full_ts_in_ns = (tod_in_ns &GENMASK_ULL (63 ,32 )) | + info->timestamp; + + shhwtstamps =skb_hwtstamps (skb); +memset (shhwtstamps,0 ,sizeof (struct skb_shared_hwtstamps )); + shhwtstamps->hwtstamp = full_ts_in_ns; + } + +/* Everything we see on an interface that is in the HW bridge +* has already been forwarded. +*/ +if (ocelot->bridge_mask &BIT (info->port)) + skb->offload_fwd_mark =1 ; + + skb->protocol =eth_type_trans (skb, dev); + *nskb = skb; +out: +return err; +} +/* Generate the IFH for frame injection * * The IFH is a 128bit-value
drivers/net/ethernet/mscc/ocelot.h +6 -0
@@ -121,6 +121,12 @@ void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);bool ocelot_can_inject (struct ocelot *ocelot,int grp);void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp,u32 rew_op,struct sk_buff *skb); +int ocelot_xtr_poll_xfh (struct ocelot *ocelot,int grp, +struct ocelot_frame_info *info); +int ocelot_xtr_poll_frame (struct ocelot *ocelot,int grp, +struct net_device *dev, +struct ocelot_frame_info *info, +struct sk_buff **skb);extern struct notifier_block ocelot_netdevice_nb;extern struct notifier_block ocelot_switchdev_nb;
drivers/net/ethernet/mscc/ocelot_vsc7514.c +10 -148
191 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 7/15 net: mscc: ocelot: just flush the CPU extraction group on error
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This procedure should yield the same effect as manually reading out the extraction data just to discard it.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mscc/ocelot_vsc7514.c +4 -3
@@ -701,9 +701,10 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) dev->stats.rx_packets++; } -if (err <0 ) -while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp)) -ocelot_read_rix (ocelot,QS_XTR_RD , grp); +if (err <0 ) { +ocelot_write (ocelot,QS_XTR_FLUSH ,BIT (grp)); +ocelot_write (ocelot,QS_XTR_FLUSH ,0 ); + }return IRQ_HANDLED ; }
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 11/15 net: mscc: ocelot: export struct ocelot_frame_info
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
Because felix DSA must now be able to extract a frame in 2 stages over MMIO (first the XFH then the frame data), it needs access to this internal ocelot structure that holds the unpacked information from the Extraction Frame Header.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot.c | 4 ++-- drivers/net/ethernet/mscc/ocelot.h | 9 --------- drivers/net/ethernet/mscc/ocelot_vsc7514.c | 4 ++-- include/soc/mscc/ocelot.h | 9 +++++++++ 4 files changed, 13 insertions(+), 13 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +2 -2
@@ -571,7 +571,7 @@ EXPORT_SYMBOL(ocelot_get_txtstamp);* bit 16: tag type 0: C-tag, 1: S-tag * bit 0-11: VID */ -static int ocelot_gen_ifh (u32 *ifh,struct frame_info *info) +static int ocelot_gen_ifh (u32 *ifh,struct ocelot_frame_info *info) { ifh[0 ] =IFH_INJ_BYPASS | ((0x1ff & info->rew_op) <<21 ); ifh[1 ] = (0xf00 & info->port) >>8 ;
@@ -596,7 +596,7 @@ bool ocelot_can_inject(struct ocelot *ocelot, int grp)void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp,u32 rew_op,struct sk_buff *skb) { -struct frame_info info = {}; +struct ocelot_frame_info info = {};u32 ifh[OCELOT_TAG_LEN /4 ];unsigned int i, count, last;
drivers/net/ethernet/mscc/ocelot.h +0 -9
@@ -32,15 +32,6 @@#define OCELOT_PTP_QUEUE_SZ 128 -struct frame_info { -u32 len; -u16 port; -u16 vid; -u8 tag_type; -u16 rew_op; -u32 timestamp;/* rew_val */ -}; -struct ocelot_port_tc {bool block_shared;unsigned long offload_cnt;
drivers/net/ethernet/mscc/ocelot_vsc7514.c +2 -2
@@ -532,7 +532,7 @@ static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)return 0 ; } -static int ocelot_parse_ifh (u32 *_ifh,struct frame_info *info) +static int ocelot_parse_ifh (u32 *_ifh,struct ocelot_frame_info *info) {u8 llen, wlen;u64 ifh[2 ];
@@ -606,10 +606,10 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp)) {struct skb_shared_hwtstamps *shhwtstamps; +struct ocelot_frame_info info = {};struct ocelot_port_private *priv;struct ocelot_port *ocelot_port;u64 tod_in_ns, full_ts_in_ns; -struct frame_info info = {};struct net_device *dev;u32 ifh[4 ], val, *buf;struct timespec64 ts;
include/soc/mscc/ocelot.h +9 -0
@@ -688,6 +688,15 @@ struct ocelot_policer {u32 burst;/* bytes */ }; +struct ocelot_frame_info { +u32 len; +u16 port; +u16 vid; +u8 tag_type; +u16 rew_op; +u32 timestamp;/* rew_val */ +}; +#define ocelot_read_ix (ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))#define ocelot_read_gix (ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))#define ocelot_read_rix (ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 10/15 net: mscc: ocelot: refactor ocelot_port_inject_frame out of ocelot_port_xmit
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The felix DSA driver will inject some frames through register MMIO, same as ocelot switchdev currently does. So we need to be able to reuse the common code.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot.c | 78 +++++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.h | 4 ++ drivers/net/ethernet/mscc/ocelot_net.c | 81 +++----------------------- 3 files changed, 89 insertions(+), 74 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +78 -0
@@ -561,6 +561,84 @@ void ocelot_get_txtstamp(struct ocelot *ocelot) }EXPORT_SYMBOL (ocelot_get_txtstamp); +/* Generate the IFH for frame injection +* +* The IFH is a 128bit-value +* bit 127: bypass the analyzer processing +* bit 56-67: destination mask +* bit 28-29: pop_cnt: 3 disables all rewriting of the frame +* bit 20-27: cpu extraction queue mask +* bit 16: tag type 0: C-tag, 1: S-tag +* bit 0-11: VID +*/ +static int ocelot_gen_ifh (u32 *ifh,struct frame_info *info) +{ + ifh[0 ] =IFH_INJ_BYPASS | ((0x1ff & info->rew_op) <<21 ); + ifh[1 ] = (0xf00 & info->port) >>8 ; + ifh[2 ] = (0xff & info->port) <<24 ; + ifh[3 ] = (info->tag_type <<16 ) | info->vid; + +return 0 ; +} + +bool ocelot_can_inject (struct ocelot *ocelot,int grp) +{ +u32 val =ocelot_read (ocelot,QS_INJ_STATUS ); + +if (!(val &QS_INJ_STATUS_FIFO_RDY (BIT (grp)))) +return false; +if (val &QS_INJ_STATUS_WMARK_REACHED (BIT (grp))) +return false; + +return true; +} + +void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp, +u32 rew_op,struct sk_buff *skb) +{ +struct frame_info info = {}; +u32 ifh[OCELOT_TAG_LEN /4 ]; +unsigned int i, count, last; + +ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) | +QS_INJ_CTRL_SOF ,QS_INJ_CTRL , grp); + + info.port =BIT (port); + info.tag_type =IFH_TAG_TYPE_C ; + info.vid =skb_vlan_tag_get (skb); + info.rew_op = rew_op; + +ocelot_gen_ifh (ifh, &info); + +for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++) +ocelot_write_rix (ocelot, (__force u32 )cpu_to_be32 (ifh[i]), +QS_INJ_WR , grp); + + count =DIV_ROUND_UP (skb->len,4 ); + last = skb->len %4 ; +for (i =0 ; i < count; i++) +ocelot_write_rix (ocelot, ((u32 *)skb->data)[i],QS_INJ_WR , grp); + +/* Add padding */ +while (i < (OCELOT_BUFFER_CELL_SZ /4 )) { +ocelot_write_rix (ocelot,0 ,QS_INJ_WR , grp); + i++; + } + +/* Indicate EOF and valid bytes in last word */ +ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) | +QS_INJ_CTRL_VLD_BYTES (skb->len <OCELOT_BUFFER_CELL_SZ ?0 : last) | +QS_INJ_CTRL_EOF , +QS_INJ_CTRL , grp); + +/* Add dummy CRC */ +ocelot_write_rix (ocelot,0 ,QS_INJ_WR , grp); +skb_tx_timestamp (skb); + + skb->dev->stats.tx_packets++; + skb->dev->stats.tx_bytes += skb->len; +} +int ocelot_fdb_add (struct ocelot *ocelot,int port,const unsigned char *addr,u16 vid) {
drivers/net/ethernet/mscc/ocelot.h +4 -0
@@ -127,6 +127,10 @@ int ocelot_port_devlink_init(struct ocelot *ocelot, int port, enum devlink_port_flavour flavour);void ocelot_port_devlink_teardown (struct ocelot *ocelot,int port); +bool ocelot_can_inject (struct ocelot *ocelot,int grp); +void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp, +u32 rew_op,struct sk_buff *skb); +extern struct notifier_block ocelot_netdevice_nb;extern struct notifier_block ocelot_switchdev_nb;extern struct notifier_block ocelot_switchdev_blocking_nb;
drivers/net/ethernet/mscc/ocelot_net.c +7 -74
105 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 8/15 net: mscc: ocelot: better error handling in ocelot_xtr_irq_handler
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The ocelot_rx_frame_word() function can return a negative error code, however this isn't being checked for consistently. Errors being ignored have not been seen in practice though.
Also, some constructs can be simplified by using "goto" instead of repeated "break" statements.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/net/ethernet/mscc/ocelot_vsc7514.c +12 -10
@@ -619,12 +619,9 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++) { err =ocelot_rx_frame_word (ocelot, grp, true, &ifh[i]);if (err !=4 ) -break ; + goto out; } -if (err !=4 ) -break ; -/* At this point the IFH was read correctly, so it is safe to * presume that there is no error. The err needs to be reset * otherwise a frame could come in CPU queue between the while
@@ -645,7 +642,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)if (unlikely (!skb)) {netdev_err (dev,"Unable to allocate sk_buff\n" ); err = -ENOMEM ; -break ; + goto out; } buf_len = info.len -ETH_FCS_LEN ; buf = (u32 *)skb_put (skb, buf_len);
@@ -653,12 +650,21 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) len =0 ;do { sz =ocelot_rx_frame_word (ocelot, grp, false, &val); +if (sz <0 ) { + err = sz; + goto out; + } *buf++ = val; len += sz; }while (len < buf_len);/* Read the FCS */ sz =ocelot_rx_frame_word (ocelot, grp, false, &val); +if (sz <0 ) { + err = sz; + goto out; + } +/* Update the statistics if part of the FCS was read before */ len -=ETH_FCS_LEN - sz;
@@ -667,11 +673,6 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) *buf = val; } -if (sz <0 ) { - err = sz; -break ; - } -if (ocelot->ptp) {ocelot_ptp_gettime64 (&ocelot->ptp_info, &ts);
@@ -701,6 +702,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) dev->stats.rx_packets++; } +out:if (err <0 ) {ocelot_write (ocelot,QS_XTR_FLUSH ,BIT (grp));ocelot_write (ocelot,QS_XTR_FLUSH ,0 );
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 3/15 net: mscc: ocelot: store a namespaced VCAP filter ID
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
We will be adding some private VCAP filters that should not interfere in any way with the filters added using tc-flower. So we need to allocate some IDs which will not be used by tc.
Currently ocelot uses an u32 id derived from the flow cookie, which in itself is an unsigned long. This is a problem in itself, since on 64 bit systems, sizeof(unsigned long)=8, so the driver is already truncating these.
Create a struct ocelot_vcap_id which contains the full unsigned long cookie from tc, as well as a boolean that is supposed to namespace the filters added by tc with the ones that aren't.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_flower.c | 7 ++++--- drivers/net/ethernet/mscc/ocelot_vcap.c | 16 ++++++++++++---- drivers/net/ethernet/mscc/ocelot_vcap.h | 3 ++- include/soc/mscc/ocelot_vcap.h | 7 ++++++- 4 files changed, 24 insertions(+), 9 deletions(-)
drivers/net/ethernet/mscc/ocelot_flower.c +4 -3
@@ -622,7 +622,8 @@ static int ocelot_flower_parse(struct ocelot *ocelot, int port, bool ingress,int ret; filter->prio = f->common.prio; - filter->id = f->cookie; + filter->id.cookie = f->cookie; + filter->id.tc_offload = true; ret =ocelot_flower_parse_action (ocelot, port, ingress, f, filter);if (ret)
@@ -717,7 +718,7 @@ int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port, block = &ocelot->block[block_id]; - filter =ocelot_vcap_block_find_filter_by_id (block, f->cookie); + filter =ocelot_vcap_block_find_filter_by_id (block, f->cookie, true);if (!filter)return 0 ;
@@ -741,7 +742,7 @@ int ocelot_cls_flower_stats(struct ocelot *ocelot, int port, block = &ocelot->block[block_id]; - filter =ocelot_vcap_block_find_filter_by_id (block, f->cookie); + filter =ocelot_vcap_block_find_filter_by_id (block, f->cookie, true);if (!filter || filter->type ==OCELOT_VCAP_FILTER_DUMMY )return 0 ;
drivers/net/ethernet/mscc/ocelot_vcap.c +12 -4
@@ -959,6 +959,12 @@ static void ocelot_vcap_filter_add_to_block(struct ocelot *ocelot,list_add (&filter->list, pos->prev); } +static bool ocelot_vcap_filter_equal (const struct ocelot_vcap_filter *a, +const struct ocelot_vcap_filter *b) +{ +return !memcmp (&a->id, &b->id,sizeof (struct ocelot_vcap_id )); +} +static int ocelot_vcap_block_get_filter_index (struct ocelot_vcap_block *block,struct ocelot_vcap_filter *filter) {
@@ -966,7 +972,7 @@ static int ocelot_vcap_block_get_filter_index(struct ocelot_vcap_block *block,int index =0 ;list_for_each_entry (tmp, &block->rules, list) { -if (filter->id == tmp->id) +if (ocelot_vcap_filter_equal (filter, tmp))return index; index++; }
@@ -991,12 +997,14 @@ ocelot_vcap_block_find_filter_by_index(struct ocelot_vcap_block *block, }struct ocelot_vcap_filter * -ocelot_vcap_block_find_filter_by_id (struct ocelot_vcap_block *block,int id) +ocelot_vcap_block_find_filter_by_id (struct ocelot_vcap_block *block,int cookie, +bool tc_offload) {struct ocelot_vcap_filter *filter;list_for_each_entry (filter, &block->rules, list) -if (filter->id == id) +if (filter->id.tc_offload == tc_offload && + filter->id.cookie == cookie)return filter;return NULL ;
@@ -1160,7 +1168,7 @@ static void ocelot_vcap_block_remove_filter(struct ocelot *ocelot,list_for_each_safe (pos, q, &block->rules) { tmp = list_entry(pos, struct ocelot_vcap_filter, list); -if (tmp->id == filter->id) { +if (ocelot_vcap_filter_equal (filter, tmp)) {if (tmp->block_id ==VCAP_IS2 && tmp->action.police_ena) ocelot_vcap_policer_del(ocelot, block,
drivers/net/ethernet/mscc/ocelot_vcap.h +2 -1
@@ -15,7 +15,8 @@int ocelot_vcap_filter_stats_update (struct ocelot *ocelot,struct ocelot_vcap_filter *rule);struct ocelot_vcap_filter * -ocelot_vcap_block_find_filter_by_id (struct ocelot_vcap_block *block,int id); +ocelot_vcap_block_find_filter_by_id (struct ocelot_vcap_block *block,int id, +bool tc_offload);void ocelot_detect_vcap_constants (struct ocelot *ocelot);int ocelot_vcap_init (struct ocelot *ocelot);
include/soc/mscc/ocelot_vcap.h +6 -1
@@ -648,6 +648,11 @@ enum ocelot_vcap_filter_type { OCELOT_VCAP_FILTER_OFFLOAD, }; +struct ocelot_vcap_id { +unsigned long cookie; +bool tc_offload; +}; +struct ocelot_vcap_filter {struct list_head list;
@@ -657,7 +662,7 @@ struct ocelot_vcap_filter {int lookup;u8 pag;u16 prio; -u32 id; +struct ocelot_vcap_id id;struct ocelot_vcap_action action;struct ocelot_vcap_stats stats;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 6/15 net: mscc: ocelot: only drain extraction queue on error
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
It appears that the intention of this snippet of code is to not exit ocelot_xtr_irq_handler() while in the middle of extracting a frame. The problem in extracting it word by word is that future extraction attempts are really easy to get desynchronized, since the IRQ handler assumes that the first 16 bytes are the IFH, which give further information about the frame, such as frame length.
But during normal operation, "err" will not be 0, but 4, set from here:
for (i = 0; i < OCELOT_TAG_LEN / 4; i++) {
err = ocelot_rx_frame_word(ocelot, grp, true, &ifh[i]);
if (err != 4)
break;
}
if (err != 4)
break;In that case, draining the extraction queue is a no-op. So explicitly make this code execute only on negative err.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mscc/ocelot_vsc7514.c +1 -1
@@ -701,7 +701,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) dev->stats.rx_packets++; } -if (err) +if (err <0 )while (ocelot_read (ocelot,QS_XTR_DATA_PRESENT ) &BIT (grp))ocelot_read_rix (ocelot,QS_XTR_RD , grp);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 9/15 net: mscc: ocelot: use DIV_ROUND_UP helper in ocelot_port_inject_frame
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This looks a bit nicer than the open-coded "(x + 3) % 4" idiom.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mscc/ocelot_net.c +1 -1
@@ -563,7 +563,7 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)ocelot_write_rix (ocelot, (__force u32 )cpu_to_be32 (ifh[i]),QS_INJ_WR , grp); - count = (skb->len +3 ) /4 ; + count =DIV_ROUND_UP (skb->len,4 ); last = skb->len %4 ;for (i =0 ; i < count; i++)ocelot_write_rix (ocelot, ((u32 *)skb->data)[i],QS_INJ_WR , grp);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 2/15 net: mscc: ocelot: export VCAP structures to include/soc/mscc
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The Felix driver will need to preinstall some VCAP filters for its tag_8021q implementation (outside of the tc-flower offload logic), so these need to be exported to the common includes.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/ethernet/mscc/ocelot_net.c | 1 + drivers/net/ethernet/mscc/ocelot_vcap.h | 293 +----------------------- include/soc/mscc/ocelot_vcap.h | 289 +++++++++++++++++++++++ 3 files changed, 292 insertions(+), 291 deletions(-)
drivers/net/ethernet/mscc/ocelot_net.c +1 -0
@@ -9,6 +9,7 @@*/ #include <linux/if_bridge.h> +#include <net/pkt_cls.h> #include "ocelot.h" #include "ocelot_vcap.h"
drivers/net/ethernet/mscc/ocelot_vcap.h +2 -291
302 lines not on this page · raw message
include/soc/mscc/ocelot_vcap.h +289 -0
293 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerv3 cover tag_8021q for Ocelot switches
From: Vladimir Oltean <[email protected]>
The Felix switch inside LS1028A has an issue. It has a 2.5G CPU port, and the external ports, in the majority of use cases, run at 1G. This means that, when the CPU injects traffic into the switch, it is very easy to run into congestion. This is not to say that it is impossible to enter congestion even with all ports running at the same speed, just that the default configuration is already very prone to that by design.
Normally, the way to deal with that is using Ethernet flow control (PAUSE frames).
However, this functionality is not working today with the ENETC - Felix switch pair. The hardware issue is undergoing documentation right now as an erratum within NXP, but several customers have been requesting a reasonable workaround for it.
In truth, the LS1028A has 2 internal port pairs. The lack of flow control is an issue only when NPI mode (Node Processor Interface, aka the mode where the "CPU port module", which carries DSA-style tagged packets, is connected to a regular Ethernet port) is used, and NPI mode is supported by Felix on a single port.
In past BSPs, we have had setups where both internal port pairs were enabled. We were advertising the following setup:
"data port" "control port"
(2.5G) (1G)
eno2 eno3
^ ^
| |
| regular | DSA-tagged
| frames | frames
| |
v vswp4 swp5
This works but is highly unpractical, due to NXP shifting the task of designing a functional system (choosing which port to use, depending on type of traffic required) up to the end user. The swpN interfaces would have to be bridged with swp4, in order for the eno2 "data port" to have access to the outside network. And the swpN interfaces would still be capable of IP networking. So running a DHCP client would give us two IP interfaces from the same subnet, one assigned to eno2, and the other to swpN (0, 1, 2, 3).
Also, the dual port design doesn't scale. When attaching another DSA switch to a Felix port, the end result is that the "data port" cannot carry any meaningful data to the external world, since it lacks the DSA tags required to traverse the sja1105 switches below. All that traffic needs to go through the "control port".
So in newer BSPs there was a desire to simplify that setup, and only have one internal port pair:
eno2 eno3
^
|
| DSA-tagged x disabled
| frames
|
vswp4 swp5
However, this setup only exacerbates the issue of not having flow control on the NPI port, since that is the only port now. Also, there are use cases that still require the "data port", such as IEEE 802.1CB (TSN stream identification doesn't work over an NPI port), source MAC address learning over NPI, etc.
Again, there is a desire to keep the simplicity of the single internal port setup, while regaining the benefits of having a dedicated data port as well. And this series attempts to deliver just that.
So the NPI functionality is disabled conditionally. Its purpose was:
- To ensure individually addressable ports on TX. This can be replaced by using some designated VLAN tags which are pushed by the DSA tagger code, then removed by the switch (so they are invisible to the outside world and to the user).
- To ensure source port identification on RX. Again, this can be replaced by using some designated VLAN tags to encapsulate all RX traffic (each VLAN uniquely identifies a source port). The DSA tagger determines which port it was based on the VLAN number, then removes that header.
- To deliver PTP timestamps. This cannot be obtained through VLAN headers, so we need to take a step back and see how else we can do that. The Microchip Ocelot-1 (VSC7514 MIPS) driver performs manual injection/extraction from the CPU port module using register-based MMIO, and not over Ethernet. We will need to do the same from DSA, which makes this tagger a sort of hybrid between DSA and pure switchdev.
I determined that a Kconfig option would be a sufficiently good configuration interface for selecting between the existing NPI-based tagged and the tag_8021q software-defined tagger. However, this is one of the things that is up for debate today.
Changes in v2:
Posted the entire rework necessary for PTP support using tag_8021q.c. Added a larger audience to the series.
Changes in v3:
Use a per-port bool is_dsa_8021q_cpu instead of a single dsa_8021q_cpu variable, to be compatible with future work where there may be potentially multiple tag_8021q CPU ports in a LAG.
Vladimir Oltean (15):
net: dsa: tag_8021q: add helpers to deduce whether a VLAN ID is RX or
TX VLAN
net: mscc: ocelot: export VCAP structures to include/soc/mscc
net: mscc: ocelot: store a namespaced VCAP filter ID
net: dsa: felix: add new VLAN-based tagger
net: mscc: ocelot: stop returning IRQ_NONE in ocelot_xtr_irq_handler
net: mscc: ocelot: only drain extraction queue on error
net: mscc: ocelot: just flush the CPU extraction group on error
net: mscc: ocelot: better error handling in ocelot_xtr_irq_handler
net: mscc: ocelot: use DIV_ROUND_UP helper in ocelot_port_inject_frame
net: mscc: ocelot: refactor ocelot_port_inject_frame out of
ocelot_port_xmit
net: mscc: ocelot: export struct ocelot_frame_info
net: mscc: ocelot: refactor ocelot_xtr_irq_handler into
ocelot_xtr_poll
net: dsa: felix: setup MMIO filtering rules for PTP when using
tag_8021q
net: dsa: felix: use promisc on master for PTP with tag_8021q
net: dsa: tag_ocelot_8021q: add support for PTP timestamping
MAINTAINERS | 1 + drivers/net/dsa/ocelot/Kconfig | 4 +- drivers/net/dsa/ocelot/Makefile | 5 + drivers/net/dsa/ocelot/felix.c | 120 +++++++- drivers/net/dsa/ocelot/felix.h | 14 + drivers/net/dsa/ocelot/felix_tag_8021q.c | 320 +++++++++++++++++++++ drivers/net/dsa/ocelot/felix_tag_8021q.h | 27 ++ drivers/net/dsa/ocelot/felix_vsc9959.c | 1 + drivers/net/ethernet/mscc/ocelot.c | 276 +++++++++++++++++- drivers/net/ethernet/mscc/ocelot.h | 11 +- drivers/net/ethernet/mscc/ocelot_flower.c | 7 +- drivers/net/ethernet/mscc/ocelot_net.c | 82 +----- drivers/net/ethernet/mscc/ocelot_vcap.c | 16 +- drivers/net/ethernet/mscc/ocelot_vcap.h | 296 +------------------ drivers/net/ethernet/mscc/ocelot_vsc7514.c | 170 ++--------- include/linux/dsa/8021q.h | 14 + include/soc/mscc/ocelot.h | 19 ++ include/soc/mscc/ocelot_vcap.h | 294 +++++++++++++++++++ net/dsa/Kconfig | 34 +++ net/dsa/Makefile | 3 +- net/dsa/tag_8021q.c | 15 +- net/dsa/tag_ocelot_8021q.c | 86 ++++++ 22 files changed, 1253 insertions(+), 562 deletions(-) create mode 100644 drivers/net/dsa/ocelot/felix_tag_8021q.c create mode 100644 drivers/net/dsa/ocelot/felix_tag_8021q.h create mode 100644 net/dsa/tag_ocelot_8021q.c
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v3 1/15 net: dsa: tag_8021q: add helpers to deduce whether a VLAN ID is RX or TX VLAN
From: Vladimir Oltean <[email protected]>
The sja1105 implementation can be blind about this, but the felix driver doesn't do exactly what it's being told, so it needs to know whether it is a TX or an RX VLAN, so it can install the appropriate type of TCAM rule.
---
Changes in v3:
None.
Changes in v2:
None.
include/linux/dsa/8021q.h | 14 ++++++++++++++ net/dsa/tag_8021q.c | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-)
include/linux/dsa/8021q.h +14 -0
@@ -64,6 +64,10 @@ int dsa_8021q_rx_source_port(u16 vid);u16 dsa_8021q_rx_subvlan (u16 vid); +bool vid_is_dsa_8021q_rxvlan (u16 vid); + +bool vid_is_dsa_8021q_txvlan (u16 vid); +bool vid_is_dsa_8021q (u16 vid);#else
@@ -123,6 +127,16 @@ u16 dsa_8021q_rx_subvlan(u16 vid)return 0 ; } +bool vid_is_dsa_8021q_rxvlan (u16 vid) +{ +return false; +} + +bool vid_is_dsa_8021q_txvlan (u16 vid) +{ +return false; +} +bool vid_is_dsa_8021q (u16 vid) {return false;
net/dsa/tag_8021q.c +13 -2
@@ -133,10 +133,21 @@ u16 dsa_8021q_rx_subvlan(u16 vid) }EXPORT_SYMBOL_GPL (dsa_8021q_rx_subvlan); +bool vid_is_dsa_8021q_rxvlan (u16 vid) +{ +return (vid &DSA_8021Q_DIR_MASK ) ==DSA_8021Q_DIR_RX ; +} +EXPORT_SYMBOL_GPL (vid_is_dsa_8021q_rxvlan); + +bool vid_is_dsa_8021q_txvlan (u16 vid) +{ +return (vid &DSA_8021Q_DIR_MASK ) ==DSA_8021Q_DIR_TX ; +} +EXPORT_SYMBOL_GPL (vid_is_dsa_8021q_txvlan); +bool vid_is_dsa_8021q (u16 vid) { -return ((vid &DSA_8021Q_DIR_MASK ) ==DSA_8021Q_DIR_RX || - (vid &DSA_8021Q_DIR_MASK ) ==DSA_8021Q_DIR_TX ); +return vid_is_dsa_8021q_rxvlan (vid) ||vid_is_dsa_8021q_txvlan (vid); }EXPORT_SYMBOL_GPL (vid_is_dsa_8021q);
Signature · 1 line
2.25.1
Re: [PATCH v3 net-next 01/15] net: dsa: tag_8021q: add helpers to deduce whether a VLAN ID is RX or TX VLAN
Quoted 8 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The sja1105 implementation can be blind about this, but the felix driver doesn't do exactly what it's being told, so it needs to know whether it is a TX or an RX VLAN, so it can install the appropriate type of TCAM rule.
Signed-off-by Vladimir Oltean <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v3 net-next 02/15] net: mscc: ocelot: export VCAP structures to include/soc/mscc
In reply to Vladimir OlteanQuoted 7 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The Felix driver will need to preinstall some VCAP filters for its
tag_8021qimplementation (outside of the tc-flower offload logic), so these need to be exported to the common includes.Signed-off-by Vladimir Oltean <[email protected]>
Signature · 1 line
Florian
Re: [PATCH v3 net-next 03/15] net: mscc: ocelot: store a namespaced VCAP filter ID
In reply to Vladimir OlteanQuoted 11 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
We will be adding some private VCAP filters that should not interfere in any way with the filters added using tc-flower. So we need to allocate some IDs which will not be used by tc.
Currently ocelot uses an u32 id derived from the flow cookie, which in itself is an unsigned long. This is a problem in itself, since on 64 bit systems, sizeof(unsigned long)=8, so the driver is already truncating these.
Quoted 5 lines
Create a struct
ocelot_vcap_idwhich contains the full unsigned long cookie from tc, as well as a boolean that is supposed to namespace the filters added by tc with the ones that aren't.Signed-off-by Vladimir Oltean <[email protected]>
Signature · 1 line
Florian
Vladimir Oltean
maintainerRe: [PATCH v3 net-next 10/15] net: mscc: ocelot: refactor ocelot_port_inject_frame out of ocelot_port_xmit
In reply to Vladimir OlteanQuoted 8 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The felix DSA driver will inject some frames through register MMIO, same as ocelot switchdev currently does. So we need to be able to reuse the common code.
Signed-off-by Vladimir Oltean <[email protected]>---
Sadly there are some build errors starting with this patch when drivers/net/ethernet/mscc/mscc_ocelot.ko is built as module. They are due to me not using EXPORT_SYMBOL on the refactored functions that were moved inside the common mscc_ocelot_switch_lib. I am adding the EXPORT_SYMBOL later (in the last patch I think) but it needs to be done now.
Quoted 229 lines
Changes in v3:
None.Changes in v2:
Patch is new.drivers/net/ethernet/mscc/ocelot.c | 78 +++++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.h | 4 ++ drivers/net/ethernet/mscc/ocelot_net.c | 81 +++----------------------- 3 files changed, 89 insertions(+), 74 deletions(-)drivers/net/ethernet/mscc/ocelot.c +78
-0@@ -561,6 +561,84 @@ void ocelot_get_txtstamp(struct ocelot *ocelot) }EXPORT_SYMBOL (ocelot_get_txtstamp); +/* Generate the IFH for frame injection +* +* The IFH is a 128bit-value +* bit 127: bypass the analyzer processing +* bit 56-67: destination mask +* bit 28-29: pop_cnt: 3 disables all rewriting of the frame +* bit 20-27: cpu extraction queue mask +* bit 16: tag type 0: C-tag, 1: S-tag +* bit 0-11: VID +*/ +static int ocelot_gen_ifh (u32 *ifh,struct frame_info *info) +{ + ifh[0 ] =IFH_INJ_BYPASS | ((0x1ff & info->rew_op) <<21 ); + ifh[1 ] = (0xf00 & info->port) >>8 ; + ifh[2 ] = (0xff & info->port) <<24 ; + ifh[3 ] = (info->tag_type <<16 ) | info->vid; + +return 0 ; +} + +bool ocelot_can_inject (struct ocelot *ocelot,int grp) +{ +u32 val =ocelot_read (ocelot,QS_INJ_STATUS ); + +if (!(val &QS_INJ_STATUS_FIFO_RDY (BIT (grp)))) +return false; +if (val &QS_INJ_STATUS_WMARK_REACHED (BIT (grp))) +return false; + +return true; +} + +void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp, +u32 rew_op,struct sk_buff *skb) +{ +struct frame_info info = {}; +u32 ifh[OCELOT_TAG_LEN /4 ]; +unsigned int i, count, last; + +ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) | +QS_INJ_CTRL_SOF ,QS_INJ_CTRL , grp); + + info.port =BIT (port); + info.tag_type =IFH_TAG_TYPE_C ; + info.vid =skb_vlan_tag_get (skb); + info.rew_op = rew_op; + +ocelot_gen_ifh (ifh, &info); + +for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++) +ocelot_write_rix (ocelot, (__force u32 )cpu_to_be32 (ifh[i]), +QS_INJ_WR , grp); + + count =DIV_ROUND_UP (skb->len,4 ); + last = skb->len %4 ; +for (i =0 ; i < count; i++) +ocelot_write_rix (ocelot, ((u32 *)skb->data)[i],QS_INJ_WR , grp); + +/* Add padding */ +while (i < (OCELOT_BUFFER_CELL_SZ /4 )) { +ocelot_write_rix (ocelot,0 ,QS_INJ_WR , grp); + i++; + } + +/* Indicate EOF and valid bytes in last word */ +ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) | +QS_INJ_CTRL_VLD_BYTES (skb->len <OCELOT_BUFFER_CELL_SZ ?0 : last) | +QS_INJ_CTRL_EOF , +QS_INJ_CTRL , grp); + +/* Add dummy CRC */ +ocelot_write_rix (ocelot,0 ,QS_INJ_WR , grp); +skb_tx_timestamp (skb); + + skb->dev->stats.tx_packets++; + skb->dev->stats.tx_bytes += skb->len; +} +int ocelot_fdb_add (struct ocelot *ocelot,int port,const unsigned char *addr,u16 vid) {drivers/net/ethernet/mscc/ocelot.h +4
-0@@ -127,6 +127,10 @@ int ocelot_port_devlink_init(struct ocelot *ocelot, int port, enum devlink_port_flavour flavour);void ocelot_port_devlink_teardown (struct ocelot *ocelot,int port); +bool ocelot_can_inject (struct ocelot *ocelot,int grp); +void ocelot_port_inject_frame (struct ocelot *ocelot,int port,int grp, +u32 rew_op,struct sk_buff *skb); +extern struct notifier_block ocelot_netdevice_nb;extern struct notifier_block ocelot_switchdev_nb;extern struct notifier_block ocelot_switchdev_blocking_nb;drivers/net/ethernet/mscc/ocelot_net.c +7
-74@@ -488,53 +488,20 @@ static int ocelot_port_stop(struct net_device *dev)return 0 ; } -/* Generate the IFH for frame injection -* -* The IFH is a 128bit-value -* bit 127: bypass the analyzer processing -* bit 56-67: destination mask -* bit 28-29: pop_cnt: 3 disables all rewriting of the frame -* bit 20-27: cpu extraction queue mask -* bit 16: tag type 0: C-tag, 1: S-tag -* bit 0-11: VID -*/ -static int ocelot_gen_ifh (u32 *ifh,struct frame_info *info) -{ - ifh[0 ] =IFH_INJ_BYPASS | ((0x1ff & info->rew_op) <<21 ); - ifh[1 ] = (0xf00 & info->port) >>8 ; - ifh[2 ] = (0xff & info->port) <<24 ; - ifh[3 ] = (info->tag_type <<16 ) | info->vid; - -return 0 ; -} - -static int ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t ocelot_port_xmit (struct sk_buff *skb,struct net_device *dev) {struct ocelot_port_private *priv =netdev_priv (dev); -struct skb_shared_info *shinfo =skb_shinfo (skb);struct ocelot_port *ocelot_port = &priv->port;struct ocelot *ocelot = ocelot_port->ocelot; -u32 val, ifh[OCELOT_TAG_LEN /4 ]; -struct frame_info info = {}; -u8 grp =0 ;/* Send everything on CPU group 0 */ -unsigned int i, count, last;int port = priv->chip_port; +u32 rew_op =0 ; - val =ocelot_read (ocelot,QS_INJ_STATUS ); -if (!(val &QS_INJ_STATUS_FIFO_RDY (BIT (grp))) || - (val &QS_INJ_STATUS_WMARK_REACHED (BIT (grp)))) +if (!ocelot_can_inject (ocelot,0 ))return NETDEV_TX_BUSY ; -ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) | -QS_INJ_CTRL_SOF ,QS_INJ_CTRL , grp); - - info.port =BIT (port); - info.tag_type =IFH_TAG_TYPE_C ; - info.vid =skb_vlan_tag_get (skb); -/* Check if timestamping is needed */ -if (ocelot->ptp && (shinfo->tx_flags &SKBTX_HW_TSTAMP )) { - info.rew_op = ocelot_port->ptp_cmd; +if (ocelot->ptp && (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP )) { + rew_op = ocelot_port->ptp_cmd;if (ocelot_port->ptp_cmd ==IFH_REW_OP_TWO_STEP_PTP ) {struct sk_buff *clone;@@ -547,45 +514,11 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)ocelot_port_add_txtstamp_skb (ocelot, port, clone); - info.rew_op |= clone->cb[0 ] <<3 ; + rew_op |= clone->cb[0 ] <<3 ; } } -if (ocelot->ptp && shinfo->tx_flags &SKBTX_HW_TSTAMP ) { - info.rew_op = ocelot_port->ptp_cmd; -if (ocelot_port->ptp_cmd ==IFH_REW_OP_TWO_STEP_PTP ) - info.rew_op |= skb->cb[0 ] <<3 ; - } - -ocelot_gen_ifh (ifh, &info); - -for (i =0 ; i <OCELOT_TAG_LEN /4 ; i++) -ocelot_write_rix (ocelot, (__force u32 )cpu_to_be32 (ifh[i]), -QS_INJ_WR , grp); - - count =DIV_ROUND_UP (skb->len,4 ); - last = skb->len %4 ; -for (i =0 ; i < count; i++) -ocelot_write_rix (ocelot, ((u32 *)skb->data)[i],QS_INJ_WR , grp); - -/* Add padding */ -while (i < (OCELOT_BUFFER_CELL_SZ /4 )) { -ocelot_write_rix (ocelot,0 ,QS_INJ_WR , grp); - i++; - } - -/* Indicate EOF and valid bytes in last word */ -ocelot_write_rix (ocelot,QS_INJ_CTRL_GAP_SIZE (1 ) | -QS_INJ_CTRL_VLD_BYTES (skb->len <OCELOT_BUFFER_CELL_SZ ?0 : last) | -QS_INJ_CTRL_EOF , -QS_INJ_CTRL , grp); - -/* Add dummy CRC */ -ocelot_write_rix (ocelot,0 ,QS_INJ_WR , grp); -skb_tx_timestamp (skb); - - dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; +ocelot_port_inject_frame (ocelot, port,0 , rew_op, skb);kfree_skb (skb);Signature · 1 line
2.25.1
Re: [PATCH v3 net-next 05/15] net: mscc: ocelot: stop returning IRQ_NONE in ocelot_xtr_irq_handler
In reply to Vladimir OlteanQuoted 7 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Since the xtr (extraction) IRQ of the ocelot switch is not shared, then if it fired, it means that some data must be present in the queues of the CPU port module. So simplify the code.
Signed-off-by Vladimir Oltean <[email protected]>
Signature · 1 line
Florian
Vladimir Oltean
maintainerRe: [PATCH v3 net-next 04/15] net: dsa: felix: add new VLAN-based tagger
In reply to Vladimir OlteanQuoted 25 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
There are use cases for which the existing tagger, based on the NPI (Node Processor Interface) functionality, is insufficient.
Namely:
- Frames injected through the NPI port bypass the frame analyzer, so no source address learning is performed, no TSN stream classification, etc.
- Flow control is not functional over an NPI port (PAUSE frames are encapsulated in the same Extraction Frame Header as all other frames)
- There can be at most one NPI port configured for an Ocelot switch. But in NXP LS1028A and T1040 there are two Ethernet CPU ports. The non-NPI port is currently either disabled, or operated as a plain user port (albeit an internally-facing one). Having the ability to configure the two CPU ports symmetrically could pave the way for e.g. creating a LAG between them, to increase bandwidth seamlessly for the system.So, there is a desire to have an alternative to the NPI mode.
This patch brings an implementation of the software-defined
tag_8021q.ctagger format, which also preserves full functionality under avlan_filteringbridge (unlike sja1105, the only other user oftag_8021q).
Quoted 8 lines
It does this by using the TCAM engines for:
- pushing the RX VLAN as a second, outer tag, on egress towards the CPU port
- redirecting towards the correct front port based on TX VLAN and popping that on egressSigned-off-by Vladimir Oltean <[email protected]>---
Should both taggers be reported as DSA_TAG_PROTO_OCELOT as I am doing in the current patchset? Currently a kernel can only be built with one tagger or the other. But it is not possible to e.g. rmmod one tagger and insmod another one.
If we allow compilation of more than one tagger for the same hardware, how do we select between them if both are built into the same kernel?
kernel test robot
build botRe: [PATCH v3 net-next 10/15] net: mscc: ocelot: refactor ocelot_port_inject_frame out of ocelot_port_xmit
In reply to Vladimir OlteanI love your patch! Yet something to improve:
Hi Vladimir,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Vladimir-Oltean/tag_8021q-for-Ocelot-switches/20210119-004520 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 213b97b125808aa220ba460a7af09d8f3772f669 config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/b0c94dae99772294285cc3219500b73026853e83
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Vladimir-Oltean/tag_8021q-for-Ocelot-switches/20210119-004520 git checkout b0c94dae99772294285cc3219500b73026853e83
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "ocelot_can_inject" [drivers/net/ethernet/mscc/mscc_ocelot.ko] undefined!
ERROR: modpost: "ocelot_port_inject_frame" [drivers/net/ethernet/mscc/mscc_ocelot.ko] undefined!
ERROR: modpost: "__delay" [drivers/net/mdio/mdio-cavium.ko] undefined!
ERROR: modpost: "__udivdi3" [fs/btrfs/btrfs.ko] undefined!
ERROR: modpost: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC
Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA Selected by
- SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC
- SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && ATMEL_SSC
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org