: Migrate TX history to singly-linked list
PATCH 5/16 : Migrate TX history to singly-linked list
The patch set migrates TFRC TX history to a singly-linked list.
The details are:
* use of a consistent naming scheme (all TFRC functions now begin with `tfrc_');
* allocation and cleanup are taken care of internally;
* provision of a lookup function, which is used by the CCID TX infrastructure to determine the time a packet was sent (in turn used for RTT sampling);
* integration of the new interface with the present use in CCID3.
Signed-off-by Gerrit Renker <[email protected]>
Signed-off-by Ian McDonald <[email protected]>
--- net/dccp/ccids/ccid3.c | 53 ++++++------------- net/dccp/ccids/ccid3.h | 3 +- net/dccp/ccids/lib/packet_history.c | 100 +++++++++++++++++++++++++++++++++- net/dccp/ccids/lib/packet_history.h | 42 ++++++++++++++- 4 files changed, 155 insertions(+), 43 deletions(-)
net/dccp/ccids/ccid3.c +17 -36
@@ -49,7 +49,7 @@ static int ccid3_debug; #define ccid3_pr_debug(format, a...)#endif -static struct dccp_tx_hist *ccid3_tx_hist; +DECLARE_TFRC_TX_CACHE (ccid3_tx_hist);static struct dccp_rx_hist *ccid3_rx_hist;/*
@@ -389,29 +389,18 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len) {struct ccid3_hc_tx_sock *hctx =ccid3_hc_tx_sk (sk); -struct dccp_tx_hist_entry *packet;ccid3_hc_tx_update_s (hctx, len); - packet =dccp_tx_hist_entry_new (ccid3_tx_hist,GFP_ATOMIC ); -if (unlikely (packet =NULL )) { +if (tfrc_tx_hist_add (&hctx->ccid3hctx_hist,dccp_sk (sk)->dccps_gss))DCCP_CRIT ("packet history - out of memory!" ); -return ; - } -dccp_tx_hist_add_entry (&hctx->ccid3hctx_hist, packet); - - packet->dccphtx_tstamp =ktime_get_real (); - packet->dccphtx_seqno =dccp_sk (sk)->dccps_gss; - packet->dccphtx_rtt = hctx->ccid3hctx_rtt; - packet->dccphtx_sent =1 ; }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; -struct dccp_tx_hist_entry *packet; -ktime_t now; +ktime_t t_send, now;unsigned long t_nfb;u32 pinv, r_sample;
@@ -425,14 +414,12 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)switch (hctx->ccid3hctx_state) {case TFRC_SSTATE_NO_FBACK :case TFRC_SSTATE_FBACK : -/* get packet from history to look up t_recvdata */ - packet =dccp_tx_hist_find_entry (&hctx->ccid3hctx_hist, -DCCP_SKB_CB (skb)->dccpd_ack_seq); -if (unlikely (packet =NULL )) { -DCCP_WARN ("%s(%p), seqno %llu(%s) doesn't exist " -"in history!\n" ,dccp_role (sk), sk, - (unsigned long long )DCCP_SKB_CB (skb)->dccpd_ack_seq, -dccp_packet_name (DCCP_SKB_CB (skb)->dccpd_type)); +/* estimate RTT from history if ACK number is valid */ +if (!tfrc_tx_hist_when (&t_send, &hctx->ccid3hctx_hist, +DCCP_SKB_CB (skb)->dccpd_ack_seq)) { +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);return ; }
@@ -451,7 +438,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)/* * Calculate new RTT sample and update moving average */ - r_sample =dccp_sample_rtt (sk,ktime_us_delta (now, packet->dccphtx_tstamp)); + r_sample =dccp_sample_rtt (sk,ktime_us_delta (now, t_send)); hctx->ccid3hctx_rtt =tfrc_ewma (hctx->ccid3hctx_rtt, r_sample,9 );if (hctx->ccid3hctx_state =TFRC_SSTATE_NO_FBACK ) {
@@ -493,9 +480,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)/* unschedule no feedback timer */ sk_stop_timer (sk, &hctx->ccid3hctx_no_feedback_timer); -/* remove all packets older than the one acked from history */ -dccp_tx_hist_purge_older (ccid3_tx_hist, - &hctx->ccid3hctx_hist, packet);/* * As we have calculated new ipi, delta, t_nom it is possible * that we now can send a packet, so wake up dccp_wait_for_ccid
@@ -598,7 +582,7 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)struct ccid3_hc_tx_sock *hctx =ccid_priv (ccid); hctx->ccid3hctx_state =TFRC_SSTATE_NO_SENT ; -INIT_LIST_HEAD (&hctx->ccid3hctx_hist); +tfrc_tx_hist_init (&hctx->ccid3hctx_hist, ccid3_tx_hist); hctx->ccid3hctx_no_feedback_timer.function ccid3_hc_tx_no_feedback_timer;
@@ -616,7 +600,7 @@ static void ccid3_hc_tx_exit(struct sock *sk)sk_stop_timer (sk, &hctx->ccid3hctx_no_feedback_timer);/* Empty packet history */ -dccp_tx_hist_purge (ccid3_tx_hist, &hctx->ccid3hctx_hist); +tfrc_tx_hist_cleanup (&hctx->ccid3hctx_hist); }static void ccid3_hc_tx_get_info (struct sock *sk,struct tcp_info *info)
@@ -1039,8 +1023,7 @@ static __init int ccid3_module_init(void)if (ccid3_rx_hist =NULL ) goto out; - ccid3_tx_hist =dccp_tx_hist_new ("ccid3" ); -if (ccid3_tx_hist =NULL ) +if (tfrc_tx_cache_init (&ccid3_tx_hist,"ccid3" )) goto out_free_rx; rc =ccid_register (&ccid3);
@@ -1050,8 +1033,7 @@ out:return rc; out_free_tx: -dccp_tx_hist_delete (ccid3_tx_hist); - ccid3_tx_hist =NULL ; +tfrc_tx_cache_cleanup (ccid3_tx_hist); out_free_rx:dccp_rx_hist_delete (ccid3_rx_hist); ccid3_rx_hist =NULL ;
@@ -1063,10 +1045,9 @@ static __exit void ccid3_module_exit(void) {ccid_unregister (&ccid3); -if (ccid3_tx_hist !=NULL ) { -dccp_tx_hist_delete (ccid3_tx_hist); - ccid3_tx_hist =NULL ; - } +if (ccid3_tx_hist !=NULL ) +tfrc_tx_cache_cleanup (ccid3_tx_hist); +if (ccid3_rx_hist !=NULL ) {dccp_rx_hist_delete (ccid3_rx_hist); ccid3_rx_hist =NULL ;
net/dccp/ccids/ccid3.h +2 -1
@@ -40,6 +40,7 @@#include <linux/list.h> #include <linux/types.h> #include <linux/tfrc.h> +#include "lib/packet_history.h" #include "../ccid.h" /* Two seconds as per RFC 3448 4.2 */
@@ -111,7 +112,7 @@ struct ccid3_hc_tx_sock {ktime_t ccid3hctx_t_ld;ktime_t ccid3hctx_t_nom;u32 ccid3hctx_delta; -struct list_head ccid3hctx_hist; +struct tfrc_tx_hist_head ccid3hctx_hist;struct ccid3_options_received ccid3hctx_options_received; };
net/dccp/ccids/lib/packet_history.c +97 -3
124 lines not on this page · raw message
net/dccp/ccids/lib/packet_history.h +39 -3
67 lines not on this page · raw message
Signature · 1 line
1.5.2.2.238.g7cbf2f2-dirty