IB/mlx5: Report mlx5 packet pacing capabilities when querying device
authorBodong Wang <bodong@mellanox.com>
Thu, 1 Dec 2016 11:43:13 +0000 (13:43 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 13 Dec 2016 18:39:50 +0000 (13:39 -0500)
Enable mlx5 based hardware to report packet pacing capabilities
from kernel to user space. Packet pacing allows to limit the rate to any
number between the maximum and minimum, based on user settings.

The capabilities are exposed to user space through query_device by uhw.
The following capabilities are reported:

1. The maximum and minimum rate limit in kbps supported by packet pacing.
2. Bitmap showing which QP types are supported by packet pacing operation.

Signed-off-by: Bodong Wang <bodong@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx5/main.c
include/uapi/rdma/mlx5-abi.h

index 8b013f8..6c19400 100644 (file)
@@ -693,6 +693,19 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
                resp.response_length += sizeof(resp.cqe_comp_caps);
        }
 
+       if (field_avail(typeof(resp), packet_pacing_caps, uhw->outlen)) {
+               if (MLX5_CAP_QOS(mdev, packet_pacing) &&
+                   MLX5_CAP_GEN(mdev, qos)) {
+                       resp.packet_pacing_caps.qp_rate_limit_max =
+                               MLX5_CAP_QOS(mdev, packet_pacing_max_rate);
+                       resp.packet_pacing_caps.qp_rate_limit_min =
+                               MLX5_CAP_QOS(mdev, packet_pacing_min_rate);
+                       resp.packet_pacing_caps.supported_qpts |=
+                               1 << IB_QPT_RAW_PACKET;
+               }
+               resp.response_length += sizeof(resp.packet_pacing_caps);
+       }
+
        if (uhw->outlen) {
                err = ib_copy_to_udata(uhw, &resp, resp.response_length);
 
index 3ebf3db..fae6cda 100644 (file)
@@ -136,12 +136,25 @@ struct mlx5_ib_cqe_comp_caps {
        __u32 supported_format; /* enum mlx5_ib_cqe_comp_res_format */
 };
 
+struct mlx5_packet_pacing_caps {
+       __u32 qp_rate_limit_min;
+       __u32 qp_rate_limit_max; /* In kpbs */
+
+       /* Corresponding bit will be set if qp type from
+        * 'enum ib_qp_type' is supported, e.g.
+        * supported_qpts |= 1 << IB_QPT_RAW_PACKET
+        */
+       __u32 supported_qpts;
+       __u32 reserved;
+};
+
 struct mlx5_ib_query_device_resp {
        __u32   comp_mask;
        __u32   response_length;
        struct  mlx5_ib_tso_caps tso_caps;
        struct  mlx5_ib_rss_caps rss_caps;
        struct  mlx5_ib_cqe_comp_caps cqe_comp_caps;
+       struct  mlx5_packet_pacing_caps packet_pacing_caps;
        __u32   mlx5_ib_support_multi_pkt_send_wqes;
        __u32   reserved;
 };