From bcdea1323e70c73fa0a85c6df55eaed886bded81 Mon Sep 17 00:00:00 2001 From: Andriy Moroz Date: Tue, 3 Oct 2017 01:07:44 +0300 Subject: [PATCH] [swssconfig]: Update Mellanox buffer profile template to work with an incomplete minigraph (#332) Signed-off-by: Andriy Moroz --- .../sample/msn27xx.32ports.buffers.json.j2 | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/swssconfig/sample/msn27xx.32ports.buffers.json.j2 b/swssconfig/sample/msn27xx.32ports.buffers.json.j2 index ee0ae2b0ba9a..5cea9f70c502 100644 --- a/swssconfig/sample/msn27xx.32ports.buffers.json.j2 +++ b/swssconfig/sample/msn27xx.32ports.buffers.json.j2 @@ -169,20 +169,26 @@ {% set switch_role = DEVICE_METADATA['localhost']['type'] %} {%- macro cable_length(port_name) -%} + {%- set cable_len = [] -%} {%- for neighbor in DEVICE_NEIGHBOR -%} - {%- if DEVICE_NEIGHBOR[neighbor]['local_port'] == port_name -%} - {%- set neighbor_role = DEVICE_NEIGHBOR[neighbor]['type'] -%} - {%- set roles1 = switch_role + '_' + neighbor_role %} - {%- set roles2 = neighbor_role + '_' + switch_role -%} - {%- if roles1 in ports2cable -%} - {{ ports2cable[roles1] }} - {%- elif roles2 in ports2cable -%} - {{ ports2cable[roles2] }} - {%- else -%} - {{ supported_cable | last }} - {%- endif -%} + {%- if DEVICE_NEIGHBOR[neighbor].local_port and DEVICE_NEIGHBOR[neighbor].type -%} + {%- if DEVICE_NEIGHBOR[neighbor]['local_port'] == port_name -%} + {%- set neighbor_role = DEVICE_NEIGHBOR[neighbor]['type'] -%} + {%- set roles1 = switch_role + '_' + neighbor_role %} + {%- set roles2 = neighbor_role + '_' + switch_role -%} + {%- if roles1 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} + {%- elif roles2 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} + {%- endif -%} + {% endif %} {% endif %} {%- endfor -%} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ supported_cable | last }} + {%- endif -%} {% endmacro %} {%- macro find_closest_greater_config(speed, cable) -%} @@ -204,9 +210,13 @@ {% set ingress_lossless_pg_pool_size = [] %} {% set used_pg_profiles = [] %} {% for port in PORT %} - {%- set speed = PORT[port]['speed'] -%} + {%- if PORT[port].speed -%} + {%- set speed = PORT[port]['speed'] -%} + {% else %} + {%- set speed = supported_speed|last -%} + {%- endif -%} {%- set cable = cable_length(port) -%} - {%- set port_config = speed + '_' + cable -%} + {%- set port_config = speed|string + '_' + cable -%} {%- if not port_config in portconfig2profile -%} {% set port_config = find_closest_greater_config(speed, cable) -%} {%- endif -%}