/** \brief Polling the timer event flags */ void Ifx_Lwip_pollTimerFlags(void) { Ifx_Lwip *lwip = &Ifx_g_Lwip; uint32 timerFlags = __swap(&lwip->timerFlags, 0); if (timerFlags & IFX_LWIP_FLAG_DHCP_COARSE) { dhcp_coarse_tmr(); } if (timerFlags & IFX_LWIP_FLAG_DHCP_FINE) { dhcp_fine_tmr(); } if (timerFlags & IFX_LWIP_FLAG_TCP_FAST) { tcp_fasttmr(); } if (timerFlags & IFX_LWIP_FLAG_TCP_SLOW) { tcp_slowtmr(); } if (timerFlags & IFX_LWIP_FLAG_ARP) { etharp_tmr(); } if (timerFlags & IFX_LWIP_FLAG_LINK) {} }
/* our own version of tcp_tmr so we can reset fast/slow timer state */ static void test_tcp_tmr(void) { tcp_fasttmr(); if (++test_tcp_timer & 1) { tcp_slowtmr(); } }
void tcp_tmr(void) { /* Call tcp_fasttmr() every 250 ms */ tcp_fasttmr(); if (++tcp_timer & 1) { /* Call tcp_tmr() every 500 ms, i.e., every other timer tcp_tmr() is called. */ tcp_slowtmr(); } }
/** * Called periodically to dispatch TCP timers. * */ void tcp_tmr(struct tcp_pcb* pcb) { /* Call tcp_fasttmr() every 100 ms */ tcp_fasttmr(pcb); if (++(pcb->tcp_timer) & 1) { /* Call tcp_tmr() every 200 ms, i.e., every other timer tcp_tmr() is called. */ tcp_slowtmr(pcb); } }
void timer_handler() { /* we need to call tcp_fasttmr & tcp_slowtmr at intervals specified by lwIP. * It is not important that the timing is absolutely accurate. */ static int odd = 1; tcp_fasttmr(); odd = !odd; if (odd) tcp_slowtmr(); }
int transfer_data() { #ifdef __arm__ if (TcpFastTimer) { TcpFastTimer = 0; tcp_fasttmr(); } if (TcpSlowTimer) { TcpSlowTimer = 0; tcp_slowtmr(); } #endif return 0; }
void timer_callback(XScuTimer * TimerInstance) { /* we need to call tcp_fasttmr & tcp_slowtmr at intervals specified * by lwIP. It is not important that the timing is absoluetly accurate. */ static int odd = 1; #if LWIP_DHCP==1 static int dhcp_timer = 0; #endif odd = !odd; #ifndef USE_SOFTETH_ON_ZYNQ ResetRxCntr++; #endif tcp_fasttmr(); if (odd) { #if LWIP_DHCP==1 dhcp_timer++; dhcp_timoutcntr--; #endif tcp_slowtmr(); #if LWIP_DHCP==1 dhcp_fine_tmr(); if (dhcp_timer >= 120) { dhcp_coarse_tmr(); dhcp_timer = 0; } #endif } /* For providing an SW alternative for the SI #692601. Under heavy * Rx traffic if at some point the Rx path becomes unresponsive, the * following API call will ensures a SW reset of the Rx path. The * API xemacpsif_resetrx_on_no_rxdata is called every 100 milliseconds. * This ensures that if the above HW bug is hit, in the worst case, * the Rx path cannot become unresponsive for more than 100 * milliseconds. */ #ifndef USE_SOFTETH_ON_ZYNQ if (ResetRxCntr >= RESET_RX_CNTR_LIMIT) { xemacpsif_resetrx_on_no_rxdata(echo_netif); ResetRxCntr = 0; } #endif XScuTimer_ClearInterruptStatus(TimerInstance); }
/*-----------------------------------------------------------------------------------*/ void tcp_tmr() { ++tcp_timer; if(tcp_timer == 10) { tcp_timer = 0; } if(tcp_timer & 1) { /* Call tcp_fasttmr() every 200 ms, i.e., every other timer tcp_tmr() is called. */ tcp_fasttmr(); } if(tcp_timer == 0 || tcp_timer == 5) { /* Call tcp_slowtmr() every 500 ms, i.e., every fifth timer tcp_tmr() is called. */ tcp_slowtmr(); } }
void timer_thread(void) { char fast_flag=0; char slow_flag=0; //char dns_flag=0; disable_timer();//变量重入 fast_flag=time_flag; time_flag=0; slow_flag=slow_timer; if(dns_time>4){ dns_time=0; } enable_timer(); if(fast_flag){//lwip不可重入解决方法 time_flag=0; tcp_fasttmr(); if(slow_flag) tcp_slowtmr(); // if(dns_flag) // dns_tmr();//dns updata } }
int main() { struct ip_addr ipaddr, netmask, gw; /* the mac address of the board. this should be unique per board */ unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 }; echo_netif = &server_netif; #if defined (__arm__) && !defined (ARMR5) #if XPAR_GIGE_PCS_PMA_SGMII_CORE_PRESENT == 1 || XPAR_GIGE_PCS_PMA_1000BASEX_CORE_PRESENT == 1 ProgramSi5324(); ProgramSfpPhy(); #endif #endif init_platform(); #if LWIP_DHCP==1 ipaddr.addr = 0; gw.addr = 0; netmask.addr = 0; #else /* initliaze IP addresses to be used */ IP4_ADDR(&ipaddr, 192, 168, 1, 10); IP4_ADDR(&netmask, 255, 255, 255, 0); IP4_ADDR(&gw, 192, 168, 1, 1); #endif print_app_header(); lwip_init(); /* Add network interface to the netif_list, and set it as default */ if (!xemac_add(echo_netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) { xil_printf("Error adding N/W interface\n\r"); return -1; } netif_set_default(echo_netif); /* now enable interrupts */ platform_enable_interrupts(); /* specify that the network if is up */ netif_set_up(echo_netif); #if (LWIP_DHCP==1) /* Create a new DHCP client for this interface. * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at * the predefined regular intervals after starting the client. */ dhcp_start(echo_netif); dhcp_timoutcntr = 24; while(((echo_netif->ip_addr.addr) == 0) && (dhcp_timoutcntr > 0)) xemacif_input(echo_netif); if (dhcp_timoutcntr <= 0) { if ((echo_netif->ip_addr.addr) == 0) { xil_printf("DHCP Timeout\r\n"); xil_printf("Configuring default IP of 192.168.1.10\r\n"); IP4_ADDR(&(echo_netif->ip_addr), 192, 168, 1, 10); IP4_ADDR(&(echo_netif->netmask), 255, 255, 255, 0); IP4_ADDR(&(echo_netif->gw), 192, 168, 1, 1); } } ipaddr.addr = echo_netif->ip_addr.addr; gw.addr = echo_netif->gw.addr; netmask.addr = echo_netif->netmask.addr; #endif print_ip_settings(&ipaddr, &netmask, &gw); /* start the application (web server, rxtest, txtest, etc..) */ start_application(); /* receive and process packets */ while (1) { if (TcpFastTmrFlag) { tcp_fasttmr(); TcpFastTmrFlag = 0; } if (TcpSlowTmrFlag) { tcp_slowtmr(); TcpSlowTmrFlag = 0; } xemacif_input(echo_netif); transfer_data(); } /* never reached */ cleanup_platform(); return 0; }
int main() { struct netif *netif, server_netif; struct ip_addr ipaddr, netmask, gw; /* the mac address of the board. this should be unique per board */ unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 }; netif = &server_netif; if (init_platform() < 0) { xil_printf("ERROR initializing platform.\r\n"); return -1; } xil_printf("\r\n\r\n"); xil_printf("-----lwIP RAW Mode Demo Application ------\r\n"); /* initliaze IP addresses to be used */ #if (LWIP_DHCP==0) IP4_ADDR(&ipaddr, 192, 168, 1, 10); IP4_ADDR(&netmask, 255, 255, 255, 0); IP4_ADDR(&gw, 192, 168, 1, 1); print_ip_settings(&ipaddr, &netmask, &gw); #endif lwip_init(); #if (LWIP_DHCP==1) ipaddr.addr = 0; gw.addr = 0; netmask.addr = 0; #endif /* Add network interface to the netif_list, and set it as default */ if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) { xil_printf("Error adding N/W interface\r\n"); return -1; } netif_set_default(netif); /* specify that the network if is up */ netif_set_up(netif); /* now enable interrupts */ platform_enable_interrupts(); #if (LWIP_DHCP==1) /* Create a new DHCP client for this interface. * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at * the predefined regular intervals after starting the client. */ dhcp_start(netif); dhcp_timoutcntr = 24; TxPerfConnMonCntr = 0; while(((netif->ip_addr.addr) == 0) && (dhcp_timoutcntr > 0)) { xemacif_input(netif); if (TcpFastTmrFlag) { tcp_fasttmr(); TcpFastTmrFlag = 0; } if (TcpSlowTmrFlag) { tcp_slowtmr(); TcpSlowTmrFlag = 0; } } if (dhcp_timoutcntr <= 0) { if ((netif->ip_addr.addr) == 0) { xil_printf("DHCP Timeout\r\n"); xil_printf("Configuring default IP of 192.168.1.10\r\n"); IP4_ADDR(&(netif->ip_addr), 192, 168, 1, 10); IP4_ADDR(&(netif->netmask), 255, 255, 255, 0); IP4_ADDR(&(netif->gw), 192, 168, 1, 1); } } /* receive and process packets */ print_ip_settings(&(netif->ip_addr), &(netif->netmask), &(netif->gw)); #endif /* start the application (web server, rxtest, txtest, etc..) */ start_applications(); print_headers(); while (1) { if (TcpFastTmrFlag) { tcp_fasttmr(); TcpFastTmrFlag = 0; } if (TcpSlowTmrFlag) { tcp_slowtmr(); TcpSlowTmrFlag = 0; } xemacif_input(netif); transfer_data(); } /* never reached */ cleanup_platform(); return 0; }
static void tcp_fwatchdog(__unused minix_timer_t *tp) { tcp_fasttmr(); set_timer(&tcp_ftmr, tcp_fticks, tcp_fwatchdog, 0); }