diff mbox

[rdma-next,3/5] iw_cxgb4: provide detailed provider-specific CM_ID information

Message ID 17ec22ecf17afad89f4a6de61e4091d27f6057f5.1525788595.git.swise@opengridcomputing.com (mailing list archive)
State Superseded
Headers show

Commit Message

Steve Wise May 8, 2018, 2:08 p.m. UTC
Add a table of important fields from the c4iw_ep* structures to the cm_id
resource tracking table.  This is helpful in debugging.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---
 drivers/infiniband/hw/cxgb4/restrack.c | 72 ++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

Comments

kernel test robot May 8, 2018, 9:29 p.m. UTC | #1
Hi Steve,

I love your patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on next-20180508]
[cannot apply to linus/master v4.17-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Wise/iw_cxgb4-always-set-iw_cm_id-provider_data/20180508-233327
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/infiniband/hw/cxgb4/restrack.c: In function 'fill_res_qp_entry':
   drivers/infiniband/hw/cxgb4/restrack.c:142:6: warning: 'last_rq_idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (rdma_nl_put_driver_u32(msg, "idx", idx))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/cxgb4/restrack.c:182:20: note: 'last_rq_idx' was declared here
     u16 first_rq_idx, last_rq_idx;
                       ^~~~~~~~~~~
   drivers/infiniband/hw/cxgb4/restrack.c:142:6: warning: 'first_rq_idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (rdma_nl_put_driver_u32(msg, "idx", idx))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/cxgb4/restrack.c:182:6: note: 'first_rq_idx' was declared here
     u16 first_rq_idx, last_rq_idx;
         ^~~~~~~~~~~~
   drivers/infiniband/hw/cxgb4/restrack.c:230:6: warning: 'last_sq_idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (fill_swsqes(msg, &wq.sq, first_sq_idx, fsp, last_sq_idx, lsp))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/infiniband/hw/cxgb4/restrack.c:230:6: warning: 'first_sq_idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   drivers/infiniband/hw/cxgb4/restrack.c: In function 'fill_res_ep_entry':
>> drivers/infiniband/hw/cxgb4/restrack.c:315:1: warning: the frame size of 1296 bytes is larger than 1024 bytes [-Wframe-larger-than=]
    }
    ^

