Skip to contentSkip to conversation

Switch support

PATCH Superseded Ratheesh Kannoth 2 participants 12 messages Jan 9 – Jan 10

Subsystems (4)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Ratheesh Kannoth

author maintainer
#0 lore raw

v3 cover Switch support

Marvell CN10K switch hardware is capable of accelerating L2, L3, and flow. The switch hardware runs an application that creates a logical port for each representor device when representors are enabled through devlink.

This patch series implements communication from Host OS to switch HW and vice versa.

   |--------------------------------|
   |            HOST OS             |
   |                                |
   | eth0(rep-eth0)  eth1(rep-eth1) |
   |  |                 |           |
   |  |                 |           |
   ---------------------------------|
      |                 |
      |                 |
  ---------------------------------|
  |  lport0             lport1     |
  |                                |
  |            switch              |
  |                                |
  ---------------------------------|

When representors are created, corresponding "logical ports" are created in switchdev. The switch hardware allocates a NIX PF and configures its send queues. These send queues should be able to transmit packets to any channel, as send queues as from same NIX PF. Switch is capable of forwarding packets between these logical ports.

Notifier callbacks are registered to receive system events such as FDB add/delete and FIB add/delete. Flow add/delete operations are handled through the .ndo_setup_tc() interface. These events are captured and processed by the NIC driver and forwarded to the switch device through the AF driver. All message exchanges use the mailbox interface.

Bridge acceleration:
FDB add/delete notifications are processed, and learned SMAC information is sent to the switch hardware. The switch inserts a hardware rule to accelerate packets destined to the MAC address.

Flow acceleration:
NFT and OVS applications call .ndo_setup_tc() to push rules to hardware for acceleration. This interface is used to forward rules to the switch hardware through the mailbox interface.

Ratheesh Kannoth (10):
octeontx2-af: switch: Add AF to switch mbox and skeleton files Mbox message for AF to switch

octeontx2-af: switch: Add switch dev to AF mboxes Switch to AF driver mbox messages

octeontx2-pf: switch: Add pf files hierarchy
PF skeleton files for bridge, fib and flow

octeontx2-af: switch: Representor for switch port Switch ID is copied and sent to switch when Representors are enabled thru devlink. Upon receipt of the message, switch queries AF driver to get info on rep interfaces.

octeontx2-af: switch: Enable Switch hw port for all channels Switch ports should be configured to TX packets on any channel.

octeontx2-pf: switch: Register for notifier chains. Notifier callback for various system events.

octeontx2: switch: L2 offload support
Bridge (L2) offload support

octeontx2: switch: L3 offload support
FIB (L3) offload support.

octeontx2: switch: Flow offload support
Flow (5/7 tuple) offload support.

octeontx2: switch: trace support
Trace logs for flow and action

 .../net/ethernet/marvell/octeontx2/Kconfig    |  12 +
 .../ethernet/marvell/octeontx2/af/Makefile    |   2 +
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 219 ++++++
 .../net/ethernet/marvell/octeontx2/af/rvu.c   | 111 +++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   6 +
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   |  54 +-
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   |  77 ++-
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  13 +-
 .../ethernet/marvell/octeontx2/af/rvu_rep.c   |   3 +-
 .../marvell/octeontx2/af/switch/rvu_sw.c      |  47 ++
 .../marvell/octeontx2/af/switch/rvu_sw.h      |  14 +
 .../marvell/octeontx2/af/switch/rvu_sw_fl.c   | 294 ++++++++
 .../marvell/octeontx2/af/switch/rvu_sw_fl.h   |  13 +
 .../marvell/octeontx2/af/switch/rvu_sw_l2.c   | 284 ++++++++
 .../marvell/octeontx2/af/switch/rvu_sw_l2.h   |  13 +
 .../marvell/octeontx2/af/switch/rvu_sw_l3.c   | 215 ++++++
 .../marvell/octeontx2/af/switch/rvu_sw_l3.h   |  11 +
 .../ethernet/marvell/octeontx2/nic/Makefile   |   8 +-
 .../ethernet/marvell/octeontx2/nic/otx2_tc.c  |  17 +-
 .../marvell/octeontx2/nic/otx2_txrx.h         |   2 +
 .../ethernet/marvell/octeontx2/nic/otx2_vf.c  |   8 +
 .../net/ethernet/marvell/octeontx2/nic/rep.c  |  10 +
 .../marvell/octeontx2/nic/switch/sw_fdb.c     | 143 ++++
 .../marvell/octeontx2/nic/switch/sw_fdb.h     |  18 +
 .../marvell/octeontx2/nic/switch/sw_fib.c     | 133 ++++
 .../marvell/octeontx2/nic/switch/sw_fib.h     |  16 +
 .../marvell/octeontx2/nic/switch/sw_fl.c      | 544 +++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fl.h      |  15 +
 .../marvell/octeontx2/nic/switch/sw_nb.c      | 629 ++++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_nb.h      |  31 +
 .../marvell/octeontx2/nic/switch/sw_trace.c   |  11 +
 .../marvell/octeontx2/nic/switch/sw_trace.h   |  82 +++
 32 files changed, 3040 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h

--
ChangeLog:
v1 -> v2: Fixed build errors
v2 -> v3: Fixed sparse error, Addressed comments from Alok, Kalesh 2.43.0

author maintainer
#1 lore raw

PATCH v3 1/10 octeontx2-af: switch: Add AF to switch mbox and skeleton files

The Marvell switch hardware runs on a Linux OS. This OS receives various messages, which are parsed to create flow rules that can be installed on HW. The switch is capable of accelerating both L2 and L3 flows.

This commit adds various mailbox messages used by the Linux OS (on arm64) to send events to the switch hardware.

fdb messages:     Linux bridge FDB messages
fib messages:     Linux routing table messages
status messages:  Packet status updates sent to Host

Linux to keep flows active
for connection-tracked flows.

---
 .../ethernet/marvell/octeontx2/af/Makefile    |  3 +-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 95 +++++++++++++++++++
 .../marvell/octeontx2/af/switch/rvu_sw_fl.c   | 21 ++++
 .../marvell/octeontx2/af/switch/rvu_sw_fl.h   | 11 +++
 .../marvell/octeontx2/af/switch/rvu_sw_l2.c   | 14 +++
 .../marvell/octeontx2/af/switch/rvu_sw_l2.h   | 11 +++
 .../marvell/octeontx2/af/switch/rvu_sw_l3.c   | 14 +++
 .../marvell/octeontx2/af/switch/rvu_sw_l3.h   | 11 +++
 8 files changed, 179 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.h
