Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111498
b: refs/heads/master
c: 63b3a73
h: refs/heads/master
v: v3
  • Loading branch information
Gerrit Renker committed Sep 4, 2008
1 parent 045d538 commit 9619313
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 59 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: de6f2b59e5cd15a8772adb732a1d80e141a77115
refs/heads/master: 63b3a73bb85daf441f964aaf9b3fc89be4209c23
34 changes: 19 additions & 15 deletions trunk/net/dccp/ccids/ccid3.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
{
struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
struct ccid3_options_received *opt_recv = &hctx->options_received;
struct tfrc_tx_hist_entry *acked;
ktime_t now;
unsigned long t_nfb;
u32 pinv, r_sample;
Expand All @@ -384,17 +385,24 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
hctx->state != TFRC_SSTATE_NO_FBACK)
return;

now = ktime_get_real();

/* Estimate RTT from history if ACK number is valid */
r_sample = tfrc_tx_hist_rtt(hctx->hist,
DCCP_SKB_CB(skb)->dccpd_ack_seq, now);
if (r_sample == 0) {
DCCP_WARN("%s(%p): %s with bogus ACK-%llu\n", dccp_role(sk), sk,
dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type),
(unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq);
/*
* Locate the acknowledged packet in the TX history.
*
* Returning "entry not found" here can for instance happen when
* - the host has not sent out anything (e.g. a passive server),
* - the Ack is outdated (packet with higher Ack number was received),
* - it is a bogus Ack (for a packet not sent on this connection).
*/
acked = tfrc_tx_hist_find_entry(hctx->hist, dccp_hdr_ack_seq(skb));
if (acked == NULL)
return;
}
/* For the sake of RTT sampling, ignore/remove all older entries */
tfrc_tx_hist_purge(&acked->next);

/* Update the moving average for the RTT estimate (RFC 3448, 4.3) */
now = ktime_get_real();
r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, acked->stamp));
hctx->rtt = tfrc_ewma(hctx->rtt, r_sample, 9);

/* Update receive rate in units of 64 * bytes/second */
hctx->x_recv = opt_recv->ccid3or_receive_rate;
Expand All @@ -406,11 +414,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
hctx->p = 0;
else /* can not exceed 100% */
hctx->p = scaled_div(1, pinv);
/*
* Validate new RTT sample and update moving average
*/
r_sample = dccp_sample_rtt(sk, r_sample);
hctx->rtt = tfrc_ewma(hctx->rtt, r_sample, 9);

/*
* Update allowed sending rate X as per draft rfc3448bis-00, 4.2/3
*/
Expand Down
40 changes: 0 additions & 40 deletions trunk/net/dccp/ccids/lib/packet_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@
#include "packet_history.h"
#include "../../dccp.h"

/**
* tfrc_tx_hist_entry - Simple singly-linked TX history list
* @next: next oldest entry (LIFO order)
* @seqno: sequence number of this entry
* @stamp: send time of packet with sequence number @seqno
*/
struct tfrc_tx_hist_entry {
struct tfrc_tx_hist_entry *next;
u64 seqno;
ktime_t stamp;
};

/*
* Transmitter History Routines
*/
Expand All @@ -73,15 +61,6 @@ void tfrc_tx_packet_history_exit(void)
}
}

static struct tfrc_tx_hist_entry *
tfrc_tx_hist_find_entry(struct tfrc_tx_hist_entry *head, u64 seqno)
{
while (head != NULL && head->seqno != seqno)
head = head->next;

return head;
}

int tfrc_tx_hist_add(struct tfrc_tx_hist_entry **headp, u64 seqno)
{
struct tfrc_tx_hist_entry *entry = kmem_cache_alloc(tfrc_tx_hist_slab, gfp_any());
Expand Down Expand Up @@ -111,25 +90,6 @@ void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp)
}
EXPORT_SYMBOL_GPL(tfrc_tx_hist_purge);

u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno,
const ktime_t now)
{
u32 rtt = 0;
struct tfrc_tx_hist_entry *packet = tfrc_tx_hist_find_entry(head, seqno);

if (packet != NULL) {
rtt = ktime_us_delta(now, packet->stamp);
/*
* Garbage-collect older (irrelevant) entries:
*/
tfrc_tx_hist_purge(&packet->next);
}

return rtt;
}
EXPORT_SYMBOL_GPL(tfrc_tx_hist_rtt);


/*
* Receiver History Routines
*/
Expand Down
22 changes: 19 additions & 3 deletions trunk/net/dccp/ccids/lib/packet_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,28 @@
#include <linux/slab.h>
#include "tfrc.h"

struct tfrc_tx_hist_entry;
/**
* tfrc_tx_hist_entry - Simple singly-linked TX history list
* @next: next oldest entry (LIFO order)
* @seqno: sequence number of this entry
* @stamp: send time of packet with sequence number @seqno
*/
struct tfrc_tx_hist_entry {
struct tfrc_tx_hist_entry *next;
u64 seqno;
ktime_t stamp;
};

static inline struct tfrc_tx_hist_entry *
tfrc_tx_hist_find_entry(struct tfrc_tx_hist_entry *head, u64 seqno)
{
while (head != NULL && head->seqno != seqno)
head = head->next;
return head;
}

extern int tfrc_tx_hist_add(struct tfrc_tx_hist_entry **headp, u64 seqno);
extern void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp);
extern u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head,
const u64 seqno, const ktime_t now);

/* Subtraction a-b modulo-16, respects circular wrap-around */
#define SUB16(a, b) (((a) + 16 - (b)) & 0xF)
Expand Down

0 comments on commit 9619313

Please sign in to comment.