aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:41 -0400
commit2f3e3bbad917c426d3aba03a535809e5699de156 (patch)
treee00bd5c8ccfad4444e8cc6ee8eb0d90223292390 /net/dccp
parent34a081be8e14b7ada70e069b65b05d54db4af497 (diff)
dccp ccid-3: Remove duplicate RX states
The only state information that the CCID-3 receiver keeps is whether initial feedback has been sent or not. Further, this overlaps with use of feedback: * state == TFRC_RSTATE_NO_DATA as long as no feedback has been sent; * state == TFRC_RSTATE_DATA as soon as the first feedback has been sent. This patch reduces the duplication, by memorising the type of the last feedback. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp')
-rw-r--r--net/dccp/ccids/ccid3.c47
-rw-r--r--net/dccp/ccids/ccid3.h14
2 files changed, 13 insertions, 48 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 8744590acb34..04b183548aa8 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -528,40 +528,6 @@ static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
528/* 528/*
529 * Receiver Half-Connection Routines 529 * Receiver Half-Connection Routines
530 */ 530 */
531
532/* CCID3 feedback types */
533enum ccid3_fback_type {
534 CCID3_FBACK_NONE = 0,
535 CCID3_FBACK_INITIAL,
536 CCID3_FBACK_PERIODIC,
537 CCID3_FBACK_PARAM_CHANGE
538};
539
540#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
541static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state)
542{
543 static char *ccid3_rx_state_names[] = {
544 [TFRC_RSTATE_NO_DATA] = "NO_DATA",
545 [TFRC_RSTATE_DATA] = "DATA",
546 };
547
548 return ccid3_rx_state_names[state];
549}
550#endif
551
552static void ccid3_hc_rx_set_state(struct sock *sk,
553 enum ccid3_hc_rx_states state)
554{
555 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
556 enum ccid3_hc_rx_states oldstate = hcrx->state;
557
558 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
559 dccp_role(sk), sk, ccid3_rx_state_name(oldstate),
560 ccid3_rx_state_name(state));
561 WARN_ON(state == oldstate);
562 hcrx->state = state;
563}
564
565static void ccid3_hc_rx_send_feedback(struct sock *sk, 531static void ccid3_hc_rx_send_feedback(struct sock *sk,
566 const struct sk_buff *skb, 532 const struct sk_buff *skb,
567 enum ccid3_fback_type fbtype) 533 enum ccid3_fback_type fbtype)
@@ -577,7 +543,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
577 hcrx->p_inverse = ~0U; /* see RFC 4342, 8.5 */ 543 hcrx->p_inverse = ~0U; /* see RFC 4342, 8.5 */
578 break; 544 break;
579 case CCID3_FBACK_PARAM_CHANGE: 545 case CCID3_FBACK_PARAM_CHANGE:
580 if (unlikely(hcrx->state == TFRC_RSTATE_NO_DATA)) { 546 if (unlikely(hcrx->feedback == CCID3_FBACK_NONE)) {
581 /* 547 /*
582 * rfc3448bis-06, 6.3.1: First packet(s) lost or marked 548 * rfc3448bis-06, 6.3.1: First packet(s) lost or marked
583 * FIXME: in rfc3448bis the receiver returns X_recv=0 549 * FIXME: in rfc3448bis the receiver returns X_recv=0
@@ -626,6 +592,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
626 hcrx->tstamp_last_feedback = now; 592 hcrx->tstamp_last_feedback = now;
627 hcrx->last_counter = dccp_hdr(skb)->dccph_ccval; 593 hcrx->last_counter = dccp_hdr(skb)->dccph_ccval;
628 hcrx->hist.bytes_recvd = 0; 594 hcrx->hist.bytes_recvd = 0;
595 hcrx->feedback = fbtype;
629 596
630 dp->dccps_hc_rx_insert_options = 1; 597 dp->dccps_hc_rx_insert_options = 1;
631 dccp_send_ack(sk); 598 dccp_send_ack(sk);
@@ -675,7 +642,7 @@ static u32 ccid3_first_li(struct sock *sk)
675 * to give the equivalent of X_target = s/(2*R). Thus fval = 2 and so p 642 * to give the equivalent of X_target = s/(2*R). Thus fval = 2 and so p
676 * is about 20.64%. This yields an interval length of 4.84 (rounded up). 643 * is about 20.64%. This yields an interval length of 4.84 (rounded up).
677 */ 644 */
678 if (unlikely(hcrx->state == TFRC_RSTATE_NO_DATA)) 645 if (unlikely(hcrx->feedback == CCID3_FBACK_NONE))
679 return 5; 646 return 5;
680 647
681 if (hcrx->rtt == 0) { 648 if (hcrx->rtt == 0) {
@@ -719,11 +686,9 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
719 goto done_receiving; 686 goto done_receiving;
720 } 687 }
721 688
722 if (unlikely(hcrx->state == TFRC_RSTATE_NO_DATA)) { 689 if (unlikely(hcrx->feedback == CCID3_FBACK_NONE)) {
723 if (is_data_packet) { 690 if (is_data_packet)
724 do_feedback = CCID3_FBACK_INITIAL; 691 do_feedback = CCID3_FBACK_INITIAL;
725 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
726 }
727 goto update_records; 692 goto update_records;
728 } 693 }
729 694
@@ -764,7 +729,6 @@ static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
764{ 729{
765 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid); 730 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid);
766 731
767 hcrx->state = TFRC_RSTATE_NO_DATA;
768 tfrc_lh_init(&hcrx->li_hist); 732 tfrc_lh_init(&hcrx->li_hist);
769 return tfrc_rx_hist_init(&hcrx->hist, sk); 733 return tfrc_rx_hist_init(&hcrx->hist, sk);
770} 734}
@@ -779,7 +743,6 @@ static void ccid3_hc_rx_exit(struct sock *sk)
779 743
780static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) 744static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
781{ 745{
782 info->tcpi_ca_state = ccid3_hc_rx_sk(sk)->state;
783 info->tcpi_options |= TCPI_OPT_TIMESTAMPS; 746 info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
784 info->tcpi_rcv_rtt = ccid3_hc_rx_sk(sk)->rtt; 747 info->tcpi_rcv_rtt = ccid3_hc_rx_sk(sk)->rtt;
785} 748}
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 0c4fadd85f94..72e110a1100f 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -114,16 +114,18 @@ static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
114 return hctx; 114 return hctx;
115} 115}
116 116
117/* TFRC receiver states */ 117
118enum ccid3_hc_rx_states { 118enum ccid3_fback_type {
119 TFRC_RSTATE_NO_DATA = 1, 119 CCID3_FBACK_NONE = 0,
120 TFRC_RSTATE_DATA, 120 CCID3_FBACK_INITIAL,
121 CCID3_FBACK_PERIODIC,
122 CCID3_FBACK_PARAM_CHANGE
121}; 123};
122 124
123/** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket 125/** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket
124 * 126 *
125 * @last_counter - Tracks window counter (RFC 4342, 8.1) 127 * @last_counter - Tracks window counter (RFC 4342, 8.1)
126 * @state - Receiver state, one of %ccid3_hc_rx_states 128 * @feedback - The type of the feedback last sent
127 * @x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3) 129 * @x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3)
128 * @rtt - Receiver estimate of RTT 130 * @rtt - Receiver estimate of RTT
129 * @tstamp_last_feedback - Time at which last feedback was sent 131 * @tstamp_last_feedback - Time at which last feedback was sent
@@ -133,7 +135,7 @@ enum ccid3_hc_rx_states {
133 */ 135 */
134struct ccid3_hc_rx_sock { 136struct ccid3_hc_rx_sock {
135 u8 last_counter:4; 137 u8 last_counter:4;
136 enum ccid3_hc_rx_states state:8; 138 enum ccid3_fback_type feedback:4;
137 u32 x_recv; 139 u32 x_recv;
138 u32 rtt; 140 u32 rtt;
139 ktime_t tstamp_last_feedback; 141 ktime_t tstamp_last_feedback;