When Stack Calls xNetworkInterfaceInitialise should NIC preserver Receive/Xmit buffer or Start Anew?

joehinkle wrote on Monday, June 20, 2016:

When the Stack processes function prvProcessNetworkDownEvent() it call the NIC interface function xNetworkInterfaceInitialise().

Normal operation, this occurs when the stack is just starting. Should the stack call it because the network went down, what actions should the NIC driver take with respect to pending XMIT buffers and any Received but noot processed RCV buffers?

Simple thing would be to clean everything out as if the NIC were atarting anew but I’m concerned if the stack had pending XMIT buffers, what the stack would do if they suddenly disappeard.


rtel wrote on Monday, June 20, 2016:

I think it is best to start afresh (dropping the pending packets) as it may be necessary to perform a new DHCP cycle, and you may get a different IP address. If the dropped packets are UDP, then bad luck, if they are TCP, then the TCP protocol will handle the packets being dropped (if the connection can be recovered they will be resent).

joehinkle wrote on Monday, June 20, 2016:

I’m looking at the zero copy xNetworkInterfaceOutput();

The post says that once the buffer is provided to the NIC to be transmitted, the buffer pointer is made NULL in the descriptor and the descriptor is returned to the stack.

When the transmit has completed, how does the NIC driver return the “buffer” (the descriptor has already been returned) to the stack?

Is there a function in FreeRTOS_TCP that takes the pointer to a buff and reattaches it to its descriptor?

Should the NIC drviver reattach the buffer to the descriptor after transmission completes (descriptor has a pointer at the start of the network buffer)?


joehinkle wrote on Monday, June 20, 2016:

Follow up on my previous question.

Is there a reason the NIC driver can’t hold both the descriptor and buffer until the transmission has completed and then return them together?

The 4 byte filler in the network structure could be used as a link list to hold them until the transmission is complete.

edwards3 wrote on Tuesday, June 21, 2016:

Are you using bufferallocation_1.c? In there I see vNetworkBufferReleaseFromISR() for the buffer and vReleaseNetworkBufferAndDescriptor() for the buffer and descriptor.

joehinkle wrote on Tuesday, June 21, 2016:

Thanks - I missed that.