Skip to content

DSA tag protocol support #93010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion boards/nxp/imx943_evk/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ CPU's UART1 for Cortex-A55, and UART8 for Cortex-M33.
Ethernet
--------

NETC driver supports to manage the Physical Station Interface (PSI).
NETC driver supports to manage the Physical Station Interface (PSI), and TSN switch.
The ENET0, ENETC1, ENETC2 ports could be enabled for M33 by west build option
``-DEXTRA_DTC_OVERLAY_FILE=enetc.overlay``.

The two switch ports could be verified via :zephyr:code-sample:`dsa`.

Programming and Debugging (A55)
*******************************

Expand Down
32 changes: 28 additions & 4 deletions boards/nxp/imx943_evk/imx943_evk_mimx94398_m33.dts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
pinctrl-names = "default";
status = "disabled";

phy0: phy@f {
phy0: phy@2 {
compatible = "ethernet-phy";
reg = <0xf>;
reg = <0x2>;
status = "disabled";
};

phy1: phy@10 {
phy1: phy@3 {
compatible = "ethernet-phy";
reg = <0x10>;
reg = <0x3>;
status = "disabled";
};

Expand Down Expand Up @@ -105,3 +105,27 @@
pinctrl-0 = <&lpuart8_default>;
pinctrl-names = "default";
};

&switch_port0 {
zephyr,random-mac-address;
pinctrl-0 = <&eth0_default>;
pinctrl-names = "default";
phy-handle = <&phy0>;
phy-connection-type = "mii";
status = "disabled";
};

&switch_port1 {
zephyr,random-mac-address;
pinctrl-0 = <&eth1_default>;
pinctrl-names = "default";
phy-handle = <&phy1>;
phy-connection-type = "mii";
status = "disabled";
};

/* Internal port */
&switch_port3 {
zephyr,random-mac-address;
status = "disabled";
};
1 change: 1 addition & 0 deletions drivers/ethernet/dsa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library_sources_ifdef(CONFIG_DSA_KSZ8XXX dsa_ksz8xxx.c)
zephyr_library_sources_ifdef(CONFIG_DSA_NXP_IMX_NETC dsa_nxp_imx_netc.c)
44 changes: 13 additions & 31 deletions drivers/ethernet/dsa/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Distributed Switch Architecture [DSA] configuration options
# Distributed Switch Architecture [DSA] device configuration options

# Copyright (c) 2020 DENX Software Engineering GmbH
# Lukasz Majewski <[email protected]>
# Copyright 2025 NXP
# SPDX-License-Identifier: Apache-2.0

config ETH_DSA_SUPPORT_DEPRECATED
Expand All @@ -10,25 +11,13 @@ config ETH_DSA_SUPPORT_DEPRECATED
Set by an ethernet driver that supports DSA. This is obsolete,
and only used for legacy dsa device.

menuconfig NET_DSA
bool "Distributed Switch Architecture support"
menuconfig DSA_DRIVERS
bool "Distributed Switch Architecture device drivers"
default y if NET_DSA
help
Enable Distributed Switch Architecture support.

if NET_DSA

config NET_DSA_DEPRECATED
bool "Distributed Switch Architecture support for legacy device"
select DEPRECATED
depends on ETH_DSA_SUPPORT_DEPRECATED
help
This is obsolete, and only used for legacy dsa device.

config DSA_PORT_MAX_COUNT
int "DSA port max count"
default 8
help
Set DSA port max count.
if DSA_DRIVERS

config DSA_KSZ8XXX
bool
Expand Down Expand Up @@ -66,14 +55,6 @@ config DSA_KSZ_TAIL_TAGGING
help
Add support for tail tagging on DSA device.

config DSA_TAG_SIZE
int "DSA tag size in bytes"
default 1 if DSA_KSZ8794 || DSA_KSZ8863 || DSA_KSZ8463
default 0
depends on DSA_KSZ_TAIL_TAGGING
help
Set the DSA tag length in bytes.

config DSA_KSZ_PORT_ISOLATING
bool "Support for ports isolating"
depends on DSA_KSZ8794 || DSA_KSZ8863 || DSA_KSZ8463
Expand All @@ -86,10 +67,11 @@ config DSA_SPI
help
Use SPI bus to communicate with PHY

module = NET_DSA
module-dep = NET_LOG
module-str = Log level for DSA
module-help = Enables core DSA code to output debug messages.
source "subsys/net/Kconfig.template.log_config.net"
config DSA_NXP_IMX_NETC
bool "Support for NXP i.MX NETC"
default y
depends on DT_HAS_NXP_NETC_SWITCH_ENABLED
help
Add support for NXP i.MX NETC DSA device driver.

endif # NET_DSA
endif # DSA_DRIVERS
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ LOG_MODULE_REGISTER(dsa_netc, CONFIG_ETHERNET_LOG_LEVEL);

#include <zephyr/net/ethernet.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/ethernet/nxp_imx_netc.h>
#include <zephyr/dt-bindings/ethernet/dsa_tag_proto.h>

#include "../eth.h"
#include "nxp_imx_netc.h"
#include "fsl_netc_switch.h"

#define DT_DRV_COMPAT nxp_netc_switch
Expand Down Expand Up @@ -128,6 +129,7 @@ static struct dsa_api dsa_netc_api = {
.port_idx = DT_REG_ADDR(port), \
.phy_dev = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, phy_handle)), \
.phy_mode = DT_PROP_OR(port, phy_connection_type, ""), \
.tag_proto = DT_PROP_OR(port, dsa_tag_protocol, DSA_TAG_PROTO_NOTAG), \
.ethernet_connection = DEVICE_DT_GET_OR_NULL(DT_PHANDLE(port, ethernet)), \
.prv_config = &dsa_netc_##n##_##port##_config, \
}; \
Expand Down
2 changes: 0 additions & 2 deletions drivers/ethernet/nxp_imx_netc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ if(CONFIG_ETH_NXP_IMX_NETC)
zephyr_library_sources(eth_nxp_imx_netc_psi.c)
zephyr_library_sources_ifdef(CONFIG_DT_HAS_NXP_IMX_NETC_BLK_CTRL_ENABLED eth_nxp_imx_netc_blk.c)
endif()

