[openib-general] [PATCH][SDP] Further simplifications.

Libor Michalek libor at topspin.com
Fri Jun 17 10:29:32 PDT 2005


  Following patch simplifies some code paths, including some error
handling in the data paths.

 3 files changed, 143 insertions(+), 377 deletions(-)

-Libor

Index: sdp_send.c
===================================================================
--- sdp_send.c	(revision 2628)
+++ sdp_send.c	(working copy)
@@ -122,15 +122,6 @@
 		conn->send_cons = 0;
 	}
 	/*
-	 * check queue membership. (first send attempt vs. flush)
-	 */
-	if (sdp_desc_q_member((struct sdpc_desc *) buff))
-		sdp_desc_q_remove((struct sdpc_desc *) buff);
-	/*
-	 * save the buffer for the event handler.
-	 */
-	sdp_buff_q_put_tail(&conn->send_post, buff);
-	/*
 	 * post send
 	 */
  	buff->sge.length = buff->tail - buff->data;
@@ -152,11 +143,18 @@
 			     sdp_buff_q_size(&conn->send_post),
 			     sdp_desc_q_size(&conn->r_src),
 			     sdp_desc_q_size(&conn->w_snk));
-
-		(void)sdp_buff_q_get_tail(&conn->send_post);
 		goto done;
 	}
 	/*
+	 * check queue membership. (first send attempt vs. flush)
+	 */
+	if (sdp_desc_q_member((struct sdpc_desc *) buff))
+		sdp_desc_q_remove((struct sdpc_desc *) buff);
+	/*
+	 * save the buffer for the event handler.
+	 */
+	sdp_buff_q_put_tail(&conn->send_post, buff);
+	/*
 	 * source cancels require us to save the sequence number
 	 * for validation of the cancel's completion.
 	 */
@@ -352,19 +350,6 @@
 		     (unsigned)(buff->tail - buff->data),
 		     advt->size);
 	/*
-	 * dequeue if needed and the queue buffer
-	 */
-	if (sdp_desc_q_member((struct sdpc_desc *) buff) > 0)
-		sdp_desc_q_remove((struct sdpc_desc *) buff);
-
-	sdp_desc_q_put_tail(&conn->w_snk, (struct sdpc_desc *)buff);
-	/*
-	 * update send queue depth
-	 */
-	conn->s_wq_size++;
-	conn->send_pipe  -= buff->data_size;
-	conn->oob_offset -= (conn->oob_offset > 0) ? buff->data_size : 0;
-	/*
 	 * post RDMA
 	 */
 	buff->sge.addr     = virt_to_phys(buff->data);
@@ -378,11 +363,15 @@
 	result = ib_post_send(conn->qp, &send_param, &bad_wr);
 	if (result) {
 		sdp_dbg_warn(conn, "Error <%d> posting rdma write", result);
-
-		conn->s_wq_size--;
 		goto error;
 	}
 	/*
+	 * update send queue depth
+	 */
+	conn->s_wq_size++;
+	conn->send_pipe  -= buff->data_size;
+	conn->oob_offset -= (conn->oob_offset > 0) ? buff->data_size : 0;
+	/*
 	 * If the available space is smaller then send size, complete the
 	 * advertisment.
 	 */
@@ -401,7 +390,14 @@
 		sdp_advt_destroy(sdp_advt_q_get(&conn->snk_pend));
 		conn->snk_recv--;
 	}
+	/*
+	 * dequeue buffer if needed and move to active queue
+	 */
+	if (sdp_desc_q_member((struct sdpc_desc *) buff) > 0)
+		sdp_desc_q_remove((struct sdpc_desc *) buff);
 
+	sdp_desc_q_put_tail(&conn->w_snk, (struct sdpc_desc *)buff);
+
 	return 0;
 error:
 	return result;
