测试rdma网卡性能
apt install -y rdma-core ibverbs-utils perftest ethtool infiniband-diags

先确认每个 PCI 设备对应的网口名
(base) [root@localhost ~]# ls -l /sys/bus/pci/devices/0000:91:00.0/net/ total 0 drwxr-xr-x 5 root root 0 Nov 4 09:51 enp145s0f0 (base) [root@localhost ~]# ls -l /sys/bus/pci/devices/0000:91:00.1/net/ total 0 drwxr-xr-x 5 root root 0 Nov 4 09:51 enp145s0f1 (base) [root@localhost ~]# ls -l /sys/bus/pci/devices/0000:a1:00.0/net/ total 0 drwxr-xr-x 5 root root 0 Nov 4 09:51 enp161s0f0 (base) [root@localhost ~]# ls -l /sys/bus/pci/devices/0000:a1:00.1/net/ total 0 drwxr-xr-x 5 root root 0 Nov 4 09:51 enp161s0f1 (base) [root@localhost ~]# ls -l /sys/bus/pci/devices/0000:22:00.1/net/ total 0
查驱动和总线信息
ethtool -i enp145s0f0 ethtool -i enp145s0f1 ethtool -i enp161s0f0 ethtool -i enp161s0f1
查看光模块信息ethtool -m enp145s0f0
查当前链路状态(查看网卡速率、驱动、是否支持 RDMA):
ethtool enp145s0f0
ethtool enp145s0f1
ethtool enp161s0f0
ethtool enp161s0f1
如果在机房现场,可以用闪烁定位物理网口:ethtool -p enp145s0f0
部分华为网卡NPU 板上,不在 CPU 的 PCIe 总线上,不归主机 CPU 管,Linux 标准的网络工具(lspci、ifconfig、ethtool)全部看不到它。智能通过hccn_tool查看和设置┌─────────────────────────────────────────┐ │ Atlas 800 服务器 │ │ │ │ ┌───────────┐ ┌────────────────┐ │ │ │ CPU 主板 │ │ NPU 板(8张昇腾芯片)│ │ │ │ │ │ │ │ │ │ Hi1822网卡 ├────→│ 芯片0内置网口 │ │ │ │ (4×25G) │ │ 芯片1内置网口 │ │ │ │ │ │ 芯片2内置网口 │ │ │ │ Mellanox ├────→│ ... │ │ │ │ (2×25G) │ │ 芯片7内置网口 │ │ │ └───────────┘ └────────────────┘ │ │ ↑ ↑ │ │ lspci能看到 lspci看不到! │ │ (挂在CPU PCIe上) (长在NPU内部) │ └─────────────────────────────────────────┘
通过hccn_tool查看
[root@localhost ~]# hccn_tool -i 1 -link -g link status: DOWNx
[root@localhost ~]# hccn_tool -i 0 -link -g link status: DOWN [root@localhost ~]# hccn_tool -i 1 -link -g link status: DOWN [root@localhost ~]# hccn_tool -i 0 -optical -g optical info: present : not present temperature : NA high power enable reg: not enabled vendor name : vendor part number : vendor serial number : vendor org unique id : 0x0 0x0 0x0 xsfp identifier : UNKNOWN xsfp wave length : 0 nm manufact date code : Vcc : NA Tx Power : NA Rx Power : NA Vcc High Thres : NA Vcc Low Thres : NA Temp High Thres : NA Temp Low Thres : NA TxPower High Thres : NA TxPower Low Thres : NA RxPower High Thres : NA RxPower Low Thres : NA [root@localhost ~]# hccn_tool -i 0 -status -g Netdev status:Settings for eth0: Supported ports: [ FIBRE ] Supported link modes: 40000baseCR4/Full 40000baseSR4/Full 40000baseLR4/Full 25000baseCR/Full 25000baseSR/Full 50000baseCR2/Full 100000baseSR4/Full 100000baseCR4/Full 100000baseLR4_ER4/Full 50000baseSR2/Full 1000baseX/Full 10000baseCR/Full 10000baseSR/Full 10000baseLR/Full 200000baseSR4/Full 200000baseLR4_ER4_FR4/Full 200000baseCR4/Full Supported pause frame use: Symmetric Supports auto-negotiation: No Supported FEC modes: None RS LLRS Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: None RS LLRS Speed: Unknown! Duplex: Unknown! (255) Auto-negotiation: off Port: Other PHYAD: 0 Transceiver: internal Supports Wake-on: d Wake-on: d Current message level: 0x00000036 (54) probe link ifdown ifup Link detected: no [root@localhost ~]#
hccn_tool -i 0 -ip -g
# 单口示例
hccn_tool -i 0 -ip -s address 192.168.100.10 netmask 255.255.255.0
# 8 口批量:10~17 依次分配
for i in $(seq 0 7); do
hccn_tool -i $i -ip -s address 192.168.100.$((10+i)) netmask 255.255.255.0
done
hccn_tool -i 0 -ping -g address 172.20.1.1
设置网关
hccn_tool -i 0 -gateway -s gateway 192.168.100.254
查看网关
hccn_tool -i 0 -gateway -g
查看网卡支持的光模块种类:
root@root1-ESC8000-E11:~# ethtool ens4np0 Settings for ens4np0: Supported ports: [ ] Supported link modes: 1000baseT/Full 10000baseT/Full 1000baseKX/Full 10000baseKR/Full 10000baseR_FEC 40000baseKR4/Full 40000baseCR4/Full 40000baseSR4/Full 40000baseLR4/Full 25000baseCR/Full 25000baseKR/Full 25000baseSR/Full 50000baseCR2/Full 50000baseKR2/Full 100000baseKR4/Full 100000baseSR4/Full 100000baseCR4/Full 100000baseLR4_ER4/Full 50000baseSR2/Full 1000baseX/Full 10000baseCR/Full 10000baseSR/Full 10000baseLR/Full 10000baseER/Full 50000baseKR/Full 50000baseSR/Full 50000baseCR/Full 50000baseLR_ER_FR/Full 50000baseDR/Full 100000baseKR2/Full 100000baseSR2/Full 100000baseCR2/Full 100000baseLR2_ER2_FR2/Full 100000baseDR2/Full 200000baseKR4/Full 200000baseSR4/Full 200000baseLR4_ER4_FR4/Full 200000baseDR4/Full 200000baseCR4/Full Supported pause frame use: Symmetric Supports auto-negotiation: Yes Supported FEC modes: None RS BASER Advertised link modes: 1000baseT/Full 10000baseT/Full 1000baseKX/Full 10000baseKR/Full 10000baseR_FEC 40000baseKR4/Full 40000baseCR4/Full 40000baseSR4/Full 40000baseLR4/Full 25000baseCR/Full 25000baseKR/Full 25000baseSR/Full 50000baseCR2/Full 50000baseKR2/Full 100000baseKR4/Full 100000baseSR4/Full 100000baseCR4/Full 100000baseLR4_ER4/Full 50000baseSR2/Full 1000baseX/Full 10000baseCR/Full 10000baseSR/Full 10000baseLR/Full 10000baseER/Full 50000baseKR/Full 50000baseSR/Full 50000baseCR/Full 50000baseLR_ER_FR/Full 50000baseDR/Full 100000baseKR2/Full 100000baseSR2/Full 100000baseCR2/Full 100000baseLR2_ER2_FR2/Full 100000baseDR2/Full 200000baseKR4/Full 200000baseSR4/Full 200000baseLR4_ER4_FR4/Full 200000baseDR4/Full 200000baseCR4/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: Unknown! Duplex: Unknown! (255) Auto-negotiation: on Port: Other PHYAD: 0 Transceiver: internal Supports Wake-on: d Wake-on: d Link detected: no (No cable) root@root1-ESC8000-E11:~# root@master:~# ibdev2netdev -v 0000:2e:00.0 mlx5_0 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp46s0 (Down) 0000:31:00.0 mlx5_1 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp49s0 (Down) 0000:5e:00.0 mlx5_2 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp94s0 (Down) 0000:5f:00.0 mlx5_3 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp95s0 (Down) 0000:a5:00.0 mlx5_4 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp165s0 (Down) 0000:a8:00.0 mlx5_5 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp168s0 (Down) 0000:ce:00.0 mlx5_6 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp206s0 (Down) 0000:d1:00.0 mlx5_7 (MT4123 - MCX653105A-HDAT) ConnectX-6 VPI adapter card, HDR IB (200Gb/s) and 200GbE, single-port QSFP56 fw 20.43.3608 port 1 (ACTIVE) ==> ibp209s0 (Down) 0000:f3:00.0 mlx5_8 (MT4129 - MCX755106AS-HEAT) NVIDIA ConnectX-7 Adapter Card, 200GbE / NDR200, Dual-port QSFP112, PCIe 5.0x16 with x16 PCIe extension option, Crypto Disabled, Secure Boot Enabled fw 28.43.3608 port 1 (DOWN ) ==> ens118f0np0 (Down) 0000:f3:00.1 mlx5_9 (MT4129 - MCX755106AS-HEAT) NVIDIA ConnectX-7 Adapter Card, 200GbE / NDR200, Dual-port QSFP112, PCIe 5.0x16 with x16 PCIe extension option, Crypto Disabled, Secure Boot Enabled fw 28.43.3608 port 1 (DOWN ) ==> ens118f1np1 (Down)
| PHY 名称 | 速率 | 常规标准封装 | 备注 |
|---|---|---|---|
| 1000baseT / 1000baseKX / 1000baseX | 1G | SFP | 千兆光 / 电口模块 |
| 10000baseT / 10000baseKR / 10000baseSR / 10000baseLR / 10000baseER / 10000baseR_FEC | 10G | SFP+ | 10G 最主流封装 |
| 25000baseCR / 25000baseKR / 25000baseSR | 25G | SFP28 | 单路 25G NRZ |
| 50000baseCR / 50000baseKR / 50000baseSR / 50000baseLR_ER_FR / 50000baseDR | 50G | SFP56 | 单路 50G PAM4 |
| 50000baseCR2 / 50000baseKR2 / 50000baseSR2 | 50G | QSFP28(2×25G NRZ) | 双 lane 50G |
| 100000baseKR4 / 100000baseSR4 / 100000baseCR4 / 100000baseLR4_ER4 | 100G | QSFP28(4×25G NRZ) | 你 breakout 后每一路就是这个 PHY |
| 100000baseKR2 / 100000baseSR2 / 100000baseCR2 / 100000baseLR2_ER2_FR2 / 100000baseDR2 | 100G | QSFP56(2×50G PAM4) | 双 lane 100G PAM4 |
| 200000baseKR4 / 200000baseSR4 / 200000baseCR4 / 200000baseLR4_ER4_FR4 / 200000baseDR4 | 200G | QSFP56(4×50G PAM4) | 标准 200G 封装 |
| 40000baseSR8 | 400G | QSFP-DD(8×50G PAM4) | 400G封装 |
| 40000baseKR4 / 40000baseCR4 / 40000baseSR4 / 40000baseLR4 / 40000baseVR4 | 400G |
QSFP-DD / OSFP QSFP-112 VR4(4×112G PAM4) |
400G 主流两种封装 |
1. 先确认 RDMA 环境正常
ip -br link show
ip addr ibv_devices ibv_devinfo ibstat lspci | grep Mellanox lspci | grep -i Ethernet lspci -vvv | grep -A10 -i ethernet ethtool 网卡名
rdma link IB网卡命令 # 查看IB fabric完整拓扑 ibnetdiscover # IB fabric巡检,检查错误、链路、SM ibdiagnet # RDMA带宽压测 ib_write_bw # 查看LID、端口状态 ibstat # 查看HCA信息 ibv_devinfo
rdma link
如果连上去网卡灯亮,但是ibstat显示是down的且Physical state: Disabled,这是由于/etc/netplan/00-installer-config.yaml 里没有该网卡配置导致的,可以使用如下命令启用网卡
ip link set ens11np0 up
上述命令是临时启用网卡,重启后网卡还是down,如果想已启动就启动网卡,需要在/etc/netplan/00-installer-config.yaml添加该网口的配置,然后netplan try/netplan apply。
# 查看 RDMA 设备 ibv_devices ibdev2netdev -v # 查看端口状态,确认 state=PORT_ACTIVE ibv_devinfo -d mlx5_0 # 查看 RoCE GID cat /sys/class/infiniband/mlx5_0/ports/1/gids/3 # 确认 MTU ip link show eth2 ethtool -i eth2
root@g3030:~# ibstat CA 'mlx5_0' CA type: MT4123 Number of ports: 1 Firmware version: 20.37.1014 Hardware version: 0 Node GUID: 0x08c0eb030057fe7e System image GUID: 0x08c0eb030057fe7e Port 1: State: Active Physical state: LinkUp Rate: 200 Base lid: 0 LMC: 0 SM lid: 0 Capability mask: 0x00010000 Port GUID: 0x0ac0ebfffe57fe7e Link layer: Ethernet root@g3030:~# mst start root@g3030:~# mst status MST modules: ------------ MST PCI module is not loaded MST PCI configuration module loaded MST devices: ------------ /dev/mst/mt4123_pciconf0 - PCI configuration cycles access. domain:bus:dev.fn=0000:1d:00.0 addr.reg=88 data.reg=92 cr_bar.gw_offset=-1 Chip revision is: 00 root@g3030:~# mlxconfig -d /dev/mst/mt4123_pciconf0 q | grep LINK_TYPE LINK_TYPE_P1 ETH(2) root@g3030:~# mlxconfig -d /dev/mst/mt4123_pciconf0 s LINK_TYPE_P1=2
华为网卡
[root@node24 ~]# hinicadm3 cfg_template -i hinic0 -q ***************** Current Info ******************* [Current ] Template name : ROCE_2X100G ***************** Next Reset Cfg ***************** [Next Reset] Template name : ROCE_2X100G [Next Reset] Firmware support cfg template name: Template[ 0]: NIC_2X100G Template[ 1]: NIC_2X100G_3PF Template[ 2]: ROCE_2X100G Template[ 3]: ROCE_2X100G_UN_ADAP [root@node24 ~]#hinicadm3 cfg_template -i hinic0 -n ROCE_2X100G
2. 先做连通性测试
# RoCE 环境常用 rping # 服务端 rping -s # 客户端 rping -c -a <server_ip> -v
ibv_rc_pingpong 做底层 Verbs 通路验证。3. 用 perftest 测带宽和时延
| 测试目标 | 工具 | 典型命令 | |---|---|---| | 写带宽 | `ib_write_bw` | `ib_write_bw -d mlx5_0 -i 1 --report_gbits` | | 读带宽 | `ib_read_bw` | `ib_read_bw -d mlx5_0 -i 1 --report_gbits` | | 发送带宽 | `ib_send_bw` | `ib_send_bw -d mlx5_0 -i 1 --report_gbits` | | 写时延 | `ib_write_lat` | `ib_write_lat -d mlx5_0 -i 1` | | 发送时延 | `ib_send_lat` | `ib_send_lat -d mlx5_0 -i 1` |
RoCEv2 场景通常要指定 GID index,例如:
ib_write_bw -d mlx5_0 -i 1 -x 3 --report_gbits -D 20 <server_ip>
建议不要只测一个消息大小,最好扫一遍:
ib_write_bw -d mlx5_0 -i 1 -a --report_gbits <server_ip>
验证
# 看 PFC 是否频繁触发 ethtool -S enp1s0f0 | grep -i pfc ethtool -S enp1s0f0 | grep -i pause # 看 ECN/CNP 统计 ethtool -S enp1s0f0 | grep -i ecn ethtool -S enp1s0f0 | grep -i cnp
- ECN 标记数有增长:说明拥塞控制在工作;
- PFC Pause 帧很少或为零:说明没有频繁硬暂停;
ib_write_bw/nccl-tests带宽稳定,尾延迟不抖动。
[root@localhost ~]# hccn_tool -i 1 -link -g
posted on 2026-10-19 10:37 yipianchuyun 阅读(42) 评论(0) 收藏 举报


浙公网安备 33010602011771号