Skip to contentSkip to conversation

net: ocelot: Extend MRP

PATCH Applied Horatiu Vultur 3 participants 8 messages Mar 16, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover net: ocelot: Extend MRP

This patch series extends the current support of MRP in Ocelot driver. Currently the forwarding of the frames happened in SW because all frames were trapped to CPU. With this patch the MRP frames will be forward in HW.

v1 -> v2:
- create a patch series instead of single patch
- rename ocelot_mrp_find_port to ocelot_mrp_find_partner_port
- rename PGID_MRP to PGID_BLACKHOLE
- use GFP_KERNEL instead of GFP_ATOMIC
- fix other whitespace issues

Horatiu Vultur (3):
net: ocelot: Add PGID_BLACKHOLE
net: ocelot: Extend MRP
net: ocelot: Remove ocelot_xfh_get_cpuq

 drivers/net/ethernet/mscc/ocelot.c     |  12 +-
 drivers/net/ethernet/mscc/ocelot_mrp.c | 233 +++++++++++++++++--------
 include/linux/dsa/ocelot.h             |   5 -
 include/soc/mscc/ocelot.h              |  12 +-
 net/dsa/tag_ocelot.c                   |   8 -
 5 files changed, 167 insertions(+), 103 deletions(-)
Signature · 1 line
2.30.1
#1 lore raw

PATCH v2 1/3 net: ocelot: Add PGID_BLACKHOLE

Add a new PGID that is used not to forward frames anywhere. It is used by MRP to make sure that MRP Test frames will not reach CPU port.

---
 drivers/net/ethernet/mscc/ocelot.c | 3 +++
 include/soc/mscc/ocelot.h          | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/mscc/ocelot.c +3 -0
index 46e5c9136bac..f74d7cf002a5 100644
@@ -2051,6 +2051,9 @@ int ocelot_init(struct ocelot *ocelot)
 
 		ocelot_write_rix(ocelot, val, ANA_PGID_PGID, i);
 	}
+
+	ocelot_write_rix(ocelot, 0, ANA_PGID_PGID, PGID_BLACKHOLE);
+
 	/* Allow broadcast and unknown L2 multicast to the CPU. */
 	ocelot_rmw_rix(ocelot, ANA_PGID_PGID_PGID(BIT(ocelot->num_phys_ports)),
 		       ANA_PGID_PGID_PGID(BIT(ocelot->num_phys_ports)),
include/soc/mscc/ocelot.h +3 -1
index 425ff29d9389..4d10ccc8e7b5 100644
@@ -51,6 +51,7 @@
  */
 
 /* Reserve some destination PGIDs at the end of the range:
+ * PGID_BLACKHOLE: used for not forwarding the frames
  * PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses
  *           of the switch port net devices, towards the CPU port module.
  * PGID_UC: the flooding destinations for unknown unicast traffic.
@@ -59,6 +60,7 @@
  * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic.
  * PGID_BC: the flooding destinations for broadcast traffic.
  */
+#define PGID_BLACKHOLE			57
 #define PGID_CPU			58
 #define PGID_UC				59
 #define PGID_MC				60
@@ -73,7 +75,7 @@
 
 #define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid)	\
 	for ((pgid) = (ocelot)->num_phys_ports + 1;		\
-	     (pgid) < PGID_CPU;					\
+	     (pgid) < PGID_BLACKHOLE;				\
 	     (pgid)++)
 
 #define for_each_aggr_pgid(ocelot, pgid)			\
Signature · 1 line
2.30.1
#3 lore raw

PATCH v2 2/3 net: ocelot: Extend MRP

In reply to Horatiu Vultur

This patch extends MRP support for Ocelot. It allows to have multiple rings and when the node has the MRC role it forwards MRP Test frames in HW. For MRM there is no change.

---
 drivers/net/ethernet/mscc/ocelot.c     |   6 -
 drivers/net/ethernet/mscc/ocelot_mrp.c | 233 +++++++++++++++++--------
 include/soc/mscc/ocelot.h              |   8 +-
 net/dsa/tag_ocelot.c                   |   6 -
 4 files changed, 160 insertions(+), 93 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +0 -6
index f74d7cf002a5..9cc9378157e4 100644
@@ -772,12 +772,6 @@ int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **nskb)
 
 	skb->protocol = eth_type_trans(skb, dev);
 
-#if IS_ENABLED(CONFIG_BRIDGE_MRP)
-	if (skb->protocol == cpu_to_be16(ETH_P_MRP) &&
-	    cpuq & BIT(OCELOT_MRP_CPUQ))
-		skb->offload_fwd_mark = 0;
-#endif
-
 	*nskb = skb;
 
 	return 0;
drivers/net/ethernet/mscc/ocelot_mrp.c +158 -75

310 lines not on this page · raw message

