From 6d00ec1cc45a338a83bfcca03afa7f2bf473052f Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Sun, 17 May 2020 14:45:51 -0700 Subject: [PATCH] iptx: support multicast mac and bypass arp table --- liteeth/core/ip.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/liteeth/core/ip.py b/liteeth/core/ip.py index 4890628..34a942b 100644 --- a/liteeth/core/ip.py +++ b/liteeth/core/ip.py @@ -112,9 +112,9 @@ class LiteEthIPTX(Module): sink.ready.eq(packetizer.sink.ready & checksum.done), packetizer.sink.target_ip.eq(sink.ip_address), packetizer.sink.protocol.eq(sink.protocol), - packetizer.sink.total_length.eq(sink.length + (0x5*4)), + packetizer.sink.total_length.eq(ipv4_header.length + sink.length), packetizer.sink.version.eq(0x4), # ipv4 - packetizer.sink.ihl.eq(0x5), # 20 bytes + packetizer.sink.ihl.eq(ipv4_header.length//4), packetizer.sink.identification.eq(0), packetizer.sink.ttl.eq(0x80), packetizer.sink.sender_ip.eq(ip_address), @@ -124,13 +124,20 @@ class LiteEthIPTX(Module): ] target_mac = Signal(48, reset_less=True) + mcast_oui = C(0x01005e, 24) + mcast_ip_mask = 224 >> 4 self.submodules.fsm = fsm = FSM(reset_state="IDLE") fsm.act("IDLE", packetizer.source.ready.eq(1), If(packetizer.source.valid, packetizer.source.ready.eq(0), - NextState("SEND_MAC_ADDRESS_REQUEST") + If(sink.ip_address[28:] == mcast_ip_mask, + NextValue(target_mac, Cat(sink.ip_address[:23], 0, mcast_oui)), + NextState("SEND") + ).Else( + NextState("SEND_MAC_ADDRESS_REQUEST") + ) ) ) self.comb += arp_table.request.ip_address.eq(sink.ip_address)