]> git.baikalelectronics.ru Git - kernel.git/commitdiff
IB/hfi1: Convert qp_stats debugfs interface to use new iterator API
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Mon, 28 Aug 2017 18:23:58 +0000 (11:23 -0700)
committerDoug Ledford <dledford@redhat.com>
Mon, 28 Aug 2017 23:12:30 +0000 (19:12 -0400)
Continue moving copy/paste code into rdmavt.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/debugfs.c
drivers/infiniband/hw/hfi1/qp.c
drivers/infiniband/hw/hfi1/qp.h

index c6a472f01025c9053088aae3239ba13048d496e0..36ae1fd86502d0bc33f46e4e8ea600675a3e4ef3 100644 (file)
@@ -1,4 +1,3 @@
-#ifdef CONFIG_DEBUG_FS
 /*
  * Copyright(c) 2015-2017 Intel Corporation.
  *
@@ -267,10 +266,10 @@ DEBUGFS_FILE_OPS(ctx_stats);
 static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos)
        __acquires(RCU)
 {
-       struct qp_iter *iter;
+       struct rvt_qp_iter *iter;
        loff_t n = *pos;
 
-       iter = qp_iter_init(s->private);
+       iter = rvt_qp_iter_init(s->private, 0, NULL);
 
        /* stop calls rcu_read_unlock */
        rcu_read_lock();
@@ -279,7 +278,7 @@ static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos)
                return NULL;
 
        do {
-               if (qp_iter_next(iter)) {
+               if (rvt_qp_iter_next(iter)) {
                        kfree(iter);
                        return NULL;
                }
@@ -292,11 +291,11 @@ static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr,
                                loff_t *pos)
        __must_hold(RCU)
 {
-       struct qp_iter *iter = iter_ptr;
+       struct rvt_qp_iter *iter = iter_ptr;
 
        (*pos)++;
 
-       if (qp_iter_next(iter)) {
+       if (rvt_qp_iter_next(iter)) {
                kfree(iter);
                return NULL;
        }
@@ -312,7 +311,7 @@ static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr)
 
 static int _qp_stats_seq_show(struct seq_file *s, void *iter_ptr)
 {
-       struct qp_iter *iter = iter_ptr;
+       struct rvt_qp_iter *iter = iter_ptr;
 
        if (!iter)
                return 0;
@@ -1535,5 +1534,3 @@ void hfi1_dbg_exit(void)
        debugfs_remove_recursive(hfi1_dbg_root);
        hfi1_dbg_root = NULL;
 }
-
-#endif
index af711318f84b1b504585f091e6e19c59dc3e64be..4b01ccd895b4f3a882a38d2dfde3f5b98c12048d 100644 (file)
@@ -530,82 +530,6 @@ struct send_context *qp_to_send_context(struct rvt_qp *qp, u8 sc5)
                                          sc5);
 }
 
-struct qp_iter {
-       struct hfi1_ibdev *dev;
-       struct rvt_qp *qp;
-       int specials;
-       int n;
-};
-
-struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev)
-{
-       struct qp_iter *iter;
-
-       iter = kzalloc(sizeof(*iter), GFP_KERNEL);
-       if (!iter)
-               return NULL;
-
-       iter->dev = dev;
-       iter->specials = dev->rdi.ibdev.phys_port_cnt * 2;
-
-       return iter;
-}
-
-int qp_iter_next(struct qp_iter *iter)
-{
-       struct hfi1_ibdev *dev = iter->dev;
-       int n = iter->n;
-       int ret = 1;
-       struct rvt_qp *pqp = iter->qp;
-       struct rvt_qp *qp;
-
-       /*
-        * The approach is to consider the special qps
-        * as an additional table entries before the
-        * real hash table.  Since the qp code sets
-        * the qp->next hash link to NULL, this works just fine.
-        *
-        * iter->specials is 2 * # ports
-        *
-        * n = 0..iter->specials is the special qp indices
-        *
-        * n = iter->specials..dev->rdi.qp_dev->qp_table_size+iter->specials are
-        * the potential hash bucket entries
-        *
-        */
-       for (; n <  dev->rdi.qp_dev->qp_table_size + iter->specials; n++) {
-               if (pqp) {
-                       qp = rcu_dereference(pqp->next);
-               } else {
-                       if (n < iter->specials) {
-                               struct hfi1_pportdata *ppd;
-                               struct hfi1_ibport *ibp;
-                               int pidx;
-
-                               pidx = n % dev->rdi.ibdev.phys_port_cnt;
-                               ppd = &dd_from_dev(dev)->pport[pidx];
-                               ibp = &ppd->ibport_data;
-
-                               if (!(n & 1))
-                                       qp = rcu_dereference(ibp->rvp.qp[0]);
-                               else
-                                       qp = rcu_dereference(ibp->rvp.qp[1]);
-                       } else {
-                               qp = rcu_dereference(
-                                       dev->rdi.qp_dev->qp_table[
-                                               (n - iter->specials)]);
-                       }
-               }
-               pqp = qp;
-               if (qp) {
-                       iter->qp = qp;
-                       iter->n = n;
-                       return 0;
-               }
-       }
-       return ret;
-}
-
 static const char * const qp_type_str[] = {
        "SMI", "GSI", "RC", "UC", "UD",
 };
@@ -619,7 +543,12 @@ static int qp_idle(struct rvt_qp *qp)
                qp->s_tail == qp->s_head;
 }
 
-void qp_iter_print(struct seq_file *s, struct qp_iter *iter)
+/**
+ * qp_iter_print - print the qp information to seq_file
+ * @s: the seq_file to emit the qp information on
+ * @iter: the iterator for the qp hash list
+ */
+void qp_iter_print(struct seq_file *s, struct rvt_qp_iter *iter)
 {
        struct rvt_swqe *wqe;
        struct rvt_qp *qp = iter->qp;
index 6fe542b6a92751863cd6385be0fe0654a346f08f..c06d2f8348e049fc289261536975125b3ec37f47 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _QP_H
 #define _QP_H
 /*
- * Copyright(c) 2015, 2016 Intel Corporation.
+ * Copyright(c) 2015 - 2017 Intel Corporation.
  *
  * This file is provided under a dual BSD/GPLv2 license.  When using or
  * redistributing this file, you may do so under either license.
@@ -94,26 +94,7 @@ void hfi1_qp_wakeup(struct rvt_qp *qp, u32 flag);
 struct sdma_engine *qp_to_sdma_engine(struct rvt_qp *qp, u8 sc5);
 struct send_context *qp_to_send_context(struct rvt_qp *qp, u8 sc5);
 
-struct qp_iter;
-
-/**
- * qp_iter_init - initialize the iterator for the qp hash list
- * @dev: the hfi1_ibdev
- */
-struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev);
-
-/**
- * qp_iter_next - Find the next qp in the hash list
- * @iter: the iterator for the qp hash list
- */
-int qp_iter_next(struct qp_iter *iter);
-
-/**
- * qp_iter_print - print the qp information to seq_file
- * @s: the seq_file to emit the qp information on
- * @iter: the iterator for the qp hash list
- */
-void qp_iter_print(struct seq_file *s, struct qp_iter *iter);
+void qp_iter_print(struct seq_file *s, struct rvt_qp_iter *iter);
 
 void _hfi1_schedule_send(struct rvt_qp *qp);
 void hfi1_schedule_send(struct rvt_qp *qp);