diff mbox

[1/3] ibacm: Reduce overhead on multicast groups not used

Message ID CF9C39F99A89134C9CF9C4CCB68B8DDF25DC95015A@orsmsx501.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hefty, Sean April 1, 2011, 11:55 p.m. UTC
None
diff mbox

Patch

diff --git a/src/acm.c b/src/acm.c
index 15f2631..3df996b 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -724,22 +724,32 @@  static void acm_process_join_resp(struct acm_ep *ep, struct ib_user_mad *umad)
 	mc_rec = (struct ib_mc_member_rec *) mad->data;
 	lock_acquire(&ep->lock);
 	index = acm_mc_index(ep, &mc_rec->mgid);
-	if (index >= 0) {
-		dest = &ep->mc_dest[index];
-		dest->remote_qpn = IB_MC_QPN;
-		dest->mgid = mc_rec->mgid;
-		acm_record_mc_av(ep->port, mc_rec, dest);
+	if (index < 0) {
+		acm_log(0, "ERROR - MGID in join response not found\n");
+		goto out;
+	}
+
+	dest = &ep->mc_dest[index];
+	dest->remote_qpn = IB_MC_QPN;
+	dest->mgid = mc_rec->mgid;
+	acm_record_mc_av(ep->port, mc_rec, dest);
+
+	if (index == 0) {
 		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;
+		}
 		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");
-		} else {
-			dest->state = ACM_READY;
-			acm_log(1, "join successful\n");
+			goto out;
 		}
-	} else {
-		acm_log(0, "ERROR - MGID in join response not found\n");
 	}
+
+	dest->state = ACM_READY;
+	acm_log(1, "join successful\n");
+out:
 	lock_release(&ep->lock);
 }