1. RoCE
1.1 连接要求
RDMA 要求端到端同一类网络,比如同一个 B 段网。
单交换机。
RoCE: 主机 NIC ── 以太交换机(PFC) ── 对端 NIC
多台交换机。
RoCE: 主机 NIC ── Leaf ── Spine ── Leaf ── 对端 NIC
多跳时注意:
| 说明 |
|---|
| 路径 | L2/L3 可达即可(同网段或可路由) |
| 无损 | 路径上每台交换机建议开 PFC;多跳更依赖 ECN/DCQCN |
| MTU / 速率 | 端到端一致 |
| 禁忌 | 中间不要经过「未开 PFC 的普通交换机」硬凑 |
交换机不开 PFC,经过多台交换机也能用,但拥塞时性能会明显下降甚至不稳定,RDMA 依赖无损网络。RoCEv2 可跨三层路由;RoCEv1 是二层协议,不能指望普通路由器转发。
1.2 安装工具
1
| apt install -y rdma-core ibverbs-utils perftest ethtool infiniband-diags
|
1.3 设备
需要:以太网 RDMA 驱动 + 对应 netdev。不装 opensm。
| 厂商 | 典型模块 | 说明 |
|---|
| NVIDIA/Mellanox | mlx5_core mlx5_ib | ConnectX 跑 RoCE;或装 MLNX_OFED |
| Intel | irdma | E810 等 RoCE / iWARP |
| Broadcom | bnxt_en bnxt_re | RoCE |
| 云厂商 | efa / erdma 等 | AWS、阿里云 |
1.4 点对点测试
mlx5_0 port 1 ==> eth0x (Up)
mlx5_1 port 1 ==> eth1x (Up)
mlx5_bond_0 port 1 ==> bond0 (Up)
bond0 对应 mlx5_bond_0;Linux slave 是 eth2x + eth3x(不是 eth0x/eth1x)。
1
| cat /sys/class/net/bond0/bonding/slaves
|
eth2x eth3x
RoCE 在以太网上跑 RDMA,用 GID(Global Identifier)标识「从哪个地址发 RDMA」。每个 RDMA 端口有一张 GID 表;表里每一行有一个 index,-x 就是在选这张表的第几行, -R 走 RDMA_CM。
1
| ibv_devinfo -v -d mlx5_bond_0 | grep -A3 GID
|
bond0 示例:
1
2
3
4
5
6
7
8
9
10
| GID[ 0]: fe80:0000:0000:0000:0000:0000:0000:0001, RoCE v1
GID[ 1]: fe80::1, RoCE v2
GID[ 2]: fe80:0000:0000:0000:0000:0000:0000:0002, RoCE v1
GID[ 3]: fe80::2, RoCE v2
GID[ 4]: 0000:0000:0000:0000:0000:ffff:0a00:0001, RoCE v1
GID[ 5]: ::ffff:10.0.0.1, RoCE v2
GID[ 6]: 0000:0000:0000:0000:0000:ffff:0a00:0101, RoCE v1
GID[ 7]: ::ffff:10.0.1.1, RoCE v2
GID[ 8]: fe80:0000:0000:0000:0000:0000:0000:0003, RoCE v1
GID[ 9]: fe80::3, RoCE v2
|
本机 bond0 地址是 10.0.0.1,对应 GID index 5(RoCE v2)。-x 选的是本机 GID,不是对端的。
测试前提:本机 -x 选对本机通信 IP 对应的 GID;命令末尾填对端 IP。
对端
1
| ib_write_bw -d mlx5_bond_0 -x 5 --report_gbits
|
测试端
1
| ib_write_bw -d mlx5_bond_0 -x 5 10.0.0.2 --report_gbits
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| ---------------------------------------------------------------------------------------
RDMA_Write BW Test
Dual-port : OFF Device : mlx5_bond_0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
PCIe relax order: ON
ibv_wr* API : ON
TX depth : 128
CQ Moderation : 1
Mtu : 1024[B]
Link type : Ethernet
GID index : 5
Max inline data : 0[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0000 QPN 0x1001 PSN 0xabc123 RKey 0x200000 VAddr 0x007f0000000000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:01
remote address: LID 0000 QPN 0x1002 PSN 0xdef456 RKey 0x200000 VAddr 0x007f0000001000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:02
---------------------------------------------------------------------------------------
#bytes #iterations BW peak[Gb/sec] BW average[Gb/sec] MsgRate[Mpps]
65536 5000 23.12 23.09 0.044035
---------------------------------------------------------------------------------------
|
对端
1
| ib_write_lat -d mlx5_bond_0 -x 5 --report_gbits
|
测试端
1
| ib_write_lat -d mlx5_bond_0 -x 5 10.0.0.2 --report_gbits
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| ---------------------------------------------------------------------------------------
RDMA_Write Latency Test
Dual-port : OFF Device : mlx5_bond_0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
PCIe relax order: OFF
ibv_wr* API : ON
TX depth : 1
Mtu : 1024[B]
Link type : Ethernet
GID index : 5
Max inline data : 220[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0000 QPN 0x1003 PSN 0xabc124 RKey 0x200001 VAddr 0x00560000000000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:01
remote address: LID 0000 QPN 0x1004 PSN 0xdef457 RKey 0x200002 VAddr 0x00560000001000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:02
---------------------------------------------------------------------------------------
#bytes #iterations t_min[usec] t_max[usec] t_typical[usec] t_avg[usec] t_stdev[usec] 99% percentile[usec] 99.9% percentile[usec]
2 1000 3.40 6.22 3.48 3.49 0.03 3.71 6.22
---------------------------------------------------------------------------------------
|
2. Soft RoCE
2.1 连接要求
RDMA 要求端到端同一类网络。Soft RoCE 跑在普通以太网口上,拓扑与 RoCE 相同,但开发联调场景下交换机可不强制 PFC。
单交换机。
主机 NIC ── 以太交换机 ── 对端 NIC
多台交换机。
主机 NIC ── Leaf ── Spine ── Leaf ── 对端 NIC
多跳时注意:
| 说明 |
|---|
| 路径 | L2/L3 可达即可(同网段或可路由) |
| 网口 | 绑定 RXE 的 netdev 需先配 IP |
| MTU / 速率 | 端到端一致 |
| 性能 | 无硬件 offload,不适合作为生产高性能网络要求 |
2.2 安装工具
1
| apt install -y rdma-core ibverbs-utils perftest ethtool infiniband-diags
|
2.3 设备
没有 RDMA 网卡时,用内核软件栈在普通以太网口上模拟 RoCE(RXE,模块 rdma_rxe)。适合开发、联调;性能远低于硬件 RoCE,生产一般不采用。
| 项目 | 说明 |
|---|
| 内核模块 | rdma_rxe |
| 设备名 | rxe0、rxe1… |
| 绑定对象 | 已有 IP 的普通 netdev(如 eth0) |
| 与硬件 RoCE | 协议类似,无硬件 offload,CPU 负担大 |
2.4 点对点测试
两端都要先创建 RXE,绑在有 IP 的普通网口上(下例 eth0 → rxe0)。
1
| rdma link add rxe0 type rxe netdev eth0
|
1
2
3
| device node GUID
------ ----------------
rxe0 0000000000000001
|
1
| ibv_devinfo -v -d rxe0 | grep -A3 GID
|
GID[ 0]: fe80:0000:0000:0000:0000:0000:0000:0001
GID[ 1]: 0000:0000:0000:0000:0000:ffff:0a00:0001
GID[ 2]: 0000:0000:0000:0000:0000:ffff:0a00:0101
本机地址 10.0.0.1 对应 GID[1](0a00:0001),测试端用 -x 1;命令末尾填对端 IP 10.0.0.2。
对端
1
| ib_write_bw -d rxe0 -x 1 --report_gbits
|
测试端
1
| ib_write_bw -d rxe0 -x 1 10.0.0.2 --report_gbits
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| ---------------------------------------------------------------------------------------
RDMA_Write BW Test
Dual-port : OFF Device : rxe0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
TX depth : 128
CQ Moderation : 100
Mtu : 1024[B]
Link type : Ethernet
GID index : 1
Max inline data : 0[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0000 QPN 0x0011 PSN 0x100001 RKey 0x000200 VAddr 0x007f0000000000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:01
remote address: LID 0000 QPN 0x0011 PSN 0x100002 RKey 0x000200 VAddr 0x007f0000001000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:02
---------------------------------------------------------------------------------------
#bytes #iterations BW peak[Gb/sec] BW average[Gb/sec] MsgRate[Mpps]
65536 5000 0.16 0.14 0.000275
---------------------------------------------------------------------------------------
|
使用 perf 测试,这两个节点之间的带宽为 3.38 Gbits/sec,远高于 Soft RoCE。
对端
1
| ib_write_lat -d rxe0 -x 1 --report_gbits
|
测试端
1
| ib_write_lat -d rxe0 -x 1 10.0.0.2 --report_gbits
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| ---------------------------------------------------------------------------------------
RDMA_Write Latency Test
Dual-port : OFF Device : rxe0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
TX depth : 1
Mtu : 1024[B]
Link type : Ethernet
GID index : 1
Max inline data : 0[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0000 QPN 0x0011 PSN 0x100003 RKey 0x000210 VAddr 0x00550000000000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:01
remote address: LID 0000 QPN 0x0011 PSN 0x100004 RKey 0x000210 VAddr 0x00550000001000
GID: 00:00:00:00:00:00:00:00:00:00:255:255:10:00:00:02
---------------------------------------------------------------------------------------
#bytes #iterations t_min[usec] t_max[usec] t_typical[usec] t_avg[usec] t_stdev[usec] 99% percentile[usec] 99.9% percentile[usec]
2 1000 383.61 1007.44 508.28 535.29 95.27 850.50 1007.44
---------------------------------------------------------------------------------------
|
3. InfiniBand
3.1 连接要求
InfiniBand 必须端到端走 IB fabric。全网由 Subnet Manager 管理,节点在同一 IB 子网内,端口被赋 LID 后才会 Active。
单交换机。
IB: 主机 HCA ── IB交换机(SM) ── 对端 HCA
多台交换机。
IB: 主机 HCA ── Leaf ── Spine ── Leaf ── 对端 HCA
多跳时注意:
| 说明 |
|---|
| 路径 | SM 管理整网,按 LID 转发 |
| 无损 | IB 链路层本身按 credit 流控 |
| MTU / 速率 | 端到端一致 |
| 禁忌 | 不要混入以太交换机 |
3.2 安装工具
1
| apt install -y rdma-core ibverbs-utils perftest ethtool infiniband-diags
|
3.3 设备
| 厂商 | 典型模块 | 说明 |
|---|
| NVIDIA/Mellanox | mlx5_core mlx5_ib | ConnectX 跑原生 IB;常用 MLNX_OFED |
| 其他 IB HCA | 跟厂商文档 | 模块名因卡而异 |
小网需 Subnet Manager(opensm 或交换机 SM);可选 IPoIB:modprobe ib_ipoib。
1
| lsmod | grep -iE 'mlx5|ib_ipoib|ib_core'
|
device node GUID
------ ----------------
mlx5_0 0000000000000001
mlx5_1 0000000000000002
mlx5_4 0000000000000003
mlx5_5 0000000000000004
mlx5_bond_0 0000000000000005
3.4 查看链路拓扑
同一 IB 子网内的机器上,执行 sminfo 返回结果类似:
1
| sminfo: sm lid 1 sm guid 0x0000000000000001, activity count 237173850 priority 0 state 3 SMINFO_MASTER
|
两端看到的 sm lid、sm guid 相同,且 state 为 SMINFO_MASTER,说明由同一个 Subnet Manager 管理、处于同一 IB 子网——这是互通的前提,还要本端端口 Active、同 PKey/分区等条件满足。activity count 会随时间变化,不必要求一致。
vendid=0x2c9
devid=0xd2f0
sysimgguid=0x0000000000001001
switchguid=0x0000000000001001(0000000000001001)
Switch 41 "S-0000000000001001" # "Quantum Mellanox Technologies" base port 0 lid 141 lmc 0
[19] "H-0000000000002001"[1](0000000000002001) # "node-01 mlx5_4" lid 185 4xHDR
[20] "H-0000000000002002"[1](0000000000002002) # "node-01 mlx5_5" lid 187 4xHDR
[21] "S-0000000000001002"[37] # "MF0;sw-agg-1:MQM8700/U1" lid 50 4xHDR
[23] "S-0000000000001002"[39] # "MF0;sw-agg-1:MQM8700/U1" lid 50 4xHDR
命令会输出 SM 可见的整张 fabric。上面是一台 Quantum 交换机(lid 141)的局部视图:端口 [19]/[20] 接到同一主机 node-01 的两张 HCA(mlx5_4 / mlx5_5),速率都是 4xHDR;[21]/[23] 接到上游聚合交换机 sw-agg-1。适合从交换机视角核对「这个口连到谁」。
CA: Mellanox Technologies Aggregation Node:
0x0000000000003001 13 1[ ] ==( 4X 53.125 Gbps Active/ LinkUp)==> 141 41[ ] "Quantum Mellanox Technologies" ( )
CA: node-01 mlx5_5:
0x0000000000002002 187 1[ ] ==( 4X 53.125 Gbps Active/ LinkUp)==> 141 20[ ] "Quantum Mellanox Technologies" ( )
Switch: 0x0000000000001003 Quantum Mellanox Technologies:
49 1[ ] ==( 4X 53.125 Gbps Active/ LinkUp)==> 173 1[ ] "node-02 mlx5_3" ( )
49 2[ ] ==( 4X 53.125 Gbps Active/ LinkUp)==> 38 1[ ] "node-03 mlx5_5" ( )
比 ibnetdiscover 更适合日常排查。每行是「本端 lid/端口 ==( 宽度 速率 状态)==> 对端 lid/端口」。这里 Active/LinkUp 表示逻辑链路与物理链路都正常;4X 53.125 Gbps 对应 HDR 速率。示例里 node-01 mlx5_5(lid 187)接到 Quantum(lid 141)的端口 20,与上面拓扑里 [20] 互相对得上。
Switch : 0x0000000000001001 ports 41 "Quantum Mellanox Technologies" base port 0 lid 141 lmc 0
Switch : 0x0000000000001004 ports 41 "MF0;sw-agg-5:MQM8700/U1" enhanced port 0 lid 55 lmc 0
快速清点 fabric 里有多少台 switch、各自 lid。这里至少有本机侧 Quantum(lid 141)和上游 sw-agg-5(lid 55);ports 41 含交换机管理口(port 0),业务口通常是 40。
Ca : 0x0000000000003001 ports 1 "Mellanox Technologies Aggregation Node"
Ca : 0x0000000000002002 ports 1 "node-01 mlx5_5"
列出 SM 登记的 CA(Channel Adapter)。既能看到普通计算节点 HCA(node-01 mlx5_5),也能看到交换机侧的 Aggregation Node;对照 iblinkinfo 可确认主机是否都挂进 fabric。
1
| ibdiagnet -o ./ib-report
|
-I- Stages Status Report:
STAGE Errors Warnings
Bad GUIDs/LIDs Check 0 0
Link State Active Check 0 0
General Devices Info Report 0 0
Performance Counters Report 0 0
Partitions Check 0 0
IPoIB Subnets Check 0 1
检查各个节点的状态是否有异常,详细报告在 ./ib-report 目录下。
3.5 点对点测试
采用 TCP 握手模式:QP 信息经 TCP 交换,RDMA 数据仍走 IB 链路。
State: Active
Base lid: 1
Port State=Active。
SM 可达。
1
2
| ip -4 addr | grep 10.0.0
ping -c 3 10.0.0.2
|
对端
1
| ib_write_bw -d mlx5_0 --report_gbits
|
测试端
1
| ib_write_bw -d mlx5_0 --report_gbits 10.0.0.2
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| ---------------------------------------------------------------------------------------
RDMA_Write BW Test
Dual-port : OFF Device : mlx5_0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
PCIe relax order: ON
ibv_wr* API : ON
TX depth : 128
CQ Moderation : 1
Mtu : 4096[B]
Link type : IB
Max inline data : 0[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0x1 QPN 0x1001 PSN 0xabc123 RKey 0x210000 VAddr 0x007f0000000000
remote address: LID 0x2 QPN 0x1002 PSN 0xdef456 RKey 0x216000 VAddr 0x007f0000001000
---------------------------------------------------------------------------------------
#bytes #iterations BW peak[Gb/sec] BW average[Gb/sec] MsgRate[Mpps]
65536 5000 179.98 179.93 0.343193
---------------------------------------------------------------------------------------
|
对端
1
| ib_write_lat -d mlx5_0 --report_gbits
|
测试端
1
| ib_write_lat -d mlx5_0 --report_gbits 10.0.0.2
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| ---------------------------------------------------------------------------------------
RDMA_Write Latency Test
Dual-port : OFF Device : mlx5_0
Number of qps : 1 Transport type : IB
Connection type : RC Using SRQ : OFF
PCIe relax order: OFF
ibv_wr* API : ON
TX depth : 1
Mtu : 4096[B]
Link type : IB
Max inline data : 220[B]
rdma_cm QPs : OFF
Data ex. method : Ethernet
---------------------------------------------------------------------------------------
local address: LID 0x1 QPN 0x1003 PSN 0xabc124 RKey 0x1ec000 VAddr 0x00560000000000
remote address: LID 0x2 QPN 0x1004 PSN 0xdef457 RKey 0x1e5000 VAddr 0x00560000001000
---------------------------------------------------------------------------------------
#bytes #iterations t_min[usec] t_max[usec] t_typical[usec] t_avg[usec] t_stdev[usec] 99% percentile[usec] 99.9% percentile[usec]
2 1000 2.44 8.29 2.56 2.56 0.10 2.58 8.29
---------------------------------------------------------------------------------------
|