public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] librdmacm/mckey: add notifications on events
@ 2009-11-11 16:15 Or Gerlitz
       [not found] ` <Pine.LNX.4.64.0911111814350.6979-aDiYczhfhVLdX2U7gxhm1tBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Or Gerlitz @ 2009-11-11 16:15 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma

add notifications on multicast error and address change events which
can take place while traffic is running.

Signed-off-by: Or Gerlitz <ogerlitz-smomgflXvOZWk0Htik3J/w@public.gmane.org>

Index: librdmacm/examples/mckey.c
===================================================================
--- librdmacm.orig/examples/mckey.c
+++ librdmacm/examples/mckey.c
@@ -62,6 +62,7 @@ struct cmatest_node {

 struct cmatest {
 	struct rdma_event_channel *channel;
+	pthread_t 		cmathread;
 	struct cmatest_node	*nodes;
 	int			conn_index;
 	int			connects_left;
@@ -319,6 +320,30 @@ static int cma_handler(struct rdma_cm_id
 	return ret;
 }

+static void *cma_thread(void *arg)
+{
+	struct rdma_cm_event *event;
+	int ret;
+
+	while (1) {
+		ret = rdma_get_cm_event(test.channel, &event);
+		if (ret) {
+			perror("rdma_get_cm_event");
+			exit(ret);
+		}
+		switch (event->event) {
+		case RDMA_CM_EVENT_MULTICAST_ERROR:
+		case RDMA_CM_EVENT_ADDR_CHANGE:
+			printf("mckey: event: %s, status: %d\n",
+			       rdma_event_str(event->event), event->status);
+			break;
+		default:
+			break;
+		}
+		rdma_ack_cm_event(event);
+	}
+}
+
 static void destroy_node(struct cmatest_node *node)
 {
 	if (!node->cma_id)
@@ -475,6 +500,7 @@ static int run(void)
 	if (ret)
 		goto out;

+	pthread_create(&test.cmathread, NULL, cma_thread, NULL);
 	/*
 	 * Pause to give SM chance to configure switches.  We don't want to
 	 * handle reliability issue in this simple test program.
--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-12 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-11 16:15 [PATCH] librdmacm/mckey: add notifications on events Or Gerlitz
     [not found] ` <Pine.LNX.4.64.0911111814350.6979-aDiYczhfhVLdX2U7gxhm1tBPR1lH4CV8@public.gmane.org>
2009-11-12  0:39   ` Sean Hefty
     [not found]     ` <C2A8DE4897EE4AA19F125A933FF8B08E-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-12  8:52       ` Or Gerlitz
     [not found]         ` <4AFBCCE3.9090106-hKgKHo2Ms0FWk0Htik3J/w@public.gmane.org>
2009-11-12 16:24           ` Sean Hefty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox