Hi Experts,
How do I configure CPSW 2G ALE to filter packets based on VLAN, Ethernet Type, Source MAC, Destination MAC, IP address etc?
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.
Hi Experts,
How do I configure CPSW 2G ALE to filter packets based on VLAN, Ethernet Type, Source MAC, Destination MAC, IP address etc?
The address lookup engine (ALE) is a sub-block of the CPSW Switch responsible for processing all received packets and determining the packet destination port(s). The ALE uses the incoming packet data to determine how the packet should be forwarded. The ALE outputs the port mask to the switch fabric that indicates the packet destination port(s).
Programmers can use the features of ALE to set up complicated rules to:
The basic steps include:
Example 1: Configuring ALE to filter packet based on VLAN:
uint32_t vlan_id = 4U; /* Sample VLAN ALE entry Code. ALE will drop any packet without this VLAN ID tag*/ /*Add inner/outer VLAN entry. IOCTL CMD: CPSW_ALE_IOCTL_ADD_VLAN IOCTL params: inArgs: CpswAle_VlanEntryInfo outArgs: uint32_t Calling context: Task*/ void EnetApp_setVlanAle(EnetApp_PerCtxt *perCtxt) { int32_t status; Enet_IoctlPrms prms; CpswAle_VlanEntryInfo addVlanEntryAleInArgs; uint32_t outArgs; /* Set the Vlan configuration, Depending on need other parameters can also be used, Here we have used 3 params*/ addVlanEntryAleInArgs.vlanIdInfo.tagType = ENET_VLAN_TAG_TYPE_INNER; addVlanEntryAleInArgs.vlanIdInfo.vlanId = vlan_id ; addVlanEntryAleInArgs.vidIngressCheck = 1U; ENET_IOCTL_SET_INOUT_ARGS(&prms, &addVlanEntryAleInArgs, &outArgs); ENET_IOCTL(perCtxt->hEnet, gEnetApp.coreId, CPSW_ALE_IOCTL_ADD_VLAN, &prms, status); if (status != ENET_SOK) { EnetAppUtils_print("\nEnetApp_setVlanAle() failed CPSW_ALE_IOCTL_ADD_VLAN : %d\n", status); } else { EnetAppUtils_print("\nFiltering Enabled for VLAN ID " , addVlanEntryAleInArgs.vlanIdInfo.vlanId)); } }
Example 2 : Configuring ALE to filter packet based on UCAST MAC address:
static uint8_t testSrcAddr[ENET_MAC_ADDR_LEN] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x08 }; /* Sample UCAST MAC ADDR ALE entry Code. ALE will drop any packet with src or dst address as this mac address */ /*Add inner/outer VLAN entry. IOCTL CMD: CPSW_ALE_IOCTL_ADD_UCAST IOCTL params: inArgs: CpswAle_SetUcastEntryInArgs outArgs: uint32_t */ void EnetApp_addUcastMacAddrAleEntry(EnetApp_PerCtxt *perCtxt) { int32_t status; Enet_IoctlPrms prms; CpswAle_SetUcastEntryInArgs addUcastMacAleInArgs; uint32_t outArgs; /* Set the Vlan configuration, Depending on need other parameters can also be used, Here we have used 3 params*/ memcpy(&addUcastMacAleInArgs.addr.addr[0U], testSrcAddr, sizeof(addUcastMacAleInArgs.addr.addr)); addUcastMacAleInArgs.blocked = 1U; ENET_IOCTL_SET_INOUT_ARGS(&prms, &addUcastMacAleInArgs, &outArgs); ENET_IOCTL(perCtxt->hEnet, gEnetApp.coreId, CPSW_ALE_IOCTL_ADD_UCAST, &prms, status); if (status != ENET_SOK) { EnetAppUtils_print("\EnetApp_addUcastMacAddrAleEntry() failed CPSW_ALE_IOCTL_ADD_UCAST : %d\n", status); } else { EnetAppUtils_print("\nFiltering Enabled on MAC Addr ")); EnetAppUtils_printMacAddr(testSrcAddr); }