include/soc/mscc/ocelot.h +2 -6
index 4d10ccc8e7b5..0a0751bf97dd 100644
@@ -613,6 +613,8 @@ struct ocelot_port {
 
 	struct net_device		*bond;
 	bool				lag_tx_active;
+
+	u16				mrp_ring_id;
 };
 
 struct ocelot {
@@ -681,12 +683,6 @@ struct ocelot {
 	/* Protects the PTP clock */
 	spinlock_t			ptp_clock_lock;
 	struct ptp_pin_desc		ptp_pins[OCELOT_PTP_PINS_NUM];
-
-#if IS_ENABLED(CONFIG_BRIDGE_MRP)
-	u16				mrp_ring_id;
-	struct net_device		*mrp_p_port;
-	struct net_device		*mrp_s_port;
-#endif
 };
 
 struct ocelot_policer {
net/dsa/tag_ocelot.c +0 -6
index 743809b5806b..157f95689d8d 100644
@@ -128,12 +128,6 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb,
 	skb->offload_fwd_mark = 1;
 	skb->priority = qos_class;
 
-#if IS_ENABLED(CONFIG_BRIDGE_MRP)
-	if (eth_hdr(skb)->h_proto == cpu_to_be16(ETH_P_MRP) &&
-	    cpuq & BIT(OCELOT_MRP_CPUQ))
-		skb->offload_fwd_mark = 0;
-#endif
-
 	/* Ocelot switches copy frames unmodified to the CPU. However, it is
 	 * possible for the user to request a VLAN modification through
 	 * VCAP_IS1_ACT_VID_REPLACE_ENA. In this case, what will happen is that
Signature · 1 line
2.30.1
#5 lore raw

PATCH v2 3/3 net: ocelot: Remove ocelot_xfh_get_cpuq

In reply to Horatiu Vultur

Now when extracting frames from CPU the cpuq is not used anymore so remove it.

---
 drivers/net/ethernet/mscc/ocelot.c | 3 +--
 include/linux/dsa/ocelot.h         | 5 -----
 net/dsa/tag_ocelot.c               | 2 --
 3 files changed, 1 insertion(+), 9 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +1 -2
index 9cc9378157e4..9f0c9bdd9f5d 100644
@@ -687,7 +687,7 @@ static int ocelot_xtr_poll_xfh(struct ocelot *ocelot, int grp, u32 *xfh)
 int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **nskb)
 {
 	struct skb_shared_hwtstamps *shhwtstamps;
-	u64 tod_in_ns, full_ts_in_ns, cpuq;
+	u64 tod_in_ns, full_ts_in_ns;
 	u64 timestamp, src_port, len;
 	u32 xfh[OCELOT_TAG_LEN / 4];
 	struct net_device *dev;
@@ -704,7 +704,6 @@ int ocelot_xtr_poll_frame(struct ocelot *ocelot, int grp, struct sk_buff **nskb)
 	ocelot_xfh_get_src_port(xfh, &src_port);
 	ocelot_xfh_get_len(xfh, &len);
 	ocelot_xfh_get_rew_val(xfh, &timestamp);
-	ocelot_xfh_get_cpuq(xfh, &cpuq);
 
 	if (WARN_ON(src_port >= ocelot->num_phys_ports))
 		return -EINVAL;
include/linux/dsa/ocelot.h +0 -5
index 4265f328681a..c6bc45ae5e03 100644
@@ -160,11 +160,6 @@ static inline void ocelot_xfh_get_src_port(void *extraction, u64 *src_port)
 	packing(extraction, src_port, 46, 43, OCELOT_TAG_LEN, UNPACK, 0);
 }
 
-static inline void ocelot_xfh_get_cpuq(void *extraction, u64 *cpuq)
-{
-	packing(extraction, cpuq, 28, 20, OCELOT_TAG_LEN, UNPACK, 0);
-}
-
 static inline void ocelot_xfh_get_qos_class(void *extraction, u64 *qos_class)
 {
 	packing(extraction, qos_class, 19, 17, OCELOT_TAG_LEN, UNPACK, 0);
net/dsa/tag_ocelot.c +0 -2
index 157f95689d8d..f9df9cac81c5 100644
@@ -83,7 +83,6 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb,
 	struct dsa_port *dp;
 	u8 *extraction;
 	u16 vlan_tpid;
-	u64 cpuq;
 
 	/* Revert skb->data by the amount consumed by the DSA master,
 	 * so it points to the beginning of the frame.
@@ -113,7 +112,6 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb,
 	ocelot_xfh_get_qos_class(extraction, &qos_class);
 	ocelot_xfh_get_tag_type(extraction, &tag_type);
 	ocelot_xfh_get_vlan_tci(extraction, &vlan_tci);
-	ocelot_xfh_get_cpuq(extraction, &cpuq);
 
 	skb->dev = dsa_master_find_slave(netdev, 0, src_port);
 	if (!skb->dev)
Signature · 1 line
2.30.1
#7 lore raw
In reply to Horatiu Vultur
This series was applied to netdev/net-next.git (refs/heads/master):

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

Quoted 4 lines · On Tue, 16 Mar 2021 21:10:16 +0100 you wrote:

This patch series extends the current support of MRP in Ocelot driver. Currently the forwarding of the frames happened in SW because all frames were trapped to CPU. With this patch the MRP frames will be forward in HW.

Quoted 8 lines

v1 -> v2:
- create a patch series instead of single patch
- rename ocelot_mrp_find_port to ocelot_mrp_find_partner_port
- rename PGID_MRP to PGID_BLACKHOLE
- use GFP_KERNEL instead of GFP_ATOMIC
- fix other whitespace issues

[...]

Here is the summary with links:
- [net-next,v2,1/3] net: ocelot: Add PGID_BLACKHOLE

    https://git.kernel.org/netdev/net-next/c/ebb1bb401303
  - [net-next,v2,2/3] net: ocelot: Extend MRP
    https://git.kernel.org/netdev/net-next/c/7c588c3e96e9
  - [net-next,v2,3/3] net: ocelot: Remove ocelot_xfh_get_cpuq
    https://git.kernel.org/netdev/net-next/c/2ed2c5f03911

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html