aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/periph_manager/n310.py
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-03-27 18:03:52 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:45 -0800
commit6a12add1560545438e1bebc05efbafd05aace4f9 (patch)
treec94dbbbd4da0c7ef41fc8849f174875a13f0b511 /mpm/python/usrp_mpm/periph_manager/n310.py
parentba4fad345d7489b40a7dab83842ac21d13c4f460 (diff)
downloaduhd-6a12add1560545438e1bebc05efbafd05aace4f9.tar.gz
uhd-6a12add1560545438e1bebc05efbafd05aace4f9.tar.bz2
uhd-6a12add1560545438e1bebc05efbafd05aace4f9.zip
mpm: mpm reorganization
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/n310.py')
-rw-r--r--mpm/python/usrp_mpm/periph_manager/n310.py65
1 files changed, 61 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py
index d1c31540b..1b01ac066 100644
--- a/mpm/python/usrp_mpm/periph_manager/n310.py
+++ b/mpm/python/usrp_mpm/periph_manager/n310.py
@@ -17,24 +17,55 @@
"""
N310 implementation module
"""
-from base import periph_manager
+from __future__ import print_function
import struct
+from .base import PeriphManagerBase
+from .net import get_iface_addrs
+from .net import byte_to_mac
+from .net import get_mac_addr
+from logging import getLogger
+LOG = getLogger(__name__)
-class n310(periph_manager):
+
+class n310(PeriphManagerBase):
+ """
+ Holds N310 specific attributes and methods
+ """
hw_pids = "1"
+ mboard_type = "n310"
mboard_eeprom_addr = "e0007000.spi:ec@0:i2c-tunnel"
dboard_eeprom_addrs = {"A": "something", "B": "else"}
dboard_spimaster_addrs = {"A": "something", "B": "else"}
+ interfaces = {}
def __init__(self, *args, **kwargs):
# First initialize parent class - will populate self._eeprom_head and self._eeprom_rawdata
super(n310, self).__init__(*args, **kwargs)
- data = self.read_eeprom_v1(self._eeprom_rawdata)
+ data = self._read_eeprom_v1(self._eeprom_rawdata)
+ # mac 0: mgmt port, mac1: sfp0, mac2: sfp1
+ self.interfaces["mgmt"] = {
+ "mac_addr": byte_to_mac(data[0]),
+ "addrs": get_iface_addrs(byte_to_mac(data[0]))
+ }
+ self.interfaces["sfp0"] = {
+ "mac_addr": byte_to_mac(data[1]),
+ "addrs": get_iface_addrs(byte_to_mac(data[1]))
+ }
+ self.interfaces["sfp1"] = {
+ "mac_addr": byte_to_mac(data[2]),
+ "addrs": get_iface_addrs(byte_to_mac(data[2]))
+ }
+ self.mboard_info["serial"] = data[3] # some format
+
print(data)
# if header.get("dataversion", 0) == 1:
- def read_eeprom_v1(self, data):
+
+ def _read_eeprom_v1(self, data):
+ """
+ read eeprom with data version 1
+ """
# data_version contains
# 6 bytes mac_addr0
# 2 bytes pad
@@ -44,3 +75,29 @@ class n310(periph_manager):
# 2 bytes pad
# 8 bytes serial
return struct.unpack_from("6s 2x 6s 2x 6s 2x 8s", data)
+
+ def get_interfaces(self):
+ """
+ returns available transport interfaces
+ """
+ return [iface for iface in self.interfaces.keys()
+ if iface.startswith("sfp")]
+
+ def get_interface_addrs(self, interface):
+ """
+ returns discovered ipv4 addresses for a given interface
+ """
+ return self.interfaces.get(interface, {}).get("addrs", [])
+
+ def _probe_interface(self, sender_addr):
+ """
+ Get the MAC address of the sender and store it in the FPGA ARP table
+ """
+ mac_addr = get_mac_addr(sender_addr)
+ if mac_addr is not None:
+ # Do something with mac_address
+ return True
+ return False
+
+
+