【报错处理】ib_write_bw执行遇到Failed to modify QP 358 to RTR原因与解决办法?

拓扑

光纤
光纤
光纤
未连接
未连接
Server
IP addr: 1.1.5.0 mlx5_0
IP addr: 1.1.5.1 mlx5_1
CMD: ib_write_bw
Client
IP addr: 1.1.4.0 mlx5_2
IP addr: 1.1.4.1 mlx5_3
命令: ib_write_bw 1.1.1.1
mlx5_0
mlx5_2
mlx5_1
mlx5_3
VENDOR     ETH        BDF                  IBdev      IPaddr          Company                       
0x15b3     enp5s0f0   mlx5_0 (Up)          05:00.0    1.1.5.0/8       Mellanox Family [ConnectX-5]  
0x15b3     enp5s0f1   mlx5_1 (Up)          05:00.1    1.1.5.1/8       Mellanox Family [ConnectX-5]  
0x15b3     enp6s0f0   mlx5_2 (Up)          06:00.0    1.1.4.0/8       Mellanox Family [ConnectX-4 Lx] 
0x15b3     enp6s0f1   mlx5_3 (Up)          06:00.1    1.1.4.1/8       Mellanox Family [ConnectX-4 Lx] 

现象

  • 命令行报错:

    Failed to modify QP 139 to RTR
    Unable to Connect the HCA’s through the link

  • 驱动报错:

    mlx5_core 0000:42:00.0 enp66s0f0: mlx5e_ethtool_get_link_ksettings: query port ptys failed: -67

    细节:
    在这里插入图片描述
    在这里插入图片描述

根因

QP可以处于不同的状态,其中RTR(Ready to Receive)是QP状态之一,表示QP已经准备好接收消息。
两个IB接口并未链接,但是两个IB接口的服务器是能够互通的时候会出现该问题

解决办法

更改拓扑,让测试的两个port在IB上能够通。比如直连或者交换机处理。

你遇到的错误: ``` undefined reference to `ibv_modify_qp' ``` 这是 **链接阶段(linking)错误**,说明编译器找到了函数声明(即头文件已包含),但 **没有找到该函数的实现** —— 也就是缺少对应的库。 --- ### ✅ 解决方案 `ibv_modify_qp` 是 **InfiniBand Verbs API** 的一部分,属于 `libibverbs` 库。你需要在编译时链接这个库。 --- ### 🔧 正确的编译命令 ```bash gcc your_program.c -o your_program -libverbs ``` 或者使用 `pkg-config` 更可靠地获取编译和链接参数: ```bash gcc $(pkg-config --cflags libibverbs) your_program.c -o your_program $(pkg-config --libs libibverbs) ``` --- ### 📦 所需依赖说明 | 组件 | 作用 | |------|------| | `-libverbs` | 链接 InfiniBand 用户态驱动库(libibverbs.so) | | `#include <infiniband/verbs.h>` | 包含头文件(必须) | 确保你的代码中已经包含了头文件: ```c #include <infiniband/verbs.h> ``` --- ### 💡 常见问题排查 #### 1. 安装 libibverbs 开发包(Ubuntu/Debian) ```bash sudo apt-get install libibverbs-dev libibverbs1 ``` #### 2. CentOS/RHEL/Fedora ```bash # Fedora/RHEL8+ sudo dnf install libibverbs-devel # 或旧版本 sudo yum install libibverbs-devel ``` #### 3. 检查库是否可用 ```bash pkg-config --exists libibverbs && echo "Found" || echo "Not found" ``` #### 4. 查看库路径(调试用) ```bash pkg-config --libs libibverbs # 输出示例:-libverbs ``` --- ### ✅ 示例完整构建流程 假设源文件为 `rdma_demo.c`: ```c #include <stdio.h> #include <infiniband/verbs.h> int main() { struct ibv_context *ctx = NULL; struct ibv_qp *qp = NULL; struct ibv_qp_attr attr = {}; int flags = 0; // 示例调用(实际需先创建 QP) // ibv_modify_qp(qp, &attr, flags); printf("Link ibverbs correctly!\n"); return 0; } ``` 编译命令: ```bash gcc $(pkg-config --cflags libibverbs) rdma_demo.c -o rdma_demo $(pkg-config --libs libibverbs) ``` --- ### ⚠️ 注意事项 - `ibv_modify_qp` 通常用于修改队列对(Queue Pair)的状态(如从 RESET → INIT → RTR → RTS) - 调用前必须正确初始化 `attr` 和 `flags` - 实际运行还需要 RDMA 硬件(如 Mellanox 网卡)或模拟环境支持 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值