All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nir Muchtar <nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
To: rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	monis-smomgflXvOZWk0Htik3J/w@public.gmane.org,
	ogerlitz-smomgflXvOZWk0Htik3J/w@public.gmane.org,
	nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org
Subject: [PATCH V3 6/6] RDMA CM: Netlink Client
Date: Mon, 13 Dec 2010 18:22:50 +0200	[thread overview]
Message-ID: <1292257370-24391-7-git-send-email-nirm@voltaire.com> (raw)
In-Reply-To: <1292257370-24391-1-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>

Add callbacks and data types for statistics export.
One callback is implemented that exports all of the current devices/ids.
Add/remove the callback to IB Netlink on init/cleanup.

Signed-off-by: Nir Muchtar <nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 drivers/infiniband/core/cma.c |   77 +++++++++++++++++++++++++++++++++++++++++
 include/rdma/ib_netlink.h     |   15 ++++++++
 include/rdma/rdma_cm.h        |   10 +++++
 3 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9629a90..e3280d3 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -51,6 +51,7 @@
 #include <rdma/ib_cm.h>
 #include <rdma/ib_sa.h>
 #include <rdma/iw_cm.h>
+#include <rdma/ib_netlink.h>
 
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("Generic RDMA CM Agent");
@@ -3251,6 +3252,79 @@ static void cma_remove_one(struct ib_device *device)
 	kfree(cma_dev);
 }
 
