-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update the platform Pcie plugs #3375
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
device/celestica/x86_64-cel_seastone-r0/Seastone-DX010/pcie.yaml
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 @@ | ||
devSpd: b960 | ||
devId: 5GT/s |
104 changes: 104 additions & 0 deletions
104
device/celestica/x86_64-cel_seastone-r0/plugins/pcieutil.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,104 @@ | ||
|
||
# pcieutil.py | ||
# Platform-specific PCIE status interface for SONIC | ||
# | ||
|
||
import os | ||
import yaml | ||
import subprocess | ||
|
||
try: | ||
from pcie_base import PcieBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
|
||
|
||
class PcieUtil(): | ||
"""Platform-specific PCIEutil class""" | ||
|
||
def __init__(self): | ||
self.Dict = {} | ||
|
||
|
||
# input the hwsku path | ||
def get_pcie_id(self, hwsku_path): | ||
_dict_temp = {} | ||
# get the device message | ||
config_path = hwsku_path + '/pcie.yaml' | ||
with open(config_path) as pcie_file: | ||
pcieInfo = yaml.safe_load(pcie_file) | ||
devSpd = pcieInfo['devSpd'] | ||
devId = pcieInfo['devId'] | ||
# get the device id info | ||
command = "sudo lspci -n | grep " + devId | ||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) | ||
output = proc.stdout.readlines() | ||
(out, err) = proc.communicate() | ||
|
||
if proc.returncode > 0: | ||
for line in output: | ||
print(line.strip()) | ||
return | ||
else: | ||
for line in output: | ||
busId = line.strip() | ||
venderId = line.split(":")[2].strip() | ||
deviceId = line.split(":")[3].split()[0].strip() | ||
_dict_temp['venderId'] = venderId | ||
_dict_temp['deviceId'] = deviceId | ||
self.Dict[busId] = _dict_temp | ||
return self.Dict | ||
# input the hwsku path | ||
def get_pcie_speed(self ,hwsku_path): | ||
_keyDict = {} | ||
# get the device message | ||
config_path = hwsku_path + '/pcie.yaml' | ||
with open(config_path) as pcie_file: | ||
pcieInfo = yaml.safe_load(pcie_file) | ||
devSpd = pcieInfo['devSpd'] | ||
devId = pcieInfo['devId'] | ||
# get the device key | ||
command = "sudo lspci" | ||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) | ||
output = proc.stdout.readlines() | ||
(out, err) = proc.communicate() | ||
#shell cmd return failed | ||
if proc.returncode > 0: | ||
for line in output: | ||
click.echo(line.strip()) | ||
return | ||
else: | ||
for line in output: | ||
if devId in line: | ||
_keyDict[line.split()[0]] = line.strip() | ||
# get the devicr message | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "device" |
||
for key, value in _keyDict.items(): | ||
checkin = 0 | ||
erroutput = open("/dev/null", "w") | ||
command = "sudo lspci -vvvv -s " + key | ||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=erroutput.fileno()) | ||
proc.wait() | ||
output = proc.stdout.readlines() | ||
#shell cmd return failed | ||
if proc.returncode > 0: | ||
for line in output: | ||
click.echo(line.strip()) | ||
print("shell cmd return faild: {0}".format(proc.returncode)) | ||
return | ||
else: | ||
for line in output: | ||
if "LnkSta:" in line: | ||
self.Dict[value] = line.strip() | ||
speed = line.split()[2].split(',')[0] #LnkSta: Speed 5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt- | ||
if speed == devSpd: | ||
checkin = 1 | ||
else: | ||
print("LnkSta not match which is {0}".format(speed)) | ||
return self.Dict | ||
|
||
|
||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is pci address