From patchwork Sun Sep 6 09:30:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haggai Abramonvsky X-Patchwork-Id: 7131281 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3B8E1BEEC1 for ; Sun, 6 Sep 2015 09:31:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 277B1207BF for ; Sun, 6 Sep 2015 09:31:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AE5D207CF for ; Sun, 6 Sep 2015 09:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751262AbbIFJbt (ORCPT ); Sun, 6 Sep 2015 05:31:49 -0400 Received: from [193.47.165.129] ([193.47.165.129]:44583 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751037AbbIFJbp (ORCPT ); Sun, 6 Sep 2015 05:31:45 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from hagaya@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 Sep 2015 12:30:56 +0300 Received: from vnc20.mtl.labs.mlnx (vnc20.mtl.labs.mlnx [10.7.2.20]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t869Uo84031942; Sun, 6 Sep 2015 12:30:50 +0300 From: Haggai Abramonvsky To: Eli Cohen Cc: linux-rdma@vger.kernel.org, Doug Ledford , Haggai Abramonvsky Subject: [PATCH libmlx5 1/5] Add infrastructure for resource tracking Date: Sun, 6 Sep 2015 12:30:08 +0300 Message-Id: <1441531812-27716-2-git-send-email-hagaya@mellanox.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <1441531812-27716-1-git-send-email-hagaya@mellanox.com> References: <1441531812-27716-1-git-send-email-hagaya@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add new struct member, mlx5_resource, for each tracked object, to allow retrieving the object in the poll_cq once we need it. Signed-off-by: Haggai Abramovsky --- src/mlx5.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mlx5.h b/src/mlx5.h index 6ad79fe..4dda0bf 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)