Skip to content

Commit db86ec2

Browse files
Jonas PfefferlePepperJo
authored andcommitted
IbvWC: valueOf status and opcode
Allow to get enum value of IbvWcStatus and IbvWcOpcode from Int. Change-Id: Ie4f600fe986f619269acdd516bd35f37bf665f79 Signed-off-by: Jonas Pfefferle <[email protected]> Reviewed-on: https://review.gerrithub.io/400059 Tested-by: <[email protected]> Reviewed-by: Yuval Degani <[email protected]> Reviewed-by: Patrick Stuedi <[email protected]> Tested-by: Patrick Stuedi <[email protected]> Reviewed-by: Adrian Schuepbach <[email protected]>
1 parent 9e273d4 commit db86ec2

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/main/java/com/ibm/disni/rdma/verbs/IbvWC.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,22 @@
4242
* Represents a work completion event. Application will use the pollCQ verbs call to query for completion events.
4343
*/
4444
public class IbvWC {
45-
public static int CSIZE = 48;
45+
public static int CSIZE = 48;
4646

4747
public enum IbvWcStatus {
48-
IBV_WC_SUCCESS, IBV_WC_LOC_LEN_ERR, IBV_WC_LOC_QP_OP_ERR, IBV_WC_LOC_EEC_OP_ERR, IBV_WC_LOC_PROT_ERR, IBV_WC_WR_FLUSH_ERR, IBV_WC_MW_BIND_ERR, IBV_WC_BAD_RESP_ERR, IBV_WC_LOC_ACCESS_ERR, IBV_WC_REM_INV_REQ_ERR, IBV_WC_REM_ACCESS_ERR, IBV_WC_REM_OP_ERR, IBV_WC_RETRY_EXC_ERR, IBV_WC_RNR_RETRY_EXC_ERR, IBV_WC_LOC_RDD_VIOL_ERR, IBV_WC_REM_INV_RD_REQ_ERR, IBV_WC_REM_ABORT_ERR, IBV_WC_INV_EECN_ERR, IBV_WC_INV_EEC_STATE_ERR, IBV_WC_FATAL_ERR, IBV_WC_RESP_TIMEOUT_ERR, IBV_WC_GENERAL_ERR
48+
IBV_WC_SUCCESS, IBV_WC_LOC_LEN_ERR, IBV_WC_LOC_QP_OP_ERR, IBV_WC_LOC_EEC_OP_ERR, IBV_WC_LOC_PROT_ERR, IBV_WC_WR_FLUSH_ERR, IBV_WC_MW_BIND_ERR, IBV_WC_BAD_RESP_ERR, IBV_WC_LOC_ACCESS_ERR, IBV_WC_REM_INV_REQ_ERR, IBV_WC_REM_ACCESS_ERR, IBV_WC_REM_OP_ERR, IBV_WC_RETRY_EXC_ERR, IBV_WC_RNR_RETRY_EXC_ERR, IBV_WC_LOC_RDD_VIOL_ERR, IBV_WC_REM_INV_RD_REQ_ERR, IBV_WC_REM_ABORT_ERR, IBV_WC_INV_EECN_ERR, IBV_WC_INV_EEC_STATE_ERR, IBV_WC_FATAL_ERR, IBV_WC_RESP_TIMEOUT_ERR, IBV_WC_GENERAL_ERR;
49+
50+
public static IbvWcStatus valueOf(int value) {
51+
/* this is slow but ok for debugging purposes */
52+
for (IbvWcStatus status : values()) {
53+
if (status.ordinal() == value) {
54+
return status;
55+
}
56+
}
57+
throw new IllegalArgumentException();
58+
}
4959
};
50-
60+
5161
public enum IbvWcOpcode {
5262
IBV_WC_SEND(0),
5363
IBV_WC_RDMA_WRITE(1),
@@ -62,11 +72,20 @@ public enum IbvWcOpcode {
6272
IbvWcOpcode(int opcode) { this.opcode = opcode; }
6373

6474
public int getOpcode() { return opcode; }
75+
76+
public static IbvWcOpcode valueOf(int value) {
77+
for (IbvWcOpcode opcode : values()) {
78+
if (opcode.getOpcode() == value) {
79+
return opcode;
80+
}
81+
}
82+
throw new IllegalArgumentException();
83+
}
6584
}
6685

6786
public static int CQ_OK = 0;
6887
public static int CQ_EMPTY = -1;
69-
public static int CQ_POLL_ERR = -2;
88+
public static int CQ_POLL_ERR = -2;
7089

7190
protected long wr_id;
7291
protected int status;
@@ -81,7 +100,7 @@ public enum IbvWcOpcode {
81100
protected short slid;
82101
protected short sl;
83102
protected short dlid_path_bits;
84-
103+
85104
protected int err;
86105
protected boolean isSend;
87106
protected short wqIndex;
@@ -97,7 +116,7 @@ public IbvWC() {
97116
isSend = false;
98117
wqIndex = -1;
99118
}
100-
119+
101120
public IbvWC clone(){
102121
IbvWC wc = new IbvWC();
103122
wc.byte_len = this.byte_len;
@@ -115,7 +134,7 @@ public IbvWC clone(){
115134
wc.status = this.status;
116135
wc.wqIndex = this.wqIndex;
117136
wc.wr_id = this.wr_id;
118-
137+
119138
return wc;
120139
}
121140

@@ -156,7 +175,7 @@ public void setStatus(int status) {
156175
}
157176

158177
/**
159-
* Represents the opcode of the original operation for this completion event.
178+
* Represents the opcode of the original operation for this completion event.
160179
*
161180
* @return the opcode
162181
*/
@@ -356,7 +375,7 @@ public void setDlid_path_bits(short dlid_path_bits) {
356375
public String getClassName() {
357376
return IbvWC.class.getCanonicalName();
358377
}
359-
378+
360379
/**
361380
* Unsupported.
362381
*
@@ -473,7 +492,7 @@ public void setTail3(short tail3) {
473492
public void setDiff(short diff) {
474493
this.diff = diff;
475494
}
476-
495+
477496
/**
478497
* Unsupported.
479498
*

0 commit comments

Comments
 (0)