Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Etherbone hybrid ip mac #1886

Merged

Conversation

trabucayre
Copy link
Collaborator

As mentionned in #1882 when add_etherbone is used in hybrid mode etherbone and ethernet must have 2 distinct MACs

This PR contains 3 commits:

  1. new constants to overrides ethernet mac address at build time
  2. add_ip_constant is moved as an helper (to be used by add_ethernet and add_etherbone) and a new helper is added to define MACADDRx constant
  3. add_etherbone signature is updated to allows user to specify local/remote IP and mac address. 2 assert are used to check if etherbone and ethernet IPs/MACs are different. This commits also add constants for ethernet configuration

Copy link
Owner

@enjoy-digital enjoy-digital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @trabucayre, this looks good. Can you just take into account the few comments? Can you also do a test with litex_sim --with-ethernet --with-etherbone to ensure this is working and updated? (and update if not).

@@ -41,6 +41,17 @@ def build_time(with_time=True):
fmt = "%Y-%m-%d %H:%M:%S" if with_time else "%Y-%m-%d"
return datetime.datetime.fromtimestamp(time.time()).strftime(fmt)

def add_ip_constants(soc, name, ip):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with add_mac_address_constants, maybe rename to add_ip_address_constants.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

assert int(_ip[n]) < 256
soc.add_constant(f"{name}{n+1}", int(_ip[n]))

def add_mac_address_constants(soc, name, mac_address):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a minimal check as for IP address to ensure mac address is < 2**48.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1803,6 +1808,9 @@ def add_ip_constants(name, ip):
def add_etherbone(self, name="etherbone", phy=None, phy_cd="eth", data_width=8,
mac_address = 0x10e2d5000000,
ip_address = "192.168.1.50",
ethernet_mac_address = 0x10e2d5000000,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid conflicting addresses as default value: 0x10e2d5000001.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1803,6 +1808,9 @@ def add_ip_constants(name, ip):
def add_etherbone(self, name="etherbone", phy=None, phy_cd="eth", data_width=8,
mac_address = 0x10e2d5000000,
ip_address = "192.168.1.50",
ethernet_mac_address = 0x10e2d5000000,
ethernet_local_ip = "192.168.1.50",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid conflicting addresses as default value: 192.168.1.51.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1814,6 +1822,12 @@ def add_etherbone(self, name="etherbone", phy=None, phy_cd="eth", data_width=8,
from liteeth.frontend.etherbone import LiteEthEtherbone
from liteeth.phy.model import LiteEthPHYModel

# Parameters.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably move these checks directly to the with_ethmac section.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

…to add_ip_address_constants, adding function to add MACADDRx constant
…/remote ip as parameters, sanity check when hybrid mode and adding ip/mac constants
@trabucayre trabucayre force-pushed the etherbone_hybrid_ip_mac branch from 11dad10 to 7f21104 Compare February 7, 2024 11:51
Copy link
Owner

@enjoy-digital enjoy-digital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @trabucayre!

@enjoy-digital enjoy-digital merged commit 0ed44a2 into enjoy-digital:master Feb 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants