[Mellanox] Add support for a new platform LS-SN2700
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
This commit is contained in:
parent
f947172c0a
commit
6383de3907
@ -0,0 +1,162 @@
|
||||
{# Default values which will be used if no actual configura available #}
|
||||
{% set default_cable = '300m' %}
|
||||
{% set default_ports_num = 32 -%}
|
||||
|
||||
{# Port configuration to cable length look-up table #}
|
||||
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
|
||||
{# Roles described in the minigraph #}
|
||||
{% set ports2cable = {
|
||||
'torrouter_server' : '5m',
|
||||
'leafrouter_torrouter' : '40m',
|
||||
'spinerouter_leafrouter' : '300m'
|
||||
}
|
||||
%}
|
||||
|
||||
{%- macro cable_length(port_name) -%}
|
||||
{%- set cable_len = [] -%}
|
||||
{%- for local_port in DEVICE_NEIGHBOR -%}
|
||||
{%- if local_port == port_name -%}
|
||||
{%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor_role = neighbor.type -%}
|
||||
{%- set roles1 = switch_role + '_' + neighbor_role %}
|
||||
{%- set roles2 = neighbor_role + '_' + switch_role -%}
|
||||
{%- set roles1 = roles1 | lower -%}
|
||||
{%- set roles2 = roles2 | lower -%}
|
||||
{%- 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 -%}
|
||||
{{ default_cable }}
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{%- if DEVICE_METADATA is defined %}
|
||||
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
||||
{%- endif -%}
|
||||
|
||||
{# Generate list of ports if not defined #}
|
||||
{% if PORT is not defined %}
|
||||
{% set PORT = [] %}
|
||||
{% for port_idx in range(0,default_ports_num) %}
|
||||
{% if PORT.append("Ethernet%d" % (port_idx*4)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
{% set port_names_list = [] %}
|
||||
{% for port in PORT %}
|
||||
{%- if port_names_list.append(port) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% set port_names = port_names_list | join(',') -%}
|
||||
|
||||
{
|
||||
"CABLE_LENGTH": {
|
||||
"AZURE": {
|
||||
{% for port in PORT %}
|
||||
{% set cable = cable_length(port) -%}
|
||||
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
}
|
||||
},
|
||||
{%if switch_role == 'ToRRouter' %}
|
||||
{% set ingress_lossless_pool_size = '4194304' %}
|
||||
{% set ingress_lossy_pool_size = '7340032' %}
|
||||
{% set egress_lossless_pool_size = '16777152' %}
|
||||
{% set egress_lossy_pool_size = '7340032' %}
|
||||
{% else %}
|
||||
{% set ingress_lossless_pool_size = '2097152' %}
|
||||
{% set ingress_lossy_pool_size = '5242880' %}
|
||||
{% set egress_lossless_pool_size = '16777152' %}
|
||||
{% set egress_lossy_pool_size = '5242880' %}
|
||||
{%endif %}
|
||||
"BUFFER_POOL": {
|
||||
"ingress_lossless_pool": {
|
||||
"size": "{{ ingress_lossless_pool_size }}",
|
||||
"type": "ingress",
|
||||
"mode": "dynamic"
|
||||
},
|
||||
"ingress_lossy_pool": {
|
||||
"size": "{{ ingress_lossy_pool_size }}",
|
||||
"type": "ingress",
|
||||
"mode": "dynamic"
|
||||
},
|
||||
"egress_lossless_pool": {
|
||||
"size": "{{ egress_lossless_pool_size }}",
|
||||
"type": "egress",
|
||||
"mode": "dynamic"
|
||||
},
|
||||
"egress_lossy_pool": {
|
||||
"size": "{{ egress_lossy_pool_size }}",
|
||||
"type": "egress",
|
||||
"mode": "dynamic"
|
||||
}
|
||||
},
|
||||
"BUFFER_PROFILE": {
|
||||
"ingress_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"0"
|
||||
},
|
||||
"ingress_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossy_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"3"
|
||||
},
|
||||
"egress_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossless_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"7"
|
||||
},
|
||||
"egress_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossy_pool]",
|
||||
"size":"4096",
|
||||
"dynamic_th":"3"
|
||||
},
|
||||
"pg_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossy_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"3"
|
||||
},
|
||||
"q_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossless_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"7"
|
||||
},
|
||||
"q_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossy_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"3"
|
||||
}
|
||||
},
|
||||
"BUFFER_PORT_INGRESS_PROFILE_LIST": {
|
||||
"{{ port_names }}": {
|
||||
"profile_list" : "[BUFFER_PROFILE|ingress_lossless_profile],[BUFFER_PROFILE|ingress_lossy_profile]"
|
||||
}
|
||||
},
|
||||
"BUFFER_PORT_EGRESS_PROFILE_LIST": {
|
||||
"{{ port_names }}": {
|
||||
"profile_list" : "[BUFFER_PROFILE|egress_lossless_profile],[BUFFER_PROFILE|egress_lossy_profile]"
|
||||
}
|
||||
},
|
||||
"BUFFER_PG": {
|
||||
"{{ port_names }}|0-1": {
|
||||
"profile" : "[BUFFER_PROFILE|pg_lossy_profile]"
|
||||
}
|
||||
},
|
||||
"BUFFER_QUEUE": {
|
||||
"{{ port_names }}|3-4": {
|
||||
"profile" : "[BUFFER_PROFILE|q_lossless_profile]"
|
||||
},
|
||||
"{{ port_names }}|0-1": {
|
||||
"profile" : "[BUFFER_PROFILE|q_lossy_profile]"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
# PG lossless profiles.
|
||||
# speed cable size xon xoff threshold
|
||||
10000 5m 34816 18432 16384 0
|
||||
25000 5m 34816 18432 16384 0
|
||||
40000 5m 34816 18432 16384 0
|
||||
50000 5m 34816 18432 16384 0
|
||||
100000 5m 36864 18432 18432 0
|
||||
10000 40m 36864 18432 18432 0
|
||||
25000 40m 39936 18432 21504 0
|
||||
40000 40m 41984 18432 23552 0
|
||||
50000 40m 41984 18432 23552 0
|
||||
100000 40m 54272 18432 35840 0
|
||||
10000 300m 49152 18432 30720 0
|
||||
25000 300m 71680 18432 53248 0
|
||||
40000 300m 94208 18432 75776 0
|
||||
50000 300m 94208 18432 75776 0
|
||||
100000 300m 184320 18432 165888 0
|
@ -0,0 +1,33 @@
|
||||
# name lanes
|
||||
Ethernet0 0,1,2,3
|
||||
Ethernet4 4,5,6,7
|
||||
Ethernet8 8,9,10,11
|
||||
Ethernet12 12,13,14,15
|
||||
Ethernet16 16,17,18,19
|
||||
Ethernet20 20,21,22,23
|
||||
Ethernet24 24,25,26,27
|
||||
Ethernet28 28,29,30,31
|
||||
Ethernet32 32,33,34,35
|
||||
Ethernet36 36,37,38,39
|
||||
Ethernet40 40,41,42,43
|
||||
Ethernet44 44,45,46,47
|
||||
Ethernet48 48,49,50,51
|
||||
Ethernet52 52,53,54,55
|
||||
Ethernet56 56,57,58,59
|
||||
Ethernet60 60,61,62,63
|
||||
Ethernet64 64,65,66,67
|
||||
Ethernet68 68,69,70,71
|
||||
Ethernet72 72,73,74,75
|
||||
Ethernet76 76,77,78,79
|
||||
Ethernet80 80,81,82,83
|
||||
Ethernet84 84,85,86,87
|
||||
Ethernet88 88,89,90,91
|
||||
Ethernet92 92,93,94,95
|
||||
Ethernet96 96,97,98,99
|
||||
Ethernet100 100,101,102,103
|
||||
Ethernet104 104,105,106,107
|
||||
Ethernet108 108,109,110,111
|
||||
Ethernet112 112,113,114,115
|
||||
Ethernet116 116,117,118,119
|
||||
Ethernet120 120,121,122,123
|
||||
Ethernet124 124,125,126,127
|
166
device/mellanox/x86_64-mlnx_lssn2700-r0/LS-SN2700/qos.json
Normal file
166
device/mellanox/x86_64-mlnx_lssn2700-r0/LS-SN2700/qos.json
Normal file
@ -0,0 +1,166 @@
|
||||
{
|
||||
"TC_TO_PRIORITY_GROUP_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"MAP_PFC_PRIORITY_TO_QUEUE": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"TC_TO_QUEUE_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"DSCP_TO_TC_MAP": {
|
||||
"AZURE": {
|
||||
"0":"0",
|
||||
"1":"0",
|
||||
"2":"0",
|
||||
"3":"3",
|
||||
"4":"4",
|
||||
"5":"0",
|
||||
"6":"0",
|
||||
"7":"0",
|
||||
"8":"1",
|
||||
"9":"0",
|
||||
"10":"0",
|
||||
"11":"0",
|
||||
"12":"0",
|
||||
"13":"0",
|
||||
"14":"0",
|
||||
"15":"0",
|
||||
"16":"0",
|
||||
"17":"0",
|
||||
"18":"0",
|
||||
"19":"0",
|
||||
"20":"0",
|
||||
"21":"0",
|
||||
"22":"0",
|
||||
"23":"0",
|
||||
"24":"0",
|
||||
"25":"0",
|
||||
"26":"0",
|
||||
"27":"0",
|
||||
"28":"0",
|
||||
"29":"0",
|
||||
"30":"0",
|
||||
"31":"0",
|
||||
"32":"0",
|
||||
"33":"0",
|
||||
"34":"0",
|
||||
"35":"0",
|
||||
"36":"0",
|
||||
"37":"0",
|
||||
"38":"0",
|
||||
"39":"0",
|
||||
"40":"0",
|
||||
"41":"0",
|
||||
"42":"0",
|
||||
"43":"0",
|
||||
"44":"0",
|
||||
"45":"0",
|
||||
"46":"0",
|
||||
"47":"0",
|
||||
"48":"0",
|
||||
"49":"0",
|
||||
"50":"0",
|
||||
"51":"0",
|
||||
"52":"0",
|
||||
"53":"0",
|
||||
"54":"0",
|
||||
"55":"0",
|
||||
"56":"0",
|
||||
"57":"0",
|
||||
"58":"0",
|
||||
"59":"0",
|
||||
"60":"0",
|
||||
"61":"0",
|
||||
"62":"0",
|
||||
"63":"0"
|
||||
}
|
||||
},
|
||||
"SCHEDULER": {
|
||||
"scheduler.0": {
|
||||
"type":"DWRR",
|
||||
"weight": "25"
|
||||
},
|
||||
"scheduler.1": {
|
||||
"type":"DWRR",
|
||||
"weight": "30"
|
||||
},
|
||||
"scheduler.2": {
|
||||
"type":"DWRR",
|
||||
"weight": "20"
|
||||
}
|
||||
},
|
||||
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"PORT_QOS_MAP": {
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124": {
|
||||
"dscp_to_tc_map" : "[DSCP_TO_TC_MAP|AZURE]",
|
||||
"tc_to_queue_map" : "[TC_TO_QUEUE_MAP|AZURE]",
|
||||
"tc_to_pg_map" : "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
|
||||
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
|
||||
"pfc_to_pg_map" : "[PFC_PRIORITY_TO_PRIORITY_GROUP_MAP|AZURE]",
|
||||
"pfc_enable": "3,4"
|
||||
}
|
||||
},
|
||||
"WRED_PROFILE": {
|
||||
"AZURE_LOSSY": {
|
||||
"wred_green_enable":"true",
|
||||
"wred_yellow_enable":"true",
|
||||
"ecn":"ecn_all",
|
||||
"red_max_threshold":"516096",
|
||||
"red_min_threshold":"516096",
|
||||
"yellow_max_threshold":"516096",
|
||||
"yellow_min_threshold":"516096",
|
||||
"green_max_threshold": "184320",
|
||||
"green_min_threshold": "184320"
|
||||
},
|
||||
"AZURE_LOSSLESS": {
|
||||
"wred_green_enable":"true",
|
||||
"wred_yellow_enable":"true",
|
||||
"ecn":"ecn_all",
|
||||
"red_max_threshold":"516096",
|
||||
"red_min_threshold":"516096",
|
||||
"yellow_max_threshold":"516096",
|
||||
"yellow_min_threshold":"516096",
|
||||
"green_max_threshold": "184320",
|
||||
"green_min_threshold": "184320"
|
||||
}
|
||||
},
|
||||
"QUEUE": {
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|0": {
|
||||
"scheduler" : "[SCHEDULER|scheduler.1]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|1": {
|
||||
"scheduler" : "[SCHEDULER|scheduler.2]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|0-1": {
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSY]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|3-4": {
|
||||
"scheduler" : "[SCHEDULER|scheduler.0]",
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSLESS]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
SAI_INIT_CONFIG_FILE=/usr/share/sai_2700.xml
|
1
device/mellanox/x86_64-mlnx_lssn2700-r0/hw-management
Symbolic link
1
device/mellanox/x86_64-mlnx_lssn2700-r0/hw-management
Symbolic link
@ -0,0 +1 @@
|
||||
/etc/mlnx/msn2700
|
1
device/mellanox/x86_64-mlnx_lssn2700-r0/installer.conf
Normal file
1
device/mellanox/x86_64-mlnx_lssn2700-r0/installer.conf
Normal file
@ -0,0 +1 @@
|
||||
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="acpi_enforce_resources=lax acpi=noirq"
|
1079
device/mellanox/x86_64-mlnx_lssn2700-r0/minigraph.xml
Normal file
1079
device/mellanox/x86_64-mlnx_lssn2700-r0/minigraph.xml
Normal file
File diff suppressed because it is too large
Load Diff
32
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/eeprom.py
Normal file
32
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Mellanox
|
||||
#
|
||||
# Platform and model specific eeprom subclass, inherits from the base class,
|
||||
# and provides the followings:
|
||||
# - the eeprom format definition
|
||||
# - specific encoder/decoder if there is special need
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
import warnings
|
||||
import os
|
||||
import sys
|
||||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/bsp/eeprom/sys_eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
74
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/psuutil.py
Normal file
74
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/psuutil.py
Normal file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Mellanox
|
||||
#
|
||||
# Module contains an implementation of SONiC PSU Base API and
|
||||
# provides the PSUs status which are available in the platform
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
self.psu_path = "/sys/bus/i2c/devices/2-0060/"
|
||||
self.psu_presence = "psu{}_status"
|
||||
self.psu_oper_status = "psu{}_pg_status"
|
||||
|
||||
def get_num_psus(self):
|
||||
"""
|
||||
Retrieves the number of PSUs available on the device
|
||||
|
||||
:return: An integer, the number of PSUs available on the device
|
||||
"""
|
||||
return 2
|
||||
|
||||
def get_psu_status(self, index):
|
||||
"""
|
||||
Retrieves the oprational status of power supply unit (PSU) defined
|
||||
by 1-based index <index>
|
||||
|
||||
:param index: An integer, 1-based index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
|
||||
"""
|
||||
if index is None:
|
||||
return False
|
||||
|
||||
status = 0
|
||||
try:
|
||||
with open(self.psu_path + self.psu_oper_status.format(index), 'r') as power_status:
|
||||
status = int(power_status.read())
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return status == 1
|
||||
|
||||
def get_psu_presence(self, index):
|
||||
"""
|
||||
Retrieves the presence status of power supply unit (PSU) defined
|
||||
by 1-based index <index>
|
||||
|
||||
:param index: An integer, 1-based index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is plugged, False if not
|
||||
"""
|
||||
if index is None:
|
||||
return False
|
||||
|
||||
status = 0
|
||||
try:
|
||||
with open(self.psu_path + self.psu_presence.format(index), 'r') as presence_status:
|
||||
status = int(presence_status.read())
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return status == 1
|
43
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfplpmget.py
Normal file
43
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfplpmget.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, errno
|
||||
import os
|
||||
from python_sdk_api.sxd_api import *
|
||||
from python_sdk_api.sx_api import *
|
||||
|
||||
# Check if SFP port number is provided
|
||||
if len(sys.argv) < 2:
|
||||
print "SFP module number is missed."
|
||||
print "Usage: sfplpmget.py <SFP module>"
|
||||
sys.exit(errno.EINVAL)
|
||||
|
||||
# Init SDK API
|
||||
rc, handle = sx_api_open(None)
|
||||
if (rc != SX_STATUS_SUCCESS):
|
||||
print "Failed to open api handle.\nPlease check that SDK is running."
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
pid = os.getpid()
|
||||
rc = sxd_access_reg_init(pid, None, 0)
|
||||
if (rc != 0):
|
||||
print "Failed to initializing register access.\nPlease check that SDK is running."
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
# Get SFP module number
|
||||
sfp_module = int(sys.argv[1])
|
||||
|
||||
# Get MCION
|
||||
mcion = ku_mcion_reg()
|
||||
mcion.module = sfp_module
|
||||
meta = sxd_reg_meta_t()
|
||||
meta.dev_id = 1
|
||||
meta.swid = 0
|
||||
meta.access_cmd = SXD_ACCESS_CMD_GET
|
||||
|
||||
rc = sxd_access_reg_mcion(mcion, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_mcion failed, rc = %d" % rc
|
||||
|
||||
# Get low power mode status
|
||||
lpm_mask = 1 << 8
|
||||
lpm_status = (lpm_mask & mcion.module_status_bits) != 0
|
||||
print "LPM ON" if lpm_status else "LPM OFF"
|
107
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfplpmset.py
Normal file
107
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfplpmset.py
Normal file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, errno
|
||||
import time
|
||||
import os
|
||||
from python_sdk_api.sxd_api import *
|
||||
from python_sdk_api.sx_api import *
|
||||
|
||||
def get_log_ports(handle, sfp_module):
|
||||
port_attributes_list = new_sx_port_attributes_t_arr(64)
|
||||
port_cnt_p = new_uint32_t_p()
|
||||
uint32_t_p_assign(port_cnt_p, 64)
|
||||
|
||||
rc = sx_api_port_device_get(handle, 1 , 0, port_attributes_list, port_cnt_p)
|
||||
assert rc == SX_STATUS_SUCCESS, "sx_api_port_device_get failed, rc = %d" % rc
|
||||
|
||||
port_cnt = uint32_t_p_value(port_cnt_p)
|
||||
log_port_list = []
|
||||
for i in range(0, port_cnt):
|
||||
port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list, i)
|
||||
if port_attributes.port_mapping.module_port == sfp_module:
|
||||
log_port_list.append(port_attributes.log_port)
|
||||
|
||||
return log_port_list
|
||||
|
||||
def set_sfp_admin_status(handle, meta, sfp_module, sfp_log_port_list, admin_status):
|
||||
# Get PMAOS
|
||||
pmaos = ku_pmaos_reg()
|
||||
pmaos.module = sfp_module
|
||||
meta.access_cmd = SXD_ACCESS_CMD_GET
|
||||
rc = sxd_access_reg_pmaos(pmaos, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_pmaos failed, rc = %d" % rc
|
||||
|
||||
# Set admin status to PMAOS
|
||||
pmaos.ase = 1
|
||||
pmaos.ee = 1
|
||||
pmaos.e = 2
|
||||
pmaos.rst = 0
|
||||
if admin_status == SX_PORT_ADMIN_STATUS_DOWN:
|
||||
pmaos.admin_status = 2
|
||||
else:
|
||||
pmaos.admin_status = 1
|
||||
|
||||
meta.access_cmd = SXD_ACCESS_CMD_SET
|
||||
rc = sxd_access_reg_pmaos(pmaos, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_pmaos failed, rc = %d" % rc
|
||||
|
||||
# Check if SFP port number is provided
|
||||
if len(sys.argv) < 3:
|
||||
print "SFP module number or LPM is missed."
|
||||
print "Usage: sfplpmset.py <SFP module> <on|off>"
|
||||
sys.exit(errno.EINVAL)
|
||||
|
||||
lpm_enable = None
|
||||
if sys.argv[2] == 'on':
|
||||
lpm_enable = True
|
||||
elif sys.argv[2] == 'off':
|
||||
lpm_enable = False
|
||||
else:
|
||||
print "Unrecognized LPM parameter. Please use <on> or <off> values"
|
||||
sys.exit(errno.EINVAL)
|
||||
|
||||
# Init SDK API
|
||||
rc, handle = sx_api_open(None)
|
||||
if (rc != SX_STATUS_SUCCESS):
|
||||
print "Failed to open api handle.\nPlease check that SDK is running."
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
pid = os.getpid()
|
||||
rc = sxd_access_reg_init(pid, None, 0)
|
||||
if (rc != 0):
|
||||
print "Failed to initializing register access.\nPlease check that SDK is running."
|
||||
sys.exit(errno.EACCES);
|
||||
|
||||
# Get SFP module and log ports number and LPM status
|
||||
sfp_module = int(sys.argv[1])
|
||||
log_port_list = get_log_ports(handle, sfp_module)
|
||||
if not log_port_list:
|
||||
print "Failed to get log ports"
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
# Get PMMP
|
||||
pmmp = ku_pmmp_reg()
|
||||
pmmp.module = sfp_module
|
||||
meta = sxd_reg_meta_t()
|
||||
meta.dev_id = 1
|
||||
meta.swid = 0
|
||||
meta.access_cmd = SXD_ACCESS_CMD_GET
|
||||
rc = sxd_access_reg_pmmp(pmmp, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_pmmp failed, rc = %d" % rc
|
||||
|
||||
# Disable admin status before LPM settings
|
||||
set_sfp_admin_status(handle, meta, sfp_module, log_port_list, SX_PORT_ADMIN_STATUS_DOWN)
|
||||
|
||||
# Set low power mode status
|
||||
lpm_mask = 1 << 8
|
||||
if lpm_enable:
|
||||
pmmp.eeprom_override = pmmp.eeprom_override | lpm_mask
|
||||
else:
|
||||
pmmp.eeprom_override = pmmp.eeprom_override & (~lpm_mask)
|
||||
|
||||
meta.access_cmd = SXD_ACCESS_CMD_SET
|
||||
rc = sxd_access_reg_pmmp(pmmp, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_pmmp failed, rc = %d" % rc
|
||||
|
||||
# Enable admin status after LPM settings
|
||||
set_sfp_admin_status(handle, meta, sfp_module, log_port_list, SX_PORT_ADMIN_STATUS_UP)
|
45
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfpreset.py
Normal file
45
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfpreset.py
Normal file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, errno
|
||||
import os
|
||||
from python_sdk_api.sxd_api import *
|
||||
from python_sdk_api.sx_api import *
|
||||
|
||||
# Check if SFP port number is provided
|
||||
if len(sys.argv) < 2:
|
||||
print "SFP module number or LPM is missed."
|
||||
print "Usage: sfpreset.py <SFP module>"
|
||||
sys.exit(errno.EINVAL)
|
||||
|
||||
# Init SDK API
|
||||
rc, handle = sx_api_open(None)
|
||||
if (rc != SX_STATUS_SUCCESS):
|
||||
print "Failed to open api handle.\nPlease check that SDK is running."
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
pid = os.getpid()
|
||||
rc = sxd_access_reg_init(pid, None, 0)
|
||||
if (rc != 0):
|
||||
print "Failed to initializing register access.\nPlease check that SDK is running."
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
# Get SFP module number
|
||||
sfp_module = int(sys.argv[1])
|
||||
|
||||
# Get PMAOS
|
||||
pmaos = ku_pmaos_reg()
|
||||
pmaos.module = sfp_module
|
||||
meta = sxd_reg_meta_t()
|
||||
meta.dev_id = 1
|
||||
meta.swid = 0
|
||||
meta.access_cmd = SXD_ACCESS_CMD_GET
|
||||
|
||||
rc = sxd_access_reg_pmaos(pmaos, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_pmaos failed, rc = %d" % rc
|
||||
|
||||
# Reset SFP
|
||||
pmaos.rst = 1
|
||||
meta.access_cmd = SXD_ACCESS_CMD_SET
|
||||
rc = sxd_access_reg_pmaos(pmaos, meta, 1, None, None)
|
||||
assert rc == SXD_STATUS_SUCCESS, "sxd_access_reg_pmaos failed, rc = %d" % rc
|
||||
print "Reset flag is set"
|
151
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfputil.py
Normal file
151
device/mellanox/x86_64-mlnx_lssn2700-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,151 @@
|
||||
# sfputil.py
|
||||
#
|
||||
# Platform-specific SFP transceiver interface for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
import time
|
||||
import subprocess
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
PORT_START = 0
|
||||
PORT_END = 31
|
||||
PORTS_IN_BLOCK = 32
|
||||
|
||||
EEPROM_OFFSET = 1
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
return self.PORT_START
|
||||
|
||||
@property
|
||||
def port_end(self):
|
||||
return self.PORT_END
|
||||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(0, self.PORTS_IN_BLOCK + 1)
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
return self._port_to_eeprom_mapping
|
||||
|
||||
def __init__(self):
|
||||
eeprom_path = "/bsp/qsfp/qsfp{0}"
|
||||
|
||||
for x in range(0, self.port_end + 1):
|
||||
self._port_to_eeprom_mapping[x] = eeprom_path.format(x + self.EEPROM_OFFSET)
|
||||
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
def get_presence(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
content = reg_file.readline().rstrip()
|
||||
|
||||
# content is a string with the qsfp status
|
||||
if content == "good":
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
lpm_cmd = "docker exec syncd python /usr/share/sonic/platform/plugins/sfplpmget.py {}".format(port_num)
|
||||
|
||||
try:
|
||||
output = subprocess.check_output(lpm_cmd, shell=True)
|
||||
if 'LPM ON' in output:
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print "Error! Unable to get LPM for {}, rc = {}, err msg: {}".format(port_num, e.returncode, e.output)
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def set_low_power_mode(self, port_num, lpmode):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
curr_lpmode = self.get_low_power_mode(port_num)
|
||||
if curr_lpmode == lpmode:
|
||||
return True
|
||||
|
||||
lpm = 'on' if lpmode else 'off'
|
||||
lpm_cmd = "docker exec syncd python /usr/share/sonic/platform/plugins/sfplpmset.py {} {}".format(port_num, lpm)
|
||||
sfp_port_names = self.physical_to_logical[port_num]
|
||||
|
||||
# Get port admin status
|
||||
try:
|
||||
enabled_ports = subprocess.check_output("ip link show up", shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print "Error! Unable to get ports status, err msg: {}".format(e.output)
|
||||
return False
|
||||
|
||||
port_to_disable = []
|
||||
for port in sfp_port_names:
|
||||
if port in enabled_ports:
|
||||
port_to_disable.append(port)
|
||||
|
||||
# Disable ports before LPM settings
|
||||
for port in port_to_disable:
|
||||
try:
|
||||
subprocess.check_output("ifconfig {} down".format(port), shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print "Error! Unable to set admin status to DOWN for {}, rc = {}, err msg: {}".format(port, e.returncode, e.output)
|
||||
return False
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Set LPM
|
||||
try:
|
||||
subprocess.check_output(lpm_cmd, shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print "Error! Unable to set LPM for {}, rc = {}, err msg: {}".format(port_num, e.returncode, e.output)
|
||||
return False
|
||||
|
||||
# Enable ports after LPM settings
|
||||
for port in port_to_disable:
|
||||
try:
|
||||
subprocess.check_output("ifconfig {} up".format(port), shell=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print "Error! Unable to set admin status to UP for {}, rc = {}, err msg: {}".format(port, e.returncode, e.output)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def reset(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
lpm_cmd = "docker exec syncd python /usr/share/sonic/platform/plugins/sfpreset.py {}".format(port_num)
|
||||
|
||||
try:
|
||||
subprocess.check_output(lpm_cmd, shell=True)
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print "Error! Unable to set LPM for {}, rc = {}, err msg: {}".format(port_num, e.returncode, e.output)
|
||||
return False
|
||||
|
||||
return False
|
21
device/mellanox/x86_64-mlnx_lssn2700-r0/sensors.conf
Normal file
21
device/mellanox/x86_64-mlnx_lssn2700-r0/sensors.conf
Normal file
@ -0,0 +1,21 @@
|
||||
bus "i2c-7" "i2c-1-mux (chan_id 5)"
|
||||
chip "lm75-i2c-7-4a"
|
||||
label temp1 "Ambient Port Temp"
|
||||
|
||||
bus "i2c-5" "i2c-1-mux (chan_id 3)"
|
||||
chip "ucd9200-i2c-5-27"
|
||||
label in1 "UCD1 vin"
|
||||
label in2 "ASIC 3.3 vout"
|
||||
label in3 "ASIC 1.2 vout"
|
||||
label temp1 "UCD1 Temp"
|
||||
label temp2 "UCD1 Temp2"
|
||||
|
||||
chip "ucd9200-i2c-5-41"
|
||||
label in1 "UCD2 vin"
|
||||
label in2 "ASIC Vcore vout"
|
||||
label temp1 "UCD2 Temp1"
|
||||
label temp2 "UCD2 Temp2"
|
||||
|
||||
bus "i2c-17" "i2c-1-mux (chan_id 7)"
|
||||
chip "lm75-i2c-17-49"
|
||||
label temp1 "Ambient Board Temp"
|
Reference in New Issue
Block a user