Repository navigation
Conversation
- add native PCI support for RTL8125, RTL8162, and compatible controllers - implement descriptor-ring DMA, interrupt-driven RX, TX completion, and link reporting - support MAC/PHY OCP access and 10/100/1000/2500M auto-negotiation - add Kconfig integration with lwIP software checksum requirement - add optional hardware PTP clock support with time adjustment and PPS control Signed-off-by: GuEe-GUI <2991707448@qq.com>
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-10-30 11:25 CST)
📝 Review Instructions
|
|
Rbb666
left a comment
There was a problem hiding this comment.
下面 6 处需要修改,涉及构建依赖、PHY 读取、设备卸载和收包处理,请修复后再合入。已检查相关调用流程,并做了部分函数的模拟验证,尚未做 RTL8125 实机测试。
| @@ -0,0 +1,22 @@ | |||
| config RT_ETHERNET_REALTEK | |||
| bool "Realtek RTL8125 Ethernet" | |||
| depends on RT_USING_PCI | |||
There was a problem hiding this comment.
[P1] 补上 DMA 依赖
这里需要加上 select RT_USING_DMA。目前可以选出 RT_ETHERNET_REALTEK=y、RT_USING_DMA=n 的配置,但驱动无条件调用 rt_dma_alloc_coherent() 和 rt_dma_free_coherent()。DMA 关闭时,rtdevice.h 不包含对应头文件,DMA 源文件也不参与构建,会导致编译或链接失败。RT_USING_PCI 本身没有选中 DMA。
| for (int i = 0; i < 1000; ++i) | ||
| { | ||
| rt_hw_us_delay(10); | ||
| if (!(RTL_R32(eth, R8125_PHYAR) & R8125_PHYAR_FLAG)) |
There was a problem hiding this comment.
[P1] MDIO 读取完成条件写反了
PHYAR 读操作应等 R8125_PHYAR_FLAG 置位后再取数据,这里在标志仍为 0 时就退出了。若第一次检查时读取尚未完成,会返回无效数据;调用方可能因此误判 BMCR 的复位位已经清零,继续配置自协商。请修正退出条件,并在超时时返回错误,避免继续使用未完成的读取结果。
| if (eth->net_registered) | ||
| { | ||
| eth_device_linkchange(ð->parent, RT_FALSE); | ||
| eth_device_deinit(ð->parent); |
There was a problem hiding this comment.
[P1] 等网络线程处理完通知后再释放设备
eth_device_linkchange() 会把设备指针放入接收线程的邮箱,下一行 eth_device_deinit() 就释放了 netif,外层 remove 随后还会释放 eth。如果接收线程尚未处理这条通知,就会访问已释放的对象。已有的收发请求也需要考虑。请先停止新的收发和通知,等待已投递的请求处理完,再释放 netif、描述符和设备对象。
| if (eth->irq_installed) | ||
| { | ||
| r8125_intr_mask(eth); | ||
| rt_hw_interrupt_mask(eth->irq); |
There was a problem hiding this comment.
[P1] 卸载时需要注销 ISR,不能直接屏蔽共享 INTx
rt_hw_interrupt_mask() 只屏蔽中断线,不会移除之前安装的 ISR。这里使用的是共享 INTx,屏蔽整条线会影响其他设备;后续这条线重新启用时,旧 ISR 还会拿着已经释放的 eth 执行。请关闭本设备的中断源,并调用 rt_hw_interrupt_uninstall() 或对应的 PIC 接口注销回调,确认没有正在执行的回调后再释放对象。
|
|
||
| static void r8125_set_rx_filter(struct r8125_eth *eth) | ||
| { | ||
| rt_uint32_t rx_mode = R8125_RX_ACCEPT_BCAST | R8125_RX_ACCEPT_MY_PHYS; |
There was a problem hiding this comment.
[P2] 接收过滤器没有开启组播
这里只接受广播和本机单播,没有设置 R8125_RX_ACCEPT_MCAST。即使下面把 MAR 全部置一,组播报文仍然无法通过过滤,IPv6 邻居发现、路由通告和 IPv4 组播都会受影响。当前没有实现组播过滤回调,建议先开启组播接收;如果要按地址过滤,需要接上 lwIP 的相应回调。
| _done: | ||
| r8125_rx_refill(eth, eth->rx_tail); | ||
| eth->rx_tail = R8125_NEXT_RX(eth->rx_tail); | ||
| return p; |
There was a problem hiding this comment.
[P2] 丢弃当前报文后需要继续检查后面的描述符
长度非法或 pbuf_alloc() 失败时,这里回收一个描述符后就返回空指针,前面的错误帧分支也一样。lwIP 接收线程把空指针当作本轮收包结束;如果同一次中断对应的后续描述符已经完成,它们可能一直等到下次中断才被处理。请在丢包后继续遍历,直到找到可交付的报文,或下一个描述符仍归硬件所有时再返回空指针。
拉取/合并请求描述:(PR description)
[
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up