[FAQ] AM263P4: How to block ethernet packets with a particular unicast address?

Part Number: AM263P4

Ethernet packets can be blocked or forwarded based on their packet addresses. Unicast address is a specific type of address that is intended for one to one communication.

ALE in CPSW susbystem can be configured to drop packets based on unicast address. ALE is a hardware block that has the capability to do this. In AM263P devices, this block feature can be enabled by calling the CPSW_ALE_IOCTL_ADD_UCAST with correct configuration.

Please see the below API which adds an ALE configuration to block packets coming from a specific unicast address.

void blockUniCast(void)
{
    CpswAle_SetUcastEntryInArgs setUcastInArgs;
    uint32_t entryIdx;
    Enet_IoctlPrms prms;
    int32_t status = ENET_SOK;
    uint8_t uniCastMacAddr[6] = {0x00, 0xe0, 0x4c, 0x32, 0x79, 0x68};

    setUcastInArgs.addr.vlanId = 0;
    setUcastInArgs.info.portNum = CPSW_ALE_HOST_PORT_NUM;
    setUcastInArgs.info.blocked = true;
    setUcastInArgs.info.secure = false;
    setUcastInArgs.info.super = false;
    setUcastInArgs.info.ageable = false;
    setUcastInArgs.info.trunk = false;

    EnetUtils_copyMacAddr(&setUcastInArgs.addr.addr[0U], &uniCastMacAddr[0]);

    ENET_IOCTL_SET_INOUT_ARGS(&prms, &setUcastInArgs, &entryIdx);

    ENET_IOCTL(gEnetApp.perCtxt[0].hEnet, gEnetApp.coreId, CPSW_ALE_IOCTL_ADD_UCAST, &prms, status);
    if (status != ENET_SOK)
    {
        printf("Failed to add ucast entry: %d\r\n", status);
    }
}

This method is also valid for AM263 and AM261 devices.