Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0e56780 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

[DCCP] Introduce dccp_timestamp



To start the timestamps with 0.0ms, easing the integer maths in the CCIDs, this
probably will be reworked to use the to be introduced struct timeval_offset
infrastructure out of skb_get_timestamp, etc.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent 954ee31f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -432,6 +432,7 @@ struct dccp_sock {
	struct ccid			*dccps_hc_rx_ccid;
	struct ccid			*dccps_hc_tx_ccid;
	struct dccp_options_received	dccps_options_received;
	struct timeval			dccps_epoch;
	enum dccp_role			dccps_role:2;
	__u8				dccps_hc_rx_insert_options:1;
	__u8				dccps_hc_tx_insert_options:1;
+14 −13
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk)
	} else {
		struct timeval now;

		do_gettimeofday(&now);
		dccp_timestamp(sk, &now);
	       	if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >=
		    hctx->ccid3hctx_rtt) {
			hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv,
@@ -317,7 +317,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
		dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet);
	}

	do_gettimeofday(&now);
	dccp_timestamp(sk, &now);

	switch (hctx->ccid3hctx_state) {
	case TFRC_SSTATE_NO_SENT:
@@ -382,7 +382,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
		return;
	}

	do_gettimeofday(&now);
	dccp_timestamp(sk, &now);

	/* check if we have sent a data packet */
	if (len > 0) {
@@ -461,6 +461,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
	struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
	struct ccid3_options_received *opt_recv;
	struct dccp_tx_hist_entry *packet;
	struct timeval now;
	unsigned long next_tmout; 
	u32 t_elapsed;
	u32 pinv;
@@ -508,7 +509,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
		}

		/* Update RTT */
		r_sample = timeval_now_delta(&packet->dccphtx_tstamp);
		dccp_timestamp(sk, &now);
		r_sample = timeval_delta(&now, &packet->dccphtx_tstamp);
		if (unlikely(r_sample <= t_elapsed))
			LIMIT_NETDEBUG(KERN_WARNING
				       "%s: r_sample=%uus, t_elapsed=%uus\n",
@@ -774,7 +776,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)

	ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);

	do_gettimeofday(&now);
	dccp_timestamp(sk, &now);

	switch (hcrx->ccid3hcrx_state) {
	case TFRC_RSTATE_NO_DATA:
@@ -903,10 +905,9 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
	if (rtt == 0)
		rtt = 1;

	delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback);
	x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC;
	if (likely(delta > 1))
		x_recv /= delta;
	dccp_timestamp(sk, &tstamp);
	delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback);
	x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta);

	tmp1 = (u64)x_recv * (u64)rtt;
	do_div(tmp1,10000000);
@@ -981,7 +982,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
		if (opt_recv->dccpor_timestamp_echo == 0)
			break;
		p_prev = hcrx->ccid3hcrx_rtt;
		do_gettimeofday(&now);
		dccp_timestamp(sk, &now);
		timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10);
		r_sample = timeval_usecs(&now);
		t_elapsed = opt_recv->dccpor_elapsed_time * 10;
@@ -1013,7 +1014,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
		return;
	}

	packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp,
	packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
					skb, SLAB_ATOMIC);
	if (packet == NULL) {
		ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet "
@@ -1045,7 +1046,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
		if (ins != 0)
			break;

		do_gettimeofday(&now);
		dccp_timestamp(sk, &now);
		if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >=
		    hcrx->ccid3hcrx_rtt) {
			hcrx->ccid3hcrx_tstamp_last_ack = now;
@@ -1100,7 +1101,7 @@ static int ccid3_hc_rx_init(struct sock *sk)
	hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA;
	INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist);
	INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist);
	do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack);
	dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack);
	hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack;
	hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */
	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ struct ccid3_hc_rx_sock {
  	u64			ccid3hcrx_seqno_last_counter:48,
				ccid3hcrx_state:8,
				ccid3hcrx_last_counter:4;
	unsigned long		ccid3hcrx_rtt;
	u32			ccid3hcrx_rtt;
  	u32			ccid3hcrx_p;
  	u32			ccid3hcrx_bytes_recv;
  	struct timeval		ccid3hcrx_tstamp_last_feedback;
+2 −1
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry *

static inline struct dccp_rx_hist_entry *
		     dccp_rx_hist_entry_new(struct dccp_rx_hist *hist,
				     	    const struct sock *sk, 
				     	    const u32 ndp, 
					    const struct sk_buff *skb,
					    const unsigned int __nocast prio)
@@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry *
		entry->dccphrx_ccval = dh->dccph_ccval;
		entry->dccphrx_type  = dh->dccph_type;
		entry->dccphrx_ndp   = ndp;
		do_gettimeofday(&(entry->dccphrx_tstamp));
		dccp_timestamp(sk, &entry->dccphrx_tstamp);
	}

	return entry;
+4 −12
Original line number Diff line number Diff line
@@ -426,10 +426,13 @@ extern struct dccp_ackpkts *
		dccp_ackpkts_alloc(unsigned int len,
				  const unsigned int __nocast priority);
extern void dccp_ackpkts_free(struct dccp_ackpkts *ap);
extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state);
extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk,
			    u64 ackno, u8 state);
extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap,
					 struct sock *sk, u64 ackno);

extern void dccp_timestamp(const struct sock *sk, struct timeval *tv);

static inline suseconds_t timeval_usecs(const struct timeval *tv)
{
	return tv->tv_sec * USEC_PER_SEC + tv->tv_usec;
@@ -468,17 +471,6 @@ static inline void timeval_sub_usecs(struct timeval *tv,
	}
}

/*
 * Returns the difference in usecs between timeval
 * passed in and current time
 */
static inline suseconds_t timeval_now_delta(const struct timeval *tv)
{
	struct timeval now;
	do_gettimeofday(&now);
	return timeval_delta(&now, tv);
}

#ifdef CONFIG_IP_DCCP_DEBUG
extern void dccp_ackvector_print(const u64 ackno,
				 const unsigned char *vector, int len);
Loading