Skip to content

Commit

Permalink
script: set nic ring buffer max
Browse files Browse the repository at this point in the history
  • Loading branch information
QiuSimons committed Apr 21, 2023
1 parent 6e77d84 commit 6e1266b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
23 changes: 0 additions & 23 deletions PATCH/files/etc/hotplug.d/net/01-igc_rx_fix

This file was deleted.

22 changes: 22 additions & 0 deletions PATCH/files/etc/hotplug.d/net/01-maximize_nic_rx_tx_buffers
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
[ "$ACTION" = add ] || exit

# 遍历所有网口
for NIC in $(ls /sys/class/net/)
do
# 检查网口是否支持ethtool命令
if command -v ethtool &> /dev/null && ethtool $NIC &> /dev/null; then
# 获取rx和tx缓存最大值
RX_MAX=$(ethtool -g $NIC 2>/dev/null | awk '/^RX:/ {print $2}' | awk 'NR==1')
TX_MAX=$(ethtool -g $NIC 2>/dev/null | awk '/^TX:/ {print $2}' | awk 'NR==1')

# 如果无法获取rx和tx缓存最大值,则跳过该网卡
if [ -z "$RX_MAX" ] || [ -z "$TX_MAX" ]; then
continue
fi

# 调整rx和tx缓存为驱动支持的最大值
ethtool -G $NIC rx $RX_MAX
ethtool -G $NIC tx $TX_MAX
fi
done

0 comments on commit 6e1266b

Please sign in to comment.