ret = ib_send_mad(mad_send_wr); if (ret) { 
if (mad_agent_priv->agent.rmpp_version) { ret = ib_send_rmpp_mad(mad_send_wr); if (ret >= 0 && ret != IB_RMPP_RESULT_CONSUMED) ret = ib_send_mad(mad_send_wr); } else ret = ib_send_mad(mad_send_wr); if (ret < 0) { 
int ib_post_send_mad(struct ib_mad_agent *mad_agent,		     struct ib_send_wr *send_wr,		     struct ib_send_wr **bad_send_wr){	int ret = -EINVAL;	struct ib_mad_agent_private *mad_agent_priv;	/* Validate supplied parameters */	if (!bad_send_wr)		goto error1;	if (!mad_agent || !send_wr)		goto error2;	if (!mad_agent->send_handler)		goto error2;	mad_agent_priv = container_of(mad_agent,				      struct ib_mad_agent_private,				      agent);	/* Walk list of send WRs and post each on send list */	while (send_wr) {		unsigned long			flags;		struct ib_send_wr		*next_send_wr;		struct ib_mad_send_wr_private	*mad_send_wr;		struct ib_smp			*smp;		/* Validate more parameters */		if (send_wr->num_sge > IB_MAD_SEND_REQ_MAX_SG)			goto error2;		if (send_wr->wr.ud.timeout_ms && !mad_agent->recv_handler)			goto error2;		if (!send_wr->wr.ud.mad_hdr) {			printk(KERN_ERR PFX "MAD header must be supplied "			       "in WR %p\n", send_wr);			goto error2;		}		/*		 * Save pointer to next work request to post in case the		 * current one completes, and the user modifies the work		 * request associated with the completion		 */		next_send_wr = (struct ib_send_wr *)send_wr->next;		smp = (struct ib_smp *)send_wr->wr.ud.mad_hdr;		if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {			ret = handle_outgoing_dr_smp(mad_agent_priv, smp,						     send_wr);			if (ret < 0)		/* error */				goto error2;			else if (ret == 1)	/* locally consumed */				goto next;		}		/* Allocate MAD send WR tracking structure */		mad_send_wr = kmalloc(sizeof *mad_send_wr, GFP_ATOMIC);		if (!mad_send_wr) {			printk(KERN_ERR PFX "No memory for "			       "ib_mad_send_wr_private\n");			ret = -ENOMEM;			goto error2;		}		mad_send_wr->send_wr = *send_wr;		mad_send_wr->send_wr.sg_list = mad_send_wr->sg_list;		memcpy(mad_send_wr->sg_list, send_wr->sg_list,		       sizeof *send_wr->sg_list * send_wr->num_sge);		mad_send_wr->wr_id = mad_send_wr->send_wr.wr_id;		mad_send_wr->send_wr.next = NULL;		mad_send_wr->tid = send_wr->wr.ud.mad_hdr->tid;		mad_send_wr->mad_agent_priv = mad_agent_priv;		/* Timeout will be updated after send completes */		mad_send_wr->timeout = msecs_to_jiffies(send_wr->wr.							ud.timeout_ms);		mad_send_wr->retries = mad_send_wr->send_wr.wr.ud.retries;		/* One reference for each work request to QP + response */		mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);		mad_send_wr->status = IB_WC_SUCCESS;		/* Reference MAD agent until send completes */		atomic_inc(&mad_agent_priv->refcount);		spin_lock_irqsave(&mad_agent_priv->lock, flags);		list_add_tail(&mad_send_wr->agent_list,			      &mad_agent_priv->send_list);		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);		ret = ib_send_mad(mad_send_wr);		if (ret) {			/* Fail send request */			spin_lock_irqsave(&mad_agent_priv->lock, flags);			list_del(&mad_send_wr->agent_list);			spin_unlock_irqrestore(&mad_agent_priv->lock, flags);			atomic_dec(&mad_agent_priv->refcount);			goto error2;		}next:		send_wr = next_send_wr;	}	return 0;error2:	*bad_send_wr = send_wr;error1:	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/fa619a77046bef30478697aba0553991033afb8e/mad.c/clean/drivers/infiniband/core/mad.c