mirror of
https://github.com/enjoy-digital/liteeth.git
synced 2025-01-03 03:43:37 -05:00
core/ip/tx: Add broadcast capability.
This commit is contained in:
parent
aff1916a03
commit
dc96269c8f
3 changed files with 15 additions and 3 deletions
|
@ -60,6 +60,11 @@ arp_header_fields = {
|
|||
}
|
||||
arp_header = Header(arp_header_fields, arp_header_length, swap_field_bytes=True)
|
||||
|
||||
# Broadcast Constants ------------------------------------------------------------------------------
|
||||
|
||||
bcast_ip_mask = 0xff
|
||||
bcast_mac_address = 0xffffffffffff
|
||||
|
||||
# Multicast Constants ------------------------------------------------------------------------------
|
||||
|
||||
mcast_oui = C(0x01005e, 24)
|
||||
|
|
|
@ -68,7 +68,7 @@ class LiteEthARPTX(Module):
|
|||
packetizer.sink.target_mac.eq(sink.mac_address),
|
||||
).Elif(sink.request,
|
||||
packetizer.sink.opcode.eq(arp_opcode_request),
|
||||
packetizer.sink.target_mac.eq(0xffffffffffff),
|
||||
packetizer.sink.target_mac.eq(bcast_mac_address),
|
||||
)
|
||||
]
|
||||
self.comb += [
|
||||
|
|
|
@ -110,7 +110,8 @@ class LiteEthIPTX(Module):
|
|||
"last",
|
||||
"last_be",
|
||||
"protocol",
|
||||
"data"}),
|
||||
"data",
|
||||
}),
|
||||
packetizer.sink.valid.eq(sink.valid & checksum.done),
|
||||
sink.ready.eq(packetizer.sink.ready & checksum.done),
|
||||
packetizer.sink.target_ip.eq(sink.ip_address),
|
||||
|
@ -130,9 +131,15 @@ class LiteEthIPTX(Module):
|
|||
self.submodules.fsm = fsm = FSM(reset_state="IDLE")
|
||||
fsm.act("IDLE",
|
||||
If(packetizer.source.valid,
|
||||
If(sink.ip_address[28:] == mcast_ip_mask,
|
||||
# Broadcast.
|
||||
If(sink.ip_address[0:8] == bcast_ip_mask,
|
||||
NextValue(target_mac, bcast_mac_address),
|
||||
NextState("SEND")
|
||||
# Multicast.
|
||||
).Elif(sink.ip_address[28:] == mcast_ip_mask,
|
||||
NextValue(target_mac, Cat(sink.ip_address[:23], 0, mcast_oui)),
|
||||
NextState("SEND")
|
||||
# Unicast.
|
||||
).Else(
|
||||
NextState("SEND_MAC_ADDRESS_REQUEST")
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue