The VLAN Filter support in the Receive (Rx) path provides a robust and flexible way to filter the incoming traffic to the host processor. The EtherNet/IP FWHAL provides a set of APIs that allow flexibility in configuring the filtering rules. Based on the configuration, only the allowed packets are sent to the host processor. This enables precise control over the network traffic, allowing for improved network security and performance.
The VLAN Filter table is a 512-byte table that stores the VLAN IDs (VIDs) that are allowed or blocked. The table is divided into 4096 bits, with each bit corresponding to a specific VID. The table is used to determine whether a packet should be allowed or blocked based on its VID.
When the VLAN Filter is disabled, the following forwarding rules are used to handle the packets.
| Packet Type | Forwarding Mode |
|---|---|
| Broadcast | Cut through and Forward to Host |
| Multicast | Cut through and Forward to Host Multicast frames like PTP/DLR are handled based on protocol |
| Unicast (not to Host) | Cut through |
| Unicast (to Host) | Forward to Host |
However, when the VLAN Filter is enabled, the VLAN Filter Table is used to determine whether an incoming packet will be received by the host. If the VLAN Filter Table bit corresponding to the VID in the VLAN Tag of the packet received is:
To enable/disable the VLAN Filtering feature, the following API can be used : EIP_configureVlanFilter.
To configure a VID in the VLAN Filter table, the following API can be used : EIP_configureVidRx.
Since each VID maps to a bit in the VLAN Filter Table, we need to compute the corresponding byte and bit as follows.
For example, in order to configure the VID 150 in the VLAN Filter table:
byte_lookup = (150/8) = 18
bit_lookup = (150 & 0x07) = 6
Therefore, the bit 6 of the byte 18 is set or cleared in the VLAN Filter Table.
In the EtherNet/IP firmware, the VID is fetched from the packet and used for looking-up the required bit in the VLAN Filter Table. If the selected bit is 0, then the frame is not sent to the host processor; while if the selected bit is 1, then the frame is sent to the host processor.
It uses the same lookup mechanism as explained in the "VLAN Filter Table Update Mechanism" section, i.e., we need to compute the corresponding byte and bit as follows.