aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
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:34 -0400
commitce177ae2e6b196659e93a9408cc1f5f13f206d13 (patch)
tree4ecd5266014cb5214c9e4955e753331f9fb23645 /net/dccp/ccids
parent535c55df136ad2783d444e54d518a8fae8bdbf79 (diff)
dccp ccid-3: Remove redundant 'options_received' struct
The `options_received' struct is redundant, since it re-duplicates the existing `p' and `x_recv' fields. This patch removes the sub-struct and migrates the format conversion operations (cf. below) to ccid3_hc_tx_parse_options(). Why the fields are redundant ---------------------------- The Loss Event Rate p and the Receive Rate x_recv are initially 0 when first loading CCID-3, as ccid_new() zeroes out the entire ccid3_hc_tx_sock. When Loss Event Rate or Receive Rate options are received, they are stored by ccid3_hc_tx_parse_options() into the fields `ccid3or_loss_event_rate' and `ccid3or_receive_rate' of the sub-struct `options_received' in ccid3_hc_tx_sock. After parsing (considering only the established state - dccp_rcv_established()), the packet is passed on to ccid_hc_tx_packet_recv(). This calls the CCID-3 specific routine ccid3_hc_tx_packet_recv(), which performs the following copy operations between fields of ccid3_hc_tx_sock: * hctx->options_received.ccid3or_receive_rate is copied into hctx->x_recv, after scaling it for fixpoint arithmetic, by 2^64; * hctx->options_received.ccid3or_loss_event_rate is copied into hctx->p, considering the above special cases; in addition, a value of 0 here needs to be mapped into p=0 (when no Loss Event Rate option has been received yet). Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid3.c24
-rw-r--r--net/dccp/ccids/ccid3.h7
2 files changed, 8 insertions, 23 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 206204551f4d..e7db8a4ee642 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -370,11 +370,10 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more,
370static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) 370static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
371{ 371{
372 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 372 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
373 struct ccid3_options_received *opt_recv = &hctx->options_received;
374 struct tfrc_tx_hist_entry *acked; 373 struct tfrc_tx_hist_entry *acked;
375 ktime_t now; 374 ktime_t now;
376 unsigned long t_nfb; 375 unsigned long t_nfb;
377 u32 pinv, r_sample; 376 u32 r_sample;
378 377
379 /* we are only interested in ACKs */ 378 /* we are only interested in ACKs */
380 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || 379 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
@@ -404,17 +403,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
404 r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, acked->stamp)); 403 r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, acked->stamp));
405 hctx->rtt = tfrc_ewma(hctx->rtt, r_sample, 9); 404 hctx->rtt = tfrc_ewma(hctx->rtt, r_sample, 9);
406 405
407 /* Update receive rate in units of 64 * bytes/second */
408 hctx->x_recv = opt_recv->ccid3or_receive_rate;
409 hctx->x_recv <<= 6;
410
411 /* Update loss event rate (which is scaled by 1e6) */
412 pinv = opt_recv->ccid3or_loss_event_rate;
413 if (pinv == 0)
414 hctx->p = 0;
415 else
416 hctx->p = tfrc_invert_loss_event_rate(pinv);
417
418 /* 406 /*
419 * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3 407 * Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
420 */ 408 */
@@ -487,7 +475,6 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, u8 packet_type,
487 u8 option, u8 *optval, u8 optlen) 475 u8 option, u8 *optval, u8 optlen)
488{ 476{
489 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 477 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
490 struct ccid3_options_received *opt_recv = &hctx->options_received;
491 __be32 opt_val; 478 __be32 opt_val;
492 479
493 switch (option) { 480 switch (option) {
@@ -504,11 +491,16 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, u8 packet_type,
504 opt_val = ntohl(get_unaligned((__be32 *)optval)); 491 opt_val = ntohl(get_unaligned((__be32 *)optval));
505 492
506 if (option == TFRC_OPT_RECEIVE_RATE) { 493 if (option == TFRC_OPT_RECEIVE_RATE) {
507 opt_recv->ccid3or_receive_rate = opt_val; 494 /* Receive Rate is kept in units of 64 bytes/second */
495 hctx->x_recv = opt_val;
496 hctx->x_recv <<= 6;
497
508 ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n", 498 ccid3_pr_debug("%s(%p), RECEIVE_RATE=%u\n",
509 dccp_role(sk), sk, opt_val); 499 dccp_role(sk), sk, opt_val);
510 } else { 500 } else {
511 opt_recv->ccid3or_loss_event_rate = opt_val; 501 /* Update the fixpoint Loss Event Rate fraction */
502 hctx->p = tfrc_invert_loss_event_rate(opt_val);
503
512 ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n", 504 ccid3_pr_debug("%s(%p), LOSS_EVENT_RATE=%u\n",
513 dccp_role(sk), sk, opt_val); 505 dccp_role(sk), sk, opt_val);
514 } 506 }
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 2268785ae8ee..ae210786c895 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -70,11 +70,6 @@ enum ccid3_options {
70 TFRC_OPT_RECEIVE_RATE = 194, 70 TFRC_OPT_RECEIVE_RATE = 194,
71}; 71};
72 72
73struct ccid3_options_received {
74 u32 ccid3or_loss_event_rate;
75 u32 ccid3or_receive_rate;
76};
77
78/* TFRC sender states */ 73/* TFRC sender states */
79enum ccid3_hc_tx_states { 74enum ccid3_hc_tx_states {
80 TFRC_SSTATE_NO_SENT = 1, 75 TFRC_SSTATE_NO_SENT = 1,
@@ -101,7 +96,6 @@ enum ccid3_hc_tx_states {
101 * @t_ld - Time last doubled during slow start 96 * @t_ld - Time last doubled during slow start
102 * @t_nom - Nominal send time of next packet 97 * @t_nom - Nominal send time of next packet
103 * @hist - Packet history 98 * @hist - Packet history
104 * @options_received - Parsed set of retrieved options
105 */ 99 */
106struct ccid3_hc_tx_sock { 100struct ccid3_hc_tx_sock {
107 u64 x; 101 u64 x;
@@ -119,7 +113,6 @@ struct ccid3_hc_tx_sock {
119 ktime_t t_ld; 113 ktime_t t_ld;
120 ktime_t t_nom; 114 ktime_t t_nom;
121 struct tfrc_tx_hist_entry *hist; 115 struct tfrc_tx_hist_entry *hist;
122 struct ccid3_options_received options_received;
123}; 116};
124 117
125static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 118static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)