[Mellanox][pcied] Ignore bus on pcie.yaml for Mellanox switches#8063
[Mellanox][pcied] Ignore bus on pcie.yaml for Mellanox switches#8063sujinmkang merged 1 commit intosonic-net:masterfrom
Conversation
|
This pull request introduces 1 alert when merging 06ce2c37a8aea536329e32ca230b0d9271fa40db into fe6e4c3 - view on LGTM.com new alerts:
|
|
@sujinmkang can you please review. |
f1e2a32 to
7cb1cc2
Compare
| for folder in device_folders: | ||
| # For each folder in the sysfs tree we check if it matches the normal PCIe device folder pattern, | ||
| # If match we add the device id from the device file and the bus from the folder name to the map | ||
| pattern_for_device_folder = re.search('....:(..):..\..', folder) |
There was a problem hiding this comment.
An example for a dir name is: 0000:ff:0b.1
The name of the folder is created from: {4 digit of domain - always 0}:{2 hex digit of bus}:{2 hex digit - dev}.{fn}
You can see this pattern of the folder name also here:
https://github.com/Azure/sonic-platform-common/blob/87c81de7193ee68568543d982fb8ba38f5e4ad07/sonic_platform_base/sonic_pcie/pcie_common.py#L106
I use this regex to look for the bus (in the above example 'ff').
The dots match any character, so I am checking if the folder that starts with 4 characters (domain), colon, 2 characters of bus (they are in parentheses to create the group I am looking for), a colon, 2 characters of dev, a dot, and the fn.
I tried to create the simplest regex, but I would be glad to hear if you have a different suggestion
| if pattern_for_device_folder: | ||
| bus = pattern_for_device_folder.group(1) | ||
| with open(os.path.join('/sys/bus/pci/devices', folder, 'device'), 'r') as device_file: | ||
| device_id = device_file.read().replace('\n', '').replace('0x', '') |
There was a problem hiding this comment.
An example of the contact of a file:
0x6fe2
I am looking for the '6fe2' part only. I will add a comment regarding this, and maybe will make it simpler by changing the first replace to strip
Why I did it BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available How I did it Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id. How to verify it Verify no errors or failures in pcied on different BIOS version with the same code base.
Why I did it BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available How I did it Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id. How to verify it Verify no errors or failures in pcied on different BIOS version with the same code base.
…c-net#8063) Why I did it BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available How I did it Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id. How to verify it Verify no errors or failures in pcied on different BIOS version with the same code base.
Why I did it
BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available
How I did it
Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id.
How to verify it
Verify no errors or failures in pcied on different BIOS version with the same code base.
Which release branch to backport (provide reason below if selected)
Description for the changelog
A picture of a cute animal (not mandatory but encouraged)