public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] ibacm: Preparation for supporting different providers
@ 2014-03-23 20:18 sean.hefty-ral2JQCrhuEAvxtiuMwx3w
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

In order to support other mechanisms for address and route resolution,
such that those being defined for ibssa (scalable SA), ibacm will be
restructured to support the concept of 'plug-in' providers.  The
existing resolution mechanism will be converted into a provider,
with the management of client requests moving into what will
become the ibacm core.

The following patches prepare the code base for this split in
functionality.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Sean Hefty (9):
  ibacm: Release the refcnt on the correct client
  ibacm: Rename client array
  ibacm: Eliminate strict aliasing compiler warnings
  ibacm: Relocate client refcnt
  ibacm: Record index for source and destination addresses
  ibacm: Change base endpoint name
  ibacm: Reset endpoint state on error
  ibacm: Store the base GID with acm_port
  ibacm: Restructure acm_port_join

 src/acm.c |  175 ++++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 98 insertions(+), 77 deletions(-)

-- 
1.7.3

--
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] 10+ messages in thread

* [PATCH 1/9] ibacm: Release the refcnt on the correct client
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 2/9] ibacm: Rename client array sean.hefty-ral2JQCrhuEAvxtiuMwx3w
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Release the reference on the client that we're referencing,
and not the one at the front of the array.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index 82f9431..c403aa8 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -452,7 +452,7 @@ static void
 acm_free_req(struct acm_request *req)
 {
 	acm_log(2, "%p\n", req);
-	(void) atomic_dec(&client->refcnt);
+	(void) atomic_dec(&req->client->refcnt);
 	free(req);
 }
 
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 2/9] ibacm: Rename client array
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2014-03-23 20:18   ` [PATCH 1/9] ibacm: Release the refcnt on the correct client sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 3/9] ibacm: Eliminate strict aliasing compiler warnings sean.hefty-ral2JQCrhuEAvxtiuMwx3w
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Rename the client array to client_array, to make it easier
to distinguish between the array and local variables, which
are also named client.

And, hey, this found the bug in the previous patch.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index c403aa8..57d34dc 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -210,7 +210,7 @@ static event_t timeout_event;
 static atomic_t wait_cnt;
 
 static SOCKET listen_socket;
-static struct acm_client client[FD_SETSIZE - 1];
+static struct acm_client client_array[FD_SETSIZE - 1];
 
 static FILE *flog;
 static lock_t log_lock;
@@ -1690,10 +1690,10 @@ static void acm_init_server(void)
 	int i;
 
 	for (i = 0; i < FD_SETSIZE - 1; i++) {
-		lock_init(&client[i].lock);
-		client[i].index = i;
-		client[i].sock = INVALID_SOCKET;
-		atomic_init(&client[i].refcnt);
+		lock_init(&client_array[i].lock);
+		client_array[i].index = i;
+		client_array[i].sock = INVALID_SOCKET;
+		atomic_init(&client_array[i].refcnt);
 	}
 
 	if (!(f = fopen("/var/run/ibacm.port", "w"))) {
@@ -1758,7 +1758,7 @@ static void acm_svr_accept(void)
 	}
 
 	for (i = 0; i < FD_SETSIZE - 1; i++) {
-		if (!atomic_get(&client[i].refcnt))
+		if (!atomic_get(&client_array[i].refcnt))
 			break;
 	}
 
@@ -1768,8 +1768,8 @@ static void acm_svr_accept(void)
 		return;
 	}
 
-	client[i].sock = s;
-	atomic_set(&client[i].refcnt, 1);
+	client_array[i].sock = s;
+	atomic_set(&client_array[i].refcnt, 1);
 	acm_log(2, "assigned client %d\n", i);
 }
 
@@ -2407,9 +2407,9 @@ static void acm_server(void)
 		FD_SET(listen_socket, &readfds);
 
 		for (i = 0; i < FD_SETSIZE - 1; i++) {
-			if (client[i].sock != INVALID_SOCKET) {
-				FD_SET(client[i].sock, &readfds);
-				n = max(n, (int) client[i].sock);
+			if (client_array[i].sock != INVALID_SOCKET) {
+				FD_SET(client_array[i].sock, &readfds);
+				n = max(n, (int) client_array[i].sock);
 			}
 		}
 
@@ -2423,10 +2423,10 @@ static void acm_server(void)
 			acm_svr_accept();
 
 		for (i = 0; i < FD_SETSIZE - 1; i++) {
-			if (client[i].sock != INVALID_SOCKET &&
-				FD_ISSET(client[i].sock, &readfds)) {
+			if (client_array[i].sock != INVALID_SOCKET &&
+				FD_ISSET(client_array[i].sock, &readfds)) {
 				acm_log(2, "receiving from client %d\n", i);
-				acm_svr_receive(&client[i]);
+				acm_svr_receive(&client_array[i]);
 			}
 		}
 	}
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 3/9] ibacm: Eliminate strict aliasing compiler warnings
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2014-03-23 20:18   ` [PATCH 1/9] ibacm: Release the refcnt on the correct client sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 2/9] ibacm: Rename client array sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 4/9] ibacm: Relocate client refcnt sean.hefty-ral2JQCrhuEAvxtiuMwx3w
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Use local variables and memcpy to defeat the
compiler warning: dereferencing type-punned
pointer will break strict-aliasing rules

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index 57d34dc..c9e1b3c 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -1598,13 +1598,15 @@ static void acm_process_timeouts(void)
 	DLIST_ENTRY *entry;
 	struct acm_send_msg *msg;
 	struct acm_resolve_rec *rec;
