Skip to content

Commit

Permalink
Merge commit '1db613149fa0389189898a04edd86c9386433361'
Browse files Browse the repository at this point in the history
  • Loading branch information
tyronevb committed May 28, 2020
2 parents 77c635f + 1db6131 commit de42127
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 22 deletions.
40 changes: 29 additions & 11 deletions src/fortygbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,33 @@ def __init__(self, parent, name, address, length_bytes,
'multicast_ip' : 0x20,
'multicast_mask' : 0x24}

@property
def ip_address(self):
ip = self._wbone_rd(self.address + self.reg_map['ip'])
ip_address = IpAddress(ip)
return ip_address

@property
def mac(self):
gbedata = []
for ctr in range(0xC, 0x14, 4):
gbedata.append(self._wbone_rd(self.address + ctr))
gbebytes = []
for d in gbedata:
gbebytes.append((d >> 24) & 0xff)
gbebytes.append((d >> 16) & 0xff)
gbebytes.append((d >> 8) & 0xff)
gbebytes.append((d >> 0) & 0xff)
pd = gbebytes
return Mac('{}:{}:{}:{}:{}:{}'.format(
*pd[2:]))

@property
def port(self):
en_port = self._wbone_rd(self.address + self.reg_map['fabric_port'])
port = en_port & (2 ** 16 - 1)
return port

def post_create_update(self, raw_device_info):
"""
Update the device with information not available at creation.
Expand Down Expand Up @@ -99,7 +126,7 @@ def _wbone_wr(self, addr, val):

def fabric_enable(self):
"""
Enables 40G corei fabric interface.
Enables 40G core fabric interface.
:return:
"""
en_port = self._wbone_rd(self.address + self.reg_map['fabric_en'])
Expand Down Expand Up @@ -133,17 +160,14 @@ def get_mac(self):
:return: Mac object
"""
details = self.get_gbe_core_details()
return details['mac']
return self.mac

def get_ip(self):
"""
Retrieve core's IP address from HW.
:return: IpAddress object
"""
ip = self._wbone_rd(self.address + self.reg_map['ip'])
self.ip_address = IpAddress(ip)
return self.ip_address

def get_port(self):
Expand All @@ -152,8 +176,6 @@ def get_port(self):
:return: int
"""
en_port = self._wbone_rd(self.address + self.reg_map['fabric_port'])
self.port = en_port & (2 ** 16 - 1)
return self.port

def set_port(self, port):
Expand All @@ -170,7 +192,6 @@ def set_port(self, port):
errmsg = 'Error setting 40gbe port to 0x%04x' % port
self.logger.error(errmsg)
raise ValueError(errmsg)
self.port = port

def get_gbe_core_details(self, read_arp=False, read_cpu=False):
"""
Expand Down Expand Up @@ -230,9 +251,6 @@ def get_gbe_core_details(self, read_arp=False, read_cpu=False):
if read_cpu:
# returnval.update(self.get_cpu_details(gbedata))
self.logger.warn('Retrieving CPU packet buffers not yet implemented.')
self.mac = returnval['mac']
self.ip_address = returnval['ip']
self.port = returnval['fabric_port']
return returnval

def get_arp_details(self, port_dump=None):
Expand Down
23 changes: 16 additions & 7 deletions src/gbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ def __init__(self, parent, name, address, length_bytes, device_info=None):
self.name = name
self.address = address
self.length_bytes = length_bytes
self.mac = None
self.ip_address = None
self.port = None
self.fullname = self.parent.host + ':' + self.name
self.block_info = device_info
self.process_device_info(device_info)
Expand All @@ -34,6 +31,18 @@ def __init__(self, parent, name, address, length_bytes, device_info=None):
# if self.parent.is_connected():
# self._check()

@property
def mac(self):
return None

@property
def ip_address(self):
return None

@property
def port(self):
return None

@classmethod
def from_device_info(cls, parent, device_name, device_info, memorymap_dict, **kwargs):
"""
Expand Down Expand Up @@ -99,7 +108,6 @@ def process_device_info(self, device_info):
if mac is None or ip_address is None or port is None:
raise ValueError('%s: 10Gbe interface must '
'have mac, ip and port.' % self.fullname)
self.setup(mac, ip_address, port)

def setup(self, mac, ipaddress, port):
"""
Expand All @@ -109,9 +117,10 @@ def setup(self, mac, ipaddress, port):
:param ipaddress: String or Integer input
:param port: String or Integer input
"""
self.mac = Mac(mac)
self.ip_address = IpAddress(ipaddress)
self.port = port if isinstance(port, int) else int(port)
raise NotImplementedError('This is no longer required as the mac, '
'ip_address and port are no longer stored '
'as attributes. These values are retrieved '
'from the processing node when required.')

def post_create_update(self, raw_device_info):
"""
Expand Down
16 changes: 14 additions & 2 deletions src/onegbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def __init__(self, parent, name, address, length_bytes, device_info=None):
Gbe.__init__(self, parent, name, address, length_bytes, device_info)
self.memmap_compliant = self._check_memmap_compliance()

@property
def mac(self):
return self.get_gbe_core_details()['mac']

@property
def ip_address(self):
return self.get_gbe_core_details()['ip']

@property
def port(self):
return self.get_gbe_core_details()['fabric_port']

def _check_memmap_compliance(self):
"""
Look at the first word of the core's memory map and try to
Expand Down Expand Up @@ -162,9 +174,9 @@ def dhcp_start(self):
"""
Configure this interface, then start a DHCP client on ALL interfaces.
"""
if self.mac is None:
#if self.mac is None:
# TODO get MAC from EEPROM serial number and assign here
self.mac = '0'
# self.mac = '0'
reply, _ = self.parent.transport.katcprequest(
name='tap-start', request_timeout=5,
require_ok=True,
Expand Down
16 changes: 14 additions & 2 deletions src/tengbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def __init__(self, parent, name, address, length_bytes, device_info=None):
Gbe.__init__(self, parent, name, address, length_bytes, device_info)
self.memmap_compliant = self._check_memmap_compliance()

@property
def mac(self):
return self.get_gbe_core_details()['mac']

@property
def ip_address(self):
return self.get_gbe_core_details()['ip']

@property
def port(self):
return self.get_gbe_core_details()['fabric_port']

def _check_memmap_compliance(self):
"""
Look at the first word of the core's memory map and try to
Expand Down Expand Up @@ -162,9 +174,9 @@ def dhcp_start(self):
"""
Configure this interface, then start a DHCP client on ALL interfaces.
"""
if self.mac is None:
#if self.mac is None:
# TODO get MAC from EEPROM serial number and assign here
self.mac = '0'
#self.mac = '0'
reply, _ = self.parent.transport.katcprequest(
name='tap-start', request_timeout=5,
require_ok=True,
Expand Down

0 comments on commit de42127

Please sign in to comment.