3535
3636static int ibv_icmd_create_cq (struct ibv_context * context , int cqe ,
3737 struct ibv_comp_channel * channel , int comp_vector ,
38+ struct verbs_create_cq_prov_attr * prov_attr ,
3839 uint32_t flags , struct ibv_cq * cq ,
3940 struct ibv_command_buffer * link ,
4041 uint32_t cmd_flags )
@@ -43,11 +44,18 @@ static int ibv_icmd_create_cq(struct ibv_context *context, int cqe,
4344 struct verbs_ex_private * priv = get_priv (context );
4445 struct ib_uverbs_attr * handle ;
4546 struct ib_uverbs_attr * async_fd_attr ;
47+ bool prov_atts_expected ;
4648 uint32_t resp_cqe ;
4749 int ret ;
4850
4951 cq -> context = context ;
5052
53+ prov_atts_expected = cmd_flags & (CREATE_CQ_CMD_FLAGS_WITH_MEM_VA |
54+ CREATE_CQ_CMD_FLAGS_WITH_MEM_DMABUF );
55+
56+ if (prov_atts_expected && !prov_attr )
57+ return EINVAL ;
58+
5159 handle = fill_attr_out_obj (cmdb , UVERBS_ATTR_CREATE_CQ_HANDLE );
5260 fill_attr_out_ptr (cmdb , UVERBS_ATTR_CREATE_CQ_RESP_CQE , & resp_cqe );
5361
@@ -63,6 +71,22 @@ static int ibv_icmd_create_cq(struct ibv_context *context, int cqe,
6371 /* Prevent fallback to the 'write' mode if kernel doesn't support it */
6472 attr_optional (async_fd_attr );
6573
74+ if (cmd_flags & CREATE_CQ_CMD_FLAGS_WITH_MEM_VA ) {
75+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_CREATE_CQ_BUFFER_VA ,
76+ (uintptr_t )prov_attr -> buffer .ptr );
77+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_CREATE_CQ_BUFFER_LENGTH ,
78+ prov_attr -> buffer .length );
79+ fallback_require_ioctl (cmdb );
80+ } else if (cmd_flags & CREATE_CQ_CMD_FLAGS_WITH_MEM_DMABUF ) {
81+ fill_attr_in_fd (cmdb , UVERBS_ATTR_CREATE_CQ_BUFFER_FD ,
82+ prov_attr -> buffer .dmabuf .fd );
83+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_CREATE_CQ_BUFFER_OFFSET ,
84+ prov_attr -> buffer .dmabuf .offset );
85+ fill_attr_in_uint64 (cmdb , UVERBS_ATTR_CREATE_CQ_BUFFER_LENGTH ,
86+ prov_attr -> buffer .length );
87+ fallback_require_ioctl (cmdb );
88+ }
89+
6690 if (flags ) {
6791 if ((flags & ~IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION ) ||
6892 (!(cmd_flags & CREATE_CQ_CMD_FLAGS_TS_IGNORED_EX )))
@@ -129,6 +153,7 @@ static int ibv_icmd_create_cq(struct ibv_context *context, int cqe,
129153
130154static int ibv_icmd_create_cq_ex (struct ibv_context * context ,
131155 const struct ibv_cq_init_attr_ex * cq_attr ,
156+ struct verbs_create_cq_prov_attr * prov_attr ,
132157 struct verbs_cq * cq ,
133158 struct ibv_command_buffer * cmdb ,
134159 uint32_t cmd_flags )
@@ -149,7 +174,7 @@ static int ibv_icmd_create_cq_ex(struct ibv_context *context,
149174 flags |= IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN ;
150175
151176 return ibv_icmd_create_cq (context , cq_attr -> cqe , cq_attr -> channel ,
152- cq_attr -> comp_vector , flags ,
177+ cq_attr -> comp_vector , prov_attr , flags ,
153178 & cq -> cq , cmdb , cmd_flags );
154179}
155180
@@ -163,12 +188,13 @@ int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
163188 UVERBS_METHOD_CQ_CREATE , cmd , cmd_size , resp ,
164189 resp_size );
165190
166- return ibv_icmd_create_cq (context , cqe , channel , comp_vector , 0 , cq ,
191+ return ibv_icmd_create_cq (context , cqe , channel , comp_vector , NULL , 0 , cq ,
167192 cmdb , 0 );
168193}
169194
170195int ibv_cmd_create_cq_ex (struct ibv_context * context ,
171196 const struct ibv_cq_init_attr_ex * cq_attr ,
197+ struct verbs_create_cq_prov_attr * prov_attr ,
172198 struct verbs_cq * cq ,
173199 struct ibv_create_cq_ex * cmd ,
174200 size_t cmd_size ,
@@ -180,11 +206,12 @@ int ibv_cmd_create_cq_ex(struct ibv_context *context,
180206 UVERBS_METHOD_CQ_CREATE , cmd , cmd_size , resp ,
181207 resp_size );
182208
183- return ibv_icmd_create_cq_ex (context , cq_attr , cq , cmdb , cmd_flags );
209+ return ibv_icmd_create_cq_ex (context , cq_attr , prov_attr , cq , cmdb , cmd_flags );
184210}
185211
186212int ibv_cmd_create_cq_ex2 (struct ibv_context * context ,
187213 const struct ibv_cq_init_attr_ex * cq_attr ,
214+ struct verbs_create_cq_prov_attr * prov_attr ,
188215 struct verbs_cq * cq ,
189216 struct ibv_create_cq_ex * cmd ,
190217 size_t cmd_size ,
@@ -197,7 +224,7 @@ int ibv_cmd_create_cq_ex2(struct ibv_context *context,
197224 UVERBS_METHOD_CQ_CREATE ,
198225 driver , cmd , cmd_size , resp , resp_size );
199226
200- return ibv_icmd_create_cq_ex (context , cq_attr , cq , cmdb , cmd_flags );
227+ return ibv_icmd_create_cq_ex (context , cq_attr , prov_attr , cq , cmdb , cmd_flags );
201228}
202229
203230int ibv_cmd_destroy_cq (struct ibv_cq * cq )
0 commit comments