zephyr_library_sources_ifdef(CONFIG_DSA_NXP_IMX_NETC dsa_nxp_imx_netc.c)
11 changes: 0 additions & 11 deletions drivers/ethernet/nxp_imx_netc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,3 @@ config ETH_NXP_IMX_RX_RING_BUF_SIZE
store one complete Ethernet frame, and be a multiple of 8.

endif # ETH_NXP_IMX_NETC

if NET_DSA

config DSA_NXP_IMX_NETC
bool "Support for NXP i.MX NETC"
default y
depends on DT_HAS_NXP_NETC_SWITCH_ENABLED
help
Add support for NXP i.MX NETC DSA device driver.

endif
8 changes: 3 additions & 5 deletions drivers/ethernet/nxp_imx_netc/eth_nxp_imx_netc.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ int netc_eth_init_common(const struct device *dev)

int netc_eth_tx(const struct device *dev, struct net_pkt *pkt)
{
const struct netc_eth_config *cfg = dev->config;
struct netc_eth_data *data = dev->data;
netc_buffer_struct_t buff = {.buffer = data->tx_buff, .length = sizeof(data->tx_buff)};
netc_frame_struct_t frame = {.buffArray = &buff, .length = 1};
Expand All @@ -376,6 +375,7 @@ int netc_eth_tx(const struct device *dev, struct net_pkt *pkt)
size_t pkt_len = net_pkt_get_len(pkt);
#if defined(NETC_HAS_NO_SWITCH_TAG_SUPPORT)
struct ethernet_context *eth_ctx = net_if_l2_data(data->iface);
const struct netc_eth_config *cfg = dev->config;
#endif
status_t result;
int ret;
Expand All @@ -387,18 +387,16 @@ int netc_eth_tx(const struct device *dev, struct net_pkt *pkt)

iface_dst = data->iface;

if (cfg->pseudo_mac) {
#if defined(NETC_HAS_NO_SWITCH_TAG_SUPPORT)
if (cfg->pseudo_mac) {
/* DSA conduit port not used */
if (eth_ctx->dsa_port != DSA_CONDUIT_PORT) {
return -ENOSYS;
}
/* DSA driver redirects the iface */
iface_dst = pkt->iface;
#else
return -ENOSYS;
#endif
}
#endif

k_mutex_lock(&data->tx_mutex, K_FOREVER);

Expand Down
2 changes: 1 addition & 1 deletion drivers/ethernet/nxp_imx_netc/eth_nxp_imx_netc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef ZEPHYR_DRIVERS_ETHERNET_ETH_NXP_IMX_NETC_PRIV_H_
#define ZEPHYR_DRIVERS_ETHERNET_ETH_NXP_IMX_NETC_PRIV_H_

#include "nxp_imx_netc.h"
#include <zephyr/drivers/ethernet/nxp_imx_netc.h>
#include "fsl_netc_endpoint.h"
#ifndef CONFIG_ETH_NXP_IMX_NETC_MSI_GIC
#include "fsl_msgintr.h"
Expand Down
50 changes: 50 additions & 0 deletions dts/arm/nxp/nxp_imx943_m33.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <arm/armv8-m.dtsi>
#include <zephyr/dt-bindings/clock/imx943_clock.h>
#include <zephyr/dt-bindings/ethernet/dsa_tag_proto.h>
#include <mem.h>
#include <freq.h>

Expand Down Expand Up @@ -332,6 +333,18 @@
status = "disabled";
};

/* Internal port */
enetc_psi3: ethernet@4cd40000 {
compatible = "nxp,imx-netc-psi";
reg = <0x4cd40000 0x10000>,
<0x4ca00000 0x1000>;
reg-names = "port", "pfconfig";
mac-index = <3>;
si-index = <3>;
phy-connection-type = "internal";
status = "disabled";
};

netc_ptp_clock0: ptp_clock@4cd80000 {
compatible = "nxp,netc-ptp-clock";
reg = <0x4cd80000 0x10000>;
Expand Down Expand Up @@ -363,6 +376,43 @@
#size-cells = <0>;
status = "disabled";
};

netc_switch: switch {
compatible = "nxp,netc-switch";
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;

switch_port0: switch_port@0 {
compatible = "zephyr,dsa-port";
reg = <0>;
status = "disabled";
};

switch_port1: switch_port@1 {
compatible = "zephyr,dsa-port";
reg = <1>;
status = "disabled";
};

/* Parallel interface is muxed with enetc_psi0. */
switch_port2: switch_port@2 {
compatible = "zephyr,dsa-port";
reg = <2>;
status = "disabled";
};

/* Internal port */
switch_port3: switch_port@3 {
compatible = "zephyr,dsa-port";
reg = <3>;
ethernet = <&enetc_psi3>;
phy-connection-type = "internal";
dsa-tag-protocol = <DSA_TAG_PROTO_NETC>;
status = "disabled";
};
};

};
};
};
Expand Down
7 changes: 7 additions & 0 deletions dts/arm/nxp/nxp_rt118x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <dt-bindings/i2c/i2c.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/ethernet/dsa_tag_proto.h>