drivers/net/ethernet/marvell/octeontx2/af/Makefile +2 -1
index 244de500963e..7d9c4050dc32 100644
@@ -3,7 +3,7 @@
 # Makefile for Marvell's RVU Admin Function driver
 #
 
-ccflags-y += -I$(src)
+ccflags-y += -I$(src) -I$(src)/switch/
 obj-$(CONFIG_OCTEONTX2_MBOX) += rvu_mbox.o
 obj-$(CONFIG_OCTEONTX2_AF) += rvu_af.o
 
@@ -12,5 +12,6 @@ rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
 		  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
 		  rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o \
 		  rvu_sdp.o rvu_npc_hash.o mcs.o mcs_rvu_if.o mcs_cnf10kb.o \
+		  switch/rvu_sw_l2.o switch/rvu_sw_l3.o switch/rvu_sw_fl.o\
 		  rvu_rep.o cn20k/mbox_init.o cn20k/nix.o cn20k/debugfs.o \
 		  cn20k/npa.o
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +95 -0

107 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.c new file +21 -0
new file mode 100644
index 000000000000..1f8b82a84a5d
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "rvu.h"
+
+int rvu_mbox_handler_fl_get_stats(struct rvu *rvu,
+				  struct fl_get_stats_req *req,
+				  struct fl_get_stats_rsp *rsp)
+{
+	return 0;
+}
+
+int rvu_mbox_handler_fl_notify(struct rvu *rvu,
+			       struct fl_notify_req *req,
+			       struct msg_rsp *rsp)
+{
+	return 0;
+}
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.h new file +11 -0
new file mode 100644
index 000000000000..cf3e5b884f77
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+
+#ifndef RVU_SW_FL_H
+#define RVU_SW_FL_H
+
+#endif
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.c new file +14 -0
new file mode 100644
index 000000000000..5f805bfa81ed
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "rvu.h"
+
+int rvu_mbox_handler_fdb_notify(struct rvu *rvu,
+				struct fdb_notify_req *req,
+				struct msg_rsp *rsp)
+{
+	return 0;
+}
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.h new file +11 -0
new file mode 100644
index 000000000000..ff28612150c9
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+
+#ifndef RVU_SW_L2_H
+#define RVU_SW_L2_H
+
+#endif
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.c new file +14 -0
new file mode 100644
index 000000000000..2b798d5f0644
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "rvu.h"
+
+int rvu_mbox_handler_fib_notify(struct rvu *rvu,
+				struct fib_notify_req *req,
+				struct msg_rsp *rsp)
+{
+	return 0;
+}
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.h new file +11 -0
new file mode 100644
index 000000000000..ac8c4f9ba5ac
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+
+#ifndef RVU_SW_L3_H
+#define RVU_SW_L3_H
+
+#endif
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v3 2/10 octeontx2-af: switch: Add switch dev to AF mboxes

In reply to Ratheesh Kannoth

The Marvell switch hardware runs on a Linux OS. Switch needs various information from AF driver. These mboxes are defined to query those from AF driver.

---
 .../ethernet/marvell/octeontx2/af/Makefile    |   2 +-
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 119 ++++++++++++++++++
 .../net/ethernet/marvell/octeontx2/af/rvu.c   | 110 +++++++++++++++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   1 +
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   |   4 +-
 .../ethernet/marvell/octeontx2/af/rvu_npc.c   |  77 +++++++++++-
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  11 ++
 .../marvell/octeontx2/af/switch/rvu_sw.c      |  15 +++
 .../marvell/octeontx2/af/switch/rvu_sw.h      |  11 ++
 9 files changed, 344 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.h
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
index 7d9c4050dc32..3254b97545d0 100644
@@ -12,6 +12,6 @@ rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
 		  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
 		  rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o \
 		  rvu_sdp.o rvu_npc_hash.o mcs.o mcs_rvu_if.o mcs_cnf10kb.o \
-		  switch/rvu_sw_l2.o switch/rvu_sw_l3.o switch/rvu_sw_fl.o\
+		  switch/rvu_sw.o switch/rvu_sw_l2.o switch/rvu_sw_l3.o switch/rvu_sw_fl.o \
 		  rvu_rep.o cn20k/mbox_init.o cn20k/nix.o cn20k/debugfs.o \
 		  cn20k/npa.o
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +119 -0

155 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu.c +109 -1

122 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
index e85dac2c806d..4e11cdf5df63 100644
@@ -1147,6 +1147,7 @@ void rvu_program_channels(struct rvu *rvu);
 
 /* CN10K NIX */
 void rvu_nix_block_cn10k_init(struct rvu *rvu, struct nix_hw *nix_hw);
+int nix_get_tx_link(struct rvu *rvu, u16 pcifunc);
 
 /* CN10K RVU - LMT*/
 void rvu_reset_lmt_map_tbl(struct rvu *rvu, u16 pcifunc);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1 -3
index 2f485a930edd..e2cc33ad2b2c 100644
@@ -31,7 +31,6 @@ static int nix_free_all_bandprof(struct rvu *rvu, u16 pcifunc);
 static void nix_clear_ratelimit_aggr(struct rvu *rvu, struct nix_hw *nix_hw,
 				     u32 leaf_prof);
 static const char *nix_get_ctx_name(int ctype);
