Commit f4056bfd authored by Haggai Eran's avatar Haggai Eran Committed by Roland Dreier

IB/core: Add on demand paging caps to ib_uverbs_ex_query_device

Add on-demand paging capabilities reporting to the extended query device verb.

Yann Droneaud writes:

    Note: as offsetof() is used to retrieve the size of the lower chunk
    of the response, beware that it only works if the upper chunk
    is right after, without any implicit padding. And, as the size of
    the latter chunk is added to the base size, implicit padding at the
    end of the structure is not taken in account. Both point must be
    taken in account when extending the uverbs functionalities.
Signed-off-by: default avatarHaggai Eran <haggaie@mellanox.com>
Reviewed-by: default avatarYann Droneaud <ydroneaud@opteya.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 02d1aa7a
...@@ -3318,7 +3318,7 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file, ...@@ -3318,7 +3318,7 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
if (cmd.reserved) if (cmd.reserved)
return -EINVAL; return -EINVAL;
resp.response_length = sizeof(resp); resp.response_length = offsetof(typeof(resp), odp_caps);
if (ucore->outlen < resp.response_length) if (ucore->outlen < resp.response_length)
return -ENOSPC; return -ENOSPC;
...@@ -3330,6 +3330,24 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file, ...@@ -3330,6 +3330,24 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
copy_query_dev_fields(file, &resp.base, &attr); copy_query_dev_fields(file, &resp.base, &attr);
resp.comp_mask = 0; resp.comp_mask = 0;
if (ucore->outlen < resp.response_length + sizeof(resp.odp_caps))
goto end;
#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
resp.odp_caps.general_caps = attr.odp_caps.general_caps;
resp.odp_caps.per_transport_caps.rc_odp_caps =
attr.odp_caps.per_transport_caps.rc_odp_caps;
resp.odp_caps.per_transport_caps.uc_odp_caps =
attr.odp_caps.per_transport_caps.uc_odp_caps;
resp.odp_caps.per_transport_caps.ud_odp_caps =
attr.odp_caps.per_transport_caps.ud_odp_caps;
resp.odp_caps.reserved = 0;
#else
memset(&resp.odp_caps, 0, sizeof(resp.odp_caps));
#endif
resp.response_length += sizeof(resp.odp_caps);
end:
err = ib_copy_to_udata(ucore, &resp, resp.response_length); err = ib_copy_to_udata(ucore, &resp, resp.response_length);
if (err) if (err)
return err; return err;
......
...@@ -207,10 +207,21 @@ struct ib_uverbs_ex_query_device { ...@@ -207,10 +207,21 @@ struct ib_uverbs_ex_query_device {
__u32 reserved; __u32 reserved;
}; };
struct ib_uverbs_odp_caps {
__u64 general_caps;
struct {
__u32 rc_odp_caps;
__u32 uc_odp_caps;
__u32 ud_odp_caps;
} per_transport_caps;
__u32 reserved;
};
struct ib_uverbs_ex_query_device_resp { struct ib_uverbs_ex_query_device_resp {
struct ib_uverbs_query_device_resp base; struct ib_uverbs_query_device_resp base;
__u32 comp_mask; __u32 comp_mask;
__u32 response_length; __u32 response_length;
struct ib_uverbs_odp_caps odp_caps;
}; };
struct ib_uverbs_query_port { struct ib_uverbs_query_port {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment