diff options
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 1 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 131 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_main.c | 1 | ||||
-rw-r--r-- | include/uapi/rdma/ib_user_verbs.h | 12 |
4 files changed, 104 insertions, 41 deletions
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 643c08a025a5..b716b0815644 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -258,5 +258,6 @@ IB_UVERBS_DECLARE_CMD(close_xrcd); | |||
258 | 258 | ||
259 | IB_UVERBS_DECLARE_EX_CMD(create_flow); | 259 | IB_UVERBS_DECLARE_EX_CMD(create_flow); |
260 | IB_UVERBS_DECLARE_EX_CMD(destroy_flow); | 260 | IB_UVERBS_DECLARE_EX_CMD(destroy_flow); |
261 | IB_UVERBS_DECLARE_EX_CMD(query_device); | ||
261 | 262 | ||
262 | #endif /* UVERBS_H */ | 263 | #endif /* UVERBS_H */ |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index b7943ff16ed3..8f507538c42b 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -400,6 +400,52 @@ err: | |||
400 | return ret; | 400 | return ret; |
401 | } | 401 | } |
402 | 402 | ||
403 | static void copy_query_dev_fields(struct ib_uverbs_file *file, | ||
404 | struct ib_uverbs_query_device_resp *resp, | ||
405 | struct ib_device_attr *attr) | ||
406 | { | ||
407 | resp->fw_ver = attr->fw_ver; | ||
408 | resp->node_guid = file->device->ib_dev->node_guid; | ||
409 | resp->sys_image_guid = attr->sys_image_guid; | ||
410 | resp->max_mr_size = attr->max_mr_size; | ||
411 | resp->page_size_cap = attr->page_size_cap; | ||
412 | resp->vendor_id = attr->vendor_id; | ||
413 | resp->vendor_part_id = attr->vendor_part_id; | ||
414 | resp->hw_ver = attr->hw_ver; | ||
415 | resp->max_qp = attr->max_qp; | ||
416 | resp->max_qp_wr = attr->max_qp_wr; | ||
417 | resp->device_cap_flags = attr->device_cap_flags; | ||
418 | resp->max_sge = attr->max_sge; | ||
419 | resp->max_sge_rd = attr->max_sge_rd; | ||
420 | resp->max_cq = attr->max_cq; | ||
421 | resp->max_cqe = attr->max_cqe; | ||
422 | resp->max_mr = attr->max_mr; | ||
423 | resp->max_pd = attr->max_pd; | ||
424 | resp->max_qp_rd_atom = attr->max_qp_rd_atom; | ||
425 | resp->max_ee_rd_atom = attr->max_ee_rd_atom; | ||
426 | resp->max_res_rd_atom = attr->max_res_rd_atom; | ||
427 | resp->max_qp_init_rd_atom = attr->max_qp_init_rd_atom; | ||
428 | resp->max_ee_init_rd_atom = attr->max_ee_init_rd_atom; | ||
429 | resp->atomic_cap = attr->atomic_cap; | ||
430 | resp->max_ee = attr->max_ee; | ||
431 | resp->max_rdd = attr->max_rdd; | ||
432 | resp->max_mw = attr->max_mw; | ||
433 | resp->max_raw_ipv6_qp = attr->max_raw_ipv6_qp; | ||
434 | resp->max_raw_ethy_qp = attr->max_raw_ethy_qp; | ||
435 | resp->max_mcast_grp = attr->max_mcast_grp; | ||
436 | resp->max_mcast_qp_attach = attr->max_mcast_qp_attach; | ||
437 | resp->max_total_mcast_qp_attach = attr->max_total_mcast_qp_attach; | ||
438 | resp->max_ah = attr->max_ah; | ||
439 | resp->max_fmr = attr->max_fmr; | ||
440 | resp->max_map_per_fmr = attr->max_map_per_fmr; | ||
441 | resp->max_srq = attr->max_srq; | ||
442 | resp->max_srq_wr = attr->max_srq_wr; | ||
443 | resp->max_srq_sge = attr->max_srq_sge; | ||
444 | resp->max_pkeys = attr->max_pkeys; | ||
445 | resp->local_ca_ack_delay = attr->local_ca_ack_delay; | ||
446 | resp->phys_port_cnt = file->device->ib_dev->phys_port_cnt; | ||
447 | } | ||
448 | |||
403 | ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, | 449 | ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, |
404 | const char __user *buf, | 450 | const char __user *buf, |
405 | int in_len, int out_len) | 451 | int in_len, int out_len) |
@@ -420,47 +466,7 @@ ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, | |||
420 | return ret; | 466 | return ret; |
421 | 467 | ||
422 | memset(&resp, 0, sizeof resp); | 468 | memset(&resp, 0, sizeof resp); |
423 | 469 | copy_query_dev_fields(file, &resp, &attr); | |
424 | resp.fw_ver = attr.fw_ver; | ||
425 | resp.node_guid = file->device->ib_dev->node_guid; | ||
426 | resp.sys_image_guid = attr.sys_image_guid; | ||
427 | resp.max_mr_size = attr.max_mr_size; | ||
428 | resp.page_size_cap = attr.page_size_cap; | ||
429 | resp.vendor_id = attr.vendor_id; | ||
430 | resp.vendor_part_id = attr.vendor_part_id; | ||
431 | resp.hw_ver = attr.hw_ver; | ||
432 | resp.max_qp = attr.max_qp; | ||
433 | resp.max_qp_wr = attr.max_qp_wr; | ||
434 | resp.device_cap_flags = attr.device_cap_flags; | ||
435 | resp.max_sge = attr.max_sge; | ||
436 | resp.max_sge_rd = attr.max_sge_rd; | ||
437 | resp.max_cq = attr.max_cq; | ||
438 | resp.max_cqe = attr.max_cqe; | ||
439 | resp.max_mr = attr.max_mr; | ||
440 | resp.max_pd = attr.max_pd; | ||
441 | resp.max_qp_rd_atom = attr.max_qp_rd_atom; | ||
442 | resp.max_ee_rd_atom = attr.max_ee_rd_atom; | ||
443 | resp.max_res_rd_atom = attr.max_res_rd_atom; | ||
444 | resp.max_qp_init_rd_atom = attr.max_qp_init_rd_atom; | ||
445 | resp.max_ee_init_rd_atom = attr.max_ee_init_rd_atom; | ||
446 | resp.atomic_cap = attr.atomic_cap; | ||
447 | resp.max_ee = attr.max_ee; | ||
448 | resp.max_rdd = attr.max_rdd; | ||
449 | resp.max_mw = attr.max_mw; | ||
450 | resp.max_raw_ipv6_qp = attr.max_raw_ipv6_qp; | ||
451 | resp.max_raw_ethy_qp = attr.max_raw_ethy_qp; | ||
452 | resp.max_mcast_grp = attr.max_mcast_grp; | ||
453 | resp.max_mcast_qp_attach = attr.max_mcast_qp_attach; | ||
454 | resp.max_total_mcast_qp_attach = attr.max_total_mcast_qp_attach; | ||
455 | resp.max_ah = attr.max_ah; | ||
456 | resp.max_fmr = attr.max_fmr; | ||
457 | resp.max_map_per_fmr = attr.max_map_per_fmr; | ||
458 | resp.max_srq = attr.max_srq; | ||
459 | resp.max_srq_wr = attr.max_srq_wr; | ||
460 | resp.max_srq_sge = attr.max_srq_sge; | ||
461 | resp.max_pkeys = attr.max_pkeys; | ||
462 | resp.local_ca_ack_delay = attr.local_ca_ack_delay; | ||
463 | resp.phys_port_cnt = file->device->ib_dev->phys_port_cnt; | ||
464 | 470 | ||
465 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 471 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
466 | &resp, sizeof resp)) | 472 | &resp, sizeof resp)) |
@@ -3287,3 +3293,46 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
3287 | 3293 | ||
3288 | return ret ? ret : in_len; | 3294 | return ret ? ret : in_len; |
3289 | } | 3295 | } |
3296 | |||
3297 | int ib_uverbs_ex_query_device(struct ib_uverbs_file *file, | ||
3298 | struct ib_udata *ucore, | ||
3299 | struct ib_udata *uhw) | ||
3300 | { | ||
3301 | struct ib_uverbs_ex_query_device_resp resp; | ||
3302 | struct ib_uverbs_ex_query_device cmd; | ||
3303 | struct ib_device_attr attr; | ||
3304 | struct ib_device *device; | ||
3305 | int err; | ||
3306 | |||
3307 | device = file->device->ib_dev; | ||
3308 | if (ucore->inlen < sizeof(cmd)) | ||
3309 | return -EINVAL; | ||
3310 | |||
3311 | err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); | ||
3312 | if (err) | ||
3313 | return err; | ||
3314 | |||
3315 | if (cmd.comp_mask) | ||
3316 | return -EINVAL; | ||
3317 | |||
3318 | if (cmd.reserved) | ||
3319 | return -EINVAL; | ||
3320 | |||
3321 | resp.response_length = sizeof(resp); | ||
3322 | |||
3323 | if (ucore->outlen < resp.response_length) | ||
3324 | return -ENOSPC; | ||
3325 | |||
3326 | err = device->query_device(device, &attr); | ||
3327 | if (err) | ||
3328 | return err; | ||
3329 | |||
3330 | copy_query_dev_fields(file, &resp.base, &attr); | ||
3331 | resp.comp_mask = 0; | ||
3332 | |||
3333 | err = ib_copy_to_udata(ucore, &resp, resp.response_length); | ||
3334 | if (err) | ||
3335 | return err; | ||
3336 | |||
3337 | return 0; | ||
3338 | } | ||
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 5db1a8cc388d..259dcc7779f5 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -123,6 +123,7 @@ static int (*uverbs_ex_cmd_table[])(struct ib_uverbs_file *file, | |||
123 | struct ib_udata *uhw) = { | 123 | struct ib_udata *uhw) = { |
124 | [IB_USER_VERBS_EX_CMD_CREATE_FLOW] = ib_uverbs_ex_create_flow, | 124 | [IB_USER_VERBS_EX_CMD_CREATE_FLOW] = ib_uverbs_ex_create_flow, |
125 | [IB_USER_VERBS_EX_CMD_DESTROY_FLOW] = ib_uverbs_ex_destroy_flow, | 125 | [IB_USER_VERBS_EX_CMD_DESTROY_FLOW] = ib_uverbs_ex_destroy_flow, |
126 | [IB_USER_VERBS_EX_CMD_QUERY_DEVICE] = ib_uverbs_ex_query_device, | ||
126 | }; | 127 | }; |
127 | 128 | ||
128 | static void ib_uverbs_add_one(struct ib_device *device); | 129 | static void ib_uverbs_add_one(struct ib_device *device); |
diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 867cc5084afb..f0f799afd856 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h | |||
@@ -90,6 +90,7 @@ enum { | |||
90 | }; | 90 | }; |
91 | 91 | ||
92 | enum { | 92 | enum { |
93 | IB_USER_VERBS_EX_CMD_QUERY_DEVICE = IB_USER_VERBS_CMD_QUERY_DEVICE, | ||
93 | IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD, | 94 | IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD, |
94 | IB_USER_VERBS_EX_CMD_DESTROY_FLOW, | 95 | IB_USER_VERBS_EX_CMD_DESTROY_FLOW, |
95 | }; | 96 | }; |
@@ -201,6 +202,17 @@ struct ib_uverbs_query_device_resp { | |||
201 | __u8 reserved[4]; | 202 | __u8 reserved[4]; |
202 | }; | 203 | }; |
203 | 204 | ||
205 | struct ib_uverbs_ex_query_device { | ||
206 | __u32 comp_mask; | ||
207 | __u32 reserved; | ||
208 | }; | ||
209 | |||
210 | struct ib_uverbs_ex_query_device_resp { | ||
211 | struct ib_uverbs_query_device_resp base; | ||
212 | __u32 comp_mask; | ||
213 | __u32 response_length; | ||
214 | }; | ||
215 | |||
204 | struct ib_uverbs_query_port { | 216 | struct ib_uverbs_query_port { |
205 | __u64 response; | 217 | __u64 response; |
206 | __u8 port_num; | 218 | __u8 port_num; |