Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame^] | 1 | import Queue |
| 2 | |
| 3 | from oftest.testutils import * |
| 4 | from accton_util import * |
| 5 | |
| 6 | def fill_mcast_pipeline_L3toL3( |
| 7 | controller, |
| 8 | logging, |
| 9 | ports, |
| 10 | is_ingress_tagged, |
| 11 | is_egress_tagged, |
| 12 | is_vlan_translated, |
| 13 | is_max_vlan |
| 14 | ): |
| 15 | """ |
| 16 | This method, according to the scenario, fills properly |
| 17 | the pipeline. The method generates using ports data the |
| 18 | necessary information to fill the multicast pipeline and |
| 19 | fills properly the pipeline which consists in this scenario: |
| 20 | |
| 21 | i) to create l2 interface groups; |
| 22 | ii)to create l3 interface groups; |
| 23 | iii) to create l3 multicast groups; |
| 24 | iv) to add multicast flows; |
| 25 | v) to add termination; flows; |
| 26 | vi) to add vlan flows |
| 27 | |
| 28 | Scenarios: |
| 29 | 1) ingress tagged, egress tagged, translation |
| 30 | """ |
| 31 | |
| 32 | Groups = Queue.LifoQueue( ) |
| 33 | MAX_INTERNAL_VLAN = 4094 |
| 34 | port_to_in_vlan = {} |
| 35 | port_to_out_vlan = {} |
| 36 | port_to_src_mac = {} |
| 37 | port_to_src_mac_str = {} |
| 38 | port_to_dst_mac = {} |
| 39 | port_to_dst_mac_str = {} |
| 40 | port_to_src_ip = {} |
| 41 | port_to_src_ip_str = {} |
| 42 | port_to_intf_src_mac = {} |
| 43 | port_to_intf_src_mac_str = {} |
| 44 | src_ip_0 = 0xc0a80100 |
| 45 | src_ip_0_str = "192.168.1.%s" |
| 46 | dst_ip = 0xe0000001 |
| 47 | switch_mac = [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ] |
| 48 | |
| 49 | for port in ports: |
| 50 | in_vlan_id = port + 1 |
| 51 | out_vlan_id = MAX_INTERNAL_VLAN - port |
| 52 | src_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, port ] |
| 53 | src_mac_str = ':'.join( [ '%02X' % x for x in src_mac ] ) |
| 54 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, port ] |
| 55 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 56 | src_ip = src_ip_0 + port |
| 57 | src_ip_str = src_ip_0_str % port |
| 58 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, port ] |
| 59 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 60 | port_to_in_vlan[port] = in_vlan_id |
| 61 | port_to_out_vlan[port] = out_vlan_id |
| 62 | port_to_src_mac[port] = src_mac |
| 63 | port_to_src_mac_str[port] = src_mac_str |
| 64 | port_to_dst_mac[port] = dst_mac |
| 65 | port_to_dst_mac_str[port] = dst_mac_str |
| 66 | port_to_src_ip[port] = src_ip |
| 67 | port_to_src_ip_str[port] = src_ip_str |
| 68 | port_to_intf_src_mac[port] = intf_src_mac |
| 69 | port_to_intf_src_mac_str[port] = intf_src_mac_str |
| 70 | |
| 71 | for port in ports: |
| 72 | L3_Groups = [] |
| 73 | for other_port in ports: |
| 74 | # add l2 interface group |
| 75 | l2gid, msg = add_one_l2_interface_group( controller, other_port, vlan_id=port_to_out_vlan[other_port], |
| 76 | is_tagged=True, send_barrier=False ) |
| 77 | Groups._put( l2gid ) |
| 78 | # add l3 interface group |
| 79 | l3group_ucast_msg = add_l3_interface_group( controller, other_port, port_to_out_vlan[other_port], port_to_in_vlan[other_port], |
| 80 | port_to_intf_src_mac[other_port] ) |
| 81 | L3_Groups.append(l3group_ucast_msg.group_id) |
| 82 | Groups._put( l3group_ucast_msg.group_id ) |
| 83 | |
| 84 | # add mcast group |
| 85 | mcat_group_msg = add_l3_mcast_group( controller, port_to_in_vlan[port], port_to_in_vlan[port], L3_Groups ) |
| 86 | Groups._put( mcat_group_msg.group_id ) |
| 87 | # add mcast flow |
| 88 | add_mcast4_routing_flow( controller, port_to_in_vlan[port], port_to_src_ip[port], 0, dst_ip, mcat_group_msg.group_id ) |
| 89 | # add termination flow |
| 90 | add_termination_flow( controller, port, 0x0800, switch_mac, port_to_in_vlan[port] ) |
| 91 | # add vlan flow table |
| 92 | add_one_vlan_table_flow( controller, port, port_to_in_vlan[port], flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 93 | |
| 94 | return ( |
| 95 | port_to_in_vlan, |
| 96 | port_to_out_vlan, |
| 97 | port_to_src_mac_str, |
| 98 | port_to_dst_mac_str, |
| 99 | port_to_src_ip_str, |
| 100 | port_to_intf_src_mac_str, |
| 101 | Groups |
| 102 | ) |