cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H5 HAL_ETH_Transmit_IT() causes tcp retransmissions in ST example

sssooo
Associate II

Hi all,

during testing a custom project with NETXDUO on NUCLEO-H563ZI I've noticed that sometimes web server response is rather slow.

Wireshark shows rather frequent TCP retransmissions and other problems.

2025-04-25_16-10-06.png

To be sure, I've tried an example from ST (Nx_Iperf) with the same result.

It seems that problem is in ETH_Prepare_Tx_Descriptors(), in check of Tx Descriptor:

  /* Current Tx Descriptor Owned by DMA: cannot be used by the application  */
  if ((READ_BIT(dmatxdesc->DESC3, ETH_DMATXNDESCWBF_OWN) == ETH_DMATXNDESCWBF_OWN)
      || (dmatxdesclist->PacketAddress[descidx] != NULL))
  {
    return HAL_ETH_ERROR_BUSY;
  }


I removed this check and TCP retransmissions became much less frequent.
Is there a better solution?

1 ACCEPTED SOLUTION

Accepted Solutions
sssooo
Associate II

For everyone who curious following settings have fixed TCP transmissions for me:

ETH_TX_DESC_CNT=8

NX_WEB_HTTP_SERVER_SESSION_MAX=4

NX_WEB_HTTP_SERVER_MAX_PENDING=8

View solution in original post

4 REPLIES 4
ASEHST
ST Employee

Hello @sssooo,

Thank you for your reply,

The Owned Tx Descriptor check indicates that a packet is already associated with the descriptor, making it unavailable for reuse by the application. This check ensures that the application does not modify or use a descriptor currently being processed by the DMA or linked to an unprocessed packet.

Although removing this check might improve performance, it may not be a sustainable solution and risks data corruption.

We are analyzing the root cause of these retransmissions internally and will keep you updated.

 

With Regards,

If your question is answered, please close this topic by clicking "Accept as Solution".
sssooo
Associate II

For everyone who curious following settings have fixed TCP transmissions for me:

ETH_TX_DESC_CNT=8

NX_WEB_HTTP_SERVER_SESSION_MAX=4

NX_WEB_HTTP_SERVER_MAX_PENDING=8

Adam BERLINGER
ST Employee

Hello @sssooo 

just to add few points based on our internal conversation, so other users can see it.

The ETH_TX_DESC_CNT will reduce the re-transmission due to no TX DMA descriptors being available to send packets.

The HTTP settings affect how much TCP connections can be opened at the same time. Web browsers will typically open several TCP connections with the server. When additional TCP connection can't be established the client will try to retransmit the request to open the TCP connection.

At the end it is tradeoff between performance and memory allocated to TCP / HTTP stack.

Grzegorz Kania
Associate III

The problem begins when we use the TCP_WRITE_FLAG_MORE flag when calling the altcp_write function.

Each call to this function with this flag adds one segment to the chain, which is then processed in the low_level_output function (ethernetif.c).

If the number of elements is greater than ETH_TX_DESC_CNT, an ERR_IF error is generated(in function low_level_output ).

This error code is patiently returned by subsequent LwIP library functions until it is forgotten at the tcp_in file level and not reported in any logs!

This could be improved!

The TCP_WRITE_FLAG_MORE flag is used by the httpd support, which is why it doesn't work with the default settings.

If we're using a Makefile, this is easily fixed by adding the line

C_DEFS +=-DETH_TX_DESC_CNT=8 # !!! Otherwise, HTTP won't work.