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.

ti driver EMACMSP432E4.c EMACMSP432E4_handleRx() understanding

Part Number: MSP432E401Y

I am looking at the EMACMSP432E4_handleRx() found in EMACMSP432E4.c. 

at line 409, for unvalid frames, pDescList->ulRead is incremented

                EMACMSP432E4_private.rxDropped++;
                EMACMSP432E4_primeRx(hPkt,
                        &(pDescList->pDescriptors[pDescList->ulRead]));
->             pDescList->ulRead++;
                break;
            }

whitout taking care to wrap.

At line 456, for valid frames, pDescList->ulRead is incremented as follow:

      /* Move on to the next descriptor in the chain, taking care to wrap. */
        pDescList->ulRead++;
        if (pDescList->ulRead == pDescList->ulNumDescs) {
            pDescList->ulRead = 0;
        }

Can someone explain why?

Regards

  • Anoter point,

    The EMACDMAOPMODE Register is set as follow:

        /* Set MAC configuration options. */
        EMACConfigSet(EMAC0_BASE, (EMAC_CONFIG_FULL_DUPLEX |
                                   EMAC_CONFIG_7BYTE_PREAMBLE |
                                   EMAC_CONFIG_IF_GAP_96BITS |
                                   EMAC_CONFIG_USE_MACADDR0 |
                                   EMAC_CONFIG_SA_FROM_DESCRIPTOR |
                                   /* Enable RX Checksum Offload: */
                                   EMAC_CONFIG_CHECKSUM_OFFLOAD |
                                   EMAC_CONFIG_BO_LIMIT_1024),
                      (EMAC_MODE_RX_STORE_FORWARD |
                       EMAC_MODE_TX_STORE_FORWARD |
                       EMAC_MODE_TX_THRESHOLD_64_BYTES |
                       EMAC_MODE_RX_THRESHOLD_64_BYTES), 0);
    

    since the DMA rx operation mode is set to EMAC_MODE_RX_STORE_FORWARD and no error forwarding is set (EMAC_MODE_KEEP_BAD_CRC and  EMAC_MODE_RX_ERROR_FRAMES are not present) the frames should be dropped before DMA transfer.

    The checksum error part of the code is thus never reached. I am seeing it correct?

    Why not defining out the error checking part of the EMACMSP432E4_handleRx() consistently with  EMACDMAOPMODE settings?

  • Hi,

    Which version of the SimpleLink MSP432E4 are you using?

    Todd

  • Hi Todd,

    i was using simplelink_msp432e4_sdk_4_10_00_13. I updated to simplelink_msp432e4_sdk_4_20_00_12 and looked at the changes/ bug fixed.

    However the question remain the same. The lines changes to  415  and 455

    Another question:

    two of the bug fixes aims to detect correctly the link status.

    my question is why we set two times the linkUp variable during the ISR. First at the beginnig of the ISR (one of the bugfixes) and then in prvProcessPhyInterrupt (because  a bug was never called prvProcessPhyInterrupt).

    setting linkup in prvProcessPhyInterrupt alone  would not be a better solution? 

  • Someone who can help?

  • Can i get some help please?

  • user4261913 said:
    The checksum error part of the code is thus never reached. I am seeing it correct?

    Yes, this is true. By default, the h/w drops any RX packet that has a back checksum (CS) and such a packet will never reach the driver.

    There is an existing Jira to add an IOCTL to more easily toggle this feature:

        TIDRIVERS-3832 MSP433E4 driver should support HW checksum error drop IOCTL

    The fix for this should be out in the next release. If you don't want to wait for that, you could try the following.

    You need to ensure that the DT bit of the EMACDMAOPMODE register is set. You should be able to do this with code similar to the following:

                uint32_t dmaMode;
    
                /* Get current value of the DMA operation mode register */
                dmaMode = HWREG(EMAC0_BASE + EMAC_O_DMAOPMODE);
    
                /*
                 * Disable h/w drops of frames with bad checksums
                 * Note the logic here is tricky (seems backwards ...)
                 * If the DT bit is currently 0 (i.e. h/w drops are
                 * -enabled-), then OR-ing will change the bit to 1 (h/w drops
                 * are -disabled-). If h/w drops are already disabled (bit is
                 * currently 1), then OR-ing here will have no effect (it will
                 * remain disabled).
                 */
                dmaMode |= EMAC_DMAOPMODE_DT;
    
                /* Write the updated value to the DMA operation mode register */
                HWREG(EMAC0_BASE + EMAC_O_DMAOPMODE) = dmaMode;

    There is an existing Jira enhancement request to make this functionality available as an IOCTL.

        TIDRIVERS-3832 MSP432E4 driver should support HW checksum error drop IOCTL

    user4261913 said:

    at line 409, for unvalid frames, pDescList->ulRead is incremented

                    EMACMSP432E4_private.rxDropped++;
                    EMACMSP432E4_primeRx(hPkt,
                            &(pDescList->pDescriptors[pDescList->ulRead]));
    ->             pDescList->ulRead++;
                    break;
                }

    whitout taking care to wrap.

    At line 456, for valid frames, pDescList->ulRead is incremented as follow:

    /* Move on to the next descriptor in the chain, taking care to wrap. */
      pDescList->ulRead++;
      if (pDescList->ulRead == pDescList->ulNumDescs) {
          pDescList->ulRead = 0;
      }

    Can someone explain why?

    This is a known issue, seen when receiving a bad frame (including those w/ a bad CS) and the fix should be out in the next release. It's tracked by the following Jira:

        TIDRIVERS-4164 EMAC DMA descriptor index overflows causing out of bounds access

    If you don't want to wait for that, you could try the following to fix this:

         uint32_t         ui32Mode;
         uint32_t         ui32FrameSz;
         uint32_t         ui32CtrlStatus;
    +    bool             noErrors = true;
     
         /* Get a pointer to the receive descriptor list. */
         pDescList = EMACMSP432E4_private.pRxDescList;
    @@ -352,7 +353,7 @@ static void EMACMSP432E4_handleRx()
                 (pDescList->ulRead - 1) : (pDescList->ulNumDescs - 1);
     
         /* Step through the descriptors that are marked for CPU attention. */
    -    while (pDescList->ulRead != ulDescEnd) {
    +    while ((pDescList->ulRead != ulDescEnd) && noErrors) {
             descCount++;
     
             /* Does the current descriptor have a buffer attached to it? */
    @@ -404,8 +405,7 @@ static void EMACMSP432E4_handleRx()
                     EMACMSP432E4_private.rxDropped++;
                     EMACMSP432E4_primeRx(hPkt,
                             &(pDescList->pDescriptors[pDescList->ulRead]));
    -                pDescList->ulRead++;
    -                break;
    +                noErrors = false;
                 }
                 else {
                     /* Allocate a new buffer for this descriptor */
    -- 
    

    user4261913 said:

    my question is why we set two times the linkUp variable during the ISR. First at the beginnig of the ISR (one of the bugfixes) and then in prvProcessPhyInterrupt (because  a bug was never called prvProcessPhyInterrupt).

    setting linkup in prvProcessPhyInterrupt alone  would not be a better solution? 

    I agree this does seem redundant. I've filed the following to track this:

    TIDRIVERS-4702 - MSP432E4 EMAC driver: investigate of 2 calls to signalLinkChange are necessary

    Steve

  • Hi Steve,

    I am implementing a driver for the freerto+tcp stack,

    https://github.com/e-sr/FreeRTOS/blob/tcpip_port_msp432e401y/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/NetworkInterface/msp432e401y/Networkinterface.c

    I Already implemented some changes you proposed. And I will try to do the rest.

    Thank you  a lot for the help!!

    Enzo

**Attention** This is a public forum