This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: Ethernet driver generated by HalCoGen - output queue broken

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

In ethernet driver generated by HalCoGen I found one serious issue. Problem is in code testing the NULL pointer taken by the DMA engine.

In short EMAC_BUF_DESC_EOQ flag in file HL_emac.c. Here is part from TRM:

32.2.6.4.9 End of Queue (EOQ) Flag
When set, this flag indicates that the descriptor in question was the last descriptor in the transmit queue
for a given transmit channel, and that the transmitter has halted. This flag is initially cleared by the
software application prior to adding the descriptor to the transmit queue. This bit is set by the EMAC when
the EMAC identifies that a descriptor is the last for a given packet (the EOP flag is set), and there are no
more descriptors in the transmit list (next descriptor pointer is NULL).
The software application can use this bit to detect when the EMAC transmitter for the corresponding
channel has halted. This is useful when the application appends additional packet descriptors to a transmit
queue list that is already owned by the EMAC. Note that this flag is valid on EOP descriptors only.

This contain obvious request, that SW must clear this flag prior add fragments into transmit queue. But current code didn't do it.

Details:

Manipulation with this descriptors have two parts. One is starting transmit (function EMACTransmit) and second after transmit done (function EMACTxIntHandler)

EMACTransmit set all flags only for first fragment packet. When one packet have multiple memory fragments, current code only add EOP flag on last part. Other flags still unchanged. All fragments between first and last are unchanged too (if exist, of course).

EMACTxIntHandler clear many flags, but never EOQ flag.

Problem is when upper layer use generate multiple fragments packets. With LwIP it is not rare. All fragment descriptors are used again and again. After some time it is normal, that many fragments have EOQ positive prior add into queue. And we have race, SW could be faster than contoller and in this case testo for EOQ have false positivity. Result it lost packets on transition in volume which can't be ignored.

This code, including problem is shared probably around all Hercules family MCUs.

Jiri Dobry

PS: do you have a plan to create better code for this completely? It have many crazy parts. For example pooling "infinite" loop inside "interrupt function". Or conversion magic number 0xFCF78600 into pointer. (In "safety" code? WTF?)
Frankly spoken, I hope that other Hercules code without sources and without another option (flash driver) have better quality.

  • Jiri,

    I am forwarding your comments and questions to our software lead so they can be addressed. As always, we appreciate your feedback regardless of how critical it may be of our work products since this allows us to continue to improve.
  • Hi Jiri, 

    Raised a CQ ticket : SDOCM00122906 to track this issue. 

    I understand your concern with the EMAC Driver Quality, "Code quality report (MISRA and HIS Metrics)" of this module also shows many Mandatory violations. The development team is aware of this.  Since EMAC driver is ported form Non-Safety Software, there are few Gaps on the code quality and is captured in our CQ data base. This particular driver has to be re-designed to address these tickets, unfortunately due to other high priority task, the team has put on hold for re-design work until 4Q17.

    For Customers issues we will take it case by case, We suggest work around and provide support to address the issues, until the re-designed driver is available. For EMAC user can implement a custom ISR, by removing the HALCoGen Generated ISR using "#if 0" and the "user code section" in the emac.c.

    We strictly follow Certified Safety Software Development process and our quality guidelines throughout the Software life cycle, If there are violations in quality each one of them are justified and approved. If you still have concerns especially on quality of the Hercules software products like SafeTI Diagnostics Library, HALCoGen( on top of EMAC) where source codes are available, Please don't hesitate to raise it in the forum. Every single issue will be formally captured and tracked to closure.