Linux virtio 中的 ethtool:它如何控制网络 speed/duplex?

Linux ethtool in virtio: how does it control the network speed/duplex?

我正在查看 virtio 驱动程序的代码:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/virtio_net.c?id=refs/tags/next-20160211

我很好奇Ethtool是如何控制驱动的双工和速度的?

例如,如果我通过以下方式将 eth1 速度指定为 100Mbps:

$ ethtool -s eth1 speed 100 duplex full

事实上,ethtool 会告诉我 eth1 的速度是 100Mbps。但是驱动程序实际上是如何在一个实际上可以提供 40Gbps 的网络上将速度限制为 100Mbps?

$ ethtool eth1

Settings for eth1:
...
    Speed: 100Mb/s
    Duplex: Full

接口不限速。速度配置仅出于兼容性原因存在。