/ {
aliases {
Expand Down Expand Up @@ -663,30 +664,36 @@
#size-cells = <0>;

switch_port0: switch_port@0 {
compatible = "zephyr,dsa-port";
reg = <0>;
status = "disabled";
};

switch_port1: switch_port@1 {
compatible = "zephyr,dsa-port";
reg = <1>;
status = "disabled";
};

switch_port2: switch_port@2 {
compatible = "zephyr,dsa-port";
reg = <2>;
status = "disabled";
};

switch_port3: switch_port@3 {
compatible = "zephyr,dsa-port";
reg = <3>;
status = "disabled";
};

/* Internal port */
switch_port4: switch_port@4 {
compatible = "zephyr,dsa-port";
reg = <4>;
ethernet = <&enetc_psi1>;
phy-connection-type = "internal";
dsa-tag-protocol = <DSA_TAG_PROTO_NOTAG>;
status = "disabled";
};
};
Expand Down
9 changes: 8 additions & 1 deletion dts/bindings/dsa/dsa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
description: DSA Device

child-binding:
description: Properties of slave port
description: Properties of port

compatible: "zephyr,dsa-port"

include:
- name: pinctrl-device.yaml
Expand All @@ -25,3 +27,8 @@ child-binding:
description:
A phandle to a valid Ethernet device node. This host
device is what the switch port is connected to.
dsa-tag-protocol:
type: int
description:
Tag protocol the switch using. The <zephyr/dt-bindings/ethernet/dsa_tag_proto.h>
which provides macros should be included to use.
14 changes: 14 additions & 0 deletions include/zephyr/dt-bindings/ethernet/dsa_tag_proto.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright 2025 NXP
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_DSA_TAG_PROTO_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_DSA_TAG_PROTO_H_

/* No switch tag protocol supported */
#define DSA_TAG_PROTO_NOTAG 0
/* NXP NETC switch tag protocol */
#define DSA_TAG_PROTO_NETC 1

#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_DSA_TAG_PROTO_H_ */
2 changes: 2 additions & 0 deletions include/zephyr/net/dsa_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ struct dsa_port_config {
const struct device *phy_dev;
/** PHY mode */
const char *phy_mode;
/** Tag protocol */
const int tag_proto;
/** Ethernet device connected to the port */
const struct device *ethernet_connection;
/** Instance specific config */
Expand Down
1 change: 1 addition & 0 deletions samples/net/dsa/boards/imx943_evk_mimx94398_m33_ddr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_NET_SAMPLE_DSA_LLDP=n
Loading