Skip to content

Commit 5d0a065

Browse files
dstaay-fbfacebook-github-bot
authored andcommitted
CQE buffer SW control bit check (#965)
Summary: Pull Request resolved: #965 Issue: When consumer index exceeds cqe_cnt, we need to flip bit check for control flag. Reviewed By: allenwang28 Differential Revision: D79104818 fbshipit-source-id: 90141796406f814bcbc7087012d934fc3b289a70
1 parent b846b84 commit 5d0a065

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rdmaxcel-sys/src/rdmaxcel.cu

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,18 @@ __host__ __device__ void cqe_poll(int32_t* byte_cnt, cqe_poll_params_t params) {
303303
// Extract the opcode (upper 4 bits)
304304
uint8_t actual_opcode = op_own >> 4;
305305

306+
// check ownership (lower 1 bit), needs SW ownership to be consumed
307+
bool is_sw_owned = ((op_own & 0x1) == ((idx / params.cqe_cnt) & 0x1));
308+
306309
// this only checks for valid opcode, in some case should generate error
307310
const uint8_t FIRST_TWO_BITS_MASK = 0x3; // Binary: 00000011
308311
bool is_valid_opcode = (actual_opcode & ~FIRST_TWO_BITS_MASK) == 0;
309312

310-
if (is_valid_opcode) {
313+
if (is_sw_owned && is_valid_opcode) {
311314
*byte_cnt = byte_swap32(*(uint32_t*)(cqe + 44));
312315

313-
*params.dbrec = byte_swap32((idx + 1) & 0xFFFFFF);
314-
316+
volatile uint32_t* dbrec = (uint32_t*)params.dbrec;
317+
*dbrec = byte_swap32((idx + 1) & 0xFFFFFF);
315318
} else {
316319
*byte_cnt = -1;
317320
}

0 commit comments

Comments
 (0)