@@ -906,10 +902,10 @@
 	if (!sdp_advt_q_look(&conn->snk_pend) ||
 	    (((struct sdpc_buff *)element)->flags & SDP_BUFF_F_OOB_PRES))
 		result = sdp_send_data_buff_post(conn,
-						  (struct sdpc_buff *)element);
+						 (struct sdpc_buff *)element);
 	else
 		result = sdp_send_data_buff_snk(conn,
-						 (struct sdpc_buff *)element);
+						(struct sdpc_buff *)element);
 
 	return result;
 }
@@ -927,30 +923,17 @@
 	 * non-zero result is generated.
 	 * (positive: no space; negative: error)
 	 */
-	while (!result && 
-	       (element = sdp_desc_q_look_head(&conn->send_queue))) {
+	while ((element = sdp_desc_q_look_head(&conn->send_queue))) {
 		
 		result = sdp_send_data_queue_test(conn, element);
-		if (!result)
-			continue;
-		/*
-		 * error
-		 */
-		if (result < 0) {
-			sdp_dbg_warn(conn, 
-				     "Error <%d> post data <%d> during flush",
-				     result, element->type);
-			/*
-			 * check for dangling element reference,
-			 * since called functions can dequeue the
-			 * element, and not know how to requeue it.
-			 */
-			if (!sdp_desc_q_member(element))
-				sdp_desc_q_put_head(&conn->send_queue,
-						    element);
-		}
+		if (result)
+			break;
 	}
 
+	if (result < 0)
+		sdp_dbg_warn(conn, "Error <%d> post data <%d> during flush",
+			     result, element->type);
+
 	return result;
 }
 
@@ -1117,24 +1100,18 @@
 	 * As long as there are buffers, try to post  until a non-zero
 	 * result is generated. (positive: no space; negative: error)
 	 */
-	while (!result && 
-	       (element = sdp_desc_q_look_head(&conn->send_ctrl))) {
+	while ((element = sdp_desc_q_look_head(&conn->send_ctrl))) {
 
 		result = sdp_send_ctrl_buff_test(conn, 
 						 (struct sdpc_buff *)element);
-		if (!result)
-			continue;
-
-		if (result < 0) {
-			sdp_dbg_warn(conn,
-				     "Error <%d> failed to flush control msg",
-				     result);
-
-			if (!sdp_desc_q_member(element))
-				sdp_desc_q_put_head(&conn->send_ctrl, element);
-		}
+		if (result)
+			break;
 	}
 
+	if (result < 0)
+		sdp_dbg_warn(conn, "Error <%d> failed to flush control msg",
+			     result);
+
 	return result;
 }
 
@@ -1543,10 +1520,8 @@
 	/*
 	 * check mode
 	 */
-	if (conn->recv_mode != SDP_MODE_PIPE) {
-		result = -EPROTO;
-		goto error;
-	}
+	if (conn->recv_mode != SDP_MODE_PIPE)
+		return -EPROTO;
 	/*
 	 * create the message, which contains just the bsdh header.
 	 * (don't need to worry about header space reservation)
@@ -1847,25 +1822,27 @@
 	 * for transmission, and the remote host needs to be notified of
 	 * present data. (rdma ping-pong letency test...)
 	 */
-	if (!sdp_desc_q_size(&conn->send_queue)) {
-		/*
-		 * might be more aggressive then we want it to be. maybe
-		 * check if the active sink queue is empty as well?
-		 */
-		advt = sdp_advt_q_look(&conn->snk_pend);
-		if (advt && advt->post > 0) {
+	if (sdp_desc_q_size(&conn->send_queue))
+		return 0;
 
-			result = sdp_send_ctrl_rdma_wr(conn, advt->post);
-			SDP_EXPECT(result >= 0);
+	/*
+	 * might be more aggressive then we want it to be. maybe
+	 * check if the active sink queue is empty as well?
+	 */
+	advt = sdp_advt_q_look(&conn->snk_pend);
+	if (!advt || !advt->post)
+		return 0;
 
-			sdp_advt_destroy(sdp_advt_q_get(&conn->snk_pend));
-			/*
-			 * update sink advertisments.
-			 */
-			conn->snk_recv--;
-		}
-	}
+	result = sdp_send_ctrl_rdma_wr(conn, advt->post);
+	if (result < 0)
+		return result;
 
