netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, allan.stephens@windriver.com,
	ying.xue@windriver.com,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [PATCH net-next 01/15] tipc: improve the link deferred queue insertion algorithm
Date: Mon,  6 Feb 2012 19:52:34 -0500	[thread overview]
Message-ID: <1328575968-20643-2-git-send-email-paul.gortmaker@windriver.com> (raw)
In-Reply-To: <1328575968-20643-1-git-send-email-paul.gortmaker@windriver.com>

From: Allan Stephens <allan.stephens@windriver.com>

Re-code the algorithm for inserting an out-of-sequence message into
a unicast or broadcast link's deferred message queue.  It remains
functionally equivalent but should be easier to understand/maintain.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 net/tipc/link.c |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/net/tipc/link.c b/net/tipc/link.c
index ac1832a..c317abf 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1853,17 +1853,16 @@ cont:
 }
 
 /*
- * link_defer_buf(): Sort a received out-of-sequence packet
- *                   into the deferred reception queue.
- * Returns the increase of the queue length,i.e. 0 or 1
+ * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue
+ *
+ * Returns increase in queue length (i.e. 0 or 1)
  */
 
-u32 tipc_link_defer_pkt(struct sk_buff **head,
-			struct sk_buff **tail,
+u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
 			struct sk_buff *buf)
 {
-	struct sk_buff *prev = NULL;
-	struct sk_buff *crs = *head;
+	struct sk_buff *queue_buf;
+	struct sk_buff **prev;
 	u32 seq_no = buf_seqno(buf);
 
 	buf->next = NULL;
@@ -1881,31 +1880,30 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
 		return 1;
 	}
 
-	/* Scan through queue and sort it in */
-	do {
-		struct tipc_msg *msg = buf_msg(crs);
+	/* Locate insertion point in queue, then insert; discard if duplicate */
+	prev = head;
+	queue_buf = *head;
+	for (;;) {
+		u32 curr_seqno = buf_seqno(queue_buf);
 
-		if (less(seq_no, msg_seqno(msg))) {
-			buf->next = crs;
-			if (prev)
-				prev->next = buf;
-			else
-				*head = buf;
-			return 1;
+		if (seq_no == curr_seqno) {
+			buf_discard(buf);
+			return 0;
 		}
-		if (seq_no == msg_seqno(msg))
+
+		if (less(seq_no, curr_seqno))
 			break;
-		prev = crs;
-		crs = crs->next;
-	} while (crs);
 
-	/* Message is a duplicate of an existing message */
+		prev = &queue_buf->next;
+		queue_buf = queue_buf->next;
+	}
 
-	buf_discard(buf);
-	return 0;
+	buf->next = queue_buf;
+	*prev = buf;
+	return 1;
 }
 
-/**
+/*
  * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
  */
 
-- 
1.7.9

  reply	other threads:[~2012-02-07  0:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07  0:52 [PATCH net-next 00/15] TIPC updates for upcoming v3.4 Paul Gortmaker
2012-02-07  0:52 ` Paul Gortmaker [this message]
2012-02-07  0:52 ` [PATCH net-next 02/15] tipc: Prevent transmission of outdated link protocol messages Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 03/15] tipc: Prevent broadcast link stalling in dual LAN environments Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 04/15] tipc: Ensure broadcast link re-acquires node after link failure Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 05/15] tipc: Fix problem with broadcast link synchronization between nodes Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 06/15] tipc: Add missing broadcast link lock when sending NACK Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 07/15] tipc: Fix node lock reclamation issues in broadcast link reception Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 08/15] tipc: Fix bug in broadcast link duplicate message statistics Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 09/15] tipc: Add missing locks in broadcast link statistics accumulation Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 10/15] tipc: Major redesign of broadcast link ACK/NACK algorithms Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 11/15] tipc: Remove obsolete broadcast tag capability Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 12/15] tipc: Prevent loss of fragmented messages over unicast links Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 13/15] tipc: Prevent loss of fragmented messages over broadcast link Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 14/15] tipc: Eliminate alteration of publication key during name table purging Paul Gortmaker
2012-02-07  0:52 ` [PATCH net-next 15/15] tipc: Minor optimization to rejection of connection-based messages Paul Gortmaker
2012-02-07 17:33 ` [PATCH net-next 00/15] TIPC updates for upcoming v3.4 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328575968-20643-2-git-send-email-paul.gortmaker@windriver.com \
    --to=paul.gortmaker@windriver.com \
    --cc=allan.stephens@windriver.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).