@@ -378,6 +378,52 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
378378 return ret ;
379379}
380380
381+ static void copy_query_dev_fields (struct ib_uverbs_file * file ,
382+ struct ib_uverbs_query_device_resp * resp ,
383+ struct ib_device_attr * attr )
384+ {
385+ resp -> fw_ver = attr -> fw_ver ;
386+ resp -> node_guid = file -> device -> ib_dev -> node_guid ;
387+ resp -> sys_image_guid = attr -> sys_image_guid ;
388+ resp -> max_mr_size = attr -> max_mr_size ;
389+ resp -> page_size_cap = attr -> page_size_cap ;
390+ resp -> vendor_id = attr -> vendor_id ;
391+ resp -> vendor_part_id = attr -> vendor_part_id ;
392+ resp -> hw_ver = attr -> hw_ver ;
393+ resp -> max_qp = attr -> max_qp ;
394+ resp -> max_qp_wr = attr -> max_qp_wr ;
395+ resp -> device_cap_flags = attr -> device_cap_flags ;
396+ resp -> max_sge = attr -> max_sge ;
397+ resp -> max_sge_rd = attr -> max_sge_rd ;
398+ resp -> max_cq = attr -> max_cq ;
399+ resp -> max_cqe = attr -> max_cqe ;
400+ resp -> max_mr = attr -> max_mr ;
401+ resp -> max_pd = attr -> max_pd ;
402+ resp -> max_qp_rd_atom = attr -> max_qp_rd_atom ;
403+ resp -> max_ee_rd_atom = attr -> max_ee_rd_atom ;
404+ resp -> max_res_rd_atom = attr -> max_res_rd_atom ;
405+ resp -> max_qp_init_rd_atom = attr -> max_qp_init_rd_atom ;
406+ resp -> max_ee_init_rd_atom = attr -> max_ee_init_rd_atom ;
407+ resp -> atomic_cap = attr -> atomic_cap ;
408+ resp -> max_ee = attr -> max_ee ;
409+ resp -> max_rdd = attr -> max_rdd ;
410+ resp -> max_mw = attr -> max_mw ;
411+ resp -> max_raw_ipv6_qp = attr -> max_raw_ipv6_qp ;
412+ resp -> max_raw_ethy_qp = attr -> max_raw_ethy_qp ;
413+ resp -> max_mcast_grp = attr -> max_mcast_grp ;
414+ resp -> max_mcast_qp_attach = attr -> max_mcast_qp_attach ;
415+ resp -> max_total_mcast_qp_attach = attr -> max_total_mcast_qp_attach ;
416+ resp -> max_ah = attr -> max_ah ;
417+ resp -> max_fmr = attr -> max_fmr ;
418+ resp -> max_map_per_fmr = attr -> max_map_per_fmr ;
419+ resp -> max_srq = attr -> max_srq ;
420+ resp -> max_srq_wr = attr -> max_srq_wr ;
421+ resp -> max_srq_sge = attr -> max_srq_sge ;
422+ resp -> max_pkeys = attr -> max_pkeys ;
423+ resp -> local_ca_ack_delay = attr -> local_ca_ack_delay ;
424+ resp -> phys_port_cnt = file -> device -> ib_dev -> phys_port_cnt ;
425+ }
426+
381427ssize_t ib_uverbs_query_device (struct ib_uverbs_file * file ,
382428 const char __user * buf ,
383429 int in_len , int out_len )
@@ -398,47 +444,7 @@ ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
398444 return ret ;
399445
400446 memset (& resp , 0 , sizeof resp );
401-
402- resp .fw_ver = attr .fw_ver ;
403- resp .node_guid = file -> device -> ib_dev -> node_guid ;
404- resp .sys_image_guid = attr .sys_image_guid ;
405- resp .max_mr_size = attr .max_mr_size ;
406- resp .page_size_cap = attr .page_size_cap ;
407- resp .vendor_id = attr .vendor_id ;
408- resp .vendor_part_id = attr .vendor_part_id ;
409- resp .hw_ver = attr .hw_ver ;
410- resp .max_qp = attr .max_qp ;
411- resp .max_qp_wr = attr .max_qp_wr ;
412- resp .device_cap_flags = attr .device_cap_flags ;
413- resp .max_sge = attr .max_sge ;
414- resp .max_sge_rd = attr .max_sge_rd ;
415- resp .max_cq = attr .max_cq ;
416- resp .max_cqe = attr .max_cqe ;
417- resp .max_mr = attr .max_mr ;
418- resp .max_pd = attr .max_pd ;
419- resp .max_qp_rd_atom = attr .max_qp_rd_atom ;
420- resp .max_ee_rd_atom = attr .max_ee_rd_atom ;
421- resp .max_res_rd_atom = attr .max_res_rd_atom ;
422- resp .max_qp_init_rd_atom = attr .max_qp_init_rd_atom ;
423- resp .max_ee_init_rd_atom = attr .max_ee_init_rd_atom ;
424- resp .atomic_cap = attr .atomic_cap ;
425- resp .max_ee = attr .max_ee ;
426- resp .max_rdd = attr .max_rdd ;
427- resp .max_mw = attr .max_mw ;
428- resp .max_raw_ipv6_qp = attr .max_raw_ipv6_qp ;
429- resp .max_raw_ethy_qp = attr .max_raw_ethy_qp ;
430- resp .max_mcast_grp = attr .max_mcast_grp ;
431- resp .max_mcast_qp_attach = attr .max_mcast_qp_attach ;
432- resp .max_total_mcast_qp_attach = attr .max_total_mcast_qp_attach ;
433- resp .max_ah = attr .max_ah ;
434- resp .max_fmr = attr .max_fmr ;
435- resp .max_map_per_fmr = attr .max_map_per_fmr ;
436- resp .max_srq = attr .max_srq ;
437- resp .max_srq_wr = attr .max_srq_wr ;
438- resp .max_srq_sge = attr .max_srq_sge ;
439- resp .max_pkeys = attr .max_pkeys ;
440- resp .local_ca_ack_delay = attr .local_ca_ack_delay ;
441- resp .phys_port_cnt = file -> device -> ib_dev -> phys_port_cnt ;
447+ copy_query_dev_fields (file , & resp , & attr );
442448
443449 if (copy_to_user ((void __user * ) (unsigned long ) cmd .response ,
444450 & resp , sizeof resp ))
@@ -3253,3 +3259,39 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
32533259
32543260 return ret ? ret : in_len ;
32553261}
3262+
3263+ int ib_uverbs_ex_query_device (struct ib_uverbs_file * file ,
3264+ struct ib_udata * ucore ,
3265+ struct ib_udata * uhw )
3266+ {
3267+ struct ib_uverbs_ex_query_device_resp resp ;
3268+ struct ib_uverbs_ex_query_device cmd ;
3269+ struct ib_device_attr attr ;
3270+ struct ib_device * device ;
3271+ int err ;
3272+
3273+ device = file -> device -> ib_dev ;
3274+ if (ucore -> inlen < sizeof (cmd ))
3275+ return - EINVAL ;
3276+
3277+ err = ib_copy_from_udata (& cmd , ucore , sizeof (cmd ));
3278+ if (err )
3279+ return err ;
3280+
3281+ if (cmd .reserved )
3282+ return - EINVAL ;
3283+
3284+ err = device -> query_device (device , & attr );
3285+ if (err )
3286+ return err ;
3287+
3288+ memset (& resp , 0 , sizeof (resp ));
3289+ copy_query_dev_fields (file , & resp .base , & attr );
3290+ resp .comp_mask = 0 ;
3291+
3292+ err = ib_copy_to_udata (ucore , & resp , sizeof (resp ));
3293+ if (err )
3294+ return err ;
3295+
3296+ return 0 ;
3297+ }
0 commit comments