From 8eab0e02df3a0fd334ef7ef9c6c1d621d05613e3 Mon Sep 17 00:00:00 2001 From: Andrew Sapronov Date: Tue, 26 Oct 2021 23:04:27 +0300 Subject: [PATCH] Added Netberg Aurora 715 support (#8604) * [202012][platform/barefoot] (#8543) Why I did it Pcied running by python 2. How I did it dropped python2 support and add python3 support for pcied in file docker-pmon.supervisord.conf.j2 How to verify it docker exec pmon supervisorctl status * [Netberg][nba715] Initial support for Netberg Aurora 715 switch Signed-off-by: Andrew Sapronov Co-authored-by: Kostiantyn Yarovyi --- .../aurora-715/buffers.json.j2 | 137 ++ .../aurora-715/buffers_defaults_def_lossy.j2 | 38 + .../aurora-715/buffers_defaults_t1.j2 | 137 ++ .../config_32x100G_netberg-aurora-715.yaml | 397 ++++++ .../aurora-715/innovium.55300 | 62 + .../aurora-715/ivm.sai.config.yaml | 8 + .../aurora-715/ivm.sai.datapath.config.yaml | 9 + .../aurora-715/pg_profile_lookup.ini | 18 + .../aurora-715/port_config.ini | 33 + .../aurora-715/qos.json.j2 | 114 ++ .../aurora-715/qos_defaults_def_lossy.j2 | 118 ++ .../aurora-715/qos_defaults_t1.j2 | 114 ++ .../aurora-715/sai.profile | 1 + .../x86_64-netberg_aurora_715-r0/default_sku | 1 + .../installer.conf | 3 + .../platform_reboot | 16 + .../plugins/eeprom.py | 14 + .../plugins/psuutil.py | 95 ++ .../plugins/sfputil.py | 213 +++ .../pmon_daemon_control.json | 4 + .../x86_64-netberg_aurora_715-r0/sensors.conf | 3 + .../x86_64-netberg_aurora_715-r0/topo.conf | 1 + platform/innovium/one-image.mk | 1 + platform/innovium/platform-modules-netberg.mk | 13 + platform/innovium/rules.mk | 1 + .../aurora-715/modules/Makefile | 4 + .../x86-64-netberg-aurora-715-common.c | 399 ++++++ .../x86-64-netberg-aurora-715-common.h | 25 + .../modules/x86-64-netberg-aurora-715-fan.c | 365 +++++ .../modules/x86-64-netberg-aurora-715-fan.h | 12 + .../modules/x86-64-netberg-aurora-715-led.c | 220 +++ .../modules/x86-64-netberg-aurora-715-led.h | 12 + .../modules/x86-64-netberg-aurora-715-power.c | 650 +++++++++ .../modules/x86-64-netberg-aurora-715-power.h | 38 + .../modules/x86-64-netberg-aurora-715-qsfp.c | 584 ++++++++ .../modules/x86-64-netberg-aurora-715-qsfp.h | 187 +++ .../modules/x86-64-netberg-aurora-715-sys.c | 864 ++++++++++++ .../modules/x86-64-netberg-aurora-715-sys.h | 23 + .../x86-64-netberg-aurora-715-thermal.c | 271 ++++ .../x86-64-netberg-aurora-715-thermal.h | 45 + .../modules/x86-64-netberg-aurora-715.h | 1069 ++++++++++++++ .../aurora-715/scripts/sensors | 8 + .../service/nba715-platform-init.service | 14 + .../aurora-715/setup.py | 30 + .../aurora-715/sonic_platform/__init__.py | 0 .../aurora-715/sonic_platform/chassis.py | 335 +++++ .../aurora-715/sonic_platform/component.py | 100 ++ .../aurora-715/sonic_platform/eeprom.py | 108 ++ .../aurora-715/sonic_platform/fan.py | 152 ++ .../aurora-715/sonic_platform/platDev.py | 408 ++++++ .../aurora-715/sonic_platform/platform.py | 19 + .../aurora-715/sonic_platform/psu.py | 196 +++ .../aurora-715/sonic_platform/sfp.py | 1251 +++++++++++++++++ .../aurora-715/sonic_platform/thermal.py | 201 +++ .../templates/netberg_aurora-715_util.py.j2 | 408 ++++++ .../aurora-715/utils/halt | 18 + .../utils/netberg_nba715_platform.sh | 10 + .../utils/netberg_nba715_sensors.py | 281 ++++ .../aurora-715/utils/netberg_nba715_startup | 17 + .../aurora-715/utils/poweroff | 18 + .../aurora-715/utils/shutdown | 18 + .../debian/changelog | 6 + .../debian/compat | 1 + .../debian/control | 10 + .../debian/netberg_platform_version.sh | 14 + .../debian/rules | 41 + .../sonic-platform-netberg-aurora-715.install | 4 + ...sonic-platform-netberg-aurora-715.postinst | 8 + 68 files changed, 9995 insertions(+) create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers.json.j2 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_def_lossy.j2 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_t1.j2 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/config_32x100G_netberg-aurora-715.yaml create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/innovium.55300 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.config.yaml create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.datapath.config.yaml create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/pg_profile_lookup.ini create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/port_config.ini create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos.json.j2 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_def_lossy.j2 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_t1.j2 create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/sai.profile create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/default_sku create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/installer.conf create mode 100755 device/netberg/x86_64-netberg_aurora_715-r0/platform_reboot create mode 100755 device/netberg/x86_64-netberg_aurora_715-r0/plugins/eeprom.py create mode 100755 device/netberg/x86_64-netberg_aurora_715-r0/plugins/psuutil.py create mode 100755 device/netberg/x86_64-netberg_aurora_715-r0/plugins/sfputil.py create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/pmon_daemon_control.json create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/sensors.conf create mode 100644 device/netberg/x86_64-netberg_aurora_715-r0/topo.conf create mode 100755 platform/innovium/platform-modules-netberg.mk create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/Makefile create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.c create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.h create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715.h create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/scripts/sensors create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/service/nba715-platform-init.service create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/setup.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/__init__.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/chassis.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/component.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/eeprom.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/fan.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platDev.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platform.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/psu.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/sfp.py create mode 100644 platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/thermal.py create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/templates/netberg_aurora-715_util.py.j2 create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/halt create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_platform.sh create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_sensors.py create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_startup create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/poweroff create mode 100755 platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/shutdown create mode 100644 platform/innovium/sonic-platform-modules-netberg/debian/changelog create mode 100644 platform/innovium/sonic-platform-modules-netberg/debian/compat create mode 100644 platform/innovium/sonic-platform-modules-netberg/debian/control create mode 100755 platform/innovium/sonic-platform-modules-netberg/debian/netberg_platform_version.sh create mode 100755 platform/innovium/sonic-platform-modules-netberg/debian/rules create mode 100644 platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.install create mode 100644 platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.postinst diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers.json.j2 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers.json.j2 new file mode 100644 index 0000000000..6f9ed3c7f6 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers.json.j2 @@ -0,0 +1,137 @@ +{# Default values which will be used if no actual configura available #} +{% set default_cable = '40m' %} + +{# 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 is defined and 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 %} + {%- if switch_role.lower() == 'torrouter' %} + {%- for local_port in VLAN_MEMBER %} + {%- if local_port[1] == port_name %} + {%- set roles3 = switch_role + '_' + 'server' %} + {%- set roles3 = roles3 | lower %} + {%- if roles3 in ports2cable %} + {%- if cable_len.append(ports2cable[roles3]) %}{% endif %} + {%- endif %} + {%- endif %} + {%- endfor %} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ default_cable }} + {%- endif %} + {%- else -%} + {{ default_cable }} + {%- endif %} + {%- endif %} +{%- endmacro %} + +{%- if DEVICE_METADATA is defined %} +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} +{%- 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 %} + } + }, + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "34056960", + "type": "ingress", + "mode": "dynamic", + "xoff": "4185600" + }, + "lossy_pool": { + "size": "14595840", + "type": "egress", + "mode": "dynamic", + "xoff": "0" + } + }, + "BUFFER_PROFILE": { + "ingress_lossless_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "xoff":"38816", + "size":"1518", + "dynamic_th":"1", + "xon_offset":"13440" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "static_th":"23001600" + }, + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|lossy_pool]", + "size":"0", + "static_th":"23001600" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|lossy_pool]", + "size":"1518", + "dynamic_th":"2" + } + }, + "BUFFER_PG": { + "{{ port_names }}|0-2": { + "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + }, + "{{ port_names }}|3-4": { + "profile" : "[BUFFER_PROFILE|ingress_lossless_profile]" + }, + "{{ port_names }}|5-7": { + "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + } + }, + "BUFFER_QUEUE": { + "{{ port_names }}|3-4": { + "profile" : "[BUFFER_PROFILE|egress_lossless_profile]" + }, + "{{ port_names }}|0-2": { + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" + }, + "{{ port_names }}|5-7": { + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" + } + } +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_def_lossy.j2 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_def_lossy.j2 new file mode 100644 index 0000000000..72a618f07f --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_def_lossy.j2 @@ -0,0 +1,38 @@ +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + +{ + "BUFFER_POOL": { + "lossy_pool": { + "size": "46003200", + "type": "egress", + "mode": "dynamic", + "xoff": "0" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|lossy_pool]", + "size":"0", + "static_th":"23001600" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|lossy_pool]", + "size":"1518", + "dynamic_th":"2" + } + }, + "BUFFER_PG": { + "{{ port_names }}|0-7": { + "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + } + }, + "BUFFER_QUEUE": { + "{{ port_names }}|0-7": { + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" + } + } +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_t1.j2 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_t1.j2 new file mode 100644 index 0000000000..6f9ed3c7f6 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/buffers_defaults_t1.j2 @@ -0,0 +1,137 @@ +{# Default values which will be used if no actual configura available #} +{% set default_cable = '40m' %} + +{# 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 is defined and 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 %} + {%- if switch_role.lower() == 'torrouter' %} + {%- for local_port in VLAN_MEMBER %} + {%- if local_port[1] == port_name %} + {%- set roles3 = switch_role + '_' + 'server' %} + {%- set roles3 = roles3 | lower %} + {%- if roles3 in ports2cable %} + {%- if cable_len.append(ports2cable[roles3]) %}{% endif %} + {%- endif %} + {%- endif %} + {%- endfor %} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ default_cable }} + {%- endif %} + {%- else -%} + {{ default_cable }} + {%- endif %} + {%- endif %} +{%- endmacro %} + +{%- if DEVICE_METADATA is defined %} +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} +{%- 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 %} + } + }, + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "34056960", + "type": "ingress", + "mode": "dynamic", + "xoff": "4185600" + }, + "lossy_pool": { + "size": "14595840", + "type": "egress", + "mode": "dynamic", + "xoff": "0" + } + }, + "BUFFER_PROFILE": { + "ingress_lossless_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "xoff":"38816", + "size":"1518", + "dynamic_th":"1", + "xon_offset":"13440" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "static_th":"23001600" + }, + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|lossy_pool]", + "size":"0", + "static_th":"23001600" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|lossy_pool]", + "size":"1518", + "dynamic_th":"2" + } + }, + "BUFFER_PG": { + "{{ port_names }}|0-2": { + "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + }, + "{{ port_names }}|3-4": { + "profile" : "[BUFFER_PROFILE|ingress_lossless_profile]" + }, + "{{ port_names }}|5-7": { + "profile" : "[BUFFER_PROFILE|ingress_lossy_profile]" + } + }, + "BUFFER_QUEUE": { + "{{ port_names }}|3-4": { + "profile" : "[BUFFER_PROFILE|egress_lossless_profile]" + }, + "{{ port_names }}|0-2": { + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" + }, + "{{ port_names }}|5-7": { + "profile" : "[BUFFER_PROFILE|egress_lossy_profile]" + } + } +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/config_32x100G_netberg-aurora-715.yaml b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/config_32x100G_netberg-aurora-715.yaml new file mode 100644 index 0000000000..346c61d828 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/config_32x100G_netberg-aurora-715.yaml @@ -0,0 +1,397 @@ +ifcs: + options: + log_level: "info" +nodes: +- node_id: "0" + options: + sku: "configs/sku/innovium.55300" + netdev: + - auto_create: "no" + multi_interface: "yes" + buffer_management_mode: "api_driven" + max_lossless_tc: "2" + skip_pll_check: "false" + ilpm_enable: "1" + forward_profile: "IFCS_FORWARD_PROFILE_ID_PROFILE_E" + mac_clk: "750" + sys_clk: "1300" + ifc_clk: "675" + txring: + - txring_id: "0" + desc_count: "1024" + prio: "1" + netdev: "true" + - txring_id: "1" + desc_count: "1024" + prio: "1" + netdev: "true" + - txring_id: "2" + desc_count: "1024" + prio: "1" + netdev: "true" + - txring_id: "3" + desc_count: "1024" + prio: "1" + netdev: "true" + rxring: + - rxring_id: "0" + desc_count: "1024" + prio: "1" + netdev: "true" + queues: "0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39" + - rxring_id: "1" + desc_count: "1024" + prio: "1" + netdev: "true" + queues: "1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40" + - rxring_id: "2" + desc_count: "1024" + prio: "1" + netdev: "true" + queues: "2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 47" + - rxring_id: "3" + desc_count: "1024" + prio: "1" + queues: "42, 43, 44, 45, 46" + devports: + - id: "0" + sysport: "129" + type: "cpu" + - fec: "KRFEC" + id: "121" + lanes: "0:4" + serdes_group: "15" + speed: "100G" + sysport: "121" + type: "eth" + - fec: "KRFEC" + id: "125" + lanes: "4:4" + serdes_group: "15" + speed: "100G" + sysport: "125" + type: "eth" + - fec: "KRFEC" + id: "113" + lanes: "0:4" + serdes_group: "14" + speed: "100G" + sysport: "113" + type: "eth" + - fec: "KRFEC" + id: "117" + lanes: "4:4" + serdes_group: "14" + speed: "100G" + sysport: "117" + type: "eth" + - fec: "KRFEC" + id: "105" + lanes: "0:4" + serdes_group: "13" + speed: "100G" + sysport: "105" + type: "eth" + - fec: "KRFEC" + id: "109" + lanes: "4:4" + serdes_group: "13" + speed: "100G" + sysport: "109" + type: "eth" + - fec: "KRFEC" + id: "97" + lanes: "0:4" + serdes_group: "12" + speed: "100G" + sysport: "97" + type: "eth" + - fec: "KRFEC" + id: "101" + lanes: "4:4" + serdes_group: "12" + speed: "100G" + sysport: "101" + type: "eth" + - fec: "KRFEC" + id: "89" + lanes: "0:4" + serdes_group: "11" + speed: "100G" + sysport: "89" + type: "eth" + - fec: "KRFEC" + id: "93" + lanes: "4:4" + serdes_group: "11" + speed: "100G" + sysport: "93" + type: "eth" + - fec: "KRFEC" + id: "81" + lanes: "0:4" + serdes_group: "10" + speed: "100G" + sysport: "81" + type: "eth" + - fec: "KRFEC" + id: "85" + lanes: "4:4" + serdes_group: "10" + speed: "100G" + sysport: "85" + type: "eth" + - fec: "KRFEC" + id: "73" + lanes: "0:4" + serdes_group: "9" + speed: "100G" + sysport: "73" + type: "eth" + - fec: "KRFEC" + id: "77" + lanes: "4:4" + serdes_group: "9" + speed: "100G" + sysport: "77" + type: "eth" + - fec: "KRFEC" + id: "65" + lanes: "0:4" + serdes_group: "8" + speed: "100G" + sysport: "65" + type: "eth" + - fec: "KRFEC" + id: "69" + lanes: "4:4" + serdes_group: "8" + speed: "100G" + sysport: "69" + type: "eth" + - fec: "KRFEC" + id: "57" + lanes: "0:4" + serdes_group: "7" + speed: "100G" + sysport: "57" + type: "eth" + - fec: "KRFEC" + id: "61" + lanes: "4:4" + serdes_group: "7" + speed: "100G" + sysport: "61" + type: "eth" + - fec: "KRFEC" + id: "49" + lanes: "0:4" + serdes_group: "6" + speed: "100G" + sysport: "49" + type: "eth" + - fec: "KRFEC" + id: "53" + lanes: "4:4" + serdes_group: "6" + speed: "100G" + sysport: "53" + type: "eth" + - fec: "KRFEC" + id: "41" + lanes: "0:4" + serdes_group: "5" + speed: "100G" + sysport: "41" + type: "eth" + - fec: "KRFEC" + id: "45" + lanes: "4:4" + serdes_group: "5" + speed: "100G" + sysport: "45" + type: "eth" + - fec: "KRFEC" + id: "33" + lanes: "0:4" + serdes_group: "4" + speed: "100G" + sysport: "33" + type: "eth" + - fec: "KRFEC" + id: "37" + lanes: "4:4" + serdes_group: "4" + speed: "100G" + sysport: "37" + type: "eth" + - fec: "KRFEC" + id: "25" + lanes: "0:4" + serdes_group: "3" + speed: "100G" + sysport: "25" + type: "eth" + - fec: "KRFEC" + id: "29" + lanes: "4:4" + serdes_group: "3" + speed: "100G" + sysport: "29" + type: "eth" + - fec: "KRFEC" + id: "17" + lanes: "0:4" + serdes_group: "2" + speed: "100G" + sysport: "17" + type: "eth" + - fec: "KRFEC" + id: "21" + lanes: "4:4" + serdes_group: "2" + speed: "100G" + sysport: "21" + type: "eth" + - fec: "KRFEC" + id: "9" + lanes: "0:4" + serdes_group: "1" + speed: "100G" + sysport: "9" + type: "eth" + - fec: "KRFEC" + id: "13" + lanes: "4:4" + serdes_group: "1" + speed: "100G" + sysport: "13" + type: "eth" + - fec: "KRFEC" + id: "1" + lanes: "0:4" + serdes_group: "0" + speed: "100G" + sysport: "1" + type: "eth" + - fec: "KRFEC" + id: "5" + lanes: "4:4" + serdes_group: "0" + speed: "100G" + sysport: "5" + type: "eth" +# Aux ports to be enabled later +# - id: "33" +# fec: "NONE" +# lanes: "0:1" +# serdes_group: "16" +# speed: "10G" +# sysport: "33" +# type: "mgmt 0" +# - id: "34" +# fec: "NONE" +# lanes: "1:1" +# serdes_group: "16" +# speed: "10G" +# sysport: "34" +# type: "mgmt 1" + isg: + - id: "0" + tx_polarity: "00001010" + rx_polarity: "01001001" + lane_swap: "46750132" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "1" + tx_polarity: "00011111" + rx_polarity: "01101001" + lane_swap: "46752130" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "2" + tx_polarity: "00101000" + rx_polarity: "11110111" + lane_swap: "57462301" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "3" + tx_polarity: "00111101" + rx_polarity: "00101101" + lane_swap: "67542301" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "4" + tx_polarity: "01110110" + rx_polarity: "01111101" + lane_swap: "76543021" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "5" + tx_polarity: "00100100" + rx_polarity: "01101010" + lane_swap: "76542103" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "6" + tx_polarity: "11000011" + rx_polarity: "11110101" + lane_swap: "45672013" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "7" + tx_polarity: "10011101" + rx_polarity: "11111010" + lane_swap: "74562103" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "8" + tx_polarity: "01001000" + rx_polarity: "00100011" + lane_swap: "54672301" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "9" + tx_polarity: "11111111" + rx_polarity: "01110111" + lane_swap: "46750321" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "10" + tx_polarity: "10011110" + rx_polarity: "10110000" + lane_swap: "67542310" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "11" + tx_polarity: "01010010" + rx_polarity: "10101011" + lane_swap: "65741302" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "12" + tx_polarity: "11010110" + rx_polarity: "01101001" + lane_swap: "45760321" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "13" + tx_polarity: "01110111" + rx_polarity: "00101000" + lane_swap: "45670123" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "14" + tx_polarity: "11110110" + rx_polarity: "10111100" + lane_swap: "67542013" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + - id: "15" + tx_polarity: "01011011" + rx_polarity: "01101000" + lane_swap: "64572103" + pre1: "-3, -3, -3, -3, -3, -3, -3, -3" + main: "20, 20, 20, 20, 20, 20, 20, 20" + + diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/innovium.55300 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/innovium.55300 new file mode 100644 index 0000000000..59383ec30e --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/innovium.55300 @@ -0,0 +1,62 @@ +sku: innovium.55300 + +device_id: 0x1b59 + +# Hardware constraint information +hardware: + num_ibs: 2 + ib_active: 0, 1 + + ports_per_ib: 64, 64 + recirc_port_num: 64, 64 + cpu_port_num: 65 + cpu_port_ib: 0 + mgmt_port_num: 65, 66 + mgmt_port_ibs: 1, 1 + + pics_per_ib: 9, 9 + pic_ports_per_pic: 8 + max_serdes_speed: 25 + + num_shared_pics: 0 + + isg [0-7]: + ib: 0 + pic_id: [0-7] + + isg 8: + ib: 1 + pic_id: 7 + + isg 9: + ib: 1 + pic_id: 6 + + isg 10: + ib: 1 + pic_id: 5 + + isg 11: + ib: 1 + pic_id: 4 + + isg 12: + ib: 1 + pic_id: 3 + + isg 13: + ib: 1 + pic_id: 2 + + isg 14: + ib: 1 + pic_id: 1 + + isg 15: + ib: 1 + pic_id: 0 + + isg 16: + mode: 0:2 + ib: 1 + pic_id: 8 diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.config.yaml b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.config.yaml new file mode 100644 index 0000000000..cac1cb8eba --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.config.yaml @@ -0,0 +1,8 @@ +IFCS_INIT_FILE : "/usr/share/sonic/hwsku/config_32x100G_netberg-aurora-715.yaml" +IFCS_SKU_FILE : "/usr/share/sonic/hwsku/innovium.55300" +IFCS_INNO_CLI_PORT : "9999" +IFCS_TARGET : "device" +INNOVIUM_DIR : "/innovium" +PYTHONPATH : "$INNOVIUM_DIR:$INNOVIUM_DIR/cmds:$INNOVIUM_DIR/scripts:$INNOVIUM_DIR/test/:$INNOVIUM_DIR/test/utils:$INNOVIUM_DIR/utils:$INNOVIUM_DIR/pyctypes" +IVM_SAI_DATAPATH_CONFIG_FILE: "/usr/share/sonic/hwsku/ivm.sai.datapath.config.yaml" +IVM_SAI_PARAM_A0008: "64" diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.datapath.config.yaml b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.datapath.config.yaml new file mode 100644 index 0000000000..ef4bc6d129 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/ivm.sai.datapath.config.yaml @@ -0,0 +1,9 @@ +ISAI_PARAM_P0_0_LS : "9216 9216" +ISAI_PARAM_P0_1_LS : "2850 2650" +ISAI_PARAM_P0_1_ALS : "290 90" +ISAI_PARAM_P1_0_LS : "3072 3072" +ISAI_PARAM_P1_0_LL : "6144 6144" +ISAI_PARAM_P1_1_LS : "2210 2010" +ISAI_PARAM_P1_1_LL : "1330 1330" +ISAI_PARAM_P1_1_ALS : "290 90" +ISAI_PARAM_P1_1_ALL : "50 50" diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/pg_profile_lookup.ini b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/pg_profile_lookup.ini new file mode 100644 index 0000000000..adcb52ab2a --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/pg_profile_lookup.ini @@ -0,0 +1,18 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold xon_offset + 25000 5m 1518 0 15680 1 13440 + 50000 5m 1518 0 21248 1 13440 + 100000 5m 1518 0 34624 1 13440 + 400000 5m 1518 0 117536 1 13440 + 25000 40m 1518 0 16928 1 13440 + 50000 40m 1518 0 23392 1 13440 + 100000 40m 1518 0 38816 1 13440 + 400000 40m 1518 0 135520 1 13440 + 25000 100m 1518 0 18848 1 13440 + 50000 100m 1518 0 27264 1 13440 + 100000 100m 1518 0 46496 1 13440 + 400000 100m 1518 0 166688 1 13440 + 25000 300m 1518 0 25184 1 13440 + 50000 300m 1518 0 40128 1 13440 + 100000 300m 1518 0 72384 1 13440 + 400000 300m 1518 0 268640 1 13440 diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/port_config.ini b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/port_config.ini new file mode 100644 index 0000000000..7cb58b4120 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/port_config.ini @@ -0,0 +1,33 @@ +# name lanes speed index mtu fec +Ethernet0 121,122,123,124 100000 0 9126 rs +Ethernet4 125,126,127,128 100000 1 9126 rs +Ethernet8 113,114,115,116 100000 2 9126 rs +Ethernet12 117,118,119,120 100000 3 9126 rs +Ethernet16 105,106,107,108 100000 4 9126 rs +Ethernet20 109,110,111,112 100000 5 9126 rs +Ethernet24 97,98,99,100 100000 6 9126 rs +Ethernet28 101,102,103,104 100000 7 9126 rs +Ethernet32 89,90,91,92 100000 8 9126 rs +Ethernet36 93,94,95,96 100000 9 9126 rs +Ethernet40 81,82,83,84 100000 10 9126 rs +Ethernet44 85,86,87,88 100000 11 9126 rs +Ethernet48 73,74,75,76 100000 12 9126 rs +Ethernet52 77,78,79,80 100000 13 9126 rs +Ethernet56 65,66,67,68 100000 14 9126 rs +Ethernet60 69,70,71,72 100000 15 9126 rs +Ethernet64 57,58,59,60 100000 16 9126 rs +Ethernet68 61,62,63,64 100000 17 9126 rs +Ethernet72 49,50,51,52 100000 18 9126 rs +Ethernet76 53,54,55,56 100000 19 9126 rs +Ethernet80 41,42,43,44 100000 20 9126 rs +Ethernet84 45,46,47,48 100000 21 9126 rs +Ethernet88 33,34,35,36 100000 22 9126 rs +Ethernet92 37,38,39,40 100000 23 9126 rs +Ethernet96 25,26,27,28 100000 24 9126 rs +Ethernet100 29,30,31,32 100000 25 9126 rs +Ethernet104 17,18,19,20 100000 26 9126 rs +Ethernet108 21,22,23,24 100000 27 9126 rs +Ethernet112 9,10,11,12 100000 28 9126 rs +Ethernet116 13,14,15,16 100000 29 9126 rs +Ethernet120 1,2,3,4 100000 30 9126 rs +Ethernet124 5,6,7,8 100000 31 9126 rs diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos.json.j2 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos.json.j2 new file mode 100644 index 0000000000..4b9748c7b5 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos.json.j2 @@ -0,0 +1,114 @@ +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + + +{ + "TC_TO_QUEUE_MAP":{ + "AZURE":{ + "0":"0", + "1":"1", + "2":"2", + "3":"3", + "4":"4", + "5":"5", + "6":"6", + "7":"7" + } + }, + "TC_TO_PRIORITY_GROUP_MAP": { + "AZURE": { + "0": "0", + "1": "0", + "2": "0", + "3": "3", + "4": "4", + "5": "0", + "6": "0", + "7": "0" + } + }, + "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" + } + }, + "PORT_QOS_MAP": { + "{{ port_names }}": { + "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", + "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]", + "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", + "pfc_enable": "3,4" + } + }, + "WRED_PROFILE": { + "AZURE_LOSSLESS" : { + "red_min_threshold":"50000" + } + } +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_def_lossy.j2 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_def_lossy.j2 new file mode 100644 index 0000000000..104d2d78de --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_def_lossy.j2 @@ -0,0 +1,118 @@ +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + + +{ + "TC_TO_QUEUE_MAP":{ + "AZURE":{ + "0":"0", + "1":"1", + "2":"2", + "3":"3", + "4":"4", + "5":"5", + "6":"6", + "7":"7" + } + }, + "TC_TO_PRIORITY_GROUP_MAP": { + "AZURE": { + "0": "0", + "1": "0", + "2": "0", + "3": "3", + "4": "4", + "5": "0", + "6": "0", + "7": "0" + } + }, + "DSCP_TO_TC_MAP": { + "AZURE": { + "0":"0", + "1":"0", + "2":"0", + "3":"0", + "4":"0", + "5":"0", + "6":"0", + "7":"0", + "8":"0", + "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" + } + }, + "PORT_QOS_MAP": { + "{{ port_names }}": { + "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", + "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]", + "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]" + } + }, + "SCHEDULER": { + "scheduler.7": { + "type": "STRICT" + } + }, + "QUEUE": { + "{{ port_names }}|7": { + "scheduler": "[SCHEDULER|scheduler.7]" + } + } +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_t1.j2 b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_t1.j2 new file mode 100644 index 0000000000..4b9748c7b5 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/qos_defaults_t1.j2 @@ -0,0 +1,114 @@ +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + + +{ + "TC_TO_QUEUE_MAP":{ + "AZURE":{ + "0":"0", + "1":"1", + "2":"2", + "3":"3", + "4":"4", + "5":"5", + "6":"6", + "7":"7" + } + }, + "TC_TO_PRIORITY_GROUP_MAP": { + "AZURE": { + "0": "0", + "1": "0", + "2": "0", + "3": "3", + "4": "4", + "5": "0", + "6": "0", + "7": "0" + } + }, + "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" + } + }, + "PORT_QOS_MAP": { + "{{ port_names }}": { + "tc_to_pg_map": "[TC_TO_PRIORITY_GROUP_MAP|AZURE]", + "tc_to_queue_map": "[TC_TO_QUEUE_MAP|AZURE]", + "dscp_to_tc_map": "[DSCP_TO_TC_MAP|AZURE]", + "pfc_enable": "3,4" + } + }, + "WRED_PROFILE": { + "AZURE_LOSSLESS" : { + "red_min_threshold":"50000" + } + } +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/sai.profile b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/sai.profile new file mode 100644 index 0000000000..aba4fc81fb --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/aurora-715/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/ivm.sai.config.yaml diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/default_sku b/device/netberg/x86_64-netberg_aurora_715-r0/default_sku new file mode 100644 index 0000000000..4da2644eb7 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/default_sku @@ -0,0 +1 @@ +aurora-715 t1 diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/installer.conf b/device/netberg/x86_64-netberg_aurora_715-r0/installer.conf new file mode 100644 index 0000000000..925a32fc0c --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/installer.conf @@ -0,0 +1,3 @@ +CONSOLE_PORT=0x3f8 +CONSOLE_DEV=0 +CONSOLE_SPEED=115200 diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/platform_reboot b/device/netberg/x86_64-netberg_aurora_715-r0/platform_reboot new file mode 100755 index 0000000000..43a798cb48 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/platform_reboot @@ -0,0 +1,16 @@ +#!/bin/sh + +mr_reboot() { + + sudo rmmod x86-64-netberg-aurora-715 + sudo i2cset -y 0 0x30 0xa1 0 + +} + +if [ $# -eq 0 ] || [ $@ = "-f" ] || [ $@ = "--force" ] || [ $@ = "reboot" ]; then + mr_reboot +elif [ $@ = "-p" ] ; then + sudo halt +else + echo "unsupported option" +fi diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/plugins/eeprom.py b/device/netberg/x86_64-netberg_aurora_715-r0/plugins/eeprom.py new file mode 100755 index 0000000000..4bee23113c --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/plugins/eeprom.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +try: + from sonic_eeprom import eeprom_tlvinfo +except ImportError as 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 = "/sys/bus/i2c/devices/0-0030/eeprom" + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/plugins/psuutil.py b/device/netberg/x86_64-netberg_aurora_715-r0/plugins/psuutil.py new file mode 100755 index 0000000000..49a359e1a1 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/plugins/psuutil.py @@ -0,0 +1,95 @@ +# +# psuutil.py +# Platform-specific PSU status interface for SONiC +# + + +import os.path + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +ATTR_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_POWER/' +MAX_PSUS = 2 + + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + + def __init__(self): + PsuBase.__init__(self) + + # Get sysfs attribute + + def get_attr_value(self, path): + + retval = 'ERR' + if not os.path.isfile(path): + return retval + + try: + with open(path, 'r') as file_d: + retval = file_d.read() + except IOError as error: + print("Unable to open ", path, " file !", str(error)) + + retval = retval.rstrip('\r\n') + return retval + + 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 MAX_PSUS + + def get_psu_status(self, index): + """ + Retrieves the oprational status of power supply unit (PSU) defined + by index + :param index: An integer, index of the PSU of which to query status + :return: Boolean, True if PSU is operating properly, False if PSU is\ + faulty + """ + status = 0 + attr_file = 'psu{}_good'.format(index) + status_path = ATTR_PATH + attr_file + try: + reg_file = open(status_path, 'r') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + text = reg_file.read() + + if int(text) == 1: + status = 1 + + reg_file.close() + + return status + + def get_psu_presence(self, index): + """ + Retrieves the presence status of power supply unit (PSU) defined + by index + :param index: An integer, index of the PSU of which to query status + :return: Boolean, True if PSU is plugged, False if not + """ + status = 0 + attr_file = 'psu{}_prnt'.format(index) + presence_path = ATTR_PATH + attr_file + try: + reg_file = open(presence_path, 'r') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + text = reg_file.read() + + if int(text) == 1: + status = 1 + + reg_file.close() + + return status diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/plugins/sfputil.py b/device/netberg/x86_64-netberg_aurora_715-r0/plugins/sfputil.py new file mode 100755 index 0000000000..8169955a07 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/plugins/sfputil.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python + + +import time + +try: + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +ATTR_PATH = '/sys/class/hwmon/hwmon2/device/' + +SFP_GROUPS = { + 'SFP-G01': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_1', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/9-0050", "/sys/bus/i2c/devices/10-0050", + "/sys/bus/i2c/devices/11-0050", "/sys/bus/i2c/devices/12-0050", + "/sys/bus/i2c/devices/13-0050", "/sys/bus/i2c/devices/14-0050", + "/sys/bus/i2c/devices/15-0050", "/sys/bus/i2c/devices/16-0050"], + 'status': 'NOTINST' + }, + 'SFP-G02': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_2', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/17-0050", "/sys/bus/i2c/devices/18-0050", + "/sys/bus/i2c/devices/19-0050", "/sys/bus/i2c/devices/20-0050", + "/sys/bus/i2c/devices/21-0050", "/sys/bus/i2c/devices/22-0050", + "/sys/bus/i2c/devices/23-0050", "/sys/bus/i2c/devices/24-0050"], + 'status': 'NOTINST' + }, + 'SFP-G03': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_3', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/25-0050", "/sys/bus/i2c/devices/26-0050", + "/sys/bus/i2c/devices/27-0050", "/sys/bus/i2c/devices/28-0050", + "/sys/bus/i2c/devices/29-0050", "/sys/bus/i2c/devices/30-0050", + "/sys/bus/i2c/devices/31-0050", "/sys/bus/i2c/devices/32-0050"], + 'status': 'NOTINST' + }, + 'SFP-G04': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_4', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/33-0050", "/sys/bus/i2c/devices/34-0050", + "/sys/bus/i2c/devices/35-0050", "/sys/bus/i2c/devices/36-0050", + "/sys/bus/i2c/devices/37-0050", "/sys/bus/i2c/devices/38-0050", + "/sys/bus/i2c/devices/39-0050", "/sys/bus/i2c/devices/40-0050"], + 'status': 'NOTINST' + } +} + +QSFP_RESET_FILE = 'NBA715_QSFP/qsfp{}_reset' +QSFP_LOWPOWER_FILE = 'NBA715_QSFP/qsfp{}_low_power' +QSFP_PRESENT_FILE = 'NBA715_QSFP/qsfp{}_present' + + +class SfpUtil(SfpUtilBase): + """Platform specific SfpUtill class""" + + _port_start = 0 + _port_end = 31 + _port_in_block = 32 + _port_to_eeprom_mapping = {} + _global_port_pres_dict = {} + + def __init__(self): + eeprom_path = "{}/eeprom" + path_list = self.get_sfp_path() + for port_n in range(self._port_start, self._port_end + 1): + port_eeprom_path = eeprom_path.format(path_list[port_n]) + self._port_to_eeprom_mapping[port_n] = port_eeprom_path + + self.init_global_port_presence() + SfpUtilBase.__init__(self) + + def get_sfp_path(self): + paths = [] + for sfp_group in SFP_GROUPS: + paths += SFP_GROUPS[sfp_group]['paths'] + return paths + + def reset(self, port_num): + # Check for invalid port_num + if port_num < self._port_start or port_num > self._port_end: + return False + + path = ATTR_PATH+QSFP_RESET_FILE.format(port_num+1) + try: + reg_file = open(path, 'w') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + reg_file.seek(0) + reg_file.write('1') + + reg_file.close() + return True + + 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 + + path = ATTR_PATH+QSFP_LOWPOWER_FILE.format(port_num+1) + try: + reg_file = open(path, 'w') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + # the gpio pin is ACTIVE_HIGH + if lpmode is True: + val = "1" + else: + val = "0" + + # write value to gpio + reg_file.seek(0) + reg_file.write(val) + reg_file.close() + + return True + + 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 + + path = ATTR_PATH+QSFP_LOWPOWER_FILE.format(port_num+1) + try: + reg_file = open(path, 'r') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + + text = reg_file.read() + reg_file.close() + + return int(text) == 1 + + 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 + + path = ATTR_PATH+QSFP_PRESENT_FILE.format(port_num+1) + try: + reg_file = open(path, 'r') + except IOError as e: + print("Error: unable to open file: %s" % str(e)) + return False + text = reg_file.read() + reg_file.close() + return int(text) == 1 + + def init_global_port_presence(self): + for port_num in range(self.port_start, (self.port_end + 1)): + presence = self.get_presence(port_num) + if presence: + self._global_port_pres_dict[port_num] = '1' + else: + self._global_port_pres_dict[port_num] = '0' + + def get_transceiver_change_event(self, timeout=0): + port_dict = {} + while True: + for port_num in range(self.port_start, (self.port_end + 1)): + presence = self.get_presence(port_num) + if(presence and self._global_port_pres_dict[port_num] == '0'): + self._global_port_pres_dict[port_num] = '1' + port_dict[port_num] = '1' + elif(not presence and + self._global_port_pres_dict[port_num] == '1'): + self._global_port_pres_dict[port_num] = '0' + port_dict[port_num] = '0' + + if len(port_dict) > 0: + return True, port_dict + + time.sleep(1) + + @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._port_in_block + 1) + + @property + def port_to_eeprom_mapping(self): + return self._port_to_eeprom_mapping diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/pmon_daemon_control.json b/device/netberg/x86_64-netberg_aurora_715-r0/pmon_daemon_control.json new file mode 100644 index 0000000000..44871c057e --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/pmon_daemon_control.json @@ -0,0 +1,4 @@ +{ + "skip_ledd": true, + "skip_thermalctld": true +} diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/sensors.conf b/device/netberg/x86_64-netberg_aurora_715-r0/sensors.conf new file mode 100644 index 0000000000..b28b04f643 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/sensors.conf @@ -0,0 +1,3 @@ + + + diff --git a/device/netberg/x86_64-netberg_aurora_715-r0/topo.conf b/device/netberg/x86_64-netberg_aurora_715-r0/topo.conf new file mode 100644 index 0000000000..795ea43143 --- /dev/null +++ b/device/netberg/x86_64-netberg_aurora_715-r0/topo.conf @@ -0,0 +1 @@ +t1 diff --git a/platform/innovium/one-image.mk b/platform/innovium/one-image.mk index c88ec5e65c..bf12670412 100755 --- a/platform/innovium/one-image.mk +++ b/platform/innovium/one-image.mk @@ -6,6 +6,7 @@ $(SONIC_ONE_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR) $(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CEL_MIDSTONE_200I_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELTA_PLATFORM_MODULE) +$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(NETBERG_AURORA_715_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_INSTALLS += $(INVM_DRV) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES) SONIC_INSTALLERS += $(SONIC_ONE_IMAGE) diff --git a/platform/innovium/platform-modules-netberg.mk b/platform/innovium/platform-modules-netberg.mk new file mode 100755 index 0000000000..819b8a1eaa --- /dev/null +++ b/platform/innovium/platform-modules-netberg.mk @@ -0,0 +1,13 @@ +# Netberg Platform modules + +NETBERG_AURORA_715_PLATFORM_MODULE_VERSION = 1.0.0 + +export NETBERG_AURORA_715_PLATFORM_MODULE_VERSION + +NETBERG_AURORA_715_PLATFORM_MODULE = sonic-platform-netberg-aurora-715_$(NETBERG_AURORA_715_PLATFORM_MODULE_VERSION)_amd64.deb +$(NETBERG_AURORA_715_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-netberg +$(NETBERG_AURORA_715_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +$(NETBERG_AURORA_715_PLATFORM_MODULE)_PLATFORM = x86_64-netberg_aurora_715-r0 +SONIC_DPKG_DEBS += $(NETBERG_AURORA_715_PLATFORM_MODULE) + +SONIC_STRETCH_DEBS +=$(NETBERG_AURORA_715_PLATFORM_MODULE) diff --git a/platform/innovium/rules.mk b/platform/innovium/rules.mk index ea23466ad5..9cf6dd2bf2 100755 --- a/platform/innovium/rules.mk +++ b/platform/innovium/rules.mk @@ -1,6 +1,7 @@ include $(PLATFORM_PATH)/invm-sai.mk include $(PLATFORM_PATH)/platform-modules-cel.mk include $(PLATFORM_PATH)/platform-modules-delta.mk +include $(PLATFORM_PATH)/platform-modules-netberg.mk include $(PLATFORM_PATH)/docker-syncd-invm.mk include $(PLATFORM_PATH)/docker-syncd-invm-rpc.mk include $(PLATFORM_PATH)/one-image.mk diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/Makefile b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/Makefile new file mode 100644 index 0000000000..189a3ae471 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/Makefile @@ -0,0 +1,4 @@ +obj-m := x86-64-netberg-aurora-715.o +x86-64-netberg-aurora-715-objs := x86-64-netberg-aurora-715-common.o x86-64-netberg-aurora-715-sys.o \ +x86-64-netberg-aurora-715-led.o x86-64-netberg-aurora-715-fan.o x86-64-netberg-aurora-715-power.o \ +x86-64-netberg-aurora-715-thermal.o x86-64-netberg-aurora-715-qsfp.o diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.c new file mode 100644 index 0000000000..f73295f832 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.c @@ -0,0 +1,399 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" + +/* Addresses scanned */ +static const unsigned short normal_i2c[] = { 0x30, 0x31, 0x32, I2C_CLIENT_END }; +static int debug = 0; + + +/* i2c_client Declaration */ +struct i2c_client *Netberg_CPLD_30_client; //0x30 for SYS CPLD +struct i2c_client *Netberg_CPLD_31_client; //0x31 for Port 01-16 +struct i2c_client *Netberg_CPLD_32_client; //0x32 for Port 17-32 +struct i2c_client *Netberg_CPLD_23_client; //0x23 for Fan CPLD +struct i2c_client *Netberg_CPLD_35_client; //0x35 for Power CPLD +struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave +struct i2c_client *Netberg_EEPROM_56_client; //0x56 for EEPROM + +/* end of i2c_client Declaration */ + +/* register offset define */ +#define BMC_EN_REG 0xA4 +/* end of register offset define */ + +/* common function */ +int bmc_enable(void) +{ + if ((i2c_smbus_read_byte_data(Netberg_CPLD_30_client, BMC_EN_REG) & BIT_0_MASK) == 0x01) + { + return ENABLE; + } + else + { + return DISABLE; + } +} + +int read_8bit_temp(u8 sign,u8 value) +{ + int result = 0; + if(sign) + { + //printf("read_8bit_temp UP %d\n", value & 0x80); + value = ~(value)+1; + result = value; + return result; + } + else + { + //printf("read_8bit_temp DOWN %d\n", value & 0x80); + result = value; + return result; + } +} + +/* end of common function*/ + +static int Netberg_i2c_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) +{ + struct Netberg_i2c_data *Netberg_CPLD_30_data; + struct Netberg_i2c_data *Netberg_CPLD_31_data; + struct Netberg_i2c_data *Netberg_CPLD_32_data; + struct Netberg_i2c_data *Netberg_CPLD_23_data; + struct Netberg_i2c_data *Netberg_CPLD_35_data; + struct Netberg_i2c_data *Netberg_BMC_14_data; + + struct eeprom_data *Netberg_EEPROM_56_data; + + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + { + status = -EIO; + goto exit; + } + + if (!(Netberg_CPLD_30_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL))) + { + printk(KERN_ALERT "kzalloc fail\n"); + status = -ENOMEM; + goto exit; + } + + if (!(Netberg_CPLD_31_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL))) + { + printk(KERN_ALERT "kzalloc fail\n"); + status = -ENOMEM; + goto exit; + } + + if (!(Netberg_CPLD_32_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL))) + { + printk(KERN_ALERT "kzalloc fail\n"); + status = -ENOMEM; + goto exit; + } + + if (!(Netberg_CPLD_23_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL))) + { + printk(KERN_ALERT "kzalloc fail\n"); + status = -ENOMEM; + goto exit; + } + + if (!(Netberg_CPLD_35_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL))) + { + printk(KERN_ALERT "kzalloc fail\n"); + status = -ENOMEM; + goto exit; + } + + if (!(Netberg_BMC_14_data = kzalloc(sizeof(struct Netberg_i2c_data), GFP_KERNEL))) + { + printk(KERN_ALERT "kzalloc fail\n"); + status = -ENOMEM; + goto exit; + } + + if (!(Netberg_EEPROM_56_data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) + { + status = -ENOMEM; + goto exit; + } + memset(Netberg_EEPROM_56_data->data, 0xff, EEPROM_SIZE); + + i2c_set_clientdata(Netberg_CPLD_30_client, Netberg_CPLD_30_data); + i2c_set_clientdata(Netberg_CPLD_31_client, Netberg_CPLD_31_data); + i2c_set_clientdata(Netberg_CPLD_32_client, Netberg_CPLD_32_data); + i2c_set_clientdata(Netberg_CPLD_23_client, Netberg_CPLD_23_data); + i2c_set_clientdata(Netberg_CPLD_35_client, Netberg_CPLD_35_data); + i2c_set_clientdata(Netberg_BMC_14_client , Netberg_BMC_14_data); + i2c_set_clientdata(Netberg_EEPROM_56_client, Netberg_EEPROM_56_data); + + mutex_init(&Netberg_CPLD_30_data->update_lock); + mutex_init(&Netberg_CPLD_31_data->update_lock); + mutex_init(&Netberg_CPLD_32_data->update_lock); + mutex_init(&Netberg_CPLD_23_data->update_lock); + mutex_init(&Netberg_CPLD_35_data->update_lock); + mutex_init(&Netberg_BMC_14_data->update_lock); + mutex_init(&Netberg_EEPROM_56_data->update_lock); + + Netberg_CPLD_30_data->valid = 0; + mutex_init(&Netberg_CPLD_30_data->update_lock); + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &NBA715_SYS_group); + if (status) + { + goto exit_free; + } + + status = sysfs_create_group(&client->dev.kobj, &NBA715_LED_group); + if (status) + { + goto exit_free; + } + + status = sysfs_create_group(&client->dev.kobj, &NBA715_FAN_group); + if (status) + { + goto exit_free; + } + + status = sysfs_create_group(&client->dev.kobj, &NBA715_THERMAL_group); + if (status) + { + goto exit_free; + } + + status = sysfs_create_group(&client->dev.kobj, &NBA715_POWER_group); + if (status) + { + goto exit_free; + } + + status = sysfs_create_group(&client->dev.kobj, &NBA715_QSFP_group); + if (status) + { + goto exit_free; + } + + /* create the sysfs eeprom file */ + status = sysfs_create_bin_file(&client->dev.kobj, &net_eeprom_attr); + if (status) { + goto exit_free; + } + + + Netberg_CPLD_30_data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(Netberg_CPLD_30_data->hwmon_dev)) + { + status = PTR_ERR(Netberg_CPLD_30_data->hwmon_dev); + goto exit_remove; + } + dev_info(&client->dev, "%s: '%s'\n", dev_name(Netberg_CPLD_30_data->hwmon_dev), client->name); + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &NBA715_SYS_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_LED_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_FAN_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_THERMAL_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_POWER_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_QSFP_group); + +exit_free: + kfree(Netberg_CPLD_30_data); + kfree(Netberg_EEPROM_56_data); + +exit: + return status; +} + +static int Netberg_i2c_remove(struct i2c_client *client) +{ + struct Netberg_i2c_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &NBA715_SYS_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_LED_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_FAN_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_THERMAL_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_POWER_group); + sysfs_remove_group(&client->dev.kobj, &NBA715_QSFP_group); + + sysfs_remove_bin_file(&client->dev.kobj, &net_eeprom_attr); + + kfree(data); + return 0; +} + +static const struct i2c_device_id Netberg_i2c_id[] = +{ + { "Netberg_CPLD_30", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(i2c, Netberg_i2c_id); + +static struct i2c_driver Netberg_i2c_driver = +{ + .class = I2C_CLASS_HWMON, + .driver = + { + .name = "NBA_715_i2c", + }, + .probe = Netberg_i2c_probe, + .remove = Netberg_i2c_remove, + .id_table = Netberg_i2c_id, + .address_list = normal_i2c, +}; + +/*For main Switch board*/ +static struct i2c_board_info Netberg_CPLD_30_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_CPLD_30", 0x30), + .platform_data = NULL, + }, +}; + +/*For QSFP Port 01 - 16*/ +static struct i2c_board_info Netberg_CPLD_31_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_CPLD_31", 0x31), + .platform_data = NULL, + }, +}; +/*For QSFP Port 17 - 32*/ +static struct i2c_board_info Netberg_CPLD_32_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_CPLD_32", 0x32), + .platform_data = NULL, + }, +}; +/*For Fan status*/ +static struct i2c_board_info Netberg_CPLD_23_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_CPLD_23", 0x23), + .platform_data = NULL, + }, +}; +/*For Power status*/ +static struct i2c_board_info Netberg_CPLD_35_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_CPLD_35", 0x35), + .platform_data = NULL, + }, +}; +/*For BMC Slave*/ +static struct i2c_board_info Netberg_BMC_14_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_BMC_14", 0x14), + .platform_data = NULL, + }, +}; + +static struct i2c_board_info Netberg_EEPROM_56_info[] __initdata = +{ + { + I2C_BOARD_INFO("Netberg_EEPROM_56", 0x56), + .platform_data = NULL, + }, +}; + + +static int __init Netberg_i2c_init(void) +{ + int ret; + int cmp; + char keyword[] = "SMBus I801"; + char buf1[128]; + struct i2c_adapter *i2c_adap; + struct file *fp; + mm_segment_t fs; + loff_t pos; + + printk("Open file...\n"); + fp = filp_open("/sys/class/i2c-dev/i2c-0/name", O_RDONLY , 0644); + if (IS_ERR(fp)) { + printk("Open file FAILED\n"); + return -1; + } + + fs = get_fs(); + set_fs(KERNEL_DS); + pos = 0; + vfs_read(fp, buf1, sizeof(buf1), &pos); + printk("Detect %s\n", buf1); + cmp = strncmp(keyword, buf1, sizeof(keyword)-1); + set_fs(fs); + + filp_close(fp, NULL); + + if(cmp == 0) + { + i2c_adap = i2c_get_adapter(0); + printk("SMBus I801 is at bus 0\n"); + } + else + { + i2c_adap = i2c_get_adapter(1); + printk("SMBus I801 is at bus 1\n"); + } + + if (i2c_adap == NULL) + { + printk("ERROR: i2c_get_adapter FAILED!\n"); + return -1; + } + Netberg_CPLD_30_client = i2c_new_device(i2c_adap, &Netberg_CPLD_30_info[0]); + Netberg_CPLD_31_client = i2c_new_device(i2c_adap, &Netberg_CPLD_31_info[0]); + Netberg_CPLD_32_client = i2c_new_device(i2c_adap, &Netberg_CPLD_32_info[0]); + Netberg_CPLD_23_client = i2c_new_device(i2c_adap, &Netberg_CPLD_23_info[0]); + Netberg_CPLD_35_client = i2c_new_device(i2c_adap, &Netberg_CPLD_35_info[0]); + Netberg_BMC_14_client = i2c_new_device(i2c_adap, &Netberg_BMC_14_info[0]); + Netberg_EEPROM_56_client = i2c_new_device(i2c_adap, &Netberg_EEPROM_56_info[0]); + + if (Netberg_CPLD_30_info == NULL || Netberg_CPLD_31_info == NULL || Netberg_CPLD_32_info == NULL + || Netberg_CPLD_23_info == NULL || Netberg_CPLD_35_info == NULL || Netberg_BMC_14_info == NULL + || Netberg_EEPROM_56_info == NULL) + { + printk("ERROR: i2c_new_device FAILED!\n"); + return -1; + } + + i2c_put_adapter(i2c_adap); + ret = i2c_add_driver(&Netberg_i2c_driver); + printk(KERN_ALERT "NBA715 i2c Driver Version: %s\n", DRIVER_VERSION); + printk(KERN_ALERT "NBA715 i2c Driver INSTALL SUCCESS\n"); + return ret; +} + +static void __exit Netberg_i2c_exit(void) +{ + i2c_unregister_device(Netberg_CPLD_30_client); + i2c_unregister_device(Netberg_CPLD_31_client); + i2c_unregister_device(Netberg_CPLD_32_client); + i2c_unregister_device(Netberg_CPLD_23_client); + i2c_unregister_device(Netberg_CPLD_35_client); + i2c_unregister_device(Netberg_BMC_14_client); + i2c_unregister_device(Netberg_EEPROM_56_client); + i2c_del_driver(&Netberg_i2c_driver); + printk(KERN_ALERT "NBA715 i2c Driver UNINSTALL SUCCESS\n"); +} + +MODULE_AUTHOR("Netberg Inc."); +MODULE_DESCRIPTION("Netberg Aurora 715 i2c Driver"); +MODULE_LICENSE("GPL"); +module_param(debug, int, 0); +MODULE_PARM_DESC(debug, "Enable debugging (0-1)"); + +module_init(Netberg_i2c_init); +module_exit(Netberg_i2c_exit); diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.h new file mode 100644 index 0000000000..39e5ab15e9 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-common.h @@ -0,0 +1,25 @@ +/* register offset define */ +#define ENABLE 1 +#define DISABLE 0 + +#define PASSED 1 +#define FAILED 0 + +#define TRUE 1 +#define FALSE 0 + +#define ABNORMAL 1 +#define NORMAL 0 + +#define BIT_0_MASK 0x01 +#define BIT_1_MASK 0x02 +#define BIT_2_MASK 0x04 +#define BIT_3_MASK 0x08 +#define BIT_4_MASK 0x10 +#define BIT_5_MASK 0x20 +#define BIT_6_MASK 0x40 +#define BIT_7_MASK 0x80 +/* end of register offset define */ + +int bmc_enable(void); +int read_8bit_temp(u8 sign,u8 value); \ No newline at end of file diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.c new file mode 100644 index 0000000000..4cb4d7ebfa --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.c @@ -0,0 +1,365 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" +#include "x86-64-netberg-aurora-715-fan.h" + +/* extern i2c_client */ +extern struct i2c_client *Netberg_CPLD_23_client; //0x23 for Fan CPLD +extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave +/* end of extern i2c_client */ + +/* implement i2c_function */ +ssize_t fan_ctrl_mode_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_BMC_14_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == FANCTRL_MODE) + { + if( bmc_enable() == ENABLE) + { + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, FANCTRL_MODE_REG); + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s0x%x\n", buf, status); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} + +ssize_t fan_ctrl_rpm_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_BMC_14_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == FANCTRL_RPM) + { + if( bmc_enable() == ENABLE) + { + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, FANCTRL_RPM_REG); + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s0x%x\n", buf, status); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} + +ssize_t fan_status_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_23_data = i2c_get_clientdata(Netberg_CPLD_23_client); + struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + mutex_lock(&Netberg_BMC_14_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_FAN_STAT_REG); + mutex_unlock(&Netberg_BMC_14_data->update_lock); + } + else + { + mutex_lock(&Netberg_CPLD_23_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, FAN_STAT_REG); + mutex_unlock(&Netberg_CPLD_23_data->update_lock); + } + + result = FAILED; + switch (attr->index) + { + case 1: + if(status & BIT_0_MASK) + { + result = PASSED; + } + break; + case 2: + if(status & BIT_1_MASK) + { + result = PASSED; + } + break; + case 3: + if(status & BIT_2_MASK) + { + result = PASSED; + } + break; + case 4: + if(status & BIT_3_MASK) + { + result = PASSED; + } + break; + case 5: + if(status & BIT_4_MASK) + { + result = PASSED; + } + break; + } + if(result != PASSED) + { + return sprintf(buf, "%s%d\n", buf, FAILED); + } + return sprintf(buf, "%s%d\n", buf, PASSED); +} + +ssize_t fan_present_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_23_data = i2c_get_clientdata(Netberg_CPLD_23_client); + struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + mutex_lock(&Netberg_BMC_14_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_FAN_PRESENT_REG); + mutex_unlock(&Netberg_BMC_14_data->update_lock); + } + else + { + mutex_lock(&Netberg_CPLD_23_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, FAN_PRESENT_REG); + mutex_unlock(&Netberg_CPLD_23_data->update_lock); + } + + result = FAILED; + switch (attr->index) + { + case 1: + if(status & BIT_0_MASK) + { + result = PASSED; + } + break; + case 2: + if(status & BIT_1_MASK) + { + result = PASSED; + } + break; + case 3: + if(status & BIT_2_MASK) + { + result = PASSED; + } + break; + case 4: + if(status & BIT_3_MASK) + { + result = PASSED; + } + break; + case 5: + if(status & BIT_4_MASK) + { + result = PASSED; + } + break; + } + if(result != PASSED) + { + return sprintf(buf, "%s%d\n", buf, FAILED); + } + return sprintf(buf, "%s%d\n", buf, PASSED); +} + +ssize_t fan_power_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_23_data = i2c_get_clientdata(Netberg_CPLD_23_client); + struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + mutex_lock(&Netberg_BMC_14_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_FAN_POWER_REG); + mutex_unlock(&Netberg_BMC_14_data->update_lock); + } + else + { + mutex_lock(&Netberg_CPLD_23_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, FAN_POWER_REG); + mutex_unlock(&Netberg_CPLD_23_data->update_lock); + } + + result = FAILED; + switch (attr->index) + { + case 1: + if(status & BIT_0_MASK) + { + result = PASSED; + } + break; + case 2: + if(status & BIT_1_MASK) + { + result = PASSED; + } + break; + case 3: + if(status & BIT_2_MASK) + { + result = PASSED; + } + break; + case 4: + if(status & BIT_3_MASK) + { + result = PASSED; + } + break; + case 5: + if(status & BIT_4_MASK) + { + result = PASSED; + } + break; + } + if(result != PASSED) + { + return sprintf(buf, "%s%d\n", buf, FAILED); + } + return sprintf(buf, "%s%d\n", buf, PASSED); +} + +ssize_t fan_rpm_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int fan_location = 0; + int fan_offset = 0; + u16 fan_speed = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *target_client = NULL; + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + target_client = Netberg_BMC_14_client; + } + else + { + target_client = Netberg_CPLD_23_client; + } + + switch (attr->index) + { + case FAN1_FRONT_RPM: + fan_location = 0; + fan_offset = 0; + break; + case FAN2_FRONT_RPM: + fan_location = 0; + fan_offset = 1; + break; + case FAN3_FRONT_RPM: + fan_location = 0; + fan_offset = 2; + break; + case FAN4_FRONT_RPM: + fan_location = 0; + fan_offset = 3; + break; + case FAN5_FRONT_RPM: + fan_location = 0; + fan_offset = 4; + break; + case FAN1_REAR_RPM: + fan_location = 1; + fan_offset = 0; + break; + case FAN2_REAR_RPM: + fan_location = 1; + fan_offset = 1; + break; + case FAN3_REAR_RPM: + fan_location = 1; + fan_offset = 2; + break; + case FAN4_REAR_RPM: + fan_location = 1; + fan_offset = 3; + break; + case FAN5_REAR_RPM: + fan_location = 1; + fan_offset = 4; + break; + } + if(fan_location == 0) + { + // front fan of couple + // read high byte + status = i2c_smbus_read_byte_data(target_client, FAN_F_RPM_REG+(fan_offset*2)+1); + fan_speed = status; + if(status < 0 || status == 0xff) + { + fan_speed = 0; + } + // read low byte + status = i2c_smbus_read_byte_data(target_client, FAN_F_RPM_REG+(fan_offset*2)); + fan_speed = ((fan_speed<<8) + status)*30; + if(status < 0 || status == 0xff) + { + fan_speed = 0; + } + } + else + { + // rear fan of couple + // read high byte + status = i2c_smbus_read_byte_data(target_client, FAN_R_RPM_REG+(fan_offset*2)+1); + fan_speed = status; + if(status < 0 || status == 0xff) + { + fan_speed = 0; + } + // read low byte + status = i2c_smbus_read_byte_data(target_client, FAN_R_RPM_REG+(fan_offset*2)); + fan_speed = ((fan_speed<<8) + status)*30; + if(status < 0 || status == 0xff) + { + fan_speed = 0; + } + } + sprintf(buf, "%s%d\n", buf, fan_speed); + return sprintf(buf, "%s\n",buf); +} +/* end of implement i2c_function */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.h new file mode 100644 index 0000000000..66ffc93393 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-fan.h @@ -0,0 +1,12 @@ +/* register offset define */ +#define FANCTRL_RPM_REG 0x1a +#define FANCTRL_MODE_REG 0x1b +#define FAN_STAT_REG 0x00 +#define FAN_POWER_REG 0x01 +#define FAN_PRESENT_REG 0x02 +#define BMC_FAN_STAT_REG 0x80 +#define BMC_FAN_POWER_REG 0x81 +#define BMC_FAN_PRESENT_REG 0x82 +#define FAN_F_RPM_REG 0xa0 +#define FAN_R_RPM_REG 0xb0 +/* end of register offset define */ \ No newline at end of file diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.c new file mode 100644 index 0000000000..df4957212d --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.c @@ -0,0 +1,220 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" +#include "x86-64-netberg-aurora-715-led.h" + +/* i2c_client Declaration */ +extern struct i2c_client *Netberg_CPLD_30_client; //0x30 for SYS CPLD +/* end of i2c_client Declaration */ + +/* implement i2c_function */ +ssize_t led_ctrl_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int res = 0x1; + int i; + int led_a_status = 0; + int led_g_status = 0; + int led_b_status = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG); + sprintf(buf, ""); + + for (i = 1; i <= 4; i++) + { + if ( i == attr->index) + { + if (status & res) + { + led_a_status = ENABLE; + } + else + { + led_a_status = DISABLE; + } + } + res = res << 1; + if( i == (attr->index + 1) ) + { + if (status & res) + { + led_g_status = ENABLE; + } + else + { + led_g_status = DISABLE; + } + } + res = res << 1; + } + res = 0x1; + + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_BLINK_REG); + for (i = 1; i <= 4; i++) + { + if ( i == attr->index) + { + if (status & res) + { + led_b_status = ENABLE; + } + else + { + led_b_status = DISABLE; + } + } + res = res << 1; + } + if(led_a_status == ENABLE && led_b_status == ENABLE) + { + sprintf(buf, "%s2\n", buf); + } + else if(led_a_status == ENABLE && led_b_status == DISABLE) + { + sprintf(buf, "%s1\n", buf); + } + else if(led_g_status == ENABLE && led_b_status == ENABLE) + { + sprintf(buf, "%s4\n", buf); + } + else if(led_g_status == ENABLE && led_b_status == DISABLE) + { + sprintf(buf, "%s3\n", buf); + } + else + { + sprintf(buf, "%s0\n", buf); + } + + return sprintf(buf, "%s", buf); +} + +ssize_t led_ctrl_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int led_value = -EPERM; + int blk_value = -EPERM; + int result = -EPERM; + int offset = 0; + u16 i; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + led_value = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG); + blk_value = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_BLINK_REG); + if (attr->index != 0) + { + i = simple_strtol(buf, NULL, 10); + if(attr->index == 1) + { + offset = 0; + } + else + { + offset = 2*((attr->index)-1); + } + switch(i) + { + case SWITCH_LED_OFF: //i=0 + led_value &= ~(0x03 << offset); + blk_value &= ~(1 << ((attr->index)-1)); + break; + case SWITCH_LED_A_N: //i=1 + led_value &= ~(0x03 << offset); + led_value |= (0x01 << offset); + blk_value &= ~(1 << ((attr->index)-1)); + break; + case SWITCH_LED_A_B: //i=2 + led_value &= ~(0x03 << offset); + led_value |= (0x01 << offset); + blk_value |= (1 << ((attr->index)-1)); + break; + case SWITCH_LED_G_N: //i=3 + led_value &= ~(0x03 << offset); + led_value |= (0x02 << offset); + blk_value &= ~(1 << ((attr->index)-1)); + break; + case SWITCH_LED_G_B: //i=4 + led_value &= ~(0x03 << offset); + led_value |= (0x02 << offset); + blk_value |= (1 << ((attr->index)-1)); + break; + default: + printk(KERN_ALERT "led_ctrl_set wrong Value\n"); + return count; + } + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG, led_value); + result |= i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_BLINK_REG, blk_value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: led_ctrl_set FAILED!\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} + +ssize_t led_fiber_get(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == LED_FIBER) + { + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_FIBER_REG) & BIT_0_MASK) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} +ssize_t led_fiber_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, LED_CTRL_REG); + if (attr->index == LED_FIBER) + { + input = simple_strtol(buf, NULL, 10); + if (input == ENABLE) + { + value = status | LED_FIBER_ENABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_FIBER_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: led_ctrl_set FAILED!\n"); + } + } + else if (input == DISABLE) + { + value = status & LED_FIBER_DISABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, LED_FIBER_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: led_ctrl_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "led_ctrl_set wrong Value\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} +/* end of implement i2c_function */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.h new file mode 100644 index 0000000000..c07a246447 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-led.h @@ -0,0 +1,12 @@ +/* register offset define */ +#define LED_CTRL_REG 0xa2 +#define LED_BLINK_REG 0xa3 +#define LED_FIBER_REG 0xa0 +#define LED_FIBER_ENABLE 0x01 +#define LED_FIBER_DISABLE 0xfe +#define SWITCH_LED_OFF 0 +#define SWITCH_LED_A_N 1 +#define SWITCH_LED_A_B 2 +#define SWITCH_LED_G_N 3 +#define SWITCH_LED_G_B 4 +/* end of register offset define */ \ No newline at end of file diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.c new file mode 100644 index 0000000000..1913d1716b --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.c @@ -0,0 +1,650 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" +#include "x86-64-netberg-aurora-715-power.h" + +/* extern i2c_client */ +extern struct i2c_client *Netberg_CPLD_35_client; //0x35 for Power CPLD +extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave +/* end of extern i2c_client */ + +/* convert function */ +static int two_complement_to_int(u16 data, u8 valid_bit, int mask) +{ + u16 valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} +/* end of convert function */ + +/* implement i2c_function */ +ssize_t psu_status_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + u32 result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_35_data = i2c_get_clientdata(Netberg_CPLD_35_client); + struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + mutex_lock(&Netberg_BMC_14_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_PSU_STAT_REG); + mutex_unlock(&Netberg_BMC_14_data->update_lock); + } + else + { + mutex_lock(&Netberg_CPLD_35_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_35_client, PSU_STAT_REG); + mutex_unlock(&Netberg_CPLD_35_data->update_lock); + } + + result = TRUE; + switch (attr->index) + { + case 1: + if(status & BIT_2_MASK) + { + result = FALSE; + } + break; + case 2: + if(status & BIT_3_MASK) + { + result = FALSE; + } + break; + } + if(result != TRUE) + { + return sprintf(buf, "%s%d\n", buf, FALSE); + } + return sprintf(buf, "%s%d\n", buf, TRUE); +} +ssize_t psu_present_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + u32 result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_35_data = i2c_get_clientdata(Netberg_CPLD_35_client); + struct Netberg_i2c_data *Netberg_BMC_14_data = i2c_get_clientdata(Netberg_BMC_14_client); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + mutex_lock(&Netberg_BMC_14_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, BMC_PSU_STAT_REG); + mutex_unlock(&Netberg_BMC_14_data->update_lock); + } + else + { + mutex_lock(&Netberg_CPLD_35_data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_35_client, PSU_STAT_REG); + mutex_unlock(&Netberg_CPLD_35_data->update_lock); + } + + result = FALSE; + switch (attr->index) + { + case 1: + if(status & BIT_0_MASK) + { + result = TRUE; + } + break; + case 2: + if(status & BIT_1_MASK) + { + result = TRUE; + } + break; + } + if(result != TRUE) + { + return sprintf(buf, "%s%d\n", buf, FALSE); + } + return sprintf(buf, "%s%d\n", buf, TRUE); +} +ssize_t psu_vin_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_VIN: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_VIN_REG); + break; + case PSU2_VIN: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_VIN_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} +ssize_t psu_iin_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_IIN: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_IIN_REG); + break; + case PSU2_IIN: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_IIN_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} +ssize_t psu_vout_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0; + int multiplier = 1000; + u16 u16_vmode = 0; + u16 u16_vout = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_VOUT: + u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_1_VOMDE_REG); + u16_vout = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_VOUT_REG); + break; + case PSU2_VOUT: + u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_2_VOMDE_REG); + u16_vout = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_VOUT_REG); + break; + } + if(u16_vout == 0xffff || u16_vout == -1) + { + return sprintf(buf, "%s0\n", buf); + } + /* vout mode */ + multiplier = 1000; + exponent = two_complement_to_int(u16_vmode & 0x1f, 5, 0x1f); + /* vout */ + result = (exponent >= 0) ? ((u16_vout << exponent)*multiplier) : \ + (u16_vout*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_iout_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_IOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_IOUT_REG); + break; + case PSU2_IOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_IOUT_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_temp_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_TEMP: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_TEMP_1_REG); + break; + case PSU2_TEMP: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_TEMP_1_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_fan_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_FAN_SPEED: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_FAN_SPEED_REG); + break; + case PSU2_FAN_SPEED: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_FAN_SPEED_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_pout_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_POUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_POUT_REG); + break; + case PSU2_POUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_POUT_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000000; // lm-sensor unit: uW + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_pin_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_PIN: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_PIN_REG); + break; + case PSU2_PIN: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_PIN_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000000; // lm-sensor unit: uW + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_mfr_model_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 u16_val = 0; + char model[2]; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_MFR_MODEL: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_MFR_MODEL_REG); + break; + case PSU2_MFR_MODEL: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_MFR_MODEL_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + model[0] = u16_val >> 8; + model[1] = u16_val; + sprintf(buf, "%s%c%c\n", buf, model[0], model[1]); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_iout_max_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u32 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_MFR_IOUT_MAX: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_1_MFR_IOUT_MAX_REG); + break; + case PSU2_MFR_IOUT_MAX: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, PSU_2_MFR_IOUT_MAX_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; // lm-sensor unit: uW + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t psu_vmode_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 u16_vmode = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case PSU1_VOMDE: + u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_1_VOMDE_REG); + break; + case PSU2_VOMDE: + u16_vmode = i2c_smbus_read_byte_data(Netberg_BMC_14_client, PSU_2_VOMDE_REG); + break; + } + if(u16_vmode == 0xffff || u16_vmode == -1) + { + return sprintf(buf, "%s0\n", buf); + } + /* vout mode */ + sprintf(buf, "%s%d\n", buf, u16_vmode); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t dc_vout_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case DC6E_P0_VOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P0_VOUT_REG); + break; + case DC6E_P1_VOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P1_VOUT_REG); + break; + case DC70_P0_VOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P0_VOUT_REG); + break; + case DC70_P1_VOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P1_VOUT_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t dc_iout_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case DC6E_P0_IOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P0_IOUT_REG); + break; + case DC6E_P1_IOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P1_IOUT_REG); + break; + case DC70_P0_IOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P0_IOUT_REG); + break; + case DC70_P1_IOUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P1_IOUT_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t dc_pout_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u16 result = -EPERM; + int exponent = 0, mantissa = 0; + int multiplier = 1000; + u16 u16_val = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + sprintf(buf, ""); + if( bmc_enable() == ENABLE) + { + switch(attr->index) + { + case DC6E_P0_POUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P0_POUT_REG); + break; + case DC6E_P1_POUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_6E_P1_POUT_REG); + break; + case DC70_P0_POUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P0_POUT_REG); + break; + case DC70_P1_POUT: + u16_val = i2c_smbus_read_word_data(Netberg_BMC_14_client, DC_CHIP_70_P1_POUT_REG); + break; + } + if(u16_val == 0xffff || u16_val == -1) + { + return sprintf(buf, "%s0\n", buf); + } + exponent = two_complement_to_int(u16_val >> 11, 5, 0x1f); + mantissa = two_complement_to_int(u16_val & 0x7ff, 11, 0x7ff); + multiplier = 1000000; + result = (exponent >= 0) ? ((mantissa << exponent)*multiplier) : \ + (mantissa*multiplier / (1 << -exponent)); + sprintf(buf, "%s%d\n", buf, result); + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + return sprintf(buf, "%s\n", buf); +} +/* end of implement i2c_function */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.h new file mode 100644 index 0000000000..6164179b2a --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-power.h @@ -0,0 +1,38 @@ +/* register offset define */ +#define PSU_STAT_REG 0xa0 +#define BMC_PSU_STAT_REG 0xc0 +#define PSU_1_VIN_REG 0x50 +#define PSU_1_IIN_REG 0x51 +#define PSU_1_VOUT_REG 0x52 +#define PSU_1_IOUT_REG 0x53 +#define PSU_1_TEMP_1_REG 0x54 +#define PSU_1_FAN_SPEED_REG 0x55 +#define PSU_1_POUT_REG 0x56 +#define PSU_1_PIN_REG 0x57 +#define PSU_1_MFR_MODEL_REG 0x58 +#define PSU_1_MFR_IOUT_MAX_REG 0x59 +#define PSU_1_VOMDE_REG 0x5a +#define PSU_2_VIN_REG 0x60 +#define PSU_2_IIN_REG 0x61 +#define PSU_2_VOUT_REG 0x62 +#define PSU_2_IOUT_REG 0x63 +#define PSU_2_TEMP_1_REG 0x64 +#define PSU_2_FAN_SPEED_REG 0x65 +#define PSU_2_POUT_REG 0x66 +#define PSU_2_PIN_REG 0x67 +#define PSU_2_MFR_MODEL_REG 0x68 +#define PSU_2_MFR_IOUT_MAX_REG 0x69 +#define PSU_2_VOMDE_REG 0x6a +#define DC_CHIP_6E_P0_VOUT_REG 0x90 +#define DC_CHIP_6E_P0_IOUT_REG 0x91 +#define DC_CHIP_6E_P0_POUT_REG 0x92 +#define DC_CHIP_6E_P1_VOUT_REG 0x94 +#define DC_CHIP_6E_P1_IOUT_REG 0x95 +#define DC_CHIP_6E_P1_POUT_REG 0x96 +#define DC_CHIP_70_P0_VOUT_REG 0x98 +#define DC_CHIP_70_P0_IOUT_REG 0x99 +#define DC_CHIP_70_P0_POUT_REG 0x9a +#define DC_CHIP_70_P1_VOUT_REG 0x9c +#define DC_CHIP_70_P1_IOUT_REG 0x9d +#define DC_CHIP_70_P1_POUT_REG 0x9e +/* end of register offset define */ \ No newline at end of file diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.c new file mode 100644 index 0000000000..97525e6298 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.c @@ -0,0 +1,584 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" +#include "x86-64-netberg-aurora-715-qsfp.h" + +/* i2c_client Declaration */ +extern struct i2c_client *Netberg_CPLD_31_client; //0x31 for Port 01-16 +extern struct i2c_client *Netberg_CPLD_32_client; //0x32 for Port 17-32 +/* end of i2c_client Declaration */ + +/* extern i2c_function */ +/* end of extern i2c_function */ + +/* implement i2c_function */ +ssize_t qsfp_low_power_all_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u8 status = -EPERM; + u32 result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + if (attr->index == QSFP_LOW_POWER_ALL) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_REAR_LOW_POWER_REG); //25-32 + result = status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_LOW_POWER_REG); //17-24 + result = (result << 8) | status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_REAR_LOW_POWER_REG); //9-16 + result = (result << 8) | status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_LOW_POWER_REG); //1-8 + result = (result << 8) | status; + sprintf(buf, "%s0x%x\n", buf, result); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_low_power_all_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int value = 0x0; + int result = 0; + int input = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client); + struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client); + + mutex_lock(&Netberg_CPLD_31_data->update_lock); + mutex_lock(&Netberg_CPLD_32_data->update_lock); + if (attr->index == QSFP_LOW_POWER_ALL) + { + input = simple_strtol(buf, NULL, 10); + if (input == ENABLE) + { + value = 0xff; + } + else if(input == DISABLE) + { + value = 0x00; + } + else + { + printk(KERN_ALERT "qsfp_low_power_all_set wrong value\n"); + return count; + } + result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_LOW_POWER_REG, value); + result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_REAR_LOW_POWER_REG, value); + result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_LOW_POWER_REG, value); + result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_REAR_LOW_POWER_REG, value); + + if(result != 0) + { + printk(KERN_ALERT "qsfp_low_power_all_set FAILED\n"); + return count; + } + } + mutex_unlock(&Netberg_CPLD_31_data->update_lock); + mutex_unlock(&Netberg_CPLD_32_data->update_lock); + return count; +} + +ssize_t qsfp_low_power_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int port_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + port_index = attr->index; + sprintf(buf, ""); + + if (port_index >= 1 && port_index <= 16) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_low_power_regs[port_index][0]); + } + else if (port_index >= 17 && port_index <= 32) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_low_power_regs[port_index][0]); + } + + if (status & qsfp_low_power_regs[port_index][1]) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_low_power_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int result = 0; + int input = 0; + int port_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client); + struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client); + struct i2c_client *target_client = NULL; + + port_index = attr->index; + input = simple_strtol(buf, NULL, 10); + mutex_lock(&Netberg_CPLD_31_data->update_lock); + mutex_lock(&Netberg_CPLD_32_data->update_lock); + + if (port_index >= 1 && port_index <= 16) + { + target_client = Netberg_CPLD_31_client; + + } + else if (port_index >= 17 && port_index <= 32) + { + target_client = Netberg_CPLD_32_client; + } + + status = i2c_smbus_read_byte_data(target_client, qsfp_low_power_regs[port_index][0]); + if( input == ENABLE) + { + status |= qsfp_low_power_regs[port_index][1]; + result = i2c_smbus_write_byte_data(target_client, qsfp_low_power_regs[port_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_low_power_set ON FAILED!\n"); + } + } + else if( input == DISABLE) + { + status &= ~(qsfp_low_power_regs[port_index][1]); + result = i2c_smbus_write_byte_data(target_client, qsfp_low_power_regs[port_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_low_power_set OFF FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "ERROR: qsfp_low_power_set WRONG VALUE\n"); + } + + mutex_unlock(&Netberg_CPLD_31_data->update_lock); + mutex_unlock(&Netberg_CPLD_32_data->update_lock); + + return count; +} + +ssize_t qsfp_reset_all_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int value = 0x0; + int result = 0; + int input = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client); + struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client); + + mutex_lock(&Netberg_CPLD_31_data->update_lock); + mutex_lock(&Netberg_CPLD_32_data->update_lock); + if (attr->index == QSFP_RESET_ALL) + { + input = simple_strtol(buf, NULL, 10); + if (input == QSFP_RESET) + { + value = 0x00; + } + else + { + printk(KERN_ALERT "qsfp_reset_all_set wrong value\n"); + return count; + } + result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_RESET_REG, value); + result += i2c_smbus_write_byte_data(Netberg_CPLD_31_client, QSFP_REAR_RESET_REG, value); + result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_RESET_REG, value); + result += i2c_smbus_write_byte_data(Netberg_CPLD_32_client, QSFP_REAR_RESET_REG, value); + + if(result != 0) + { + printk(KERN_ALERT "qsfp_reset_all_set FAILED\n"); + return count; + } + } + mutex_unlock(&Netberg_CPLD_31_data->update_lock); + mutex_unlock(&Netberg_CPLD_32_data->update_lock); + return count; +} + +ssize_t qsfp_reset_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int result = 0; + int input = 0; + int port_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client); + struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client); + struct i2c_client *target_client = NULL; + + port_index = attr->index; + input = simple_strtol(buf, NULL, 10); + mutex_lock(&Netberg_CPLD_31_data->update_lock); + mutex_lock(&Netberg_CPLD_32_data->update_lock); + + if (port_index >= 1 && port_index <= 16) + { + target_client = Netberg_CPLD_31_client; + + } + else if (port_index >= 17 && port_index <= 32) + { + target_client = Netberg_CPLD_32_client; + } + + status = i2c_smbus_read_byte_data(target_client, qsfp_reset_regs[port_index][0]); + if( input == QSFP_RESET) + { + status |= qsfp_reset_regs[port_index][1]; + result = i2c_smbus_write_byte_data(target_client, qsfp_reset_regs[port_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_reset_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "ERROR: qsfp_reset_set WRONG VALUE\n"); + } + + mutex_unlock(&Netberg_CPLD_31_data->update_lock); + mutex_unlock(&Netberg_CPLD_32_data->update_lock); + + return count; +} + +ssize_t qsfp_present_all_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u8 status = -EPERM; + u32 result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + if (attr->index == QSFP_PRESENT_ALL) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_REAR_PRESENT_REG); //25-32 + result = status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_PRESENT_REG); //17-24 + result = (result << 8) | status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_REAR_PRESENT_REG); //9-16 + result = (result << 8) | status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_PRESENT_REG); //1-8 + result = (result << 8) | status; + result = ~(result); + sprintf(buf, "%s0x%x\n", buf, result); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_present_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int port_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + port_index = attr->index; + sprintf(buf, ""); + + if (port_index >= 1 && port_index <= 16) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_present_regs[port_index][0]); + } + else if (port_index >= 17 && port_index <= 32) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_present_regs[port_index][0]); + } + + if (status & qsfp_present_regs[port_index][1]) + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + + return sprintf(buf, "%s\n", buf); +} +ssize_t qsfp_int_all_get(struct device *dev, struct device_attribute *da, char *buf) +{ + u8 status = -EPERM; + u32 result = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + if (attr->index == QSFP_INT_ALL) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_REAR_INT_REG); //25-32 + result = status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, QSFP_FRONT_INT_REG); //17-24 + result = (result << 8) | status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_REAR_INT_REG); //9-16 + result = (result << 8) | status; + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, QSFP_FRONT_INT_REG); //1-8 + result = (result << 8) | status; + sprintf(buf, "%s0x%x\n", buf, result); + } + return sprintf(buf, "%s\n", buf); +} +ssize_t qsfp_int_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int port_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + port_index = attr->index; + sprintf(buf, ""); + + if (port_index >= 1 && port_index <= 16) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_int_regs[port_index][0]); + } + else if (port_index >= 17 && port_index <= 32) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_int_regs[port_index][0]); + } + + if (status & qsfp_int_regs[port_index][1]) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_quter_int_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int quter_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + quter_index = attr->index; + sprintf(buf, ""); + + if (quter_index >= 1 && quter_index <= 2) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_quter_int_regs[quter_index][0]); + } + else if (quter_index >= 3 && quter_index <= 4) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_quter_int_regs[quter_index][0]); + } + + if (status & qsfp_quter_int_regs[quter_index][1]) + { + sprintf(buf, "%s%d\n", buf, NORMAL); + } + else + { + sprintf(buf, "%s%d\n", buf, ABNORMAL); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_quter_int_mask_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int quter_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + quter_index = attr->index; + sprintf(buf, ""); + + if (quter_index >= 1 && quter_index <= 2) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_quter_int_mask_regs[quter_index][0]); + } + else if (quter_index >= 3 && quter_index <= 4) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_quter_int_mask_regs[quter_index][0]); + } + + if (status & qsfp_quter_int_mask_regs[quter_index][1]) + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_quter_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int result = 0; + int input = 0; + int quter_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client); + struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client); + struct i2c_client *target_client = NULL; + + quter_index = attr->index; + input = simple_strtol(buf, NULL, 10); + mutex_lock(&Netberg_CPLD_31_data->update_lock); + mutex_lock(&Netberg_CPLD_32_data->update_lock); + + if (quter_index >= 1 && quter_index <= 2) + { + target_client = Netberg_CPLD_31_client; + + } + else if (quter_index >= 3 && quter_index <= 4) + { + target_client = Netberg_CPLD_32_client; + } + + status = i2c_smbus_read_byte_data(target_client, qsfp_quter_int_mask_regs[quter_index][0]); + if( input == DISABLE) + { + status |= qsfp_quter_int_mask_regs[quter_index][1]; + result = i2c_smbus_write_byte_data(target_client, qsfp_quter_int_mask_regs[quter_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_quter_int_mask_set ON FAILED!\n"); + } + } + else if( input == ENABLE) + { + status &= ~(qsfp_quter_int_mask_regs[quter_index][1]); + result = i2c_smbus_write_byte_data(target_client, qsfp_quter_int_mask_regs[quter_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_quter_int_mask_set OFF FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "ERROR: qsfp_quter_int_mask_set WRONG VALUE\n"); + } + + mutex_unlock(&Netberg_CPLD_31_data->update_lock); + mutex_unlock(&Netberg_CPLD_32_data->update_lock); + + return count; +} + +ssize_t qsfp_modprs_int_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int quter_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + quter_index = attr->index; + sprintf(buf, ""); + + if (quter_index >= 1 && quter_index <= 2) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_modprs_int_regs[quter_index][0]); + } + else if (quter_index >= 3 && quter_index <= 4) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_modprs_int_regs[quter_index][0]); + } + + if (status & qsfp_modprs_int_regs[quter_index][1]) + { + sprintf(buf, "%s%d\n", buf, NORMAL); + } + else + { + sprintf(buf, "%s%d\n", buf, ABNORMAL); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_modprs_int_mask_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + int quter_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + quter_index = attr->index; + sprintf(buf, ""); + + if (quter_index >= 1 && quter_index <= 2) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, qsfp_modprs_int_mask_regs[quter_index][0]); + } + else if (quter_index >= 3 && quter_index <= 4) + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, qsfp_modprs_int_mask_regs[quter_index][0]); + } + + if (status & qsfp_modprs_int_mask_regs[quter_index][1]) + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t qsfp_modprs_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int result = 0; + int input = 0; + int quter_index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *Netberg_CPLD_31_data = i2c_get_clientdata(Netberg_CPLD_31_client); + struct Netberg_i2c_data *Netberg_CPLD_32_data = i2c_get_clientdata(Netberg_CPLD_32_client); + struct i2c_client *target_client = NULL; + + quter_index = attr->index; + input = simple_strtol(buf, NULL, 10); + mutex_lock(&Netberg_CPLD_31_data->update_lock); + mutex_lock(&Netberg_CPLD_32_data->update_lock); + + if (quter_index >= 1 && quter_index <= 2) + { + target_client = Netberg_CPLD_31_client; + + } + else if (quter_index >= 3 && quter_index <= 4) + { + target_client = Netberg_CPLD_32_client; + } + + status = i2c_smbus_read_byte_data(target_client, qsfp_modprs_int_mask_regs[quter_index][0]); + if( input == DISABLE) + { + status |= qsfp_modprs_int_mask_regs[quter_index][1]; + result = i2c_smbus_write_byte_data(target_client, qsfp_modprs_int_mask_regs[quter_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_modprs_int_mask_set ON FAILED!\n"); + } + } + else if( input == ENABLE) + { + status &= ~(qsfp_modprs_int_mask_regs[quter_index][1]); + result = i2c_smbus_write_byte_data(target_client, qsfp_modprs_int_mask_regs[quter_index][0], status); + if (result < 0) + { + printk(KERN_ALERT "ERROR: qsfp_modprs_int_mask_set OFF FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "ERROR: qsfp_modprs_int_mask_set WRONG VALUE\n"); + } + + mutex_unlock(&Netberg_CPLD_31_data->update_lock); + mutex_unlock(&Netberg_CPLD_32_data->update_lock); + + return count; +} +/* end of implement i2c_function */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.h new file mode 100644 index 0000000000..a1deb8f3d7 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-qsfp.h @@ -0,0 +1,187 @@ +/* register offset define */ +#define QSFP_FRONT_LOW_POWER_REG 0x60 +#define QSFP_REAR_LOW_POWER_REG 0x61 +#define QSFP_FRONT_RESET_REG 0x70 +#define QSFP_REAR_RESET_REG 0x71 +#define QSFP_FRONT_PRESENT_REG 0x80 +#define QSFP_REAR_PRESENT_REG 0x81 +#define QSFP_FRONT_INT_REG 0x90 +#define QSFP_REAR_INT_REG 0x91 +#define QSFP_RESET 1 + +unsigned char qsfp_low_power_regs[33][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0x60, 0x01}, + {0x60, 0x02}, + {0x60, 0x04}, + {0x60, 0x08}, + {0x60, 0x10}, + {0x60, 0x20}, + {0x60, 0x40}, + {0x60, 0x80}, + {0x61, 0x01}, + {0x61, 0x02}, + {0x61, 0x04}, + {0x61, 0x08}, + {0x61, 0x10}, + {0x61, 0x20}, + {0x61, 0x40}, + {0x61, 0x80}, + {0x60, 0x01}, + {0x60, 0x02}, + {0x60, 0x04}, + {0x60, 0x08}, + {0x60, 0x10}, + {0x60, 0x20}, + {0x60, 0x40}, + {0x60, 0x80}, + {0x61, 0x01}, + {0x61, 0x02}, + {0x61, 0x04}, + {0x61, 0x08}, + {0x61, 0x10}, + {0x61, 0x20}, + {0x61, 0x40}, + {0x61, 0x80} +}; + +unsigned char qsfp_reset_regs[33][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0x70, 0x01}, + {0x70, 0x02}, + {0x70, 0x04}, + {0x70, 0x08}, + {0x70, 0x10}, + {0x70, 0x20}, + {0x70, 0x40}, + {0x70, 0x80}, + {0x71, 0x01}, + {0x71, 0x02}, + {0x71, 0x04}, + {0x71, 0x08}, + {0x71, 0x10}, + {0x71, 0x20}, + {0x71, 0x40}, + {0x71, 0x80}, + {0x70, 0x01}, + {0x70, 0x02}, + {0x70, 0x04}, + {0x70, 0x08}, + {0x70, 0x10}, + {0x70, 0x20}, + {0x70, 0x40}, + {0x70, 0x80}, + {0x71, 0x01}, + {0x71, 0x02}, + {0x71, 0x04}, + {0x71, 0x08}, + {0x71, 0x10}, + {0x71, 0x20}, + {0x71, 0x40}, + {0x71, 0x80} +}; + +unsigned char qsfp_present_regs[33][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0x80, 0x01}, + {0x80, 0x02}, + {0x80, 0x04}, + {0x80, 0x08}, + {0x80, 0x10}, + {0x80, 0x20}, + {0x80, 0x40}, + {0x80, 0x80}, + {0x81, 0x01}, + {0x81, 0x02}, + {0x81, 0x04}, + {0x81, 0x08}, + {0x81, 0x10}, + {0x81, 0x20}, + {0x81, 0x40}, + {0x81, 0x80}, + {0x80, 0x01}, + {0x80, 0x02}, + {0x80, 0x04}, + {0x80, 0x08}, + {0x80, 0x10}, + {0x80, 0x20}, + {0x80, 0x40}, + {0x80, 0x80}, + {0x81, 0x01}, + {0x81, 0x02}, + {0x81, 0x04}, + {0x81, 0x08}, + {0x81, 0x10}, + {0x81, 0x20}, + {0x81, 0x40}, + {0x81, 0x80} +}; + +unsigned char qsfp_int_regs[33][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0x90, 0x01}, + {0x90, 0x02}, + {0x90, 0x04}, + {0x90, 0x08}, + {0x90, 0x10}, + {0x90, 0x20}, + {0x90, 0x40}, + {0x90, 0x80}, + {0x91, 0x01}, + {0x91, 0x02}, + {0x91, 0x04}, + {0x91, 0x08}, + {0x91, 0x10}, + {0x91, 0x20}, + {0x91, 0x40}, + {0x91, 0x80}, + {0x90, 0x01}, + {0x90, 0x02}, + {0x90, 0x04}, + {0x90, 0x08}, + {0x90, 0x10}, + {0x90, 0x20}, + {0x90, 0x40}, + {0x90, 0x80}, + {0x91, 0x01}, + {0x91, 0x02}, + {0x91, 0x04}, + {0x91, 0x08}, + {0x91, 0x10}, + {0x91, 0x20}, + {0x91, 0x40}, + {0x91, 0x80} +}; + +unsigned char qsfp_quter_int_regs[5][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0xd0, 0x04}, + {0xd0, 0x08}, + {0xd0, 0x04}, + {0xd0, 0x08} +}; + +unsigned char qsfp_quter_int_mask_regs[5][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0xd1, 0x04}, + {0xd1, 0x08}, + {0xd1, 0x04}, + {0xd1, 0x08} +}; + +unsigned char qsfp_modprs_int_regs[5][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0xd0, 0x01}, + {0xd0, 0x02}, + {0xd0, 0x01}, + {0xd0, 0x02} +}; + +unsigned char qsfp_modprs_int_mask_regs[5][2] = { + {0x00, 0x00}, //cpld offset, bit mask + {0xd1, 0x01}, + {0xd1, 0x02}, + {0xd1, 0x01}, + {0xd1, 0x02} +}; +/* end of register offset define */ \ No newline at end of file diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.c new file mode 100644 index 0000000000..6ee287b9ef --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.c @@ -0,0 +1,864 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" +#include "x86-64-netberg-aurora-715-sys.h" + +/* extern i2c_client */ +extern struct i2c_client *Netberg_CPLD_30_client; //0x30 for SYS CPLD +extern struct i2c_client *Netberg_CPLD_31_client; //0x31 for Port 01-16 +extern struct i2c_client *Netberg_CPLD_32_client; //0x32 for Port 17-32 +extern struct i2c_client *Netberg_CPLD_23_client; //0x23 for Fan CPLD +extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave +extern struct i2c_client *Netberg_EEPROM_56_client; //0x56 for EEPROM slave +/* end of extern i2c_client */ + +/* implement i2c_function */ +ssize_t cpld_hw_ver_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + switch (attr->index) + { + case 23: + if( bmc_enable() == ENABLE) + { + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, 0xff); + } + else + { + status = i2c_smbus_read_byte_data(Netberg_CPLD_23_client, CPLD_VER_REG); + } + case 30: + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, CPLD_VER_REG); + case 31: + status = i2c_smbus_read_byte_data(Netberg_CPLD_31_client, CPLD_VER_REG); + case 32: + status = i2c_smbus_read_byte_data(Netberg_CPLD_32_client, CPLD_VER_REG); + } + if(status < 0) + { + mutex_unlock(&data->update_lock); + return status; + } + else + { + mutex_unlock(&data->update_lock); + sprintf(buf, "%s0x%x\n", buf, status); + } + return sprintf(buf, "%s\n", buf); +} + +ssize_t wdt_enable_get(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == WDT_EN) + { + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, WDT_EN_REG) & BIT_4_MASK) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} + +ssize_t wdt_enable_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, WDT_EN_REG); + if (attr->index == WDT_EN) + { + input = simple_strtol(buf, NULL, 10); + if (input == ENABLE) + { + value = status | WDT_EN_ENABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, WDT_EN_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: wdt_enable_set FAILED!\n"); + } + } + else if (input == DISABLE) + { + value = status & WDT_EN_DISABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, WDT_EN_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: wdt_enable_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "wdt_enable_set wrong Value\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} + +ssize_t eeprom_wp_get(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == EEPROM_WP) + { + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG) & BIT_2_MASK) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} + +ssize_t eeprom_wp_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG); + if (attr->index == EEPROM_WP) + { + input = simple_strtol(buf, NULL, 10); + if (input == ENABLE) + { + value = status | EEPROM_WP_ENABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: eeprom_wp_set FAILED!\n"); + } + } + else if (input == DISABLE) + { + value = status & EEPROM_WP_DISABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, EEPROM_WP_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: eeprom_wp_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "eeprom_wp_set wrong Value\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} + +static void net_eeprom_update_client(struct i2c_client *client, u8 slice) +{ + struct eeprom_data *data = i2c_get_clientdata(client); + int i, j; + int ret; + int addr; + + + mutex_lock(&data->update_lock); + + if (!(data->valid & (1 << slice)) || + time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { + dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); + + addr = slice << SLICE_BITS; + + ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF); + /* select the eeprom address */ + if (ret < 0) { + dev_err(&client->dev, "address set failed\n"); + goto exit; + } + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { + goto exit; + } + + for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { + for (j = i; j < (i+SLICE_SIZE); j++) { + int res; + + res = i2c_smbus_read_byte(client); + if (res < 0) { + goto exit; + } + + data->data[j] = res & 0xFF; + } + } + + data->last_updated[slice] = jiffies; + data->valid |= (1 << slice); + } + +exit: + mutex_unlock(&data->update_lock); +} + + +ssize_t net_eeprom_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + /* struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); */ + struct eeprom_data *data = i2c_get_clientdata(Netberg_EEPROM_56_client); + u8 slice; + + + if (off > EEPROM_SIZE) { + return 0; + } + if (off + count > EEPROM_SIZE) { + count = EEPROM_SIZE - off; + } + if (count == 0) { + return 0; + } + + /* Only refresh slices which contain requested bytes */ + for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { + net_eeprom_update_client(Netberg_EEPROM_56_client, slice); + } + + memcpy(buf, &data->data[off], count); + + return count; +} + +ssize_t usb_enable_get(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == USB_EN) + { + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, USB_EN_REG) & BIT_2_MASK) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} + +ssize_t usb_enable_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, USB_EN_REG); + if (attr->index == USB_EN) + { + input = simple_strtol(buf, NULL, 10); + if (input == ENABLE) + { + value = status | USB_EN_ENABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, USB_EN_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: usb_enable_set FAILED!\n"); + } + } + else if (input == DISABLE) + { + value = status & USB_EN_DISABLE; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, USB_EN_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: usb_enable_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "usb_enable_set wrong Value\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} + +ssize_t reset_mac_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, MAC_RESET_REG); + if (attr->index == RESET) + { + input = simple_strtol(buf, NULL, 10); + if (input == MAC_RESET) + { + value = MAC_RESET; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, MAC_RESET_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: reset_mac_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "reset_mac_set wrong Value\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} + +ssize_t shutdown_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SHUTDOWN_REG); + if (attr->index == SHUTDOWN_SET) + { + input = simple_strtol(buf, NULL, 10); + if (input == SHUTDOWN) + { + value = status | SHUTDOWN; + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, SHUTDOWN_REG, value); + if (result < 0) + { + printk(KERN_ALERT "ERROR: shutdown_set FAILED!\n"); + } + } + else + { + printk(KERN_ALERT "shutdown_set wrong Value\n"); + } + } + mutex_unlock(&data->update_lock); + return count; +} + +ssize_t bmc_enable_get(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + if (attr->index == BMC_PRESENT) + { + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, BMC_EN_REG) & BIT_0_MASK) + { + sprintf(buf, "%s%d\n", buf, ENABLE); + } + else + { + sprintf(buf, "%s%d\n", buf, DISABLE); + } + } + mutex_unlock(&data->update_lock); + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_int_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int result = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + switch (attr->index) + { + case TEMP_R_B_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_0_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case TEMP_L_B_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_1_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case TEMP_L_T_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_2_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case TEMP_R_T_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_REG) & BIT_3_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + } + mutex_unlock(&data->update_lock); + sprintf(buf, "%s%d\n", buf, result); + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_int_mask_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int result = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + switch (attr->index) + { + case TEMP_R_B_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_0_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case TEMP_L_B_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_1_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case TEMP_L_T_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_2_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case TEMP_R_T_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG) & BIT_3_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + } + mutex_unlock(&data->update_lock); + sprintf(buf, "%s%d\n", buf, result); + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG); + + input = simple_strtol(buf, NULL, 10); + switch (attr->index) + { + case TEMP_R_B_INT_MASK: + if (input == ENABLE) + { + value = status | 0x01; + } + else if (input == DISABLE) + { + value = status & 0xfe; + } + else + { + printk(KERN_ALERT "themal_int_mask_set wrong Value\n"); + return count; + } + break; + case TEMP_L_B_INT_MASK: + if (input == ENABLE) + { + value = status | 0x02; + } + else if (input == DISABLE) + { + value = status & 0xfd; + } + else + { + printk(KERN_ALERT "themal_int_mask_set wrong Value\n"); + return count; + } + break; + case TEMP_L_T_INT_MASK: + if (input == ENABLE) + { + value = status | 0x04; + } + else if (input == DISABLE) + { + value = status & 0xfb; + } + else + { + printk(KERN_ALERT "themal_int_mask_set wrong Value\n"); + return count; + } + break; + case TEMP_R_T_INT_MASK: + if (input == ENABLE) + { + value = status | 0x08; + } + else if (input == DISABLE) + { + value = status & 0xf7; + } + else + { + printk(KERN_ALERT "themal_int_mask_set wrong Value\n"); + return count; + } + break; + } + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, THERMAL_INT_MASK_REG, value); + mutex_unlock(&data->update_lock); + return count; +} + +ssize_t sys_int_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int result = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + switch (attr->index) + { + case CPLD_FP_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_2_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case CPLD_RP_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_3_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case CPLD_FAN_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_4_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case CPLD_PSU_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_5_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case THERMAL_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_6_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case USB_INT: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_REG) & BIT_7_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + } + mutex_unlock(&data->update_lock); + sprintf(buf, "%s%d\n", buf, result); + return sprintf(buf, "%s\n", buf); +} + +ssize_t sys_int_mask_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int result = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + sprintf(buf, ""); + switch (attr->index) + { + case CPLD_FP_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_2_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case CPLD_RP_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_3_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case CPLD_FAN_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_4_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case CPLD_PSU_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_5_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case THERMAL_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_6_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + case USB_INT_MASK: + if (i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG) & BIT_7_MASK) + { + result = ENABLE; + } + else + { + result = DISABLE; + } + break; + } + mutex_unlock(&data->update_lock); + sprintf(buf, "%s%d\n", buf, result); + return sprintf(buf, "%s\n", buf); +} + +ssize_t sys_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count) +{ + int status = -EPERM; + int value = -EPERM; + int result = -EPERM; + int input; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct Netberg_i2c_data *data = i2c_get_clientdata(Netberg_CPLD_30_client); + + mutex_lock(&data->update_lock); + status = i2c_smbus_read_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG); + + input = simple_strtol(buf, NULL, 10); + switch (attr->index) + { + case CPLD_FP_INT_MASK: + if (input == ENABLE) + { + value = status | 0x02; + } + else if (input == DISABLE) + { + value = status & 0xfd; + } + else + { + printk(KERN_ALERT "sys_int_mask_set wrong Value\n"); + return count; + } + break; + case CPLD_RP_INT_MASK: + if (input == ENABLE) + { + value = status | 0x04; + } + else if (input == DISABLE) + { + value = status & 0xfb; + } + else + { + printk(KERN_ALERT "sys_int_mask_set wrong Value\n"); + return count; + } + break; + case CPLD_FAN_INT_MASK: + if (input == ENABLE) + { + value = status | 0x08; + } + else if (input == DISABLE) + { + value = status & 0xf7; + } + else + { + printk(KERN_ALERT "sys_int_mask_set wrong Value\n"); + return count; + } + break; + case CPLD_PSU_INT_MASK: + if (input == ENABLE) + { + value = status | 0x10; + } + else if (input == DISABLE) + { + value = status & 0xef; + } + else + { + printk(KERN_ALERT "sys_int_mask_set wrong Value\n"); + return count; + } + break; + case THERMAL_INT_MASK: + if (input == ENABLE) + { + value = status | 0x20; + } + else if (input == DISABLE) + { + value = status & 0xdf; + } + else + { + printk(KERN_ALERT "sys_int_mask_set wrong Value\n"); + return count; + } + break; + case USB_INT_MASK: + if (input == ENABLE) + { + value = status | 0x40; + } + else if (input == DISABLE) + { + value = status & 0xbf; + } + else + { + printk(KERN_ALERT "sys_int_mask_set wrong Value\n"); + return count; + } + break; + } + result = i2c_smbus_write_byte_data(Netberg_CPLD_30_client, SYS_INT_MASK_REG, value); + mutex_unlock(&data->update_lock); + return count; +} +/* end of implement i2c_function */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.h new file mode 100644 index 0000000000..0126b7dbbc --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-sys.h @@ -0,0 +1,23 @@ +/* register offset define */ +#define CPLD_VER_REG 0x20 +#define WDT_EN_REG 0xa0 +#define WDT_EN_ENABLE 0x10 +#define WDT_EN_DISABLE 0xef +#define EEPROM_WP_REG 0xa0 +#define EEPROM_WP_ENABLE 0x04 +#define EEPROM_WP_DISABLE 0xfB +#define USB_EN_REG 0xa0 +#define USB_EN_ENABLE 0x02 +#define USB_EN_DISABLE 0xfD +#define MAC_RESET_REG 0xa1 +#define MAC_RESET 0x00 +#define SHUTDOWN_REG 0xa1 +#define SHUTDOWN 0x10 +#define BMC_EN_REG 0xa4 +#define BMC_EN_ENABLE 0x01 +#define BMC_EN_DISABLE 0x00 +#define THERMAL_INT_REG 0xc0 +#define THERMAL_INT_MASK_REG 0xc1 +#define SYS_INT_REG 0xd0 +#define SYS_INT_MASK_REG 0xd1 +/* end of register offset define */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.c b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.c new file mode 100644 index 0000000000..8e288f4aa3 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.c @@ -0,0 +1,271 @@ +/* An hwmon driver for Netberg Aurora 715 Innovium i2c Module */ +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#include "x86-64-netberg-aurora-715.h" +#include "x86-64-netberg-aurora-715-common.h" +#include "x86-64-netberg-aurora-715-thermal.h" + +/* extern i2c_client */ +extern struct i2c_client *Netberg_BMC_14_client; //0x14 for BMC slave +/* end of extern i2c_client */ + +/* implement i2c_function */ +ssize_t themal_temp_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + sprintf(buf, ""); + + if( bmc_enable() == ENABLE) + { + switch (attr->index) + { + case TEMP_R_B_F: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_REG); + break; + case TEMP_R_B_B: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_REG); + break; + case TEMP_L_B_F: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_REG); + break; + case TEMP_L_B_B: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_REG); + break; + case TEMP_R_T_F: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_REG); + break; + case TEMP_R_T_B: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_REG); + break; + case TEMP_L_T_F: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_REG); + break; + case TEMP_L_T_B: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_REG); + break; + } + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_temp_max_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + sprintf(buf, ""); + + if( bmc_enable() == ENABLE) + { + switch (attr->index) + { + case TEMP_R_B_F_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_MAX_REG); + break; + case TEMP_L_B_F_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_MAX_REG); + break; + case TEMP_R_T_F_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_MAX_REG); + break; + case TEMP_L_T_F_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_MAX_REG); + break; + case TEMP_R_B_B_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_MAX_REG); + break; + case TEMP_L_B_B_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_MAX_REG); + break; + case TEMP_R_T_B_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_MAX_REG); + break; + case TEMP_L_T_B_MAX: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_MAX_REG); + break; + } + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_temp_min_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + sprintf(buf, ""); + + if( bmc_enable() == ENABLE) + { + switch (attr->index) + { + case TEMP_R_B_F_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_MIN_REG); + break; + case TEMP_L_B_F_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_MIN_REG); + break; + case TEMP_R_T_F_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_MIN_REG); + break; + case TEMP_L_T_F_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_MIN_REG); + break; + case TEMP_R_B_B_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_MIN_REG); + break; + case TEMP_L_B_B_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_MIN_REG); + break; + case TEMP_R_T_B_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_MIN_REG); + break; + case TEMP_L_T_B_MIN: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_MIN_REG); + break; + } + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_temp_crit_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + sprintf(buf, ""); + + if( bmc_enable() == ENABLE) + { + switch (attr->index) + { + case TEMP_R_B_F_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_CRIT_REG); + break; + case TEMP_L_B_F_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_CRIT_REG); + break; + case TEMP_R_T_F_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_CRIT_REG); + break; + case TEMP_L_T_F_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_CRIT_REG); + break; + case TEMP_R_B_B_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_CRIT_REG); + break; + case TEMP_L_B_B_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_CRIT_REG); + break; + case TEMP_R_T_B_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_CRIT_REG); + break; + case TEMP_L_T_B_CRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_CRIT_REG); + break; + } + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + + return sprintf(buf, "%s\n", buf); +} + +ssize_t themal_temp_lcrit_get(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = -EPERM; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + sprintf(buf, ""); + + if( bmc_enable() == ENABLE) + { + switch (attr->index) + { + case TEMP_R_B_F_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_F_LCRIT_REG); + break; + case TEMP_L_B_F_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_F_LCRIT_REG); + break; + case TEMP_R_T_F_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_F_LCRIT_REG); + break; + case TEMP_L_T_F_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_F_LCRIT_REG); + break; + case TEMP_R_B_B_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_B_B_LCRIT_REG); + break; + case TEMP_L_B_B_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_B_B_LCRIT_REG); + break; + case TEMP_R_T_B_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_R_T_B_LCRIT_REG); + break; + case TEMP_L_T_B_LCRIT: + status = i2c_smbus_read_byte_data(Netberg_BMC_14_client, TEMP_L_T_B_LCRIT_REG); + break; + } + if(status == 0xff || status < 0) + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + else + { + sprintf(buf, "%s%d\n", buf, (read_8bit_temp((status & 0x80), status))*1000); + } + } + else + { + sprintf(buf, "%sAccess BMC module FAILED\n", buf); + } + + return sprintf(buf, "%s\n", buf); +} +/* end of implement i2c_function */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.h new file mode 100644 index 0000000000..54b95a3869 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715-thermal.h @@ -0,0 +1,45 @@ +/* register offset define */ +#define TEMP_R_B_F_REG 0x10 +#define TEMP_R_B_B_REG 0x11 +#define TEMP_R_B_F_MAX_REG 0x12 +#define TEMP_R_B_F_MIN_REG 0x13 +#define TEMP_R_B_F_CRIT_REG 0x14 +#define TEMP_R_B_F_LCRIT_REG 0x15 +#define TEMP_R_B_B_MAX_REG 0x16 +#define TEMP_R_B_B_MIN_REG 0x17 +#define TEMP_R_B_B_CRIT_REG 0x18 +#define TEMP_R_B_B_LCRIT_REG 0x19 + +#define TEMP_L_B_F_REG 0x20 +#define TEMP_L_B_B_REG 0x21 +#define TEMP_L_B_F_MAX_REG 0x22 +#define TEMP_L_B_F_MIN_REG 0x23 +#define TEMP_L_B_F_CRIT_REG 0x24 +#define TEMP_L_B_F_LCRIT_REG 0x25 +#define TEMP_L_B_B_MAX_REG 0x26 +#define TEMP_L_B_B_MIN_REG 0x27 +#define TEMP_L_B_B_CRIT_REG 0x28 +#define TEMP_L_B_B_LCRIT_REG 0x29 + +#define TEMP_R_T_F_REG 0x30 +#define TEMP_R_T_B_REG 0x31 +#define TEMP_R_T_F_MAX_REG 0x32 +#define TEMP_R_T_F_MIN_REG 0x33 +#define TEMP_R_T_F_CRIT_REG 0x34 +#define TEMP_R_T_F_LCRIT_REG 0x35 +#define TEMP_R_T_B_MAX_REG 0x36 +#define TEMP_R_T_B_MIN_REG 0x37 +#define TEMP_R_T_B_CRIT_REG 0x38 +#define TEMP_R_T_B_LCRIT_REG 0x39 + +#define TEMP_L_T_F_REG 0x40 +#define TEMP_L_T_B_REG 0x41 +#define TEMP_L_T_F_MAX_REG 0x42 +#define TEMP_L_T_F_MIN_REG 0x43 +#define TEMP_L_T_F_CRIT_REG 0x44 +#define TEMP_L_T_F_LCRIT_REG 0x45 +#define TEMP_L_T_B_MAX_REG 0x46 +#define TEMP_L_T_B_MIN_REG 0x47 +#define TEMP_L_T_B_CRIT_REG 0x48 +#define TEMP_L_T_B_LCRIT_REG 0x49 +/* end of register offset define */ \ No newline at end of file diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715.h b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715.h new file mode 100644 index 0000000000..d4c1e6daba --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/modules/x86-64-netberg-aurora-715.h @@ -0,0 +1,1069 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_VERSION "1.0.1" + +#define EEPROM_SIZE 0x100 +#define SLICE_BITS (6) +#define SLICE_SIZE (1 << SLICE_BITS) +#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) + +struct i2c_adap { + int nr; + char *name; + const char *funcs; + const char *algo; +}; + +struct eeprom_data { + struct mutex update_lock; + u8 valid; /* bitfield, bit!=0 if slice is valid */ + unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ + u8 data[EEPROM_SIZE]; /* Register values */ +}; + +struct i2c_adap *gather_i2c_busses(void); +void free_adapters(struct i2c_adap *adapters); + +/* compiler conditional */ +/* end of compiler conditional */ + +/* Function Declaration */ +/* i2c-0 */ +ssize_t cpld_hw_ver_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t wdt_enable_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t wdt_enable_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t eeprom_wp_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t eeprom_wp_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); + +ssize_t net_eeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count); + +ssize_t usb_enable_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t usb_enable_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t reset_mac_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t shutdown_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t bmc_enable_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t led_ctrl_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t led_ctrl_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t led_fiber_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t led_fiber_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t themal_int_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t themal_int_mask_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t themal_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t sys_int_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t sys_int_mask_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t sys_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t themal_temp_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t themal_temp_max_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t themal_temp_min_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t themal_temp_crit_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t themal_temp_lcrit_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t fan_ctrl_mode_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t fan_ctrl_rpm_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t fan_status_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t fan_present_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t fan_power_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t fan_rpm_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_status_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_present_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_vin_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_iin_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_vout_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_iout_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_temp_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_fan_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_pout_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_pin_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_mfr_model_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_iout_max_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t psu_vmode_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t dc_vout_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t dc_iout_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t dc_pout_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_low_power_all_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_low_power_all_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t qsfp_low_power_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_low_power_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t qsfp_reset_all_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t qsfp_reset_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t qsfp_present_all_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_present_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_int_all_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_int_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_quter_int_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_quter_int_mask_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_quter_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +ssize_t qsfp_modprs_int_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_modprs_int_mask_get(struct device *dev, struct device_attribute *da, char *buf); +ssize_t qsfp_modprs_int_mask_set(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +/* end of Function Declaration */ + +/* struct i2c_data */ +struct Netberg_i2c_data +{ + struct device *hwmon_dev; + struct mutex update_lock; + char valid; + unsigned long last_updated; + u8 status; +}; + +/* struct i2c_sysfs_attributes */ +enum Netberg_i2c_sysfs_attributes +{ + CPLD_23_VER, + CPLD_30_VER, + CPLD_31_VER, + CPLD_32_VER, + WDT_EN, + EEPROM_WP, + USB_EN, + SHUTDOWN_SET, + RESET, + BMC_PRESENT, + LED_1, + LED_2, + LED_FLOW, + LED_SYS, + LED_FIBER, + TEMP_R_B_INT, + TEMP_L_B_INT, + TEMP_R_T_INT, + TEMP_L_T_INT, + TEMP_R_B_INT_MASK, + TEMP_L_B_INT_MASK, + TEMP_R_T_INT_MASK, + TEMP_L_T_INT_MASK, + CPLD_FP_INT, + CPLD_RP_INT, + CPLD_FAN_INT, + CPLD_PSU_INT, + THERMAL_INT, + USB_INT, + CPLD_FP_INT_MASK, + CPLD_RP_INT_MASK, + CPLD_FAN_INT_MASK, + CPLD_PSU_INT_MASK, + THERMAL_INT_MASK, + USB_INT_MASK, + TEMP_R_B_F, + TEMP_R_B_B, + TEMP_L_B_F, + TEMP_L_B_B, + TEMP_R_T_F, + TEMP_R_T_B, + TEMP_L_T_F, + TEMP_L_T_B, + TEMP_R_B_F_MAX, + TEMP_L_B_F_MAX, + TEMP_R_T_F_MAX, + TEMP_L_T_F_MAX, + TEMP_R_B_B_MAX, + TEMP_L_B_B_MAX, + TEMP_R_T_B_MAX, + TEMP_L_T_B_MAX, + TEMP_R_B_F_MIN, + TEMP_L_B_F_MIN, + TEMP_R_T_F_MIN, + TEMP_L_T_F_MIN, + TEMP_R_B_B_MIN, + TEMP_L_B_B_MIN, + TEMP_R_T_B_MIN, + TEMP_L_T_B_MIN, + TEMP_R_B_F_CRIT, + TEMP_L_B_F_CRIT, + TEMP_R_T_F_CRIT, + TEMP_L_T_F_CRIT, + TEMP_R_B_B_CRIT, + TEMP_L_B_B_CRIT, + TEMP_R_T_B_CRIT, + TEMP_L_T_B_CRIT, + TEMP_R_B_F_LCRIT, + TEMP_L_B_F_LCRIT, + TEMP_R_T_F_LCRIT, + TEMP_L_T_F_LCRIT, + TEMP_R_B_B_LCRIT, + TEMP_L_B_B_LCRIT, + TEMP_R_T_B_LCRIT, + TEMP_L_T_B_LCRIT, + FANCTRL_RPM, + FANCTRL_MODE, + FAN1_STAT, + FAN2_STAT, + FAN3_STAT, + FAN4_STAT, + FAN5_STAT, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN1_POWER, + FAN2_POWER, + FAN3_POWER, + FAN4_POWER, + FAN5_POWER, + FAN1_FRONT_RPM, + FAN2_FRONT_RPM, + FAN3_FRONT_RPM, + FAN4_FRONT_RPM, + FAN5_FRONT_RPM, + FAN1_REAR_RPM, + FAN2_REAR_RPM, + FAN3_REAR_RPM, + FAN4_REAR_RPM, + FAN5_REAR_RPM, + PSU1_GOOD, + PSU2_GOOD, + PSU1_PRNT, + PSU2_PRNT, + PSU1_VIN, + PSU1_IIN, + PSU1_VOUT, + PSU1_IOUT, + PSU1_TEMP, + PSU1_FAN_SPEED, + PSU1_POUT, + PSU1_PIN, + PSU1_MFR_MODEL, + PSU1_MFR_IOUT_MAX, + PSU1_VOMDE, + PSU2_VIN, + PSU2_IIN, + PSU2_VOUT, + PSU2_IOUT, + PSU2_TEMP, + PSU2_FAN_SPEED, + PSU2_POUT, + PSU2_PIN, + PSU2_MFR_MODEL, + PSU2_MFR_IOUT_MAX, + PSU2_VOMDE, + DC6E_P0_VOUT, + DC6E_P0_IOUT, + DC6E_P0_POUT, + DC6E_P1_VOUT, + DC6E_P1_IOUT, + DC6E_P1_POUT, + DC70_P0_VOUT, + DC70_P0_IOUT, + DC70_P0_POUT, + DC70_P1_VOUT, + DC70_P1_IOUT, + DC70_P1_POUT, + QSFP_LOW_POWER_ALL, + QSFP1_LOW_POWER, + QSFP2_LOW_POWER, + QSFP3_LOW_POWER, + QSFP4_LOW_POWER, + QSFP5_LOW_POWER, + QSFP6_LOW_POWER, + QSFP7_LOW_POWER, + QSFP8_LOW_POWER, + QSFP9_LOW_POWER, + QSFP10_LOW_POWER, + QSFP11_LOW_POWER, + QSFP12_LOW_POWER, + QSFP13_LOW_POWER, + QSFP14_LOW_POWER, + QSFP15_LOW_POWER, + QSFP16_LOW_POWER, + QSFP17_LOW_POWER, + QSFP18_LOW_POWER, + QSFP19_LOW_POWER, + QSFP20_LOW_POWER, + QSFP21_LOW_POWER, + QSFP22_LOW_POWER, + QSFP23_LOW_POWER, + QSFP24_LOW_POWER, + QSFP25_LOW_POWER, + QSFP26_LOW_POWER, + QSFP27_LOW_POWER, + QSFP28_LOW_POWER, + QSFP29_LOW_POWER, + QSFP30_LOW_POWER, + QSFP31_LOW_POWER, + QSFP32_LOW_POWER, + QSFP_RESET_ALL, + QSFP1_RESET, + QSFP2_RESET, + QSFP3_RESET, + QSFP4_RESET, + QSFP5_RESET, + QSFP6_RESET, + QSFP7_RESET, + QSFP8_RESET, + QSFP9_RESET, + QSFP10_RESET, + QSFP11_RESET, + QSFP12_RESET, + QSFP13_RESET, + QSFP14_RESET, + QSFP15_RESET, + QSFP16_RESET, + QSFP17_RESET, + QSFP18_RESET, + QSFP19_RESET, + QSFP20_RESET, + QSFP21_RESET, + QSFP22_RESET, + QSFP23_RESET, + QSFP24_RESET, + QSFP25_RESET, + QSFP26_RESET, + QSFP27_RESET, + QSFP28_RESET, + QSFP29_RESET, + QSFP30_RESET, + QSFP31_RESET, + QSFP32_RESET, + QSFP_PRESENT_ALL, + QSFP1_PRESENT, + QSFP2_PRESENT, + QSFP3_PRESENT, + QSFP4_PRESENT, + QSFP5_PRESENT, + QSFP6_PRESENT, + QSFP7_PRESENT, + QSFP8_PRESENT, + QSFP9_PRESENT, + QSFP10_PRESENT, + QSFP11_PRESENT, + QSFP12_PRESENT, + QSFP13_PRESENT, + QSFP14_PRESENT, + QSFP15_PRESENT, + QSFP16_PRESENT, + QSFP17_PRESENT, + QSFP18_PRESENT, + QSFP19_PRESENT, + QSFP20_PRESENT, + QSFP21_PRESENT, + QSFP22_PRESENT, + QSFP23_PRESENT, + QSFP24_PRESENT, + QSFP25_PRESENT, + QSFP26_PRESENT, + QSFP27_PRESENT, + QSFP28_PRESENT, + QSFP29_PRESENT, + QSFP30_PRESENT, + QSFP31_PRESENT, + QSFP32_PRESENT, + QSFP_INT_ALL, + QSFP1_INT, + QSFP2_INT, + QSFP3_INT, + QSFP4_INT, + QSFP5_INT, + QSFP6_INT, + QSFP7_INT, + QSFP8_INT, + QSFP9_INT, + QSFP10_INT, + QSFP11_INT, + QSFP12_INT, + QSFP13_INT, + QSFP14_INT, + QSFP15_INT, + QSFP16_INT, + QSFP17_INT, + QSFP18_INT, + QSFP19_INT, + QSFP20_INT, + QSFP21_INT, + QSFP22_INT, + QSFP23_INT, + QSFP24_INT, + QSFP25_INT, + QSFP26_INT, + QSFP27_INT, + QSFP28_INT, + QSFP29_INT, + QSFP30_INT, + QSFP31_INT, + QSFP32_INT, + QSFP1_4_INT, + QSFP2_4_INT, + QSFP3_4_INT, + QSFP4_4_INT, + QSFP1_4_MODPRS, + QSFP2_4_MODPRS, + QSFP3_4_MODPRS, + QSFP4_4_MODPRS, + QSFP1_4_INT_MASK, + QSFP2_4_INT_MASK, + QSFP3_4_INT_MASK, + QSFP4_4_INT_MASK, + QSFP1_4_MODPRS_MASK, + QSFP2_4_MODPRS_MASK, + QSFP3_4_MODPRS_MASK, + QSFP4_4_MODPRS_MASK +}; +/* end of struct i2c_sysfs_attributes */ + +/* sysfs attributes for SENSOR_DEVICE_ATTR */ +static SENSOR_DEVICE_ATTR(cpld_23_ver , S_IRUGO , cpld_hw_ver_get , NULL , 23); +static SENSOR_DEVICE_ATTR(cpld_30_ver , S_IRUGO , cpld_hw_ver_get , NULL , 30); +static SENSOR_DEVICE_ATTR(cpld_31_ver , S_IRUGO , cpld_hw_ver_get , NULL , 31); +static SENSOR_DEVICE_ATTR(cpld_32_ver , S_IRUGO , cpld_hw_ver_get , NULL , 32); +static SENSOR_DEVICE_ATTR(wdt_en , S_IRUGO | S_IWUSR , wdt_enable_get , wdt_enable_set , WDT_EN); +static SENSOR_DEVICE_ATTR(eeprom_wp , S_IRUGO | S_IWUSR , eeprom_wp_get , eeprom_wp_set , EEPROM_WP); +static SENSOR_DEVICE_ATTR(usb_en , S_IRUGO | S_IWUSR , usb_enable_get , usb_enable_set , USB_EN); +static SENSOR_DEVICE_ATTR(shutdown_set , S_IRUGO | S_IWUSR , NULL , shutdown_set , SHUTDOWN_SET); +static SENSOR_DEVICE_ATTR(reset , S_IRUGO | S_IWUSR , NULL , reset_mac_set , RESET); +static SENSOR_DEVICE_ATTR(bmc_present , S_IRUGO , bmc_enable_get , NULL , BMC_PRESENT); +static SENSOR_DEVICE_ATTR(led_1 , S_IRUGO | S_IWUSR , led_ctrl_get , led_ctrl_set , 4); +static SENSOR_DEVICE_ATTR(led_2 , S_IRUGO | S_IWUSR , led_ctrl_get , led_ctrl_set , 3); +static SENSOR_DEVICE_ATTR(led_flow , S_IRUGO | S_IWUSR , led_ctrl_get , led_ctrl_set , 2); +static SENSOR_DEVICE_ATTR(led_sys , S_IRUGO | S_IWUSR , led_ctrl_get , led_ctrl_set , 1); +static SENSOR_DEVICE_ATTR(led_fiber , S_IRUGO | S_IWUSR , led_fiber_get , led_fiber_set , LED_FIBER); +static SENSOR_DEVICE_ATTR(temp_r_b_int , S_IRUGO , themal_int_get , NULL , TEMP_R_B_INT); +static SENSOR_DEVICE_ATTR(temp_l_b_int , S_IRUGO , themal_int_get , NULL , TEMP_L_B_INT); +static SENSOR_DEVICE_ATTR(temp_r_t_int , S_IRUGO , themal_int_get , NULL , TEMP_R_T_INT); +static SENSOR_DEVICE_ATTR(temp_l_t_int , S_IRUGO , themal_int_get , NULL , TEMP_L_T_INT); +static SENSOR_DEVICE_ATTR(temp_r_b_int_mask , S_IRUGO | S_IWUSR , themal_int_mask_get , themal_int_mask_set , TEMP_R_B_INT_MASK); +static SENSOR_DEVICE_ATTR(temp_l_b_int_mask , S_IRUGO | S_IWUSR , themal_int_mask_get , themal_int_mask_set , TEMP_L_B_INT_MASK); +static SENSOR_DEVICE_ATTR(temp_r_t_int_mask , S_IRUGO | S_IWUSR , themal_int_mask_get , themal_int_mask_set , TEMP_R_T_INT_MASK); +static SENSOR_DEVICE_ATTR(temp_l_t_int_mask , S_IRUGO | S_IWUSR , themal_int_mask_get , themal_int_mask_set , TEMP_L_T_INT_MASK); +static SENSOR_DEVICE_ATTR(cpld_fp_int , S_IRUGO , sys_int_get , NULL , CPLD_FP_INT); +static SENSOR_DEVICE_ATTR(cpld_rp_int , S_IRUGO , sys_int_get , NULL , CPLD_RP_INT); +static SENSOR_DEVICE_ATTR(cpld_fan_int , S_IRUGO , sys_int_get , NULL , CPLD_FAN_INT); +static SENSOR_DEVICE_ATTR(cpld_psu_int , S_IRUGO , sys_int_get , NULL , CPLD_PSU_INT); +static SENSOR_DEVICE_ATTR(thermal_int , S_IRUGO , sys_int_get , NULL , THERMAL_INT); +static SENSOR_DEVICE_ATTR(usb_int , S_IRUGO , sys_int_get , NULL , USB_INT); +static SENSOR_DEVICE_ATTR(cpld_fp_int_mask , S_IRUGO | S_IWUSR , sys_int_mask_get , sys_int_mask_set , CPLD_FP_INT_MASK); +static SENSOR_DEVICE_ATTR(cpld_rp_int_mask , S_IRUGO | S_IWUSR , sys_int_mask_get , sys_int_mask_set , CPLD_RP_INT_MASK); +static SENSOR_DEVICE_ATTR(cpld_fan_int_mask , S_IRUGO | S_IWUSR , sys_int_mask_get , sys_int_mask_set , CPLD_FAN_INT_MASK); +static SENSOR_DEVICE_ATTR(cpld_psu_int_mask , S_IRUGO | S_IWUSR , sys_int_mask_get , sys_int_mask_set , CPLD_PSU_INT_MASK); +static SENSOR_DEVICE_ATTR(thermal_int_mask , S_IRUGO | S_IWUSR , sys_int_mask_get , sys_int_mask_set , THERMAL_INT_MASK); +static SENSOR_DEVICE_ATTR(usb_int_mask , S_IRUGO | S_IWUSR , sys_int_mask_get , sys_int_mask_set , USB_INT_MASK); +static SENSOR_DEVICE_ATTR(temp_r_b_f , S_IRUGO , themal_temp_get , NULL , TEMP_R_B_F); +static SENSOR_DEVICE_ATTR(temp_r_b_b , S_IRUGO , themal_temp_get , NULL , TEMP_R_B_B); +static SENSOR_DEVICE_ATTR(temp_l_b_f , S_IRUGO , themal_temp_get , NULL , TEMP_L_B_F); +static SENSOR_DEVICE_ATTR(temp_l_b_b , S_IRUGO , themal_temp_get , NULL , TEMP_L_B_B); +static SENSOR_DEVICE_ATTR(temp_r_t_f , S_IRUGO , themal_temp_get , NULL , TEMP_R_T_F); +static SENSOR_DEVICE_ATTR(temp_r_t_b , S_IRUGO , themal_temp_get , NULL , TEMP_R_T_B); +static SENSOR_DEVICE_ATTR(temp_l_t_f , S_IRUGO , themal_temp_get , NULL , TEMP_L_T_F); +static SENSOR_DEVICE_ATTR(temp_l_t_b , S_IRUGO , themal_temp_get , NULL , TEMP_L_T_B); +static SENSOR_DEVICE_ATTR(temp_r_b_f_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_R_B_F_MAX); +static SENSOR_DEVICE_ATTR(temp_l_b_f_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_L_B_F_MAX); +static SENSOR_DEVICE_ATTR(temp_r_t_f_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_R_T_F_MAX); +static SENSOR_DEVICE_ATTR(temp_l_t_f_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_L_T_F_MAX); +static SENSOR_DEVICE_ATTR(temp_r_b_b_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_R_B_B_MAX); +static SENSOR_DEVICE_ATTR(temp_l_b_b_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_L_B_B_MAX); +static SENSOR_DEVICE_ATTR(temp_r_t_b_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_R_T_B_MAX); +static SENSOR_DEVICE_ATTR(temp_l_t_b_max , S_IRUGO , themal_temp_max_get , NULL , TEMP_L_T_B_MAX); +static SENSOR_DEVICE_ATTR(temp_r_b_f_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_R_B_F_MIN); +static SENSOR_DEVICE_ATTR(temp_l_b_f_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_L_B_F_MIN); +static SENSOR_DEVICE_ATTR(temp_r_t_f_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_R_T_F_MIN); +static SENSOR_DEVICE_ATTR(temp_l_t_f_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_L_T_F_MIN); +static SENSOR_DEVICE_ATTR(temp_r_b_b_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_R_B_B_MIN); +static SENSOR_DEVICE_ATTR(temp_l_b_b_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_L_B_B_MIN); +static SENSOR_DEVICE_ATTR(temp_r_t_b_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_R_T_B_MIN); +static SENSOR_DEVICE_ATTR(temp_l_t_b_min , S_IRUGO , themal_temp_min_get , NULL , TEMP_L_T_B_MIN); +static SENSOR_DEVICE_ATTR(temp_r_b_f_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_R_B_F_CRIT); +static SENSOR_DEVICE_ATTR(temp_l_b_f_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_L_B_F_CRIT); +static SENSOR_DEVICE_ATTR(temp_r_t_f_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_R_T_F_CRIT); +static SENSOR_DEVICE_ATTR(temp_l_t_f_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_L_T_F_CRIT); +static SENSOR_DEVICE_ATTR(temp_r_b_b_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_R_B_B_CRIT); +static SENSOR_DEVICE_ATTR(temp_l_b_b_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_L_B_B_CRIT); +static SENSOR_DEVICE_ATTR(temp_r_t_b_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_R_T_B_CRIT); +static SENSOR_DEVICE_ATTR(temp_l_t_b_crit , S_IRUGO , themal_temp_crit_get , NULL , TEMP_L_T_B_CRIT); +static SENSOR_DEVICE_ATTR(temp_r_b_f_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_R_B_F_LCRIT); +static SENSOR_DEVICE_ATTR(temp_l_b_f_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_L_B_F_LCRIT); +static SENSOR_DEVICE_ATTR(temp_r_t_f_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_R_T_F_LCRIT); +static SENSOR_DEVICE_ATTR(temp_l_t_f_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_L_T_F_LCRIT); +static SENSOR_DEVICE_ATTR(temp_r_b_b_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_R_B_B_LCRIT); +static SENSOR_DEVICE_ATTR(temp_l_b_b_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_L_B_B_LCRIT); +static SENSOR_DEVICE_ATTR(temp_r_t_b_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_R_T_B_LCRIT); +static SENSOR_DEVICE_ATTR(temp_l_t_b_lcrit , S_IRUGO , themal_temp_lcrit_get , NULL , TEMP_L_T_B_LCRIT); +static SENSOR_DEVICE_ATTR(fanctrl_rpm , S_IRUGO , fan_ctrl_rpm_get , NULL , FANCTRL_RPM); +static SENSOR_DEVICE_ATTR(fanctrl_mode , S_IRUGO , fan_ctrl_mode_get , NULL , FANCTRL_MODE); +static SENSOR_DEVICE_ATTR(fan1_stat , S_IRUGO , fan_status_get , NULL , 1); +static SENSOR_DEVICE_ATTR(fan2_stat , S_IRUGO , fan_status_get , NULL , 2); +static SENSOR_DEVICE_ATTR(fan3_stat , S_IRUGO , fan_status_get , NULL , 3); +static SENSOR_DEVICE_ATTR(fan4_stat , S_IRUGO , fan_status_get , NULL , 4); +static SENSOR_DEVICE_ATTR(fan5_stat , S_IRUGO , fan_status_get , NULL , 5); +static SENSOR_DEVICE_ATTR(fan1_present , S_IRUGO , fan_present_get , NULL , 1); +static SENSOR_DEVICE_ATTR(fan2_present , S_IRUGO , fan_present_get , NULL , 2); +static SENSOR_DEVICE_ATTR(fan3_present , S_IRUGO , fan_present_get , NULL , 3); +static SENSOR_DEVICE_ATTR(fan4_present , S_IRUGO , fan_present_get , NULL , 4); +static SENSOR_DEVICE_ATTR(fan5_present , S_IRUGO , fan_present_get , NULL , 5); +static SENSOR_DEVICE_ATTR(fan1_power , S_IRUGO , fan_power_get , NULL , 1); +static SENSOR_DEVICE_ATTR(fan2_power , S_IRUGO , fan_power_get , NULL , 2); +static SENSOR_DEVICE_ATTR(fan3_power , S_IRUGO , fan_power_get , NULL , 3); +static SENSOR_DEVICE_ATTR(fan4_power , S_IRUGO , fan_power_get , NULL , 4); +static SENSOR_DEVICE_ATTR(fan5_power , S_IRUGO , fan_power_get , NULL , 5); +static SENSOR_DEVICE_ATTR(fan1_front_rpm , S_IRUGO , fan_rpm_get , NULL , FAN1_FRONT_RPM); +static SENSOR_DEVICE_ATTR(fan2_front_rpm , S_IRUGO , fan_rpm_get , NULL , FAN2_FRONT_RPM); +static SENSOR_DEVICE_ATTR(fan3_front_rpm , S_IRUGO , fan_rpm_get , NULL , FAN3_FRONT_RPM); +static SENSOR_DEVICE_ATTR(fan4_front_rpm , S_IRUGO , fan_rpm_get , NULL , FAN4_FRONT_RPM); +static SENSOR_DEVICE_ATTR(fan5_front_rpm , S_IRUGO , fan_rpm_get , NULL , FAN5_FRONT_RPM); +static SENSOR_DEVICE_ATTR(fan1_rear_rpm , S_IRUGO , fan_rpm_get , NULL , FAN1_REAR_RPM); +static SENSOR_DEVICE_ATTR(fan2_rear_rpm , S_IRUGO , fan_rpm_get , NULL , FAN2_REAR_RPM); +static SENSOR_DEVICE_ATTR(fan3_rear_rpm , S_IRUGO , fan_rpm_get , NULL , FAN3_REAR_RPM); +static SENSOR_DEVICE_ATTR(fan4_rear_rpm , S_IRUGO , fan_rpm_get , NULL , FAN4_REAR_RPM); +static SENSOR_DEVICE_ATTR(fan5_rear_rpm , S_IRUGO , fan_rpm_get , NULL , FAN5_REAR_RPM); +static SENSOR_DEVICE_ATTR(psu1_good , S_IRUGO , psu_status_get , NULL , 1); +static SENSOR_DEVICE_ATTR(psu2_good , S_IRUGO , psu_status_get , NULL , 2); +static SENSOR_DEVICE_ATTR(psu1_prnt , S_IRUGO , psu_present_get , NULL , 1); +static SENSOR_DEVICE_ATTR(psu2_prnt , S_IRUGO , psu_present_get , NULL , 2); +static SENSOR_DEVICE_ATTR(psu1_vin , S_IRUGO , psu_vin_get , NULL , PSU1_VIN); +static SENSOR_DEVICE_ATTR(psu1_iin , S_IRUGO , psu_iin_get , NULL , PSU1_IIN); +static SENSOR_DEVICE_ATTR(psu1_vout , S_IRUGO , psu_vout_get , NULL , PSU1_VOUT); +static SENSOR_DEVICE_ATTR(psu1_iout , S_IRUGO , psu_iout_get , NULL , PSU1_IOUT); +static SENSOR_DEVICE_ATTR(psu1_temp , S_IRUGO , psu_temp_get , NULL , PSU1_TEMP); +static SENSOR_DEVICE_ATTR(psu1_fan_speed , S_IRUGO , psu_fan_get , NULL , PSU1_FAN_SPEED); +static SENSOR_DEVICE_ATTR(psu1_pout , S_IRUGO , psu_pout_get , NULL , PSU1_POUT); +static SENSOR_DEVICE_ATTR(psu1_pin , S_IRUGO , psu_pin_get , NULL , PSU1_PIN); +static SENSOR_DEVICE_ATTR(psu1_mfr_model , S_IRUGO , psu_mfr_model_get , NULL , PSU1_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu1_mfr_iout_max , S_IRUGO , psu_iout_max_get , NULL , PSU1_MFR_IOUT_MAX); +static SENSOR_DEVICE_ATTR(psu1_vomde , S_IRUGO , psu_vmode_get , NULL , PSU1_VOMDE); +static SENSOR_DEVICE_ATTR(psu2_vin , S_IRUGO , psu_vin_get , NULL , PSU2_VIN); +static SENSOR_DEVICE_ATTR(psu2_iin , S_IRUGO , psu_iin_get , NULL , PSU2_IIN); +static SENSOR_DEVICE_ATTR(psu2_vout , S_IRUGO , psu_vout_get , NULL , PSU2_VOUT); +static SENSOR_DEVICE_ATTR(psu2_iout , S_IRUGO , psu_iout_get , NULL , PSU2_IOUT); +static SENSOR_DEVICE_ATTR(psu2_temp , S_IRUGO , psu_temp_get , NULL , PSU2_TEMP); +static SENSOR_DEVICE_ATTR(psu2_fan_speed , S_IRUGO , psu_fan_get , NULL , PSU2_FAN_SPEED); +static SENSOR_DEVICE_ATTR(psu2_pout , S_IRUGO , psu_pout_get , NULL , PSU2_POUT); +static SENSOR_DEVICE_ATTR(psu2_pin , S_IRUGO , psu_pin_get , NULL , PSU2_PIN); +static SENSOR_DEVICE_ATTR(psu2_mfr_model , S_IRUGO , psu_mfr_model_get , NULL , PSU2_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu2_mfr_iout_max , S_IRUGO , psu_iout_max_get , NULL , PSU2_MFR_IOUT_MAX); +static SENSOR_DEVICE_ATTR(psu2_vomde , S_IRUGO , psu_vmode_get , NULL , PSU2_VOMDE); +static SENSOR_DEVICE_ATTR(dc6e_p0_vout , S_IRUGO , dc_vout_get , NULL , DC6E_P0_VOUT); +static SENSOR_DEVICE_ATTR(dc6e_p0_iout , S_IRUGO , dc_iout_get , NULL , DC6E_P0_IOUT); +static SENSOR_DEVICE_ATTR(dc6e_p0_pout , S_IRUGO , dc_pout_get , NULL , DC6E_P0_POUT); +static SENSOR_DEVICE_ATTR(dc6e_p1_vout , S_IRUGO , dc_vout_get , NULL , DC6E_P1_VOUT); +static SENSOR_DEVICE_ATTR(dc6e_p1_iout , S_IRUGO , dc_iout_get , NULL , DC6E_P1_IOUT); +static SENSOR_DEVICE_ATTR(dc6e_p1_pout , S_IRUGO , dc_pout_get , NULL , DC6E_P1_POUT); +static SENSOR_DEVICE_ATTR(dc70_p0_vout , S_IRUGO , dc_vout_get , NULL , DC70_P0_VOUT); +static SENSOR_DEVICE_ATTR(dc70_p0_iout , S_IRUGO , dc_iout_get , NULL , DC70_P0_IOUT); +static SENSOR_DEVICE_ATTR(dc70_p0_pout , S_IRUGO , dc_pout_get , NULL , DC70_P0_POUT); +static SENSOR_DEVICE_ATTR(dc70_p1_vout , S_IRUGO , dc_vout_get , NULL , DC70_P1_VOUT); +static SENSOR_DEVICE_ATTR(dc70_p1_iout , S_IRUGO , dc_iout_get , NULL , DC70_P1_IOUT); +static SENSOR_DEVICE_ATTR(dc70_p1_pout , S_IRUGO , dc_pout_get , NULL , DC70_P1_POUT); +static SENSOR_DEVICE_ATTR(qsfp_low_power_all , S_IRUGO | S_IWUSR , qsfp_low_power_all_get , qsfp_low_power_all_set , QSFP_LOW_POWER_ALL); +static SENSOR_DEVICE_ATTR(qsfp1_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 1); +static SENSOR_DEVICE_ATTR(qsfp2_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 2); +static SENSOR_DEVICE_ATTR(qsfp3_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 3); +static SENSOR_DEVICE_ATTR(qsfp4_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 4); +static SENSOR_DEVICE_ATTR(qsfp5_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 5); +static SENSOR_DEVICE_ATTR(qsfp6_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 6); +static SENSOR_DEVICE_ATTR(qsfp7_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 7); +static SENSOR_DEVICE_ATTR(qsfp8_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 8); +static SENSOR_DEVICE_ATTR(qsfp9_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 9); +static SENSOR_DEVICE_ATTR(qsfp10_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 10); +static SENSOR_DEVICE_ATTR(qsfp11_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 11); +static SENSOR_DEVICE_ATTR(qsfp12_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 12); +static SENSOR_DEVICE_ATTR(qsfp13_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 13); +static SENSOR_DEVICE_ATTR(qsfp14_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 14); +static SENSOR_DEVICE_ATTR(qsfp15_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 15); +static SENSOR_DEVICE_ATTR(qsfp16_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 16); +static SENSOR_DEVICE_ATTR(qsfp17_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 17); +static SENSOR_DEVICE_ATTR(qsfp18_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 18); +static SENSOR_DEVICE_ATTR(qsfp19_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 19); +static SENSOR_DEVICE_ATTR(qsfp20_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 20); +static SENSOR_DEVICE_ATTR(qsfp21_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 21); +static SENSOR_DEVICE_ATTR(qsfp22_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 22); +static SENSOR_DEVICE_ATTR(qsfp23_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 23); +static SENSOR_DEVICE_ATTR(qsfp24_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 24); +static SENSOR_DEVICE_ATTR(qsfp25_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 25); +static SENSOR_DEVICE_ATTR(qsfp26_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 26); +static SENSOR_DEVICE_ATTR(qsfp27_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 27); +static SENSOR_DEVICE_ATTR(qsfp28_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 28); +static SENSOR_DEVICE_ATTR(qsfp29_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 29); +static SENSOR_DEVICE_ATTR(qsfp30_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 30); +static SENSOR_DEVICE_ATTR(qsfp31_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 31); +static SENSOR_DEVICE_ATTR(qsfp32_low_power , S_IRUGO | S_IWUSR , qsfp_low_power_get , qsfp_low_power_set , 32); +static SENSOR_DEVICE_ATTR(qsfp_reset_all , S_IRUGO | S_IWUSR , NULL , qsfp_reset_all_set , QSFP_RESET_ALL); +static SENSOR_DEVICE_ATTR(qsfp1_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 1); +static SENSOR_DEVICE_ATTR(qsfp2_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 2); +static SENSOR_DEVICE_ATTR(qsfp3_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 3); +static SENSOR_DEVICE_ATTR(qsfp4_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 4); +static SENSOR_DEVICE_ATTR(qsfp5_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 5); +static SENSOR_DEVICE_ATTR(qsfp6_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 6); +static SENSOR_DEVICE_ATTR(qsfp7_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 7); +static SENSOR_DEVICE_ATTR(qsfp8_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 8); +static SENSOR_DEVICE_ATTR(qsfp9_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 9); +static SENSOR_DEVICE_ATTR(qsfp10_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 10); +static SENSOR_DEVICE_ATTR(qsfp11_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 11); +static SENSOR_DEVICE_ATTR(qsfp12_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 12); +static SENSOR_DEVICE_ATTR(qsfp13_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 13); +static SENSOR_DEVICE_ATTR(qsfp14_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 14); +static SENSOR_DEVICE_ATTR(qsfp15_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 15); +static SENSOR_DEVICE_ATTR(qsfp16_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 16); +static SENSOR_DEVICE_ATTR(qsfp17_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 17); +static SENSOR_DEVICE_ATTR(qsfp18_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 18); +static SENSOR_DEVICE_ATTR(qsfp19_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 19); +static SENSOR_DEVICE_ATTR(qsfp20_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 20); +static SENSOR_DEVICE_ATTR(qsfp21_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 21); +static SENSOR_DEVICE_ATTR(qsfp22_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 22); +static SENSOR_DEVICE_ATTR(qsfp23_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 23); +static SENSOR_DEVICE_ATTR(qsfp24_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 24); +static SENSOR_DEVICE_ATTR(qsfp25_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 25); +static SENSOR_DEVICE_ATTR(qsfp26_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 26); +static SENSOR_DEVICE_ATTR(qsfp27_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 27); +static SENSOR_DEVICE_ATTR(qsfp28_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 28); +static SENSOR_DEVICE_ATTR(qsfp29_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 29); +static SENSOR_DEVICE_ATTR(qsfp30_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 30); +static SENSOR_DEVICE_ATTR(qsfp31_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 31); +static SENSOR_DEVICE_ATTR(qsfp32_reset , S_IRUGO | S_IWUSR , NULL , qsfp_reset_set , 32); +static SENSOR_DEVICE_ATTR(qsfp_present_all , S_IRUGO , qsfp_present_all_get , NULL , QSFP_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(qsfp1_present , S_IRUGO , qsfp_present_get , NULL , 1); +static SENSOR_DEVICE_ATTR(qsfp2_present , S_IRUGO , qsfp_present_get , NULL , 2); +static SENSOR_DEVICE_ATTR(qsfp3_present , S_IRUGO , qsfp_present_get , NULL , 3); +static SENSOR_DEVICE_ATTR(qsfp4_present , S_IRUGO , qsfp_present_get , NULL , 4); +static SENSOR_DEVICE_ATTR(qsfp5_present , S_IRUGO , qsfp_present_get , NULL , 5); +static SENSOR_DEVICE_ATTR(qsfp6_present , S_IRUGO , qsfp_present_get , NULL , 6); +static SENSOR_DEVICE_ATTR(qsfp7_present , S_IRUGO , qsfp_present_get , NULL , 7); +static SENSOR_DEVICE_ATTR(qsfp8_present , S_IRUGO , qsfp_present_get , NULL , 8); +static SENSOR_DEVICE_ATTR(qsfp9_present , S_IRUGO , qsfp_present_get , NULL , 9); +static SENSOR_DEVICE_ATTR(qsfp10_present , S_IRUGO , qsfp_present_get , NULL , 10); +static SENSOR_DEVICE_ATTR(qsfp11_present , S_IRUGO , qsfp_present_get , NULL , 11); +static SENSOR_DEVICE_ATTR(qsfp12_present , S_IRUGO , qsfp_present_get , NULL , 12); +static SENSOR_DEVICE_ATTR(qsfp13_present , S_IRUGO , qsfp_present_get , NULL , 13); +static SENSOR_DEVICE_ATTR(qsfp14_present , S_IRUGO , qsfp_present_get , NULL , 14); +static SENSOR_DEVICE_ATTR(qsfp15_present , S_IRUGO , qsfp_present_get , NULL , 15); +static SENSOR_DEVICE_ATTR(qsfp16_present , S_IRUGO , qsfp_present_get , NULL , 16); +static SENSOR_DEVICE_ATTR(qsfp17_present , S_IRUGO , qsfp_present_get , NULL , 17); +static SENSOR_DEVICE_ATTR(qsfp18_present , S_IRUGO , qsfp_present_get , NULL , 18); +static SENSOR_DEVICE_ATTR(qsfp19_present , S_IRUGO , qsfp_present_get , NULL , 19); +static SENSOR_DEVICE_ATTR(qsfp20_present , S_IRUGO , qsfp_present_get , NULL , 20); +static SENSOR_DEVICE_ATTR(qsfp21_present , S_IRUGO , qsfp_present_get , NULL , 21); +static SENSOR_DEVICE_ATTR(qsfp22_present , S_IRUGO , qsfp_present_get , NULL , 22); +static SENSOR_DEVICE_ATTR(qsfp23_present , S_IRUGO , qsfp_present_get , NULL , 23); +static SENSOR_DEVICE_ATTR(qsfp24_present , S_IRUGO , qsfp_present_get , NULL , 24); +static SENSOR_DEVICE_ATTR(qsfp25_present , S_IRUGO , qsfp_present_get , NULL , 25); +static SENSOR_DEVICE_ATTR(qsfp26_present , S_IRUGO , qsfp_present_get , NULL , 26); +static SENSOR_DEVICE_ATTR(qsfp27_present , S_IRUGO , qsfp_present_get , NULL , 27); +static SENSOR_DEVICE_ATTR(qsfp28_present , S_IRUGO , qsfp_present_get , NULL , 28); +static SENSOR_DEVICE_ATTR(qsfp29_present , S_IRUGO , qsfp_present_get , NULL , 29); +static SENSOR_DEVICE_ATTR(qsfp30_present , S_IRUGO , qsfp_present_get , NULL , 30); +static SENSOR_DEVICE_ATTR(qsfp31_present , S_IRUGO , qsfp_present_get , NULL , 31); +static SENSOR_DEVICE_ATTR(qsfp32_present , S_IRUGO , qsfp_present_get , NULL , 32); +static SENSOR_DEVICE_ATTR(qsfp_int_all , S_IRUGO , qsfp_int_all_get , NULL , QSFP_INT_ALL); +static SENSOR_DEVICE_ATTR(qsfp1_int , S_IRUGO , qsfp_int_get , NULL , 1); +static SENSOR_DEVICE_ATTR(qsfp2_int , S_IRUGO , qsfp_int_get , NULL , 2); +static SENSOR_DEVICE_ATTR(qsfp3_int , S_IRUGO , qsfp_int_get , NULL , 3); +static SENSOR_DEVICE_ATTR(qsfp4_int , S_IRUGO , qsfp_int_get , NULL , 4); +static SENSOR_DEVICE_ATTR(qsfp5_int , S_IRUGO , qsfp_int_get , NULL , 5); +static SENSOR_DEVICE_ATTR(qsfp6_int , S_IRUGO , qsfp_int_get , NULL , 6); +static SENSOR_DEVICE_ATTR(qsfp7_int , S_IRUGO , qsfp_int_get , NULL , 7); +static SENSOR_DEVICE_ATTR(qsfp8_int , S_IRUGO , qsfp_int_get , NULL , 8); +static SENSOR_DEVICE_ATTR(qsfp9_int , S_IRUGO , qsfp_int_get , NULL , 9); +static SENSOR_DEVICE_ATTR(qsfp10_int , S_IRUGO , qsfp_int_get , NULL , 10); +static SENSOR_DEVICE_ATTR(qsfp11_int , S_IRUGO , qsfp_int_get , NULL , 11); +static SENSOR_DEVICE_ATTR(qsfp12_int , S_IRUGO , qsfp_int_get , NULL , 12); +static SENSOR_DEVICE_ATTR(qsfp13_int , S_IRUGO , qsfp_int_get , NULL , 13); +static SENSOR_DEVICE_ATTR(qsfp14_int , S_IRUGO , qsfp_int_get , NULL , 14); +static SENSOR_DEVICE_ATTR(qsfp15_int , S_IRUGO , qsfp_int_get , NULL , 15); +static SENSOR_DEVICE_ATTR(qsfp16_int , S_IRUGO , qsfp_int_get , NULL , 16); +static SENSOR_DEVICE_ATTR(qsfp17_int , S_IRUGO , qsfp_int_get , NULL , 17); +static SENSOR_DEVICE_ATTR(qsfp18_int , S_IRUGO , qsfp_int_get , NULL , 18); +static SENSOR_DEVICE_ATTR(qsfp19_int , S_IRUGO , qsfp_int_get , NULL , 19); +static SENSOR_DEVICE_ATTR(qsfp20_int , S_IRUGO , qsfp_int_get , NULL , 20); +static SENSOR_DEVICE_ATTR(qsfp21_int , S_IRUGO , qsfp_int_get , NULL , 21); +static SENSOR_DEVICE_ATTR(qsfp22_int , S_IRUGO , qsfp_int_get , NULL , 22); +static SENSOR_DEVICE_ATTR(qsfp23_int , S_IRUGO , qsfp_int_get , NULL , 23); +static SENSOR_DEVICE_ATTR(qsfp24_int , S_IRUGO , qsfp_int_get , NULL , 24); +static SENSOR_DEVICE_ATTR(qsfp25_int , S_IRUGO , qsfp_int_get , NULL , 25); +static SENSOR_DEVICE_ATTR(qsfp26_int , S_IRUGO , qsfp_int_get , NULL , 26); +static SENSOR_DEVICE_ATTR(qsfp27_int , S_IRUGO , qsfp_int_get , NULL , 27); +static SENSOR_DEVICE_ATTR(qsfp28_int , S_IRUGO , qsfp_int_get , NULL , 28); +static SENSOR_DEVICE_ATTR(qsfp29_int , S_IRUGO , qsfp_int_get , NULL , 29); +static SENSOR_DEVICE_ATTR(qsfp30_int , S_IRUGO , qsfp_int_get , NULL , 30); +static SENSOR_DEVICE_ATTR(qsfp31_int , S_IRUGO , qsfp_int_get , NULL , 31); +static SENSOR_DEVICE_ATTR(qsfp32_int , S_IRUGO , qsfp_int_get , NULL , 32); +static SENSOR_DEVICE_ATTR(qsfp1_4_int , S_IRUGO , qsfp_quter_int_get , NULL , 1); +static SENSOR_DEVICE_ATTR(qsfp2_4_int , S_IRUGO , qsfp_quter_int_get , NULL , 2); +static SENSOR_DEVICE_ATTR(qsfp3_4_int , S_IRUGO , qsfp_quter_int_get , NULL , 3); +static SENSOR_DEVICE_ATTR(qsfp4_4_int , S_IRUGO , qsfp_quter_int_get , NULL , 4); +static SENSOR_DEVICE_ATTR(qsfp1_4_modprs , S_IRUGO , qsfp_modprs_int_get , NULL , 1); +static SENSOR_DEVICE_ATTR(qsfp2_4_modprs , S_IRUGO , qsfp_modprs_int_get , NULL , 2); +static SENSOR_DEVICE_ATTR(qsfp3_4_modprs , S_IRUGO , qsfp_modprs_int_get , NULL , 3); +static SENSOR_DEVICE_ATTR(qsfp4_4_modprs , S_IRUGO , qsfp_modprs_int_get , NULL , 4); +static SENSOR_DEVICE_ATTR(qsfp1_4_int_mask , S_IRUGO | S_IWUSR , qsfp_quter_int_mask_get , qsfp_quter_int_mask_set , 1); +static SENSOR_DEVICE_ATTR(qsfp2_4_int_mask , S_IRUGO | S_IWUSR , qsfp_quter_int_mask_get , qsfp_quter_int_mask_set , 2); +static SENSOR_DEVICE_ATTR(qsfp3_4_int_mask , S_IRUGO | S_IWUSR , qsfp_quter_int_mask_get , qsfp_quter_int_mask_set , 3); +static SENSOR_DEVICE_ATTR(qsfp4_4_int_mask , S_IRUGO | S_IWUSR , qsfp_quter_int_mask_get , qsfp_quter_int_mask_set , 4); +static SENSOR_DEVICE_ATTR(qsfp1_4_modprs_mask , S_IRUGO | S_IWUSR , qsfp_modprs_int_mask_get , qsfp_modprs_int_mask_set , 1); +static SENSOR_DEVICE_ATTR(qsfp2_4_modprs_mask , S_IRUGO | S_IWUSR , qsfp_modprs_int_mask_get , qsfp_modprs_int_mask_set , 2); +static SENSOR_DEVICE_ATTR(qsfp3_4_modprs_mask , S_IRUGO | S_IWUSR , qsfp_modprs_int_mask_get , qsfp_modprs_int_mask_set , 3); +static SENSOR_DEVICE_ATTR(qsfp4_4_modprs_mask , S_IRUGO | S_IWUSR , qsfp_modprs_int_mask_get , qsfp_modprs_int_mask_set , 4); +/* end of sysfs attributes for SENSOR_DEVICE_ATTR */ + +/* sysfs attributes for hwmon */ +/* i2c-0 */ +static struct attribute *NBA715_SYS_attributes[] = +{ + &sensor_dev_attr_cpld_23_ver.dev_attr.attr, + &sensor_dev_attr_cpld_30_ver.dev_attr.attr, + &sensor_dev_attr_cpld_31_ver.dev_attr.attr, + &sensor_dev_attr_cpld_32_ver.dev_attr.attr, + &sensor_dev_attr_wdt_en.dev_attr.attr, + &sensor_dev_attr_eeprom_wp.dev_attr.attr, + &sensor_dev_attr_usb_en.dev_attr.attr, + &sensor_dev_attr_shutdown_set.dev_attr.attr, + &sensor_dev_attr_reset.dev_attr.attr, + &sensor_dev_attr_bmc_present.dev_attr.attr, + &sensor_dev_attr_cpld_fp_int.dev_attr.attr, + &sensor_dev_attr_cpld_rp_int.dev_attr.attr, + &sensor_dev_attr_cpld_fan_int.dev_attr.attr, + &sensor_dev_attr_cpld_psu_int.dev_attr.attr, + &sensor_dev_attr_thermal_int.dev_attr.attr, + &sensor_dev_attr_usb_int.dev_attr.attr, + &sensor_dev_attr_cpld_fp_int_mask.dev_attr.attr, + &sensor_dev_attr_cpld_rp_int_mask.dev_attr.attr, + &sensor_dev_attr_cpld_fan_int_mask.dev_attr.attr, + &sensor_dev_attr_cpld_psu_int_mask.dev_attr.attr, + &sensor_dev_attr_thermal_int_mask.dev_attr.attr, + &sensor_dev_attr_usb_int_mask.dev_attr.attr, + NULL +}; +static struct attribute *NBA715_LED_attributes[] = +{ + &sensor_dev_attr_led_1.dev_attr.attr, + &sensor_dev_attr_led_2.dev_attr.attr, + &sensor_dev_attr_led_flow.dev_attr.attr, + &sensor_dev_attr_led_sys.dev_attr.attr, + &sensor_dev_attr_led_fiber.dev_attr.attr, + NULL +}; +static struct attribute *NBA715_THERMAL_attributes[] = +{ + &sensor_dev_attr_temp_r_b_f.dev_attr.attr, + &sensor_dev_attr_temp_r_b_b.dev_attr.attr, + &sensor_dev_attr_temp_l_b_f.dev_attr.attr, + &sensor_dev_attr_temp_l_b_b.dev_attr.attr, + &sensor_dev_attr_temp_r_t_f.dev_attr.attr, + &sensor_dev_attr_temp_r_t_b.dev_attr.attr, + &sensor_dev_attr_temp_l_t_f.dev_attr.attr, + &sensor_dev_attr_temp_l_t_b.dev_attr.attr, + &sensor_dev_attr_temp_r_b_int.dev_attr.attr, + &sensor_dev_attr_temp_l_b_int.dev_attr.attr, + &sensor_dev_attr_temp_r_t_int.dev_attr.attr, + &sensor_dev_attr_temp_l_t_int.dev_attr.attr, + &sensor_dev_attr_temp_r_b_int_mask.dev_attr.attr, + &sensor_dev_attr_temp_l_b_int_mask.dev_attr.attr, + &sensor_dev_attr_temp_r_t_int_mask.dev_attr.attr, + &sensor_dev_attr_temp_l_t_int_mask.dev_attr.attr, + &sensor_dev_attr_temp_r_b_f_max.dev_attr.attr, + &sensor_dev_attr_temp_r_b_f_min.dev_attr.attr, + &sensor_dev_attr_temp_r_b_f_crit.dev_attr.attr, + &sensor_dev_attr_temp_r_b_f_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_r_b_b_max.dev_attr.attr, + &sensor_dev_attr_temp_r_b_b_min.dev_attr.attr, + &sensor_dev_attr_temp_r_b_b_crit.dev_attr.attr, + &sensor_dev_attr_temp_r_b_b_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_l_b_f_max.dev_attr.attr, + &sensor_dev_attr_temp_l_b_f_min.dev_attr.attr, + &sensor_dev_attr_temp_l_b_f_crit.dev_attr.attr, + &sensor_dev_attr_temp_l_b_f_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_l_b_b_max.dev_attr.attr, + &sensor_dev_attr_temp_l_b_b_min.dev_attr.attr, + &sensor_dev_attr_temp_l_b_b_crit.dev_attr.attr, + &sensor_dev_attr_temp_l_b_b_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_r_t_f_max.dev_attr.attr, + &sensor_dev_attr_temp_r_t_f_min.dev_attr.attr, + &sensor_dev_attr_temp_r_t_f_crit.dev_attr.attr, + &sensor_dev_attr_temp_r_t_f_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_r_t_b_max.dev_attr.attr, + &sensor_dev_attr_temp_r_t_b_min.dev_attr.attr, + &sensor_dev_attr_temp_r_t_b_crit.dev_attr.attr, + &sensor_dev_attr_temp_r_t_b_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_l_t_f_max.dev_attr.attr, + &sensor_dev_attr_temp_l_t_f_min.dev_attr.attr, + &sensor_dev_attr_temp_l_t_f_crit.dev_attr.attr, + &sensor_dev_attr_temp_l_t_f_lcrit.dev_attr.attr, + &sensor_dev_attr_temp_l_t_b_max.dev_attr.attr, + &sensor_dev_attr_temp_l_t_b_min.dev_attr.attr, + &sensor_dev_attr_temp_l_t_b_crit.dev_attr.attr, + &sensor_dev_attr_temp_l_t_b_lcrit.dev_attr.attr, + NULL +}; +static struct attribute *NBA715_FAN_attributes[] = +{ + &sensor_dev_attr_fanctrl_rpm.dev_attr.attr, + &sensor_dev_attr_fanctrl_mode.dev_attr.attr, + &sensor_dev_attr_fan1_stat.dev_attr.attr, + &sensor_dev_attr_fan2_stat.dev_attr.attr, + &sensor_dev_attr_fan3_stat.dev_attr.attr, + &sensor_dev_attr_fan4_stat.dev_attr.attr, + &sensor_dev_attr_fan5_stat.dev_attr.attr, + &sensor_dev_attr_fan1_present.dev_attr.attr, + &sensor_dev_attr_fan2_present.dev_attr.attr, + &sensor_dev_attr_fan3_present.dev_attr.attr, + &sensor_dev_attr_fan4_present.dev_attr.attr, + &sensor_dev_attr_fan5_present.dev_attr.attr, + &sensor_dev_attr_fan1_power.dev_attr.attr, + &sensor_dev_attr_fan2_power.dev_attr.attr, + &sensor_dev_attr_fan3_power.dev_attr.attr, + &sensor_dev_attr_fan4_power.dev_attr.attr, + &sensor_dev_attr_fan5_power.dev_attr.attr, + &sensor_dev_attr_fan1_front_rpm.dev_attr.attr, + &sensor_dev_attr_fan2_front_rpm.dev_attr.attr, + &sensor_dev_attr_fan3_front_rpm.dev_attr.attr, + &sensor_dev_attr_fan4_front_rpm.dev_attr.attr, + &sensor_dev_attr_fan5_front_rpm.dev_attr.attr, + &sensor_dev_attr_fan1_rear_rpm.dev_attr.attr, + &sensor_dev_attr_fan2_rear_rpm.dev_attr.attr, + &sensor_dev_attr_fan3_rear_rpm.dev_attr.attr, + &sensor_dev_attr_fan4_rear_rpm.dev_attr.attr, + &sensor_dev_attr_fan5_rear_rpm.dev_attr.attr, + NULL +}; +static struct attribute *NBA715_POWER_attributes[] = +{ + &sensor_dev_attr_psu1_good.dev_attr.attr, + &sensor_dev_attr_psu2_good.dev_attr.attr, + &sensor_dev_attr_psu1_prnt.dev_attr.attr, + &sensor_dev_attr_psu2_prnt.dev_attr.attr, + &sensor_dev_attr_psu1_vin.dev_attr.attr, + &sensor_dev_attr_psu1_iin.dev_attr.attr, + &sensor_dev_attr_psu1_vout.dev_attr.attr, + &sensor_dev_attr_psu1_iout.dev_attr.attr, + &sensor_dev_attr_psu1_temp.dev_attr.attr, + &sensor_dev_attr_psu1_fan_speed.dev_attr.attr, + &sensor_dev_attr_psu1_pout.dev_attr.attr, + &sensor_dev_attr_psu1_pin.dev_attr.attr, + &sensor_dev_attr_psu1_mfr_model.dev_attr.attr, + &sensor_dev_attr_psu1_mfr_iout_max.dev_attr.attr, + &sensor_dev_attr_psu1_vomde.dev_attr.attr, + &sensor_dev_attr_psu2_vin.dev_attr.attr, + &sensor_dev_attr_psu2_iin.dev_attr.attr, + &sensor_dev_attr_psu2_vout.dev_attr.attr, + &sensor_dev_attr_psu2_iout.dev_attr.attr, + &sensor_dev_attr_psu2_temp.dev_attr.attr, + &sensor_dev_attr_psu2_fan_speed.dev_attr.attr, + &sensor_dev_attr_psu2_pout.dev_attr.attr, + &sensor_dev_attr_psu2_pin.dev_attr.attr, + &sensor_dev_attr_psu2_mfr_model.dev_attr.attr, + &sensor_dev_attr_psu2_mfr_iout_max.dev_attr.attr, + &sensor_dev_attr_psu2_vomde.dev_attr.attr, + &sensor_dev_attr_dc6e_p0_vout.dev_attr.attr, + &sensor_dev_attr_dc6e_p0_iout.dev_attr.attr, + &sensor_dev_attr_dc6e_p0_pout.dev_attr.attr, + &sensor_dev_attr_dc6e_p1_vout.dev_attr.attr, + &sensor_dev_attr_dc6e_p1_iout.dev_attr.attr, + &sensor_dev_attr_dc6e_p1_pout.dev_attr.attr, + &sensor_dev_attr_dc70_p0_vout.dev_attr.attr, + &sensor_dev_attr_dc70_p0_iout.dev_attr.attr, + &sensor_dev_attr_dc70_p0_pout.dev_attr.attr, + &sensor_dev_attr_dc70_p1_vout.dev_attr.attr, + &sensor_dev_attr_dc70_p1_iout.dev_attr.attr, + &sensor_dev_attr_dc70_p1_pout.dev_attr.attr, + NULL +}; +static struct attribute *NBA715_QSFP_attributes[] = +{ + &sensor_dev_attr_qsfp_low_power_all.dev_attr.attr, + &sensor_dev_attr_qsfp1_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp2_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp3_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp4_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp5_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp6_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp7_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp8_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp9_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp10_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp11_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp12_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp13_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp14_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp15_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp16_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp17_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp18_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp19_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp20_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp21_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp22_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp23_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp24_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp25_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp26_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp27_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp28_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp29_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp30_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp31_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp32_low_power.dev_attr.attr, + &sensor_dev_attr_qsfp_reset_all.dev_attr.attr, + &sensor_dev_attr_qsfp1_reset.dev_attr.attr, + &sensor_dev_attr_qsfp2_reset.dev_attr.attr, + &sensor_dev_attr_qsfp3_reset.dev_attr.attr, + &sensor_dev_attr_qsfp4_reset.dev_attr.attr, + &sensor_dev_attr_qsfp5_reset.dev_attr.attr, + &sensor_dev_attr_qsfp6_reset.dev_attr.attr, + &sensor_dev_attr_qsfp7_reset.dev_attr.attr, + &sensor_dev_attr_qsfp8_reset.dev_attr.attr, + &sensor_dev_attr_qsfp9_reset.dev_attr.attr, + &sensor_dev_attr_qsfp10_reset.dev_attr.attr, + &sensor_dev_attr_qsfp11_reset.dev_attr.attr, + &sensor_dev_attr_qsfp12_reset.dev_attr.attr, + &sensor_dev_attr_qsfp13_reset.dev_attr.attr, + &sensor_dev_attr_qsfp14_reset.dev_attr.attr, + &sensor_dev_attr_qsfp15_reset.dev_attr.attr, + &sensor_dev_attr_qsfp16_reset.dev_attr.attr, + &sensor_dev_attr_qsfp17_reset.dev_attr.attr, + &sensor_dev_attr_qsfp18_reset.dev_attr.attr, + &sensor_dev_attr_qsfp19_reset.dev_attr.attr, + &sensor_dev_attr_qsfp20_reset.dev_attr.attr, + &sensor_dev_attr_qsfp21_reset.dev_attr.attr, + &sensor_dev_attr_qsfp22_reset.dev_attr.attr, + &sensor_dev_attr_qsfp23_reset.dev_attr.attr, + &sensor_dev_attr_qsfp24_reset.dev_attr.attr, + &sensor_dev_attr_qsfp25_reset.dev_attr.attr, + &sensor_dev_attr_qsfp26_reset.dev_attr.attr, + &sensor_dev_attr_qsfp27_reset.dev_attr.attr, + &sensor_dev_attr_qsfp28_reset.dev_attr.attr, + &sensor_dev_attr_qsfp29_reset.dev_attr.attr, + &sensor_dev_attr_qsfp30_reset.dev_attr.attr, + &sensor_dev_attr_qsfp31_reset.dev_attr.attr, + &sensor_dev_attr_qsfp32_reset.dev_attr.attr, + &sensor_dev_attr_qsfp_present_all.dev_attr.attr, + &sensor_dev_attr_qsfp1_present.dev_attr.attr, + &sensor_dev_attr_qsfp2_present.dev_attr.attr, + &sensor_dev_attr_qsfp3_present.dev_attr.attr, + &sensor_dev_attr_qsfp4_present.dev_attr.attr, + &sensor_dev_attr_qsfp5_present.dev_attr.attr, + &sensor_dev_attr_qsfp6_present.dev_attr.attr, + &sensor_dev_attr_qsfp7_present.dev_attr.attr, + &sensor_dev_attr_qsfp8_present.dev_attr.attr, + &sensor_dev_attr_qsfp9_present.dev_attr.attr, + &sensor_dev_attr_qsfp10_present.dev_attr.attr, + &sensor_dev_attr_qsfp11_present.dev_attr.attr, + &sensor_dev_attr_qsfp12_present.dev_attr.attr, + &sensor_dev_attr_qsfp13_present.dev_attr.attr, + &sensor_dev_attr_qsfp14_present.dev_attr.attr, + &sensor_dev_attr_qsfp15_present.dev_attr.attr, + &sensor_dev_attr_qsfp16_present.dev_attr.attr, + &sensor_dev_attr_qsfp17_present.dev_attr.attr, + &sensor_dev_attr_qsfp18_present.dev_attr.attr, + &sensor_dev_attr_qsfp19_present.dev_attr.attr, + &sensor_dev_attr_qsfp20_present.dev_attr.attr, + &sensor_dev_attr_qsfp21_present.dev_attr.attr, + &sensor_dev_attr_qsfp22_present.dev_attr.attr, + &sensor_dev_attr_qsfp23_present.dev_attr.attr, + &sensor_dev_attr_qsfp24_present.dev_attr.attr, + &sensor_dev_attr_qsfp25_present.dev_attr.attr, + &sensor_dev_attr_qsfp26_present.dev_attr.attr, + &sensor_dev_attr_qsfp27_present.dev_attr.attr, + &sensor_dev_attr_qsfp28_present.dev_attr.attr, + &sensor_dev_attr_qsfp29_present.dev_attr.attr, + &sensor_dev_attr_qsfp30_present.dev_attr.attr, + &sensor_dev_attr_qsfp31_present.dev_attr.attr, + &sensor_dev_attr_qsfp32_present.dev_attr.attr, + &sensor_dev_attr_qsfp_int_all.dev_attr.attr, + &sensor_dev_attr_qsfp1_int.dev_attr.attr, + &sensor_dev_attr_qsfp2_int.dev_attr.attr, + &sensor_dev_attr_qsfp3_int.dev_attr.attr, + &sensor_dev_attr_qsfp4_int.dev_attr.attr, + &sensor_dev_attr_qsfp5_int.dev_attr.attr, + &sensor_dev_attr_qsfp6_int.dev_attr.attr, + &sensor_dev_attr_qsfp7_int.dev_attr.attr, + &sensor_dev_attr_qsfp8_int.dev_attr.attr, + &sensor_dev_attr_qsfp9_int.dev_attr.attr, + &sensor_dev_attr_qsfp10_int.dev_attr.attr, + &sensor_dev_attr_qsfp11_int.dev_attr.attr, + &sensor_dev_attr_qsfp12_int.dev_attr.attr, + &sensor_dev_attr_qsfp13_int.dev_attr.attr, + &sensor_dev_attr_qsfp14_int.dev_attr.attr, + &sensor_dev_attr_qsfp15_int.dev_attr.attr, + &sensor_dev_attr_qsfp16_int.dev_attr.attr, + &sensor_dev_attr_qsfp17_int.dev_attr.attr, + &sensor_dev_attr_qsfp18_int.dev_attr.attr, + &sensor_dev_attr_qsfp19_int.dev_attr.attr, + &sensor_dev_attr_qsfp20_int.dev_attr.attr, + &sensor_dev_attr_qsfp21_int.dev_attr.attr, + &sensor_dev_attr_qsfp22_int.dev_attr.attr, + &sensor_dev_attr_qsfp23_int.dev_attr.attr, + &sensor_dev_attr_qsfp24_int.dev_attr.attr, + &sensor_dev_attr_qsfp25_int.dev_attr.attr, + &sensor_dev_attr_qsfp26_int.dev_attr.attr, + &sensor_dev_attr_qsfp27_int.dev_attr.attr, + &sensor_dev_attr_qsfp28_int.dev_attr.attr, + &sensor_dev_attr_qsfp29_int.dev_attr.attr, + &sensor_dev_attr_qsfp30_int.dev_attr.attr, + &sensor_dev_attr_qsfp31_int.dev_attr.attr, + &sensor_dev_attr_qsfp32_int.dev_attr.attr, + &sensor_dev_attr_qsfp1_4_int.dev_attr.attr, + &sensor_dev_attr_qsfp2_4_int.dev_attr.attr, + &sensor_dev_attr_qsfp3_4_int.dev_attr.attr, + &sensor_dev_attr_qsfp4_4_int.dev_attr.attr, + &sensor_dev_attr_qsfp1_4_modprs.dev_attr.attr, + &sensor_dev_attr_qsfp2_4_modprs.dev_attr.attr, + &sensor_dev_attr_qsfp3_4_modprs.dev_attr.attr, + &sensor_dev_attr_qsfp4_4_modprs.dev_attr.attr, + &sensor_dev_attr_qsfp1_4_int_mask.dev_attr.attr, + &sensor_dev_attr_qsfp2_4_int_mask.dev_attr.attr, + &sensor_dev_attr_qsfp3_4_int_mask.dev_attr.attr, + &sensor_dev_attr_qsfp4_4_int_mask.dev_attr.attr, + &sensor_dev_attr_qsfp1_4_modprs_mask.dev_attr.attr, + &sensor_dev_attr_qsfp2_4_modprs_mask.dev_attr.attr, + &sensor_dev_attr_qsfp3_4_modprs_mask.dev_attr.attr, + &sensor_dev_attr_qsfp4_4_modprs_mask.dev_attr.attr, + NULL +}; +/* end of sysfs attributes for hwmon */ + +/* struct attribute_group */ +static const struct attribute_group NBA715_SYS_group = +{ + .name = "NBA715_SYS", + .attrs = NBA715_SYS_attributes, +}; + +static const struct attribute_group NBA715_LED_group = +{ + .name = "NBA715_LED", + .attrs = NBA715_LED_attributes, +}; + +static const struct attribute_group NBA715_THERMAL_group = +{ + .name = "NBA715_THERMAL", + .attrs = NBA715_THERMAL_attributes, +}; + +static const struct attribute_group NBA715_FAN_group = +{ + .name = "NBA715_FAN", + .attrs = NBA715_FAN_attributes, +}; + +static const struct attribute_group NBA715_POWER_group = +{ + .name = "NBA715_POWER", + .attrs = NBA715_POWER_attributes, +}; + +static const struct attribute_group NBA715_QSFP_group = +{ + .name = "NBA715_QSFP", + .attrs = NBA715_QSFP_attributes, +}; + +static const struct bin_attribute net_eeprom_attr = { + .attr = { + .name = "eeprom", + .mode = S_IRUGO, + }, + .size = EEPROM_SIZE, + .read = net_eeprom_read, +}; + +/* end of struct attribute_group */ diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/scripts/sensors b/platform/innovium/sonic-platform-modules-netberg/aurora-715/scripts/sensors new file mode 100755 index 0000000000..a2d1477bbd --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/scripts/sensors @@ -0,0 +1,8 @@ +#!/bin/bash +docker exec -i pmon sensors "$@" + +#To probe sensors not part of lm-sensors +if [ -r /usr/local/bin/netberg_nba715_sensors.py ]; then + python /usr/local/bin/netberg_nba715_sensors.py fan_status + python /usr/local/bin/netberg_nba715_sensors.py sensor_status +fi diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/service/nba715-platform-init.service b/platform/innovium/sonic-platform-modules-netberg/aurora-715/service/nba715-platform-init.service new file mode 100644 index 0000000000..6f019485ee --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/service/nba715-platform-init.service @@ -0,0 +1,14 @@ +[Unit] +Description=Netberg Aurora 715 Platform initialization service +After=local-fs.target innovium_platform_driver.service +Before=pmon.service + + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/netberg_nba715_startup start +ExecStop=/usr/local/bin/netberg_nba715_startup stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/setup.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/setup.py new file mode 100755 index 0000000000..e6ccd481b0 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/setup.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import os +# import sys +from setuptools import setup +os.listdir + +setup( + name='sonic_platform', + version='1.0', + description='Netberg Aurora 715 sonic platform API', + + packages=['sonic_platform'], + package_dir={'sonic_platform': 'aurora-715/sonic_platform'}, + + + classifiers=[ + 'Development Status :: 3 - Beta', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.7', + 'Topic :: Utilities', + ], +) diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/__init__.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/chassis.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/chassis.py new file mode 100644 index 0000000000..39c8242f78 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/chassis.py @@ -0,0 +1,335 @@ +############################################################################# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + + +try: + import os + import time + import subprocess + from sonic_platform_base.chassis_base import ChassisBase + from sonic_platform.platDev import PlatDev + from sonic_platform.fan import Fan + from sonic_platform.psu import Psu + from sonic_platform.sfp import Sfp + from sonic_platform.thermal import Thermal + from sonic_platform.eeprom import Eeprom + from sonic_platform.component import Component +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +GET_HWSKU_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.hwsku" +GET_PLATFORM_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.platform" + + +# XCVR type definition +SFP_TYPE = 0 +QSFP_TYPE = 1 + + +class Chassis(ChassisBase): + """Platform-specific Chassis class""" + + _global_port_pres_dict = {} + + def __init__(self): + super(Chassis, self).__init__() + + # Initialize SKU name and Platform name + self.sku_name = self._get_sku_name() + self.platform_name = self._get_platform_name() + self.name = self.sku_name + + # get the device infomation of platform + self.platdev = PlatDev() + + #self._component_list = [] + #self._module_list = [] + #self._fan_drawer_list = [] + + self._eeprom = Eeprom() + # init component + for i in range(self.platdev.get_component_count()): + component = Component(i, self.platdev.get_component_name( + i), self.platdev.get_component_descript(i)) + self._component_list.append(component) + # init fan list + if self.platdev.get_fan_support(): + fanlist = self.platdev.get_fan_list() + for index in range(0, len(fanlist)): + fan_name = fanlist[index] + for pos in range(0, self.platdev.get_fan_num_by_name(fan_name)): + fan = Fan( + index, pos, [self.platdev.get_fan_sysfile_path_by_name(fan_name), '']) + self._fan_list.append(fan) + + # init psu list + psulist = self.platdev.get_psu_list() + for index in range(0, len(psulist)): + psu_name = psulist[index] + psu = Psu(index, [self.platdev.get_psu_attr_path_by_name(psu_name), + self.platdev.get_psu_status_path_by_name(psu_name)], + self.platdev.bmc_is_exist()) + self._psu_list.append(psu) + + # init thermal list + thermal_info_list = self.platdev.get_thermal_dev_info_all() + for index in range(0, len(thermal_info_list)): + if len(self.platdev.get_thermal_dev_tempidx_by_idx(index)) > 1: + for idx in self.platdev.get_thermal_dev_tempidx_by_idx(index): + thermal = Thermal(idx, self.platdev.get_thermal_dev_name_by_idx(index)+"-{}".format(idx), + self.platdev.get_thermal_dev_sysfile_path_by_idx( + index), + self.platdev.bmc_is_exist(), + self.platdev.get_thermal_dev_support_mask_by_idx( + index), + self.platdev.get_thermal_dev_ext_sysfile_list_by_idx(index)) + self._thermal_list.append(thermal) + else: + thermal = Thermal(1, self.platdev.get_thermal_dev_name_by_idx(index), + self.platdev.get_thermal_dev_sysfile_path_by_idx( + index), + self.platdev.bmc_is_exist(), + self.platdev.get_thermal_dev_support_mask_by_idx( + index), + self.platdev.get_thermal_dev_ext_sysfile_list_by_idx(index)) + self._thermal_list.append(thermal) + + # init sfp list + port_num = 1 + for sfpg_name in self.platdev.get_sfp_group_list(): + if self.platdev.get_sfp_group_type_by_name(sfpg_name) == 'QSFP28': + sfp_type = QSFP_TYPE + else: + sfp_type = SFP_TYPE + + for x in range(0, self.platdev.get_sfp_group_number_by_name(sfpg_name)): + eeprom_path_list = ['n/a', 'n/a'] + if self.platdev.get_sfp_group_path_by_name(sfpg_name)[x] != 'n/a': + eeprom_path_list[0] = self.platdev.get_sfp_group_path_by_name(sfpg_name)[ + x] + '/eeprom' + if os.path.exists(eeprom_path_list[0].replace("0050", "0051")): + eeprom_path_list[1] = eeprom_path_list[0].replace( + "0050", "0051") + # index: port index, start from 0 + # eeprom_path_list : a list of path to eeprom sysfile + # [0]: for 0x50 + # [1]: for 0x51 + # ext_sysfile_list: used to get other function of sfp + # [0]: present + # [1]: reset + # [2]: get lowpower mode + # [3]: set lowpower mode + sfp = Sfp(port_num, eeprom_path_list, sfp_type, + self.platdev.get_sfp_ext_sysfile_list()) + port_num += 1 + self._sfp_list.append(sfp) + + self.init_global_port_presence() + + def _get_sku_name(self): + pipe = subprocess.Popen( + GET_HWSKU_CMD, shell=True, stdout=subprocess.PIPE) + out, err = pipe.communicate() + return out.decode().rstrip('\n') + + def _get_platform_name(self): + pipe = subprocess.Popen( + GET_PLATFORM_CMD, shell=True, stdout=subprocess.PIPE) + out, err = pipe.communicate() + return out.decode().rstrip('\n') + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return self.name + + def get_base_mac(self): + """ + Retrieves the base MAC address for the chassis + Returns: + A string containing the MAC address in the format + 'XX:XX:XX:XX:XX:XX' + """ + return self._eeprom.base_mac_addr('') + + def get_model(self): + """ + Retrieves the model number (or part number) of the chassis + Returns: + string: Model/part number of chassis + """ + return self._eeprom.part_number_str() + + def get_serial_number(self): + """ + Retrieves the hardware serial number for the chassis + Returns: + A string containing the hardware serial number for this chassis. + """ + return self._eeprom.serial_number_str() + + def get_system_eeprom_info(self): + """ + Retrieves the full content of system EEPROM information for the chassis + Returns: + A dictionary where keys are the type code defined in + OCP ONIE TlvInfo EEPROM format and values are their corresponding + values. + """ + return self._eeprom.system_eeprom_info() + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + # not support any hardware reboot, just return REBOOT_CAUSE_NON_HARDWARE + # to keep reboot cause as software reboot + return (self.REBOOT_CAUSE_NON_HARDWARE, None) + + ############################################## + # System LED methods + ############################################## + + def set_status_led(self, color): + """ + Sets the state of the system LED + Args: + color: A string representing the color with which to set the + system LED + Returns: + bool: True if system LED state is set successfully, False if not + """ + return False + + def get_status_led(self): + """ + Gets the state of the system LED + Returns: + A string, one of the valid LED color strings which could be vendor + specified. + """ + raise NotImplementedError + + ############################################## + # Other methods + ############################################## + + def init_global_port_presence(self): + for port_num in range(0, self.platdev.get_sfp_num()): + presence = self._sfp_list[port_num].get_presence() + self._global_port_pres_dict[port_num] = '1' if presence else '0' + + def get_change_event(self, timeout=0): + """ + Returns a nested dictionary containing all devices which have + experienced a change at chassis level + Args: + timeout: Timeout in milliseconds (optional). If timeout == 0, + this method will block until a change is detected. + Returns: + (bool, dict): + - True if call successful, False if not; + - A nested dictionary where key is a device type, + value is a dictionary with key:value pairs in the format of + {'device_id':'device_event'}, + where device_id is the device ID for this device and + device_event, + status='1' represents device inserted, + status='0' represents device removed. + Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0'}} + indicates that fan 0 has been removed, fan 2 + has been inserted and sfp 11 has been removed. + Specifically for SFP event, besides SFP plug in and plug out, + there are some other error event could be raised from SFP, when + these error happened, SFP eeprom will not be avalaible, XCVRD shall + stop to read eeprom before SFP recovered from error status. + status='2' I2C bus stuck, + status='3' Bad eeprom, + status='4' Unsupported cable, + status='5' High Temperature, + status='6' Bad cable. + """ + port_dict = {} + while True: + for port_num in range(0, self.platdev.get_sfp_num()): + presence = self._sfp_list[port_num].get_presence() + if(presence and self._global_port_pres_dict[port_num] == '0'): + self._global_port_pres_dict[port_num] = '1' + port_dict[port_num] = '1' + elif(not presence and + self._global_port_pres_dict[port_num] == '1'): + self._global_port_pres_dict[port_num] = '0' + port_dict[port_num] = '0' + + if len(port_dict) > 0: + return True, {'sfp': port_dict} + + time.sleep(1) + + def sfp_debugger(self): + """ + Try to show all parameters read from eeprom with sfp methods + """ + print("SFP EEPROM data:") + for sfp_n in range(0, len(self._sfp_list)): + print("======SFP{}==TYPE {}====".format( + sfp_n, self._sfp_list[sfp_n].sfp_type)) + print("get_transceiver_info:") + print(self._sfp_list[sfp_n].get_transceiver_info()) + print(" ") + + print("get_transceiver_threshold_info:") + print(self._sfp_list[sfp_n].get_transceiver_threshold_info()) + print(" ") + + print("get_transceiver_bulk_status:") + print(self._sfp_list[sfp_n].get_transceiver_bulk_status()) + print(" ") + + print("get_lpmode:") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_lpmode())) + # set_lpmode + + print("get_power_override:") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_power_override())) + + print("get_temperature:") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_temperature())) + + print("get_voltage") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_voltage())) + + print("get_tx_bias") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_tx_bias())) + + print("get_rx_power") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_rx_power())) + + print("get_tx_power") + for sfp_n in range(0, len(self._sfp_list)): + print("\tsfp{}: {}".format( + sfp_n, self._sfp_list[sfp_n].get_tx_power())) diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/component.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/component.py new file mode 100644 index 0000000000..5b580a62a2 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/component.py @@ -0,0 +1,100 @@ +######################################################################## +# Module contains an implementation of SONiC Platform Base API and +# provides the Components' (e.g., BIOS, CPLD, FPGA, etc.) available in +# the platform +# +######################################################################## + +try: + import os + from sonic_platform_base.component_base import ComponentBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" + + +class Component(ComponentBase): + def __init__(self, idx, name, descript): + self.index = idx + self.name = name + self.description = descript + + def _get_cpld_register(self, syspath): + rv = 'ERR' + if (not os.path.isfile(syspath)): + return rv + # noinspection PyBroadException + try: + with open(syspath, 'r') as fd: + rv = fd.read() + except Exception as error: + rv = 'ERR' + rv = rv.rstrip('\r\n') + rv = rv.lstrip(" ") + return rv + + def _get_bios_version(self): + # Retrieves the BIOS firmware version + try: + with open(BIOS_VERSION_PATH, 'r') as fd: + bios_version = fd.read() + return bios_version.strip() + except Exception as e: + return None + + def _get_cpld_version(self, cpld_number): + cpld_version_reg = { + 1: "/sys/class/hwmon/hwmon2/device/NBA715_SYS/cpld_30_ver", + 2: "master_cpld_ver", + 3: "slave_cpld_ver" + } + + cpld_version = self._get_cpld_register(cpld_version_reg[cpld_number]) + + if cpld_version != 'ERR': + return cpld_version[-4:] + + return 'NA' + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return self.name + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return self.description + + def get_firmware_version(self): + """ + Retrieves the firmware version of the component + Returns: + A string containing the firmware version of the component + """ + if self.index == 0: + bios_ver = self._get_bios_version() + if not bios_ver: + return 'NA' + + return bios_ver + + elif self.index <= 3: + return self._get_cpld_version(self.index) + + def install_firmware(self, image_path): + """ + Installs firmware to the component + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install was successful, False if not + """ + return False diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/eeprom.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/eeprom.py new file mode 100644 index 0000000000..a4c34c1c86 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/eeprom.py @@ -0,0 +1,108 @@ +try: + import sys + import re + if sys.version_info.major == 3: + from io import StringIO + else: + from cStringIO import StringIO + from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): + + EEPROM_DECODE_HEADLINES = 6 + + def __init__(self): + self._eeprom_path = "/sys/bus/i2c/drivers/NBA_715_i2c/0-0030/eeprom" + super(Eeprom, self).__init__(self._eeprom_path, 0, '', True) + self._eeprom = self._load_eeprom() + + def __parse_output(self, decode_output): + decode_output.replace('\0', '') + lines = decode_output.split('\n') + lines = lines[self.EEPROM_DECODE_HEADLINES:] + _eeprom_info_dict = dict() + + for line in lines: + match = re.search( + '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line) + if match is not None: + idx = match.group(1) + value = match.group(3).rstrip('\0') + _eeprom_info_dict[idx] = value + return _eeprom_info_dict + + def _load_eeprom(self): + original_stdout = sys.stdout + sys.stdout = StringIO() + err = self.read_eeprom_db() + if err: + pass + else: + decode_output = sys.stdout.getvalue() + sys.stdout = original_stdout + return self.__parse_output(decode_output) + + status = self.check_status() + if status < 'ok': + return {} + + data = self.read_eeprom() + if data is None: + return 0 + + self.decode_eeprom(data) + decode_output = sys.stdout.getvalue() + sys.stdout = original_stdout + + (is_valid, valid_crc) = self.is_checksum_valid(data) + if not is_valid: + return {} + + return self.__parse_output(decode_output) + + def get_eeprom(self): + return self._eeprom + + def serial_number_str(self): + """ + Returns the serial number + """ + return self._eeprom.get('0x23', "Undefined.") + + def base_mac_addr(self, e): + """ + Returns the base mac address found in the system EEPROM + """ + return self._eeprom.get('0x24', "Undefined.") + + def modelstr(self): + """ + Returns the Model name + """ + return self._eeprom.get('0x28', "Undefined.") + + def part_number_str(self): + """ + Returns the part number + """ + return self._eeprom.get('0x22', "Undefined.") + + def revision_str(self): + """ + Returns the device revision + """ + return self._eeprom.get('0x26', "Undefined.") + + def serial_str(self): + return self._eeprom.get('0x2F', "Undefined.") + + def system_eeprom_info(self): + """ + Returns a dictionary, where keys are the type code defined in + ONIE EEPROM format and values are their corresponding values + found in the system EEPROM. + """ + return self._eeprom diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/fan.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/fan.py new file mode 100644 index 0000000000..2f706d4cd5 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/fan.py @@ -0,0 +1,152 @@ +try: + from sonic_py_common.logger import Logger + from sonic_platform_base.fan_base import FanBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +SYSLOG_IDENTIFIER = 'thermalctld' +logger = Logger(SYSLOG_IDENTIFIER) + +FAN_POSITION_NAME = ["Front", "Rear"] + + +class Fan(FanBase): + """Platform-specific Fan class""" + + def __init__(self, fan_index, position_index, attr_path, psu_fan=False): + # fan_index: the index of a fan module belongs to + # position_index : position of the fan in a fan module, 0 -> front, 1 -> rear, + # position_index : index of PSU belongs to if psu_fan is True, start from 0 + super(Fan, self).__init__() + self.index = fan_index + 1 + self.position = position_index + self.is_psu_fan = psu_fan + self.attr_path = attr_path[0] + + if psu_fan is True: + self.fan_name = "PSU{}_FAN{}".format(self.index, self.position+1) + self.speed_file = attr_path[1] + else: + self.fan_name = "FAN{}-{}".format(self.index, + FAN_POSITION_NAME[self.position]) + + def __read_attr_file(self, filepath, line=0xFF): + try: + with open(filepath, 'r') as fd: + if line == 0xFF: + data = fd.read() + return data.rstrip('\r\n') + else: + data = fd.readlines() + return data[line].rstrip('\r\n') + except FileNotFoundError: + logger.log_error(f"File {filepath} not found. Aborting") + except OSError as ex: + logger.log_error("Cannot open - {}: {}".format(filepath, repr(ex))) + + return None + + def get_presence(self): + if self.is_psu_fan is True: + data = self.__read_attr_file( + self.attr_path + 'psu{}_prnt'.format(self.index)) + return data == '1' + + ret = self.__read_attr_file( + self.attr_path + 'fan{}_present'.format(self.index)) + return ret == '1' + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return self.fan_name + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + return self.FAN_DIRECTION_NOT_APPLICABLE + + def get_status(self): + if self.is_psu_fan is True: + data = self.__read_attr_file( + self.attr_path + 'psu{}_good'.format(self.index)) + return data == '1' + data = self.__read_attr_file( + self.attr_path + 'fan{}_stat'.format(self.index)) + + return data == '1' + + def get_speed(self): + """ + Retrieves the speed of fan as a percentage of full speed + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if self.is_psu_fan is True and self.get_presence(): + speed = self.__read_attr_file(self.speed_file, 0) + if speed is not None: + return (int(speed)*100)//16000 + + return 0 + + if self.get_presence(): + if self.position == 0: + speed_file = self.attr_path + \ + 'fan{}_front_rpm'.format(self.index) + else: + speed_file = self.attr_path + \ + 'fan{}_rear_rpm'.format(self.index) + data = self.__read_attr_file(speed_file) + if data is not None: + for sdata in data.split(' '): + if sdata.isdigit(): + return (int(sdata)*100)//18000 + return 0 + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + return self.get_speed() + + def get_speed_tolerance(self): + """ + Retrieves the speed tolerance of the fan + Returns: + An integer, the percentage of variance from target speed which is + considered tolerable + """ + return 10 + + def set_speed(self, speed): + """ + Sets the fan speed + Args: + speed: An integer, the percentage of full fan speed to set fan to, + in the range 0 (off) to 100 (full speed) + Returns: + A boolean, True if speed is set successfully, False if not + """ + return False + + def set_status_led(self, color): + """ + Sets the state of the fan module status LED + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + return False diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platDev.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platDev.py new file mode 100644 index 0000000000..5686153806 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platDev.py @@ -0,0 +1,408 @@ +#!/usr/bin/env python + +try: + import os + import copy + from sonic_py_common.logger import Logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +logger = Logger("platDev") +PLATFORM_NAME = "aurora-715" +MAX_FAN_MODULE = 5 +MAX_FAN = 2 + +THERMAL_SENSOR_LIST = [ + { + 'name': "pch_haswell", + 'temp_index': [1], + 'sysfile_path': "/sys/class/hwmon/hwmon0/", + 'support_mask': 0x81, + 'ext_sysfile_list': None + }, + { + 'name': "CPU core temp", + 'temp_index': [1, 2], + 'sysfile_path': "/sys/class/hwmon/hwmon1/", + 'support_mask': 0x8B, + 'ext_sysfile_list': None + }, + { + 'name': "NCT7511Y(U73)", + 'temp_index': [1, 2], + 'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/", + 'support_mask': 0x0F, + 'ext_sysfile_list': {1: ['temp_r_b_f', 'temp_r_b_f_max', 'temp_r_b_f_min', 'temp_r_b_f_crit', 'temp_r_b_f_lcrit'], + 2:['temp_r_b_b', 'temp_r_b_b_max', 'temp_r_b_b_min', 'temp_r_b_b_crit', 'temp_r_b_b_lcrit']} + }, + { + 'name': "G781(U94)", + 'temp_index': [1, 2], + 'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/", + 'support_mask': 0x0F, + 'ext_sysfile_list': {1: ['temp_l_b_f', 'temp_l_b_f_max', 'temp_l_b_f_min', 'temp_l_b_f_crit', 'temp_l_b_f_lcrit'], + 2:['temp_l_b_b', 'temp_l_b_b_max', 'temp_l_b_b_min', 'temp_l_b_b_crit', 'temp_l_b_b_lcrit']} + }, + { + 'name': "G781(U34)", + 'temp_index': [1, 2], + 'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/", + 'support_mask': 0x0F, + 'ext_sysfile_list': {1: ['temp_r_t_f', 'temp_r_t_f_max', 'temp_r_t_f_min', 'temp_r_t_f_crit', 'temp_r_t_f_lcrit'], + 2:['temp_r_t_b', 'temp_r_t_b_max', 'temp_r_t_b_min', 'temp_r_t_b_crit', 'temp_r_t_b_lcrit']} + }, + { + 'name': "G781(U4)", + 'temp_index': [1, 2], + 'sysfile_path': "/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/", + 'support_mask': 0x0F, + 'ext_sysfile_list': {1: ['temp_l_t_f', 'temp_l_t_f_max', 'temp_l_t_f_min', 'temp_l_t_f_crit', 'temp_l_t_f_lcrit'], + 2:['temp_l_t_b', 'temp_l_t_b_max', 'temp_l_t_b_min', 'temp_l_t_b_crit', 'temp_l_t_b_lcrit']} + } +] + +# PSU LIST +# ext_sysfile_list +# [0] : sysfile path for present +# [1] : sysfile path for status +# +PSU_LIST = ['PSU1', 'PSU2'] + +PSU_INFO = { + 'PSU1': { + 'attr_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/", + 'status_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/" + }, + 'PSU2': { + 'attr_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/", + 'status_path': "/sys/class/hwmon/hwmon2/device/NBA715_POWER/" + } +} + +FAN_LIST = ['FAN1', 'FAN2', 'FAN3', 'FAN4', 'FAN5'] + +FAN_INFO = { + 'FAN1': { + 'isdraw': True, + 'fan_num': 2, + 'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/' + }, + 'FAN2': { + 'isdraw': True, + 'fan_num': 2, + 'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/' + }, + 'FAN3': { + 'isdraw': True, + 'fan_num': 2, + 'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/' + }, + 'FAN4': { + 'isdraw': True, + 'fan_num': 2, + 'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/' + }, + 'FAN5': { + 'isdraw': True, + 'fan_num': 2, + 'attr_path': '/sys/class/hwmon/hwmon2/device/NBA715_FAN/' + } +} + + +# SFP LIST +# +# +# 0: QSFP +# 1: SFP +# sfp not port on 715 platform + +SFP_EXT_SYSFILE_LIST = ["/sys/class/hwmon/hwmon2/device/NBA715_QSFP/", ""] + +SFP_GROUP_LIST = ['SFP-G01', 'SFP-G02', 'SFP-G03', 'SFP-G04'] + +PORT_NUM = 32 + +# SFP-eeprom paths /sys/bus/i2c/devices/XX-0050 + +I2C_DEVICES = { + # NCT7511Y sensor & fan control + 'NCT7511Y(U73)': { + 'parent': 'viaBMC', + 'parent_ch': 0, + 'driver': 'nct7511', + 'i2caddr': '0x2e', + 'path': ' ', + 'status': 'NOTINST' + }, + # G781 sensors + 'G781(U94)': { + 'parent': 'viaBMC', + 'parent_ch': 1, + 'driver': 'g781', + 'i2caddr': '0x4c', + 'path': ' ', + 'status': 'NOTINST' + }, + 'G781(U4)': { + 'parent': 'viaBMC', + 'parent_ch': 2, + 'driver': 'g781', + 'i2caddr': '0x4c', + 'path': ' ', + 'status': 'NOTINST' + }, + 'G781(U34)': { + 'parent': 'viaBMC', + 'parent_ch': 3, + 'driver': 'g781', + 'i2caddr': '0x4c', + 'path': ' ', + 'status': 'NOTINST' + }, + # PSU + 'PSU1': { + 'parent': 'viaBMC', + 'parent_ch': 4, + 'driver': 'zrh2800k2', + 'i2caddr': '0x58', + 'path': ' ', + 'status': 'NOTINST' + }, + 'PSU2': { + 'parent': 'viaBMC', + 'parent_ch': 4, + 'driver': 'zrh2800k2', + 'i2caddr': '0x59', + 'path': ' ', + 'status': 'NOTINST' + }, + 'TPS53681(0x6C)': { + 'parent': 'viaBMC', + 'parent_ch': 5, + 'driver': 'tps53679', + 'i2caddr': '0x6c', + 'path': ' ', + 'status': 'NOTINST' + }, + 'TPS53681(0x6E)': { + 'parent': 'viaBMC', + 'parent_ch': 5, + 'driver': 'tps53679', + 'i2caddr': '0x6e', + 'path': ' ', + 'status': 'NOTINST' + }, + 'TPS53681(0x70)': { + 'parent': 'viaBMC', + 'parent_ch': 5, + 'driver': 'tps53679', + 'i2caddr': '0x70', + 'path': ' ', + 'status': 'NOTINST' + } +} + + +SFP_GROUPS = { + 'SFP-G01': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_1', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/9-0050", "/sys/bus/i2c/devices/10-0050", + "/sys/bus/i2c/devices/11-0050", "/sys/bus/i2c/devices/12-0050", + "/sys/bus/i2c/devices/13-0050", "/sys/bus/i2c/devices/14-0050", + "/sys/bus/i2c/devices/15-0050", "/sys/bus/i2c/devices/16-0050"], + 'status': 'NOTINST' + }, + 'SFP-G02': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_2', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/17-0050", "/sys/bus/i2c/devices/18-0050", + "/sys/bus/i2c/devices/19-0050", "/sys/bus/i2c/devices/20-0050", + "/sys/bus/i2c/devices/21-0050", "/sys/bus/i2c/devices/22-0050", + "/sys/bus/i2c/devices/23-0050", "/sys/bus/i2c/devices/24-0050"], + 'status': 'NOTINST' + }, + 'SFP-G03': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_3', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/25-0050", "/sys/bus/i2c/devices/26-0050", + "/sys/bus/i2c/devices/27-0050", "/sys/bus/i2c/devices/28-0050", + "/sys/bus/i2c/devices/29-0050", "/sys/bus/i2c/devices/30-0050", + "/sys/bus/i2c/devices/31-0050", "/sys/bus/i2c/devices/32-0050"], + 'status': 'NOTINST' + }, + 'SFP-G04': { + "type": "QSFP28", + 'number': 8, + 'parent': 'PCA9548_0x71_4', + 'channels': [0, 1, 2, 3, 4, 5, 6, 7], + 'driver': 'optoe1', + 'i2caddr': '0x50', + 'paths': ["/sys/bus/i2c/devices/33-0050", "/sys/bus/i2c/devices/34-0050", + "/sys/bus/i2c/devices/35-0050", "/sys/bus/i2c/devices/36-0050", + "/sys/bus/i2c/devices/37-0050", "/sys/bus/i2c/devices/38-0050", + "/sys/bus/i2c/devices/39-0050", "/sys/bus/i2c/devices/40-0050"], + 'status': 'NOTINST' + } +} + +# Component +# ["Master-CPLD", ("Used for managing Fan, PSU, system LEDs, QSFP " +# "modules (1-16)")], +# ["Slave-CPLD", "Used for managing QSFP modules (17-32)"] + +CHASSIS_COMPONENTS = [ + ["BIOS", ("Performs initialization of hardware components during " + "booting")], + ["System-CPLD", "Used for managing CPU board devices and power"] +] + + +class PlatDev(): + def __init__(self): + self.plat_name = PLATFORM_NAME + self.psu_info = copy.deepcopy(PSU_INFO) + self.thermal_info = [] + self.fan_info = copy.deepcopy(FAN_INFO) + self.sfp_info = copy.deepcopy(SFP_GROUPS) + + # get install info + # self.sfp_install_info = SFP_GROUPS + self.device_install_info = I2C_DEVICES + + # update path info with install info + # Item 1/2 not changed, append directly + self.thermal_info.append(THERMAL_SENSOR_LIST[0]) + self.thermal_info.append(THERMAL_SENSOR_LIST[1]) + + def __read_attr_file(self, filepath, line=0xFF): + try: + with open(filepath, 'r') as fd: + if line == 0xFF: + data = fd.read() + return data.rstrip('\r\n') + else: + data = fd.readlines() + return data[line].rstrip('\r\n') + except FileNotFoundError: + logger.log_error(f"File {filepath} not found. Aborting") + except OSError as ex: + logger.log_error("Cannot open - {}: {}".format(filepath, repr(ex))) + + return None + + def bmc_is_exist(self): + bmc_filePath = '/sys/class/hwmon/hwmon2/device/NBA715_SYS/bmc_present' + if os.path.exists(bmc_filePath): + value = self.__read_attr_file(bmc_filePath) + if int(value) == 1: + return True + else: + return False + else: + return False + ######Componet method ##### + + def get_component_count(self): + return len(CHASSIS_COMPONENTS) + + def get_component_name(self, idx): + return CHASSIS_COMPONENTS[idx][0] + + def get_component_descript(self, idx): + return CHASSIS_COMPONENTS[idx][1] + + ###### PSU method ###### + def get_psu_list(self): + return PSU_LIST + + def get_psu_info_all(self): + return self.psu_info + + def get_psu_info_by_name(self, name): + return self.psu_info.get(name) + + def get_psu_attr_path_by_name(self, name): + return self.psu_info[name].get('attr_path') + + def get_psu_status_path_by_name(self, name): + return self.psu_info[name].get('status_path') + + ###### Thermal method ###### + def get_thermal_dev_info_all(self): + return self.thermal_info + + def get_thermal_dev_name_by_idx(self, index): + return self.thermal_info[index].get('name') + + def get_thermal_dev_tempidx_by_idx(self, index): + return self.thermal_info[index].get('temp_index') + + def get_thermal_dev_sysfile_path_by_idx(self, index): + return self.thermal_info[index].get('sysfile_path') + + def get_thermal_dev_support_mask_by_idx(self, index): + return self.thermal_info[index].get('support_mask') + + def get_thermal_dev_ext_sysfile_list_by_idx(self, index): + return self.thermal_info[index].get('ext_sysfile_list') + + ###### Fan method ###### + def get_fan_support(self): + return True + + def get_fan_list(self): + return FAN_LIST + + def get_fan_info_all(self): + return self.fan_info + + def get_fan_info_by_name(self, name): + return self.fan_info.get(name) + + def get_fan_sysfile_path_by_name(self, name): + return self.fan_info[name].get('attr_path') + + def get_fan_is_draw_by_name(self, name): + return self.fan_info[name].get('isdraw') + + def get_fan_num_by_name(self, name): + return self.fan_info[name].get('fan_num') + + ###### SFP method ###### + def get_sfp_num(self): + return PORT_NUM + + def get_sfp_group_list(self): + return SFP_GROUP_LIST + + def get_sfp_group_info(self): + return self.sfp_info + + def get_sfp_group_info_by_name(self, name): + return self.sfp_info.get(name) + + def get_sfp_group_type_by_name(self, name): + return self.sfp_info[name].get('type') + + def get_sfp_group_path_by_name(self, name): + return self.sfp_info[name].get('paths') + + def get_sfp_group_number_by_name(self, name): + return self.sfp_info[name].get('number') + + def get_sfp_ext_sysfile_list(self): + return SFP_EXT_SYSFILE_LIST diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platform.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platform.py new file mode 100644 index 0000000000..6e1a90132a --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/platform.py @@ -0,0 +1,19 @@ +############################################################################# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + """Platform-specific Platform class""" + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/psu.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/psu.py new file mode 100644 index 0000000000..986267bf3f --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/psu.py @@ -0,0 +1,196 @@ +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +try: + from sonic_platform_base.psu_base import PsuBase + from sonic_py_common.logger import Logger + from sonic_platform.fan import Fan +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +SYSLOG_IDENTIFIER = 'thermalctld' +logger = Logger(SYSLOG_IDENTIFIER) + +# To do: should be defined in platDev +PSU_MAX_VOUT = 12.0 # voltage +PSU_MIN_VOUT = 3.3 # voltage +PSU_MAX_TEMP = 50.0 # C + + +class Psu(PsuBase): + """Platform-specific Psu class""" + + def __init__(self, index, info_list, is_bmc): + PsuBase.__init__(self) + self.index = index + self.is_bmc = is_bmc + self.attr_path = info_list[0] + self.status_path = info_list[1] + if is_bmc: + speed_file = self.attr_path + 'psu{}_fan_speed'.format(index+1) + else: + speed_file = self.attr_path + 'psu_fan_speed_1' + + fan = Fan(index, 0, [self.status_path, speed_file], True) + self._fan_list.append(fan) + self.psu_name = "PSU{}".format(self.index+1) + + def __read_attr_file(self, filepath, line=0xFF): + try: + with open(filepath, 'r') as fd: + if line == 0xFF: + data = fd.read() + return data.rstrip('\r\n') + else: + data = fd.readlines() + return data[line].rstrip('\r\n') + except FileNotFoundError: + logger.log_error(f"File {filepath} not found. Aborting") + except OSError as ex: + logger.log_error("Cannot open - {}: {}".format(filepath, repr(ex))) + + return None + + def get_name(self): + return self.psu_name + + def get_presence(self): + """ + Retrieves the presence status of power supply unit (PSU) defined + Returns: + bool: True if PSU is present, False if not + """ + data = self.__read_attr_file( + self.status_path + 'psu{}_prnt'.format(self.index+1)) + if data == '1': + return True + else: + return False + + def get_powergood_status(self): + """ + Retrieves the powergood status of PSU + Returns: + A boolean, True if PSU has stablized its output voltages and passed all + its internal self-tests, False if not. + """ + data = self.__read_attr_file( + self.status_path + 'psu{}_good'.format(self.index+1)) + if data == '1': + return True + else: + return False + + def get_voltage(self): + """ + Retrieves current PSU voltage output + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + if self.is_bmc: + path = self.attr_path + 'psu{}_vout'.format(self.index+1) + else: + path = self.attr_path + "/psu_vout" + vout = self.__read_attr_file(path, 0) + if vout is not None: + return float(vout) / 1000 + + return False + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + Returns: + A float number, the electric current in amperes, e.g 15.4 + """ + if self.is_bmc: + path = self.attr_path + 'psu{}_iout'.format(self.index+1) + else: + path = self.attr_path + "/psu_iout" + iout = self.__read_attr_file(path, 0) + if iout is not None: + return float(iout) / 1000 + return False + + def get_power(self): + """ + Retrieves current energy supplied by PSU + Returns: + A float number, the power in watts, e.g. 302.6 + """ + if self.is_bmc: + path = self.attr_path + 'psu{}_pout'.format(self.index+1) + else: + path = self.attr_path + "/psu_pout" + pout = self.__read_attr_file(path, 0) + if pout is not None: + return float(pout) / 1000000 + return False + + def set_status_led(self, color): + """ + Sets the state of the PSU status LED + Args: + color: A string representing the color with which to set the + PSU status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + raise NotImplementedError + + def get_status_led(self): + """ + Gets the state of the PSU status LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + raise NotImplementedError + + def get_temperature(self): + """ + Retrieves current temperature reading from PSU + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + if self.is_bmc: + path = self.attr_path+'psu{}_temp'.format(self.index+1) + else: + path = self.attr_path + "/psu_temp_1" + temperature = self.__read_attr_file(path, 0) + if temperature is not None: + return float(temperature) / 1000 + + return False + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + Returns: + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + return PSU_MAX_TEMP + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + return PSU_MAX_VOUT + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + return PSU_MIN_VOUT diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/sfp.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/sfp.py new file mode 100644 index 0000000000..57c349d8bd --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/sfp.py @@ -0,0 +1,1251 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +try: + from sonic_platform_base.sfp_base import SfpBase + from sonic_py_common.logger import Logger + from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId + from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom + from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId + from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +logger = Logger("sfp") + +############################################################################# +# +# SFP : +# 2 wire address 1010000x (A0h) (i2c 0x50) +# ------------------------------------------------ 0 +# | Serial ID Defined by SFP MSA (96 bytes) | <-- get_transceiver_info +# |----------------------------------------------| 95 +# | Vendor Specific (32 bytes) | +# |----------------------------------------------| 127 +# | Reserved, SFF-8079 (128 byte) | +# ------------------------------------------------ 255 +# +# 2 wire address 1010001x (A2h) (i2c 0x51) +# ------------------------------------------------ 0 +# | Alarm and Warning Threshold (56 bytes) | <-- get_transceiver_threshold_info +# |----------------------------------------------| 55 +# | Cal Constants (40 bytes) | +# |----------------------------------------------| 95 +# | Real Time Diagnostic Interface(24 bytes) | <-- get_transceiver_bulk_status +# |----------------------------------------------| 119 +# | Vendor Specific (7 bytes) | +# |----------------------------------------------| 126 +# | Page Select Byte (Optional) | -> select one of the below pages as +# ------------------------------------------------ 127 address 128-255 +# +# Page 00h/01h +# |----------------------------------------------| 128 +# | User Writeable EEPROM (120 bytes) | +# |----------------------------------------------| 247 +# | Vendor Specific (8 bytes) | +# ------------------------------------------------ 255 +# Page 02h +# |----------------------------------------------| 128 +# | Control Function (128 bytes) | +# ------------------------------------------------ 255 +# Page 03h-7Fh +# |----------------------------------------------| 128 +# | Reserved (128 bytes) | +# ------------------------------------------------ 255 +# Page 80h-FFh +# |----------------------------------------------| 128 +# | Vendor Specific (128 bytes) | +# ------------------------------------------------ 255 +# +# ========================================================== +# QSFP : +# 2 wire address 1010000x (A0h) (i2c 0x50) +# +# ------------------------------------------------ 0 +# | ID and status (3 bytes) | +# |----------------------------------------------| 2 +# | Interrupt Flags (19 bytes) | +# |----------------------------------------------| 21 +# | Module Monitors (12 bytes) | <-- get_transceiver_bulk_status +# |----------------------------------------------| 33 +# | Channel Monitors (12 bytes) | +# |----------------------------------------------| 81 +# | Reserved (4 bytes) | +# |----------------------------------------------| 85 +# | Control (12 bytes) | <- get_power_override +# |----------------------------------------------| 97 +# | ~~~ | +# |----------------------------------------------| 126 +# | Page Select Byte | -> select one of the below pages as +# ------------------------------------------------ 127 address 128-255 +# +# +# Page 00h +# |----------------------------------------------| 128 +# | Base ID Filed (64 bytes) | <-- get_transceiver_info +# |----------------------------------------------| 191 +# | Extended ID (32 bytes) | +# |----------------------------------------------| 223 +# | Vendor Specific ID (8 bytes) | +# ------------------------------------------------ 255 +# Page 01h (optional) +# |----------------------------------------------| 128 +# | ~~~~ (128 bytes) | +# ------------------------------------------------ 255 +# Page 02h (optional) +# |----------------------------------------------| 128 +# | User EEPROM Data (128 bytes) | +# ------------------------------------------------ 255 + +# Page 03h (optional on QSFP28) +# |----------------------------------------------| 128 +# | Module Threshold (48 bytes) | <-- get_transceiver_threshold_info +# |----------------------------------------------| 175 +# | Channel Threshold (48 bytes) | +# |----------------------------------------------| 223 +# | Reserved (2 bytes) | +# |----------------------------------------------| 225 +# | Vendor Specific Channel Controls (16 bytes) | +# |----------------------------------------------| 241 +# | Channel Monitor Masks (12 bytes) | +# |----------------------------------------------| 253 +# | Reserved (2 bytes) | +# ------------------------------------------------ 255 +# +############################################################################# + +# function eunm +SFP_GET_PRESENCE = 0 +SFP_RESET = 1 +SFP_GET_LOW_POWER_MODE = 2 +SFP_SET_LOW_POWER_MODE = 3 + +# XCVR type definition +SFP_TYPE = 0 +QSFP_TYPE = 1 + +SFP_TYPE_CODE_LIST = [ + '03' # SFP/SFP+/SFP28 +] +QSFP_TYPE_CODE_LIST = [ + '0d', # QSFP+ or later + '11' # QSFP28 or later +] + +# index for A0H, A2H sysfs file path +INDEX_A0H = 0 +INDEX_A2H = 1 + +# offset/width definition +OFFSET = 0 +WIDTH = 1 + +QSFP_UPPER_MEMORY_PAGE00_OFFSET = 128 +QSFP_UPPER_MEMORY_PAGE03_OFFSET = 512 + +SFP_A0H_OFFSET = 0 +SFP_A2H_OFFSET = 0 + +XCVR_DOM_CAPABILITY_OFFSET = 92 +XCVR_DOM_CAPABILITY_WIDTH = 2 +ID_FIELD_WIDTH = 92 + +QSFP_VERSION_COMPLIANCE_OFFSET = 1 +QSFP_VERSION_COMPLIANCE_WIDTH = 1 +QSFP_INTERFACE_BULK_WIDTH = 20 +QSFP_OPTION_VALUE_OFFSET = 192 +QSFP_OPTION_VALUE_WIDTH = 4 +QSFP_ID_FIELDS = { + # NAME : [OFFSET:WIDTH] + 'TYPE': [0, 1], + 'EXTID': [1, 1], + 'CONNECTOR': [2, 1], + 'XCVR_COMPLIANCE': [3, 8], + 'ENCODING': [11, 1], + 'NORMAL_BITRATE': [12, 1], + 'EXT_RATE_SEL_COMPLIANCE': [13, 1], + 'CABLE_LEN': [14, 5], + 'DEVICE_TECH': [19, 1], + 'VENDOR_NAME': [20, 16], + 'EXT_XCVR_CODE': [36, 1], + 'VENDOR_OUI': [37, 3], + 'VENDOR_PN': [40, 16], + 'VENDOR_REV': [56, 2], + 'WAVELENGTH': [58, 2], + 'WAVELENGTH_TOLERANCE': [60, 2], + 'MAX_CASE_TEMP': [62, 1], + 'CC_BASE': [63, 1], + 'OPTIONS': [64, 4], + 'VENDOR_SN': [68, 16], + 'VENDOR_DATE': [84, 8], + # DOM + 'TEMPERATURE': [22, 2], + 'VOLTAGE': [26, 2], + 'CHANNEL_MON': [34, 24], + 'CONTROL': [86, 12], + # PAGE03 + 'MODULE_THRESHOLD': [0, 24], + 'CHANNEL_THRESHOLD': [50, 24] +} +SFP_INTERFACE_BULK_WIDTH = 21 +SFP_ID_FIELDS = { + # NAME : [OFFSET:WIDTH] + 'TYPE': [0, 1], + 'EXTID': [1, 1], + 'CONNECTOR': [2, 1], + 'XCVR_COMPLIANCE': [3, 8], + 'ENCODING': [11, 1], + 'NORMAL_BITRATE': [12, 1], + 'EXT_RATE_SEL_COMPLIANCE': [13, 1], + 'CABLE_LEN': [14, 6], + 'VENDOR_NAME': [20, 16], + 'EXT_XCVR_CODE': [36, 1], + 'VENDOR_OUI': [37, 3], + 'VENDOR_PN': [40, 16], + 'VENDOR_REV': [56, 4], + 'WAVELENGTH': [60, 2], + # UNALLOCATED WIDDTH: 1 + 'CC_BASE': [63, 1], + 'OPTIONS': [64, 2], + 'BITRATE_MAX': [66, 1], + # BITRATE_MAX ?? + 'BITRATE_MAX_1': [67, 1], + 'VENDOR_SN': [68, 16], + 'VENDOR_DATE': [84, 8], + # DOM + 'TEMPERATURE': [96, 2], + 'VOLTAGE': [98, 2], + 'CHANNEL_MON': [100, 6], + 'MODULE_THRESHOLD': [0, 40] +} + + +qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', + 'Length OM2(m)', 'Length OM1(m)', + 'Length Cable Assembly(m)') + +sfp_cable_length_tup = ('LengthSMFkm-UnitsOfKm', 'LengthSMF(UnitsOf100m)', + 'Length50um(UnitsOf10m)', 'Length62.5um(UnitsOfm)', + 'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)') + +sfp_compliance_code_tup = ('10GEthernetComplianceCode', 'InfinibandComplianceCode', + 'ESCONComplianceCodes', 'SONETComplianceCodes', + 'EthernetComplianceCodes', 'FibreChannelLinkLength', + 'FibreChannelTechnology', 'SFP+CableTechnology', + 'FibreChannelTransmissionMedia', 'FibreChannelSpeed') + +qsfp_compliance_code_tup = ('10/40G Ethernet Compliance Code', 'SONET Compliance codes', + 'SAS/SATA compliance codes', 'Gigabit Ethernet Compliant codes', + 'Fibre Channel link length/Transmitter Technology', + 'Fibre Channel transmission media', 'Fibre Channel Speed') + + +class Sfp(SfpBase): + """Platform-specific Sfp class""" + + def __init__(self, index, eeprom_path_list, sfp_type, ext_sysfile_list=None): + # index: port index, start from 0 + # eeprom_path_list : a list of path to eeprom sysfile + # [0]: for 0x50 + # [1]: for 0x51 + # ext_sysfile_list: used to get other function of sfp + # [0]: present + # [1]: reset + # [2]: get lowpower mode + # [3]: set lowpower mode + # ext_sysfile_list[0]: QSFP path + # ext_sysfile_list[1]: SFP path + self.index = index + self.eeprom_path_list = eeprom_path_list + # self._get_sfp_type(sfp_type) + self.sfp_type = sfp_type + if self.sfp_type == QSFP_TYPE: + self.present_file = ext_sysfile_list[0] + \ + 'qsfp{}_present'.format(self.index) + self.reset_file = ext_sysfile_list[0] + \ + 'qsfp{}_reset'.format(self.index) + self.lp_file = ext_sysfile_list[0] + \ + 'qsfp{}_low_power'.format(self.index) + else: + self.present_file = ext_sysfile_list[1] + \ + 'sfp{}_present'.format(self.index) + self.reset_file = None + self.lp_file = None + + def _get_sfp_type(self, sfp_type): + ty = self._read_eeprom_bytes( + SFP_ID_FIELDS['TYPE'][OFFSET], SFP_ID_FIELDS['TYPE'][WIDTH], INDEX_A0H) + if ty is not None: + if ty[0] in SFP_TYPE_CODE_LIST: + self.sfp_type = SFP_TYPE + if ty[0] in QSFP_TYPE_CODE_LIST: + self.sfp_type = QSFP_TYPE + else: + self.sfp_type = sfp_type + logger.log_warning("Unreganized sfp type of module {} . unsupported, treated as specified type {}".format( + self.index, sfp_type)) + else: + self.sfp_type = sfp_type + + def _read_eeprom_bytes(self, offset, num_bytes, path_idx): + eeprom_raw = [] + + eeprom = None + + for i in range(0, num_bytes): + eeprom_raw.append("0x00") + + try: + eeprom = open( + self.eeprom_path_list[path_idx], mode="rb", buffering=0) + eeprom.seek(offset) + raw_data = eeprom.read(num_bytes) + for nb in range(0, len(raw_data)): + eeprom_raw[nb] = hex(ord(raw_data[nb]))[2:].zfill(2) + except Exception as ex: + logger.log_error("Fail to read eeprom {}".format( + self.eeprom_path_list[path_idx])) + logger.log_error(" {}".format(ex)) + if eeprom is not None: + eeprom.close() + return None + + return eeprom_raw + + def __read_attr_file(self, filepath, line=0xFF): + try: + with open(filepath, 'r') as fd: + if line == 0xFF: + data = fd.read() + return data.rstrip('\r\n') + else: + data = fd.readlines() + return data[line].rstrip('\r\n') + except Exception as ex: + logger.log_error( + "Unable to open {} due to {}".format(filepath, repr(ex))) + + return None + + def __write_attr_file(self, filepath, data): + try: + with open(filepath, 'w') as fd: + return fd.write(data) + except Exception as ex: + logger.log_error( + "Unable to open {} due to {}".format(filepath, repr(ex))) + return 0 + + def get_presence(self): + if self.present_file is not None: + data = self.__read_attr_file(self.present_file) + if data is not None: + if int(data) == 1: + return True + return False + + def _convert_string_to_num(self, value_str): + if "-inf" in value_str: + return '-inf' + elif "Unknown" in value_str: + return 'N/A' + elif 'dBm' in value_str: + t_str = value_str.rstrip('dBm') + return float(t_str) + elif 'mA' in value_str: + t_str = value_str.rstrip('mA') + return float(t_str) + elif 'C' in value_str: + t_str = value_str.rstrip('C') + return float(t_str) + elif 'Volts' in value_str: + t_str = value_str.rstrip('Volts') + return float(t_str) + else: + return 'N/A' + + def _dom_capability_detect(self): + if not self.get_presence(): + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + return + + if self.sfp_type == QSFP_TYPE: + self.calibration = 1 + sfpi_obj = sff8436InterfaceId() + if sfpi_obj is None: + self.dom_supported = False + offset = 128 + + # QSFP capability byte parse, through this byte can know whether it support tx_power or not. + # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, + # need to add more code for determining the capability and version compliance + # in SFF-8636 dom capability definitions evolving with the versions. + qsfp_dom_capability_raw = self._read_eeprom_bytes( + (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH, INDEX_A0H) + if qsfp_dom_capability_raw is not None: + qsfp_version_compliance_raw = self._read_eeprom_bytes( + QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH, INDEX_A0H) + qsfp_version_compliance = int( + qsfp_version_compliance_raw[0], 16) + qspf_dom_capability = int(qsfp_dom_capability_raw[0], 16) + if qsfp_version_compliance >= 0x08: + self.dom_temp_supported = (qspf_dom_capability & 0x20 != 0) + self.dom_volt_supported = (qspf_dom_capability & 0x10 != 0) + self.dom_rx_power_supported = ( + qspf_dom_capability & 0x08 != 0) + self.dom_tx_power_supported = ( + qspf_dom_capability & 0x04 != 0) + else: + self.dom_temp_supported = True + self.dom_volt_supported = True + self.dom_rx_power_supported = ( + qspf_dom_capability & 0x08 != 0) + self.dom_tx_power_supported = True + self.dom_supported = True + self.calibration = 1 + qsfp_option_value_raw = self._read_eeprom_bytes( + QSFP_OPTION_VALUE_OFFSET, QSFP_OPTION_VALUE_WIDTH, INDEX_A0H) + if qsfp_option_value_raw is not None: + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + self.optional_capability = sfpd_obj.parse_option_params( + qsfp_option_value_raw, 0) + self.dom_tx_disable_supported = self.optional_capability[ + 'data']['TxDisable']['value'] == 'On' + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + elif self.sfp_type == SFP_TYPE: + sfpi_obj = sff8472InterfaceId() + if sfpi_obj is None: + return None + sfp_dom_capability_raw = self._read_eeprom_bytes( + XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH, INDEX_A0H) + if sfp_dom_capability_raw is not None: + sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) + self.dom_supported = (sfp_dom_capability & 0x40 != 0) + if self.dom_supported: + self.dom_temp_supported = True + self.dom_volt_supported = True + self.dom_rx_power_supported = True + self.dom_tx_power_supported = True + if sfp_dom_capability & 0x20 != 0: + self.calibration = 1 + elif sfp_dom_capability & 0x10 != 0: + self.calibration = 2 + else: + self.calibration = 0 + else: + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + self.dom_tx_disable_supported = ( + int(sfp_dom_capability_raw[1], 16) & 0x40 != 0) + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + + def get_transceiver_info(self): + """ + Retrieves transceiver info of this SFP + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + type |1*255VCHAR |type of SFP + hardware_rev |1*255VCHAR |hardware version of SFP + serial |1*255VCHAR |serial number of the SFP + manufacturer |1*255VCHAR |SFP vendor name + model |1*255VCHAR |SFP model name + connector |1*255VCHAR |connector information + encoding |1*255VCHAR |encoding information + ext_identifier |1*255VCHAR |extend identifier + ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance + cable_length |INT |cable length in m + nominal_bit_rate |INT |nominal bit rate by 100Mbs + specification_compliance |1*255VCHAR |specification compliance + vendor_date |1*255VCHAR |vendor date + vendor_oui |1*255VCHAR |vendor OUI + ======================================================================== + """ + transceiver_info_dict_keys = [ + 'type', 'hardware_rev', + 'serial', 'manufacturer', + 'model', 'connector', + 'encoding', 'ext_identifier', + 'ext_rateselect_compliance', 'cable_type', + 'cable_length', 'nominal_bit_rate', + 'specification_compliance', 'vendor_date', + 'vendor_oui', 'application_advertisement'] + + transceiver_info_dict = dict.fromkeys( + transceiver_info_dict_keys, 'N/A') + + if self.sfp_type == QSFP_TYPE: + field_offset = QSFP_UPPER_MEMORY_PAGE00_OFFSET # upper memory map: Page 00h + Id_field = QSFP_ID_FIELDS + info_bulk_width = QSFP_INTERFACE_BULK_WIDTH + sfpi_obj = sff8436InterfaceId() + + elif self.sfp_type == SFP_TYPE: + # lower memory map: A0h (SFP i2c 0x50) + field_offset = SFP_A0H_OFFSET + Id_field = SFP_ID_FIELDS + info_bulk_width = SFP_INTERFACE_BULK_WIDTH + sfpi_obj = sff8472InterfaceId() + else: + logger.log_error("Unsupported sfp type") + return None + + if sfpi_obj is None: + logger.log_error("sfpi_obj create fail") + return None + + # read Base ID field + sfp_interface_bulk_raw = self._read_eeprom_bytes( + field_offset, ID_FIELD_WIDTH, INDEX_A0H) + if sfp_interface_bulk_raw is None: + logger.log_error( + " Fail to read BaseID field of module {}".format(self.index+1)) + return None + + start = 0 + end = start + info_bulk_width + sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( + sfp_interface_bulk_raw[start: end], 0) + + start = Id_field['VENDOR_NAME'][OFFSET] + end = start + Id_field['VENDOR_NAME'][WIDTH] + sfp_vendor_name_data = sfpi_obj.parse_vendor_name( + sfp_interface_bulk_raw[start: end], 0) + + start = Id_field['VENDOR_PN'][OFFSET] + end = start + Id_field['VENDOR_PN'][WIDTH] + sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( + sfp_interface_bulk_raw[start: end], 0) + + start = Id_field['VENDOR_REV'][OFFSET] + end = start + Id_field['VENDOR_REV'][WIDTH] + sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( + sfp_interface_bulk_raw[start: end], 0) + + start = Id_field['VENDOR_SN'][OFFSET] + end = start + Id_field['VENDOR_SN'][WIDTH] + sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( + sfp_interface_bulk_raw[start: end], 0) + + start = Id_field['VENDOR_OUI'][OFFSET] + end = start + Id_field['VENDOR_OUI'][WIDTH] + sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( + sfp_interface_bulk_raw[start: end], 0) + + start = Id_field['VENDOR_DATE'][OFFSET] + end = start + Id_field['VENDOR_DATE'][WIDTH] + sfp_vendor_date_data = sfpi_obj.parse_vendor_date( + sfp_interface_bulk_raw[start: end], 0) + + compliance_code_dict = {} + + transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['value'] + transceiver_info_dict['manufacturer'] = sfp_vendor_name_data['data']['Vendor Name']['value'] + transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] + transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] + transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] + transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] + transceiver_info_dict['vendor_date'] = sfp_vendor_date_data[ + 'data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] + transceiver_info_dict['connector'] = sfp_interface_bulk_data['data']['Connector']['value'] + transceiver_info_dict['encoding'] = sfp_interface_bulk_data['data']['EncodingCodes']['value'] + transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data['data']['Extended Identifier']['value'] + transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data['data']['RateIdentifier']['value'] + + if self.sfp_type == QSFP_TYPE: + for key in qsfp_cable_length_tup: + if key in sfp_interface_bulk_data['data']: + transceiver_info_dict['cable_type'] = key + transceiver_info_dict['cable_length'] = str( + sfp_interface_bulk_data['data'][key]['value']) + + for key in qsfp_compliance_code_tup: + if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: + compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] + transceiver_info_dict['specification_compliance'] = str( + compliance_code_dict) + transceiver_info_dict['nominal_bit_rate'] = str( + sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value']) + else: + for key in sfp_cable_length_tup: + if key in sfp_interface_bulk_data['data']: + transceiver_info_dict['cable_type'] = key + transceiver_info_dict['cable_length'] = str( + sfp_interface_bulk_data['data'][key]['value']) + + for key in sfp_compliance_code_tup: + if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: + compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] + transceiver_info_dict['specification_compliance'] = str( + compliance_code_dict) + transceiver_info_dict['nominal_bit_rate'] = str( + sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) + + return transceiver_info_dict + + def get_transceiver_bulk_status(self): + """ + Retrieves transceiver bulk status of this SFP + + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + rx_los |BOOLEAN |RX loss-of-signal status, True if has RX los, False if not. + tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not. + reset_status |BOOLEAN |reset status, True if SFP in reset, False if not. + lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not. + tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not. + tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0 + | |to channel 3. + temperature |INT |module temperature in Celsius + voltage |INT |supply voltage in mV + txbias |INT |TX Bias Current in mA, n is the channel number, + | |for example, tx2bias stands for tx bias of channel 2. + rxpower |INT |received optical power in mW, n is the channel number, + | |for example, rx2power stands for rx power of channel 2. + txpower |INT |TX output power in mW, n is the channel number, + | |for example, tx2power stands for tx power of channel 2. + ======================================================================== + """ + transceiver_dom_info_dict_keys = [ + 'temperature', 'voltage', + 'rx1power', 'rx2power', + 'rx3power', 'rx4power', + 'tx1bias', 'tx2bias', + 'tx3bias', 'tx4bias', + 'tx1power', 'tx2power', + 'tx3power', 'tx4power'] + + transceiver_dom_info_dict = dict.fromkeys( + transceiver_dom_info_dict_keys, 'N/A') + + path_idx = INDEX_A0H + + self._dom_capability_detect() + if not self.dom_supported: + return transceiver_dom_info_dict + + if self.sfp_type == QSFP_TYPE: + field_offset = 0 # lower memory map: A0h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + if self.eeprom_path_list[INDEX_A2H] is not 'n/a': + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + path_idx = INDEX_A2H + else: + field_offset = 256 + Id_field = SFP_ID_FIELDS + sfpd_obj = sff8472Dom() + else: + return None + + if sfpd_obj is None: + return transceiver_dom_info_dict + sfpd_obj._calibration_type = self.calibration + + dom_temperature_raw = self._read_eeprom_bytes( + field_offset + Id_field['TEMPERATURE'][OFFSET], Id_field['TEMPERATURE'][WIDTH], path_idx) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature( + dom_temperature_raw, 0) + transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] + + dom_voltage_raw = self._read_eeprom_bytes( + field_offset + Id_field['VOLTAGE'][OFFSET], Id_field['VOLTAGE'][WIDTH], path_idx) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] + + dom_channel_monitor_raw = self._read_eeprom_bytes( + field_offset + Id_field['CHANNEL_MON'][OFFSET], Id_field['CHANNEL_MON'][WIDTH], path_idx) + if dom_channel_monitor_raw is not None: + if self.sfp_type == QSFP_TYPE: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) + transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] + transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] + transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] + transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] + transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value'] + transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value'] + transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value'] + transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value'] + transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value'] + transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value'] + transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value'] + transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value'] + + else: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RXPower']['value'] + transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TXBias']['value'] + transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TXPower']['value'] + + for key in transceiver_dom_info_dict: + transceiver_dom_info_dict[key] = self._convert_string_to_num( + transceiver_dom_info_dict[key]) + + return transceiver_dom_info_dict + + def get_transceiver_threshold_info(self): + """ + Retrieves transceiver threshold info of this SFP + + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. + templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. + temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. + templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. + vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. + vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. + vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. + vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. + rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. + rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. + rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. + rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. + txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. + txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. + txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. + txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. + txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. + txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. + txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. + txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. + ======================================================================== + """ + dom_info_dict_keys = ['temphighalarm', 'temphighwarning', + 'templowalarm', 'templowwarning', + 'vcchighalarm', 'vcchighwarning', + 'vcclowalarm', 'vcclowwarning', + 'rxpowerhighalarm', 'rxpowerhighwarning', + 'rxpowerlowalarm', 'rxpowerlowwarning', + 'txpowerhighalarm', 'txpowerhighwarning', + 'txpowerlowalarm', 'txpowerlowwarning', + 'txbiashighalarm', 'txbiashighwarning', + 'txbiaslowalarm', 'txbiaslowwarning' + ] + + transceiver_dom_threshold_info_dict = dict.fromkeys( + dom_info_dict_keys, 'N/A') + + path_idx = INDEX_A0H + + self._dom_capability_detect() + if not self.dom_supported: + return transceiver_dom_threshold_info_dict + + if self.sfp_type == QSFP_TYPE: + field_offset = QSFP_UPPER_MEMORY_PAGE03_OFFSET # uppper memory map: Page 03h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + if self.eeprom_path_list[INDEX_A2H] is not 'n/a': + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + path_idx = INDEX_A2H + else: + field_offset = 256 + Id_field = SFP_ID_FIELDS + sfpd_obj = sff8472Dom() + else: + return transceiver_dom_threshold_info_dict + + if sfpd_obj is None: + return transceiver_dom_threshold_info_dict + + dom_module_threshold_raw = self._read_eeprom_bytes( + field_offset + Id_field['MODULE_THRESHOLD'][OFFSET], Id_field['MODULE_THRESHOLD'][WIDTH], path_idx) + + if dom_module_threshold_raw is None: + return transceiver_dom_threshold_info_dict + + if self.sfp_type == QSFP_TYPE: + dom_module_threshold_data = sfpd_obj.parse_module_threshold_values( + dom_module_threshold_raw, 0) + + dom_channel_threshold_raw = self._read_eeprom_bytes( + field_offset + Id_field['CHANNEL_THRESHOLD'][OFFSET], Id_field['CHANNEL_THRESHOLD'][WIDTH], path_idx) + + if dom_channel_threshold_raw is None: + return transceiver_dom_threshold_info_dict + + dom_channel_threshold_data = sfpd_obj.parse_channel_threshold_values( + dom_channel_threshold_raw, 0) + + transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_channel_threshold_data['data']['RxPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_channel_threshold_data['data']['RxPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_channel_threshold_data['data']['RxPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_channel_threshold_data['data']['RxPowerLowWarning']['value'] + transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_channel_threshold_data['data']['TxPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_channel_threshold_data['data']['TxPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_channel_threshold_data['data']['TxPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_channel_threshold_data['data']['TxPowerLowWarning']['value'] + transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_channel_threshold_data['data']['TxBiasHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_channel_threshold_data['data']['TxBiasHighWarning']['value'] + transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_channel_threshold_data['data']['TxBiasLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_channel_threshold_data['data']['TxBiasLowWarning']['value'] + else: # SFP_TYPE + dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold( + dom_module_threshold_raw, 0) + transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] + transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value'] + transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value'] + transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value'] + + transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value'] + transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value'] + transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value'] + transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value'] + transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VccHighAlarm']['value'] + transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VccHighWarning']['value'] + transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VccLowAlarm']['value'] + transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VccLowWarning']['value'] + + return transceiver_dom_threshold_info_dict + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + + Returns: + A Boolean, True if reset enabled, False if disabled + """ + raise NotImplementedError + + def get_rx_los(self): + """ + Retrieves the RX LOS (lost-of-signal) status of SFP + + Returns: + A Boolean, True if SFP has RX LOS, False if not. + Note : RX LOS status is latched until a call to get_rx_los or a reset. + """ + raise NotImplementedError + + def get_tx_fault(self): + """ + Retrieves the TX fault status of SFP + + Returns: + A Boolean, True if SFP has TX fault, False if not + Note : TX fault status is lached until a call to get_tx_fault or a reset. + """ + raise NotImplementedError + + def get_tx_disable(self): + """ + Retrieves the tx_disable status of this SFP + + Returns: + A Boolean, True if tx_disable is enabled, False if disabled + """ + raise NotImplementedError + + def get_tx_disable_channel(self): + """ + Retrieves the TX disabled channels in this SFP + + Returns: + A hex of 4 bits (bit 0 to bit 3 as channel 0 to channel 3) to represent + TX channels which have been disabled in this SFP. + As an example, a returned value of 0x5 indicates that channel 0 + and channel 2 have been disabled. + """ + raise NotImplementedError + + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this SFP + + Returns: + A Boolean, True if lpmode is enabled, False if disabled + """ + if self.lp_file is not None: + data = self.__read_attr_file(self.lp_file, 0) + if data is not None: + if int(data) == 1: + return True + return False + + def get_power_override(self): + """ + Retrieves the power-override status of this SFP + + Returns: + A Boolean, True if power-override is enabled, False if disabled + """ + + if self.sfp_type == QSFP_TYPE: + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self._read_eeprom_bytes( + Id_field['CONTROL'][OFFSET], Id_field['CONTROL'][WIDTH], INDEX_A0H) + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes( + dom_control_raw, 0) + return ('On' == dom_control_data['data']['PowerOverride']) + + return False + else: + return NotImplementedError + + def get_temperature(self): + """ + Retrieves the temperature of this SFP + + Returns: + An integer number of current temperature in Celsius + """ + path_idx = INDEX_A0H + + if self.sfp_type == QSFP_TYPE: + field_offset = 0 # lower memory map: A0h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + Id_field = SFP_ID_FIELDS + path_idx = INDEX_A2H + sfpd_obj = sff8472Dom() + else: + return None + + if sfpd_obj is None: + return None + + dom_temperature_raw = self._read_eeprom_bytes( + field_offset + Id_field['TEMPERATURE'][OFFSET], Id_field['TEMPERATURE'][WIDTH], path_idx) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature( + dom_temperature_raw, 0) + temp = self._convert_string_to_num( + dom_temperature_data['data']['Temperature']['value']) + return temp + + return None + + def get_voltage(self): + """ + Retrieves the supply voltage of this SFP + + Returns: + An integer number of supply voltage in mV + """ + path_idx = INDEX_A0H + if self.sfp_type == QSFP_TYPE: + field_offset = 0 # lower memory map: A0h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + Id_field = SFP_ID_FIELDS + path_idx = INDEX_A2H + sfpd_obj = sff8472Dom() + else: + return None + + if sfpd_obj is None: + return None + + dom_voltage_raw = self._read_eeprom_bytes( + field_offset + Id_field['VOLTAGE'][OFFSET], Id_field['VOLTAGE'][WIDTH], path_idx) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + volt = self._convert_string_to_num( + dom_voltage_data['data']['Vcc']['value']) + return volt + + return None + + def get_tx_bias(self): + """ + Retrieves the TX bias current of this SFP + + Returns: + A list of four integer numbers, representing TX bias in mA + for channel 0 to channel 4. + Ex. ['110.09', '111.12', '108.21', '112.09'] + """ + path_idx = INDEX_A0H + tx_bias_list = [] + + if self.sfp_type == QSFP_TYPE: + field_offset = 0 # lower memory map: A0h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + Id_field = SFP_ID_FIELDS + path_idx = INDEX_A2H + sfpd_obj = sff8472Dom() + else: + return None + + if sfpd_obj is None: + return None + + dom_channel_monitor_raw = self._read_eeprom_bytes( + field_offset + Id_field['CHANNEL_MON'][OFFSET], Id_field['CHANNEL_MON'][WIDTH], path_idx) + if dom_channel_monitor_raw is not None: + if self.sfp_type == QSFP_TYPE: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Bias']['value'])) + + else: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXBias']['value'])) + + return tx_bias_list + + return None + + def get_rx_power(self): + """ + Retrieves the received optical power for this SFP + + Returns: + A list of four integer numbers, representing received optical + power in mW for channel 0 to channel 4. + Ex. ['1.77', '1.71', '1.68', '1.70'] + """ + path_idx = INDEX_A0H + rx_power_list = [] + + if self.sfp_type == QSFP_TYPE: + field_offset = 0 # lower memory map: A0h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + Id_field = SFP_ID_FIELDS + path_idx = INDEX_A2H + sfpd_obj = sff8472Dom() + else: + return None + + if sfpd_obj is None: + return None + + dom_channel_monitor_raw = self._read_eeprom_bytes( + field_offset + Id_field['CHANNEL_MON'][OFFSET], Id_field['CHANNEL_MON'][WIDTH], path_idx) + if dom_channel_monitor_raw is not None: + if self.sfp_type == QSFP_TYPE: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX1Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX2Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX3Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX4Power']['value'])) + + else: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RXPower']['value'])) + + return rx_power_list + + return None + + def get_tx_power(self): + """ + Retrieves the TX power of this SFP + + Returns: + A list of four integer numbers, representing TX power in mW + for channel 0 to channel 4. + Ex. ['1.86', '1.86', '1.86', '1.86'] + """ + path_idx = INDEX_A0H + tx_power_list = [] + + if self.sfp_type == QSFP_TYPE: + field_offset = 0 # lower memory map: A0h + Id_field = QSFP_ID_FIELDS + sfpd_obj = sff8436Dom() + elif self.sfp_type == SFP_TYPE: + # lower memory map: A2h (SFP i2c 0x51) + field_offset = SFP_A2H_OFFSET + Id_field = SFP_ID_FIELDS + path_idx = INDEX_A2H + sfpd_obj = sff8472Dom() + else: + return None + + if sfpd_obj is None: + return None + + dom_channel_monitor_raw = self._read_eeprom_bytes( + field_offset + Id_field['CHANNEL_MON'][OFFSET], Id_field['CHANNEL_MON'][WIDTH], path_idx) + if dom_channel_monitor_raw is not None: + if self.sfp_type == QSFP_TYPE: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Power']['value'])) + + else: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXPower']['value'])) + + return tx_power_list + + return None + + def reset(self): + """ + Reset SFP and return all user module settings to their default srate. + + Returns: + A boolean, True if successful, False if not + """ + if self.reset_file is not None: + ret = self.__write_attr_file(self.reset_file, '1') + if ret != 0: + return True + return False + + def tx_disable(self, tx_disable): + """ + Disable SFP TX for all channels + + Args: + tx_disable : A Boolean, True to enable tx_disable mode, False to disable + tx_disable mode. + + Returns: + A boolean, True if tx_disable is set successfully, False if not + """ + return False + + def tx_disable_channel(self, channel, disable): + """ + Sets the tx_disable for specified SFP channels + + Args: + channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3, + e.g. 0x5 for channel 0 and channel 2. + disable : A boolean, True to disable TX channels specified in channel, + False to enable + + Returns: + A boolean, True if successful, False if not + """ + return False + + def set_lpmode(self, lpmode): + """ + Sets the lpmode (low power mode) of SFP + + Args: + lpmode: A Boolean, True to enable lpmode, False to disable it + Note : lpmode can be overridden by set_power_override + + Returns: + A boolean, True if lpmode is set successfully, False if not + """ + if self.lp_file is not None: + if lpmode is True: + ret = self.__write_attr_file(self.lp_file, "1") + else: + ret = self.__write_attr_file(self.lp_file, "0") + if ret != 0: + return True + return False + + def set_power_override(self, power_override, power_set): + """ + Sets SFP power level using power_override and power_set + + Args: + power_override : + A Boolean, True to override set_lpmode and use power_set + to control SFP power, False to disable SFP power control + through power_override/power_set and use set_lpmode + to control SFP power. + power_set : + Only valid when power_override is True. + A Boolean, True to set SFP to low power mode, False to set + SFP to high power mode. + + Returns: + A boolean, True if power-override and power_set are set successfully, + False if not + """ + return False diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/thermal.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/thermal.py new file mode 100644 index 0000000000..8d1bb949f3 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/sonic_platform/thermal.py @@ -0,0 +1,201 @@ +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +try: + from sonic_py_common.logger import Logger + from sonic_platform_base.thermal_base import ThermalBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +logger = Logger("thermal") + + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + + def __init__(self, index, name, sysfile_path, is_bmc, support_mask=0x1, ext_sysfile_list=None): + # index is used to indicate the temp{} under sffile_path + # support_mask: 1:support 0:not support + # bit 0 : temperature (always 1) + # bit 1 : high threshold + # bit 2 : low threshold + # bit 3 : high critical threshold + # bit 4 : low critical threshold + # bit 7 : cpu internal sensor + # ext_sysfile_list: each specified path of each supported function, + # which not follows the general naming rule + + self.index = index + self.name = name + self.filepath = sysfile_path + self.support_mask = support_mask + self.is_bmc = is_bmc + + self.temperature_file = None + self.high_thershold_file = None + self.low_threshold_file = None + self.high_critical_file = None + self.low_critical_file = None + + if sysfile_path is None: + return + + if self.is_bmc == False or support_mask & 0x80 == 0x80: + if support_mask & 0x1: + self.temperature_file = \ + sysfile_path + "/temp{}_input".format(self.index) + if support_mask & 0x2: + self.high_thershold_file = \ + sysfile_path + "/temp{}_max".format(self.index) + if support_mask & 0x4: + self.low_threshold_file = \ + sysfile_path + "/temp{}_min".format(self.index) + if support_mask & 0x8: + self.high_critical_file = \ + sysfile_path + "/temp{}_crit".format(self.index) + if support_mask & 0x10: + self.low_critical_file = \ + sysfile_path + "/temp{}_lcrit".format(self.index) + elif self.is_bmc and ext_sysfile_list is not None: + if support_mask & 0x1: + self.temperature_file = \ + sysfile_path + ext_sysfile_list[self.index][0] + if support_mask & 0x2: + self.high_thershold_file = \ + sysfile_path + ext_sysfile_list[self.index][1] + if support_mask & 0x4: + self.low_threshold_file = \ + sysfile_path + ext_sysfile_list[self.index][2] + if support_mask & 0x8: + self.high_critical_file = \ + sysfile_path + ext_sysfile_list[self.index][3] + if support_mask & 0x10: + self.low_critical_file = \ + sysfile_path + ext_sysfile_list[self.index][4] + + def __read_attr_file(self, filepath, line=0xFF): + try: + with open(filepath, 'r') as fd: + if line == 0xFF: + data = fd.read() + return data.rstrip('\r\n') + else: + data = fd.readlines() + return data[line].rstrip('\r\n') + except Exception as ex: + logger.log_error( + "Unable to open {} due to {}".format(filepath, repr(ex))) + + return None + + def get_name(self): + return self.name + + def get_presence(self): + return True + + def get_temperature(self): + """ + Retrieves current temperature reading from thermal + + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + if self.temperature_file is not None: + temp = self.__read_attr_file(self.temperature_file) + if temp is not None: + return float(temp) / 1000 + + return None + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature of thermal + + Returns: + A float number, the high threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.high_thershold_file is not None: + temp = self.__read_attr_file(self.high_thershold_file) + if temp is not None: + return float(temp) / 1000 + + return None + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature of thermal + + Returns: + A float number, the low threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.low_threshold_file is not None: + temp = self.__read_attr_file(self.low_threshold_file) + if temp is not None: + return float(temp) / 1000 + + return None + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + + Returns: + A boolean, True if threshold is set successfully, False if not + """ + return False + + def set_low_threshold(self, temperature): + """ + Sets the low threshold temperature of thermal + + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + + Returns: + A boolean, True if threshold is set successfully, False if not + """ + return False + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature of thermal + + Returns: + A float number, the high critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.high_critical_file is not None: + temp = self.__read_attr_file(self.high_critical_file) + if temp is not None: + return float(temp) / 1000 + + return None + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature of thermal + + Returns: + A float number, the low critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.low_critical_file is not None: + temp = self.__read_attr_file(self.low_critical_file) + if temp is not None: + return float(temp) / 1000 + + return None diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/templates/netberg_aurora-715_util.py.j2 b/platform/innovium/sonic-platform-modules-netberg/aurora-715/templates/netberg_aurora-715_util.py.j2 new file mode 100755 index 0000000000..c71aa4a032 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/templates/netberg_aurora-715_util.py.j2 @@ -0,0 +1,408 @@ +#!/usr/bin/env python + + +""" +Usage: %(scriptName)s [options] command object + +options: + -h | --help : this help message + -d | --debug : run with debug mode + -f | --force : ignore error during installation or clean +command: + install : install drivers and generate related sysfs nodes + clean : uninstall drivers and remove related sysfs nodes + show : show all systen status + sff : dump SFP eeprom + set : change board setting with fan|led|sfp +""" + +import os +import commands +import sys, getopt +import logging +import re +import time +import json + +PROJECT_NAME = 'aurora_715' +verbose = False +DEBUG = False +FORCE = 0 + +# default is 'i2c-0', we will choose the correct one from 'i2c-0' and 'i2c-1'. +#DEFAULT_BASE_BUS = 'i2c-0' +I2C_PREFIX = '/sys/bus/i2c/devices/' +BASE_BUS = 'i2c-0' +BASE_BUS_PATH = I2C_PREFIX + BASE_BUS + +#I2C_BASE_BUS = { +# 'i2c-0':{ +# 'path':'/sys/bus/i2c/devices/i2c-0', +# 'status':'INSTALLED' +# } +#} + +switch_install_order = [ +# 'PCA9548_0x73', +'PCA9548_0x71_1', +'PCA9548_0x71_2', +'PCA9548_0x71_3', +'PCA9548_0x71_4' +# 'PCA9548_0x75' +] + +I2C_SWITCH_LIST = { + # i2c switches + 'PCA9548_0x73': { + 'parent':BASE_BUS, + 'driver':'pca9548', + 'i2caddr': '0x73', + 'path': '/sys/bus/i2c/devices/0-0073', + 'bus_map': [1,2,3,4,5,6,7,8], + 'status':'NOTINST' + }, + #'PCA9548_0x75': { + # 'parent':BASE_BUS, + # 'driver':'pca9548', + # 'i2caddr': '0x75', + # 'path': ' ', + # 'bus_map': [0,0,0,0,0,0,0,0], + # 'status':'NOTINST' + #}, + 'PCA9548_0x71_1': { + 'parent':'PCA9548_0x73', + 'parent_ch': 4, + 'driver':'pca9548', + 'i2caddr': '0x71', + 'path': '/sys/bus/i2c/devices/5-0071', + 'bus_map': [9,10,11,12,13,14,15,16], + 'status':'NOTINST' + }, + 'PCA9548_0x71_2': { + 'parent':'PCA9548_0x73', + 'parent_ch': 5, + 'driver':'pca9548', + 'i2caddr': '0x71', + 'path': '/sys/bus/i2c/devices/6-0071', + 'bus_map': [17,18,19,20,21,22,23,24], + 'status':'NOTINST' + }, + 'PCA9548_0x71_3': { + 'parent':'PCA9548_0x73', + 'parent_ch': 6, + 'driver':'pca9548', + 'i2caddr': '0x71', + 'path': '/sys/bus/i2c/devices/7-0071', + 'bus_map': [25,26,27,28,29,30,31,32], + 'status':'NOTINST' + }, + 'PCA9548_0x71_4': { + 'parent':'PCA9548_0x73', + 'parent_ch': 7, + 'driver':'pca9548', + 'i2caddr': '0x71', + 'path': '/sys/bus/i2c/devices/8-0071', + 'bus_map': [33,34,35,36,37,38,39,40], + 'status':'NOTINST' + } +} + +I2C_DEVICES = { + # NCT7511Y sensor & fan control + 'NCT7511Y(U73)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 0, + 'driver':'nct7511', + 'i2caddr': '0x2e', + 'path': ' ', + 'status':'NOTINST' + }, + # G781 sensors + 'G781(U94)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 1, + 'driver':'g781', + 'i2caddr': '0x4c', + 'path': ' ', + 'status':'NOTINST' + }, + 'G781(U4)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 2, + 'driver':'g781', + 'i2caddr': '0x4c', + 'path': ' ', + 'status':'NOTINST' + }, + 'G781(U34)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 3, + 'driver':'g781', + 'i2caddr': '0x4c', + 'path': ' ', + 'status':'NOTINST' + }, + # PSU + 'PSU1': { + 'parent':'PCA9548_0x75', + 'parent_ch': 4, + 'driver':'zrh2800k2', + 'i2caddr': '0x58', + 'path': ' ', + 'status':'NOTINST' + }, + 'PSU2': { + 'parent':'PCA9548_0x75', + 'parent_ch': 4, + 'driver':'zrh2800k2', + 'i2caddr': '0x59', + 'path': ' ', + 'status':'NOTINST' + }, + 'TPS53681(0x6C)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 5, + 'driver':'tps53679', + 'i2caddr': '0x6c', + 'path': ' ', + 'status':'NOTINST' + }, + 'TPS53681(0x6E)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 5, + 'driver':'tps53679', + 'i2caddr': '0x6e', + 'path': ' ', + 'status':'NOTINST' + }, + 'TPS53681(0x70)': { + 'parent':'PCA9548_0x75', + 'parent_ch': 5, + 'driver':'tps53679', + 'i2caddr': '0x70', + 'path': ' ', + 'status':'NOTINST' + } +} + +SFP_GROUPS = { + 'SFP-G01' :{ + 'number': 8, + 'parent':'PCA9548_0x71_1', + 'channels':[0,1,2,3,4,5,6,7], + 'driver':'optoe1', + 'i2caddr': '0x50', + 'paths': [], + 'status':'NOTINST' + }, + 'SFP-G02' :{ + 'number': 8, + 'parent':'PCA9548_0x71_2', + 'channels':[0,1,2,3,4,5,6,7], + 'driver':'optoe1', + 'i2caddr': '0x50', + 'paths': [], + 'status':'NOTINST' + }, + 'SFP-G03' :{ + 'number': 8, + 'parent':'PCA9548_0x71_3', + 'channels':[0,1,2,3,4,5,6,7], + 'driver':'optoe1', + 'i2caddr': '0x50', + 'paths': [], + 'status':'NOTINST' + }, + 'SFP-G04' :{ + 'number': 8, + 'parent':'PCA9548_0x71_4', + 'channels':[0,1,2,3,4,5,6,7], + 'driver':'optoe1', + 'i2caddr': '0x50', + 'paths': [], + 'status':'NOTINST' + } +} + + + +def main(): + global DEBUG + global args + global FORCE + + options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', + 'debug', + 'force', + ]) + for opt, arg in options: + if opt in ('-d', '--debug'): + DEBUG = True + logging.basicConfig(level=logging.INFO) + elif opt in ('-f', '--force'): + FORCE = 1 + else: + logging.info('no option') + for arg in args: + if arg == 'install': + do_install() + elif arg == 'clean': + do_uninstall() + elif arg == 'version': + show_version() + + return 0 + +def show_version(): + print("platform driver version: {}\n".format(PLATFORM_DRIVER_VER)) + +def driver_check(): + with open('/proc/modules') as modules: + return 'x86_64_netberg_aurora' in modules.read() + +def driver_install(): + print("Probbing modules...") + os.system('modprobe i2c_dev') + os.system('modprobe x86-64-netberg-aurora-715') + os.system('modprobe i2c_mux_pca954x force_deselect_on_exit=1') + + return 0 + + +def driver_uninstall(): + os.system('rmmod i2c_mux_pca954x') + os.system('rmmod x86-64-netberg-aurora-715') + os.system('rmmod i2c_dev') + + return 0 + +def install_i2c_switch(): + + print("Init root I2C switch...") + + root_sw = I2C_SWITCH_LIST['PCA9548_0x73'] + os.system("echo {} {} > {}/new_device".format(root_sw['driver'], root_sw['i2caddr'], BASE_BUS_PATH)) + # make sure the root switch for sfp is installed + time.sleep(2) + + + for switch_name in switch_install_order: + switch = I2C_SWITCH_LIST[switch_name] + + install_path = I2C_SWITCH_LIST[switch['parent']]['path'] + install_path = install_path+"/channel-{}".format(switch['parent_ch']) + + cmd = "echo {} {} > {}/new_device".format(switch['driver'], switch['i2caddr'], install_path) + print(cmd) + os.system(cmd) + +def install_sfp(): + for sfp_group_name in SFP_GROUPS.keys(): + sfp_group = SFP_GROUPS[sfp_group_name] + install_path = I2C_SWITCH_LIST[sfp_group['parent']]['path'] + + for n in range(0,sfp_group['number']): + sfp_install_path = install_path+"/channel-{}".format(sfp_group['channels'][n]) + cmd = "echo {} {} > {}/new_device".format(sfp_group['driver'], sfp_group['i2caddr'], sfp_install_path) + print(cmd) + os.system(cmd) + + # sfp_group['paths'].append("/sys/bus/i2c/devices/{}-00{}".format(I2C_SWITCH_LIST[sfp_group['parent']]['bus_map'][sfp_group['channels'][n]],sfp_group['i2caddr'][-2:])) + print("/sys/bus/i2c/devices/{}-00{}".format(I2C_SWITCH_LIST[sfp_group['parent']]['bus_map'][sfp_group['channels'][n]],sfp_group['i2caddr'][-2:])) + + +def uninstall_sfp(): + for sfp_group_name in SFP_GROUPS.keys(): + sfp_group = SFP_GROUPS[sfp_group_name] + + uninst_path = I2C_SWITCH_LIST[sfp_group['parent']]['path'] + + for n in range(0,sfp_group['number']): + sfp_uninst_path = uninst_path+"/channel-{}".format(sfp_group['channels'][n]) + cmd = "echo {} > {}/delete_device".format(sfp_group['i2caddr'], sfp_uninst_path) + print(cmd) + os.system(cmd) + +def uninstall_i2c_switch(): + for switch_name in reversed(switch_install_order): + switch = I2C_SWITCH_LIST[switch_name] + uninst_path = I2C_SWITCH_LIST[switch['parent']]['path'] + "/channel-{}".format(switch['parent_ch']) + + cmd = "echo {} > {}/delete_device".format(switch['i2caddr'], uninst_path) + + print(cmd) + os.system(cmd) + + print("Uninstall root switch...") + root_sw = I2C_SWITCH_LIST['PCA9548_0x73'] + cmd = "echo {} > {}/delete_device".format(root_sw['i2caddr'], BASE_BUS_PATH) + print(cmd) + os.system(cmd) + +def set_led_control(): + cmd = "echo 1 > /sys/class/hwmon/hwmon2/device/NBA715_LED/led_fiber" + print(cmd) + os.system(cmd) + +def device_install(): + print('Base bus is {}'.format(BASE_BUS)) + + set_led_control() + + install_i2c_switch() + # delay to make sure all switches are installed completely, + time.sleep(1) + + # install_i2c_device() + + install_sfp() + return 0 + +def device_uninstall(): + global SFP_GROUPS + # global I2C_DEVICES + global I2C_SWITCH_LIST + + uninstall_sfp() +# uninstall_i2c_device() + uninstall_i2c_switch() + return 0 + +def do_install(): + print("Drivers installing....") + status = driver_install() + print("Devices installing....") + status = device_install() + return + + +def do_uninstall(): + print "Checking system...." + if not device_exist(): + print PROJECT_NAME.upper() + " has no device installed...." + else: + print "Removing device...." + status = device_uninstall() + if status: + + if FORCE == 0: + return status + + if driver_check() == False: + print PROJECT_NAME.upper() + " has no driver installed...." + else: + print "Removing installed driver...." + status = driver_uninstall() + if status: + if FORCE == 0: + return status + + return + +def device_exist(): + print("Checking devices... ") + return os.path.isdir("/sys/bus/i2c/devices/0-0056/") + + +if __name__ == "__main__": + main() diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/halt b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/halt new file mode 100755 index 0000000000..eca0b5c1ad --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/halt @@ -0,0 +1,18 @@ +#!/bin/sh + +mr_reboot() { + + sudo rmmod x86-64-netberg-aurora-715 + sudo i2cset -y 0 0x30 0xa1 0 + +} + +if [ $# -eq 0 ] || [ $@ = "--halt" ] || [ $@ = "-f" ] || [ $@ = "--force" ]; then + sudo /sbin/halt +elif [ $@ = "-p" ] || [ $@ = "--reboot" ] || [ $@ = "--poweroff" ]; then + sync;sync + mr_reboot +else + echo "unsupported option" +fi + diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_platform.sh b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_platform.sh new file mode 100755 index 0000000000..27e4974351 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_platform.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Install aurora-715 python package +DEVICE="/usr/share/sonic/device" +PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + +if [ -e $DEVICE/$PLATFORM/sonic_platform-1.0-py3-none-any.whl ]; then + pip install $DEVICE/$PLATFORM/sonic_platform-1.0-py3-none-any.whl +fi + diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_sensors.py b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_sensors.py new file mode 100755 index 0000000000..bac1550af4 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_sensors.py @@ -0,0 +1,281 @@ +#!/usr/bin/python + +from __future__ import print_function +import os +import sys +import logging + +MAX_FAN_NUM = 5 +MAX_PSU_NUM = 2 +PSU_LIST = ['PSU1', 'PSU2'] # 0x58, 0x59 + +THERMAL_SENSOR_LIST = ['NCT7511Y(U73)', 'G781(U94)', 'G781(U34)', 'G781(U4)'] + +BMC_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_SYS/' +FAN_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_FAN/' +POWER_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_POWER/' +THERMAL_SYSFILE_PATH = '/sys/class/hwmon/hwmon2/device/NBA715_THERMAL/' + + +def get_thermal_sensor_path(): + sensor_path = [] + try: + with open(PLATFORM_INSTALL_INFO_FILE) as fd: + install_info = json.load(fd) + for sensor_name in THERMAL_SENSOR_LIST: + sensor = install_info[1][sensor_name] + sensor_path.append(sensor['hwmon_path']+'/') + return sensor_path + except Exception: + print("Fail to get sensor sysfsfile path") + + return sensor_path + +# Get sysfs attribute + + +def get_attr_value(attr_path): + retval = 'ERR' + if not os.path.isfile(attr_path): + return retval + + try: + with open(attr_path, 'r') as fd: + retval = fd.read() + except Exception as error: + logging.error("Unable to open ", attr_path, " file !") + + retval = retval.rstrip('\r\n') + fd.close() + return retval + + +def print_attr_value_lines(sys_path): + retval = 'ERR' + if not os.path.isfile(sys_path): + return retval + try: + fo = open(sys_path, "r") + except Exception as error: + logging.error("Unable to open ", sys_path, " file !") + for line in fo.readlines(): + line = line.strip() + print(" %s" % line) + fo.close() + return retval + + +def show_sensor_table(): + + headers = ['Sensor', 'Temperature', 'High', + 'Low', 'Critical High', 'Critical Low'] + table = list() + temp = list() + + sensor_table = [ + ['Right Bottom Front', 'temp_r_b_f', 'temp_r_b_f_max', + 'temp_r_b_f_min', 'temp_r_b_f_crit', 'temp_r_b_f_lcrit'], + ['Right Bottom Back', 'temp_r_b_b', 'temp_r_b_b_max', + 'temp_r_b_b_min', 'temp_r_b_b_crit', 'temp_r_b_b_lcrit'], + ['Left Bottom Front', 'temp_l_b_f', 'temp_l_b_f_max', + 'temp_l_b_f_min', 'temp_l_b_f_crit', 'temp_l_b_f_lcrit'], + ['Left Bottom Back', 'temp_l_b_b', 'temp_l_b_b_max', + 'temp_l_b_b_min', 'temp_l_b_b_crit', 'temp_l_b_b_lcrit'], + ['Right Top Front', 'temp_r_t_f', 'temp_r_t_f_max', + 'temp_r_t_f_min', 'temp_r_t_f_crit', 'temp_r_t_f_lcrit'], + ['Right Top Back Sensor', 'temp_r_t_b', 'temp_r_t_b_max', + 'temp_r_t_b_min', 'temp_r_t_b_crit', 'temp_r_t_b_lcrit'], + ['Left Top Front Sensor', 'temp_l_t_f', 'temp_l_t_f_max', + 'temp_l_t_f_min', 'temp_l_t_f_crit', 'temp_l_t_f_lcrit'], + ['Left Top Back Sensor', 'temp_l_t_b', 'temp_l_t_b_max', + 'temp_l_t_b_min', 'temp_l_t_b_crit', 'temp_l_t_b_lcrit'], + ] + + for index in range(len(sensor_table)): + name = sensor_table[index][0] + for x in range(0, 5): + sys_path = THERMAL_SYSFILE_PATH + sensor_table[index][x+1] + t = get_attr_value(sys_path) + if t == 'ERR': + temp.append('N/A') + else: + if t.isdigit(): + t = int(t)/1000.0 + temp.append('{} C'.format(t)) + + table.append([name, temp[0], temp[1], temp[2], temp[3], temp[4]]) + del temp[:] + print(headers) + print(table) + print('') + + +def show_fan_table(): + print(*['Fan', 'Speed', 'Presence', 'Status', 'Power'], sep='\t') + + for index in range(1, MAX_FAN_NUM+1): + name_front = "FAN{}-Front".format(index) + name_rear = "FAN{}-Rear".format(index) + speed_front, speed_rear = fan_speed_dual(index) + present = fan_present(index) + status = fan_status(index) + power = fan_power(index) + print(*[name_front, speed_front, present, status, power], sep='\t') + print(*[name_rear, speed_front, present, status, power], sep='\t') + + print('') + + +def fan_status(index): + sys_path = FAN_SYSFILE_PATH + 'fan{}_stat'.format(index) + ret = get_attr_value(sys_path) + if ret == '1': + return 'OK' + elif ret == '0': + return 'NG' + else: + return 'N/A' + + +def fan_present(index): + sys_path = FAN_SYSFILE_PATH + 'fan{}_present'.format(index) + ret = get_attr_value(sys_path) + if ret == '1': + return 'Present' + elif ret == '0': + return 'Not Present' + else: + return 'N/A' + + +def fan_power(index): + sys_path = FAN_SYSFILE_PATH + 'fan{}_power'.format(index) + ret = get_attr_value(sys_path) + if ret == '1': + return 'On' + elif ret == '0': + return 'Off' + else: + return 'N/A' + + +def fan_speed_dual(index): + sys_path = FAN_SYSFILE_PATH + 'fan{}_front_rpm'.format(index) + front_ret = get_attr_value(sys_path) + if front_ret == 'ERR': + front_ret = 'N/A' + else: + front_ret = front_ret+'RPM' + + sys_path = FAN_SYSFILE_PATH + 'fan{}_rear_rpm'.format(index) + rear_ret = get_attr_value(sys_path) + if rear_ret == 'ERR': + rear_ret = 'N/A' + else: + rear_ret = rear_ret+'RPM' + + return (front_ret, rear_ret) + + +def is_psu_present(psu_number): + sys_path = POWER_SYSFILE_PATH + 'psu{}_prnt'.format(psu_number) + if os.path.exists(sys_path): + value = get_attr_value(sys_path) + if value == '1': + return True + else: + return False + + return False + + +def is_psu_power_up(psu_number): + sys_path = POWER_SYSFILE_PATH + 'psu{}_good'.format(psu_number) + if os.path.exists(sys_path): + value = get_attr_value(sys_path) + if value == '1': + return True + else: + return False + + return False + + +def show_psu_table(): + headers = ['PSU', 'Presence', 'Power', 'Fan Speed(RPM)', 'Temperature(C)', + 'Vin(V)', 'Vout(V)', 'Pin(W)', 'Pout(W)', 'Iin(A)', 'Iout(A)', 'Max Iout(A)'] + table = [] + psu_sysfiles_list = [] + + for index in range(0, MAX_PSU_NUM): + psu_sysfiles_list = [ + POWER_SYSFILE_PATH+'psu{}_fan_speed'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_temp'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_vin'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_vout'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_pin'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_pout'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_iin'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_iout'.format(index+1), + POWER_SYSFILE_PATH+'psu{}_mfr_iout_max'.format(index+1) + ] + status_list = get_psu_status(index+1, psu_sysfiles_list) + table.append(status_list) + + print(headers) + print(table) + print('') + + +def get_psu_status(index, sysfile_list): + # result_list: [name, presence, power, fanSpeed(RPM), temperature(C), vin(V), vout(V), pin(W), pout(W), iin(A), iout(A), maxIout(A)] + name = 'PSU{}'.format(index) + result_list = [name, 'Not Present', 'N/A', 'N/A', 'N/A', + 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A'] + result_mutipler = [None, None, None, None, 1000.0, 1000.0, + 1000.0, 1000000.0, 1000000.0, 1000.0, 1000.0, 1000.0] + + if is_psu_present(index): + result_list[1] = 'Present' + else: + return result_list + + if is_psu_power_up(index): + result_list[2] = 'up' + else: + result_list[2] = 'down' + + for x in range(0, 9): + result_list[x+3] = get_attr_value(sysfile_list[x]) + + for x in range(0, 12): + if result_mutipler[x] != None and result_list[x] != 'ERR': + result_list[x] = int(result_list[x]) / result_mutipler[x] + + return result_list + + +def main(): + """ + Usage: %(scriptName)s command object + + command: + fan_status : display fans status(present/power good) + """ + + if len(sys.argv) < 2: + print (main.__doc__) + + for arg in sys.argv[1:]: + if arg == 'fan_status': + show_fan_table() + elif arg == 'sensor_status': + show_sensor_table() + show_psu_table() + + else: + print (main.__doc__) + + +if __name__ == "__main__": + main() diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_startup b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_startup new file mode 100755 index 0000000000..31acf66fdb --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/netberg_nba715_startup @@ -0,0 +1,17 @@ +#!/bin/bash + + +start() { + # load platform driver, native drivers + /usr/local/bin/netberg_aurora-715_util.py install +} + +stop() { + /usr/local/bin/netberg_aurora-715_util.py clean +} + + +case $1 in + start|stop) "$1" ;; +esac + diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/poweroff b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/poweroff new file mode 100755 index 0000000000..f905fcc519 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/poweroff @@ -0,0 +1,18 @@ +#!/bin/sh + +mr_reboot() { + + sudo rmmod x86-64-netberg-aurora-715 + sudo i2cset -y 0 0x30 0xa1 0 + +} + +if [ $# -eq 0 ] || [ $@ = "-p" ] || [ $@ = "--reboot" ] || [ $@ = "--poweroff" ] || [ $@ = "-f" ] || [ $@ = "--force" ]; then + sync;sync + mr_reboot +elif [ $@ = "--halt" ]; then + sudo halt +else + echo "unsupported option" +fi + diff --git a/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/shutdown b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/shutdown new file mode 100755 index 0000000000..c27ab47408 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/aurora-715/utils/shutdown @@ -0,0 +1,18 @@ +#!/bin/sh + +mr_reboot() { + + sudo rmmod x86-64-netberg-aurora-715 + sudo i2cset -y 0 0x31 0xa1 0 + +} + +if [ $# -eq 0 ] || [ $@ = "-r" ] || [ $@ = "--reboot" ] || [ $@ = "-h" ] || [ $@ = "-P" ] || [ $@ = "--poweroff" ]; then + sync;sync + mr_reboot +elif [ $@ = "-H" ] || [ $@ = "--halt" ]; then + sudo halt +else + echo "unsupported option" +fi + diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/changelog b/platform/innovium/sonic-platform-modules-netberg/debian/changelog new file mode 100644 index 0000000000..1e449b28b5 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/changelog @@ -0,0 +1,6 @@ +sonic-netberg-platform-modules (1.0.0) unstable; urgency=low + + * Add support for Netberg Aurora 715 + + -- developer Mon, 29 Jul 2019 11:00:00 +0800 + diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/compat b/platform/innovium/sonic-platform-modules-netberg/debian/compat new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/compat @@ -0,0 +1 @@ +9 diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/control b/platform/innovium/sonic-platform-modules-netberg/debian/control new file mode 100644 index 0000000000..65ba1cd0a6 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/control @@ -0,0 +1,10 @@ +Source: sonic-netberg-platform-modules +Section: main +Priority: extra +Maintainer: support@netbergtw.com +Build-Depends: debhelper (>= 8.0.0), bzip2 +Standards-Version: 3.9.3 + +Package: sonic-platform-netberg-aurora-715 +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/netberg_platform_version.sh b/platform/innovium/sonic-platform-modules-netberg/debian/netberg_platform_version.sh new file mode 100755 index 0000000000..17c6ff4cdd --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/netberg_platform_version.sh @@ -0,0 +1,14 @@ +#! /bin/sh +# driver version + +PLATFROM=$1 +PLATFROM_PATH=$2 + +export PLATFORM_DRIVER_VER='"0.3.16"' + +echo "PLATFORM_DRIVER_VER = $PLATFORM_DRIVER_VER" + +util_name=$(echo $PLATFROM) + +j2 $PLATFROM_PATH/templates/netberg_${util_name}_util.py.j2 -o $PLATFROM_PATH/utils/netberg_${util_name}_util.py +chmod 775 $PLATFROM_PATH/utils/netberg_${util_name}_util.py diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/rules b/platform/innovium/sonic-platform-modules-netberg/debian/rules new file mode 100755 index 0000000000..1f43414f76 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/rules @@ -0,0 +1,41 @@ +#!/usr/bin/make -f + +export INSTALL_MOD_DIR:=extra + +PYTHON3 ?= python3 + +PACKAGE_PRE_NAME := sonic-platform-netberg +KVERSION ?= $(shell uname -r) +KERNEL_SRC := /lib/modules/$(KVERSION) +MOD_SRC_DIR:= $(shell pwd) +MODULE_DIRS:= aurora-715 +MODULE_DIR := modules + +%: + dh $@ + +override_dh_auto_build: + (for mod in $(MODULE_DIRS); do \ + make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ + if [ -f "$${mod}/setup.py" ]; then \ + rm -rdf build; \ + $(PYTHON3) $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + fi;\ + debian/netberg_platform_version.sh $${mod} $(MOD_SRC_DIR)/$${mod}; \ + done) + + +override_dh_auto_install: + (for mod in $(MODULE_DIRS); do \ + dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko \ + debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ + done) + +override_dh_usrlocal: + +override_dh_clean: + dh_clean + (for mod in $(MODULE_DIRS); do \ + make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ + done) diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.install b/platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.install new file mode 100644 index 0000000000..b1ea30a637 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.install @@ -0,0 +1,4 @@ +aurora-715/scripts/* usr/bin +aurora-715/utils/* usr/local/bin +aurora-715/service/*.service lib/systemd/system +aurora-715/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-netberg_aurora_715-r0 diff --git a/platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.postinst b/platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.postinst new file mode 100644 index 0000000000..62659fbdc9 --- /dev/null +++ b/platform/innovium/sonic-platform-modules-netberg/debian/sonic-platform-netberg-aurora-715.postinst @@ -0,0 +1,8 @@ +#!/bin/sh + +depmod -a +systemctl enable nba715-platform-init.service +systemctl start nba715-platform-init.service + + +/usr/local/bin/netberg_nba715_platform.sh