-static int nix_get_tx_link(struct rvu *rvu, u16 pcifunc);
 
 enum mc_tbl_sz {
 	MC_TBL_SZ_256,
@@ -2055,7 +2054,7 @@ static void nix_clear_tx_xoff(struct rvu *rvu, int blkaddr,
 	rvu_write64(rvu, blkaddr, reg, 0x0);
 }
 
-static int nix_get_tx_link(struct rvu *rvu, u16 pcifunc)
+int nix_get_tx_link(struct rvu *rvu, u16 pcifunc)
 {
 	struct rvu_hwinfo *hw = rvu->hw;
 	int pf = rvu_get_pf(rvu->pdev, pcifunc);
@@ -5283,7 +5282,6 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,
 	/* Disable the interface if it is in any multicast list */
 	nix_mcast_update_mce_entry(rvu, pcifunc, 0);
 
-
 	pfvf = rvu_get_pfvf(rvu, pcifunc);
 	clear_bit(NIXLF_INITIALIZED, &pfvf->flags);
 
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +76 -1

95 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +11 -0
index b56395ac5a74..3d6f780635a5 100644
@@ -1549,6 +1549,17 @@ static int npc_delete_flow(struct rvu *rvu, struct rvu_npc_mcam_rule *rule,
 	return rvu_mbox_handler_npc_mcam_dis_entry(rvu, &dis_req, &dis_rsp);
 }
 
+int rvu_mbox_handler_npc_mcam_get_features(struct rvu *rvu,
+					   struct msg_req *req,
+					   struct npc_mcam_get_features_rsp *rsp)
+{
+	struct npc_mcam *mcam = &rvu->hw->mcam;
+
+	rsp->rx_features = mcam->rx_features;
+	rsp->tx_features = mcam->tx_features;
+	return 0;
+}
+
 int rvu_mbox_handler_npc_delete_flow(struct rvu *rvu,
 				     struct npc_delete_flow_req *req,
 				     struct npc_delete_flow_rsp *rsp)
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c new file +15 -0
new file mode 100644
index 000000000000..fe143ad3f944
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+
+#include "rvu.h"
+
+int rvu_mbox_handler_swdev2af_notify(struct rvu *rvu,
+				     struct swdev2af_notify_req *req,
+				     struct msg_rsp *rsp)
+{
+	return 0;
+}
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.h new file +11 -0
new file mode 100644
index 000000000000..f28dba556d80
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+
+#ifndef RVU_SWITCH_H
+#define RVU_SWITCH_H
+
+#endif
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v3 3/10 octeontx2-pf: switch: Add pf files hierarchy

In reply to Ratheesh Kannoth

PF driver skeleton files. Follow up patches add meat to these files.

sw_nb* : Implements various notifier callbacks for linux events sw_fdb* : L2 offload
sw_fib* : L3 offload
sw_fl* : Flow based offload (ovs, nft etc)

---
 drivers/net/ethernet/marvell/octeontx2/Kconfig  | 12 ++++++++++++
 .../net/ethernet/marvell/octeontx2/nic/Makefile |  8 +++++++-
 .../marvell/octeontx2/nic/switch/sw_fdb.c       | 16 ++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fdb.h       | 13 +++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fib.c       | 16 ++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fib.h       | 13 +++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fl.c        | 16 ++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fl.h        | 13 +++++++++++++
 .../marvell/octeontx2/nic/switch/sw_nb.c        | 17 +++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_nb.h        | 13 +++++++++++++
 10 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.h
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.h
drivers/net/ethernet/marvell/octeontx2/Kconfig +12 -0
index 35c4f5f64f58..a883efc9d9dd 100644
@@ -28,6 +28,18 @@ config NDC_DIS_DYNAMIC_CACHING
 	  , NPA stack pages etc in NDC. Also locks down NIX SQ/CQ/RQ/RSS and
 	  NPA Aura/Pool contexts.
 
+config OCTEONTX_SWITCH
+	tristate "Marvell OcteonTX2 switch driver"
+	select OCTEONTX2_MBOX
+	select NET_DEVLINK
+	default n
+	select PAGE_POOL
+	depends on (64BIT && COMPILE_TEST) || ARM64
+	help
+	  This driver supports Marvell's OcteonTX2 switch driver.
+	  Marvell SW HW can offload L2, L3 offload. ARM core interacts
+	  with Marvell SW HW thru mbox.
+
 config OCTEONTX2_PF
 	tristate "Marvell OcteonTX2 NIC Physical Function driver"
 	select OCTEONTX2_MBOX
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +7 -1
index 883e9f4d601c..da87e952c187 100644
@@ -9,7 +9,13 @@ obj-$(CONFIG_RVU_ESWITCH) += rvu_rep.o
 
 rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \
                otx2_flows.o otx2_tc.o cn10k.o cn20k.o otx2_dmac_flt.o \
-               otx2_devlink.o qos_sq.o qos.o otx2_xsk.o
+               otx2_devlink.o qos_sq.o qos.o otx2_xsk.o \
+	       switch/sw_fdb.o switch/sw_fl.o
+
+ifdef CONFIG_OCTEONTX_SWITCH
+rvu_nicpf-y += switch/sw_nb.o switch/sw_fib.o
+endif
+
 rvu_nicvf-y := otx2_vf.o
 rvu_rep-y := rep.o
 
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.c new file +16 -0
new file mode 100644
index 000000000000..6842c8d91ffc
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "sw_fdb.h"
+
+int sw_fdb_init(void)
+{
+	return 0;
+}
+
+void sw_fdb_deinit(void)
+{
+}
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.h new file +13 -0
new file mode 100644
index 000000000000..d4314d6d3ee4
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#ifndef SW_FDB_H_
+#define SW_FDB_H_
+
+void sw_fdb_deinit(void);
+int sw_fdb_init(void);
+
+#endif // SW_FDB_H
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.c new file +16 -0
new file mode 100644
index 000000000000..12ddf8119372
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "sw_fib.h"
+
+int sw_fib_init(void)
+{
+	return 0;
+}
+
+void sw_fib_deinit(void)
+{
+}
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.h new file +13 -0
new file mode 100644
index 000000000000..a51d15c2b80e
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#ifndef SW_FIB_H_
+#define SW_FIB_H_
+
+void sw_fib_deinit(void);
+int sw_fib_init(void);
+
+#endif // SW_FIB_H
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c new file +16 -0
new file mode 100644
index 000000000000..36a2359a0a48
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "sw_fl.h"
+
+int sw_fl_init(void)
+{
+	return 0;
+}
+
+void sw_fl_deinit(void)
+{
+}
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.h new file +13 -0
new file mode 100644
index 000000000000..cd018d770a8a
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#ifndef SW_FL_H_
+#define SW_FL_H_
+
+void sw_fl_deinit(void);
+int sw_fl_init(void);
+
+#endif // SW_FL_H
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c new file +17 -0
new file mode 100644
index 000000000000..2d14a0590c5d
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#include "sw_nb.h"
+
+int sw_nb_unregister(void)
+{
+	return 0;
+}
+
+int sw_nb_register(void)
+{
+	return 0;
+}
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.h new file +13 -0
new file mode 100644
index 000000000000..5f744cc3ecbb
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Marvell switch driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+#ifndef SW_NB_H_
+#define SW_NB_H_
+
+int sw_nb_register(void);
+int sw_nb_unregister(void);
+
+#endif // SW_NB_H_
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH v3 4/10 octeontx2-af: switch: Representor for switch port

In reply to Ratheesh Kannoth

Representor support is already available in AF driver. When Representors are enabled through devlink, switch id and various information are collected from AF driver and sent to switchdev thru mbox message. This message enables switchdev HW.

---
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h   |  1 +
 drivers/net/ethernet/marvell/octeontx2/af/rvu.h    |  5 +++++
 .../net/ethernet/marvell/octeontx2/af/rvu_rep.c    |  3 ++-
 .../ethernet/marvell/octeontx2/af/switch/rvu_sw.c  | 14 ++++++++++++++
 .../ethernet/marvell/octeontx2/af/switch/rvu_sw.h  |  3 +++
 drivers/net/ethernet/marvell/octeontx2/nic/rep.c   |  4 ++++
 6 files changed, 29 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -0
index d82d7c1b0926..24703c27a352 100644
@@ -1721,6 +1721,7 @@ struct get_rep_cnt_rsp {
 struct esw_cfg_req {
 	struct mbox_msghdr hdr;
 	u8 ena;
+	unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN];
 	u64 rsvd;
 };
 
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5 -0
index 4e11cdf5df63..0f3d1b38a7dd 100644
@@ -567,6 +567,10 @@ struct rvu_switch {
 	u16 *entry2pcifunc;
 	u16 mode;
 	u16 start_entry;
+	unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN];
+#define RVU_SWITCH_FLAG_FW_READY BIT_ULL(0)
+	u64 flags;
+	u16 pcifunc;
 };
 
 struct rep_evtq_ent {
@@ -1185,4 +1189,5 @@ int rvu_rep_pf_init(struct rvu *rvu);
 int rvu_rep_install_mcam_rules(struct rvu *rvu);
 void rvu_rep_update_rules(struct rvu *rvu, u16 pcifunc, bool ena);
 int rvu_rep_notify_pfvf_state(struct rvu *rvu, u16 pcifunc, bool enable);
+u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc);
 #endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_rep.c +2 -1
index 4415d0ce9aef..078ba5bd2369 100644
@@ -181,7 +181,7 @@ int rvu_mbox_handler_nix_lf_stats(struct rvu *rvu,
 	return 0;
 }
 
-static u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
+u16 rvu_rep_get_vlan_id(struct rvu *rvu, u16 pcifunc)
 {
 	int id;
 
@@ -428,6 +428,7 @@ int rvu_mbox_handler_esw_cfg(struct rvu *rvu, struct esw_cfg_req *req,
 		return 0;
 
 	rvu->rep_mode = req->ena;
+	memcpy(rvu->rswitch.switch_id, req->switch_id, MAX_PHYS_ITEM_ID_LEN);
 
 	if (!rvu->rep_mode)
 		rvu_npc_free_mcam_entries(rvu, req->hdr.pcifunc, -1);
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c +14 -0
index fe143ad3f944..533ee8725e38 100644
@@ -6,6 +6,20 @@
  */
 
 #include "rvu.h"
+#include "rvu_sw.h"
+
+u32 rvu_sw_port_id(struct rvu *rvu, u16 pcifunc)
+{
+	u16 port_id;
+	u16 rep_id;
+
+	rep_id  = rvu_rep_get_vlan_id(rvu, pcifunc);
+
+	port_id = FIELD_PREP(GENMASK_ULL(31, 16), rep_id) |
+		  FIELD_PREP(GENMASK_ULL(15, 0), pcifunc);
+
+	return port_id;
+}
 
 int rvu_mbox_handler_swdev2af_notify(struct rvu *rvu,
 				     struct swdev2af_notify_req *req,
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.h +3 -0
index f28dba556d80..847a8da60d0a 100644
@@ -8,4 +8,7 @@
 #ifndef RVU_SWITCH_H
 #define RVU_SWITCH_H
 
+/* RVU Switch */
+u32 rvu_sw_port_id(struct rvu *rvu, u16 pcifunc);
+
 #endif
drivers/net/ethernet/marvell/octeontx2/nic/rep.c +4 -0
index b476733a0234..9200198be71f 100644
@@ -399,8 +399,11 @@ static void rvu_rep_get_stats64(struct net_device *dev,
 
 static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
 {
+	struct devlink_port_attrs attrs = {};
 	struct esw_cfg_req *req;
 
+	rvu_rep_devlink_set_switch_id(priv, &attrs.switch_id);
+
 	mutex_lock(&priv->mbox.lock);
 	req = otx2_mbox_alloc_msg_esw_cfg(&priv->mbox);
 	if (!req) {
@@ -408,6 +411,7 @@ static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
 		return -ENOMEM;
 	}
 	req->ena = ena;
+	memcpy(req->switch_id, attrs.switch_id.id, attrs.switch_id.id_len);
 	otx2_sync_mbox_msg(&priv->mbox);
 	mutex_unlock(&priv->mbox.lock);
 	return 0;
Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH v3 5/10 octeontx2-af: switch: Enable Switch hw port for all channels

In reply to Ratheesh Kannoth

Switch HW should be able to fwd packets to any link based on flow rules. Set txlink enable for all channels.

---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  4 ++
 .../ethernet/marvell/octeontx2/af/rvu_nix.c   | 50 ++++++++++++++++---
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  2 +-
 .../marvell/octeontx2/nic/otx2_txrx.h         |  2 +
 4 files changed, 51 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +4 -0
index 24703c27a352..00bacbc22052 100644
@@ -1122,6 +1122,8 @@ struct nix_txsch_alloc_req {
 	/* Scheduler queue count request at each level */
 	u16 schq_contig[NIX_TXSCH_LVL_CNT]; /* No of contiguous queues */
 	u16 schq[NIX_TXSCH_LVL_CNT]; /* No of non-contiguous queues */
+#define NIX_TXSCH_ALLOC_FLAG_PAN BIT_ULL(0)
+	u64 flags;
 };
 
 struct nix_txsch_alloc_rsp {
@@ -1140,6 +1142,7 @@ struct nix_txsch_alloc_rsp {
 struct nix_txsch_free_req {
 	struct mbox_msghdr hdr;
 #define TXSCHQ_FREE_ALL BIT_ULL(0)
+#define TXSCHQ_FREE_PAN_TL1 BIT_ULL(1)
 	u16 flags;
 	/* Scheduler queue level to be freed */
 	u16 schq_lvl;
@@ -1958,6 +1961,7 @@ struct npc_install_flow_req {
 	u16 entry;
 	u16 channel;
 	u16 chan_mask;
+	u8 set_chanmask;
 	u8 intf;
 	u8 set_cntr; /* If counter is available set counter for this entry ? */
 	u8 default_rule;
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +44 -6

91 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +1 -1
index 3d6f780635a5..925b0b02279e 100644
@@ -1469,7 +1469,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
 	}
 
 	/* ignore chan_mask in case pf func is not AF, revisit later */
-	if (!is_pffunc_af(req->hdr.pcifunc))
+	if (!req->set_chanmask && !is_pffunc_af(req->hdr.pcifunc))
 		req->chan_mask = 0xFFF;
 
 	err = npc_check_unsupported_flows(rvu, req->features, req->intf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +2 -0
index acf259d72008..73a98b94426b 100644
@@ -78,6 +78,8 @@ struct otx2_rcv_queue {
 struct sg_list {
 	u16	num_segs;
 	u16	flags;
+	u16	cq_idx;
+	u16	len;
 	u64	skb;
 	u64	size[OTX2_MAX_FRAGS_IN_SQE];
 	u64	dma_addr[OTX2_MAX_FRAGS_IN_SQE];
Signature · 1 line
2.43.0
author maintainer
#6 lore raw

PATCH v3 6/10 octeontx2-pf: switch: Register for notifier chains.

In reply to Ratheesh Kannoth

Switchdev flow table needs information on 5tuple information to mangle/to find egress ports etc. PF driver registers for fdb/fib/netdev notifier chains to listen to events. These events are parsed and sent to switchdev HW through mbox events.

---
 .../net/ethernet/marvell/octeontx2/nic/rep.c  |   7 +
 .../marvell/octeontx2/nic/switch/sw_nb.c      | 622 +++++++++++++++++-
 .../marvell/octeontx2/nic/switch/sw_nb.h      |  23 +-
 3 files changed, 648 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/rep.c +7 -0
index 9200198be71f..0edbc56ae693 100644
@@ -15,6 +15,7 @@
 #include "cn10k.h"
 #include "otx2_reg.h"
 #include "rep.h"
+#include "switch/sw_nb.h"
 
 #define DRV_NAME	"rvu_rep"
 #define DRV_STRING	"Marvell RVU Representor Driver"
@@ -399,6 +400,7 @@ static void rvu_rep_get_stats64(struct net_device *dev,
 
 static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
 {
+	struct net_device *netdev = priv->netdev;
 	struct devlink_port_attrs attrs = {};
 	struct esw_cfg_req *req;
 
@@ -414,6 +416,11 @@ static int rvu_eswitch_config(struct otx2_nic *priv, u8 ena)
 	memcpy(req->switch_id, attrs.switch_id.id, attrs.switch_id.id_len);
 	otx2_sync_mbox_msg(&priv->mbox);
 	mutex_unlock(&priv->mbox.lock);
+
+#if IS_ENABLED(CONFIG_OCTEONTX_SWITCH)
+	ena ? sw_nb_register(netdev) : sw_nb_unregister(netdev);
+#endif
+
 	return 0;
 }
 
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c +620 -2

634 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.h +21 -2
index 5f744cc3ecbb..81a54cb28ce2 100644
@@ -7,7 +7,26 @@
 #ifndef SW_NB_H_
 #define SW_NB_H_
 
-int sw_nb_register(void);
-int sw_nb_unregister(void);
+enum {
+	OTX2_DEV_UP = 1,
+	OTX2_DEV_DOWN,
+	OTX2_DEV_CHANGE,
+	OTX2_NEIGH_UPDATE,
+	OTX2_FIB_ENTRY_REPLACE,
+	OTX2_FIB_ENTRY_ADD,
+	OTX2_FIB_ENTRY_DEL,
+	OTX2_FIB_ENTRY_APPEND,
+	OTX2_CMD_MAX,
+};
+
+int sw_nb_register(struct net_device *netdev);
+int sw_nb_unregister(struct net_device *netdev);
+bool sw_nb_is_valid_dev(struct net_device *netdev);
+
+int otx2_mbox_up_handler_af2pf_fdb_refresh(struct otx2_nic *pf,
+					   struct af2pf_fdb_refresh_req *req,
+					   struct msg_rsp *rsp);
+
+const char *sw_nb_get_cmd2str(int cmd);
 
 #endif // SW_NB_H_
Signature · 1 line
2.43.0
author maintainer
#7 lore raw

PATCH v3 7/10 octeontx2: switch: L2 offload support

In reply to Ratheesh Kannoth

Linux bridge fdb events are parsed to decide on DMAC to fwd packets. Switchdev HW flow table is filled with this information. Once populated, all packet with DMAC will be accelerated.

---
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |   1 +
 .../marvell/octeontx2/af/switch/rvu_sw.c      |  18 +-
 .../marvell/octeontx2/af/switch/rvu_sw_l2.c   | 270 ++++++++++++++++++
 .../marvell/octeontx2/af/switch/rvu_sw_l2.h   |   2 +
 .../ethernet/marvell/octeontx2/nic/otx2_vf.c  |  17 ++
 .../marvell/octeontx2/nic/switch/sw_fdb.c     | 127 ++++++++
 .../marvell/octeontx2/nic/switch/sw_fdb.h     |   5 +
 .../marvell/octeontx2/nic/switch/sw_nb.c      |   5 +-
 8 files changed, 441 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -0
index 6b61742a61b1..95decbc5fc0d 100644
@@ -2460,6 +2460,7 @@ static void __rvu_mbox_up_handler(struct rvu_work *mwork, int type)
 
 		switch (msg->id) {
 		case MBOX_MSG_CGX_LINK_EVENT:
+		case MBOX_MSG_AF2PF_FDB_REFRESH:
 			break;
 		default:
 			if (msg->rc)
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c +16 -2
index 533ee8725e38..b66f9c2eb981 100644
@@ -7,6 +7,8 @@
 
 #include "rvu.h"
 #include "rvu_sw.h"
+#include "rvu_sw_l2.h"
+#include "rvu_sw_fl.h"
 
 u32 rvu_sw_port_id(struct rvu *rvu, u16 pcifunc)
 {
@@ -16,7 +18,7 @@ u32 rvu_sw_port_id(struct rvu *rvu, u16 pcifunc)
 	rep_id  = rvu_rep_get_vlan_id(rvu, pcifunc);
 
 	port_id = FIELD_PREP(GENMASK_ULL(31, 16), rep_id) |
-		  FIELD_PREP(GENMASK_ULL(15, 0), pcifunc);
+		FIELD_PREP(GENMASK_ULL(15, 0), pcifunc);
 
 	return port_id;
 }
@@ -25,5 +27,17 @@ int rvu_mbox_handler_swdev2af_notify(struct rvu *rvu,
 				     struct swdev2af_notify_req *req,
 				     struct msg_rsp *rsp)
 {
-	return 0;
+	int rc = 0;
+
+	switch (req->msg_type) {
+	case SWDEV2AF_MSG_TYPE_FW_STATUS:
+		rc = rvu_sw_l2_init_offl_wq(rvu, req->pcifunc, req->fw_up);
+		break;
+
+	case SWDEV2AF_MSG_TYPE_REFRESH_FDB:
+		rc = rvu_sw_l2_fdb_list_entry_add(rvu, req->pcifunc, req->mac);
+		break;
+	}
+
+	return rc;
 }
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.c +270 -0

281 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.h +2 -0
index ff28612150c9..56786768880e 100644
@@ -8,4 +8,6 @@
 #ifndef RVU_SW_L2_H
 #define RVU_SW_L2_H
 
+int rvu_sw_l2_init_offl_wq(struct rvu *rvu, u16 pcifunc, bool fw_up);
+int rvu_sw_l2_fdb_list_entry_add(struct rvu *rvu, u16 pcifunc, u8 *mac);
 #endif
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +17 -0
index f4fdbfba8667..4642a1dd7ccb 100644
@@ -15,6 +15,7 @@
 #include "otx2_ptp.h"
 #include "cn10k.h"
 #include "cn10k_ipsec.h"
+#include "switch/sw_nb.h"
 
 #define DRV_NAME	"rvu_nicvf"
 #define DRV_STRING	"Marvell RVU NIC Virtual Function Driver"
@@ -141,6 +142,22 @@ static int otx2vf_process_mbox_msg_up(struct otx2_nic *vf,
 		err = otx2_mbox_up_handler_cgx_link_event(
 				vf, (struct cgx_link_info_msg *)req, rsp);
 		return err;
+
+	case MBOX_MSG_AF2PF_FDB_REFRESH:
+		rsp = (struct msg_rsp *)otx2_mbox_alloc_msg(&vf->mbox.mbox_up, 0,
+							    sizeof(struct msg_rsp));
+		if (!rsp)
+			return -ENOMEM;
+
+		rsp->hdr.id = MBOX_MSG_AF2PF_FDB_REFRESH;
+		rsp->hdr.sig = OTX2_MBOX_RSP_SIG;
+		rsp->hdr.pcifunc = req->pcifunc;
+		rsp->hdr.rc = 0;
+		err = otx2_mbox_up_handler_af2pf_fdb_refresh(vf,
+							     (struct af2pf_fdb_refresh_req *)req,
+							     rsp);
+		return err;
+
 	default:
 		otx2_reply_invalid_msg(&vf->mbox.mbox_up, 0, 0, req->id);
 		return -ENODEV;
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.c +127 -0

140 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.h +5 -0
index d4314d6d3ee4..f8705083418c 100644
@@ -7,7 +7,12 @@
 #ifndef SW_FDB_H_
 #define SW_FDB_H_
 
+int sw_fdb_add_to_list(struct net_device *dev, u8 *mac, bool add_fdb);
 void sw_fdb_deinit(void);
 int sw_fdb_init(void);
 
+int otx2_mbox_up_handler_af2pf_fdb_refresh(struct otx2_nic *pf,
+					   struct af2pf_fdb_refresh_req *req,
+					   struct msg_rsp *rsp);
+
 #endif // SW_FDB_H
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c +3 -2
index ce565fe7035c..f5e00807c0fa 100644
@@ -21,6 +21,7 @@
 #include "sw_fdb.h"
 #include "sw_fib.h"
 #include "sw_fl.h"
+#include "sw_nb.h"
 
 static const char *sw_nb_cmd2str[OTX2_CMD_MAX] = {
 	[OTX2_DEV_UP]  = "OTX2_DEV_UP",
@@ -59,7 +60,6 @@ static int sw_nb_check_slaves(struct net_device *dev,
 			      struct netdev_nested_priv *priv)
 {
 	int *cnt;
-
 	if (!priv->flags)
 		return 0;
 
@@ -115,11 +115,13 @@ static int sw_nb_fdb_event(struct notifier_block *unused,
 	case SWITCHDEV_FDB_ADD_TO_DEVICE:
 		if (fdb_info->is_local)
 			break;
+		sw_fdb_add_to_list(dev, (u8 *)fdb_info->addr, true);
 		break;
 
 	case SWITCHDEV_FDB_DEL_TO_DEVICE:
 		if (fdb_info->is_local)
 			break;
+		sw_fdb_add_to_list(dev, (u8 *)fdb_info->addr, false);
 		break;
 
 	default:
@@ -313,7 +315,6 @@ static int sw_nb_fib_event(struct notifier_block *nb,
 	entries = kcalloc(hcnt, sizeof(*entries), GFP_ATOMIC);
 	if (!entries)
 		return NOTIFY_DONE;
-
 	iter = entries;
 
 	for (i = 0; i < hcnt; i++, iter++) {
Signature · 1 line
2.43.0
author maintainer
#8 lore raw

PATCH v3 8/10 octeontx2: switch: L3 offload support

In reply to Ratheesh Kannoth

Linux route events are parsed to decide on destination DIP/MASK to fwd packets. Switchdev HW flow table is filled with this information. Once populated, all packet with DIP/MASK will be accelerated.

---
 .../marvell/octeontx2/af/switch/rvu_sw.c      |   2 +-
 .../marvell/octeontx2/af/switch/rvu_sw_l3.c   | 202 ++++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fib.c     | 119 +++++++++++
 .../marvell/octeontx2/nic/switch/sw_fib.h     |   3 +
 .../marvell/octeontx2/nic/switch/sw_nb.c      |  20 ++
 5 files changed, 345 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c +1 -1
index b66f9c2eb981..fe91b0a6baf5 100644
@@ -6,9 +6,9 @@
  */
 
 #include "rvu.h"
-#include "rvu_sw.h"
 #include "rvu_sw_l2.h"
 #include "rvu_sw_fl.h"
+#include "rvu_sw.h"
 
 u32 rvu_sw_port_id(struct rvu *rvu, u16 pcifunc)
 {
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.c +202 -0

213 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.c +119 -0

132 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.h +3 -0
index a51d15c2b80e..50c4fbca81e8 100644
@@ -7,6 +7,9 @@
 #ifndef SW_FIB_H_
 #define SW_FIB_H_
 
+int sw_fib_add_to_list(struct net_device *dev,
+		       struct fib_entry *entry, int cnt);
+
 void sw_fib_deinit(void);
 int sw_fib_init(void);
 
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c +20 -0
index f5e00807c0fa..7a0ed52eae95 100644
@@ -307,6 +307,12 @@ static int sw_nb_fib_event(struct notifier_block *nb,
 		return NOTIFY_DONE;
 	}
 
+	if (sw_fib_add_to_list(pf_dev, entries, cnt)) {
+		kfree(entries);
+		kfree(haddr);
+		return NOTIFY_DONE;
+	}
+
 	if (!hcnt) {
 		kfree(haddr);
 		return NOTIFY_DONE;
@@ -336,6 +342,7 @@ static int sw_nb_fib_event(struct notifier_block *nb,
 			   iter->cmd, iter->dst, iter->dst_len, iter->gw, dev->name);
 	}
 
+	sw_fib_add_to_list(pf_dev, entries, hcnt);
 	kfree(haddr);
 	return NOTIFY_DONE;
 }
@@ -390,6 +397,9 @@ static int sw_nb_net_event(struct notifier_block *nb,
 
 		pf = netdev_priv(pf_dev);
 		entry->port_id = pf->pcifunc;
+		if (sw_fib_add_to_list(pf_dev, entry, 1))
+			kfree(entry);
+
 		break;
 	}
 
@@ -469,6 +479,11 @@ static int sw_nb_inetaddr_event(struct notifier_block *nb,
 		break;
 	}
 
+	if (sw_fib_add_to_list(pf_dev, entry, 1)) {
+		kfree(entry);
+		return NOTIFY_DONE;
+	}
+
 	netdev_dbg(dev,
 		   "%s:%d pushing inetaddr event from HOST interface address %#x, %pM, %s\n",
 		   __func__, __LINE__,  entry->dst, entry->mac, dev->name);
@@ -536,6 +551,11 @@ static int sw_nb_netdev_event(struct notifier_block *unused,
 		break;
 	}
 
+	if (sw_fib_add_to_list(pf_dev, entry, 1)) {
+		kfree(entry);
+		return NOTIFY_DONE;
+	}
+
 	netdev_dbg(dev,
 		   "%s:%d pushing netdev event from HOST interface address %#x, %pM, dev=%s\n",
 		   __func__, __LINE__,  entry->dst, entry->mac, dev->name);
Signature · 1 line
2.43.0
author maintainer
#9 lore raw

PATCH v3 9/10 octeontx2: switch: Flow offload support

In reply to Ratheesh Kannoth

OVS/NFT pushed HW acceleration rules to pf driver thru .ndo_tc(). Switchdev HW flow table is filled with this information. Once populated, flow will be accelerated.

---
 .../marvell/octeontx2/af/switch/rvu_sw.c      |   4 +
 .../marvell/octeontx2/af/switch/rvu_sw_fl.c   | 278 +++++++++
 .../marvell/octeontx2/af/switch/rvu_sw_fl.h   |   2 +
 .../ethernet/marvell/octeontx2/nic/otx2_tc.c  |  16 +-
 .../marvell/octeontx2/nic/switch/sw_fl.c      | 541 ++++++++++++++++++
 .../marvell/octeontx2/nic/switch/sw_fl.h      |   2 +
 .../marvell/octeontx2/nic/switch/sw_nb.c      |   1 -
 7 files changed, 842 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw.c +4 -0
index fe91b0a6baf5..10aed0ca5934 100644
@@ -37,6 +37,10 @@ int rvu_mbox_handler_swdev2af_notify(struct rvu *rvu,
 	case SWDEV2AF_MSG_TYPE_REFRESH_FDB:
 		rc = rvu_sw_l2_fdb_list_entry_add(rvu, req->pcifunc, req->mac);
 		break;
+
+	case SWDEV2AF_MSG_TYPE_REFRESH_FL:
+		rc = rvu_sw_fl_stats_sync2db(rvu, req->fl, req->cnt);
+		break;
 	}
 
 	return rc;
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.c +278 -0

295 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.h +2 -0
index cf3e5b884f77..aa375413bc14 100644
@@ -8,4 +8,6 @@
 #ifndef RVU_SW_FL_H
 #define RVU_SW_FL_H
 
+int rvu_sw_fl_stats_sync2db(struct rvu *rvu, struct fl_info *fl, int cnt);
+
 #endif
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +15 -1
index 26a08d2cfbb1..907f1d7da798 100644
@@ -20,6 +20,7 @@
 #include "cn10k.h"
 #include "otx2_common.h"
 #include "qos.h"
+#include "switch/sw_fl.h"
 
 #define CN10K_MAX_BURST_MANTISSA	0x7FFFULL
 #define CN10K_MAX_BURST_SIZE		8453888ULL
@@ -1238,7 +1239,6 @@ static int otx2_tc_del_flow(struct otx2_nic *nic,
 		mutex_unlock(&nic->mbox.lock);
 	}
 
-
 free_mcam_flow:
 	otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL);
 	otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false);
@@ -1595,11 +1595,25 @@ static int otx2_setup_tc_block(struct net_device *netdev,
 int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,
 		  void *type_data)
 {
+	struct otx2_nic *nic = netdev_priv(netdev);
+
 	switch (type) {
 	case TC_SETUP_BLOCK:
+		if (netif_is_ovs_port(netdev))
+			return flow_block_cb_setup_simple(type_data,
+							  &otx2_block_cb_list,
+							  sw_fl_setup_ft_block_ingress_cb,
+							  nic, nic, true);
+
 		return otx2_setup_tc_block(netdev, type_data);
 	case TC_SETUP_QDISC_HTB:
 		return otx2_setup_tc_htb(netdev, type_data);
+
+	case TC_SETUP_FT:
+		return flow_block_cb_setup_simple(type_data,
+						  &otx2_block_cb_list,
+						  sw_fl_setup_ft_block_ingress_cb,
+						  nic, nic, true);
 	default:
 		return -EOPNOTSUPP;
 	}
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c +541 -0

554 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.h +2 -0
index cd018d770a8a..8dd816eb17d2 100644
@@ -9,5 +9,7 @@
 
 void sw_fl_deinit(void);
 int sw_fl_init(void);
+int sw_fl_setup_ft_block_ingress_cb(enum tc_setup_type type,
+				    void *type_data, void *cb_priv);
 
 #endif // SW_FL_H
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c +0 -1
index 7a0ed52eae95..c316aeac2e81 100644
@@ -21,7 +21,6 @@
 #include "sw_fdb.h"
 #include "sw_fib.h"
 #include "sw_fl.h"
-#include "sw_nb.h"
 
 static const char *sw_nb_cmd2str[OTX2_CMD_MAX] = {
 	[OTX2_DEV_UP]  = "OTX2_DEV_UP",
Signature · 1 line
2.43.0
author maintainer
#10 lore raw

PATCH v3 10/10 octeontx2: switch: trace support

In reply to Ratheesh Kannoth

Traces are added to flow parsing to ease debugging.

---
 .../ethernet/marvell/octeontx2/nic/Makefile   |  2 +-
 .../marvell/octeontx2/nic/switch/sw_fl.c      | 18 +++-
 .../marvell/octeontx2/nic/switch/sw_trace.c   | 11 +++
 .../marvell/octeontx2/nic/switch/sw_trace.h   | 82 +++++++++++++++++++
 4 files changed, 109 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +1 -1
index da87e952c187..5f722d0cfac2 100644
@@ -13,7 +13,7 @@ rvu_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \
 	       switch/sw_fdb.o switch/sw_fl.o
 
 ifdef CONFIG_OCTEONTX_SWITCH
-rvu_nicpf-y += switch/sw_nb.o switch/sw_fib.o
+rvu_nicpf-y += switch/sw_nb.o switch/sw_fib.o switch/sw_trace.o
 endif
 
 rvu_nicvf-y := otx2_vf.o
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fl.c +15 -3
index c9aa0043cc4c..3ddae5d08578 100644
@@ -18,6 +18,7 @@
 #include "../otx2_struct.h"
 #include "../cn10k.h"
 #include "sw_nb.h"
+#include "sw_trace.h"
 #include "sw_fl.h"
 
 #if !IS_ENABLED(CONFIG_OCTEONTX_SWITCH)
@@ -140,6 +141,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic,
 
 		switch (act->id) {
 		case FLOW_ACTION_REDIRECT:
+			trace_sw_act_dump(__func__, __LINE__, act->id);
 			tuple->in_pf = nic->pcifunc;
 			out_nic = netdev_priv(act->dev);
 			tuple->xmit_pf = out_nic->pcifunc;
@@ -147,6 +149,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic,
 			break;
 
 		case FLOW_ACTION_CT:
+			trace_sw_act_dump(__func__, __LINE__, act->id);
 			err = nf_flow_table_offload_add_cb(act->ct.flow_table,
 							   sw_fl_setup_ft_block_ingress_cb,
 							   nic);
@@ -161,6 +164,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic,
 			break;
 
 		case FLOW_ACTION_MANGLE:
+			trace_sw_act_dump(__func__, __LINE__, act->id);
 			tuple->mangle[used].type = act->mangle.htype;
 			tuple->mangle[used].val = act->mangle.val;
 			tuple->mangle[used].mask = act->mangle.mask;
@@ -170,6 +174,7 @@ static int sw_fl_parse_actions(struct otx2_nic *nic,
 			break;
 
 		default:
+			trace_sw_act_dump(__func__, __LINE__, act->id);
 			break;
 		}
 	}
@@ -445,21 +450,28 @@ static int sw_fl_add(struct otx2_nic *nic, struct flow_cls_offload *f)
 		return 0;
 
 	rc  = sw_fl_parse_flow(nic, f, &tuple, &features);
-	if (rc)
+	if (rc) {
+		trace_sw_fl_dump(__func__, __LINE__, &tuple);
 		return -EFAULT;
+	}
 
 	if (!netif_is_ovs_port(nic->netdev)) {
 		rc = sw_fl_get_pcifunc(nic, tuple.ip4src, &tuple.in_pf,
 				       &tuple, true);
-		if (rc)
+		if (rc) {
+			trace_sw_fl_dump(__func__, __LINE__, &tuple);
 			return rc;
+		}
 
 		rc = sw_fl_get_pcifunc(nic, tuple.ip4dst, &tuple.xmit_pf,
 				       &tuple, false);
-		if (rc)
+		if (rc) {
+			trace_sw_fl_dump(__func__, __LINE__, &tuple);
 			return rc;
+		}
 	}
 
+	trace_sw_fl_dump(__func__, __LINE__, &tuple);
 	sw_fl_add_to_list(nic, &tuple, f->cookie, true);
 	return 0;
 }
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.c new file +11 -0
new file mode 100644
index 000000000000..260fd2bb3606
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell RVU Admin Function driver
+ *
+ * Copyright (C) 2026 Marvell.
+ *
+ */
+
+#define CREATE_TRACE_POINTS
+#include "sw_trace.h"
+EXPORT_TRACEPOINT_SYMBOL(sw_fl_dump);
+EXPORT_TRACEPOINT_SYMBOL(sw_act_dump);
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_trace.h new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#11 lore raw
In reply to Ratheesh Kannoth
Quoted 1 line · On Fri, 9 Jan 2026 16:00:25 +0530 Ratheesh Kannoth wrote:

Subject: [PATCH net-next v3 00/10] Switch support

The 15 patch limit applies to all your outstanding submissions. It does not mean that you can submit 2 13 patch series at the same time. I'm dropping this from patchwork.

I pointed out the tools to run to validate your patches. You are at v3 and apparently still there are trivial code linting warnings. The patch limit is to motivate people to run the linters locally instead of bombarding the list with patches that don't even build.

Signature · 1 line
pw-bot: defer