|
| 1 | +{# Default values which will be used if no actual configura available #} |
| 2 | +{% set default_cable = '300m' %} |
| 3 | +{% set default_ports_num = 64 -%} |
| 4 | + |
| 5 | +{# Port configuration to cable length look-up table #} |
| 6 | +{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} |
| 7 | +{# Roles described in the minigraph #} |
| 8 | +{% set ports2cable = { |
| 9 | + 'torrouter_server' : '5m', |
| 10 | + 'leafrouter_torrouter' : '40m', |
| 11 | + 'spinerouter_leafrouter' : '300m' |
| 12 | + } |
| 13 | +%} |
| 14 | + |
| 15 | +{%- macro cable_length(port_name) -%} |
| 16 | + {%- set cable_len = [] -%} |
| 17 | + {%- for local_port in DEVICE_NEIGHBOR -%} |
| 18 | + {%- if local_port == port_name -%} |
| 19 | + {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} |
| 20 | + {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} |
| 21 | + {%- set neighbor_role = neighbor.type -%} |
| 22 | + {%- set roles1 = switch_role + '_' + neighbor_role %} |
| 23 | + {%- set roles2 = neighbor_role + '_' + switch_role -%} |
| 24 | + {%- set roles1 = roles1 | lower -%} |
| 25 | + {%- set roles2 = roles2 | lower -%} |
| 26 | + {%- if roles1 in ports2cable -%} |
| 27 | + {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} |
| 28 | + {%- elif roles2 in ports2cable -%} |
| 29 | + {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} |
| 30 | + {%- endif -%} |
| 31 | + {%- endif -%} |
| 32 | + {%- endif -%} |
| 33 | + {%- endfor -%} |
| 34 | + {%- if cable_len -%} |
| 35 | + {{ cable_len.0 }} |
| 36 | + {%- else -%} |
| 37 | + {{ default_cable }} |
| 38 | + {%- endif -%} |
| 39 | +{% endmacro %} |
| 40 | + |
| 41 | +{%- if DEVICE_METADATA is defined %} |
| 42 | +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} |
| 43 | +{%- endif -%} |
| 44 | + |
| 45 | +{# Generate list of ports if not defined #} |
| 46 | +{% if PORT is not defined %} |
| 47 | + {% set PORT = [] %} |
| 48 | + {% for port_idx in range(0,default_ports_num) %} |
| 49 | + {% if PORT.append("Ethernet%d" % (port_idx*4)) %}{% endif %} |
| 50 | + {% endfor %} |
| 51 | +{% endif -%} |
| 52 | + |
| 53 | +{% set port_names_list = [] %} |
| 54 | +{% for port in PORT %} |
| 55 | + {%- if port_names_list.append(port) %}{% endif %} |
| 56 | +{% endfor %} |
| 57 | +{% set port_names = port_names_list | join(',') -%} |
| 58 | + |
| 59 | +{ |
| 60 | + "BUFFER_POOL": { |
| 61 | + "ingress_lossless_pool": { |
| 62 | + "size": "47218432", |
| 63 | + "type": "ingress", |
| 64 | + "mode": "dynamic", |
| 65 | + "xoff": "17708800" |
| 66 | + }, |
| 67 | + "egress_lossy_pool": { |
| 68 | + "size": "18874368", |
| 69 | + "type": "egress", |
| 70 | + "mode": "dynamic", |
| 71 | + "xoff": "0" |
| 72 | + } |
| 73 | + }, |
| 74 | + "BUFFER_PROFILE": { |
| 75 | + "ingress_lossless_profile": { |
| 76 | + "pool":"[BUFFER_POOL|ingress_lossless_pool]", |
| 77 | + "xoff":"1433600", |
| 78 | + "size":"1518", |
| 79 | + "dynamic_th":"-4", |
| 80 | + "xon_offset":"6272" |
| 81 | + }, |
| 82 | + "ingress_lossy_profile": { |
| 83 | + "pool":"[BUFFER_POOL|ingress_lossless_pool]", |
| 84 | + "size":"0", |
| 85 | + "static_th":"9721600" |
| 86 | + }, |
| 87 | + "egress_lossless_profile": { |
| 88 | + "pool":"[BUFFER_POOL|egress_lossy_pool]", |
| 89 | + "size":"0", |
| 90 | + "static_th":"9721600" |
| 91 | + }, |
| 92 | + "egress_lossy_profile": { |
| 93 | + "pool":"[BUFFER_POOL|egress_lossy_pool]", |
| 94 | + "size":"1518", |
| 95 | + "dynamic_th":"3" |
| 96 | + } |
| 97 | + }, |
| 98 | + "BUFFER_PG": { |
| 99 | + "{{ port_names }}|0-3": { |
| 100 | + "profile" : "[BUFFER_PROFILE|egress_lossless_profile]" |
| 101 | + }, |
| 102 | + "{{ port_names }}|4-5": { |
| 103 | + "profile" : "[BUFFER_PROFILE|ingress_lossless_profile]" |
| 104 | + }, |
| 105 | + "{{ port_names }}|6-7": { |
| 106 | + "profile" : "[BUFFER_PROFILE|egress_lossless_profile]" |
| 107 | + } |
| 108 | + }, |
| 109 | + "BUFFER_QUEUE": { |
| 110 | + "{{ port_names }}|4-5": { |
| 111 | + "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" |
| 112 | + }, |
| 113 | + "{{ port_names }}|0-3": { |
| 114 | + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" |
| 115 | + }, |
| 116 | + "{{ port_names }}|6-7": { |
| 117 | + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" |
| 118 | + } |
| 119 | + } |
| 120 | +} |
0 commit comments