vim +315 drivers/infiniband/hw/cxgb4/restrack.c

   171	
   172	static int fill_res_qp_entry(struct sk_buff *msg,
   173				     struct rdma_restrack_entry *res)
   174	{
   175		struct ib_qp *ibqp = container_of(res, struct ib_qp, res);
   176		struct t4_swsqe *fsp = NULL, *lsp = NULL;
   177		struct t4_swrqe *frp = NULL, *lrp = NULL;
   178		struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
   179		struct t4_swsqe first_sqe, last_sqe;
   180		struct t4_swrqe first_rqe, last_rqe;
   181		u16 first_sq_idx, last_sq_idx;
 > 182		u16 first_rq_idx, last_rq_idx;
   183		struct nlattr *table_attr;
   184		struct t4_wq wq;
   185	
   186		/* User qp state is not available, so don't dump user qps */
   187		if (qhp->ucontext)
   188			return 0;
   189	
   190		table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
   191		if (!table_attr)
   192			goto err;
   193	
   194		/* Get a consistent snapshot */
   195		spin_lock_irq(&qhp->lock);
   196		wq = qhp->wq;
   197	
   198		/* If there are any pending sqes, copy the first and last */
   199		if (wq.sq.cidx != wq.sq.pidx) {
   200			first_sq_idx = wq.sq.cidx;
   201			first_sqe = qhp->wq.sq.sw_sq[first_sq_idx];
   202			fsp = &first_sqe;
   203			last_sq_idx = wq.sq.pidx;
   204			if (last_sq_idx-- == 0)
   205				last_sq_idx = wq.sq.size - 1;
   206			if (last_sq_idx != first_sq_idx) {
   207				last_sqe = qhp->wq.sq.sw_sq[last_sq_idx];
   208				lsp = &last_sqe;
   209			}
   210		}
   211	
   212		/* If there are any pending rqes, copy the first and last */
   213		if (wq.rq.cidx != wq.rq.pidx) {
   214			first_rq_idx = wq.rq.cidx;
   215			first_rqe = qhp->wq.rq.sw_rq[first_rq_idx];
   216			frp = &first_rqe;
   217			last_rq_idx = wq.rq.pidx;
   218			if (last_rq_idx-- == 0)
   219				last_rq_idx = wq.rq.size - 1;
   220			if (last_rq_idx != first_rq_idx) {
   221				last_rqe = qhp->wq.rq.sw_rq[last_rq_idx];
   222				lrp = &last_rqe;
   223			}
   224		}
   225		spin_unlock_irq(&qhp->lock);
   226	
   227		if (fill_sq(msg, &wq))
   228			goto err_cancel_table;
   229	
   230		if (fill_swsqes(msg, &wq.sq, first_sq_idx, fsp, last_sq_idx, lsp))
   231			goto err_cancel_table;
   232	
   233		if (fill_rq(msg, &wq))
   234			goto err_cancel_table;
   235	
   236		if (fill_swrqes(msg, &wq.rq, first_rq_idx, frp, last_rq_idx, lrp))
   237			goto err_cancel_table;
   238	
   239		nla_nest_end(msg, table_attr);
   240		return 0;
   241	
   242	err_cancel_table:
   243		nla_nest_cancel(msg, table_attr);
   244	err:
   245		return -EMSGSIZE;
   246	}
   247	
   248	static int fill_res_ep_entry(struct sk_buff *msg,
   249				     struct rdma_restrack_entry *res)
   250	{
   251		struct rdma_cm_id *cm_id = rdma_res_to_id(res);
   252		struct nlattr *table_attr;
   253		struct c4iw_ep_common epc, *epcp;
   254		struct c4iw_listen_ep listen_ep;
   255		struct iw_cm_id *iw_cm_id;
   256		struct c4iw_ep ep;
   257	
   258		iw_cm_id = rdma_iw_cm_id(cm_id);
   259		if (!iw_cm_id)
   260			return 0;
   261		epcp = (struct c4iw_ep_common *)iw_cm_id->provider_data;
   262		if (!epcp)
   263			return 0;
   264	
   265		table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
   266		if (!table_attr)
   267			goto err;
   268	
   269		/* Get a consistent snapshot */
   270		mutex_lock(&epcp->mutex);
   271		if (epcp->state == LISTEN) {
   272			listen_ep = *(struct c4iw_listen_ep *)epcp;
   273			mutex_unlock(&epcp->mutex);
   274			epcp = &listen_ep.com;
   275		} else {
   276			ep = *(struct c4iw_ep *)epcp;
   277			mutex_unlock(&epcp->mutex);
   278			epcp = &ep.com;
   279		}
   280		epc = *epcp;
   281	
   282		if (rdma_nl_put_driver_u32(msg, "state", epc.state))
   283			goto err_cancel_table;
   284		if (rdma_nl_put_driver_u64_hex(msg, "flags", epc.flags))
   285			goto err_cancel_table;
   286		if (rdma_nl_put_driver_u64_hex(msg, "history", epc.history))
   287			goto err_cancel_table;
   288	
   289		if (epc.state == LISTEN) {
   290			if (rdma_nl_put_driver_u32(msg, "stid", listen_ep.stid))
   291				goto err_cancel_table;
   292			if (rdma_nl_put_driver_u32(msg, "backlog", listen_ep.backlog))
   293				goto err_cancel_table;
   294		} else {
   295			if (rdma_nl_put_driver_u32(msg, "hwtid", ep.hwtid))
   296				goto err_cancel_table;
   297			if (rdma_nl_put_driver_u32(msg, "ord", ep.ord))
   298				goto err_cancel_table;
   299			if (rdma_nl_put_driver_u32(msg, "ird", ep.ird))
   300				goto err_cancel_table;
   301			if (rdma_nl_put_driver_u32(msg, "emss", ep.emss))
   302				goto err_cancel_table;
   303	
   304			if (!ep.parent_ep && rdma_nl_put_driver_u32(msg, "atid",
   305								      ep.atid))
   306				goto err_cancel_table;
   307		}
   308		nla_nest_end(msg, table_attr);
   309		return 0;
   310	
   311	err_cancel_table:
   312		nla_nest_cancel(msg, table_attr);
   313	err:
   314		return -EMSGSIZE;
 > 315	}
   316	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/infiniband/hw/cxgb4/restrack.c b/drivers/infiniband/hw/cxgb4/restrack.c
