[PATCH rdma-next 14/16] RDMA/restrack: Introduce range support for IDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky <leonro@xxxxxxxxxxxx>

The IDs are supposed to be generated in ranges with reserved slots for
HW management, (e.g. reserved_pd in mlx4 and hns), so provide extra
function to set supported range.

This function was names rdma_rt_* and not rdma_restrack_* to simplify
the usage and spread across drivers.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/restrack.c | 18 ++++++++++++++++++
 include/rdma/restrack.h            | 11 +++++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
index c50e95a82915..a3c94fe910a2 100644
--- a/drivers/infiniband/core/restrack.c
+++ b/drivers/infiniband/core/restrack.c
@@ -27,6 +27,14 @@ struct rdma_restrack_root {
 	 * @xa: Array of XArray structure to hold restrack entries.
 	 */
 	struct xarray xa;
+	/**
+	 * @reserved: Keep aside this number of indexes
+	 */
+	u32 reserved;
+	/**
+	 * @max: Maximal supported numer of indexes
+	 */
+	u32 max;
 };
 
 int rdma_restrack_init(struct ib_device *dev)
@@ -354,3 +362,13 @@ void rdma_restrack_del(struct rdma_restrack_entry *res)
 	}
 }
 EXPORT_SYMBOL(rdma_restrack_del);
+
+void rdma_rt_set_id_range(struct ib_device *dev, enum rdma_restrack_type type,
+			  u32 reserved, u32 max)
+{
+	struct rdma_restrack_root *rt = dev->res;
+
+	rt[type].max = max;
+	rt[type].reserved = reserved;
+}
+EXPORT_SYMBOL(rdma_rt_set_id_range);
diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h
index 09cc4eff3f9d..4dba2e0ec90e 100644
--- a/include/rdma/restrack.h
+++ b/include/rdma/restrack.h
@@ -195,4 +195,15 @@ void rdma_rt_read_lock(struct ib_device *dev, enum rdma_restrack_type type);
  * @type: resource track type
  */
 void rdma_rt_read_unlock(struct ib_device *dev, enum rdma_restrack_type type);
+/**
+ * rdma_rt_set_id_range() - initialize IDs range. Devices which are able
+ *                          to manage thos IDs in HW will leave max and reserved
+ *                          as zero.
+ * @dev: IB device to work
+ * @type: resource track type
+ * @reserved: number of entries to keep aside
+ * @max: maximal possible value
+ */
+void rdma_rt_set_id_range(struct ib_device *dev, enum rdma_restrack_type type,
+			  u32 reserved, u32 max);
 #endif /* _RDMA_RESTRACK_H_ */
-- 
2.19.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux