Post Go back to editing

EMAC descriptor or buffer data flush.

Contains AI Generated Content

Thread Summary

The user is trying to implement read and write operations with EMACPhyLoopback on the SC594 SOM module using the EV-SOMCRR-EZKIT board. The final answer seeks confirmation on the need to clear status and ownership bits in descriptors and buffer data, and asks if the user is experiencing specific issues or has modified the loopback example.
AI Generated Content
Category: Software
Product Number: EMAC
Software Version: CCES 3.0.2

H sir/Madam,

I am using SC594 SOM module with EV-SOMCRR-EZKIT board, trying to implement to read and write operation with EMACPhyLoopback.

after reading old data i want to flush descriptor and buffer data ( emac_data_tx.data or  emac_data_rx & emac_desc_rx[desc_cnt].Buffer1, emac_desc_tx[desc_cnt].Buffer1).

can you please let me know how to reset the buffers and descriptor.

Regards

Mothilal.

  • Hi Mothilal,

    We understand that after reading the received Ethernet data from the RX buffers and descriptors (emac_data_rx and emac_desc_rx), you want to flush or reset the descriptors and buffer memory so they can be safely reused for the next packets. Similarly, after transmission, you want to reset the TX buffers and descriptors (emac_data_tx and emac_desc_tx).

    Specifically, you're asking how to properly clear status bits, set or clear ownership bits, and whether it's necessary to clear the buffer data itself.


    Please confirm if this understanding is correct.
    Are you seeing any specific problems or errors related to buffer or descriptor management, such as stale data?
    Also, are you using the loopback example exactly as provided, or have you changed it to communicate between EMAC0 and EMAC1(or vice versa) instead of using loopback mode?

    Regards,
    Nandini C

  • HI Nandini,
    Good morning and thank you for your response,

    in my project i want to read data through polling method, using following method to read data from buffer.


    busy=true;

    while(busy==true)
    {
    eMACResult = adi_emac_IsDescriptorBusy(&emac_desc_rx[NO_OF_DESCS-1],&busy); 
    }

    eMACResult = adi_emac_SubmitDescriptorListRx(hemac,0,emac_desc_rx,NO_OF_DESCS, true); CHECK_EMAC_RESULT(eMACResult);

    in above scenario, i am missing couple of frames verified through wireshark and incrementing variable for every frame receive, 

    To avoid missing of frames started reading of data for every 10msec once (reading based on timer interrupt),

    by calling below function.

    eMACResult = adi_emac_SubmitDescriptorListRx(hemac,0,emac_desc_rx,NO_OF_DESCS, true);

    In this case i want to erase my old data after reading from buffer. 

    i am using EMAC1 to communicate with PC, only change in example code in disabled loopback and digital loop back parameters.

    Regards

    Mothilal.

  • Hi Mothilal,

    From your response, we understand you faced some data loss issue when using the polling method, so you switched to reading data on every 10 ms using a timer interrupt.

    You mentioned that you want to clear the receive buffer after each read. Usually, the DMA buffers and descriptors don’t need manual clearing because the hardware overwrites buffer with new incoming data automatically. So, could you please explain why you want to clear the buffer after each read? Are you facing any issues? This will help us to assist you more effectively.

    Regards,
    Nandini C

  • HI Nandini,

    Like you mentioned DMA buffer and descriptors are overwriting with new data, i would like to take 2 scenarios.

    1. Scenario:1.

    If received data size is fixed means no issues because it will overwrite with new data.

    Scenario: 2

    a. received 1st set of data with buffer size of 100 bytes (have latest data for 100 bytes).

    b. Received 2nd set of data with buffer size of 70 bytes, (now 70 bytes is latest data and remaining 30 bytes holds the old data), in my application while parsing data assigned to various parameters, which includes decision making bytes, since it is holding previous data (30 bytes 71 to 100) my system is not behaving as expected. because of this reason i want to clear the descriptor. this behavior i am seeing in my software now.

  • Hi Mothilal,

    Thanks for the details.

    Have you tried clearing the Rx buffer using the standard memset() function? If not, Can you please try the below line and check whether it resolves the issue:
    memset(emac_data_rx[desc_cnt].data, 0, FRAME_SIZE);

    Usually,memset is suitable for small-sized buffers. If this resolves the issue, you may consider using MDMA to clear larger buffers. This will offload the memory clearing operation to hardware, freeing up CPU cycles and improving overall system performance.
    The reference example for MDMA copy is available in the following BSP path:
    <installation path>:\Analog Devices\EV-SC59x_EZ-KIT-Rel3.2.0\EV-SC59x_EZ-KIT\Examples\services\mdma

    Regards,
    Nandini C