Switch support
Subsystems (4)
Ratheesh Kannoth
maintainercover Switch support
Marvell OcteonTX2 switch hardware is capable of accelerating L2, L3, and flow. When representors are enabled through devlink, a logical port is created in switch hardware for each representor device.
This patch series implements communication from the host OS to the switch hardware and vice versa.
control plane (FDB / FIB / flow over mailbox)
+---------------------------------------------------------------------+
| HOST OS |
| |
| +------------+ +---------------------+ +---------------+ |
| | bridge / | | PF + notifiers | | TC / flower | |
| | routing | | (FDB, FIB, flow) | | offload | |
| +------+-----+ +-----------+---------+ +-------+-------+ |
| ^ | | |
| | slow path | | |
| | (unmatched pkts) v v |
| +------+------+ +------+------+ +------+------+ |
| | rep-eth0 | | PF / VF | <----> | RVU AF | |
| +------+------+ +-------------+ +------+------+ |
| | | |
| +------+------+ | |
| | rep-eth1 | | |
| +-------------+ | |
| | slow path (miss / control to host stack) | |
+---------------------------------------------------------------------+
| | | |
| | mailbox / PCIe | |
| v v |
+---------------------------------------------------------------------+
| SWITCH HARDWARE |
| |
| +---------------------------------------------------+ |
| | L2 tables | L3 tables | flow TCAM (HW) | |
| +-------+-------------+---------------+-------------+ |
| | fast path (HW) | |
| v v |
| lport0 <========================> lport1 |
| HW forwarding between ports |
| |
| slow path (miss): packets raised to host via representors |
+---------------------------------------------------------------------+
When representors are created, corresponding logical ports are created in switchdev. Matching traffic is accelerated in switch hardware using installed L2, L3, and flow rules. Packets that do not match offloaded state, or that require software handling, take the slow path through representors and the host networking stack. Control updates from the host (FDB, FIB, TC flower) are sent to the AF over mailbox and programmed into switch hardware tables.
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 ingress flow-table offload path. 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. Switch-initiated FDB refresh is propagated back to the host bridge through an AF to PF/VF mailbox and switchdev notifier.
L3 acceleration:
IPv4 and IPv6 FIB updates observed through netdev and FIB notifiers are queued on the PF and sent to the AF. The AF batches fib_entry structures and forwards them to switchdev when firmware is ready.
Flow acceleration:
TC flower rules accepted by the ingress flow-table offload callback are translated into fl_tuple state, ingress and egress pcifunc are resolved through FIB lookup, and flow updates are sent to the switch hardware through the mailbox interface. Per-cookie packet counters are kept in sync using NPC MCAM multi-stats when the switch requests a flow refresh.
Ratheesh Kannoth (9):
octeontx2-af: switch: Add AF to switch mbox and skeleton files Host to switch mailbox definitions for FDB, FIB, flow, and flow stats; AF-side L2/L3/flow skeleton objects.
octeontx2-af: switch: Add switch dev to AF mboxes Switch to AF and AF to switchdev mailbox messages; interface query handler and NPC helpers for flow delete/stats/features.
octeontx2-pf: switch: Add pf files hierarchy CONFIG_OCTEONTX_SWITCH and stub PF switch objects for FDB, FIB, flow, and notifier plumbing.
octeontx2-af: switch: Representor for switch port
Copy devlink switch_id to the AF and map representor pcifunc to a switch port id when eswitch mode is enabled.
octeontx2-af: PAN switch TL1 scheduling and NPC channel control Allocate multiple TL1 scheduler queues in PAN mode and honor caller supplied NPC channel masks for multi-link steering.
octeontx2-pf: register switch notifiers for eswitch offload Register PF notifier blocks for FIB, neighbour, address, netdev, and switchdev FDB events; split IPv4/IPv6 handling.
octeontx2: plumb bridge FDB updates through AF and switchdev End-to-end L2 offload from switchdev FDB notifications to AF to switchdev, including firmware gating and FDB refresh to host.
octeontx2: offload host FIB updates to switch via AF mailbox Queue IPv4/IPv6 FIB updates from notifiers and batch fib_entry delivery from AF to switchdev.
octeontx2: add TC flow offload path for switch flows Ingress flow-table offload for TC flower rules, AF forwarding to switchdev, and flow counter refresh from switch to host.
.../net/ethernet/marvell/octeontx2/Kconfig | 13 + .../ethernet/marvell/octeontx2/af/Makefile | 3 +- .../net/ethernet/marvell/octeontx2/af/mbox.h | 227 ++++++++ .../net/ethernet/marvell/octeontx2/af/rvu.c | 110 ++++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 6 + .../ethernet/marvell/octeontx2/af/rvu_nix.c | 53 +- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 76 +++ .../marvell/octeontx2/af/rvu_npc_fs.c | 11 + .../ethernet/marvell/octeontx2/af/rvu_rep.c | 3 +- .../marvell/octeontx2/af/switch/rvu_sw.c | 48 ++ .../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 | 12 + .../marvell/octeontx2/af/switch/rvu_sw_l2.c | 283 +++++++++ .../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 | 13 +- .../marvell/octeontx2/nic/otx2_txrx.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 17 + .../net/ethernet/marvell/octeontx2/nic/rep.c | 11 + .../marvell/octeontx2/nic/switch/sw_fdb.c | 144 +++++ .../marvell/octeontx2/nic/switch/sw_fdb.h | 14 + .../marvell/octeontx2/nic/switch/sw_fib.c | 132 +++++ .../marvell/octeontx2/nic/switch/sw_fib.h | 16 + .../marvell/octeontx2/nic/switch/sw_fl.c | 546 ++++++++++++++++++ .../marvell/octeontx2/nic/switch/sw_fl.h | 15 + .../marvell/octeontx2/nic/switch/sw_nb.c | 422 ++++++++++++++ .../marvell/octeontx2/nic/switch/sw_nb.h | 35 ++ .../marvell/octeontx2/nic/switch/sw_nb_v4.c | 335 +++++++++++ .../marvell/octeontx2/nic/switch/sw_nb_v4.h | 21 + .../marvell/octeontx2/nic/switch/sw_nb_v6.c | 236 ++++++++ .../marvell/octeontx2/nic/switch/sw_nb_v6.h | 21 + 33 files changed, 3361 insertions(+), 11 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_nb_v4.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v4.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.h
--
2.43.0
Ratheesh Kannoth
maintainerPATCH 1/9 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 | 104 ++++++++++++++++++ .../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, 188 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
@@ -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 cn20k/npc.o
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +104 -0
116 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.c new file +21 -0
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Ratheesh Kannoth
maintainerPATCH 2/9 octeontx2-af: switch: Add switch dev to AF mboxes
In reply to Ratheesh KannothThe 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 | 109 ++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../ethernet/marvell/octeontx2/af/rvu_nix.c | 3 +- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 76 +++++++++++ .../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(+), 3 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
@@ -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 cn20k/npc.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 -0
115 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -1158,6 +1158,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 -2
@@ -32,7 +32,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 ,
@@ -2087,7 +2086,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);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +76 -0
88 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +11 -0
@@ -1926,6 +1926,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
@@ -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
@@ -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
Ratheesh Kannoth
maintainerPATCH 3/9 octeontx2-pf: switch: Add pf files hierarchy
In reply to Ratheesh KannothAdds CONFIG_OCTEONTX_SWITCH, links stub switch objects into the PF module, and introduces empty sw_* init/deinit and notifier hooks for later patches.
--- drivers/net/ethernet/marvell/octeontx2/Kconfig | 13 +++++++++++++ .../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, 137 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 +13 -0
@@ -28,6 +28,19 @@ 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 + depends on OCTEONTX2_PF + help + This driver supports Marvell's OcteonTX2 switch driver. + Marvell SWITCH HW can offload L2, L3 flow. 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Re: [PATCH net-next 3/9] octeontx2-pf: switch: Add pf files hierarchy
Hi Ratheesh,
drivers/net/ethernet/marvell/octeontx2/Kconfig config NDC_DIS_DYNAMIC_CACHING · line 38
Quoted 8 lines · Ratheesh Kannoth
drivers/net/ethernet/marvell/octeontx2/Kconfig +8
-0+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 + depends on OCTEONTX2_PF
Could you keep the 'select's together (move the 'default')?
- Julian Braha
Ratheesh Kannoth
maintainerPATCH 4/9 octeontx2-af: switch: Representor for switch port
In reply to Ratheesh KannothExtends esw_cfg with a devlink-derived switch id, copies it into rvu->rswitch on the AF, adds rvu_sw_port_id(), exports rvu_rep_get_vlan_id().
--- 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 | 15 +++++++++++++++ .../ethernet/marvell/octeontx2/af/switch/rvu_sw.h | 3 +++ drivers/net/ethernet/marvell/octeontx2/nic/rep.c | 4 ++++ 6 files changed, 30 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -0
@@ -1832,6 +1832,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
@@ -576,6 +576,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 {
@@ -1197,4 +1201,5 @@ 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);int npc_mcam_verify_entry (struct npc_mcam *mcam,u16 pcifunc,int entry); +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
@@ -189,7 +189,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;
@@ -436,6 +436,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 +15 -0
@@ -5,7 +5,22 @@* */ +#include <linux/bitfield.h> #include "rvu.h" +#include "rvu_sw.h" + +u32 rvu_sw_port_id (struct rvu *rvu,u16 pcifunc) +{ +u32 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
@@ -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
@@ -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
Ratheesh Kannoth
maintainerPATCH 5/9 octeontx2-af: PAN switch TL1 scheduling and NPC channel control
In reply to Ratheesh KannothSwitch (PAN) mode needs more than one TL1 scheduler queue index so the hardware can steer traffic to different links according to NPC flow rules, not only the PF/VF default Tx link.
Add NIX_TXSCH_ALLOC_FLAG_PAN to nix_txsch_alloc requests: use the PAN link index for scheduler range calculation, allow multiple TL1 queues when the aggregate level spans start..end, and allocate indices in that range. Add TXSCHQ_FREE_PAN_TL1 so TL1 entries in that path can be freed via nix_txsch_free where they were previously skipped. For NPC install flow, add set_chanmask so callers can keep a non-default chan_mask when the requester is not the AF; without it, chan_mask was always forced to 0xFFF for non-AF functions.
Allocate the NIX LF SQ bitmap with the same span used by bitmap_weight(..., BITS_PER_LONG * 16) in rvu_get_hwinfo(). Extend struct sg_list with cq_idx and len for transmit-side metadata.
--- .../net/ethernet/marvell/octeontx2/af/mbox.h | 4 ++ .../ethernet/marvell/octeontx2/af/rvu_nix.c | 50 ++++++++++++++++--- .../marvell/octeontx2/nic/otx2_txrx.h | 2 + 3 files changed, 50 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +4 -0
@@ -1157,6 +1157,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 {
@@ -1175,6 +1177,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;
@@ -2078,6 +2081,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/nic/otx2_txrx.h +2 -0
@@ -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
Ratheesh Kannoth
maintainerPATCH 6/9 octeontx2-pf: register switch notifiers for eswitch offload
In reply to Ratheesh KannothThe representor enables switch mode via devlink; register and unregister the switch notifier blocks when that mode is turned on or off so the PF can observe FIB routes, neighbour updates, IPv4/IPv6 address changes, netdev state, and switchdev FDB notifications.
Add sw_nb_v4.c and sw_nb_v6.c for IPv4 and IPv6-specific handling, build sw_nb_v6.o only when CONFIG_IPV6 is set, and extend sw_nb.c with device filtering for Cavium ports behind bridges and VLANs. Initialize and tear down the existing sw_fdb, sw_fib, and sw_fl helpers together with notifier registration.
--- .../ethernet/marvell/octeontx2/nic/Makefile | 7 +- .../net/ethernet/marvell/octeontx2/nic/rep.c | 9 + .../marvell/octeontx2/nic/switch/sw_nb.c | 410 +++++++++++++++++- .../marvell/octeontx2/nic/switch/sw_nb.h | 28 +- .../marvell/octeontx2/nic/switch/sw_nb_v4.c | 323 ++++++++++++++ .../marvell/octeontx2/nic/switch/sw_nb_v4.h | 21 + .../marvell/octeontx2/nic/switch/sw_nb_v6.c | 237 ++++++++++ .../marvell/octeontx2/nic/switch/sw_nb_v6.h | 21 + 8 files changed, 1050 insertions(+), 6 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v4.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v4.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.h
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +6 -1
@@ -13,7 +13,12 @@ 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_nb_v4.o + +ifdef CONFIG_IPV6 +rvu_nicpf-y += switch/sw_nb_v6.o +endif endif rvu_nicvf-y := otx2_vf.o
drivers/net/ethernet/marvell/octeontx2/nic/rep.c +9 -0
@@ -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,9 @@ static void rvu_rep_get_stats64(struct net_device *dev,static int rvu_eswitch_config (struct otx2_nic *priv,u8 ena) { +#if IS_ENABLED (CONFIG_OCTEONTX_SWITCH ) +struct net_device *netdev = priv->netdev; +#endif struct devlink_port_attrs attrs = {};struct esw_cfg_req *req;
@@ -414,6 +418,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 +408 -2
422 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.h +25 -3
@@ -7,7 +7,29 @@#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 , +}; -#endif // SW_NB_H_ +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); + +bool sw_nb_is_cavium_dev (struct net_device *netdev); +int sw_nb_fib_event_to_otx2_event (int event,struct net_device *netdev); +int sw_nb_inetaddr_event_to_otx2_event (int event,struct net_device *netdev); + +const char *sw_nb_get_cmd2str (int cmd); +#endif // SW_NB_H__
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v4.c new file +323 -0
323 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v4.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell switch driver +* +* Copyright (C) 2026 Marvell. +* +*/ +#ifndef SW_NB_V4_H_ +#define SW_NB_V4_H_ + +int sw_nb_v4_fib_event (struct notifier_block *nb, +unsigned long event,void *ptr); + +int sw_nb_net_v4_neigh_update (struct notifier_block *nb, +unsigned long event,void *ptr); + +int sw_nb_v4_inetaddr_event (struct notifier_block *nb, +unsigned long event,void *ptr); + +int sw_nb_v4_netdev_event (struct notifier_block *unused, +unsigned long event,void *ptr); +#endif // SW_NB_V4_H__
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.c new file +237 -0
237 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell switch driver +* +* Copyright (C) 2026 Marvell. +* +*/ +#ifndef SW_NB_V6_H_ +#define SW_NB_V6_H_ + +int sw_nb_v6_fib_event (struct notifier_block *nb, +unsigned long event,void *ptr); + +int sw_nb_net_v6_neigh_update (struct notifier_block *nb, +unsigned long event,void *ptr); + +int sw_nb_v6_inetaddr_event (struct notifier_block *nb, +unsigned long event,void *ptr); + +int sw_nb_v6_netdev_event (struct notifier_block *unused, +unsigned long event,void *ptr); +#endif // SW_NB_V6_H__
Signature · 1 line
2.43.0
Ratheesh Kannoth
maintainerPATCH 7/9 octeontx2: plumb bridge FDB updates through AF and switchdev
In reply to Ratheesh KannothHandle switchdev FDB add and delete notifications on the PF by queuing work that sends fdb_notify mailbox messages to the AF. The AF queues those updates and pushes L2 rules toward the switchdev image with af2swdev notify messages when firmware is ready.
Teach the AF swdev2af path to initialize L2 offload workqueues on firmware up/down and to accept refresh requests that enqueue FDB entries for AF to PF mailbox delivery. Add an AF to PF (and VF) upstream message for FDB refresh, handle it in the VF driver, and treat it like the CGX link event when acknowledging mailbox completion in the AF. On refresh, invoke the switchdev notifier so the host bridge can learn the updated FDB entry.
--- .../net/ethernet/marvell/octeontx2/af/rvu.c | 1 + .../marvell/octeontx2/af/switch/rvu_sw.c | 16 +- .../marvell/octeontx2/af/switch/rvu_sw_l2.c | 269 ++++++++++++++++++ .../marvell/octeontx2/af/switch/rvu_sw_l2.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 17 ++ .../marvell/octeontx2/nic/switch/sw_fdb.c | 128 +++++++++ .../marvell/octeontx2/nic/switch/sw_fdb.h | 1 + .../marvell/octeontx2/nic/switch/sw_nb.c | 2 + 8 files changed, 435 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -0
@@ -2572,6 +2572,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 +15 -1
@@ -8,6 +8,8 @@#include <linux/bitfield.h> #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) {
@@ -26,5 +28,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 +269 -0
280 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l2.h +2 -0
@@ -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
@@ -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 +128 -0
141 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fdb.h +1 -0
@@ -7,6 +7,7 @@#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 );
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb.c +2 -0
@@ -117,11 +117,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 :
Signature · 1 line
2.43.0
Ratheesh Kannoth
maintainerPATCH 8/9 octeontx2: offload host FIB updates to switch via AF mailbox
In reply to Ratheesh KannothQueue IPv4/IPv6 FIB-derived updates from the switch notifier path and handle fib_notify in the RVU AF by batching fib_entry structures and sending them to the switch PF through the AF-to-switchdev FIB_CMD). Require the switch firmware to be ready before accepting offload work.
--- .../net/ethernet/marvell/octeontx2/af/mbox.h | 2 +- .../marvell/octeontx2/af/switch/rvu_sw_l3.c | 187 ++++++++++++++++++ .../marvell/octeontx2/nic/switch/sw_fib.c | 103 ++++++++++ .../marvell/octeontx2/nic/switch/sw_fib.h | 3 + .../marvell/octeontx2/nic/switch/sw_nb.c | 10 +- .../marvell/octeontx2/nic/switch/sw_nb_v4.c | 26 ++- .../marvell/octeontx2/nic/switch/sw_nb_v6.c | 10 +- 7 files changed, 324 insertions(+), 17 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -1
@@ -1968,7 +1968,7 @@ struct af2swdev_notify_req { };struct {u8 cnt; -struct fib_entry entry[16 ]; +struct fib_entry entry[12 ]; };struct {
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_l3.c +187 -0
198 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.c +103 -0
116 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_fib.h +3 -0
@@ -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 +6 -4
@@ -109,6 +109,7 @@ static int sw_nb_fdb_event(struct notifier_block *unused, {struct net_device *dev =switchdev_notifier_info_to_dev (ptr);struct switchdev_notifier_fdb_info *fdb_info = ptr; +int rc =0 ;if (!sw_nb_is_valid_dev (dev))return NOTIFY_DONE ;
@@ -117,19 +118,22 @@ 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); + rc =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); + rc =sw_fdb_add_to_list (dev, (u8 *)fdb_info->addr, false);break ;default :return NOTIFY_DONE ; } +if (rc) +netdev_err (dev,"%s: Error to add to list\n" , __func__); +return NOTIFY_DONE ; }
@@ -298,11 +302,9 @@ static int sw_nb_netdev_event(struct notifier_block *unused,if (idev)sw_nb_v4_netdev_event (unused, event, ptr); -#if IS_ENABLED (CONFIG_IPV6 ) i6dev =__in6_dev_get (dev);if (i6dev)sw_nb_v6_netdev_event (unused, event, ptr); -#endif return NOTIFY_DONE ; }
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v4.c +18 -8
@@ -71,9 +71,10 @@ int sw_nb_v4_netdev_event(struct notifier_block *unused,break ; } +sw_fib_add_to_list (pf_dev, entry,1 ); +netdev_dbg (dev,"%s: pushing netdev event from HOST interface address %#x, %pM, dev=%s\n" , __func__, entry->dst, entry->mac, dev->name); -kfree (entry);return NOTIFY_DONE ; }
@@ -131,7 +132,7 @@ int sw_nb_v4_inetaddr_event(struct notifier_block *nb,netdev_dbg (dev,"%s: pushing inetaddr event from HOST interface address %#x, %pM, %s\n" , __func__, entry->dst, entry->mac, dev->name); -kfree (entry); +sw_fib_add_to_list (pf_dev, entry,1 );return NOTIFY_DONE ; }
@@ -243,18 +244,26 @@ int sw_nb_v4_fib_event(struct notifier_block *nb, } cnt = iter - entries; -if (!cnt) +if (!cnt) { +kfree (entries); +kfree (haddr);return NOTIFY_DONE ; + }netdev_dbg (pf_dev,"pf_dev is %s cnt=%d\n" , pf_dev->name, cnt); -kfree (entries); -if (!hcnt) +sw_fib_add_to_list (pf_dev, entries, cnt); + +if (!hcnt) { +kfree (haddr);return NOTIFY_DONE ; + } entries =kcalloc (hcnt,sizeof (*entries),GFP_ATOMIC ); -if (!entries) +if (!entries) { +kfree (haddr);return NOTIFY_DONE ; + } iter = entries;
@@ -274,7 +283,7 @@ int sw_nb_v4_fib_event(struct notifier_block *nb,netdev_dbg (pf_dev,"%s: FIB host Rule cmd=%lld dst=%#x dst_len=%d gw=%#x %s\n" , __func__, iter->cmd, iter->dst, iter->dst_len, iter->gw, pf_dev->name); } -kfree (entries); +sw_fib_add_to_list (pf_dev, entries, hcnt);kfree (haddr);return NOTIFY_DONE ; }
@@ -315,7 +324,8 @@ int sw_nb_net_v4_neigh_update(struct notifier_block *nb, pf =netdev_priv (pf_dev); entry->port_id = pf->pcifunc; -kfree (entry); +sw_fib_add_to_list (pf_dev, entry,1 ); +return NOTIFY_DONE ; err:kfree (entry);
drivers/net/ethernet/marvell/octeontx2/nic/switch/sw_nb_v6.c +6 -4
@@ -63,10 +63,10 @@ int sw_nb_v6_netdev_event(struct notifier_block *unused,ether_addr_copy (entry->mac, dev_addr->addr);break ; } +sw_fib_add_to_list (dev, entry,1 );netdev_dbg (dev,"netdev event %pM plen=%u mac=%pM\n" , &ifp->addr, ifp->prefix_len, entry->mac); -kfree (entry);return NOTIFY_DONE ; }
@@ -145,8 +145,8 @@ int sw_nb_v6_fib_event(struct notifier_block *nb,netdev_dbg (fib_dev,"fib found MAC=%pM\n" , entry->mac); } +sw_fib_add_to_list (fib_dev, entry,1 );rcu_read_unlock (); -kfree (entry);return NOTIFY_DONE ; }
@@ -180,9 +180,10 @@ int sw_nb_net_v6_neigh_update(struct notifier_block *nb, entry->mac_valid =1 ; entry->port_id = pf->pcifunc; +sw_fib_add_to_list (pf_dev, entry,1 ); +netdev_dbg (n->dev,"v6 neigh update %pI6 mac=%pM plen=%u\n" , n->primary_key, n->ha, n->tbl->key_len *8 ); -kfree (entry);return NOTIFY_DONE ; }
@@ -228,9 +229,10 @@ int sw_nb_v6_inetaddr_event(struct notifier_block *nb,break ; } +sw_fib_add_to_list (dev, entry,1 ); +netdev_dbg (dev,"inetaddr addr=%pI6c len=%u %pM\n" , &ifa6->addr, ifa6->prefix_len, entry->mac); -kfree (entry);return NOTIFY_DONE ; }
Signature · 1 line
2.43.0
Ratheesh Kannoth
maintainerPATCH 9/9 octeontx2: add TC flow offload path for switch flows
In reply to Ratheesh KannothRegister an ingress flow-table offload callback that translates TC flower rules into fl_tuple state, resolves ingress and egress pcifunc via FIB for accelerated ports, and notifies the RVU AF over the PF mailbox. The AF forwards flow updates to switchdev and keeps per-cookie packet counters in sync using NPC MCAM multi-stats when the switch requests SWDEV2AF refresh.
--- .../marvell/octeontx2/af/switch/rvu_sw.c | 8 +- .../marvell/octeontx2/af/switch/rvu_sw_fl.c | 264 +++++++++ .../marvell/octeontx2/af/switch/rvu_sw_fl.h | 1 + .../ethernet/marvell/octeontx2/nic/Makefile | 2 +- .../marvell/octeontx2/nic/switch/sw_fl.c | 541 ++++++++++++++++++ .../marvell/octeontx2/nic/switch/sw_fl.h | 2 + .../marvell/octeontx2/nic/switch/sw_trace.c | 13 + .../marvell/octeontx2/nic/switch/sw_trace.h | 82 +++ 8 files changed, 910 insertions(+), 3 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/af/switch/rvu_sw.c +6 -2
@@ -7,13 +7,13 @@#include <linux/bitfield.h> #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) { -u32 port_id; +u16 port_id;u16 rep_id; rep_id =rvu_rep_get_vlan_id (rvu, pcifunc);
@@ -38,6 +38,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 +264 -0
281 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/switch/rvu_sw_fl.h +1 -0
@@ -7,5 +7,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/Makefile +1 -1
@@ -10,7 +10,7 @@ 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 \ - switch/sw_fdb.o switch/sw_fl.o + switch/sw_fdb.o switch/sw_fl.o switch/sw_trace.o ifdef CONFIG_OCTEONTX_SWITCH rvu_nicpf-y += switch/sw_nb.o switch/sw_fib.o \
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
@@ -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_trace.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell RVU Admin Function driver +* +* Copyright (C) 2026 Marvell. +* +*/ + +#define CREATE_TRACE_POINTS +#if IS_ENABLED (CONFIG_OCTEONTX_SWITCH ) +#include "sw_trace.h" +EXPORT_TRACEPOINT_SYMBOL (sw_fl_dump); +EXPORT_TRACEPOINT_SYMBOL (sw_act_dump); +#endif
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
Jakub Kicinski
maintainerQuoted 3 lines · On Tue, 30 Jun 2026 08:17:06 +0530 Ratheesh Kannoth wrote:
Marvell OcteonTX2 switch hardware is capable of accelerating L2, L3, and flow. When representors are enabled through devlink, a logical port is created in switch hardware for each representor device.
There's a number of allocations here which are missing a NULL check.
I'm sure sashiko will also have semi-infinite number of complaints, so please check that yourself.
Signature · 1 line
pw-bot: cr