diff options
author | Jianfeng Tan <henry.tjf@antfin.com> | 2019-11-18 06:59:50 +0000 |
---|---|---|
committer | Jianfeng Tan <henry.tjf@antfin.com> | 2020-03-05 01:31:33 +0800 |
commit | 78c896b3b3127515478090c19447e27dc406427e (patch) | |
tree | d6d67d4683e9ca0409f9984a834547a572fb5310 /lib/libtle_l4p/tcp_timer.h | |
parent | e4380f4866091fd92a7a57667dd938a99144f9cd (diff) |
TLDKv2dev-next-socket
Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
Signed-off-by: Jielong Zhou <jielong.zjl@antfin.com>
Signed-off-by: Jian Zhang <wuzai.zj@antfin.com>
Signed-off-by: Chen Zhao <winters.zc@antfin.com>
Change-Id: I55c39de4c6cd30f991f35631eb507f770230f08e
Diffstat (limited to 'lib/libtle_l4p/tcp_timer.h')
-rw-r--r-- | lib/libtle_l4p/tcp_timer.h | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/libtle_l4p/tcp_timer.h b/lib/libtle_l4p/tcp_timer.h index 8faefb3..d242556 100644 --- a/lib/libtle_l4p/tcp_timer.h +++ b/lib/libtle_l4p/tcp_timer.h @@ -27,43 +27,53 @@ extern "C" { * all RTO values are in ms. */ #define TCP_RTO_MAX 60000U /* RFC 6298 (2.5) */ -#define TCP_RTO_MIN 1000U /* RFC 6298 (2.4) */ +#define TCP_RTO_MIN 200U /* Linux/include/net/tcp.h: TCP_RTO_MIN */ #define TCP_RTO_2MSL (2 * TCP_RTO_MAX) -#define TCP_RTO_DEFAULT TCP_RTO_MIN /* RFC 6298 (2.1)*/ +#define TCP_RTO_DEFAULT 1000U /* RFC 6298 (2.1)*/ #define TCP_RTO_GRANULARITY 100U +static inline struct tle_tcp_stream * +timer_stream(struct tle_tcp_stream *s) +{ + return (struct tle_tcp_stream *)((unsigned long)s & (~(unsigned long)TIMER_MASK)); +} + +static inline uint8_t +timer_type(struct tle_tcp_stream *s) +{ + return (uint8_t)((unsigned long)s & (unsigned long)TIMER_MASK); +} static inline void -timer_stop(struct tle_tcp_stream *s) +timer_stop(struct tle_tcp_stream *s, uint8_t type) { struct tle_timer_wheel *tw; - if (s->timer.handle != NULL) { + if (s->timer.handle[type] != NULL) { tw = CTX_TCP_TMWHL(s->s.ctx); - tle_timer_stop(tw, s->timer.handle); - s->timer.handle = NULL; + tle_timer_stop(tw, s->timer.handle[type]); + s->timer.handle[type] = NULL; } } static inline void -timer_start(struct tle_tcp_stream *s) +timer_start(struct tle_tcp_stream *s, uint8_t type, uint32_t timeout) { struct tle_timer_wheel *tw; - if (s->timer.handle == NULL) { + if (s->timer.handle[type] == NULL) { tw = CTX_TCP_TMWHL(s->s.ctx); - s->timer.handle = tle_timer_start(tw, s, s->tcb.snd.rto); - s->tcb.snd.nb_retx = 0; + s->timer.handle[type] = tle_timer_start(tw, (void*)((unsigned long)s | type), timeout); } } static inline void -timer_restart(struct tle_tcp_stream *s) +timer_restart(struct tle_tcp_stream *s, uint8_t type, uint32_t timeout) { struct tle_timer_wheel *tw; tw = CTX_TCP_TMWHL(s->s.ctx); - s->timer.handle = tle_timer_start(tw, s, s->tcb.snd.rto); + s->timer.handle[type] = tle_timer_start(tw, (void*)((unsigned long)s | type), timeout); } @@ -71,10 +81,10 @@ timer_restart(struct tle_tcp_stream *s) * reset number of retransmissions and restart RTO timer. */ static inline void -timer_reset(struct tle_tcp_stream *s) +timer_reset(struct tle_tcp_stream *s, uint8_t type, uint32_t timeout) { - timer_stop(s); - timer_start(s); + timer_stop(s, type); + timer_start(s, type, timeout); } static inline uint32_t |