IB/uverbs: Add CQ moderation capability to query_device
authorYonatan Cohen <yonatanc@mellanox.com>
Mon, 13 Nov 2017 08:51:16 +0000 (10:51 +0200)
committerDoug Ledford <dledford@redhat.com>
Mon, 13 Nov 2017 21:59:22 +0000 (16:59 -0500)
The query_device function can now obtain the maximum values for
cq_max_count and cq_period, needed for CQ moderation.
cq_max_count is a 16 bits number that determines the number
of CQEs to accumulate before generating an event.
cq_period is a 16 bits number that determines the timeout in micro
seconds from the last event generated, upon which a new event will
be generated even if cq_max_count was not reached.

Signed-off-by: Yonatan Cohen <yonatanc@mellanox.com>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/uverbs_cmd.c
include/rdma/ib_verbs.h
include/uapi/rdma/ib_user_verbs.h

index 3c2673cd40908bd7d4e0705d03dc298ed06d6ab7..53143e4b1c50f3a6fbf29ae3e2a45148ad139968 100644 (file)
@@ -3852,6 +3852,15 @@ int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
        resp.tm_caps.max_sge            = attr.tm_caps.max_sge;
        resp.tm_caps.flags              = attr.tm_caps.flags;
        resp.response_length += sizeof(resp.tm_caps);
+
+       if (ucore->outlen < resp.response_length + sizeof(resp.cq_moderation_caps))
+               goto end;
+
+       resp.cq_moderation_caps.max_cq_moderation_count  =
+               attr.cq_caps.max_cq_moderation_count;
+       resp.cq_moderation_caps.max_cq_moderation_period =
+               attr.cq_caps.max_cq_moderation_period;
+       resp.response_length += sizeof(resp.cq_moderation_caps);
 end:
        err = ib_copy_to_udata(ucore, &resp, resp.response_length);
        return err;
index 8e0d3780ce4e008c5a6558baab8630919eafaf67..0b484c023fa9c24f3daf0787dbd52f92e14b2ce0 100644 (file)
@@ -315,6 +315,11 @@ enum ib_cq_attr_mask {
        IB_CQ_MODERATE = 1 << 0,
 };
 
+struct ib_cq_caps {
+       u16     max_cq_moderation_count;
+       u16     max_cq_moderation_period;
+};
+
 struct ib_device_attr {
        u64                     fw_ver;
        __be64                  sys_image_guid;
@@ -365,6 +370,7 @@ struct ib_device_attr {
        u32                     max_wq_type_rq;
        u32                     raw_packet_caps; /* Use ib_raw_packet_caps enum */
        struct ib_tm_caps       tm_caps;
+       struct ib_cq_caps       cq_caps;
 };
 
 enum ib_mtu {
index cfa09d6095d6a22c3caa2532fcc4f80b53f2f332..5186fb12629b802ed94b131f78434e63e65df2ef 100644 (file)
@@ -125,6 +125,12 @@ struct ib_uverbs_comp_event_desc {
        __u64 cq_handle;
 };
 
+struct ib_uverbs_cq_moderation_caps {
+       __u16     max_cq_moderation_count;
+       __u16     max_cq_moderation_period;
+       __u32     reserved;
+};
+
 /*
  * All commands from userspace should start with a __u32 command field
  * followed by __u16 in_words and out_words fields (which give the
@@ -263,6 +269,7 @@ struct ib_uverbs_ex_query_device_resp {
        __u32  max_wq_type_rq;
        __u32 raw_packet_caps;
        struct ib_uverbs_tm_caps tm_caps;
+       struct ib_uverbs_cq_moderation_caps cq_moderation_caps;
 };
 
 struct ib_uverbs_query_port {