+	struct acm_mad *mad;
 	
 	while (!DListEmpty(&timeout_list)) {
 		entry = timeout_list.Next;
 		DListRemove(entry);
 
 		msg = container_of(entry, struct acm_send_msg, entry);
-		rec = (struct acm_resolve_rec *) ((struct acm_mad *) msg->data)->data;
+		mad = (struct acm_mad *) &msg->data[0];
+		rec = (struct acm_resolve_rec *) mad->data;
 
 		acm_format_name(0, log_data, sizeof log_data,
 				rec->dest_type, rec->dest, sizeof rec->dest);
@@ -2647,7 +2649,7 @@ static int acm_parse_osm_fullv1_paths(FILE *f, uint64_t *lid2guid, struct acm_ep
 	char s[128];
 	char *p, *ptr, *p_guid, *p_lid;
 	uint64_t guid;
-	uint16_t lid, dlid;
+	uint16_t lid, dlid, net_dlid;
 	int sl, mtu, rate;
 	int ret = 1, i;
 	uint8_t addr[ACM_MAX_ADDRESS];
@@ -2710,6 +2712,7 @@ static int acm_parse_osm_fullv1_paths(FILE *f, uint64_t *lid2guid, struct acm_ep
 			break;
 
 		dlid = strtoul(p, NULL, 0);
+		net_dlid = htons(dlid);
 
 		p = strtok_r(NULL, ":", &ptr);
 		if (!p)
@@ -2740,7 +2743,7 @@ static int acm_parse_osm_fullv1_paths(FILE *f, uint64_t *lid2guid, struct acm_ep
 			memset(addr, 0, ACM_MAX_ADDRESS);
 			if (i == 0) {
 				addr_type = ACM_ADDRESS_LID;
-				*((uint16_t *) addr) = htons(dlid);
+				memcpy(addr, &net_dlid, sizeof net_dlid);
 			} else {
 				addr_type = ACM_ADDRESS_GID;
 				memcpy(addr, &dgid, sizeof(dgid));
@@ -2754,7 +2757,7 @@ static int acm_parse_osm_fullv1_paths(FILE *f, uint64_t *lid2guid, struct acm_ep
 			dest->path.sgid = sgid;
 			dest->path.slid = htons(ep->port->lid);
 			dest->path.dgid = dgid;
-			dest->path.dlid = htons(dlid);
+			dest->path.dlid = net_dlid;
 			dest->path.reversible_numpath = IBV_PATH_RECORD_REVERSIBLE;
 			dest->path.pkey = htons(ep->pkey);
 			dest->path.mtu = (uint8_t) mtu;
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 4/9] ibacm: Relocate client refcnt
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2014-03-23 20:18   ` [PATCH 3/9] ibacm: Eliminate strict aliasing compiler warnings sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 5/9] ibacm: Record index for source and destination addresses sean.hefty-ral2JQCrhuEAvxtiuMwx3w
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Adjust when we take a reference on the client connection.
Increment the client reference when we begin processing
the client's request, and release it when the response
has been sent.

The client reference will no longer be associated with the
lifetime of any underlying acm_request structure.  This change
will allow the acm core to control the client reference
count when we move to a provider plug-in model in subsequent
patches.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index c9e1b3c..4fc650b 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -441,7 +441,6 @@ acm_alloc_req(struct acm_client *client, struct acm_msg *msg)
 		return NULL;
 	}
 
-	(void) atomic_inc(&client->refcnt);
 	req->client = client;
 	memcpy(&req->msg, msg, sizeof(req->msg));
 	acm_log(2, "client %d, req %p\n", client->index, req);
@@ -452,7 +451,6 @@ static void
 acm_free_req(struct acm_request *req)
 {
 	acm_log(2, "%p\n", req);
-	(void) atomic_dec(&req->client->refcnt);
 	free(req);
 }
 
@@ -1084,6 +1082,7 @@ acm_client_resolve_resp(struct acm_client *client, struct acm_msg *req_msg,
 
 release:
 	lock_release(&client->lock);
+	(void) atomic_dec(&client->refcnt);
 	return ret;
 }
 
@@ -1340,6 +1339,7 @@ acm_client_query_resp(struct acm_client *client,
 
 release:
 	lock_release(&client->lock);
+	(void) atomic_dec(&client->refcnt);
 	return ret;
 }
 
@@ -2311,6 +2311,8 @@ put:
 
 static int acm_svr_resolve(struct acm_client *client, struct acm_msg *msg)
 {
+	(void) atomic_inc(&client->refcnt);
+
 	if (msg->resolve_data[0].type == ACM_EP_INFO_PATH) {
 		if (msg->resolve_data[0].flags & ACM_FLAGS_QUERY_SA) {
 			return acm_svr_query_path(client, msg);
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 5/9] ibacm: Record index for source and destination addresses
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2014-03-23 20:18   ` [PATCH 4/9] ibacm: Relocate client refcnt sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 6/9] ibacm: Change base endpoint name sean.hefty-ral2JQCrhuEAvxtiuMwx3w
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

When processing a resolve route message, record what
index the source and destination addresses were located
at directly into the message.  This replaces returning
pointers to the source and destination address that must
then be passed around.

When provider plug-in support is added in subsequent
patches, this will avoid pointer exchanges between the
core and provider code.

Fix a minor issue where the src_out field may be
uninitialized (value read from client message).  Src_out
now becomes a boolean value, rather than an index.  The
actual location for the output is specified as an index.

This change cleanups the call to acm_svr_select_src,
which selects a source address.  It is only called when
a source is needed, which is explicitly determined by
seeing if src_out is set, rather than relying on a zero
src type field.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |   54 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index 4fc650b..16e929b 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -49,6 +49,8 @@
 #include "acm_mad.h"
 
 #define src_out     data[0]
+#define src_index   data[1]
+#define dst_index   data[2]
 
 #define IB_LID_MCAST_START 0xc000
 
@@ -1069,7 +1071,7 @@ acm_client_resolve_resp(struct acm_client *client, struct acm_msg *req_msg,
 		if (req_msg->hdr.src_out) {
 			msg.hdr.length += ACM_MSG_EP_LENGTH;
 			memcpy(&msg.resolve_data[1],
-				&req_msg->resolve_data[req_msg->hdr.src_out],
+				&req_msg->resolve_data[req_msg->hdr.src_index],
 				ACM_MSG_EP_LENGTH);
 		}
 	}
@@ -1980,9 +1982,6 @@ static int acm_svr_select_src(struct acm_ep_addr_data *src, struct acm_ep_addr_d
 	int ret;
 	SOCKET s;
 
-	if (src->type)
-		return 0;
-
 	acm_log(2, "selecting source address\n");
 	memset(&addr, 0, sizeof addr);
 	switch (dst->type) {
@@ -2038,24 +2037,24 @@ out:
  * references to the source and destination addresses.
  * The message buffer contains extra address data buffers.  If a
  * source address is not given, reference an empty address buffer,
- * and we'll resolve a source address later.
+ * and we'll resolve a source address later.  Record the location of
+ * the source and destination addresses in the message header data
+ * to avoid further searches.
  */
-static uint8_t
-acm_svr_verify_resolve(struct acm_msg *msg,
-	struct acm_ep_addr_data **saddr, struct acm_ep_addr_data **daddr)
+static uint8_t acm_svr_verify_resolve(struct acm_msg *msg)
 {
-	struct acm_ep_addr_data *src = NULL, *dst = NULL;
-	int i, cnt;
+	int i, cnt, have_dst = 0;
 
 	if (msg->hdr.length < ACM_MSG_HDR_LENGTH) {
 		acm_log(0, "ERROR - invalid msg hdr length %d\n", msg->hdr.length);
 		return ACM_STATUS_EINVAL;
 	}
 
+	msg->hdr.src_out = 1;
 	cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / ACM_MSG_EP_LENGTH;
 	for (i = 0; i < cnt; i++) {
 		if (msg->resolve_data[i].flags & ACM_EP_FLAG_SOURCE) {
-			if (src) {
+			if (!msg->hdr.src_out) {
 				acm_log(0, "ERROR - multiple sources specified\n");
 				return ACM_STATUS_ESRCADDR;
 			}
@@ -2064,10 +2063,11 @@ acm_svr_verify_resolve(struct acm_msg *msg,
 				acm_log(0, "ERROR - unsupported source address type\n");
 				return ACM_STATUS_ESRCTYPE;
 			}
-			src = &msg->resolve_data[i];
+			msg->hdr.src_out = 0;
+			msg->hdr.src_index = i;
 		}
 		if (msg->resolve_data[i].flags & ACM_EP_FLAG_DEST) {
-			if (dst) {
+			if (have_dst) {
 				acm_log(0, "ERROR - multiple destinations specified\n");
 				return ACM_STATUS_EDESTADDR;
 			}
@@ -2076,22 +2076,20 @@ acm_svr_verify_resolve(struct acm_msg *msg,
 				acm_log(0, "ERROR - unsupported destination address type\n");
 				return ACM_STATUS_EDESTTYPE;
 			}
-			dst = &msg->resolve_data[i];
+			have_dst = 1;
+			msg->hdr.dst_index = i;
 		}
 	}
 
-	if (!dst) {
+	if (!have_dst) {
 		acm_log(0, "ERROR - destination address required\n");
 		return ACM_STATUS_EDESTTYPE;
 	}
 
-	if (!src) {
-		msg->hdr.src_out = i;
-		src = &msg->resolve_data[i];
-		memset(src, 0, sizeof *src);
+	if (msg->hdr.src_out) {
+		msg->hdr.src_index = i;
+		memset(&msg->resolve_data[i], 0, sizeof(struct acm_ep_addr_data));
 	}
-	*saddr = src;
-	*daddr = dst;
 	return ACM_STATUS_SUCCESS;
 }
 
@@ -2138,16 +2136,20 @@ acm_svr_resolve_dest(struct acm_client *client, struct acm_msg *msg)
 	int ret;
 
 	acm_log(2, "client %d\n", client->index);
-	status = acm_svr_verify_resolve(msg, &saddr, &daddr);
+	status = acm_svr_verify_resolve(msg);
 	if (status) {
 		acm_log(0, "notice - misformatted or unsupported request\n");
 		return acm_client_resolve_resp(client, msg, NULL, status);
 	}
 
-	status = acm_svr_select_src(saddr, daddr);
-	if (status) {
-		acm_log(0, "notice - unable to select suitable source address\n");
-		return acm_client_resolve_resp(client, msg, NULL, status);
+	saddr = &msg->resolve_data[msg->hdr.src_index];
+	daddr = &msg->resolve_data[msg->hdr.dst_index];
+	if (msg->hdr.src_out) {
+		status = acm_svr_select_src(saddr, daddr);
+		if (status) {
+			acm_log(0, "notice - unable to select suitable source address\n");
+			return acm_client_resolve_resp(client, msg, NULL, status);
+		}
 	}
 
 	acm_format_name(2, log_data, sizeof log_data,
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 6/9] ibacm: Change base endpoint name
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2014-03-23 20:18   ` [PATCH 5/9] ibacm: Record index for source and destination addresses sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 7/9] ibacm: Reset endpoint state on error sean.hefty-ral2JQCrhuEAvxtiuMwx3w
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Endpoints are given a string identifer (base name) that matches
the first address assigned to the endpoint.  Store the endpoint
string identifier separately from the address name, and identify
the endpoint using the device name, port, and pkey.

The endpoint identifier is only used for logging purposes.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index 16e929b..a8a1fb9 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -153,6 +153,7 @@ struct acm_ep {
 	DLIST_ENTRY           entry;
 	union acm_ep_info     addr[MAX_EP_ADDR];
 	char                  name[MAX_EP_ADDR][ACM_MAX_ADDRESS];
+	char		      id_string[ACM_MAX_ADDRESS];
 	uint8_t               addr_type[MAX_EP_ADDR];
 	void                  *dest_map[ACM_ADDRESS_RESERVED - 1];
 	struct acm_dest       mc_dest[MAX_EP_MC];
@@ -1394,7 +1395,7 @@ static void acm_process_recv(struct acm_ep *ep, struct ibv_wc *wc)
 {
 	struct acm_mad *mad;
 
-	acm_log(2, "base endpoint name %s\n", ep->name[0]);
+	acm_log(2, "base endpoint name %s\n", ep->id_string);
 	mad = (struct acm_mad *) (uintptr_t) (wc->wr_id + sizeof(struct ibv_grh));
 	switch (mad->mgmt_class) {
 	case IB_MGMT_CLASS_SA:
@@ -3057,6 +3058,8 @@ acm_alloc_ep(struct acm_port *port, uint16_t pkey, uint16_t pkey_index)
 	DListInit(&ep->active_queue);
 	DListInit(&ep->wait_queue);
 	lock_init(&ep->lock);
+	sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
+		port->port_num, pkey);
 
 	return ep;
 }
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 7/9] ibacm: Reset endpoint state on error
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2014-03-23 20:18   ` [PATCH 6/9] ibacm: Change base endpoint name sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 8/9] ibacm: Store the base GID with acm_port sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 9/9] ibacm: Restructure acm_port_join sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

An endpoint will be set to the ACM_READY state after
joining its multicast group.  If we later receive a
reregister event or port down followed by port up and
try to join the group again but fail, we will leave the
endpoint state as READY, rather than reset it back to INIT.

To fix, always set the mc_dest state to ACM_INIT on
any failure.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index a8a1fb9..eba027d 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -750,21 +750,21 @@ static void acm_process_join_resp(struct acm_ep *ep, struct ib_user_mad *umad)
 	mad = (struct ib_sa_mad *) umad->data;
 	acm_log(1, "response status: 0x%x, mad status: 0x%x\n",
 		umad->status, mad->status);
+	lock_acquire(&ep->lock);
 	if (umad->status) {
 		acm_log(0, "ERROR - send join failed 0x%x\n", umad->status);
-		return;
+		goto err1;
 	}
 	if (mad->status) {
 		acm_log(0, "ERROR - join response status 0x%x\n", mad->status);
-		return;
+		goto err1;
 	}
 
 	mc_rec = (struct ib_mc_member_rec *) mad->data;
-	lock_acquire(&ep->lock);
 	index = acm_mc_index(ep, &mc_rec->mgid);
 	if (index < 0) {
 		acm_log(0, "ERROR - MGID in join response not found\n");
-		goto out;
+		goto err1;
 	}
 
 	dest = &ep->mc_dest[index];
@@ -776,19 +776,25 @@ static void acm_process_join_resp(struct acm_ep *ep, struct ib_user_mad *umad)
 		dest->ah = ibv_create_ah(ep->port->dev->pd, &dest->av);
 		if (!dest->ah) {
 			acm_log(0, "ERROR - unable to create ah\n");
-			goto out;
+			goto err1;
 		}
 		ret = ibv_attach_mcast(ep->qp, &mc_rec->mgid, mc_rec->mlid);
 		if (ret) {
 			acm_log(0, "ERROR - unable to attach QP to multicast group\n");
-			goto out;
+			goto err2;
 		}
 	}
 
 	atomic_set(&dest->refcnt, 1);
 	dest->state = ACM_READY;
 	acm_log(1, "join successful\n");
-out:
+	lock_release(&ep->lock);
+	return;
+err2:
+	ibv_destroy_ah(dest->ah);
+	dest->ah = NULL;
+err1:
+	dest->state = ACM_INIT;
 	lock_release(&ep->lock);
 }
 
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 8/9] ibacm: Store the base GID with acm_port
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (6 preceding siblings ...)
  2014-03-23 20:18   ` [PATCH 7/9] ibacm: Reset endpoint state on error sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2014-03-23 20:18   ` [PATCH 9/9] ibacm: Restructure acm_port_join sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Record the base GID of a port with acm_port.  This avoids
needing to query again for it later.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index eba027d..2d9ecee 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -117,6 +117,7 @@ struct acm_port {
 	int                 mad_portid;
 	int                 mad_agentid;
 	struct acm_dest     sa_dest;
+	union ibv_gid	    base_gid;
 	enum ibv_port_state state;
 	enum ibv_mtu        mtu;
 	enum ibv_rate       rate;
@@ -1569,34 +1570,25 @@ static void acm_port_join(struct acm_port *port)
 {
 	struct acm_device *dev;
 	struct acm_ep *ep;
-	union ibv_gid port_gid;
 	DLIST_ENTRY *ep_entry;
-	int ret;
 
 	dev = port->dev;
 	acm_log(1, "device %s port %d\n", dev->verbs->device->name,
 		port->port_num);
 
-	ret = ibv_query_gid(dev->verbs, port->port_num, 0, &port_gid);
-	if (ret) {
-		acm_log(0, "ERROR - ibv_query_gid %d device %s port %d\n",
-			ret, dev->verbs->device->name, port->port_num);
-		return;
-	}
-
 	for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
 		 ep_entry = ep_entry->Next) {
 
 		ep = container_of(ep_entry, struct acm_ep, entry);
 		ep->mc_cnt = 0;
-		acm_join_group(ep, &port_gid, 0, 0, 0, min_rate, min_mtu);
+		acm_join_group(ep, &port->base_gid, 0, 0, 0, min_rate, min_mtu);
 
 		if ((ep->state = ep->mc_dest[0].state) != ACM_READY)
 			continue;
 
 		if ((route_prot == ACM_ROUTE_PROT_ACM) &&
 		    (port->rate != min_rate || port->mtu != min_mtu))
-			acm_join_group(ep, &port_gid, 0, 0, 0, port->rate, port->mtu);
+			acm_join_group(ep, &port->base_gid, 0, 0, 0, port->rate, port->mtu);
 	}
 	acm_log(1, "joins for device %s port %d complete\n", dev->verbs->device->name,
 		port->port_num);
@@ -3206,6 +3198,9 @@ static void acm_port_up(struct acm_port *port)
 		ret = ibv_query_gid(port->dev->verbs, port->port_num, port->gid_cnt, &gid);
 		if (ret || !gid.global.interface_id)
 			break;
+
+		if (port->gid_cnt == 0)
+			port->base_gid = gid;
 	}
 
 	port->lid = attr.lid;
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

* [PATCH 9/9] ibacm: Restructure acm_port_join
       [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                     ` (7 preceding siblings ...)
  2014-03-23 20:18   ` [PATCH 8/9] ibacm: Store the base GID with acm_port sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2014-03-23 20:18   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  8 siblings, 0 replies; 10+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2014-03-23 20:18 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	ira.weiny-ral2JQCrhuEAvxtiuMwx3w,
	kaike.wan-ral2JQCrhuEAvxtiuMwx3w,
	john.fleck-ral2JQCrhuEAvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Create a subroutine to process joining a single
endpoint that can be called directly in place of
joining all endpoints on a port.

This will make it easier to handle future changes that
affect a single endpoint, such as a pkey change.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 src/acm.c |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index 2d9ecee..14ef71a 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -1566,32 +1566,42 @@ out:
 	free(umad);
 }
 
+static void acm_ep_join(struct acm_ep *ep)
+{
+	struct acm_port *port;
+
+	port = ep->port;
+	acm_log(1, "%s\n", ep->id_string);
+
+	ep->mc_cnt = 0;
+	acm_join_group(ep, &port->base_gid, 0, 0, 0, min_rate, min_mtu);
+
+	if ((ep->state = ep->mc_dest[0].state) != ACM_READY)
+		return;
+
+	if ((route_prot == ACM_ROUTE_PROT_ACM) &&
+	    (port->rate != min_rate || port->mtu != min_mtu))
+		acm_join_group(ep, &port->base_gid, 0, 0, 0, port->rate, port->mtu);
+
+	acm_log(1, "join for %s complete\n", ep->id_string);
+}
+
 static void acm_port_join(struct acm_port *port)
 {
-	struct acm_device *dev;
 	struct acm_ep *ep;
 	DLIST_ENTRY *ep_entry;
 
-	dev = port->dev;
-	acm_log(1, "device %s port %d\n", dev->verbs->device->name,
+	acm_log(1, "device %s port %d\n", port->dev->verbs->device->name,
 		port->port_num);
 
 	for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
 		 ep_entry = ep_entry->Next) {
 
 		ep = container_of(ep_entry, struct acm_ep, entry);
-		ep->mc_cnt = 0;
-		acm_join_group(ep, &port->base_gid, 0, 0, 0, min_rate, min_mtu);
-
-		if ((ep->state = ep->mc_dest[0].state) != ACM_READY)
-			continue;
-
-		if ((route_prot == ACM_ROUTE_PROT_ACM) &&
-		    (port->rate != min_rate || port->mtu != min_mtu))
-			acm_join_group(ep, &port->base_gid, 0, 0, 0, port->rate, port->mtu);
+		acm_ep_join(ep);
 	}
-	acm_log(1, "joins for device %s port %d complete\n", dev->verbs->device->name,
-		port->port_num);
+	acm_log(1, "joins for device %s port %d complete\n",
+		port->dev->verbs->device->name, port->port_num);
 }
 
 static void acm_process_timeouts(void)
-- 
1.7.3

--
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 related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-03-23 20:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-23 20:18 [PATCH 0/9] ibacm: Preparation for supporting different providers sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1395605901-9080-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-23 20:18   ` [PATCH 1/9] ibacm: Release the refcnt on the correct client sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 2/9] ibacm: Rename client array sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 3/9] ibacm: Eliminate strict aliasing compiler warnings sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 4/9] ibacm: Relocate client refcnt sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 5/9] ibacm: Record index for source and destination addresses sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 6/9] ibacm: Change base endpoint name sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 7/9] ibacm: Reset endpoint state on error sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 8/9] ibacm: Store the base GID with acm_port sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-23 20:18   ` [PATCH 9/9] ibacm: Restructure acm_port_join sean.hefty-ral2JQCrhuEAvxtiuMwx3w

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