-
Notifications
You must be signed in to change notification settings - Fork 1.5k
drivers/net/mdio: add mdio bus #16999
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
d08e96a to
61ca78d
Compare
|
@tinnedkarma this is great addition, this way we will have a standard way to communicate with PHY. Could you please create a basic Documentation about this driver? Unfortunately your drivers documentation are really "shy", the best references you can use will be: https://nuttx.apache.org/docs/latest/components/drivers/special/mtd.html Thank again for your this great contribution |
Hi @acassis, you are right, I'm also overdue with the documentation for some other contributions. There are some things that differs from standard nuttx "approach". Please have a look over them.
I'll get this PR out of draft after the documentation is added, but in the mean time, can you have a look over the point above? |
61ca78d to
21a03c2
Compare
21a03c2 to
c315c33
Compare
|
@tinnedkarma very good Documentation! Kudos! |
|
ping @xiaoxiang781216 |
|
i will review at the weekend |
|
Please, check compatibility with PHY access according to Clause 45 / MMD Ethernet standard implemented by @matiamic and mainlined in #16926 include/net/if.h: Add mechanism for MMD access with SIOCxMIIREG ioctls The final IOCTLs has been defined Linux kernel compatible way. The MMD has been used only for SPI OA MAC-PHY drivers till now #16936 but many already included MAC drivers can be extended to support MMD if underlaying hardware supports it. There is high probability that Elektroline adds that support for integrated SAMv7 MAC is some time (@michallenc and @Cynerd are closer to such planning). If the given STM32 family provides MMD functionality in PHY/MDIO interface then it would worth to think about testing it implementing it with MMD support from the start. The MMD PHY API functions should be considered from start in each case. MMD is important today to allow seamlessly connect and configure PLCA T1S PHYs directly to existing MCUs where probably many of them include MMD support in MDIO interface. |
Let me start by presenting the concept/design of my work. Then we'll have a common starting point to make is suit everyone's work. Lately, my work was mainly on the stm32 mcus. There, the netdevs (usually living in stm32_ethernet.c or stm32_eth.c) handles everything. From register access to memory mamagement to packets that gets in and out of the net subsystem. It is plain hard to understand the logic there, and it also led to code duplication across st mcu families.
You mention IOCTLs. I did not plan anything of this sort. The current upperhalf/lowerhalf netdev approach want to handle the IOCTLs, so no IOCTLs for MDIO or PHY. My take on the netdevs architecture is as follows: netdev->phy->mdio
So to try giving an answer. I think ioctls should be handled two layers up, by the netdev, not the mdio bus, this is why there is nothing ioctl related in my bus. Anything else is up for debate. I would really need some feedback for the phy api, or we can work in parallel after agreeing on a common approach. The current changes for the stm32_ethernet.c file is part of my testing, work validation, I'll continue updating this file when I start work on the phy. |
c315c33 to
d764a08
Compare
For the second approach it might be worth considering the encoding introduced in #16926: Add mechanism for MMD access with SIOCxMIIREG ioctls. Usage in driver here. But special functions for c22 and c45 seem clearer. As seen in I think the inclusion of the c45 functionality from the start would be nice. As @ppisa noted it is needed for configuration of the PLCA in 10BASE-T1S PHYs.
You are probably looking into chip-specific drivers. The MDIO access in question is implemented in the generic driver here.
I think you are right, having explicit mdio bus would not help here. If I understand correctly, your concern is to provide standard way of exchanging configuration between MAC drivers and external PHYs. The concern of the OA-TC6 driver in this regard is to expose MMD registers to user apps (such as |
1d5e8f3 to
3ab8287
Compare
|
So the last thing to clarify then is how we handle both c22 and c45 clauses. |
I think adding an option in Kconfig is fine (although I prefer when we remove items from Kconfig than when we add items there, since NuttX has too many entries) |
I agree, there a some Kconfig files that a thousands of lines long. But I see it as the better option here. I'll update the docs, and the source files with the function signatures. The votes will reset though. |
|
should we support c45 clauses in this patch or put into new pr? @tinnedkarma |
|
@xiaoxiang781216 I'll add the kconfig options and guard both read/write functions for c22 today. I'll open a new pr with the c45 function signatures, as this thread is getting long and hard to follow. |
e0b65b8
e0b65b8 to
67d513b
Compare
67d513b to
4b6db07
Compare
Currently the mdio communication is part of the monolithic 'full netdevs'. This commit serves as an way to add modularity for the netdevs drivers. A new upperhalf/lowerhalf mdio device comes with this commit that manages the data transfer ofer mdio interface. Signed-off-by: Luchian Mihai <luchiann.mihai@gmail.com>
4b6db07 to
fdcaa06
Compare
|
@xiaoxiang781216 Is there anything else to do in this PR? |
Summary
Currently the mdio communication is part of the monolithic 'full netdevs'.
This commit serves as an way to add modularity for the netdevs drivers.
A new upperhalf/lowerhalf mdio device comes with this commit that manages the data transfer ofer mdio interface.
It resembles the upperhalf/lowerhalf approach of the netdevs or i2c bitbang.
It is still in the draft because there are still code style issues, but I ask you to review this PR nevertheless
Impact
A new upperhalf mdio bus is now added as a set of include/nuttx/net/mdio.h and drivers/net/mdio.c files
which "sets" the available mdio commands (read, write, reset). Acts as the bus "controller". It block the bus during the transaction and calls the apropriate lowerhalf function.
A new lowerhalf mdio bus for the stm32h7 mcu family was added which implements the actual mdio transfers.
A new Kconfig option was added MDIO_BUS in the drivers/net directory
Testing
This PR have low impact over the nuttx codebase. The new files are included to the build system based on the
CONFIG_MDIO_BUS
Currently, only stm32h7 has the new mdio bus.