diff mbox

[libmlx5,v1,1/5] libmlx5: Add infrastructure for resource identification

Message ID 1447587059-26725-2-git-send-email-hagaya@dev-l-vrt-198-005.mtl.labs.mlnx (mailing list archive)
State Superseded
Headers show

Commit Message

Haggai Abramonvsky Nov. 15, 2015, 11:30 a.m. UTC
From: Haggai Abramonvsky <hagaya@mellanox.com>

Add new struct member, mlx5_resource, for each tracked object, mlx5_srq
and mlx5_qp, to allow retrieving the object in the  poll_cq once we need
it.

Change-Id: Id7d1356cc866fa0aa06d256df9f3612dc1988e6a
Signed-off-by: Haggai Abramovsky <hagaya@mellanox.com>
---
 src/mlx5.h | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/mlx5.h b/src/mlx5.h
index 92ef33d..d8ce908 100644
--- a/src/mlx5.h
+++ b/src/mlx5.h
@@ -228,6 +228,18 @@  enum mlx5_alloc_type {
 	MLX5_ALLOC_TYPE_ALL
 };
 
+enum mlx5_rsc_type {
+	MLX5_RSC_TYPE_QP,
+	MLX5_RSC_TYPE_XSRQ,
+	MLX5_RSC_TYPE_SRQ,
+	MLX5_RSC_TYPE_INVAL,
+};
+
+struct mlx5_resource {
+	enum mlx5_rsc_type      type;
+	uint32_t                rsn;
+};
+
 struct mlx5_device {
 	struct verbs_device	verbs_dev;
 	int			page_size;
@@ -341,6 +353,7 @@  struct mlx5_cq {
 };
 
 struct mlx5_srq {
+	struct mlx5_resource            rsc;  /* This struct must be first */
 	struct verbs_srq		vsrq;
 	struct mlx5_buf			buf;
 	struct mlx5_spinlock		lock;
@@ -392,6 +405,7 @@  struct mlx5_mr {
 };
 
 struct mlx5_qp {
+	struct mlx5_resource            rsc; /* This struct must be first */
 	struct verbs_qp			verbs_qp;
 	struct ibv_qp			ibv_qp;
 	struct mlx5_buf                 buf;
@@ -491,7 +505,9 @@  static inline struct mlx5_cq *to_mcq(struct ibv_cq *ibcq)
 
 static inline struct mlx5_srq *to_msrq(struct ibv_srq *ibsrq)
 {
-	return (struct mlx5_srq *)ibsrq;
+	struct verbs_srq *vsrq = (struct verbs_srq *)ibsrq;
+
+	return container_of(vsrq, struct mlx5_srq, vsrq);
 }
 
 static inline struct mlx5_qp *to_mqp(struct ibv_qp *ibqp)