]> err.no Git - linux-2.6/commitdiff
[CCID3]: Move ccid3_hc_rx_add_hist to packet_history.c
authorArnaldo Carvalho de Melo <acme@mandriva.com>
Sun, 28 Aug 2005 04:19:14 +0000 (01:19 -0300)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 29 Aug 2005 23:13:10 +0000 (16:13 -0700)
Renaming it to dccp_rx_hist_add_packet.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dccp/ccids/ccid3.c
net/dccp/ccids/ccid3.h
net/dccp/ccids/lib/packet_history.c
net/dccp/ccids/lib/packet_history.h

index a215c46d6f1bd08c2ce91f219a44935132c92b24..849f5580efbd2b6dd4d586a6d34f8aaa9ca68d6f 100644 (file)
@@ -744,125 +744,6 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk,
        hcrx->ccid3hcrx_state = state;
 }
 
-static int ccid3_hc_rx_add_hist(struct sock *sk,
-                               struct dccp_rx_hist_entry *packet)
-{
-       struct dccp_sock *dp = dccp_sk(sk);
-       struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
-       struct dccp_rx_hist_entry *entry, *next, *iter;
-       u8 num_later = 0;
-
-       iter = dccp_rx_hist_head(&hcrx->ccid3hcrx_hist);
-       if (iter == NULL)
-               dccp_rx_hist_add_entry(&hcrx->ccid3hcrx_hist, packet);
-       else {
-               const u64 seqno = packet->dccphrx_seqno;
-
-               if (after48(seqno, iter->dccphrx_seqno))
-                       dccp_rx_hist_add_entry(&hcrx->ccid3hcrx_hist, packet);
-               else {
-                       if (dccp_rx_hist_entry_data_packet(iter))
-                               num_later = 1;
-
-                       list_for_each_entry_continue(iter,
-                                                    &hcrx->ccid3hcrx_hist,
-                                                    dccphrx_node) {
-                               if (after48(seqno, iter->dccphrx_seqno)) {
-                                       dccp_rx_hist_add_entry(&iter->dccphrx_node,
-                                                              packet);
-                                       goto trim_history;
-                               }
-
-                               if (dccp_rx_hist_entry_data_packet(iter))
-                                       num_later++;
-
-                               if (num_later == TFRC_RECV_NUM_LATE_LOSS) {
-                                       dccp_rx_hist_entry_delete(ccid3_rx_hist,
-                                                                 packet);
-                                       ccid3_pr_debug("%s, sk=%p, packet"
-                                                      "(%llu) already lost!\n",
-                                                      dccp_role(sk), sk,
-                                                      seqno);
-                                       return 1;
-                               }
-                       }
-
-                       if (num_later < TFRC_RECV_NUM_LATE_LOSS)
-                               dccp_rx_hist_add_entry(&hcrx->ccid3hcrx_hist,
-                                                      packet);
-                       /*
-                        * FIXME: else what? should we destroy the packet
-                        * like above?
-                        */
-               }
-       }
-
-trim_history:
-       /*
-        * Trim history (remove all packets after the NUM_LATE_LOSS + 1
-        * data packets)
-        */
-       num_later = TFRC_RECV_NUM_LATE_LOSS + 1;
-
-       if (!list_empty(&hcrx->ccid3hcrx_li_hist)) {
-               list_for_each_entry_safe(entry, next, &hcrx->ccid3hcrx_hist,
-                                        dccphrx_node) {
-                       if (num_later == 0) {
-                               list_del_init(&entry->dccphrx_node);
-                               dccp_rx_hist_entry_delete(ccid3_rx_hist, entry);
-                       } else if (dccp_rx_hist_entry_data_packet(entry))
-                               --num_later;
-               }
-       } else {
-               int step = 0;
-               u8 win_count = 0; /* Not needed, but lets shut up gcc */
-               int tmp;
-               /*
-                * We have no loss interval history so we need at least one
-                * rtt:s of data packets to approximate rtt.
-                */
-               list_for_each_entry_safe(entry, next, &hcrx->ccid3hcrx_hist,
-                                        dccphrx_node) {
-                       if (num_later == 0) {
-                               switch (step) {
-                               case 0:
-                                       step = 1;
-                                       /* OK, find next data packet */
-                                       num_later = 1;
-                                       break;
-                               case 1:
-                                       step = 2;
-                                       /* OK, find next data packet */
-                                       num_later = 1;
-                                       win_count = entry->dccphrx_ccval;
-                                       break;
-                               case 2:
-                                       tmp = win_count - entry->dccphrx_ccval;
-                                       if (tmp < 0)
-                                               tmp += TFRC_WIN_COUNT_LIMIT;
-                                       if (tmp > TFRC_WIN_COUNT_PER_RTT + 1) {
-                                               /*
-                                                * We have found a packet older
-                                                * than one rtt remove the rest
-                                                */
-                                               step = 3;
-                                       } else /* OK, find next data packet */
-                                               num_later = 1;
-                                       break;
-                               case 3:
-                                       list_del_init(&entry->dccphrx_node);
-                                       dccp_rx_hist_entry_delete(ccid3_rx_hist,
-                                                                 entry);
-                                       break;
-                               }
-                       } else if (dccp_rx_hist_entry_data_packet(entry))
-                               --num_later;
-               }
-       }
-
-       return 0;
-}
-
 static void ccid3_hc_rx_send_feedback(struct sock *sk)
 {
        struct dccp_sock *dp = dccp_sk(sk);
@@ -1185,7 +1066,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
 
        win_count = packet->dccphrx_ccval;
 
-       ins = ccid3_hc_rx_add_hist(sk, packet);
+       ins = dccp_rx_hist_add_packet(ccid3_rx_hist, &hcrx->ccid3hcrx_hist,
+                                     &hcrx->ccid3hcrx_li_hist, packet);
 
        if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK)
                return;
