env: add API to get NUMA socket ID of a PCI device
Change-Id: Ic13298752bd5c68e3449d7dc004bd466ef468085 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
bcd1dc93fb
commit
47eec4329e
@ -364,9 +364,9 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
{
|
||||
struct spdk_nvmf_probe_ctx *ctx = cb_ctx;
|
||||
int rc;
|
||||
char path[MAX_STRING_LEN];
|
||||
int numa_node = -1;
|
||||
struct spdk_pci_addr pci_addr;
|
||||
struct spdk_pci_device *pci_dev;
|
||||
|
||||
spdk_pci_addr_parse(&pci_addr, trid->traddr);
|
||||
|
||||
@ -375,10 +375,10 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
trid->traddr,
|
||||
spdk_nvmf_subsystem_get_nqn(ctx->app_subsystem->subsystem));
|
||||
|
||||
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/numa_node",
|
||||
trid->traddr);
|
||||
|
||||
numa_node = spdk_get_numa_node_value(path);
|
||||
pci_dev = spdk_pci_get_device(&pci_addr);
|
||||
if (pci_dev) {
|
||||
numa_node = spdk_pci_device_get_socket_id(pci_dev);
|
||||
}
|
||||
if (numa_node >= 0) {
|
||||
/* Running subsystem and NVMe device is on the same socket or not */
|
||||
if (rte_lcore_to_socket_id(ctx->app_subsystem->lcore) != (unsigned)numa_node) {
|
||||
|
@ -210,6 +210,15 @@ uint16_t spdk_pci_device_get_subdevice_id(struct spdk_pci_device *dev);
|
||||
|
||||
struct spdk_pci_id spdk_pci_device_get_id(struct spdk_pci_device *dev);
|
||||
|
||||
/**
|
||||
* Get the NUMA socket ID of a PCI device.
|
||||
*
|
||||
* \param dev PCI device to get the socket ID of.
|
||||
*
|
||||
* \return Socket ID (>= 0), or negative if unknown.
|
||||
*/
|
||||
int spdk_pci_device_get_socket_id(struct spdk_pci_device *dev);
|
||||
|
||||
int spdk_pci_device_get_serial_number(struct spdk_pci_device *dev, char *sn, size_t len);
|
||||
int spdk_pci_device_claim(const struct spdk_pci_addr *pci_addr);
|
||||
void spdk_pci_device_detach(struct spdk_pci_device *device);
|
||||
|
@ -249,6 +249,16 @@ spdk_pci_device_get_id(struct spdk_pci_device *pci_dev)
|
||||
return pci_id;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_get_socket_id(struct spdk_pci_device *pci_dev)
|
||||
{
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
return pci_dev->device.numa_node;
|
||||
#else
|
||||
return pci_dev->numa_node;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_cfg_read8(struct spdk_pci_device *dev, uint8_t *value, uint32_t offset)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user