RDMA: Lift ibdev_to_node from rds to common code
authorChristoph Hellwig <hch@lst.de>
Fri, 6 Nov 2020 18:19:34 +0000 (19:19 +0100)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 12 Nov 2020 17:33:44 +0000 (13:33 -0400)
Lift the ibdev_to_node from rds to common code and document it.

Link: https://lore.kernel.org/r/20201106181941.1878556-4-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
include/rdma/ib_verbs.h
net/rds/ib.h

index a0f9b1c..3feb42e 100644 (file)
@@ -4549,6 +4549,19 @@ static inline struct ib_device *rdma_device_to_ibdev(struct device *device)
        return coredev->owner;
 }
 
+/**
+ * ibdev_to_node - return the NUMA node for a given ib_device
+ * @dev:       device to get the NUMA node for.
+ */
+static inline int ibdev_to_node(struct ib_device *ibdev)
+{
+       struct device *parent = ibdev->dev.parent;
+
+       if (!parent)
+               return NUMA_NO_NODE;
+       return dev_to_node(parent);
+}
+
 /**
  * rdma_device_to_drv_device - Helper macro to reach back to driver's
  *                            ib_device holder structure from device pointer.
index 8dfff43..c23a11d 100644 (file)
@@ -264,13 +264,6 @@ struct rds_ib_device {
        int                     *vector_load;
 };
 
-static inline int ibdev_to_node(struct ib_device *ibdev)
-{
-       struct device *parent;
-
-       parent = ibdev->dev.parent;
-       return parent ? dev_to_node(parent) : NUMA_NO_NODE;
-}
 #define rdsibdev_to_node(rdsibdev) ibdev_to_node(rdsibdev->dev)
 
 /* bits for i_ack_flags */