VOL-1391: Suport use of any nni port
Change-Id: Ia38672d804f646ebe96d5a13d99960c5eda7e50e
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 1381110..07f49cd 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -417,10 +417,6 @@
if intf_oper_indication.type == "nni":
- # FIXME - creating logical port for 2nd interface throws exception!
- if intf_oper_indication.intf_id != 0:
- return
-
# add_(logical_)port update the port if it exists
port_no, label = self.add_port(intf_oper_indication.intf_id,
Port.ETHERNET_NNI, oper_state)
diff --git a/voltha/adapters/openolt/openolt_flow_mgr.py b/voltha/adapters/openolt/openolt_flow_mgr.py
index c372cf5..e298db2 100644
--- a/voltha/adapters/openolt/openolt_flow_mgr.py
+++ b/voltha/adapters/openolt/openolt_flow_mgr.py
@@ -77,6 +77,7 @@
self.stub = stub
self.device_id = device_id
self.logical_device_id = logical_device_id
+ self.nni_intf_id = None
self.platform = platform
self.logical_flows_proxy = registry('core').get_proxy(
'/logical_devices/{}/flows'.format(self.logical_device_id))
@@ -403,7 +404,8 @@
if classifier[ETH_TYPE] == LLDP_ETH_TYPE:
self.log.debug('lldp flow add')
- self.add_lldp_flow(flow, port_no)
+ nni_intf_id = self.get_nni_intf_id()
+ self.add_lldp_flow(flow, port_no, nni_intf_id)
elif PUSH_VLAN in action:
self.add_upstream_data_flow(intf_id, onu_id, uni_id, port_no, classifier,
@@ -544,10 +546,9 @@
if flow_id is None:
self.log.error("hsia-flow-unavailable")
return
-
flow = openolt_pb2.Flow(
access_intf_id=intf_id, onu_id=onu_id, uni_id=uni_id, flow_id=flow_id,
- flow_type=direction, alloc_id=alloc_id, network_intf_id=0,
+ flow_type=direction, alloc_id=alloc_id, network_intf_id=self.get_nni_intf_id(),
gemport_id=gemport_id,
classifier=self.mk_classifier(classifier),
action=self.mk_action(action),
@@ -582,11 +583,10 @@
flow_id = self.resource_mgr.get_flow_id(
intf_id, onu_id, uni_id, flow_store_cookie
)
-
dhcp_flow = openolt_pb2.Flow(
onu_id=onu_id, uni_id=uni_id, flow_id=flow_id, flow_type=UPSTREAM,
access_intf_id=intf_id, gemport_id=gemport_id,
- alloc_id=alloc_id, network_intf_id=0,
+ alloc_id=alloc_id, network_intf_id=self.get_nni_intf_id(),
priority=logical_flow.priority,
classifier=self.mk_classifier(classifier),
action=self.mk_action(action),
@@ -621,7 +621,7 @@
upstream_flow = openolt_pb2.Flow(
access_intf_id=intf_id, onu_id=onu_id, uni_id=uni_id, flow_id=uplink_flow_id,
- flow_type=UPSTREAM, alloc_id=alloc_id, network_intf_id=0,
+ flow_type=UPSTREAM, alloc_id=alloc_id, network_intf_id=self.get_nni_intf_id(),
gemport_id=gemport_id,
classifier=self.mk_classifier(uplink_classifier),
action=self.mk_action(uplink_action),
@@ -674,7 +674,7 @@
downstream_flow = openolt_pb2.Flow(
access_intf_id=intf_id, onu_id=onu_id, uni_id=uni_id, flow_id=downlink_flow_id,
- flow_type=DOWNSTREAM, alloc_id=alloc_id, network_intf_id=0,
+ flow_type=DOWNSTREAM, alloc_id=alloc_id, network_intf_id=self.get_nni_intf_id(),
gemport_id=gemport_id,
classifier=self.mk_classifier(downlink_classifier),
action=self.mk_action(downlink_action),
@@ -1049,3 +1049,14 @@
else:
to_hash = dumps(classifier, sort_keys=True)
return hashlib.md5(to_hash).hexdigest()[:12]
+
+ def get_nni_intf_id(self):
+ if self.nni_intf_id is not None:
+ return self.nni_intf_id
+
+ port_list = self.adapter_agent.get_ports(self.device_id, Port.ETHERNET_NNI)
+ logical_port = self.adapter_agent.get_logical_port(self.logical_device_id,
+ port_list[0].label)
+ self.nni_intf_id = self.platform.intf_id_from_nni_port_num(logical_port.ofp_port.port_no)
+ self.log.debug("nni-intf-d ", nni_intf_id=self.nni_intf_id)
+ return self.nni_intf_id