+	sdp_advt_destroy(sdp_advt_q_get(&conn->snk_pend));
+	/*
+	 * update sink advertisments.
+	 */
+	conn->snk_recv--;
+
 	return 0;
 }
 
@@ -1920,7 +1897,7 @@
 	/*
 	 * see if there is enough buffer to wake/notify writers
 	 */
-	sdp_inet_wake_send(conn->sk); /*  conn->sk->write_space(conn->sk); */
+	sdp_inet_wake_send(conn->sk);
 
 	return 0;
 done:
Index: sdp_sent.c
===================================================================
--- sdp_sent.c	(revision 2628)
+++ sdp_sent.c	(working copy)
@@ -111,202 +111,16 @@
 	return result;
 }
 
-static int sdp_sent_send_sm(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	return 0;
-}
-
-static int sdp_sent_rdma_wr(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	struct msg_hdr_rwch *rwch;
-
-	rwch = (struct msg_hdr_rwch *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_rwch);
-
-	sdp_msg_net_to_cpu_rwch(rwch);
-
-	return 0;
-}
-
-static int sdp_sent_rdma_rd(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	struct msg_hdr_rrch *rrch;
-
-	rrch = (struct msg_hdr_rrch *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_rrch);
-
-	sdp_msg_net_to_cpu_rrch(rrch);
-
-	return 0;
-}
-
-static int sdp_sent_mode_change(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	struct msg_hdr_mch *mch;
-
-	mch = (struct msg_hdr_mch *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_mch);
-
-	sdp_msg_net_to_cpu_mch(mch);
-
-	return 0;
-}
-
-static int sdp_sent_src_cancel(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	return 0;
-}
-
-static int sdp_sent_snk_cancel(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	return 0;
-}
-
-static int sdp_sent_snk_cancel_ack(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	return 0;
-}
-
-static int sdp_sent_resize_buff_ack(struct sdp_opt *conn,
-				    struct sdpc_buff *buff)
-{
-	struct msg_hdr_crbah *crbah;
-
-	crbah = (struct msg_hdr_crbah *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_crbah);
-
-	sdp_msg_net_to_cpu_crbah(crbah);
-
-	return 0;
-}
-
-static int sdp_sent_suspend(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	struct msg_hdr_sch *sch;
-
-	sch = (struct msg_hdr_sch *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_sch);
-
-	sdp_msg_net_to_cpu_sch(sch);
-
-	return 0;
-}
-
-static int sdp_sent_suspend_ack(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	return 0;
-}
-
-static int sdp_sent_snk_avail(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	struct msg_hdr_snkah *snkah;
-
-	snkah = (struct msg_hdr_snkah *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_snkah);
-
-	sdp_msg_net_to_cpu_snkah(snkah);
-
-	return 0;
-}
-
-static int sdp_sent_src_avail(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	struct msg_hdr_srcah *srcah;
-
-	srcah = (struct msg_hdr_srcah *) buff->data;
-	buff->data = buff->data + sizeof(struct msg_hdr_srcah);
-
-	sdp_msg_net_to_cpu_srcah(srcah);
-
-	return 0;
-}
-
 /*
- * sdp_sent_data - SDP data message event received
- */
-static int sdp_sent_data(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	int result = 0;
-
-	conn->send_qud -= buff->data_size;
-
-	return result;
-}
-
-/*
- * sdp_sent_unsupported - Valid messages we're not sending
- */
-static int sdp_sent_unsupported(struct sdp_opt *conn, struct sdpc_buff *buff)
-{
-	/*
-	 * Since the gateway only initates RDMA's but is never a target, and
-	 * for a few other reasons, there are certain valid SDP messages
-	 * which we never send.
-	 */
-	sdp_dbg_warn(conn, "Unexpected SDP message <%02x> sent!",
-		     buff->bsdh_hdr->mid);
-
-	return 0;
-}
-
-/*
- * Event Dispatch table. For performance a dispatch table is used to avoid
- * a giant case statment for every single SDP event. This is a bit more
- * confusing, relies on the layout of the Message IDs, and is less
- * flexable. However, it is faster.
- *
- * Sparse table, the full table would be 16x16, where the low 4 bits, of
- * the MID byte, are one dimension, and the high 4 bits are the other
- * dimension. Since all rows, except for the first and last, are empty,
- * only those are represented in the table.
- */
-static sdp_event_cb_func send_event_funcs[SDP_MSG_EVENT_TABLE_SIZE] = {
-	NULL,                     /* SDP_MID_HELLO            0x00 */
-	NULL,                     /* SDP_MID_HELLO_ACK        0x01 */
-	sdp_sent_disconnect,      /* SDP_MID_DISCONNECT       0x02 */
-	sdp_sent_abort,           /* SDP_MID_ABORT_CONN       0x03 */
-	sdp_sent_send_sm,         /* SDP_MID_SEND_SM          0x04 */
-	sdp_sent_rdma_wr,         /* SDP_MID_RDMA_WR_COMP     0x05 */
-	sdp_sent_rdma_rd,         /* SDP_MID_RDMA_RD_COMP     0x06 */
-	sdp_sent_mode_change,     /* SDP_MID_MODE_CHANGE      0x07 */
-	sdp_sent_src_cancel,      /* SDP_MID_SRC_CANCEL       0x08 */
-	sdp_sent_snk_cancel,      /* SDP_MID_SNK_CANCEL       0x09 */
-	sdp_sent_snk_cancel_ack,  /* SDP_MID_SNK_CANCEL_ACK   0x0A */
-	sdp_sent_unsupported,     /* SDP_MID_CH_RECV_BUF      0x0B */
-	sdp_sent_resize_buff_ack, /* SDP_MID_CH_RECV_BUF_ACK  0x0C */
-	sdp_sent_suspend,         /* SDP_MID_SUSPEND          0x0D */
-	sdp_sent_suspend_ack,     /* SDP_MID_SUSPEND_ACK      0x0E */
-	NULL,                     /* reserved                 0x0F */
-	NULL,                     /* reserved                 0xF0 */
-	NULL,                     /* reserved                 0xF1 */
-	NULL,                     /* reserved                 0xF2 */
-	NULL,                     /* reserved                 0xF3 */
-	NULL,                     /* reserved                 0xF4 */
-	NULL,                     /* reserved                 0xF5 */
-	NULL,                     /* reserved                 0xF6 */
-	NULL,                     /* reserved                 0xF7 */
-	NULL,                     /* reserved                 0xF8 */
-	NULL,                     /* reserved                 0xF9 */
-	NULL,                     /* reserved                 0xFA */
-	NULL,                     /* reserved                 0xFB */
-	NULL,                     /* reserved                 0xFC */
-	sdp_sent_snk_avail,       /* SDP_MID_SNK_AVAIL        0xFD */
-	sdp_sent_src_avail,       /* SDP_MID_SRC_AVAIL        0xFE */
-	sdp_sent_data             /* SDP_MID_DATA             0xFF */
-};
-
-/*
  * sdp_event_send - send event handler
  */
 int sdp_event_send(struct sdp_opt *conn, struct ib_wc *comp)
 {
-	sdp_event_cb_func dispatch_func;
-	u32 free_count = 0;
+	struct sdpc_buff *head = NULL;
+	struct sdpc_buff *buff;
 	u64 current_wrid = 0;
-	u32 offset;
+	u32 free_count = 0;
 	int result;
-	struct sdpc_buff *buff;
-	struct sdpc_buff *head = NULL;
 
 	/*
 	 * error handling
@@ -374,29 +188,47 @@
 		 * data fast path we collapse the next level dispatch function.
 		 * For all other buffers we go the slow path.
 		 */
-		if (SDP_MID_DATA == buff->bsdh_hdr->mid)
+		result = 0;
+
+		switch (buff->bsdh_hdr->mid) {
+		case SDP_MID_DATA:
 			conn->send_qud -= buff->data_size;
-		else {
-			offset = buff->bsdh_hdr->mid & 0x1F;
+			break;
+                case SDP_MID_DISCONNECT:
+			result = sdp_sent_disconnect(conn, buff);
+			break;
+		case SDP_MID_ABORT_CONN:
+			result = sdp_sent_abort(conn, buff);
+			break;
+		case SDP_MID_SEND_SM:
+		case SDP_MID_RDMA_WR_COMP:
+		case SDP_MID_RDMA_RD_COMP:
+		case SDP_MID_MODE_CHANGE:
+		case SDP_MID_SRC_CANCEL:
+		case SDP_MID_SNK_CANCEL:
+		case SDP_MID_SNK_CANCEL_ACK:
+		case SDP_MID_CH_RECV_BUF_ACK:
+		case SDP_MID_SNK_AVAIL:
+		case SDP_MID_SRC_AVAIL:
+			break;
+		case SDP_MID_CH_RECV_BUF:
+		case SDP_MID_SUSPEND:
+		case SDP_MID_SUSPEND_ACK:
+			sdp_dbg_warn(conn,
+				     "Unexpected SDP message <%02x> sent!",
+				     buff->bsdh_hdr->mid);
+			break;
+		default:
+			sdp_dbg_warn(conn, "Send complete unknown MID <%d>",
+				     buff->bsdh_hdr->mid);
+			result = -EINVAL;
+			break;
+		}
 
-			if (!(offset < SDP_MSG_EVENT_TABLE_SIZE) ||
-			    !send_event_funcs[offset]) {
-				sdp_dbg_warn(conn, 
-					     "Send complete unknown MID <%d>",
-					     buff->bsdh_hdr->mid);
-				result = -EINVAL;
-				goto drop;
-			}
-
-			SDP_CONN_STAT_SEND_MID_INC(conn, offset);
-			
-			dispatch_func = send_event_funcs[offset];
-			result = dispatch_func(conn, buff);
-			if (result < 0) {
-				sdp_dbg_warn(conn, "Sent dispatch error. <%d>",
-					     result);
-				goto drop;
-			}
+		if (result) {
+			sdp_dbg_warn(conn, "Sent dispatch error. <%d>",
+				     result);
+			goto drop;
 		}
 
 		current_wrid = buff->wrid;
Index: sdp_recv.c
===================================================================
--- sdp_recv.c	(revision 2628)
+++ sdp_recv.c	(working copy)
@@ -74,8 +74,6 @@
 	 * actually posting the thing. Completion event can happen before
 	 * post function returns.
 	 */
-	sdp_buff_q_put_tail(&conn->recv_post, buff);
-
 	sdp_dbg_data(conn, "POST RECV BUFF wrid <%llu> of <%u> bytes.",
 		     (unsigned long long) buff->wrid,
 		     (unsigned)(buff->tail - buff->data));
@@ -96,10 +94,11 @@
 	if (result) {
 		sdp_dbg_warn(conn, "Error <%d> posting receive buffer",
 			     result);
-		(void)sdp_buff_q_get_tail(&conn->recv_post);
 		goto drop;
 	}
 
+	sdp_buff_q_put_tail(&conn->recv_post, buff);
+
 	return 0;
 drop:
 	sdp_buff_pool_put(buff);
@@ -122,26 +121,21 @@
 	/*
 	 * check queue depth
 	 */
-	if (!(conn->send_cq_size > conn->s_wq_size)) {
-		result = ENODEV;
-		goto done;
-	}
+	if (!(conn->send_cq_size > conn->s_wq_size))
+		return ENODEV;
 	/*
 	 * get a reference to the first SrcAvail advertisment.
 	 */
 	advt = sdp_advt_q_look(&conn->src_pend);
-	if (!advt) {
-		result = ENODEV;
-		goto done;
-	}
+	if (!advt)
+		return ENODEV;
 	/*
 	 * get a buffer
 	 */
 	buff = sdp_buff_pool_get();
 	if (!buff) {
 		sdp_dbg_warn(conn, "failed to allocate buff for rdma read.");
-		result = -ENOMEM;
-		goto error;
+		return -ENOMEM;
 	}
 	/*
 	 * The data pointer is backed up based on what the stream interface
@@ -171,21 +165,11 @@
 	if (advt->size <= 0)
 		sdp_advt_q_put(&conn->src_actv,
 			       sdp_advt_q_get(&conn->src_pend));
-	/*
-	 * save the buffer for the event handler. Make sure it's before
-	 * actually posting the thing. Completion event can happen before
-	 * post function returns.
-	 */
-	sdp_desc_q_put_tail(&conn->r_src, (struct sdpc_desc *) buff);
 
 	sdp_dbg_data(conn, "POST READ BUFF wrid <%llu> of <%u> bytes.",
 		     (unsigned long long) buff->wrid,
 		     (unsigned)(buff->tail - buff->data));
 	/*
-	 * update send queue depth
-	 */
-	conn->s_wq_size++;
-	/*
 	 * post rdma
 	 */
 	buff->sge.addr     = virt_to_phys(buff->data);
@@ -199,18 +183,18 @@
 	result = ib_post_send(conn->qp, &send_param, &bad_wr);
 	if (result) {
 		sdp_dbg_warn(conn, "Error <%d> posting rdma read", result);
-
-		(void)sdp_desc_q_get_tail(&conn->r_src);
-		conn->s_wq_size--;
-
 		goto drop;
 	}
+	/*
+	 * Save buffer and update send queue depth
+	 */
+	sdp_desc_q_put_tail(&conn->r_src, (struct sdpc_desc *) buff);
 
+	conn->s_wq_size++;
+
 	return 0;
 drop:
 	sdp_buff_pool_put(buff);
-error:
-done:
 	return result;
 }
 
@@ -230,18 +214,14 @@
 	/*
 	 * check queue depth
 	 */
-	if (!(conn->send_cq_size > conn->s_wq_size)) {
-		result = ENODEV;
-		goto done;
-	}
+	if (!(conn->send_cq_size > conn->s_wq_size))
+		return ENODEV;
 	/*
 	 * get a reference to the first SrcAvail advertisment.
 	 */
 	advt = sdp_advt_q_look(&conn->src_pend);
-	if (!advt) {
-		result = ENODEV;
-		goto done;
-	}
+	if (!advt)
+		return ENODEV;
 	/*
 	 * get a reference to the first IOCB pending.
 	 *
@@ -249,10 +229,8 @@
 	 * (final complete RDMA will clear it out.)
 	 */
 	iocb = sdp_iocb_q_look(&conn->r_pend);
-	if (!iocb) {
-		result = ENODEV;
-		goto done;
-	}
+	if (!iocb)
+		return ENODEV;
 	/*
 	 * register IOCBs physical memory.
 	 */
@@ -307,10 +285,6 @@
 		     (unsigned long long) iocb->wrid, zcopy,
 		     iocb->len, advt->size);
 	/*
-	 * update send queue depth
-	 */
-	conn->s_wq_size++;
-	/*
 	 * post RDMA
 	 */
 	send_param.next    = NULL;
