net/mlx5e: Add helper to get the RQ WQE counter
authorAya Levin <ayal@mellanox.com>
Thu, 30 Apr 2020 11:41:13 +0000 (14:41 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 3 Jul 2020 04:05:18 +0000 (21:05 -0700)
Add a helper which retrieves the RQ's WQE counter. Use this helper in
the RX reporter diagnose callback.

$ devlink health diagnose pci/0000:00:0b.0 reporter rx
Common config:
  RQ:
     type: 2 stride size: 2048 size: 8
     CQ:
      stride size: 64 size: 1024
RQs:
   channel ix: 0 rqn: 2113 HW state: 1 SW state: 5 WQE counter: 7 posted WQEs: 7 cc: 7 ICOSQ HW state: 1
   CQ:
    cqn: 1032 HW status: 0
   channel ix: 1 rqn: 2118 HW state: 1 SW state: 5 WQE counter: 7 posted WQEs: 7 cc: 7 ICOSQ HW state: 1
   CQ:
    cqn: 1036 HW status: 0

Signed-off-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
drivers/net/ethernet/mellanox/mlx5/core/wq.h

index f0e639e..bec8042 100644 (file)
@@ -183,6 +183,7 @@ static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
        struct mlx5e_priv *priv = rq->channel->priv;
        struct mlx5e_icosq *icosq;
        u8 icosq_hw_state;
+       u16 wqe_counter;
        int wqes_sz;
        u8 hw_state;
        u16 wq_head;
@@ -199,6 +200,7 @@ static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
 
        wqes_sz = mlx5e_rqwq_get_cur_sz(rq);
        wq_head = mlx5e_rqwq_get_head(rq);
+       wqe_counter = mlx5e_rqwq_get_wqe_counter(rq);
 
        err = devlink_fmsg_obj_nest_start(fmsg);
        if (err)
@@ -220,6 +222,10 @@ static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
        if (err)
                return err;
 
+       err = devlink_fmsg_u32_pair_put(fmsg, "WQE counter", wqe_counter);
+       if (err)
+               return err;
+
        err = devlink_fmsg_u32_pair_put(fmsg, "posted WQEs", wqes_sz);
        if (err)
                return err;
index d787e8f..cf425a6 100644 (file)
@@ -314,6 +314,16 @@ static inline u16 mlx5e_rqwq_get_head(struct mlx5e_rq *rq)
        }
 }
 
+static inline u16 mlx5e_rqwq_get_wqe_counter(struct mlx5e_rq *rq)
+{
+       switch (rq->wq_type) {
+       case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
+               return mlx5_wq_ll_get_counter(&rq->mpwqe.wq);
+       default:
+               return mlx5_wq_cyc_get_counter(&rq->wqe.wq);
+       }
+}
+
 /* SW parser related functions */
 
 struct mlx5e_swp_spec {
index 27dece3..e5c4dcd 100644 (file)
@@ -172,6 +172,11 @@ static inline int mlx5_wq_cyc_cc_bigger(u16 cc1, u16 cc2)
        return !equal && !smaller;
 }
 
+static inline u16 mlx5_wq_cyc_get_counter(struct mlx5_wq_cyc *wq)
+{
+       return wq->wqe_ctr;
+}
+
 static inline u32 mlx5_cqwq_get_size(struct mlx5_cqwq *wq)
 {
        return wq->fbc.sz_m1 + 1;
@@ -294,4 +299,10 @@ static inline u16 mlx5_wq_ll_get_head(struct mlx5_wq_ll *wq)
 {
        return wq->head;
 }
+
+static inline u16 mlx5_wq_ll_get_counter(struct mlx5_wq_ll *wq)
+{
+       return wq->wqe_ctr;
+}
+
 #endif /* __MLX5_WQ_H__ */