Soft-RoCE环境搭建

Soft-RoCE是RoCE协议的软件栈版本,可以在普通网卡上搭建RDMA环境

先确保安装以下软件:

1
2
3
4
5
6
7
sudo apt-get install git
sudo apt-get install libncurses5-dev
sudo apt-get install libssl-dev
sudo apt-get install libibverbs1 libibcm1libibcm-dev ibverbs-utils libibverbs-dev
sudo apt-get install libibverbs1librdmacm-dev librdmacm1 rdmacm-utils
sudo apt-get install openssh-server
sudo apt-get install libswitch-perl

Install Kernel

Clone kernel

1
git clone https://github.com/SoftRoCE/rxe-dev.git

切换到 ‘rxe_submission_v18’ 分支

1
git checkout rxe_submission_v18

进入到rxe-dev 目录 cd rxe-dev

1
cp /boot/config-$(uname –r) .config

切换到root用户权限,运行make menuconfig ,出现选择界面。(在使用 make menuconfig 之前需要安装ncurse-devel

输入”/“ ,然后输入RDMA_RXE,按下 enter,会查找有关RDMA_RXE 的选择项. 输入数字 1,就会选择到RDMA_RXE 的设置,输入”M” ,选中 RDMA 的配置.

然后 vi.config 来确认CONFIG_RDMA_RXE 为 m ,CONFIG_INFINIBAND_ADDR_TRANSCONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS 为 y

建议在Generalsetup –>Local version中填写一个名称,便于之后编译出的内核与其他内核区别开。

##编译内核

1
2
3
4
make –j 32
make modules_install
make install
make headers_install INSTALL_HDR_PATH=/usr

上述步骤如果遇到permission denied,命令前加上sudo 再执行。且上述命令均应在源码目录即 /rxe-dev 下执行

确认新的内核是否在grub引导中,可以查看 /boot/grub/grub.conf

用新内核启动后查看内核版本号和rdma_rxe模块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
kevin@ubuntu:~$ uname -r
4.7.0-rc3kevin+
kevin@ubuntu:~$ modinfo rdma_rxe
filename: /lib/modules/4.7.0-rc3kevin+/kernel/drivers/infiniband/hw/rxe/rdma_rxe.ko
version: 0.2
license: DualBSD/GPL
description: SoftRDMA transport
author: BobPearson, Frank Zago, John Groves, Kamal Heib
srcversion: 85F0433D44A5DAF81FBFE5C
depends: ib_core,ip6_udp_tunnel,udp_tunnel
intree: Y
vermagic: 4.7.0-rc3kevin+ SMP mod_unload modversions
parm: add:Create RXE device over network interface
parm: remove:Remove RXE device over network interface

Install user space library (librxe)

安装以下的包

1
2
3
4
5
6
7
libswitch-perl
libibverbs
libibverbs-devel
libibverbs-utils
librdmacm
librdmacm-devel
librdmacm-utils

编译安装 install userspace library librxe:

1
2
3
4
5
git clone https://github.com/SoftRoCE/librxe-dev.git
cd librxe-dev
./configure --libdir=/usr/lib64/ --prefix=
make
make install

./configure --libdir=/usr/lib64/ --prefix= 中如果路径只有/lib 就用/lib

Configure Soft-RoCE (RXE)

1
2
3
4
kevin@ubuntu:~$ rxe_cfg status
rxe modules not loaded
Name Link Driver Speed NMTU IPv4_addr RDEV RMTU
ens33 yes e1000 1500 192.168.188.132

Load ib_rxe kernel module, using the rxe_cfg script included in the librxe RPM:

1
2
3
4
kevin@ubuntu:~$ sudo rxe_cfg start
sh: echo: I/O error
Name Link Driver Speed NMTU IPv4_addr RDEV RMTU
ens33 yes e1000 1500 192.168.188.132 rxe0 1024

To verify RXE kernel module is loaded, run:

1
2
3
4
5
kevin@ubuntu:~$ lsmod |grep rdma_rxe
rdma_rxe 102400 0
ip6_udp_tunnel 16384 1 rdma_rxe
udp_tunnel 16384 1 rdma_rxe
ib_core 208896 6 rdma_cm,ib_cm,iw_cm,ib_uverbs,rdma_rxe,rdma_ucm

Create RXE device over network interface (e.g. ens33):

1
sudo rxe_cfg add ens33

Check the status of rxe_cfg, make sure that rxe0 was added under RDEV (rxe device).It is also possible to check the ibv_devices command.

1
2
3
4
5
6
7
kevin@ubuntu:~$ rxe_cfg 
Name Link Driver Speed NMTU IPv4_addr RDEV RMTU
ens33 yes e1000 1500 192.168.188.132 rxe0 1024 (3)
kevin@ubuntu:~$ ibv_devices
device node GUID
------ ----------------
rxe0 020c29fffebd5e22

Test connectivity.

  • On the server:
1
ibv_rc_pingpong -d rxe0 -g 0
  • On the client:
1
ibv_rc_pingpong -d rxe0 -g 0 <server_management_ip>

e.g Client:

1
2
3
kevin@ubuntu:~$ ibv_rc_pingpong -g 0 -d rxe0 -i 1 192.168.188.129
local address: LID 0x0000, QPN 0x000011, PSN 0x2cd726, GID fe80::20c:29ff:febd:5e22
remote address: LID 0x0000, QPN 0x000011, PSN 0x767a62, GID fe80::20c:29ff:fe44:4345

Test

rping

server

mark

client

mark

perftest

1
sudo apt-get install perftest

测试时需切换到root

Sever:

1
ib_send_bw –a

Client:

1
ib_send_bw 192.168.46.132 –a

mark

mark

FAQ

  • 用sudoapt-get update时出现“ E: 无法获得锁/var/lib/apt/lists/lock”错误
1
sudo rm /var/lib/apt/lists/lock
  • 如果出现缺少ssl的错误,就安装ssl
1
apt-get install libssl-dev
  • ERROR: make *No rule to make target”menuconfig”.stop.

原因是没有在内核源码目录下进行。例如,要编译或升级的内核解压后的目录为/usr/src/Linux-2.4.24,一定要进入到该目录后使用makemenuconfig命令,这样就不会提示上面的错误了。(在本文中就是在rxe-dev目录下编译)

  • 克隆的虚拟机中找不到eth0。因为网卡是克隆的,所以在测试连通性的时候不能用。要手动修改网卡信息。

  • 在试验 rdma 的时候,记得关闭防火墙

    1
    2
    - sudo iptables -F 
    chkconfig iptables off #开机不启动