I performed a test using Bob's changes. The test consists in sending 200 bytes long packets to a PC that sends them back to the interface and measuring the time to cover the loop. The thread performes the send operation and then blocks on the receive on a different socket. It runs on a Stratix II @ 50 MHz. and the times are averaged over 1000 sends/receives
The results are depriming: 5154 microseconds to complete the loopback i.e. 620Kbps integrated over transmit and receive.
Here is a portion of code:
while(1)
{
start=alt_timestamp();
if (sendto(fd_write, buffer, MSG_LEN , 0, (struct sockaddr*)&rem_addr,
sizeof(struct sockaddr_in)) < 0) {
fprintf(stderr, "%s: sendto failed: ", __FUNCTION__);
}
sent++;
if((num_car_letti= recvfrom(fd_listen, str_in, NUM_CAR, 0, &src_addr,
&namelen)) == -1)
{
fprintf(stderr,"%s: recvfrom failed: \n", __FUNCTION__);
exit(1);
}
stop=alt_timestamp();
delay=(stop-start);
sum+=delay;
if(sent == 1000)
{
fprintf(stderr, "delay %lu usec", (sum/1000)/(tps/1000000));
fprintf(stderr, " %lu\n ", sum);
sent=stop=delay=sum=0;
alt_timestamp_start();
}
}//while
--- Quote Start ---
originally posted by bob@Jun 9 2005, 02:38 AM
i made the following changes which compiled and tested ok, but haven't done any comparative performance measurements yet.
1.) added the following code to:
\altera\kits\nios2\components\altera_lwip\ucosii\inc\lwipopts.h
/*
* enable lightweight protection.
* refer \altera\kits\nios2\components\altera_lwip\ucosii\src\downloads\lwip-1.1.0\src\include\lwip\sys.h
* for changes to the sys_arch_decl_protect(), sys_arch_protect() and
* sys_arch_unprotect() macros.
*/# define sys_lightweight_prot 1
2.) made the following changes in:
\altera\kits\nios2\components\altera_lwip\ucosii\src\downloads\lwip-1.1.0\src\include\lwip\sys.h
/** sys_arch_decl_protect
* declare a protection variable. this macro will default to defining a variable of
* type sys_prot_t. if a particular port needs a different implementation, then
* this macro may be defined in sys_arch.h.
*/
//#define sys_arch_decl_protect(lev) sys_prot_t lev# define sys_arch_decl_protect(lev) alt_irq_context lev
/** sys_arch_protect
* perform a "fast" protect. this could be implemented by
* disabling interrupts for an embedded system or by using a semaphore or
* mutex. the implementation should allow calling sys_arch_protect when
* already protected. the old protection level is returned in the variable
* "lev". this macro will default to calling the sys_arch_protect() function
* which should be implemented in sys_arch.c. if a particular port needs a
* different implementation, then this macro may be defined in sys_arch.h
*/
//#define sys_arch_protect(lev) lev = sys_arch_protect()# define sys_arch_protect(lev) lev = alt_irq_disable_all()
/** sys_arch_unprotect
* perform a "fast" set of the protection level to "lev". this could be
* implemented by setting the interrupt level to "lev" within the macro or by
* using a semaphore or mutex. this macro will default to calling the
* sys_arch_unprotect() function which should be implemented in
* sys_arch.c. if a particular port needs a different implementation, then
* this macro may be defined in sys_arch.h
*/
//#define sys_arch_unprotect(lev) sys_arch_unprotect(lev)# define sys_arch_unprotect(lev) alt_irq_enable_all(lev)
//sys_prot_t sys_arch_protect(void);
//void sys_arch_unprotect(sys_prot_t pval);
3.) added the following include to:
\altera\kits\nios2\components\altera_lwip\ucosii\src\downloads\lwip-1.1.0\src\core\pbuf.c
\altera\kits\nios2\components\altera_lwip\ucosii\src\downloads\lwip-1.1.0\src\core\memp.c
# include "sys/alt_irq.h"
not sure about any of the other tuning options, haven't got that far yet.
ciao
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=7529)
--- quote end ---
--- Quote End ---