@@ -321,13 +295,15 @@
 	result = ib_post_send(conn->qp, &send_param, &bad_wr);
 	if (result) {
 		sdp_dbg_warn(conn, "Error <%d> posting rdma read", result);
-		conn->s_wq_size--;
 		goto error;
 	}
+	/*
+	 * update send queue depth
+	 */
+	conn->s_wq_size++;
 
 	return 0;
 error:
-done:
 	return result;
 }
 
@@ -342,32 +318,24 @@
 	/*
 	 * check if sink cancel is pending
 	 */
-	if (conn->flags & SDP_CONN_F_SNK_CANCEL) {
-		result = ENODEV;
-		goto error;
-	}
+	if (conn->flags & SDP_CONN_F_SNK_CANCEL)
+		return ENODEV;
 	/*
 	 * get the pending iocb
 	 */
 	iocb = sdp_iocb_q_look(&conn->r_pend);
-	if (!iocb) {
-		result = ENODEV;
-		goto error;
-	}
+	if (!iocb)
+		return ENODEV;
 	/*
 	 * check zcopy threshold
 	 */
-	if (conn->snk_zthresh > iocb->len) {
-		result = ENODEV;
-		goto error;
-	}
+	if (conn->snk_zthresh > iocb->len)
+		return ENODEV;
 	/*
 	 * check number of outstanding sink advertisments
 	 */
