@@ -158,49 +158,51 @@ int ibv_cmd_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset, size_t length,
158158}
159159
160160int ibv_cmd_reg_mr_ex (struct ibv_pd * pd , struct verbs_mr * vmr ,
161- struct ibv_reg_mr_in * in )
161+ struct ibv_mr_init_attr * mr_init_attr )
162162{
163163 DECLARE_COMMAND_BUFFER (cmdb , UVERBS_OBJECT_MR ,
164164 UVERBS_METHOD_REG_MR , 11 );
165- bool fd_based = (in -> comp_mask & IBV_REG_MR_MASK_FD );
165+ bool fd_based = (mr_init_attr -> comp_mask & IBV_REG_MR_MASK_FD );
166166 struct ib_uverbs_attr * handle ;
167- uint64_t length = in -> length ;
167+ uint64_t length = mr_init_attr -> length ;
168168 uint32_t lkey , rkey ;
169169 int ret ;
170170
171171 if (fd_based ) {
172- if (!(in -> comp_mask & IBV_REG_MR_MASK_FD_OFFSET ) ||
173- (in -> comp_mask & IBV_REG_MR_MASK_ADDR )) {
172+ if (!(mr_init_attr -> comp_mask & IBV_REG_MR_MASK_FD_OFFSET ) ||
173+ (mr_init_attr -> comp_mask & IBV_REG_MR_MASK_ADDR )) {
174174 errno = EINVAL ;
175175 return EINVAL ;
176176 }
177- fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_FD_OFFSET , in -> fd_offset );
177+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_FD_OFFSET ,
178+ mr_init_attr -> fd_offset );
178179 fill_attr_in_fd (cmdb , UVERBS_ATTR_REG_MR_FD ,
179- in -> fd );
180+ mr_init_attr -> fd );
180181 } else {
181- if ((in -> comp_mask & IBV_REG_MR_MASK_FD_OFFSET ) ||
182- !(in -> comp_mask & IBV_REG_MR_MASK_ADDR )) {
182+ if ((mr_init_attr -> comp_mask & IBV_REG_MR_MASK_FD_OFFSET ) ||
183+ !(mr_init_attr -> comp_mask & IBV_REG_MR_MASK_ADDR )) {
183184 errno = EINVAL ;
184185 return EINVAL ;
185186 }
186187
187- fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_ADDR , (uintptr_t )in -> addr );
188- if (in -> access & IBV_ACCESS_ON_DEMAND ) {
189- if (in -> length == SIZE_MAX && in -> addr ) {
188+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_ADDR ,
189+ (uintptr_t ) mr_init_attr -> addr );
190+ if (mr_init_attr -> access & IBV_ACCESS_ON_DEMAND ) {
191+ if (mr_init_attr -> length == SIZE_MAX && mr_init_attr -> addr ) {
190192 errno = EINVAL ;
191193 return EINVAL ;
192194 }
193- if (in -> length == SIZE_MAX )
195+ if (mr_init_attr -> length == SIZE_MAX )
194196 length = UINT64_MAX ;
195197 }
196198 }
197199
198- if (in -> comp_mask & IBV_REG_MR_MASK_IOVA ) {
199- fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_IOVA , in -> iova );
200+ if (mr_init_attr -> comp_mask & IBV_REG_MR_MASK_IOVA ) {
201+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_IOVA , mr_init_attr -> iova );
200202 } else {
201203 if (!fd_based ) {
202204 fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_IOVA ,
203- (uintptr_t )in -> addr );
205+ (uintptr_t ) mr_init_attr -> addr );
204206 } else {
205207 /* iova is a must from kernel point of view */
206208 errno = EINVAL ;
@@ -213,11 +215,12 @@ int ibv_cmd_reg_mr_ex(struct ibv_pd *pd, struct verbs_mr *vmr,
213215 fill_attr_out_ptr (cmdb , UVERBS_ATTR_REG_MR_RESP_RKEY , & rkey );
214216 fill_attr_in_obj (cmdb , UVERBS_ATTR_REG_MR_PD_HANDLE , pd -> handle );
215217 fill_attr_in_uint64 (cmdb , UVERBS_ATTR_REG_MR_LENGTH , length );
216- fill_attr_in_uint32 (cmdb , UVERBS_ATTR_REG_MR_ACCESS_FLAGS , in -> access );
218+ fill_attr_in_uint32 (cmdb , UVERBS_ATTR_REG_MR_ACCESS_FLAGS ,
219+ mr_init_attr -> access );
217220
218- if (in -> comp_mask & IBV_REG_MR_MASK_DMAH )
221+ if (mr_init_attr -> comp_mask & IBV_REG_MR_MASK_DMAH )
219222 fill_attr_in_obj (cmdb , UVERBS_ATTR_REG_MR_DMA_HANDLE ,
220- verbs_get_dmah (in -> dmah )-> handle );
223+ verbs_get_dmah (mr_init_attr -> dmah )-> handle );
221224
222225 ret = execute_ioctl (pd -> context , cmdb );
223226 if (ret )
0 commit comments