[U-Boot] Ethernet HW loopack test

Hello,
I'm trying to write an U-Boot command to ping the other interface on my platform. This is to test the hardware at production, the ping must hit the wire. I got deeply inspired from this patch: http://lists.denx.de/pipermail/u-boot/2005-March/009317.html
What changes is that I really want to ping the other interface with a cross cable and not using a special "home made" device ... The problem is when I send the ping, it is the same interface that answers (the one that sent the ping), this is not what I want. I thought by changing the destination MAC address in the packet and initializing it, the other interface should answer by itself. Actually this is not the case...
I know a lot of improvement can be done but at the moment I just trying to make it work, this is why I let a lot of "debug" code and messages... ------------------ Here is some code I wrote in net/net.c ------------------ void NetReceive(volatile uchar * inpkt, int len) { ... switch (x) { case PROT_ARP: ... case PROT_TEST: answerToEthloopTest(pkt, et->et_dest, et->et_src, len); break; ... } /* Prepare and send packet ... */ int EthLoopSend(void) { int i; uchar *pkt; struct eth_device* thisEth = eth_get_dev_by_index(eth_get_dev_index()); struct eth_device* other = thisEth->next; bd_t *bd = gd->bd;
/* Choose the destination interface */ if(other->init(other, bd)){ printf("Couldn't initialize other interface, cannot perform test !\n"); return -1; }
printf("Using %s as destination device\n", other->name); for (i=12 ; i<ETHLOOP_LEN ; i++) { EtherPacket[i] = i; }
/* set the other interface's MAC address as destination address */ pkt = (uchar *)EtherPacket; pkt += NetSetEther (pkt, other->enetaddr, PROT_TEST);
(void) eth_send(EtherPacket, ETHLOOP_LEN);
return 1; /* waiting */ }
/* When no answer arrives ... */ static void EthLoopTimeout (void) { eth_halt(); NetState = NETLOOP_FAIL; /* we did not get the reply */ }
/* The other interface answers here */ static void answerToEthloopTest(uchar *pkt, unsigned dest, unsigned src, unsigned len){ int i; uchar tmp; pkt = (uchar *)EtherPacket;
printf("Device %s answers ...\n", eth_get_name()); =======>>>> Why is it ETSEC 0 ??!
// Reverse src dest MAC for(i = 1 ; i < 6 ; i++){ tmp = EtherPacket[i]; EtherPacket[i] = EtherPacket[i + 6]; EtherPacket[i + 6] = tmp; }
(void)eth_send(EtherPacket, ETHLOOP_LEN); eth_get_dev()->halt(eth_get_dev()); }
/* When the source interface got an answer */ static void EthLoopHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) { int i = 12; pkt = (uchar *)EtherPacket;
for(i ; i < len ; i++){ printf("Comparing %i with %i at index %i", pkt[i], i, i); if(pkt[i] != i){ NetState = NETLOOP_FAIL; break; } } }
/* Initialize the loop test */ static void EthLoopStart(void) { printf ("Using %s as source device\n", eth_get_name()); NetSetTimeout (2000, EthLoopTimeout); NetSetHandler (EthLoopHandler); EthLoopSend(); } -------------------------- Here is the output -------------------------------------- IPSniffer=> ethloop Speed: 10, half duplex Using eTSEC0 as source device Speed: 10, half duplex Using eTSEC1 as destination device Device eTSEC0 answers ... ========> NO I WANT ETSEC1 !!!! loopback test failed
I checked with Wireshark, the packet is correctly build. Maybe my approach is flawed ! Or maybe do you have another way to perform that kind of test ?
Thanks !
Guy Morand

Dear Guy Morand,
please restrict your line length to approx 70 characters or so.
In message A91D8217D6A8B240A79EBEE98176B19B298B1D2069@PRISM.telecontrol.local you wrote:
I'm trying to write an U-Boot command to ping the other interface on my pla tform. This is to test the hardware at production, the ping must hit the wi re. I got deeply inspired from this patch: http://lists.denx.de/pipermail/u-boot/2005-March/009317.html
I hope you also ready my comments. These still apply.
What changes is that I really want to ping the other interface with a cross cable and not using a special "home made" device ... The problem is when I send the ping, it is the same interface that answers (the one that sent th e ping), this is not what I want. I thought by changing the destination MAC address in the packet and initializing it, the other interface should answ er by itself. Actually this is not the case...
...
I checked with Wireshark, the packet is correctly build. Maybe my approach is flawed ! Or maybe do you have another way to perform that kind of test ?
You a run into a number of very basic limitations here.
First, U-Boot has, so far, no clean device model yet. In your case this means that we can enable only one Ethenret interface at a time. When you enable one interface (to send a packet), all other interfaces are shut down and disabled, so they will never be able to see the packet, even if it arrives as intended. We have been discussing improvments in this area in the past, but nothing got implemented or even designed yet.
Second, U-Boot is strictly single-tasking. Even if we had a better driver interface so we were able to "open" two network interfaces simultaneously, we have no infrastructure in place to run independend "send" and "receive" tasks.
If local loopback tests are not sufficient, you will probably find it easiest to perform such testing using an external test machine with two network interfaces.
Best regards,
Wolfgang Denk

-----Original Message----- From: Wolfgang Denk [mailto:wd@denx.de] Sent: mardi 21 décembre 2010 16:04 To: Guy Morand Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] Ethernet HW loopack test
Dear Guy Morand,
please restrict your line length to approx 70 characters or so.
Yes sorry in my company they use the great M$ outlook 2010, I'm not very familiar and apparently it does not know about "automatic carriage return" ... Adding ">" to the eplies was already a Big mess ... I'll do my best in the future!
In message <A91D8217D6A8B240A79EBEE98176B19B298B1D2069@PRISM.telecontrol.loc al> you wrote:
I'm trying to write an U-Boot command to ping the other interface on my pla tform. This is to test the hardware at production, the ping must hit the wi re. I got deeply inspired from this patch: http://lists.denx.de/pipermail/u-boot/2005-March/009317.html
I hope you also ready my comments. These still apply.
What changes is that I really want to ping the other interface with a cross cable and not using a special "home made" device ... The problem is when I send the ping, it is the same interface that answers (the one that sent th e ping), this is not what I want. I thought by changing the destination MAC address in the packet and initializing it, the other interface should answ er by itself. Actually this is not
the case... ...
I checked with Wireshark, the packet is correctly build. Maybe my approach is flawed ! Or maybe do you have another way to perform that
kind of test ?
You a run into a number of very basic limitations here.
First, U-Boot has, so far, no clean device model yet. In your case this means that we can enable only one Ethenret interface at a time. When you enable one interface (to send a packet), all other interfaces are shut down and disabled, so they will never be able to see the packet, even if it arrives as intended. We have been discussing improvments in this area in the past, but nothing got implemented or even designed yet.
Second, U-Boot is strictly single-tasking. Even if we had a better driver interface so we were able to "open" two network interfaces simultaneously, we have no infrastructure in place to run independend "send" and "receive" tasks.
If local loopback tests are not sufficient, you will probably find it easiest to perform such testing using an external test machine with two network interfaces.
Best regards,
Wolfgang Denk
Thanks for your reply, this is more or less what I thought in my bath yesterday evening !
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de It's hard to think of you as the end result of millions of years of evolution.
Regards, Guy Morand
participants (2)
-
Guy Morand
-
Wolfgang Denk