VOL-669: Openolt adapter - eapol trap
Change-Id: Ieb20d6242cc321c5be68df4f47816ff4e432f3fe
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 35ef09f..d12c953 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -41,6 +41,12 @@
ASFVOLT_HSIA_ID = 13 # FIXME
ASFVOLT_DHCP_TAGGED_ID = 5 # FIXME
+ASFVOLT_EAPOL_ID = 1 # FIXME
+ASFVOLT_DOWNLINK_EAPOL_ID = 2 # FIXME
+
+# FIXME - BRDCM_DEFAULT_VLAN in broadcom_onu.py
+ASFVOLT16_DEFAULT_VLAN = 4091
+
Onu = collections.namedtuple("Onu", ["intf_id", "onu_id"])
"""
@@ -658,7 +664,7 @@
# FIXME - Why ignore downstream flows?
if is_down_stream is False:
intf_id, onu_id = self.parse_port_no(classifier_info['in_port'])
- self.divide_and_add_flow(onu_id, intf_id, classifier_info, action_info)
+ self.divide_and_add_flow(intf_id, onu_id, classifier_info, action_info)
except Exception as e:
self.log.exception('failed-to-install-flow', e=e, flow=flow)
@@ -668,11 +674,11 @@
# FIXME - No need for divide_and_add_flow if
# both upstream and downstream flows
# are acted upon (not just upstream flows).
- def divide_and_add_flow(self, onu_id, intf_id, classifier, action):
+ def divide_and_add_flow(self, intf_id, onu_id, classifier, action):
if 'ip_proto' in classifier:
if classifier['ip_proto'] == 17:
- self.log.info('dhcp flow add')
- self.add_dhcp_trap(classifier, action, onu_id, intf_id)
+ self.log.debug('dhcp flow add')
+ self.add_dhcp_trap(intf_id, onu_id, classifier, action)
elif classifier['ip_proto'] == 2:
self.log.info('igmp flow add ignored')
else:
@@ -680,14 +686,18 @@
action=action)
elif 'eth_type' in classifier:
if classifier['eth_type'] == 0x888e:
- self.log.error('epol flow add ignored')
+ self.log.info('eapol flow add')
+ self.add_eapol_flow(intf_id, onu_id, classifier, action)
elif 'push_vlan' in action:
- self.add_data_flow(onu_id, intf_id, classifier, action)
+ # FIXME - Is this required?
+ #self.prepare_and_add_eapol_flow(intf_id, onu_id, classifier, action)
+ # ASFVOLT_EAPOL_ID_DATA_VLAN, ASFVOLT_DOWNLINK_EAPOL_ID_DATA_VLAN)
+ self.add_data_flow(intf_id, onu_id, classifier, action)
else:
self.log.info('Invalid-flow-type-to-handle', classifier=classifier,
action=action)
- def add_data_flow(self, onu_id, intf_id, uplink_classifier, uplink_action):
+ def add_data_flow(self, intf_id, onu_id, uplink_classifier, uplink_action):
downlink_classifier = dict(uplink_classifier)
downlink_action = dict(uplink_action)
@@ -703,7 +713,7 @@
# To-Do right now only one GEM port is supported, so below method
# will take care of handling all the p bits.
# We need to revisit when mulitple gem port per p bits is needed.
- self.add_hsia_flow(onu_id, intf_id, uplink_classifier, uplink_action,
+ self.add_hsia_flow(intf_id, onu_id, uplink_classifier, uplink_action,
downlink_classifier, downlink_action, ASFVOLT_HSIA_ID)
def mk_classifier(self, classifier_info):
@@ -756,11 +766,11 @@
return
return action
- def add_hsia_flow(self, onu_id, intf_id, uplink_classifier, uplink_action,
+ def add_hsia_flow(self, intf_id, onu_id, uplink_classifier, uplink_action,
downlink_classifier, downlink_action, hsia_id):
gemport_id = self.mk_gemport_id(onu_id)
- flow_id = self.mk_flow_id(onu_id, intf_id, hsia_id)
+ flow_id = self.mk_flow_id(intf_id, onu_id, hsia_id)
self.log.info('add upstream flow', onu_id=onu_id, classifier=uplink_classifier,
action=uplink_action, gemport_id=gemport_id, flow_id=flow_id)
@@ -785,7 +795,7 @@
self.stub.FlowAdd(flow)
time.sleep(0.1) # FIXME
- def add_dhcp_trap(self, classifier, action, onu_id, intf_id):
+ def add_dhcp_trap(intf_id, onu_id, self, classifier, action):
self.log.info('add dhcp trap', classifier=classifier, action=action)
@@ -795,17 +805,55 @@
classifier.pop('vlan_vid', None)
gemport_id = self.mk_gemport_id(onu_id)
- flow_id = self.mk_flow_id(onu_id, intf_id, ASFVOLT_DHCP_TAGGED_ID)
+ flow_id = self.mk_flow_id(intf_id, onu_id, ASFVOLT_DHCP_TAGGED_ID)
- flow = openolt_pb2.Flow(
+ upstream_flow = openolt_pb2.Flow(
onu_id=onu_id, flow_id=flow_id, flow_type="upstream",
gemport_id=gemport_id, classifier=self.mk_classifier(classifier),
action=self.mk_action(action))
- self.stub.FlowAdd(flow)
+ self.stub.FlowAdd(upstream_flow)
- def mk_flow_id(self, onu_id, intf_id, id):
- # Tp-Do Need to generate unique flow ID using
+ def add_eapol_flow(self, intf_id, onu_id, uplink_classifier, uplink_action,
+ uplink_eapol_id=ASFVOLT_EAPOL_ID,
+ downlink_eapol_id=ASFVOLT_DOWNLINK_EAPOL_ID,
+ vlan_id=ASFVOLT16_DEFAULT_VLAN):
+
+ self.log.info('add eapol flow', classifier=uplink_classifier, action=uplink_action)
+
+ downlink_classifier = dict(uplink_classifier)
+ downlink_action = dict(uplink_action)
+
+ gemport_id = self.mk_gemport_id(onu_id)
+ uplink_flow_id = self.mk_flow_id(intf_id, onu_id, uplink_eapol_id)
+
+ # Add Upstream EAPOL Flow.
+ uplink_classifier['pkt_tag_type'] = 'single_tag'
+ uplink_classifier['vlan_vid'] = vlan_id
+ uplink_action.clear()
+ uplink_action['trap_to_host'] = True
+
+ upstream_flow = openolt_pb2.Flow(
+ onu_id=onu_id, flow_id=uplink_flow_id, flow_type="upstream",
+ gemport_id=gemport_id, classifier=self.mk_classifier(uplink_classifier),
+ action=self.mk_action(uplink_action))
+
+ self.stub.FlowAdd(upstream_flow)
+
+ # Add Downstream EAPOL Flow.
+ downlink_flow_id = self.mk_flow_id(intf_id, onu_id, downlink_eapol_id)
+ downlink_classifier['pkt_tag_type'] = 'single_tag'
+ downlink_classifier['vlan_vid'] = vlan_id
+
+ downstream_flow = openolt_pb2.Flow(
+ onu_id=onu_id, flow_id=downlink_flow_id, flow_type="downstream",
+ gemport_id=gemport_id, classifier=self.mk_classifier(downlink_classifier),
+ action=self.mk_action(downlink_action))
+
+ self.stub.FlowAdd(downstream_flow)
+
+ def mk_flow_id(self, intf_id, onu_id, id):
+ # To-Do Need to generate unique flow ID using
# OnuID, IntfId, id
# BAL accepts flow_id till 16384. So we are
# using only onu_id and id to generate flow ID.