index a677940..4a6fc1d8 100644
--- a/drivers/infiniband/hw/cxgb4/restrack.c
+++ b/drivers/infiniband/hw/cxgb4/restrack.c
@@ -30,6 +30,8 @@ 
  * SOFTWARE.
  */
 
+#include <rdma/rdma_cm.h>
+
 #include "iw_cxgb4.h"
 #include <rdma/restrack.h>
 #include <uapi/rdma/rdma_netlink.h>
@@ -243,6 +245,76 @@  static int fill_res_qp_entry(struct sk_buff *msg,
 	return -EMSGSIZE;
 }
 
+static int fill_res_ep_entry(struct sk_buff *msg,
+			     struct rdma_restrack_entry *res)
+{
+	struct rdma_cm_id *cm_id = rdma_res_to_id(res);
+	struct nlattr *table_attr;
+	struct c4iw_ep_common epc, *epcp;
+	struct c4iw_listen_ep listen_ep;
+	struct iw_cm_id *iw_cm_id;
+	struct c4iw_ep ep;
+
+	iw_cm_id = rdma_iw_cm_id(cm_id);
+	if (!iw_cm_id)
+		return 0;
+	epcp = (struct c4iw_ep_common *)iw_cm_id->provider_data;
+	if (!epcp)
+		return 0;
+
+	table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
+	if (!table_attr)
+		goto err;
+
+	/* Get a consistent snapshot */
+	mutex_lock(&epcp->mutex);
+	if (epcp->state == LISTEN) {
+		listen_ep = *(struct c4iw_listen_ep *)epcp;
+		mutex_unlock(&epcp->mutex);
+		epcp = &listen_ep.com;
+	} else {
+		ep = *(struct c4iw_ep *)epcp;
+		mutex_unlock(&epcp->mutex);
+		epcp = &ep.com;
+	}
+	epc = *epcp;
+
+	if (rdma_nl_put_driver_u32(msg, "state", epc.state))
+		goto err_cancel_table;
+	if (rdma_nl_put_driver_u64_hex(msg, "flags", epc.flags))
+		goto err_cancel_table;
+	if (rdma_nl_put_driver_u64_hex(msg, "history", epc.history))
+		goto err_cancel_table;
+
+	if (epc.state == LISTEN) {
+		if (rdma_nl_put_driver_u32(msg, "stid", listen_ep.stid))
+			goto err_cancel_table;
+		if (rdma_nl_put_driver_u32(msg, "backlog", listen_ep.backlog))
+			goto err_cancel_table;
+	} else {
+		if (rdma_nl_put_driver_u32(msg, "hwtid", ep.hwtid))
+			goto err_cancel_table;
+		if (rdma_nl_put_driver_u32(msg, "ord", ep.ord))
+			goto err_cancel_table;
+		if (rdma_nl_put_driver_u32(msg, "ird", ep.ird))
+			goto err_cancel_table;
+		if (rdma_nl_put_driver_u32(msg, "emss", ep.emss))
+			goto err_cancel_table;
+
+		if (!ep.parent_ep && rdma_nl_put_driver_u32(msg, "atid",
+							      ep.atid))
+			goto err_cancel_table;
+	}
+	nla_nest_end(msg, table_attr);
+	return 0;
+
+err_cancel_table:
+	nla_nest_cancel(msg, table_attr);
+err:
+	return -EMSGSIZE;
+}
+
 c4iw_restrack_func *c4iw_restrack_funcs[RDMA_RESTRACK_MAX] = {
 	[RDMA_RESTRACK_QP]	= fill_res_qp_entry,
+	[RDMA_RESTRACK_CM_ID]	= fill_res_ep_entry,
 };