Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed the week of November 23.

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.

AM2634-Q1: dual mac mode ethernet with same IP address

Part Number: AM2634-Q1

Hi,

I have a project specific requirement.

Both ports of the ethernet would be assigned same IP address and same subnet mask but in different networks. The use case states that both should acquire IP address using DHCP. Only one port is always communicating. On status/link failure or down for any reason, the second port is to be used. The 2nd port is expected to resume immediately.  When the 1st port is up again, it shall resume the communications.

I was not be handle this in switch mode, for two reasons. First reason was communication was active on both ports at the same time. Second, when port 1 cable was disconnected, the entire communication stopped.

My question is how do we handle making 2nd port inactive until the 1st port is up again? Is this possible in either Switch mode or MAC only mode?

Regards

Varma

 

  • Hi Varma,

    This is something that should be implemented in dual mac mode at application level. The driver will provide you port link-status callbacks for both ports. You will have to implement a mechanism to check the link activity, lets say you receive a Link Down event when port-1 goes down, then you switch over communication to port-2. And when both ports are up, you manually disable the port-2, 

    I would still recommend not keeping same IP active at the same time on both ports. Assign the IP only when the other Port goes down. Keep only 1 netif active at one time. You could use netif_remove() and remove it as an active netif, or in the init flow, not add the other netif, and add it only when the first netif goes down.

    Regards,
    Shaunak

  • Hi Shaunak,

    I have to allow both ports do a DHCP to acquire IP address, so that client's controller knows that both ports are available. I only need to do this at power-up once. Following your suggestion, if I make the netif down or remove, do I need to go through another DHCP start when I make the port up later?

    Regards

    Varma

  • Hi Varma,

    The NetIFs on the same device cannot have duplicated IP addresses. At one instance, only 1 netif can have an ip address "x", if you try to share it across 2 netif's, the datapath might be broken and you might see unexpected issues..

    Regards,
    Shaunak

  • Hi Shaunak,

    I got your point. I was asking if we are to set the other port to down initially, when we make it up again, do we need to initiate a DHCP again? 

    By the way, when I enable both ports, both of them are doing a DHCP and getting the same IP addresses. But I do not intend to use both of them at the same time.

    Regards

    Varma

  • Hi Shaunak,

    I request your help on this. Can you layout sequence to remove and add back the netif? 

    I am using bare metal. I have already developed code to use both netifs with DHCP, udp client with bare metal.

    Regards

    Varma

  • Hi Varma,

    To avoid ARP ambiguity, routing issues, duplicate IP advertisements, you will have to modify the code to:

    1. Make sure only 1 NetIF gets initialized at the startup, even if both ports are available. So check if Port-1 link is good, then activate the netif, if not activate port-2 netif. Even if not being used together, i would say avoid having both NetIFs active and assigned with the same IP address. So only bring-up one netif at startup.

    So netif_add(), netif_set_default(), netif_set_up() etc should be called only for 1 NetIF during init, and for other NetIF during the Link-Down event of primary NetIF.

    2. During your Link down event, in the callback function check which netif went down, and then bringup the other netif, This will involve getting the IP address again from the DHCP server (unless static hardcoded IP is used)

    You can follow the exact same flow that the SDK example shows, but make sure you only handle one NetIF at once, since you want to share the same IP address.

    Regards,
    Shaunak

  • Hi Shaunak.

    Thank you for your inputs

    The following sequence worked for me.

    1. After LWIP Init and IP is acquired, disabled Port 2 using netif_set_link_down(port2_netif). The default is already set to port1

    2. When port 1 is down, I call netif_set_link_down(port1_netif), then netif_set_default(port2_netif) and netif_set_link_up(port2_netif). This brings up my second port as default.

    3. When port 1 is back again, I bring it up with the same order of link down, default and set-up calls.

    I am continuously monitoring the status of both ports by checking network events in a while loops

    Regards

    Varma