+static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	struct nlmsghdr *nlh;
+	struct rdma_cm_id_stats *id_stats;
+	struct rdma_id_private *id_priv;
+	struct rdma_cm_id *id = NULL;
+	struct cma_device *cma_dev;
+	int i_dev, i_id;
+
+	/* We export all of the id's as a sequence of messages.
+	   Each id gets its own netlink message */	
+	mutex_lock(&lock);
+	i_dev = 0;
+	list_for_each_entry(cma_dev, &dev_list, list) {
+		if (i_dev < cb->args[0]) {
+			i_dev++;
+			continue;
+		}
+		i_id = 0;
+		list_for_each_entry(id_priv, &cma_dev->id_list, list) {
+			if (i_id < cb->args[1]) {
+				i_id++;
+				continue;
+			}
+			id_stats = ibnl_put_msg(skb, &nlh, cb->nlh->nlmsg_seq,
+						sizeof *id_stats, IBNL_RDMA_CM,
+						IBNL_RDMA_CM_ID_STATS);
+			if (!id_stats)
+				goto out;
+			memset(id_stats, 0, sizeof *id_stats);
+			id = &id_priv->id;
+			id_stats->nt = id->route.addr.dev_addr.dev_type;
+			id_stats->port_num = id->port_num;
+			id_stats->bound_dev_if =
+				id->route.addr.dev_addr.bound_dev_if;
+
+			if (ibnl_put_attr(skb, nlh,
+					  sizeof id->route.addr.src_addr,
+					  &id->route.addr.src_addr,
+					  IBNL_RDMA_CM_ATTR_SRC_ADDR)) {
+				goto out;
+			}
+
+			if (ibnl_put_attr(skb, nlh,
+					  sizeof id->route.addr.dst_addr,
+					  &id->route.addr.dst_addr,
+					  IBNL_RDMA_CM_ATTR_DST_ADDR)) {
+				goto out;
+			}
+
+			id_stats->ps = id->ps;
+			id_stats->cm_state = id_priv->state;
+			id_stats->qp_num = id_priv->qp_num;
+			id_stats->pid = id_priv->owner;
+
+			i_id++;
+		}
+		cb->args[1] = 0;
+		i_dev++;
+	}
+out:
+	mutex_unlock(&lock);
+	cb->args[0] = i_dev;
+	cb->args[1] = i_id;
+
+	return skb->len;
+}
+
+static int (*cma_cb_table[])(struct sk_buff *skb,
+			     struct netlink_callback *cb) = {
+	[IBNL_RDMA_CM_ID_STATS] = cma_get_id_stats,
+};
+
 static int __init cma_init(void)
 {
 	int ret;
@@ -3266,6 +3340,8 @@ static int __init cma_init(void)
 	ret = ib_register_client(&cma_client);
 	if (ret)
 		goto err;
+	if (ibnl_add_client(IBNL_RDMA_CM, IBNL_RDMA_CM_NUM_OPS, cma_cb_table))
+		printk(KERN_WARNING "RDMA CM failed to add netlink callback\n");
 	return 0;
 
 err:
@@ -3278,6 +3354,7 @@ err:
 
 static void __exit cma_cleanup(void)
 {
+	ibnl_remove_client(IBNL_RDMA_CM);
 	ib_unregister_client(&cma_client);
 	unregister_netdevice_notifier(&cma_nb);
 	rdma_addr_unregister_client(&addr_client);
diff --git a/include/rdma/ib_netlink.h b/include/rdma/ib_netlink.h
index 0db338c..470318f 100644
--- a/include/rdma/ib_netlink.h
+++ b/include/rdma/ib_netlink.h
@@ -1,6 +1,21 @@
 #ifndef _IBNETLINK_H
 #define _IBNETLINK_H
 
+enum {
+	IBNL_RDMA_CM = 1
+};
+
+enum {
+	IBNL_RDMA_CM_ID_STATS = 0,
+	IBNL_RDMA_CM_NUM_OPS
+};
+
+enum {
+	IBNL_RDMA_CM_ATTR_SRC_ADDR = 1,
+	IBNL_RDMA_CM_ATTR_DST_ADDR,
+	IBNL_RDMA_CM_NUM_ATTR,
+};
+
 #define IBNL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
 #define IBNL_GET_OP(type) (type & ((1 << 10) - 1))
 #define IBNL_GET_TYPE(client, op) ((client << 10) + op)
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index c766da9..ec47f11 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -147,6 +147,16 @@ struct rdma_cm_id {
 	u8			 port_num;
 };
 
+struct rdma_cm_id_stats {
+	u8 nt;
+	u8 port_num;
+	u32 bound_dev_if;
+	u32 ps;
+	u8 cm_state;
+	u32 qp_num;
+	pid_t pid;
+};
+
 /**
  * rdma_create_id - Create an RDMA identifier.
  *
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-12-13 16:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-13 16:22 [PATCH V3 0/6] IB Netlink Interface and RDMA CM exports Nir Muchtar
     [not found] ` <1292257370-24391-1-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-13 16:22   ` [PATCH V3 1/6] IB Netlink Infrastructure Nir Muchtar
     [not found]     ` <1292257370-24391-2-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-14 18:34       ` Jason Gunthorpe
     [not found]         ` <20101214183401.GC2506-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-19 14:34           ` Nir Muchtar
2010-12-13 16:22   ` [PATCH V3 2/6] IB Core: Error Handler Nir Muchtar
2010-12-13 16:22   ` [PATCH V3 3/6] IB Core Run Netlink Nir Muchtar
2010-12-13 16:22   ` [PATCH V3 4/6] RDMA CM: Export State Enum Nir Muchtar
2010-12-13 16:22   ` [PATCH V3 5/6] RDMA CM: Save Owning PID Nir Muchtar
     [not found]     ` <1292257370-24391-6-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-14 18:34       ` Jason Gunthorpe
     [not found]         ` <20101214183458.GD2506-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-19 14:36           ` Nir Muchtar
2010-12-20 21:54             ` Jason Gunthorpe
     [not found]               ` <20101220215433.GB12090-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-21 15:05                 ` Nir Muchtar
2010-12-21 18:10                   ` Jason Gunthorpe
2010-12-21 19:43                     ` Nir Muchtar
2010-12-21 20:33                       ` Nir Muchtar
     [not found]                       ` <7E95F01E94AB484F83061FCFA35B39F8794E3F-QfUkFaTmzUSUvQqKE/ONIwC/G2K4zDHf@public.gmane.org>
2010-12-21 20:36                         ` Jason Gunthorpe
     [not found]                           ` <20101221203627.GE12090-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-22 16:03                             ` Nir Muchtar
2010-12-22 22:10                               ` Jason Gunthorpe
     [not found]                     ` <20101221181043.GD12090-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-23 12:21                       ` Or Gerlitz
2010-12-13 16:22   ` Nir Muchtar [this message]
     [not found]     ` <1292257370-24391-7-git-send-email-nirm-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2010-12-14 18:45       ` [PATCH V3 6/6] RDMA CM: Netlink Client Jason Gunthorpe
     [not found]         ` <20101214184514.GE2506-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-19 14:47           ` Nir Muchtar
2010-12-20  7:24             ` Or Gerlitz
2010-12-20 19:16             ` Hefty, Sean
2010-12-20 21:52             ` Jason Gunthorpe
2010-12-14 18:27   ` [PATCH V3 0/6] IB Netlink Interface and RDMA CM exports Jason Gunthorpe
     [not found]     ` <20101214182746.GB2506-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-12-19 14:30       ` Nir Muchtar
2010-12-20 21:55         ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292257370-24391-7-git-send-email-nirm@voltaire.com \
    --to=nirm-smomgflxvozwk0htik3j/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=monis-smomgflXvOZWk0Htik3J/w@public.gmane.org \
    --cc=ogerlitz-smomgflXvOZWk0Htik3J/w@public.gmane.org \
    --cc=rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.