Intermediate transport support
Changes:
- Adds a procedure to fill the pipeline in different use cases;
- Adds a new utility function to fill the MPLS flow tables;
- Adds an utility function to print the ports stats
Change-Id: I8928b177ac93e4c05ced4573be87c1c9361d35b5
diff --git a/accton/accton_util.py b/accton/accton_util.py
index 2a8eba3..75a1df5 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -674,6 +674,8 @@
actions=[]
if vrf!=0:
actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf)))
+ if mpls_type!=None:
+ actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=mpls_type)))
#actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(value=vlan_id)))
@@ -1086,6 +1088,7 @@
match.oxm_list.append(ofp.oxm.eth_type(0x8847))
match.oxm_list.append(ofp.oxm.mpls_label(label))
match.oxm_list.append(ofp.oxm.mpls_bos(bos))
+ actions = []
actions = [ofp.action.dec_mpls_ttl(),
ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))]
if (goto_table == 29):
@@ -1114,6 +1117,38 @@
return request
+def add_mpls_flow_pw(ctrl, action_group_id, label, ethertype, bos, goto_table=MPLS_TYPE_FLOW_TABLE, pop=True, send_barrier=False):
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.eth_type(0x8847))
+ match.oxm_list.append(ofp.oxm.mpls_label(label))
+ match.oxm_list.append(ofp.oxm.mpls_bos(bos))
+
+ actions = []
+ actions.append(ofp.action.dec_mpls_ttl())
+ if pop == True:
+ actions.append(ofp.action.copy_ttl_in())
+ actions.append(ofp.action.pop_mpls(ethertype))
+ actions.append(ofp.action.group(action_group_id))
+
+ request = ofp.message.flow_add(
+ table_id=24,
+ cookie=43,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(actions=actions),
+ ofp.instruction.goto_table(goto_table)
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1
+ )
+ logging.info("Inserting MPLS flow , label %ld", label)
+ ctrl.message_send(request)
+
+ if send_barrier:
+ do_barrier(ctrl)
+
+ return request
+
def add_mcast4_routing_flow(ctrl, vlan_id, src_ip, src_ip_mask, dst_ip, action_group_id, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(0x0800))
@@ -1571,6 +1606,28 @@
return mpls_group_id, request
+def add_mpls_swap_label_group(
+ ctrl,
+ ref_gid,
+ subtype,
+ index,
+ label,
+ ):
+
+ action=[]
+ action.append(ofp.action.set_field(ofp.oxm.mpls_label(label)))
+ action.append(ofp.action.group(ref_gid))
+ buckets = [ofp.bucket(actions=action)]
+
+ mpls_group_id = encode_mpls_label_group_id(subtype, index)
+ request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT,
+ group_id=mpls_group_id,
+ buckets=buckets
+ )
+ ctrl.message_send(request)
+
+ return mpls_group_id, request
+
def add_mpls_label_group(ctrl, subtype, index, ref_gid,
lmep_id=-1,
qos_index=-1,