lwip port for STM32F107 repeats tx packets

hermajo wrote on Monday, February 01, 2010:

I just started to work with the freeRTOS port including the lwIP stack for the STM32 communication line devices.
Everything works fine, but I found that every packet is sent twice. Diving deeper into the code I found that this
is obviously done intentionally: a field ‘SendCount’ is maintained with the Tx descriptor, which is evaluated in
the Tx interrupt processing to repeat the last sent packet.
Has anyone an idea, why this is implemented that way?

Joerg

rtel wrote on Monday, February 01, 2010:

I would guess the Ethernet driver was copied from a uIP demo.  It is quite common in uIP to send packets twice as a technique to speed up the ACK coming back from the other end of the link.

Regards.

stf12 wrote on Tuesday, February 02, 2010:

Hi Joerg,
I observer this behavior and more over I found that the Ethernet driver is configured to work in promiscuous mode.
I propose a fix to both this bugs. You find more information at the following web page http://developers.stf12.net/just-another-eclipse-demo-str91x. See the bug report #B3.3 and #B3.4

Regards,
Stefano

hermajo wrote on Tuesday, February 02, 2010:

Hi Stefano,
thanks a lot for your reply. For some reasons I didn’t look up the project page….
I’m not sure id the fix you have described there is sufficient.
I modified the source at thres positions:
(1) in xEthInitialise():

		/* SendCount must be initialized to 2 to ensure the Tx descriptor looks
		 as if its available (as if it has already been sent twice. */
		[s]xTxDescriptor.SendCount = 2;[/s]
                xTxDescriptor.SendCount = 1;

(2) in vMAC_ISR()

		if (xTxDescriptor.SendCount == 0) {
			/* Send again! */
			(xTxDescriptor.SendCount)++;
[s]			xTxDescriptor.Status = ETH_DMATxDesc_OWN | ETH_DMATxDesc_LS
					| ETH_DMATxDesc_FS | ETH_DMATxDesc_TER | ETH_DMATxDesc_TCH
					| ETH_DMATxDesc_IC;
			ETH->DMASR = ETH_DMASR_TBUS;
			ETH->DMATPDR = 0;
[/s]			vReturnBuffer((unsigned char *) xTxDescriptor.Buffer1Addr);
		} else {

(3) in vSendMACData()

	[s]while ((xTxDescriptor.SendCount < 2) && (xTxDescriptor.Status & ETH_DMATxDesc_OWN) == ETH_DMATxDesc_OWN) {[/s]
	while ((xTxDescriptor.SendCount < 1) && (xTxDescriptor.Status & ETH_DMATxDesc_OWN) == ETH_DMATxDesc_OWN) {

At least it seems to work and my peer server application is not longer confused about the duplicated packets :wink:
I will also try the patch to turn off the promiscuous mode; thanks again for the hint.
best  regards,
Joerg

hermajo wrote on Tuesday, February 02, 2010:

….Sorry, the text got messed up a little bit, since the  tags do not work within .
Read as follows: delete text within  …  and replace by the following line(s).

Joerg