RDMA/efa: Add messages and RDMA read work requests HW stats
authorDaniel Kranzdorf <dkkranzd@amazon.com>
Tue, 15 Sep 2020 14:14:49 +0000 (17:14 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 22 Sep 2020 23:21:11 +0000 (20:21 -0300)
Add separate stats types for send messages and RDMA read work requests.

Link: https://lore.kernel.org/r/20200915141449.8428-3-galpress@amazon.com
Signed-off-by: Daniel Kranzdorf <dkkranzd@amazon.com>
Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/efa/efa_admin_cmds_defs.h
drivers/infiniband/hw/efa/efa_com_cmd.c
drivers/infiniband/hw/efa/efa_com_cmd.h
drivers/infiniband/hw/efa/efa_verbs.c

index d9676ca..b199e4a 100644 (file)
@@ -61,6 +61,8 @@ enum efa_admin_qp_state {
 
 enum efa_admin_get_stats_type {
        EFA_ADMIN_GET_STATS_TYPE_BASIC              = 0,
+       EFA_ADMIN_GET_STATS_TYPE_MESSAGES           = 1,
+       EFA_ADMIN_GET_STATS_TYPE_RDMA_READ          = 2,
 };
 
 enum efa_admin_get_stats_scope {
@@ -528,10 +530,36 @@ struct efa_admin_basic_stats {
        u64 rx_drops;
 };
 
+struct efa_admin_messages_stats {
+       u64 send_bytes;
+
+       u64 send_wrs;
+
+       u64 recv_bytes;
+
+       u64 recv_wrs;
+};
+
+struct efa_admin_rdma_read_stats {
+       u64 read_wrs;
+
+       u64 read_bytes;
+
+       u64 read_wr_err;
+
+       u64 read_resp_bytes;
+};
+
 struct efa_admin_acq_get_stats_resp {
        struct efa_admin_acq_common_desc acq_common_desc;
 
-       struct efa_admin_basic_stats basic_stats;
+       union {
+               struct efa_admin_basic_stats basic_stats;
+
+               struct efa_admin_messages_stats messages_stats;
+
+               struct efa_admin_rdma_read_stats rdma_read_stats;
+       } u;
 };
 
 struct efa_admin_get_set_feature_common_desc {
index f24634c..f752ef6 100644 (file)
@@ -752,11 +752,27 @@ int efa_com_get_stats(struct efa_com_dev *edev,
                return err;
        }
 
-       result->basic_stats.tx_bytes = resp.basic_stats.tx_bytes;
-       result->basic_stats.tx_pkts = resp.basic_stats.tx_pkts;
-       result->basic_stats.rx_bytes = resp.basic_stats.rx_bytes;
-       result->basic_stats.rx_pkts = resp.basic_stats.rx_pkts;
-       result->basic_stats.rx_drops = resp.basic_stats.rx_drops;
+       switch (cmd.type) {
+       case EFA_ADMIN_GET_STATS_TYPE_BASIC:
+               result->basic_stats.tx_bytes = resp.u.basic_stats.tx_bytes;
+               result->basic_stats.tx_pkts = resp.u.basic_stats.tx_pkts;
+               result->basic_stats.rx_bytes = resp.u.basic_stats.rx_bytes;
+               result->basic_stats.rx_pkts = resp.u.basic_stats.rx_pkts;
+               result->basic_stats.rx_drops = resp.u.basic_stats.rx_drops;
+               break;
+       case EFA_ADMIN_GET_STATS_TYPE_MESSAGES:
+               result->messages_stats.send_bytes = resp.u.messages_stats.send_bytes;
+               result->messages_stats.send_wrs = resp.u.messages_stats.send_wrs;
+               result->messages_stats.recv_bytes = resp.u.messages_stats.recv_bytes;
+               result->messages_stats.recv_wrs = resp.u.messages_stats.recv_wrs;
+               break;
+       case EFA_ADMIN_GET_STATS_TYPE_RDMA_READ:
+               result->rdma_read_stats.read_wrs = resp.u.rdma_read_stats.read_wrs;
+               result->rdma_read_stats.read_bytes = resp.u.rdma_read_stats.read_bytes;
+               result->rdma_read_stats.read_wr_err = resp.u.rdma_read_stats.read_wr_err;
+               result->rdma_read_stats.read_resp_bytes = resp.u.rdma_read_stats.read_resp_bytes;
+               break;
+       }
 
        return 0;
 }
index 9ebee12..eea4ebf 100644 (file)
@@ -240,8 +240,24 @@ struct efa_com_basic_stats {
        u64 rx_drops;
 };
 
+struct efa_com_messages_stats {
+       u64 send_bytes;
+       u64 send_wrs;
+       u64 recv_bytes;
+       u64 recv_wrs;
+};
+
+struct efa_com_rdma_read_stats {
+       u64 read_wrs;
+       u64 read_bytes;
+       u64 read_wr_err;
+       u64 read_resp_bytes;
+};
+
 union efa_com_get_stats_result {
        struct efa_com_basic_stats basic_stats;
+       struct efa_com_messages_stats messages_stats;
+       struct efa_com_rdma_read_stats rdma_read_stats;
 };
 
 void efa_com_set_dma_addr(dma_addr_t addr, u32 *addr_high, u32 *addr_low);
index c0c4eee..9ff2a83 100644 (file)
@@ -36,6 +36,14 @@ struct efa_user_mmap_entry {
        op(EFA_RX_BYTES, "rx_bytes") \
        op(EFA_RX_PKTS, "rx_pkts") \
        op(EFA_RX_DROPS, "rx_drops") \
+       op(EFA_SEND_BYTES, "send_bytes") \
+       op(EFA_SEND_WRS, "send_wrs") \
+       op(EFA_RECV_BYTES, "recv_bytes") \
+       op(EFA_RECV_WRS, "recv_wrs") \
+       op(EFA_RDMA_READ_WRS, "rdma_read_wrs") \
+       op(EFA_RDMA_READ_BYTES, "rdma_read_bytes") \
+       op(EFA_RDMA_READ_WR_ERR, "rdma_read_wr_err") \
+       op(EFA_RDMA_READ_RESP_BYTES, "rdma_read_resp_bytes") \
        op(EFA_SUBMITTED_CMDS, "submitted_cmds") \
        op(EFA_COMPLETED_CMDS, "completed_cmds") \
        op(EFA_CMDS_ERR, "cmds_err") \
@@ -1903,13 +1911,15 @@ int efa_get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
        struct efa_com_get_stats_params params = {};
        union efa_com_get_stats_result result;
        struct efa_dev *dev = to_edev(ibdev);
+       struct efa_com_rdma_read_stats *rrs;
+       struct efa_com_messages_stats *ms;
        struct efa_com_basic_stats *bs;
        struct efa_com_stats_admin *as;
        struct efa_stats *s;
        int err;
 
-       params.type = EFA_ADMIN_GET_STATS_TYPE_BASIC;
        params.scope = EFA_ADMIN_GET_STATS_SCOPE_ALL;
+       params.type = EFA_ADMIN_GET_STATS_TYPE_BASIC;
 
        err = efa_com_get_stats(&dev->edev, &params, &result);
        if (err)
@@ -1922,6 +1932,28 @@ int efa_get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
        stats->value[EFA_RX_PKTS] = bs->rx_pkts;
        stats->value[EFA_RX_DROPS] = bs->rx_drops;
 
+       params.type = EFA_ADMIN_GET_STATS_TYPE_MESSAGES;
+       err = efa_com_get_stats(&dev->edev, &params, &result);
+       if (err)
+               return err;
+
+       ms = &result.messages_stats;
+       stats->value[EFA_SEND_BYTES] = ms->send_bytes;
+       stats->value[EFA_SEND_WRS] = ms->send_wrs;
+       stats->value[EFA_RECV_BYTES] = ms->recv_bytes;
+       stats->value[EFA_RECV_WRS] = ms->recv_wrs;
+
+       params.type = EFA_ADMIN_GET_STATS_TYPE_RDMA_READ;
+       err = efa_com_get_stats(&dev->edev, &params, &result);
+       if (err)
+               return err;
+
+       rrs = &result.rdma_read_stats;
+       stats->value[EFA_RDMA_READ_WRS] = rrs->read_wrs;
+       stats->value[EFA_RDMA_READ_BYTES] = rrs->read_bytes;
+       stats->value[EFA_RDMA_READ_WR_ERR] = rrs->read_wr_err;
+       stats->value[EFA_RDMA_READ_RESP_BYTES] = rrs->read_resp_bytes;
+
        as = &dev->edev.aq.stats;
        stats->value[EFA_SUBMITTED_CMDS] = atomic64_read(&as->submitted_cmd);
        stats->value[EFA_COMPLETED_CMDS] = atomic64_read(&as->completed_cmd);