Repository navigation
Get device/vendor ids of SF from its parent PCI - #5964
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| #define UCT_IB_DEVICE_SYSFS_GID_TYPE_FMT UCT_IB_DEVICE_SYSFS_GID_ATTR_PFX "/types/%d" | ||
| #define UCT_IB_DEVICE_SYSFS_GID_NDEV_FMT UCT_IB_DEVICE_SYSFS_GID_ATTR_PFX "/ndevs/%d" | ||
|
|
||
| #define UCT_IB_PCI_BUS_ID_LEN 7 /* PCI BUS ID */ |
There was a problem hiding this comment.
@yosefe We need the real length of 0000:03 which is 7 to memcpy 0000:03 from 0000:03:00.0.
There was a problem hiding this comment.
@yosefe Or is it better to use something like strstr(":") to get the length of 0000:03 then we don't need to define monstant here?
There was a problem hiding this comment.
@yosefe Maybe no need to do this because the pci bus id and format is pretty fixed. No need to add more code and logic to parse it.
|
bot:pipe:retest |
| /* get 0000:03 from 0000:03:00.0*/ | ||
| memcpy(pci_bus, bus_id, UCT_IB_PCI_BUS_ID_LEN); | ||
| pci_bus[UCT_IB_PCI_BUS_ID_LEN] = 0; |
There was a problem hiding this comment.
can we unite common code with uct_ib_device_get_sys_dev ?
There was a problem hiding this comment.
@yosefe This is not common code with uct_ib_device_get_sys_dev. uct_ib_device_get_sys_dev doesn't need to use 0000:03. It only needs 0000:03:00.0.
| status = ucs_read_file_number(&vendor_id, 1, UCT_IB_DEVICE_SYSFS_PCI_BUS_FMT, | ||
| pci_bus, bus_id, "vendor"); | ||
| if (status != UCS_OK) { | ||
| return status; | ||
| } | ||
|
|
||
| /* /sys/class/pci_bus/0000:03/device/0000:03:00.0/device */ | ||
| status = ucs_read_file_number(&device_id, 1, UCT_IB_DEVICE_SYSFS_PCI_BUS_FMT, | ||
| pci_bus, bus_id, "device"); | ||
| if (status != UCS_OK) { |
There was a problem hiding this comment.
can we unite common code with 549-552?
There was a problem hiding this comment.
@yosefe Tried, but seems not simply to do it. The SYSFS path format is much different for both places, the contents and path layers are different. Need much more code to deal with the diffrence.
| return status; | ||
| } | ||
|
|
||
| bus_id = basename(dirname(dirname(dirname(path_buffer)))); |
There was a problem hiding this comment.
check return values from dirname
| #define UCT_IB_DEVICE_SYSFS_GID_TYPE_FMT UCT_IB_DEVICE_SYSFS_GID_ATTR_PFX "/types/%d" | ||
| #define UCT_IB_DEVICE_SYSFS_GID_NDEV_FMT UCT_IB_DEVICE_SYSFS_GID_ATTR_PFX "/ndevs/%d" | ||
|
|
||
| #define UCT_IB_PCI_BUS_ID_LEN 7 /* PCI BUS ID */ |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
bot:pipe:retest |
1 similar comment
|
bot:pipe:retest |
bb4245e to
abcf45e
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| return UCS_OK; | ||
| } | ||
|
|
||
| char* uct_ib_device_get_pcie_bus(char *path_buffer, uint8_t layers) |
There was a problem hiding this comment.
add function to UCS:
ucs_dirname(chat *dir_path, int num_layers)
pls add doxygen and small gtest for this function
| return basename(path_buffer); | ||
| } | ||
|
|
||
| static ucs_status_t uct_ib_device_get_ids_from_path(char *path, |
| return status; | ||
| } | ||
|
|
||
| bus_id = uct_ib_device_get_pcie_bus(path_buffer, 3); |
There was a problem hiding this comment.
seems like 'bus_id' here, after stripping 3 directory components, already points to the SF
$ cat $(realpath /sys/class/infiniband/mlx5_0)/../../../vendor
0x15b3
$ cat $(realpath /sys/class/infiniband/mlx5_0)/../../../device
0xa2d6
$ cat $(realpath /sys/class/infiniband/mlx5_0)/../../../current_link_speed
16 GT/s
|
bot:pipe:retest |
|
|
||
| char *ucs_dirname(char *path, int num_layers) | ||
| { | ||
| while (num_layers--) { |
There was a problem hiding this comment.
@yosefe Should not have problem when num_layers==0 since "--" is after num_layers. When num_layers==0, won't go into while loop, will only return path.
There was a problem hiding this comment.
sorry, github re-formatted my comment
i've meant:
while (num_layers-- > 0)
| for (i = 0; i < 2; i++) { | ||
| ids_path = ucs_dirname(path_buffer, nums_layers[i]); |
There was a problem hiding this comment.
call ucs_dirname twice, without loop
also, need to reset path_buffer before 2nd call because ucs_dirname may change it
There was a problem hiding this comment.
Fixed. You detected a bug which caused by my fixing on PF but didn't retest on SF. Thanks!
| for (i = 0; i < 2; i++) { | ||
| ids_path = ucs_dirname(path_buffer, nums_layers[i]); | ||
| if (ids_path != NULL) { | ||
| if (uct_ib_device_get_ids_from_path(ids_path, &vendor_id, &device_id) == UCS_OK) { |
There was a problem hiding this comment.
maybe pass &dev->pci_id.vendor and &dev->pci_id.device?
There was a problem hiding this comment.
@yosefe Can't pass them directly since the variable types are different with the function parameters. Have changed to another way.
| pcie_bus = ucs_dirname(path_buffer, 2); | ||
| if (pcie_bus == NULL) { | ||
| return UCS_SYS_DEVICE_ID_UNKNOWN; | ||
| } |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| /* SF: realpath name is of form /sys/devices/.../0000:03:00.0/<UUID>/infiniband/mlx5_0 */ | ||
|
|
||
| status = uct_ib_device_get_path_buffer(dev, path_buffer); | ||
| if (status == UCS_OK) { |
There was a problem hiding this comment.
if (status != UCS_OK) {
goto not_found;
}
...
not_found:
dev->pci_id.vendor = 0;
...
| if (status == UCS_OK) { | ||
| /* PF: strip 2 layers. */ | ||
| ids_path = ucs_dirname(path_buffer, 2); | ||
| if (ids_path != NULL) { |
There was a problem hiding this comment.
if (ids_path == NULL) {
goto not_found;
}
| /* PF: strip 2 layers. */ | ||
| ids_path = ucs_dirname(path_buffer, 2); | ||
| if (ids_path != NULL) { | ||
| if (uct_ib_device_get_ids_from_path(ids_path, |
There was a problem hiding this comment.
status = uct_ib_device_get_ids_from_path(...)
if (status == UCS_OK) {
....
return;
}
/* SF: strip 3 layers (1 more layer than PF). */
ids_path = ucs_dirname(path_buffer, 1);
...
| if (status == UCS_OK) { | ||
| ucs_debug("SF: %s vendor_id: 0x%x device_id: %d", uct_ib_device_name(dev), | ||
| dev->pci_id.vendor, dev->pci_id.device); | ||
| return; |
| #define UCT_IB_DEVICE_SYSFS_PCI_PFX "/sys/class/pci_bus/%s" | ||
| #define UCT_IB_DEVICE_SYSFS_PCI_PATH_FMT UCT_IB_DEVICE_SYSFS_PCI_PFX "/device/%s" |
There was a problem hiding this comment.
Yes, according latest implementation they are unused. Removed. Thanks!
| #define UCT_IB_DEFAULT_ROCEV2_DSCP 106 /* Default DSCP for RoCE v2 */ | ||
| #define UCT_IB_ROCE_UDP_SRC_PORT_BASE 0xC000 | ||
| #define UCT_IB_DEVICE_SYSFS_PFX "/sys/class/infiniband/%s" | ||
| #define UCT_IB_DEVICE_SYSFS_PATH_FMT UCT_IB_DEVICE_SYSFS_PFX "/device" |
Done. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
What
Get device/vendor ids of SF from its parent PCI.
Why ?
We can't get device/vendor ids of SF from its sysfs directly, so we get the ids from SF's parent PCI.
How ?
Get the parent PCI of SF, then get the device/vendor ids of parent PCI. The SF has the same device/vendor ids as its parent PCI.