UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer lampertg
Observer
321 Views
Registered: ‎02-12-2018

unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

Hi,
I'm using the Virtex Ultrascale VCU118, with the Xiling soft Ethernet IP.
Sometimes when the system is under load I'm getting "ERR_MEM" return value from "tcp_write".
according to everything I saw online, I never should have got to the point where I get this return value since before I'm calling "tcp_write", I'm calling "tcp_sndbuf" to see if there's enough space in the pbuf, and there is.

Also, sometimes it ever recovers anf I keep on getting "ERR_MEM" for every "tcp_write".

any suggestions?

code:

uint16_t usAvailable;

usAvailable = tcp_sndbuf(pcb);
if (usAvailable > size)
{
     nErr = tcp_write(pcb, (void *)(address),size, 0);
}

 

FYI: I thought that tcp_sndbuf might also be returning the "ERR_MEM", but it's not, it's returning a valid number.

 

any suggestions? 

 

Thank you,

Gilad

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Visitor hossam1984
Visitor
206 Views
Registered: ‎02-26-2019

Re: unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

Hello Again,

To get rid of this error I am using the following routine:

I define this variable to enable sending without wait

u8_t apiflags = TCP_WRITE_FLAG_COPY;// | TCP_WRITE_FLAG_MORE;

 

Then in the sending function I do the following:

_Bool HEAD_FLAG = true; // Used to breake the while loop
while(HEAD_FLAG)
{
if((tcp_sndbuf(send_pcb) > sendpacketheader.packet_length))// To check there is a space in the sending buffer (Same as what you're doing)
{
if(send_pcb->state == CLOSED || (eth_link_status != ETH_LINK_UP))//Checke if the connection is OK
{
xil_printf("tcpip_headerpacket_send send_pcb->state: %d\r\n", send_pcb->state);
active=false;
tcp_abort(send_pcb);
break;
}
err = tcp_write(send_pcb, (uint8_t *)&sendpacketheader.packet_header, sendpacketheader.packet_length, apiflags); // 
if (err != ERR_OK) {
xil_printf("TCP client: Error on tcp_write: %d\r\n", err);
return err;
}
err = tcp_output(send_pcb); // This part sends the packet directly without waiting to filling the buffer. // I think you're missing this part
if (err != ERR_OK) {xil_printf("TCP client: Error on tcp_output: %d\r\n", err); return err; }

HEAD_FLAG = false;
}

// Here I used this function to receive ACK from the other side because if there is no space in the buffer I have to wait it for free space 

// by regular check of the received ACK which means the other side has received some packets

xemacif_input(echo_netif); 

}

 

 

Hope it hepls you.

 

Good Luck

View solution in original post

5 Replies
Highlighted
Visitor hossam1984
Visitor
207 Views
Registered: ‎02-26-2019

Re: unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

Hello Again,

To get rid of this error I am using the following routine:

I define this variable to enable sending without wait

u8_t apiflags = TCP_WRITE_FLAG_COPY;// | TCP_WRITE_FLAG_MORE;

 

Then in the sending function I do the following:

_Bool HEAD_FLAG = true; // Used to breake the while loop
while(HEAD_FLAG)
{
if((tcp_sndbuf(send_pcb) > sendpacketheader.packet_length))// To check there is a space in the sending buffer (Same as what you're doing)
{
if(send_pcb->state == CLOSED || (eth_link_status != ETH_LINK_UP))//Checke if the connection is OK
{
xil_printf("tcpip_headerpacket_send send_pcb->state: %d\r\n", send_pcb->state);
active=false;
tcp_abort(send_pcb);
break;
}
err = tcp_write(send_pcb, (uint8_t *)&sendpacketheader.packet_header, sendpacketheader.packet_length, apiflags); // 
if (err != ERR_OK) {
xil_printf("TCP client: Error on tcp_write: %d\r\n", err);
return err;
}
err = tcp_output(send_pcb); // This part sends the packet directly without waiting to filling the buffer. // I think you're missing this part
if (err != ERR_OK) {xil_printf("TCP client: Error on tcp_output: %d\r\n", err); return err; }

HEAD_FLAG = false;
}

// Here I used this function to receive ACK from the other side because if there is no space in the buffer I have to wait it for free space 

// by regular check of the received ACK which means the other side has received some packets

xemacif_input(echo_netif); 

}

 

 

Hope it hepls you.

 

Good Luck

View solution in original post

Observer lampertg
Observer
170 Views
Registered: ‎02-12-2018

Re: unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

Thank you!
I'll Give it a try

0 Kudos
Moderator
Moderator
128 Views
Registered: ‎08-25-2009

Re: unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

Hi @lampertg ,

If you've got this resolved, could you please mark the relavent thread as "Accepted Solution" so it will benifit other forum users? Thank you!

 

"Don't forget to reply, kudo and accept as solution."
Observer lampertg
Observer
120 Views
Registered: ‎02-12-2018

Re: unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

Sure, It's in my pipeline, as soon as I'll test it and see that it's working, I'll mark it as resolved.

thank you!

0 Kudos
Observer lampertg
Observer
52 Views
Registered: ‎02-12-2018

Re: unexplained "ERR_MEM" when calling tcp_write (sometimes can't recover)

Jump to solution

@hossam1984 Thanks again!
the error didn't go away, but it improved the performance (fewer occurrences).

I'll mark it as solved since it is a partial solution.