forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bluefield] Add platform-api implementation. (#27)
Signed-off-by: Oleksandr Ivantsiv <oivantsiv@nvidia.com>
- Loading branch information
1 parent
15553ab
commit 71a9ee5
Showing
23 changed files
with
1,244 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
device/nvidia-bluefield/arm64-nvda_bf-mbf2h536c/platform.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"chassis": { | ||
"name": "Nvidia-MBF2H536C", | ||
"components": [], | ||
"fans": [], | ||
"fan_drawers": [], | ||
"psus": [], | ||
"thermals": [], | ||
"sfps": [ | ||
{ | ||
"name": "p0" | ||
}, | ||
{ | ||
"name": "p1" | ||
} | ||
] | ||
}, | ||
"interfaces": { | ||
"Ethernet0": { | ||
"index": "1,1,1,1", | ||
"lanes": "0,1,2,3", | ||
"breakout_modes": { | ||
"1x100G": ["etp1"] | ||
} | ||
}, | ||
"Ethernet4": { | ||
"index": "2,2,2,2", | ||
"lanes": "4,5,6,7", | ||
"breakout_modes": { | ||
"1x100G": ["etp2"] | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
device/nvidia-bluefield/arm64-nvda_bf-mbf2m516a/platform.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"chassis": { | ||
"name": "Nvidia-MBF2H516A", | ||
"components": [], | ||
"fans": [], | ||
"fan_drawers": [], | ||
"psus": [], | ||
"thermals": [], | ||
"sfps": [ | ||
{ | ||
"name": "p0" | ||
}, | ||
{ | ||
"name": "p1" | ||
} | ||
] | ||
}, | ||
"interfaces": { | ||
"Ethernet0": { | ||
"index": "1,1,1,1", | ||
"lanes": "0,1,2,3", | ||
"breakout_modes": { | ||
"1x100G": ["etp1"] | ||
} | ||
}, | ||
"Ethernet4": { | ||
"index": "2,2,2,2", | ||
"lanes": "4,5,6,7", | ||
"breakout_modes": { | ||
"1x100G": ["etp2"] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.pyc | ||
.cache/ | ||
*/test-results.xml | ||
*/htmlcov/ | ||
*/coverage.xml | ||
*/.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## | ||
## Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. | ||
## Apache-2.0 | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
[pytest] | ||
addopts = --cov=sonic_platform --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -vv | ||
filterwarnings = | ||
ignore::DeprecationWarning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[aliases] | ||
test=pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. | ||
# Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from setuptools import setup | ||
|
||
setup( | ||
name='platform-api', | ||
version='1.0', | ||
description='SONiC platform API implementation on NVIDIA BlueField platform', | ||
license='Apache 2.0', | ||
author='NVIDIA SONiC Team', | ||
author_email='oivantsiv@nvidia.com', | ||
url='https://github.com/Azure/sonic-buildimage', | ||
maintainer='Oleksandr Ivantsiv', | ||
maintainer_email='oivantsiv@nvidia.com', | ||
packages=[ | ||
'sonic_platform', | ||
'tests' | ||
], | ||
setup_requires= [ | ||
'pytest-runner' | ||
], | ||
tests_require = [ | ||
'pytest', | ||
'mock>=2.0.0' | ||
], | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', | ||
'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 :: 3.7', | ||
'Topic :: Utilities', | ||
], | ||
keywords='sonic SONiC platform PLATFORM', | ||
test_suite='setup.get_test_suite' | ||
) |
18 changes: 18 additions & 0 deletions
18
platform/nvidia-bluefield/platform-api/sonic_platform/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. | ||
# Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
__all__ = ["platform", "chassis"] | ||
from sonic_platform import * |
155 changes: 155 additions & 0 deletions
155
platform/nvidia-bluefield/platform-api/sonic_platform/chassis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# | ||
# Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. | ||
# Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
try: | ||
from sonic_platform_base.chassis_base import ChassisBase | ||
from sonic_py_common.logger import Logger | ||
import os | ||
from functools import reduce | ||
|
||
from . import utils | ||
from .device_data import DeviceDataManager | ||
from .sfp import Sfp | ||
from .eeprom import Eeprom | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
MAX_SELECT_DELAY = 3600 | ||
|
||
|
||
# Global logger class instance | ||
logger = Logger() | ||
|
||
|
||
class Chassis(ChassisBase): | ||
"""Platform-specific Chassis class""" | ||
|
||
def __init__(self): | ||
super(Chassis, self).__init__() | ||
|
||
# Initialize DMI data | ||
self.dmi_data = None | ||
|
||
self.device_data = DeviceDataManager() | ||
self._initialize_sfp() | ||
self.sfp_event = None | ||
self._eeprom = Eeprom() | ||
logger.log_info("Chassis loaded successfully") | ||
|
||
def _initialize_sfp(self): | ||
self._sfp_list = [] | ||
|
||
sfp_count = self.get_num_sfps() | ||
for index in range(sfp_count): | ||
sfp_module = Sfp(index, self.device_data.get_sfp_data(index)) | ||
self._sfp_list.append(sfp_module) | ||
|
||
def get_sfp(self, index): | ||
return super(Chassis, self).get_sfp(index - 1) | ||
|
||
def get_num_sfps(self): | ||
""" | ||
Retrieves the number of sfps available on this chassis | ||
Returns: | ||
An integer, the number of sfps available on this chassis | ||
""" | ||
return self.device_data.get_sfp_count() | ||
|
||
def get_eeprom(self): | ||
""" | ||
Retreives eeprom device on this chassis | ||
Returns: | ||
An object derived from WatchdogBase representing the hardware | ||
eeprom device | ||
""" | ||
return self._eeprom | ||
|
||
def get_name(self): | ||
""" | ||
Retrieves the name of the device | ||
Returns: | ||
string: The name of the device | ||
""" | ||
return self._eeprom.get_product_name() | ||
|
||
def get_model(self): | ||
""" | ||
Retrieves the model number (or part number) of the device | ||
Returns: | ||
string: Model/part number of device | ||
""" | ||
return self._eeprom.get_part_number() | ||
|
||
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.get_base_mac() | ||
|
||
def get_serial(self): | ||
""" | ||
Retrieves the hardware serial number for the chassis | ||
Returns: | ||
A string containing the hardware serial number for this chassis. | ||
""" | ||
return self._eeprom.get_serial_number() | ||
|
||
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.get_system_eeprom_info() | ||
|
||
def get_revision(self): | ||
""" | ||
Retrieves the hardware revision of the device | ||
Returns: | ||
string: Revision value of device | ||
""" | ||
return self._eeprom.get_revision() | ||
|
||
def get_position_in_parent(self): | ||
""" | ||
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position | ||
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned | ||
Returns: | ||
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position | ||
""" | ||
return -1 | ||
|
||
def is_replaceable(self): | ||
""" | ||
Indicate whether this device is replaceable. | ||
Returns: | ||
bool: True if it is replaceable. | ||
""" | ||
return False |
Oops, something went wrong.