-	if (!(conn->r_max_adv > conn->snk_sent)) {
-		result = ENODEV;
-		goto error;
-	}
+	if (!(conn->r_max_adv > conn->snk_sent))
+		return ENODEV;
 	/*
 	 * registration
 	 */
@@ -381,15 +349,6 @@
 		goto error;
 	}
 	/*
-	 * IOCB
-	 */
-	iocb->flags |= SDP_IOCB_F_ACTIVE;
-	iocb->flags |= SDP_IOCB_F_RDMA_W;
-	/*
-	 * queue IOCB
-	 */
-	sdp_iocb_q_put_tail(&conn->r_snk, sdp_iocb_q_get_head(&conn->r_pend));
-	/*
 	 * Either post a send, or buffer the packet in the tx queue
 	 */
 	result = sdp_send_ctrl_snk_avail(conn,
@@ -399,16 +358,16 @@
 	if (result < 0) {
 		sdp_dbg_warn(conn, "Error <%d> sending SnkAvail message",
 			     result);
-
-		sdp_iocb_q_put_head(&conn->r_pend, 
-				    sdp_iocb_q_get_tail(&conn->r_snk));
-
-		iocb->flags &= ~SDP_IOCB_F_ACTIVE;
-		iocb->flags &= ~SDP_IOCB_F_RDMA_W;
-
 		goto error;
 	}
+	/*
+	 * Update and queue IOCB
+	 */
+	iocb->flags |= SDP_IOCB_F_ACTIVE;
+	iocb->flags |= SDP_IOCB_F_RDMA_W;
 
+	sdp_iocb_q_put_tail(&conn->r_snk, sdp_iocb_q_get_head(&conn->r_pend));
+
 	conn->snk_sent++;
 
 	return 0;
@@ -1011,7 +970,6 @@
 	u8 update;
 
 	if (buff->flags & SDP_BUFF_F_OOB_PRES) {
-		SDP_EXPECT((buff->tail > buff->data));
 
 		update = *value;
 		*value = *(u8 *) (buff->tail - 1);
@@ -1081,13 +1039,9 @@
 			buff = sdp_buff_q_fetch(&conn->recv_pool,
 						sdp_inet_recv_urg_test,
 						(void *)0);
-			if (buff) {
+			if (buff)
 				sdp_buff_pool_put(buff);
 
-				result = sdp_recv_flush(conn);
-				SDP_EXPECT(result >= 0);
-			}
-
 			result = 1;
 		}
 	} else {
@@ -1157,6 +1111,9 @@
 		result = sdp_inet_recv_urg(sk, msg, size, flags);
 		copied = (result > 0) ? result : 0;
 		result = (result > 0) ? 0 : result;
+
+		if (copied)
+			ack = copied;
 		goto done;
 	}
 	/*



More information about the general mailing list