@@ -76,8 +76,92 @@ static int _zxdh_query_qpc(struct ibv_qp *qp, struct zxdh_rdma_qpc *qpc)
76
76
return 0 ;
77
77
}
78
78
79
+ static void copy_modify_qpc_fields (struct zxdh_modify_qpc_req * req_cmd ,
80
+ uint64_t attr_mask ,
81
+ struct zxdh_rdma_qpc * qpc )
82
+ {
83
+ if (attr_mask & ZXDH_TX_READ_RETRY_FLAG_SET ) {
84
+ req_cmd -> retry_flag = qpc -> retry_flag ;
85
+ req_cmd -> rnr_retry_flag = qpc -> rnr_retry_flag ;
86
+ req_cmd -> read_retry_flag = qpc -> read_retry_flag ;
87
+ req_cmd -> cur_retry_count = qpc -> cur_retry_count ;
88
+ }
89
+ if (attr_mask & ZXDH_RETRY_CQE_SQ_OPCODE )
90
+ req_cmd -> retry_cqe_sq_opcode = qpc -> retry_cqe_sq_opcode ;
91
+
92
+ if (attr_mask & ZXDH_ERR_FLAG_SET ) {
93
+ req_cmd -> err_flag = qpc -> err_flag ;
94
+ req_cmd -> ack_err_flag = qpc -> ack_err_flag ;
95
+ }
96
+ if (attr_mask & ZXDH_PACKAGE_ERR_FLAG )
97
+ req_cmd -> package_err_flag = qpc -> package_err_flag ;
98
+ }
99
+
100
+ static int _zxdh_reset_qp (struct ibv_qp * qp , uint64_t opcode )
101
+ {
102
+ DECLARE_COMMAND_BUFFER (cmd , ZXDH_IB_OBJECT_QP_OBJ ,
103
+ ZXDH_IB_METHOD_QP_RESET_QP , 2 );
104
+ fill_attr_in_obj (cmd , ZXDH_IB_ATTR_QP_RESET_QP_HANDLE , qp -> handle );
105
+ fill_attr_in_uint64 (cmd , ZXDH_IB_ATTR_QP_RESET_OP_CODE , opcode );
106
+ return execute_ioctl (qp -> context , cmd );
107
+ }
108
+
109
+ static int _zxdh_modify_qpc (struct ibv_qp * qp , struct zxdh_rdma_qpc * qpc ,
110
+ uint64_t qpc_mask )
111
+ {
112
+ DECLARE_COMMAND_BUFFER (cmd , ZXDH_IB_OBJECT_QP_OBJ ,
113
+ ZXDH_IB_METHOD_QP_MODIFY_QPC , 3 );
114
+ struct zxdh_modify_qpc_req req = { 0 };
115
+
116
+ copy_modify_qpc_fields (& req , qpc_mask , qpc );
117
+ fill_attr_in_obj (cmd , ZXDH_IB_ATTR_QP_QUERY_HANDLE , qp -> handle );
118
+ fill_attr_in_uint64 (cmd , ZXDH_IB_ATTR_QP_MODIFY_QPC_MASK , qpc_mask );
119
+ fill_attr_in_ptr (cmd , ZXDH_IB_ATTR_QP_MODIFY_QPC_REQ , & req );
120
+ return execute_ioctl (qp -> context , cmd );
121
+ }
122
+
123
+ static int _zxdh_modify_qp_udp_sport (struct ibv_context * ibctx ,
124
+ uint16_t udp_sport , uint32_t qpn )
125
+ {
126
+ if (udp_sport <= MIN_UDP_SPORT || qpn <= MIN_QP_QPN )
127
+ return - EINVAL ;
128
+
129
+ DECLARE_COMMAND_BUFFER (cmd , ZXDH_IB_OBJECT_QP_OBJ ,
130
+ ZXDH_IB_METHOD_QP_MODIFY_UDP_SPORT , 2 );
131
+ fill_attr_in (cmd , ZXDH_IB_ATTR_QP_UDP_PORT , & udp_sport ,
132
+ sizeof (udp_sport ));
133
+ fill_attr_in_uint32 (cmd , ZXDH_IB_ATTR_QP_QPN , qpn );
134
+ return execute_ioctl (ibctx , cmd );
135
+ }
136
+
137
+ static int _zxdh_get_log_trace_switch (struct ibv_context * ibctx ,
138
+ uint8_t * switch_status )
139
+ {
140
+ DECLARE_COMMAND_BUFFER (cmd , ZXDH_IB_OBJECT_DEV ,
141
+ ZXDH_IB_METHOD_DEV_GET_LOG_TRACE , 1 );
142
+
143
+ fill_attr_out_ptr (cmd , ZXDH_IB_ATTR_DEV_GET_LOG_TARCE_SWITCH ,
144
+ switch_status );
145
+ return execute_ioctl (ibctx , cmd );
146
+ }
147
+
148
+ static int _zxdh_set_log_trace_switch (struct ibv_context * ibctx ,
149
+ uint8_t switch_status )
150
+ {
151
+ DECLARE_COMMAND_BUFFER (cmd , ZXDH_IB_OBJECT_DEV ,
152
+ ZXDH_IB_METHOD_DEV_SET_LOG_TRACE , 1 );
153
+ fill_attr_in (cmd , ZXDH_IB_ATTR_DEV_SET_LOG_TARCE_SWITCH , & switch_status ,
154
+ sizeof (switch_status ));
155
+ return execute_ioctl (ibctx , cmd );
156
+ }
157
+
79
158
static struct zxdh_uvcontext_ops zxdh_ctx_ops = {
159
+ .modify_qp_udp_sport = _zxdh_modify_qp_udp_sport ,
160
+ .get_log_trace_switch = _zxdh_get_log_trace_switch ,
161
+ .set_log_trace_switch = _zxdh_set_log_trace_switch ,
80
162
.query_qpc = _zxdh_query_qpc ,
163
+ .modify_qpc = _zxdh_modify_qpc ,
164
+ .reset_qp = _zxdh_reset_qp ,
81
165
};
82
166
83
167
static inline struct zxdh_uvcontext * to_zxdhtx (struct ibv_context * ibctx )
0 commit comments