我正在使用 RT_PREEMPT 补丁在 Xubuntu 上开发 EtherCAT Master 应用程序,这样我就可以通过 EtherCAT 通信获得实时性能。
我发现一些 NIC 的rx-usecs 'Coalesce parameter' 默认设置为非 0 值。任何非 0 的设置都会导致网卡在收到网络数据包后等待那么多微秒才产生中断;但是,网络驱动程序将被我的实时应用程序抢占,并导致我的应用程序从网络接收 EtherCAT IO 时出现明显延迟。
ecat@EcatLab:~/SIL/RealTimePlatform/EcMaster$ ethtool -c eth1
Coalesce parameters for eth1:
Adaptive RX: off TX: off
stats-block-usecs: 0
sample-interval: 0
pkt-rate-low: 0
pkt-rate-high: 0
rx-usecs: 3
rx-frames: 0
rx-usecs-irq: 0
rx-frames-irq: 0
tx-usecs: 0
tx-frames: 0
tx-usecs-irq: 0
tx-frames-irq: 0
rx-usecs-low: 0
rx-frame-low: 0
tx-usecs-low: 0
tx-frame-low: 0
rx-usecs-high: 0
rx-frame-high: 0
tx-usecs-high: 0
tx-frame-high: 0
目前,我必须为要用于 EtherCAT 的每个网卡手动运行带有 sudo 的 ethtool。这可以编写脚本,但理想情况下,它应该只在实际配置为使用 EtherCAT 的 NIC 上执行,这在应用程序之外很难做到。
有没有办法从我的 linux 应用程序中调用 ethtool 来配置它正在使用的 NIC 的网络设置?还是执行相同操作的 API?
我的应用程序以非 root 用户身份运行,使用 setcap 分配 CAP_NET_ADMIN 和 CAP_NET_RAW 功能以供 EtherCAT 使用。这足以将 ethtool 作为子进程调用,还是我需要额外的权限?或者我什至可以调用 ethtool 来更改合并设置而不是 root?