-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Introduce new DSA switch framework #87045
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
Conversation
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yangbolu1991 - Thank you for your work put to port relevant pieces of Linux DSA driver to Zephyr.
Generally, for me the code looks OK. It is also great that you added the detailed documentation for DSA subsystem to Zephyr.
Currently the https://docs.zephyrproject.org/latest/boards/segger/ip_k66f/doc/index.html board (including its sample LLDP protocol program) uses the NET_DSA_LEGACY
but I think that it shall finally support the new framework.
doc/connectivity/networking/dsa.rst
Outdated
| Switch | | ||
|+------+ +------+ +------+ +------+| | ||
|| swp0 | | swp1 | | swp2 | | swp3 || | ||
++------+-+------+-+------+-+------++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could the rx/tx diagram in #87091, but not use this diagram which is from Linux kernel document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will replace it.
Thanks.
subsys/net/l2/ethernet/dsa/dsa.c
Outdated
/* | ||
* Copyright (c) 2018 Intel Corporation | ||
* Copyright 2025 NXP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to our discussion, let's add a "dsa_" prefix in order to follow the same naming rules in Zephyr driver, for example, use "dsa_core.c dsa_port.c dsa_salve.c ..."
Another suggestion, in order to make the old architectrue code and new architecuture code works simulteneously in new architecuture developing period, let's don't modify the old file directly, we could create new architeccture code in each new clean file, so that we could define which files can be compiled in cmake according to CONFIG_NET_DSA_DEPRECATED.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense. That will make code much clear. Will do that.
Thank you very much.
70ffad8
to
2606c9b
Compare
Rebased to trigger CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new DSA switch framework for Zephyr aligned with the Linux DSA model. Key changes include updating header files and typedefs to use the new DSA naming (e.g. “user” and “conduit” instead of “slave” and “master”), adding a new dsa_core.h for DSA core APIs, and updating DTS bindings and Ethernet drivers (including nxp_imx_netc, eth_stm32_hal, and eth_nxp_enet) to support the new framework.
Reviewed Changes
Copilot reviewed 32 out of 41 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
include/zephyr/net/ethernet.h | Adjusted conditional inclusion and renamed DSA port enums to reflect new architecture. |
include/zephyr/net/dsa_core.h | Introduces core DSA framework interfaces and data structures. |
dts/bindings/dsa/*.yaml | Unifies DTS bindings for DSA by including a common dsa.yaml file. |
drivers/ethernet/nxp_imx_netc/* | Updated NETC driver code to use new DSA handling, including revised Tx descriptor reclamation and DSA port handling. |
drivers/ethernet/dsa/dsa_ksz8xxx.c | Updated capability bit masks to align with new DSA port naming. |
drivers/ethernet/eth_stm32_hal.c, eth_nxp_enet.c | Updated usage of DSA conditional compilation to use CONFIG_NET_DSA_DEPRECATED for backward compatibility. |
Files not reviewed (9)
- boards/nxp/mimxrt1180_evk/mimxrt1180_evk.dtsi: Language not supported
- doc/connectivity/networking/dsa.rst: Language not supported
- doc/connectivity/networking/index.rst: Language not supported
- doc/releases/migration-guide-4.2.rst: Language not supported
- drivers/ethernet/Kconfig.nxp_enet: Language not supported
- drivers/ethernet/Kconfig.sam_gmac: Language not supported
- drivers/ethernet/Kconfig.stm32_hal: Language not supported
- drivers/ethernet/dsa/Kconfig: Language not supported
- drivers/ethernet/nxp_imx_netc/Kconfig: Language not supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments related to docs.
Also, did was this presented/discussed in the Architecture WG?
include/zephyr/net/dsa_core.h
Outdated
/** | ||
* @brief Distributed Switch Architecture (DSA) | ||
* @defgroup dsa_core Distributed Switch Architecture (DSA) | ||
* @since 2.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I once hesitated to use 2.5 or not previously, as the legacy dsa.h existed.
Let me use 4.2 I think it makes sense since it's new file added.
Thanks.
doc/connectivity/networking/dsa.rst
Outdated
- ``DSA_SWITCH_INST_INIT(n, _dapi, data, fn)`` | ||
- ``DSA_PORT_INST_INIT(port, n, cfg)`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if these macros are API please don't put them in a hidden Doxygen block. Also, please cross reference them using :c:macro:
role
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will do that.
I put it in hidden doxygen block was because I thought it's used only by drivers. And the doc was describing device driver support.
Let me move them and related structures out. I think maybe it's better for device driver developer to understand and for cross reference.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please review the entire file for Doxygen comments. It looks like you have put a lot more as "internal" stuff as you may have orginally intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... I had intended to hidden most.
But let me expose APIs/structure related to device driver support. That may be useful for device driver developer to read doc.
Thanks.
doc/connectivity/networking/dsa.rst
Outdated
- ``DSA_SWITCH_INST_INIT(n, _dapi, data, fn)`` | ||
- ``DSA_PORT_INST_INIT(port, n, cfg)`` | ||
|
||
.. code-block:: console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. code-block:: console | |
.. code-block:: c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix, thanks!
doc/connectivity/networking/dsa.rst
Outdated
This is copied from Linux DSA documentation. It applies to zephyr too. Although conduit port and | ||
cpu port exposed as ethernet device in zephyr, they are not able to be used. | ||
|
||
.. code-block:: console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
maybe you meant .. note::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix, thanks!
It was discussed in the Networking WG meeting on 4/14. The meeting was recorded. |
The new DSA framework purpose and changes are as below. - Aligned to Linux DSA framework which has been already mature framework for many years, For now in zephyr, the DSA components were splited as: switch, port, master(not need driver file for now), slave, and tag. Seperated drivers were used for maintaining and developing new features. - The unified dts bindings (aligned to linux) were supported. The port driver would parse DTS to decide the port type (master port, slave port, or cpu port) to set up the switch. All the ports registered as standard ethernet devices. (dsa port and dsa switch tree was not supported.) - How to add DSA device driver based on the framework? All the device driver needing to do is providing dsa_spi implementation and private data, and calling below initialization. DSA_INIT_INSTANCE(n, _dapi, data) - For switch tag case, recv/xmit helpers in dsa_api could be used for taging/untagging. No modified ethernet drivers. For no-tag type case, ethernet driver of master port should support packet injection/extraction for slave ports leaving NULL recv/xmit. The dsa_nxp_imx_netc.c driver will be the first example of the new DSA framework. The future work for DSA will be supporting bridge for ports. We may align Linux to give users two options to use DSA device: - Standalone mode: the switch ports work as regular ethernet ports. - Bridge mode: switch mode with virtual bridge device which could be assigned IP address. Signed-off-by: Yangbo Lu <[email protected]>
Added DSA document. Signed-off-by: Yangbo Lu <[email protected]>
Added support for no-tag type DSA conduit. Signed-off-by: Yangbo Lu <[email protected]>
Adapted to use new DSA framework. And related platforms converted in samples too. Signed-off-by: Yangbo Lu <[email protected]>
Converted to use random mac addresses for switch. Signed-off-by: Yangbo Lu <[email protected]>
Renamed master/slave to conduit/user. Signed-off-by: Yangbo Lu <[email protected]>
Converted to new dsa core driver. And adapted mimxrt1180_evk to it. Signed-off-by: Yangbo Lu <[email protected]>
Enable DHCPv4 when network interface goes up. This makes it easier to test IP connectivity with DSA. Signed-off-by: Jukka Rissanen <[email protected]> Signed-off-by: Yangbo Lu <[email protected]>
95cd1ec
2606c9b
to
95cd1ec
Compare
Updated to v8. Changes includes,
Thanks a lot. |
This PR is to introduce new DSA switch framework. the RFC for new DSA architecuture is at discussion: #87091
This PR is first update according to new DSA arthiteture in RFC, the purpose and changes are as below.
Also a basic doc is added in patch
45bf638