Merge pull request #41 from shuffle2/mcast

iptx: support multicast mac and bypass arp table
This commit is contained in:
enjoy-digital 2020-05-19 09:51:11 +02:00 committed by GitHub
commit 58e1681f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -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,15 +124,22 @@ 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),
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)
fsm.act("SEND_MAC_ADDRESS_REQUEST",
arp_table.request.valid.eq(1),