From patchwork Tue Feb 2 18:50:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Majd Dibbiny X-Patchwork-Id: 8194091 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4411D9F3CD for ; Tue, 2 Feb 2016 18:51:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 613EC202B8 for ; Tue, 2 Feb 2016 18:51:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 728D92025B for ; Tue, 2 Feb 2016 18:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933439AbcBBSva (ORCPT ); Tue, 2 Feb 2016 13:51:30 -0500 Received: from [193.47.165.129] ([193.47.165.129]:49946 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S965384AbcBBSv1 (ORCPT ); Tue, 2 Feb 2016 13:51:27 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from majd@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Feb 2016 20:51:04 +0200 Received: from vnc21.mtl.labs.mlnx (vnc21.mtl.labs.mlnx [10.7.2.21]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id u12Ip40U029333; Tue, 2 Feb 2016 20:51:04 +0200 From: Majd Dibbiny To: yishaih@mellanox.com Cc: linux-rdma@vger.kernel.org, matanb@mellanox.com, talal@mellanox.com, majd@mellanox.com, cl@linux.com, Haggai Abramovsky Subject: [PATCH libmlx5 1/7] Add infrastructure for resource identification Date: Tue, 2 Feb 2016 20:50:55 +0200 Message-Id: <1454439061-929-2-git-send-email-majd@mellanox.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <1454439061-929-1-git-send-email-majd@mellanox.com> References: <1454439061-929-1-git-send-email-majd@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.3 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 From: Haggai Abramovsky 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. Reviewed-by:: Yishai Hadas Signed-off-by: Haggai Abramovsky Signed-off-by: Majd Dibbiny --- src/mlx5.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mlx5.h b/src/mlx5.h index 9181ec5..a930bac 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)