[openib-general] [PATCH] mad: In handle_outgoing_smp, only match response if generated

Hal Rosenstock halr at voltaire.com
Mon Nov 15 12:06:25 PST 2004


mad: In handle_outgoing_smp, only match response if generated
(based on comment from Roland)

Index: mad.c
===================================================================
--- mad.c	(revision 1230)
+++ mad.c	(working copy)
@@ -394,6 +394,10 @@
 			goto error1;
 		}
 
+		mad_agent_priv = container_of(mad_agent,
+					      struct ib_mad_agent_private,
+					      agent);
+
 		if (mad_agent->device->process_mad) {
 			ret = mad_agent->device->process_mad(
 					    mad_agent->device,
@@ -418,46 +422,50 @@
 								mad_priv);
 						goto error1;
 					}
-				}
-			}
-		}
 
-		/* See if response is solicited and there is a recv handler */
-		mad_agent_priv = container_of(mad_agent,
-					      struct ib_mad_agent_private,
-					      agent);
-		if (solicited_mad(&mad_priv->mad.mad) && 
-		    mad_agent_priv->agent.recv_handler) {
-			struct ib_wc wc;
+					/*
+					 * See if response is solicited and
+					 * there is a recv handler
+					 */
+					if (solicited_mad(&mad_priv->mad.mad) && 
+					    mad_agent_priv->agent.recv_handler) {
+						struct ib_wc wc;
 
-			/*
-			 * Defined behavior is to complete response
-			 * before request
-			 */
-			wc.wr_id = send_wr->wr_id;
-			wc.status = IB_WC_SUCCESS;
-			wc.opcode = IB_WC_RECV;
-			wc.vendor_err = 0;
-			wc.byte_len = sizeof(struct ib_mad);
-			wc.src_qp = 0;	/* IB_QPT_SMI ? */
-			wc.wc_flags = 0;
-			wc.pkey_index = 0;
-			wc.slid = IB_LID_PERMISSIVE;
-			wc.sl = 0;
-			wc.dlid_path_bits = 0;
-			mad_priv->header.recv_wc.wc = &wc;
-			mad_priv->header.recv_wc.mad_len =
+						/*
+						 * Defined behavior is to
+						 * complete response before
+						 * request
+						 */
+						wc.wr_id = send_wr->wr_id;
+						wc.status = IB_WC_SUCCESS;
+						wc.opcode = IB_WC_RECV;
+						wc.vendor_err = 0;
+						wc.byte_len = sizeof(struct ib_mad);
+						wc.src_qp = 0;  /* IB_QPT_SMI ? */
+						wc.wc_flags = 0;
+						wc.pkey_index = 0;
+						wc.slid = IB_LID_PERMISSIVE;
+						wc.sl = 0;
+						wc.dlid_path_bits = 0;
+						mad_priv->header.recv_wc.wc = &wc;
+						mad_priv->header.recv_wc.mad_len =
 							sizeof(struct ib_mad);
-			INIT_LIST_HEAD(&mad_priv->header.recv_buf.list);
-			mad_priv->header.recv_buf.grh = NULL;
-			mad_priv->header.recv_buf.mad = &mad_priv->mad.mad;
-			mad_priv->header.recv_wc.recv_buf =
-						&mad_priv->header.recv_buf;
-			mad_agent_priv->agent.recv_handler(
-						mad_agent,
-						&mad_priv->header.recv_wc);
-		} else
-			kmem_cache_free(ib_mad_cache, mad_priv);
+						INIT_LIST_HEAD(&mad_priv->header.recv_buf.list);
+						mad_priv->header.recv_buf.grh = NULL;
+						mad_priv->header.recv_buf.mad =
+							&mad_priv->mad.mad;
+						mad_priv->header.recv_wc.recv_buf =
+							&mad_priv->header.recv_buf;
+						mad_agent_priv->agent.recv_handler(
+							mad_agent,
+							&mad_priv->header.recv_wc);
+					} else
+						kmem_cache_free(ib_mad_cache, mad_priv);
+				} else
+					kmem_cache_free(ib_mad_cache, mad_priv);
+			} else
+				kmem_cache_free(ib_mad_cache, mad_priv);
+		}
 
 		if (mad_agent_priv->agent.send_handler) {
 			/* Now, complete send */






More information about the general mailing list