index f68d0b4e31e9683b98284f6d8f22977cb22c8649..ee8cbace6630a6ca443679d428000b0b2a602d25 100644 (file)
 /* In usecs - half the scheduling granularity as per RFC3448 4.6 */
 #define TFRC_OPSYS_HALF_TIME_GRAN  (USEC_PER_SEC / (2 * HZ))
 
-#define TFRC_WIN_COUNT_PER_RTT     4
-#define TFRC_WIN_COUNT_LIMIT      16
-
 /* In seconds */
 #define TFRC_MAX_BACK_OFF_TIME    64
 
 #define TFRC_SMALLEST_P                   40
 
-/* Number of later packets received before one is considered lost */
-#define TFRC_RECV_NUM_LATE_LOSS        3
-
 enum ccid3_options {
        TFRC_OPT_LOSS_EVENT_RATE = 192,
        TFRC_OPT_LOSS_INTERVALS  = 193,
index f252a9555e313b97fe86e2fd1f2d0f67c60afe0c..e2576b45ac0b67a272f313698130b20fcbe811b0 100644 (file)
@@ -113,6 +113,117 @@ struct dccp_rx_hist_entry *
 
 EXPORT_SYMBOL_GPL(dccp_rx_hist_find_data_packet);
 
+int dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
+                           struct list_head *rx_list,
+                           struct list_head *li_list,
+                           struct dccp_rx_hist_entry *packet)
+{
+       struct dccp_rx_hist_entry *entry, *next, *iter;
+       u8 num_later = 0;
+
+       iter = dccp_rx_hist_head(rx_list);
+       if (iter == NULL)
+               dccp_rx_hist_add_entry(rx_list, packet);
+       else {
+               const u64 seqno = packet->dccphrx_seqno;
+
+               if (after48(seqno, iter->dccphrx_seqno))
+                       dccp_rx_hist_add_entry(rx_list, packet);
+               else {
+                       if (dccp_rx_hist_entry_data_packet(iter))
+                               num_later = 1;
+
+                       list_for_each_entry_continue(iter, rx_list,
+                                                    dccphrx_node) {
+                               if (after48(seqno, iter->dccphrx_seqno)) {
+                                       dccp_rx_hist_add_entry(&iter->dccphrx_node,
+                                                              packet);
+                                       goto trim_history;
+                               }
+
+                               if (dccp_rx_hist_entry_data_packet(iter))
+                                       num_later++;
+
+                               if (num_later == TFRC_RECV_NUM_LATE_LOSS) {
+                                       dccp_rx_hist_entry_delete(hist, packet);
+                                       return 1;
+                               }
+                       }
+
+                       if (num_later < TFRC_RECV_NUM_LATE_LOSS)
+                               dccp_rx_hist_add_entry(rx_list, packet);
+                       /*
+                        * FIXME: else what? should we destroy the packet
+                        * like above?
+                        */
+               }
+       }
+
+trim_history:
+       /*
+        * Trim history (remove all packets after the NUM_LATE_LOSS + 1
+        * data packets)
+        */
+       num_later = TFRC_RECV_NUM_LATE_LOSS + 1;
+
+       if (!list_empty(li_list)) {
+               list_for_each_entry_safe(entry, next, rx_list, dccphrx_node) {
+                       if (num_later == 0) {
+                               list_del_init(&entry->dccphrx_node);
+                               dccp_rx_hist_entry_delete(hist, entry);
+                       } else if (dccp_rx_hist_entry_data_packet(entry))
+                               --num_later;
+               }
+       } else {
+               int step = 0;
+               u8 win_count = 0; /* Not needed, but lets shut up gcc */
+               int tmp;
+               /*
+                * We have no loss interval history so we need at least one
+                * rtt:s of data packets to approximate rtt.
+                */
+               list_for_each_entry_safe(entry, next, rx_list, dccphrx_node) {
+                       if (num_later == 0) {
+                               switch (step) {
+                               case 0:
+                                       step = 1;
+                                       /* OK, find next data packet */
+                                       num_later = 1;
+                                       break;
+                               case 1:
+                                       step = 2;
+                                       /* OK, find next data packet */
+                                       num_later = 1;
+                                       win_count = entry->dccphrx_ccval;
+                                       break;
+                               case 2:
+                                       tmp = win_count - entry->dccphrx_ccval;
+                                       if (tmp < 0)
+                                               tmp += TFRC_WIN_COUNT_LIMIT;
+                                       if (tmp > TFRC_WIN_COUNT_PER_RTT + 1) {
+                                               /*
+                                                * We have found a packet older
+                                                * than one rtt remove the rest
+                                                */
+                                               step = 3;
+                                       } else /* OK, find next data packet */
+                                               num_later = 1;
+                                       break;
+                               case 3:
+                                       list_del_init(&entry->dccphrx_node);
+                                       dccp_rx_hist_entry_delete(hist, entry);
+                                       break;
+                               }
+                       } else if (dccp_rx_hist_entry_data_packet(entry))
+                               --num_later;
+               }
+       }
+
+       return 0;
+}
+
+EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet);
+
 struct dccp_tx_hist *dccp_tx_hist_new(const char *name)
 {
        struct dccp_tx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC);
index 235828d822d9d033ec59b0f2465800eac3069794..ebfcb8e2c6768991696b755282e8e3a2b0f36eab 100644 (file)
 
 #include "../../dccp.h"
 
+/* Number of later packets received before one is considered lost */
+#define TFRC_RECV_NUM_LATE_LOSS         3
+
+#define TFRC_WIN_COUNT_PER_RTT  4
+#define TFRC_WIN_COUNT_LIMIT   16
+
 struct dccp_tx_hist_entry {
        struct list_head dccphtx_node;
        u64              dccphtx_seqno:48,
@@ -182,4 +188,9 @@ static inline int
               entry->dccphrx_type == DCCP_PKT_DATAACK;
 }
 
+extern int dccp_rx_hist_add_packet(struct dccp_rx_hist *hist,
+                                  struct list_head *rx_list,
+                                  struct list_head *li_list,
+                                  struct dccp_rx_hist_entry *packet);
+
 #endif /* _DCCP_PKT_HIST_ */