以太网 PHY 环回测试编码
我必须在 Linux 中编写以太网 PHY 环回测试。我以前从未这样做过,也不知道从哪里开始。经过一番研究,我想出了测试计划,不知道有没有人可以帮我验证一下,并给我一些关于我的问题的指导。
这是外部环回设置。它将以太网交换机芯片上每个内部 PHY 的 TX+/- 引脚连接到 RX+/- 引脚。
因此环回高级数据包路径如下:
CPU->PHY0(芯片)->以太网交换机(芯片)的内部 PHY->PHY0(芯片)->CPU
对于此测试,我计划
- 配置以太网交换机上具有特定 MAC 地址的内部 PHY,
- 使用 CPU 的 MAC 地址作为源地址和
步骤1中配置的MAC地址作为目的地址, - 发送并等待接收测试数据包,
- 比较发送和接收的数据模式。
有什么建议吗?另外,我想知道Linux中是否有函数可以用来生成步骤2的数据包,并发送步骤3的数据包
。非常感谢。
I have to write a Ethernet PHY loopback test in Linux. I've never done it before and had no clue where to start. After some researching, I came up with the plan for the test, and I wonder if anyone can help me to verify it and give me some pointers to my questions.
This is a external loopback setup. It connects the TX+/- to RX+/- pins for each internal PHY's on the Ethernet switch chip.
So the loopback high level packet path is as follow:
CPU->PHY0(chip)->Ethernet switch(chip)'s internal PHY->PHY0(chip)->CPU
For this test, I plan to
- configure the internal PHYs on the Ethernet switch with specific MAC addresses,
- pack the Ethernet test packet using CPU's MAC address as the source address and the
MAC address configured in step 1. as the destination address, - send and wait to receive the test packet,
- compare sent and received data pattern.
Any suggestions? Also, I wonder if there are functions in Linux that I can use to generate the packets for step 2, and send the packets for step 3.
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大多数 Phys 可以切换到测试模式。我们使用引导加载程序直接写入
Phy 并切换到测试模式。
还有一个 ioctl 取自 Documentation/networking/phy.txt
Ethtool 便利功能。
int phy_mii_ioctl(结构 phy_device *phydev,
结构 mii_ioctl_data *mii_data, int cmd);
MII ioctl。请注意,此函数将完全搞乱状态
如果您写入 BMCR、BMSR、ADVERTISE 等寄存器,最好
仅使用它来写入非标准寄存器,并且不会触发
重新谈判。
Most Phys can be switched to a test mode. We used the bootloader to write directly to the
Phy and switch to testing mode.
There is also an ioctl taken from documentation/networking/phy.txt
Ethtool convenience functions.
int phy_mii_ioctl(struct phy_device *phydev,
struct mii_ioctl_data *mii_data, int cmd);
The MII ioctl. Note that this function will completely screw up the state
machine if you write registers like BMCR, BMSR, ADVERTISE, etc. Best to
use this only to write registers which are not standard, and don't set off
a renegotiation.