[DCCP]: Convert dccp_sample_rtt to ktime_t
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a272378d11
commit
9823b7b554
3 changed files with 23 additions and 30 deletions
|
@ -414,7 +414,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_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
|
||||||
struct ccid3_options_received *opt_recv;
|
struct ccid3_options_received *opt_recv;
|
||||||
struct dccp_tx_hist_entry *packet;
|
struct dccp_tx_hist_entry *packet;
|
||||||
struct timeval now;
|
ktime_t now, t_hist;
|
||||||
unsigned long t_nfb;
|
unsigned long t_nfb;
|
||||||
u32 pinv, r_sample;
|
u32 pinv, r_sample;
|
||||||
|
|
||||||
|
@ -452,13 +452,13 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
else /* can not exceed 100% */
|
else /* can not exceed 100% */
|
||||||
hctx->ccid3hctx_p = 1000000 / pinv;
|
hctx->ccid3hctx_p = 1000000 / pinv;
|
||||||
|
|
||||||
dccp_timestamp(sk, &now);
|
now = ktime_get_real();
|
||||||
|
t_hist = timeval_to_ktime(packet->dccphtx_tstamp);
|
||||||
/*
|
/*
|
||||||
* Calculate new round trip sample as per [RFC 3448, 4.3] by
|
* Calculate new round trip sample as per [RFC 3448, 4.3] by
|
||||||
* R_sample = (now - t_recvdata) - t_elapsed
|
* R_sample = (now - t_recvdata) - t_elapsed
|
||||||
*/
|
*/
|
||||||
r_sample = dccp_sample_rtt(sk, &now, &packet->dccphtx_tstamp);
|
r_sample = dccp_sample_rtt(sk, now, &t_hist);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update RTT estimate by
|
* Update RTT estimate by
|
||||||
|
@ -475,7 +475,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
*/
|
*/
|
||||||
hctx->ccid3hctx_rtt = r_sample;
|
hctx->ccid3hctx_rtt = r_sample;
|
||||||
hctx->ccid3hctx_x = rfc3390_initial_rate(sk);
|
hctx->ccid3hctx_x = rfc3390_initial_rate(sk);
|
||||||
hctx->ccid3hctx_t_ld = timeval_to_ktime(now);
|
hctx->ccid3hctx_t_ld = now;
|
||||||
|
|
||||||
ccid3_update_send_interval(hctx);
|
ccid3_update_send_interval(hctx);
|
||||||
|
|
||||||
|
@ -882,6 +882,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
struct dccp_rx_hist_entry *packet;
|
struct dccp_rx_hist_entry *packet;
|
||||||
u32 p_prev, r_sample, rtt_prev;
|
u32 p_prev, r_sample, rtt_prev;
|
||||||
int loss, payload_size;
|
int loss, payload_size;
|
||||||
|
ktime_t now;
|
||||||
|
|
||||||
BUG_ON(hcrx == NULL);
|
BUG_ON(hcrx == NULL);
|
||||||
|
|
||||||
|
@ -891,14 +892,12 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
case DCCP_PKT_ACK:
|
case DCCP_PKT_ACK:
|
||||||
if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
|
if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
|
||||||
return;
|
return;
|
||||||
case DCCP_PKT_DATAACK: {
|
case DCCP_PKT_DATAACK:
|
||||||
struct timeval now;
|
|
||||||
|
|
||||||
if (opt_recv->dccpor_timestamp_echo == 0)
|
if (opt_recv->dccpor_timestamp_echo == 0)
|
||||||
break;
|
break;
|
||||||
rtt_prev = hcrx->ccid3hcrx_rtt;
|
rtt_prev = hcrx->ccid3hcrx_rtt;
|
||||||
dccp_timestamp(sk, &now);
|
now = ktime_get_real();
|
||||||
r_sample = dccp_sample_rtt(sk, &now, NULL);
|
r_sample = dccp_sample_rtt(sk, now, NULL);
|
||||||
|
|
||||||
if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
|
if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA)
|
||||||
hcrx->ccid3hcrx_rtt = r_sample;
|
hcrx->ccid3hcrx_rtt = r_sample;
|
||||||
|
@ -911,7 +910,6 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
dccp_role(sk), sk, hcrx->ccid3hcrx_rtt,
|
dccp_role(sk), sk, hcrx->ccid3hcrx_rtt,
|
||||||
opt_recv->dccpor_elapsed_time);
|
opt_recv->dccpor_elapsed_time);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case DCCP_PKT_DATA:
|
case DCCP_PKT_DATA:
|
||||||
break;
|
break;
|
||||||
default: /* We're not interested in other packet types, move along */
|
default: /* We're not interested in other packet types, move along */
|
||||||
|
@ -942,9 +940,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
ccid3_hc_rx_send_feedback(sk);
|
ccid3_hc_rx_send_feedback(sk);
|
||||||
ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
|
ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
|
||||||
return;
|
return;
|
||||||
case TFRC_RSTATE_DATA: {
|
case TFRC_RSTATE_DATA:
|
||||||
ktime_t now;
|
|
||||||
|
|
||||||
hcrx->ccid3hcrx_bytes_recv += payload_size;
|
hcrx->ccid3hcrx_bytes_recv += payload_size;
|
||||||
if (loss)
|
if (loss)
|
||||||
break;
|
break;
|
||||||
|
@ -956,7 +952,6 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
|
||||||
ccid3_hc_rx_send_feedback(sk);
|
ccid3_hc_rx_send_feedback(sk);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
case TFRC_RSTATE_TERM:
|
case TFRC_RSTATE_TERM:
|
||||||
DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk);
|
DCCP_BUG("%s(%p) - Illegal state TERM", dccp_role(sk), sk);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/dccp.h>
|
#include <linux/dccp.h>
|
||||||
|
#include <linux/ktime.h>
|
||||||
#include <net/snmp.h>
|
#include <net/snmp.h>
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
#include <net/tcp.h>
|
#include <net/tcp.h>
|
||||||
|
@ -296,8 +297,8 @@ extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
|
||||||
extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
|
extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
|
||||||
extern void dccp_send_close(struct sock *sk, const int active);
|
extern void dccp_send_close(struct sock *sk, const int active);
|
||||||
extern int dccp_invalid_packet(struct sk_buff *skb);
|
extern int dccp_invalid_packet(struct sk_buff *skb);
|
||||||
extern u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv,
|
extern u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv,
|
||||||
struct timeval *t_history);
|
ktime_t *t_history);
|
||||||
|
|
||||||
static inline int dccp_bad_service_code(const struct sock *sk,
|
static inline int dccp_bad_service_code(const struct sock *sk,
|
||||||
const __be32 service)
|
const __be32 service)
|
||||||
|
|
|
@ -301,12 +301,10 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
|
||||||
goto out_invalid_packet;
|
goto out_invalid_packet;
|
||||||
|
|
||||||
/* Obtain RTT sample from SYN exchange (used by CCID 3) */
|
/* Obtain RTT sample from SYN exchange (used by CCID 3) */
|
||||||
if (dp->dccps_options_received.dccpor_timestamp_echo) {
|
if (dp->dccps_options_received.dccpor_timestamp_echo)
|
||||||
struct timeval now;
|
dp->dccps_syn_rtt = dccp_sample_rtt(sk,
|
||||||
|
ktime_get_real(),
|
||||||
dccp_timestamp(sk, &now);
|
NULL);
|
||||||
dp->dccps_syn_rtt = dccp_sample_rtt(sk, &now, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dccp_msk(sk)->dccpms_send_ack_vector &&
|
if (dccp_msk(sk)->dccpms_send_ack_vector &&
|
||||||
dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
|
dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
|
||||||
|
@ -593,22 +591,21 @@ EXPORT_SYMBOL_GPL(dccp_rcv_state_process);
|
||||||
* @t_recv: receive timestamp of packet with timestamp echo
|
* @t_recv: receive timestamp of packet with timestamp echo
|
||||||
* @t_hist: packet history timestamp or NULL
|
* @t_hist: packet history timestamp or NULL
|
||||||
*/
|
*/
|
||||||
u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv,
|
u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv, ktime_t *t_hist)
|
||||||
struct timeval *t_hist)
|
|
||||||
{
|
{
|
||||||
struct dccp_sock *dp = dccp_sk(sk);
|
struct dccp_sock *dp = dccp_sk(sk);
|
||||||
struct dccp_options_received *or = &dp->dccps_options_received;
|
struct dccp_options_received *or = &dp->dccps_options_received;
|
||||||
suseconds_t delta;
|
s64 delta;
|
||||||
|
|
||||||
if (t_hist == NULL) {
|
if (t_hist == NULL) {
|
||||||
if (!or->dccpor_timestamp_echo) {
|
if (!or->dccpor_timestamp_echo) {
|
||||||
DCCP_WARN("packet without timestamp echo\n");
|
DCCP_WARN("packet without timestamp echo\n");
|
||||||
return DCCP_SANE_RTT_MAX;
|
return DCCP_SANE_RTT_MAX;
|
||||||
}
|
}
|
||||||
timeval_sub_usecs(t_recv, or->dccpor_timestamp_echo * 10);
|
ktime_sub_us(t_recv, or->dccpor_timestamp_echo * 10);
|
||||||
delta = timeval_usecs(t_recv);
|
delta = ktime_to_us(t_recv);
|
||||||
} else
|
} else
|
||||||
delta = timeval_delta(t_recv, t_hist);
|
delta = ktime_us_delta(t_recv, *t_hist);
|
||||||
|
|
||||||
delta -= or->dccpor_elapsed_time * 10; /* either set or 0 */
|
delta -= or->dccpor_elapsed_time * 10; /* either set or 0 */
|
||||||
|
|
||||||
|
@ -616,7 +613,7 @@ u32 dccp_sample_rtt(struct sock *sk, struct timeval *t_recv,
|
||||||
DCCP_WARN("unusable RTT sample %ld, using min\n", (long)delta);
|
DCCP_WARN("unusable RTT sample %ld, using min\n", (long)delta);
|
||||||
return DCCP_SANE_RTT_MIN;
|
return DCCP_SANE_RTT_MIN;
|
||||||
}
|
}
|
||||||
if (unlikely(delta - (suseconds_t)DCCP_SANE_RTT_MAX > 0)) {
|
if (unlikely(delta - (s64)DCCP_SANE_RTT_MAX > 0)) {
|
||||||
DCCP_WARN("RTT sample %ld too large, using max\n", (long)delta);
|
DCCP_WARN("RTT sample %ld too large, using max\n", (long)delta);
|
||||||
return DCCP_SANE_RTT_MAX;
|
return DCCP_SANE_RTT_MAX;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue