@@ -36,7 +36,7 @@ static void uct_rc_mlx5_get_dptr_buffer(uct_rc_iface_send_op_t *op,
3636 buffer = * is_dm_p ? op -> buffer : wqe_buffer ;
3737 * length_p = ntohl (dptr -> byte_count );
3838
39- ucs_assert ((buffer != NULL ) || (* length_p == 0 ));
39+ ucs_assert ((buffer != NULL ) && (* length_p > 0 ));
4040
4141 * buffer_p = buffer ;
4242}
@@ -62,7 +62,7 @@ uct_rc_mlx5_op_info_fill_rma_raddr(uct_ep_op_info_t *info,
6262 info -> rma .rkey = ntohl (raddr -> rkey );
6363}
6464
65- static ucs_status_t uct_rc_mlx5_op_info_fill_zcopy_iov (
65+ static void uct_rc_mlx5_op_info_fill_zcopy_iov (
6666 uct_rc_mlx5_op_callback_data_t * callback_data ,
6767 const uct_ib_mlx5_txwq_t * txwq , const void * first_dptr , size_t length ,
6868 size_t * iovcnt_p )
@@ -71,22 +71,16 @@ static ucs_status_t uct_rc_mlx5_op_info_fill_zcopy_iov(
7171 uint32_t byte_count ;
7272 size_t iovcnt , i ;
7373
74- if ((length % sizeof (* dptr )) != 0 ) {
75- return UCS_ERR_INVALID_PARAM ;
76- }
74+ ucs_assert ((length % sizeof (* dptr )) == 0 );
7775
7876 iovcnt = length / sizeof (* dptr );
79- if (iovcnt > ucs_static_array_size (callback_data -> iov )) {
80- return UCS_ERR_INVALID_PARAM ;
81- }
77+ ucs_assert (iovcnt <= ucs_static_array_size (callback_data -> iov ));
8278
8379 dptr = uct_ib_mlx5_txwq_wrap_any ((uct_ib_mlx5_txwq_t * )txwq ,
8480 (void * )first_dptr );
8581 for (i = 0 ; i < iovcnt ; ++ i ) {
8682 byte_count = ntohl (dptr -> byte_count );
87- if (byte_count & MLX5_INLINE_SEG ) {
88- return UCS_ERR_INVALID_PARAM ;
89- }
83+ ucs_assert (!(byte_count & MLX5_INLINE_SEG ));
9084
9185 callback_data -> memh [i ].lkey = ntohl (dptr -> lkey );
9286 callback_data -> memh [i ].rkey = UCT_IB_INVALID_MKEY ;
@@ -102,7 +96,6 @@ static ucs_status_t uct_rc_mlx5_op_info_fill_zcopy_iov(
10296 }
10397
10498 * iovcnt_p = iovcnt ;
105- return UCS_OK ;
10699}
107100
108101static void
@@ -111,37 +104,27 @@ uct_rc_mlx5_op_info_fill_put_null(uct_ep_op_info_t *info,
111104{
112105 uct_rc_mlx5_op_info_fill_rma_raddr (info , raddr );
113106
114- info -> operation = UCT_EP_OP_PUT_SHORT ;
115- info -> rma .field_mask |= UCT_EP_OP_INFO_RMA_FIELD_PAYLOAD_DATA ;
116- info -> rma .payload .data .buffer = NULL ;
117- info -> rma .payload .data .length = 0 ;
107+ info -> operation = UCT_EP_OP_PUT_SHORT ;
118108}
119109
120- static ucs_status_t
121- uct_rc_mlx5_op_info_fill_put_short (uct_ep_op_info_t * info ,
122- const uct_ib_mlx5_txwq_t * txwq ,
123- const struct mlx5_wqe_inl_data_seg * inl ,
124- const struct mlx5_wqe_raddr_seg * raddr ,
125- uint8_t * callback_data ,
126- size_t callback_data_size ,
127- size_t max_inline_length )
110+ static void uct_rc_mlx5_op_info_fill_put_short (
111+ uct_ep_op_info_t * info , const uct_ib_mlx5_txwq_t * txwq ,
112+ const struct mlx5_wqe_inl_data_seg * inl ,
113+ const struct mlx5_wqe_raddr_seg * raddr ,
114+ uct_rc_mlx5_op_callback_data_t * callback_data )
128115{
129116 size_t inline_length = ntohl (inl -> byte_count ) & ~MLX5_INLINE_SEG ;
130117
131- if ((inline_length > callback_data_size ) ||
132- (inline_length > max_inline_length )) {
133- return UCS_ERR_INVALID_PARAM ;
134- }
118+ ucs_assert (inline_length <= sizeof (callback_data -> data ));
135119
136- uct_ib_mlx5_txwq_copy_data (txwq , inl + 1 , callback_data , inline_length );
120+ uct_ib_mlx5_txwq_copy_segs (txwq , inl + 1 , callback_data -> data ,
121+ inline_length );
137122 uct_rc_mlx5_op_info_fill_rma_raddr (info , raddr );
138123
139124 info -> operation = UCT_EP_OP_PUT_SHORT ;
140125 info -> rma .field_mask |= UCT_EP_OP_INFO_RMA_FIELD_PAYLOAD_DATA ;
141- info -> rma .payload .data .buffer = callback_data ;
126+ info -> rma .payload .data .buffer = callback_data -> data ;
142127 info -> rma .payload .data .length = inline_length ;
143-
144- return UCS_OK ;
145128}
146129
147130static void
@@ -163,22 +146,17 @@ uct_rc_mlx5_op_info_fill_put_bcopy(uct_ep_op_info_t *info,
163146 info -> rma .payload .data .length = length ;
164147}
165148
166- static ucs_status_t uct_rc_mlx5_op_info_fill_put_zcopy (
149+ static void uct_rc_mlx5_op_info_fill_put_zcopy (
167150 uct_ep_op_info_t * info , const uct_ib_mlx5_txwq_t * txwq ,
168151 uct_rc_iface_send_op_t * op , const struct mlx5_wqe_data_seg * dptr ,
169152 const struct mlx5_wqe_raddr_seg * raddr , size_t wqe_size ,
170153 uct_rc_mlx5_op_callback_data_t * callback_data )
171154{
172155 size_t header_size = sizeof (struct mlx5_wqe_ctrl_seg ) + sizeof (* raddr );
173156 size_t iovcnt ;
174- ucs_status_t status ;
175-
176- status = uct_rc_mlx5_op_info_fill_zcopy_iov (
177- callback_data , txwq , dptr , wqe_size - header_size , & iovcnt );
178- if (status != UCS_OK ) {
179- return status ;
180- }
181157
158+ uct_rc_mlx5_op_info_fill_zcopy_iov (callback_data , txwq , dptr ,
159+ wqe_size - header_size , & iovcnt );
182160 uct_rc_mlx5_op_info_fill_rma_raddr (info , raddr );
183161
184162 info -> operation = UCT_EP_OP_PUT_ZCOPY ;
@@ -187,7 +165,6 @@ static ucs_status_t uct_rc_mlx5_op_info_fill_put_zcopy(
187165 info -> rma .payload .zcopy .iovcnt = iovcnt ;
188166
189167 uct_rc_mlx5_op_info_fill_comp (info , op );
190- return UCS_OK ;
191168}
192169
193170static ucs_status_t uct_rc_mlx5_op_info_fill_put (
@@ -199,43 +176,33 @@ static ucs_status_t uct_rc_mlx5_op_info_fill_put(
199176 const struct mlx5_wqe_raddr_seg * raddr ;
200177 const struct mlx5_wqe_inl_data_seg * inl ;
201178
202- if (wqe_size < header_size ) {
203- return UCS_ERR_INVALID_PARAM ;
204- }
179+ ucs_assert (wqe_size >= header_size );
205180
206181 raddr = uct_ib_mlx5_txwq_wrap_any ((uct_ib_mlx5_txwq_t * )txwq ,
207182 (void * )(ctrl + 1 ));
208- /* Empty RDMA_WRITE: zero-length zcopy, or a dummy PUT with no payload. */
209183 if (wqe_size == header_size ) {
210- if ((op != NULL ) &&
211- (op -> handler == uct_rc_ep_send_op_completion_handler )) {
212- return uct_rc_mlx5_op_info_fill_put_zcopy (
213- info , txwq , op ,
214- (const struct mlx5_wqe_data_seg * )(raddr + 1 ), raddr ,
215- wqe_size , callback_data );
216- }
184+ ucs_assert (op == NULL );
217185
218186 uct_rc_mlx5_op_info_fill_put_null (info , raddr );
219187 return UCS_OK ;
220188 }
221189
222190 inl = uct_ib_mlx5_txwq_wrap_any ((uct_ib_mlx5_txwq_t * )txwq ,
223191 (void * )(raddr + 1 ));
224- if (wqe_size < (header_size + sizeof (* inl ))) {
225- return UCS_ERR_INVALID_PARAM ;
226- }
227-
228192 if (inl -> byte_count & htonl (MLX5_INLINE_SEG )) {
229- return uct_rc_mlx5_op_info_fill_put_short (
230- info , txwq , inl , raddr , callback_data -> data ,
231- sizeof (callback_data -> data ),
232- wqe_size - header_size - sizeof (* inl ));
193+ uct_rc_mlx5_op_info_fill_put_short (info , txwq , inl , raddr ,
194+ callback_data -> data ,
195+ sizeof (callback_data -> data ));
196+
197+ return UCS_OK ;
233198 }
234199
235200 if ((op == NULL ) || (op -> handler == uct_rc_ep_send_op_completion_handler )) {
236- return uct_rc_mlx5_op_info_fill_put_zcopy (
237- info , txwq , op , (const struct mlx5_wqe_data_seg * )inl , raddr ,
238- wqe_size , callback_data );
201+ uct_rc_mlx5_op_info_fill_put_zcopy (info , txwq , op ,
202+ (const struct mlx5_wqe_data_seg * )inl ,
203+ raddr , wqe_size , callback_data );
204+
205+ return UCS_OK ;
239206 }
240207
241208 if ((void * )op -> handler == (void * )ucs_mpool_put ) {
@@ -260,7 +227,6 @@ uct_rc_mlx5_op_info_fill(uct_ep_op_info_t *info, const uct_ib_mlx5_txwq_t *txwq,
260227 uct_rc_mlx5_op_callback_data_t * callback_data )
261228{
262229 * skip_p = 0 ;
263- memset (info , 0 , sizeof (* info ));
264230
265231 switch (uct_ib_mlx5_wqe_opcode (ctrl )) {
266232 case MLX5_OPCODE_RDMA_WRITE :
0 commit comments