@@ -36,6 +36,33 @@ def __init__(self, parent, name, address, length_bytes,
3636 'multicast_ip' : 0x20 ,
3737 'multicast_mask' : 0x24 }
3838
39+ @property
40+ def ip_address (self ):
41+ ip = self ._wbone_rd (self .address + self .reg_map ['ip' ])
42+ ip_address = IpAddress (ip )
43+ return ip_address
44+
45+ @property
46+ def mac (self ):
47+ gbedata = []
48+ for ctr in range (0xC , 0x14 , 4 ):
49+ gbedata .append (self ._wbone_rd (self .address + ctr ))
50+ gbebytes = []
51+ for d in gbedata :
52+ gbebytes .append ((d >> 24 ) & 0xff )
53+ gbebytes .append ((d >> 16 ) & 0xff )
54+ gbebytes .append ((d >> 8 ) & 0xff )
55+ gbebytes .append ((d >> 0 ) & 0xff )
56+ pd = gbebytes
57+ return Mac ('{}:{}:{}:{}:{}:{}' .format (
58+ * pd [2 :]))
59+
60+ @property
61+ def port (self ):
62+ en_port = self ._wbone_rd (self .address + self .reg_map ['fabric_port' ])
63+ port = en_port & (2 ** 16 - 1 )
64+ return port
65+
3966 def post_create_update (self , raw_device_info ):
4067 """
4168 Update the device with information not available at creation.
@@ -99,7 +126,7 @@ def _wbone_wr(self, addr, val):
99126
100127 def fabric_enable (self ):
101128 """
102- Enables 40G corei fabric interface.
129+ Enables 40G core fabric interface.
103130 :return:
104131 """
105132 en_port = self ._wbone_rd (self .address + self .reg_map ['fabric_en' ])
@@ -133,17 +160,14 @@ def get_mac(self):
133160
134161 :return: Mac object
135162 """
136- details = self .get_gbe_core_details ()
137- return details ['mac' ]
163+ return self .mac
138164
139165 def get_ip (self ):
140166 """
141167 Retrieve core's IP address from HW.
142168
143169 :return: IpAddress object
144170 """
145- ip = self ._wbone_rd (self .address + self .reg_map ['ip' ])
146- self .ip_address = IpAddress (ip )
147171 return self .ip_address
148172
149173 def get_port (self ):
@@ -152,8 +176,6 @@ def get_port(self):
152176
153177 :return: int
154178 """
155- en_port = self ._wbone_rd (self .address + self .reg_map ['fabric_port' ])
156- self .port = en_port & (2 ** 16 - 1 )
157179 return self .port
158180
159181 def set_port (self , port ):
@@ -170,7 +192,6 @@ def set_port(self, port):
170192 errmsg = 'Error setting 40gbe port to 0x%04x' % port
171193 self .logger .error (errmsg )
172194 raise ValueError (errmsg )
173- self .port = port
174195
175196 def get_gbe_core_details (self , read_arp = False , read_cpu = False ):
176197 """
@@ -230,9 +251,6 @@ def get_gbe_core_details(self, read_arp=False, read_cpu=False):
230251 if read_cpu :
231252 # returnval.update(self.get_cpu_details(gbedata))
232253 self .logger .warn ('Retrieving CPU packet buffers not yet implemented.' )
233- self .mac = returnval ['mac' ]
234- self .ip_address = returnval ['ip' ]
235- self .port = returnval ['fabric_port' ]
236254 return returnval
237255
238256 def get_arp_details (self , port_dump = None ):
0 commit comments