技术标签: RDMA
目录
原文:https://www.rdmamojo.com/2013/02/15/ibv_poll_cq/ (强烈建议去看原文)
ibv_poll_cq()从完成队列(CQ)轮询WC(工作完成),非阻塞函数。
[工作完成] 表示 WQ(工作队列)中的WR(工作请求) 以及与CQ相关联的所有已发布到该工作队列的未发出信号的WR(工作请求)均已完成。
(A Work Completion indicates that a Work Request in a Work Queue, and all of the outstanding unsignaled Work Requests that posted to that Work Queue, associated with the CQ are done.)
任何发送和接收请求 以及以错误结束的发送请求,将在处理结束后生成WC(工作完成)。
(Any Receive Requests, signaled Send Requests and Send Requests that ended with an error will generate a Work Completion after their processing end.)
当[工作请求]结束时,会将[工作完成]添加到与此工作队列相关联的CQ的尾部。 ibv_poll_cq()检查CQ中是否存在[工作完成],并按其输入顺序从CQ的顶部弹出(FIFO)。从CQ弹出[工作完成]后,无法将其返回给CQ。
应该以比产生WC更快的速度消费CQ中的WC,防止CQ队列溢出,如果发生CQ溢出,将触发异步事件IBV_EVENT_CQ_ERR,并且无法再使用CQ。
Name | Direction | Description |
---|---|---|
cq | in | 从ibv_create_cq()返回的CQ |
num_entries | in | 期望从CQ读取的WC数 |
wc | out | 从CQ读取的WC数num_entries的数组。(Array of size num_entries of the Work Completions that will be read from the CQ) |
结构ibv_wc描述了wc的属性。
struct ibv_wc {
uint64_t wr_id;
enum ibv_wc_status status;
enum ibv_wc_opcode opcode;
uint32_t vendor_err;
uint32_t byte_len;
uint32_t imm_data;
uint32_t qp_num;
uint32_t src_qp;
int wc_flags;
uint16_t pkey_index;
uint16_t slid;
uint8_t sl;
uint8_t dlid_path_bits;
};
这是struct ibv_wc的完整说明:
wr_id | 与WR对应关联的64 bit值 (The 64 bits value that was associated with the corresponding Work Request) |
status | Status of the operation. The value can be one of the following enumerated values and their numeric value: 操作状态。该值可以是下列枚举值及其数字值之一:
|
opcode | The operation that the corresponding Work Request performed. This value controls the way that data was sent, the direction of the data flow and the valid attributes in the Work Completion. The value can be one of the following enumerated values: 相应的工作请求执行的操作。此值控制数据的发送方式、数据流的方向以及“工作完成”中的有效属性。该值可以是下列枚举值之一:
|
vendor_err | 供应商特定的错误,如果completion 因错误而结束,则会提供更多信息。一旦WC以错误结束,该值向RDMA设备的供应商提供有关失败原因的提示。 |
byte_len | 传输的字节数。与incoming Send或 RDMA Write with immediate operations的接收队列有关。该值不包括立即数的长度(如果存在)。与RDMA读取和原子操作的“发送队列”相关。对于不与SRQ关联的UD QP的接收队列,或者对于与UD QP关联的SRQ,该值等于消息的有效负载加上为GRH保留的40个字节。传输的字节数是消息的有效负载加上为GRH保留的40个字节(无论是否存在GRH) (The number of bytes transferred. Relevant if the Receive Queue for incoming Send or RDMA Write with immediate operations. This value doesn't include the length of the immediate data, if such exists. Relevant in the Send Queue for RDMA Read and Atomic operations.For the Receive Queue of a UD QP that is not associated with an SRQ or for an SRQ that is associated with a UD QP this value equals to the payload of the message plus the 40 bytes reserved for the GRH.The number of bytes transferred is the payload of the message plus the 40 bytes reserved for the GRH, whether or not the GRH is present) |
imm_data | (可选)以网络顺序的SEND或RDMA WRITE操作码中的32 bit 数字,与有效载荷一起发送到远程端,并放置在[接收工作完]( Receive Work Completion)成中,而不是在远端内存缓冲区中。如果设置了IBV_WC_WITH_IMM,则此值有效 |
qp_num | 已完成的WR的本地QP的号码。与和SRQ相关的[接收工作完成](Receive Work Completions)相关. (Local QP number of completed WR. Relevant for Receive Work Completions that are associated with an SRQ) |
src_qp | Source QP number (remote QP number) of completed WR. Relevant for Receive Work Completions of a UD QP |
wc_flags | Flags of the Work Completion. It is either 0 or the bitwise OR of one or more of the following flags:
|
pkey_index | P_Key index. Relevant for GSI QPs |
slid | Source LID (the base LID that this message was sent from). Relevant for Receive Work Completions of a UD QP |
sl | Service Level (the SL LID that this message was sent with). Relevant for Receive Work Completions of a UD QP |
dlid_path_bits | Destination LID path bits. Relevant for Receive Work Completions of a UD QP (not applicable for multicast messages) |
以下测试(opcode & IBV_WC_RECV)将指示 来自接收队列的完成状态。(The following test (opcode & IBV_WC_RECV) will indicate that the status of a completion is from the Receive Queue.)
对于UD QP的[接收工作完成](receive Work Completions),无论是否设置了IBV_WC_GRH位,数据均从已发布的接收缓冲区的偏移量40开始。
并非所有wc属性始终有效。如果完成状态不是IBV_WC_SUCCESS,则仅以下属性有效:
Value | Description |
---|---|
正数 | 从CQ读取的WC数及其值在wc中返回。如果该值小于num_entries,则表示CQ中没有更多的工作完成。如果此值等于num_entries,则CQ中可能会有更多的工作完成 |
0 | CQ为空 |
负数 | 尝试从CQ读取WC(工作完成)时发生故障 |
从CQ轮询WC(工作完成)(在轮询模式下):
struct ibv_wc wc;
int num_comp;
do {
num_comp = ibv_poll_cq(cq, 1, &wc);
} while (num_comp == 0);
if (num_comp < 0) {
fprintf(stderr, "ibv_poll_cq() failed\n");
return -1;
}
/* verify the completion status */
if (wc.status != IBV_WC_SUCCESS) {
fprintf(stderr, "Failed status %s (%d) for wr_id %d\n",
ibv_wc_status_str(wc.status),
wc.status, (int)wc.wr_id);
return -1;
}
那工作完成(WC)到底是什么?
工作完成意味着相应的工作请求已结束,缓冲区可以(重新)用于读取,写入或释放。
ibv_poll_cq()是否引起上下文切换?
否。Work Completions的轮询根本不会导致上下文切换;它不会导致上下文切换。这就是为什么RDMA技术可以实现极低的延迟(低于1 usc)的原因。
Is there a limit to the number of Work Completions that can we polled when calling ibv_poll_cq()?
调用ibv_poll_cq()时可以轮询的[工作完成](Work Completions 数量是否有限制?
没有,你想读多少都行。
我调用了ibv_poll_cq(),它填充了我提供给它的所有数组。我能否知道CQ中还有多少工作完成?
不,你不能。
我从UD QP的接收队列中获得了工作完成(WC),并且进展顺利。我从内存缓冲区中读取了数据,但数据不正确。为什么?
也许您查看了数据的起始偏移量0。对于UD QP的任何工作完成,无论是否存在GRH,数据都将放置在相关内存缓冲区的偏移量40中。
什么是GRH,为什么我需要它?
全局路由头(GRH)提供的信息对于将消息发回给此消息的发件人(如果来自其他子网或来自多播组)最有用。
I've got completion with error status. Can I read all of the Work Completion fields?
否。如果“工作完成”状态表明存在错误,则仅以下属性有效:wr_id,status,qp_num和vendor_err。其余属性未定义。
我从CQ上Read了一个WC,但我不需要,我可以将其退还给CQ吗?
不,你不能。
我可以阅读属于特定工作队列的工作完成吗?(Can I read Work Completion that belongs to a specific Work Queue?)
不,你不能。
如果添加的工作完成(WC)数量超过CQ的size,将会发生什么情况?
CQ将超限,并且CQ(以及与之关联的所有QP)将进入错误状态。
文章浏览阅读210次。HG-S1010配有模拟量输出(电压、电流),NPN/PNP输出,也可通过外接通讯模块进行输出。通信模块包括SC-HG1-485模块(RS485接口协议)、SC-HG1-ETC模块(EtherCAT总线)、SC-HG1-C模块(CCLink协议)等。本文介绍连接松下FP7与HG-S1010配RS485通信模块进行通信,通过modbus协议读取HG-S1010当前测量值。主控制器测量值位置在地址H64处,占两个字节。将SC-HG1-485模块与控制器HG-SC101连接,在端子台+、-插入通信用线。_hg s1010接线
文章浏览阅读861次。verilog_[netlist 29-358] reg 'inst/image_out_valid_reg' of type 'fdcp' cannot be tim
文章浏览阅读328次,点赞6次,收藏10次。关于计算机一级考试的局详细版整理
文章浏览阅读740次,点赞10次,收藏7次。在面向对象设计中,根据具体需求选择使用接口、抽象类或实现类来组织扩展与维护的代码结构 ···
文章浏览阅读6.2w次,点赞5次,收藏46次。前言其实大数据图表展示的这类平台有很多,Superset是其中之一,最近有个需求对各类图表展示的开发较多,索性将工作量交给这个平台。介绍Superset的中文翻译是快船,而Superset其实是一个自助式数据分析工具,它的主要目标是简化我们的数据探索分析操作,它的强大之处在于整个过程一气呵成,几乎不用片刻的等待。 部署docker方式(推荐)docker pull amancevice/carav_superset分析hive表
文章浏览阅读1.3k次,点赞28次,收藏21次。在使用Windows 10的过程中,许多用户依赖于其内置的安全中心来保护电脑免受恶意软件的侵害。然而,有时安全中心的误判可能导致重要文件被错误地删除。当面对这种情况时,了解如何恢复误删的文件并掌握预防措施显得尤为重要。本文将为您详细解析恢复误删文件的多种方法,并为您提供一系列实用的预防策略,以确保您的数据安全。
文章浏览阅读46次。当前使用Centos7.x系统,php使用7.1版本,WLNMP一键安装包amqp扩展包地址:https://pecl.php.net/package/amqp1、安装所需依赖,如果在编译时还提示缺少其他依赖,请自行安装12yuminstallepel-releaseyuminstallautoconfgccgcc-c++librabbitmqlibrabbitmq-devel2、下载amqp最新...
文章浏览阅读824次,点赞2次,收藏8次。HyperMesh二次开发创建顶层窗口在HyperMesh中进行二次开发我们经常会做一些弹窗插件,在窗口输入某些参数,实现某些功能,但是当我们需要重复使用这个功能的时候,只要中途有任何返回HyperMesh软件的操作,普通的窗口就会直接进入后台。以下为实例代码:destroy .\u9876\u5c42\u7a97\u53e3set win .\u9876\u5c42\u7a97\u53e3toplevel $win -padx 20 -pady 15#下面这行代码为控制窗口在电脑窗口最顶层_hypermesh如何创建工具窗口
文章浏览阅读157次。Hive 3.12Hadoop 3.1.3hbase 2.0.5spark 3.0.0zookeeper 3.5.7flume 1.9.0ranger 2.0.0sqoop 1.4.7_你们公司的大数据框架版本
文章浏览阅读126次。Java虚拟机一 java内存区域和内存溢出异常运行时数据区域栈帧是方法运行期的基础数据结构。程序计数器是一块较小的内存空间,它的作用可以看做是当前线程所执行的字节码的行号指示器。字节码解释器工作时就是通过改变这个计数器的值来选取下一条需要执行的字节码指令,分支、循环、跳转、异常处理线程恢复等基础功能都需要依赖这个计数器来完成。Java虚拟机的多线程是通过线程轮流切换并分配处理器执行时间的方式来实现的,在任何一个时刻,一个处理器(对于多核处理器来说是一个内核)只会执行一条线程中的指令。因此,为
文章浏览阅读379次。import Vue from 'vue'Vue.directive('isIphoneX', {bind: function (el, binding) {const _local = 'ios'let isIphoneX = falseif (_local === 'ios' && window.screen.height) {isIphoneX = window.screen..._min-height: 89vh;
文章浏览阅读2.8k次,点赞2次,收藏4次。简介MyBatis-Plus是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。一、MyBatis-Plus和SpringBoot整合应用1.1 项目依赖在原项目依赖上,加上下面依赖<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-start_ com.baomidou mybatis-plus-boot-s