Skip to content

Commit

Permalink
support 20usec tick for astf-tcp
Browse files Browse the repository at this point in the history
Signed-off-by: Hanoh Haim <hhaim@cisco.com>
  • Loading branch information
hhaim committed Dec 11, 2017
1 parent 7d49ffc commit 2b8e055
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
13 changes: 8 additions & 5 deletions src/44bsd/tcp_subr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,10 @@ bool CTcpPerThreadCtx::is_open_flow_enabled(){
/* tick every 50msec TCP_TIMER_W_TICK */
void CTcpPerThreadCtx::timer_w_on_tick(){
#ifndef TREX_SIM
/* we have two levels on non-sim */
uint32_t left;
m_timer_w.on_tick_level_count(0,(void*)this,tcp_timer,16,left);
m_timer_w.on_tick_level0((void*)this,tcp_timer);
m_timer_w.on_tick_level_count(1,(void*)this,tcp_timer,16,left);
#else
m_timer_w.on_tick_level0((void*)this,tcp_timer);
#endif
Expand Down Expand Up @@ -546,17 +548,18 @@ bool CTcpPerThreadCtx::Create(uint32_t size,
memset(&tcp_saveti,0,sizeof(tcp_saveti));

RC_HTW_t tw_res;
tw_res = m_timer_w.Create(1024,1);
tw_res = m_timer_w.Create(1024,TCP_TIMER_LEVEL1_DIV);

if (tw_res != RC_HTW_OK ){
CHTimerWheelErrorStr err(tw_res);
printf("Timer wheel configuration error,please look into the manual for details \n");
printf("ERROR %-30s - %s \n",err.get_str(),err.get_help_str());
return(false);
}
#ifndef TREX_SIM
m_timer_w.set_level1_cnt_div(TCP_TIMER_W_DIV);
#endif
if (TCP_TIMER_LEVEL1_DIV>1){
/* on non-simulation we have two level active*/
m_timer_w.set_level1_cnt_div();
}

if (!m_ft.Create(size,is_client)){
printf("ERROR can't create flow table \n");
Expand Down
44 changes: 34 additions & 10 deletions src/44bsd/tcp_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,17 @@ struct tcpstat {

#ifdef TREX_SIM

/*The tick is 50msec , resolotion */

/* only one level (0) is used */
#define TCP_TIMER_LEVEL1_DIV 1


#define TCP_TIMER_TICK_BASE_MS 200

/* tick is 50 msec */
#define TCP_TIMER_W_TICK 50

#define TCP_TIMER_W_DIV 1

#define TCP_FAST_TICK_ (TCP_TIMER_TICK_BASE_MS/TCP_TIMER_W_TICK)
Expand All @@ -395,13 +404,23 @@ struct tcpstat {
#define TCP_SLOW_FAST_RATIO_ 1


/* main tick in sec */
#define TCP_TIME_TICK_SEC ((double)TCP_TIMER_W_TICK/((double)TCP_TIMER_W_DIV* 1000.0))

#define TCP_TIMER_W_1_TICK_US (TCP_TIMER_W_TICK*1000)

#else

/* 2 levels (0,1) of the tw are used */
#define TCP_TIMER_LEVEL1_DIV 16

// base tick in msec

/* base tick of timer in msec */
#define TCP_TIMER_W_TICK 1
/* base tick of timer in 20usec */
#define TCP_TIMER_W_1_TICK_US 20

#define TCP_TIMER_W_1_MS (1000/TCP_TIMER_W_1_TICK_US)


/* fast tick msec */
#define TCP_TIMER_TICK_FAST_MS 100
Expand All @@ -410,23 +429,28 @@ struct tcpstat {
#define TCP_TIMER_TICK_SLOW_MS 500


/* to how many micro tick to div the TCP_TIMER_W_TICK */
#define TCP_TIMER_W_DIV 50


/* ticks of FAST */
#define TCP_FAST_TICK_ (TCP_TIMER_TICK_FAST_MS/TCP_TIMER_W_TICK)
#define TCP_FAST_TICK_ (TCP_TIMER_TICK_FAST_MS * TCP_TIMER_W_1_MS)

#define TCP_SLOW_RATIO_MASTER ((TCP_TIMER_TICK_SLOW_MS*TCP_TIMER_W_DIV)/TCP_TIMER_W_TICK)
/* how many ticks of TCP_TIMER_W_1_TICK_US */
#define TCP_SLOW_RATIO_MASTER (TCP_TIMER_TICK_SLOW_MS * TCP_TIMER_W_1_MS)

/* how many fast ticks need to get */
#define TCP_SLOW_FAST_RATIO_ (TCP_TIMER_TICK_SLOW_MS/TCP_TIMER_TICK_FAST_MS)

/* one tick that derive the TW in sec */
#define TCP_TIME_TICK_SEC ((double)TCP_TIMER_W_1_TICK_US/((double)1000000.0))


#endif

/* main tick in sec */
#define TCP_TIME_TICK_SEC ((double)TCP_TIMER_W_TICK/((double)TCP_TIMER_W_DIV* 1000.0))
static inline uint32_t tw_time_usec_to_ticks(uint32_t usec){
return (usec/TCP_TIMER_W_1_TICK_US);
}

static inline uint32_t tw_time_msec_to_ticks(uint32_t msec){
return (tw_time_usec_to_ticks(1000*msec));
}


#include "h_timer.h"
Expand Down

0 comments on commit 2b8e055

Please sign in to comment.