In the Remote Wakeup Magic Packet based power saving mode, the reception of expected remote wakeup packet by MAC receiver triggers the exit from low-power mode. The MAC enters power saving mode when PWRDWN bit of MAC_PMT_Control_Status register is programmed to 1. Exit from the remote wakeup based low-power mode is enabled by programming RWKPKTEN bit of MAC_PMT_Control_Status register to 1.
The MAC implements a filter lookup table (programmed through MAC_RWK_Packet_Filter register) in which CRC, offset, and byte mask of the pattern embedded in remote wakeup packet and the filter operation commands are programmed.
The pattern embedded in the remote wakeup packet is located at any offset after the Destination address and Source address fields. In addition to the CRC match for the pattern, the MAC receiver also checks the following, to detect the received packet as a valid remote wakeup packet:
- The packet must be addressed to it (Destination Address of the received packet should perfect match the MAC_Address0_High and MAC_Address0_Low registers) or with multicast/broadcast address
- The packet must not have length error, FCS error, dribble bit error, MII error, and collision
- The packet must not be runt (length including Ethernet header and FCS is at least 64 bytes)
When a valid remote wakeup packet is received, the MAC receiver sets the RWKPRCVD bit in MAC_PMT_Control_Status register and triggers the PMT interrupt . The PMTIS bit in MAC_Interrupt_Status register is set when power-gating is not enabled in low-power mode. An interrupt is triggered to the application (sbd_intr) when interrupt is enabled (PMTIE bit in MAC_Interrupt_Enable register is set).
The Remote Wakeup Filters are arranged in blocks of 4 filters each and each such block have eight 32-bit wide registers, viz. wkuppktfilter_reg0-7, wkuppktfilter_reg8-15, wkuppktfilter_reg16-23 and wkuppktfilter_reg24-31. The fields of Remote Wakeup Filter are as follows:
Filter i Byte Mask
The filter i byte mask register defines the bytes of the packet that are examined by filter i (0, 1, 2, 3, .., 15) to determine whether or not a packet is a wake-up packet.
- The MSB (31st bit) must be zero.
- Bit j[30:0] is the byte mask.
- If Bit j (byte number) of the byte mask is set, the CRC block processes the Filter i Offset + j of the incoming packet; otherwise Filter i Offset + j is ignored
Filter i Command
The 4-bit filter i command controls the filter i operation.
- Bit 3 specifies the address type, defining the destination address type of the pattern. When the bit is set, the pattern applies to only multicast packets; when the bit is reset, the pattern applies only to unicast packet
- Bit 2 (Inverse Mode), when set, reverses the logic of the CRC16 hash function signal, to reject a packet with matching CRC-16 value. Bit 2, along with Bit 1, allows a MAC to reject a subset of remote wake-up packets by creating filter logic such as "Pattern 1 AND NOT Pattern 2".
- Bit 1 (And_Previous) implements the Boolean logic. When set, the result of the
current entry is logically ANDed with the result of the previous filter. This
AND logic allows a filter pattern longer than 32 bytes by splitting the mask
among two, three, or four filters. This depends on the number of filters that
have the And_Previous bit set. The details are as follows:
- The And_Previous bit setting is applicable within a
set of 4 filters.
- Setting of And_Previous bit of filter that is not
enabled has no effect, that is setting And_Previous bit of lowest number
filter in the set of 4 filters has no effect. For example, setting of
And_Previous bit of Filter 0 has no effect.
- If And_Previous bit is set for filter to form AND
chained filter, the AND chain breaks at the point any filter is not
enabled. For example: If Filter 2 And_Previous bit is set (bit 1 in
Filter 2 command is set) but Filter 1 is not enabled (bit 0 in Filter 1
command is reset), then only Filter 2 result is considered. If Filter 2
And_Previous bit is set (bit 1 in Filter 2 command is set), Filter 3
And_Previous bit is set (bit 1 in Filter 3 command is set), but Filter 1
is not enabled (bit 0 in Filter 1 command is reset), then only Filter 2
result ANDed with Filter 3 result is considered. If Filter 2
And_Previous bit is set (bit 1 in Filter 2 command is set), Filter 3
And_Previous bit is set (bit 1 in Filter 3 command is set), but Filter 2
is not enabled (bit 0 in Filter 2 command is reset), then since setting
of Filter 2 And_Previous bit has no effect only Filter 1 result ORed
with Filter 3 result is considered.
- If filters chained by And_Previous bit setting have
complementary programming, then a frame can never pass the AND chained
filter. For example, if Filter 2 And_Previous bit is set (bit 1 in
Filter 2 command is set), Filter 1 Address_Type bit is set (bit 3 in
Filter 1 command is set) indicating multicast detection and Filter 2
Address_Type bit is reset (bit 3 in Filter 2 command is reset)
indicating unicast detection or conversely, a remote wakeup frame does
not pass the AND chained filter as a remote wakeup frame cannot be of
both unicast and multicast address type.
Filter i Offset
The filter i offset register defines the offset (within the packet) from which the filter i examines the packets.
- This 8-bit pattern-offset is the offset for the filter i first byte to be examined.
- The minimum allowed offset is 12, which refers to the 13th byte of the packet.
- The offset value 0 refers to the first byte of the packet.
Filter i CRC-16
The filter i CRC-16 register contains the CRC-16 value calculated from the pattern and the byte mask programmed in the Remote Wakeup filter register.
- The 16-bit CRC calculation uses the following polynomial: G(x) =
x16 + x15 + x2 + 1
- Each mask, used in the hash function calculation, is compared with a 16-bit value associated with that mask. Each filter has the following:
- 32-bit Mask: Each bit in this mask corresponds to one byte in the detected packet. If the bit is 1, the corresponding byte is taken into the CRC-16 calculation.
- 8-bit Offset Pointer: Specifies the byte to start the CRC-16 computation. The
pointer and the mask are used together to locate the bytes to be used in
the CRC-16 calculations.
The Remote Wakeup Filter registers are implemented
as 8 indirect access registers (wkuppktfilter_reg#i) and accessed by application
through MAC_RWK_Packet_Filter register. When the Remote Wakeup Filters are to be
programmed, the entire set of wkuppktfilter_reg registers must be written. The
wkuppktfilter_reg register is programmed by sequentially writing the 8, 16, or 32
register values in MAC_RWK_Packet_Filter register for wkuppktfilter_reg0,
wkuppktfilter_reg1, ..., wkuppktfilter_reg31 respectively. The wkuppktfilter_reg
register is read in a similar way. The MAC updates the wkuppktfilter_reg register
current pointer value in RWKPTR field of MAC_PMT_Control_Status register.
Note: When MAC_RWK_Packet_Filter register is written, the content
is transferred from CSR clock domain to PHY receive clock domain after the write
operation, there can not be any further writes to the MAC_RWK_Packet_Filter register
until the first write is updated in PHY receive clock domain. Otherwise, the second
write operation does not get updated to the PHY receive clock domain. Therefore, the
delay between two writes to the MAC_RWK_Packet_Filter register can be at least
4 cycles of the PHY receive clock.
The PMT interrupt signal is asserted when a valid
remote wake-up packet is received. As the PMT interrupt signal is generated in the
PHY Rx clock domain, the PMT interrupt signal is not cleared immediately when the
PMT Control and Status register is read. This is because the resultant clear signal
has to cross to the PHY Rx clock domain, and then clear the interrupt source. This
delay is at least 4 clock cycles of Rx clock and can be significant when the
Ethernet module is operating in the 10Mbps mode. When the application clears the
PWRDWN bit in Remote Wake-Up Packet Detection register, the MAC comes out of the
power-down mode, but this event does not generate the PMT interrupt.
The MAC implements a set of registers for Layer3 and Layer4 based packet filtering. In a register set, there is a control register, such as MAC_L3_L4_Control (#i) (for i = 0; i <=3), to control the packet filtering. In addition, there are five address registers to program the Layer 3 and Layer 4 fields to be matched, such as:
- MAC_Layer4_Address(#i) (for i = 0; <=3)
- MAC_Layer3_Address0_Reg(#i) (for i = 0; i <=3)
- MAC_Layer3_Address1_Reg(#i) (for i = 0; i =3)
- MAC_Layer3_Address2_Reg(#i) (for i = 0; i <=3)
- MAC_Layer3_Address3_Reg(#i) (for i = 0; i =<3)