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.

AM2432: icssg enet_lwip example for Profinet communication

Part Number: AM2432

Currently I try to port Profinet stack to AM2432 based on icssg enet_lwip example. But I don't know how to use enet API to handel

1) Set L2 multicast forward rules, for example: AM2342 has port0 (management port), port 1(physical port), port 2(physical port) . How to set the forward rules like:

01-80-C2-00-00-0E: port 1 -> port0; port2 -> port0

01-0E-CF-00-00-00: port 1 -> port0 and port2;  port2 -> port0 and port 1

Can I use  EnetFdb_Ioctl to control this? How to?

2) Get ingress port number via Lwip API

For example: If using lwip_hook_unknown_eth_protocol to handel LLDP package, how to get the ingress port of incoming LLDP packet?

3) Specify egress port via netif->linkoutput

If I want to send a LLDP multicast package to port 1, how to achieve this?

  • Hi

    The ticket is assigned to expert.

    Please expect some delay in response as expert is out of office.

    Regards

    Sri Vidya

  • Hi Jie,

    I have started looking into the issue. Let me get back by Friday on this.

  • Thank you. Is there any solution?

  • Hi 

    1. The forwarding rules are programmed using FDB table. The forwarding and tagging information has to set using an IOCTL. ICSSG_PER_IOCTL_VLAN_SET_ENTRY is the IOCTL used to set an entry. Use this ENET_IOCTL() API and pass ICSSG_PER_IOCTL_VLAN_SET_ENTRY command with valid params.
    2. I assume you are trying switch mode. Do you want to know the receive frame port number?
    3. You can send it as an directed packet with specifying the port number (this will push packets to ring buffers of specified port).

    BR

    Nilabh A.

  • Hi,

    1. Would you please show me an example?

    2. Yes, ICSSG in switch mode. I want to  know the receive frame port number from LWIP interface.

    3. Would you please show me an example?

    BR

    JM 

  • Hi  

    1. please refer to https://software-dl.ti.com/mcu-plus-sdk/esd/AM243X/latest/exports/docs/api_guide_am243x/EXAMPLES_ENET_VLAN_ICSSG.html

    2. I am not sure if LwiP provides any such APIs, I will have to check it, mean while it will be helpful if you can also check on your end on lwip forums.

    3. 

    ) Specify egress port via netif->linkoutput

    If I want to send a LLDP multicast package to port 1, how to achieve this?

    This can be again done using VLAN tagging using FDB. Please refer same example as mentioned above.

  • Hi,

    Thank you for the support! I add FDB as following code:

    int32_t add_mac_fdb_entry()
    {
        uint32_t instId;
        int32_t retVal = RET_FAILURE;
        Enet_Type enetType;
        bool semStatus;
        Enet_IoctlPrms prms;
        Icssg_FdbEntry params;
        SemaphoreP_Object ayncIoctlSemObj;
        int32_t status = ENET_SOK;
        EnetApp_HandleInfo handleInfo;
        uint32_t coreId = EnetSoc_getCoreId();
        EnetApp_getEnetInstInfo(&enetType, &instId);
        EnetApp_acquireHandleInfo(enetType, instId, &handleInfo);
        if(ENET_ICSSG_SWITCH != enetType) return retVal;
    
        status = SemaphoreP_constructBinary(&ayncIoctlSemObj, 0);
        DebugP_assert(SystemP_SUCCESS == status);
    
        Enet_registerEventCb(handleInfo.hEnet,
                            ENET_EVT_ASYNC_CMD_RESP,
                            0U,
                            asyncIoctlCb,
                            (void *)&ayncIoctlSemObj);
        int i = 0;
        //Now make an entry in FDB for the HOST MAC address using Asynchronous IOCTL
        for (i = 0; i < ENET_MAC_ADDR_LEN; i++)
        {
            params.macAddr[i] = lldp_mac[i];
        }
        params.vlanId = 0;
        params.fdbEntry[0] = ICSSG_FDB_ENTRY_P0_MEMBERSHIP|ICSSG_FDB_ENTRY_VALID;
        params.fdbEntry[1] = ICSSG_FDB_ENTRY_P0_MEMBERSHIP|ICSSG_FDB_ENTRY_VALID;
    
        EnetAppUtils_print("LLDP entry in FDB \n\r");
    
        ENET_IOCTL_SET_IN_ARGS(&prms, &params);
        ENET_IOCTL(handleInfo.hEnet, coreId, ICSSG_FDB_IOCTL_ADD_ENTRY, &prms, retVal);
        if (retVal == ENET_SINPROGRESS)
        {
            EnetAppUtils_print("Success: IOCTL command sent for making MAC entry in FDB \n\r");
            /* Wait for asyc ioctl to complete */
            do
            {
                Enet_poll(handleInfo.hEnet, ENET_EVT_ASYNC_CMD_RESP, NULL, 0U);
                semStatus = SemaphoreP_pend(&ayncIoctlSemObj, SystemP_WAIT_FOREVER);
            } while (semStatus != SystemP_SUCCESS);
    
            retVal = ENET_SOK;
        }
        else
        {
            EnetAppUtils_print("ERROR: IOCTL command sent for making MAC entry in FDB failed\n\r");
        }
    
        EnetAppUtils_print("DCP entry in FDB \n\r");
        for (i = 0; i < ENET_MAC_ADDR_LEN; i++)
        {
            params.macAddr[i] = dcp_mac[i];
        }
        params.vlanId = 0;
        params.fdbEntry[0] = ICSSG_FDB_ENTRY_P0_MEMBERSHIP|ICSSG_FDB_ENTRY_P1_MEMBERSHIP|ICSSG_FDB_ENTRY_P2_MEMBERSHIP|ICSSG_FDB_ENTRY_VALID;
        params.fdbEntry[1] = ICSSG_FDB_ENTRY_P0_MEMBERSHIP|ICSSG_FDB_ENTRY_P1_MEMBERSHIP|ICSSG_FDB_ENTRY_P2_MEMBERSHIP|ICSSG_FDB_ENTRY_VALID;
    
        ENET_IOCTL_SET_IN_ARGS(&prms, &params);
        ENET_IOCTL(handleInfo.hEnet, coreId, ICSSG_FDB_IOCTL_ADD_ENTRY, &prms, retVal);
        if (retVal == ENET_SINPROGRESS)
        {
            EnetAppUtils_print("Success: IOCTL command sent for making MAC entry in FDB \n\r");
            /* Wait for asyc ioctl to complete */
            do
            {
                Enet_poll(handleInfo.hEnet, ENET_EVT_ASYNC_CMD_RESP, NULL, 0U);
                semStatus = SemaphoreP_pend(&ayncIoctlSemObj, SystemP_WAIT_FOREVER);
            } while (semStatus != SystemP_SUCCESS);
    
            retVal = ENET_SOK;
        }
        else
        {
            EnetAppUtils_print("ERROR: IOCTL command sent for making MAC entry in FDB failed\n\r");
        }
    
        SemaphoreP_destruct(&ayncIoctlSemObj);
        Enet_unregisterEventCb(handleInfo.hEnet, ENET_EVT_ASYNC_CMD_RESP, 0U);
        return retVal;
    }

    and add call back to handle multicast packet:

    err_t eth_unknow_type_hook(struct pbuf *pbuf, struct netif *netif)
    {
        uint8_t portNum = 2;
        if(pbuf->flags != 0) portNum = 1;
        uint8_t* data = (uint8_t*) pbuf->payload;
        uint8_t type = getMcType(data);
        printf("P%02X", portNum);
        switch(type)
        {
        case MC_LLDP: printf(" LLDP ");break;
        case MC_DCP: printf(" DCP ");break;
        default: printf(" UNKNOWN ");break;
        }
        printf("%02X%02X%02X%02X%02X%02X\r\n",
               data[6], data[7], data[8],data[9], data[10], data[11]);
        return ERR_OK;
    }
    

    At beginning the code works OK. After host port cecieve a mount of multicast packets, it stop recieve any multicast from two ports. 

    ==========================
          ENET LWIP App       
    ==========================
    Enabling clocks!
    Mdio_open: MDIO Manual_Mode enabled
    EnetPhy_bindDriver: PHY 15: OUI:080028 Model:0f Ver:01 <-> 'dp83869' : OK
    EnetPhy_bindDriver: PHY 3: OUI:080028 Model:0f Ver:01 <-> 'dp83869' : OK
    PHY 3 is alive
    PHY 15 is alive
    LLDP entry in FDB 
    Success: IOCTL command sent for making MAC entry in FDB 
    DCP entry in FDB 
    Success: IOCTL command sent for making MAC entry in FDB 
    Starting lwIP, local interface IP is dhcp-enabled
    Host MAC address-0 : 70:ff:76:1e:ef:87
    [LWIPIF_LWIP] NETIF INIT SUCCESS
    [LWIPIF_LWIP] Enet has been started successfully
    status_callback==UP, local interface IP is 0.0.0.0
    UDP server listening on port 5001
    Icssg_handleLinkUp: icssg1: Port 2: Link up: 100-Mbps Full-Duplex
    P02 LLDP 28633698A5F1
    link_callback==UP
    P02 DCP 28633698A5EF
    Icssg_handleLinkUp: icssg1: Port 1: Link up: 100-Mbps Full-Duplex
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
          5.170s : CPU load =   3.39 %
    P02 LLDP 28633698A5F1
    P01 LLDP 0826AE3BA68B
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
         10.170s : CPU load =   2.76 %
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
    P02 LLDP 28633698A5F1
    P01 LLDP 0826AE3BA68B
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
         15.170s : CPU load =   2.73 %
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
    P02 LLDP 28633698A5F1
         20.170s : CPU load =   2.73 %
    P02 LLDP 28633698A5F1
    P01 LLDP 0826AE3BA68B
    P02 LLDP 28633698A5F1
    P02 DCP 28633698A5EF
    P02 LLDP 28633698A5F1
    P02 LLDP 28633698A5F1
         25.170s : CPU load =   2.71 %
    P01 LLDP 0826AE3BA68B
         30.170s : CPU load =   2.68 %
         35.170s : CPU load =   2.68 %
    P01 LLDP 0826AE3BA68B
         40.170s : CPU load =   2.68 %
         45.170s : CPU load =   2.67 %
    P01 LLDP 0826AE3BA68B
         50.170s : CPU load =   2.68 %
    P01 LLDP 0826AE3BA68B
         55.170s : CPU load =   2.68 %
         60.170s : CPU load =   2.68 %
    P01 LLDP 0826AE3BA68B

    Would you please help me solve this problem?

    With best regards

  • Hi,

    Can you please tell me if cpu load is still getting printed or not. If not then example might have crashed.

  • CPU load is still printed as normal. Seems like the fdb entry for Mcast was automatically removed after ~20-30 packets recieved.  

  • Hi Jie,

    We will try to reproduce the issue on our end and come back on it by early next week.

  • Hi,

    The issue is solved.

    I modify the lwipif-icssg and use pBuf->flags to pass the port number to application layer. If flags = 0, it will cause Lwip stack stop working (I don't know the reason). So I change the flags =0xFF for port 2, flags =0xFE for port 1. The code woks without hanging up.