From patchwork Fri Mar 30 18:03:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Wise X-Patchwork-Id: 10318261 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 280506055B for ; Fri, 30 Mar 2018 18:09:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 184432A62A for ; Fri, 30 Mar 2018 18:09:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B5DD2A62C; Fri, 30 Mar 2018 18:09:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914872A62A for ; Fri, 30 Mar 2018 18:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478AbeC3SJj (ORCPT ); Fri, 30 Mar 2018 14:09:39 -0400 Received: from opengridcomputing.com ([70.118.0.34]:55288 "EHLO smtp.opengridcomputing.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752474AbeC3SJj (ORCPT ); Fri, 30 Mar 2018 14:09:39 -0400 Received: by smtp.opengridcomputing.com (Postfix, from userid 503) id 55CD82BC61; Fri, 30 Mar 2018 13:09:38 -0500 (CDT) Message-Id: In-Reply-To: References: From: Steve Wise Date: Fri, 30 Mar 2018 11:03:39 -0700 Subject: [PATCH v3 rdma-next 3/5] RDMA/nldev: add provider-specific device/port tracking To: jgg@mellanox.com, dledford@redhat.com Cc: leon@kernel.org, linux-rdma@vger.kernel.org Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add fill_dev_info and fill_port_info functions to rdma_restrack_root. This allows providers to have provider-specific fill functions for device and port restrack operations. Signed-off-by: Steve Wise --- drivers/infiniband/core/nldev.c | 24 ++++++++++++++++++++++-- drivers/infiniband/core/restrack.c | 2 ++ include/rdma/restrack.h | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index 1a680a3..0610313 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -114,6 +114,20 @@ static int provider_fill_res_entry(struct rdma_restrack_root *resroot, resroot->fill_res_entry(msg, res) : 0; } +static int provider_fill_dev_info(struct sk_buff *msg, + struct ib_device *device) +{ + return device->res.fill_dev_info ? + device->res.fill_dev_info(msg, device) : 0; +} + +static int provider_fill_port_info(struct sk_buff *msg, + struct ib_device *device, u32 port) +{ + return device->res.fill_port_info ? + device->res.fill_port_info(msg, device, port) : 0; +} + static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device) { if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index)) @@ -155,11 +169,15 @@ static int fill_dev_info(struct sk_buff *msg, struct ib_device *device) return -EMSGSIZE; if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device->node_type)) return -EMSGSIZE; + + if (provider_fill_dev_info(msg, device)) + return -EMSGSIZE; + return 0; } -static int fill_port_info(struct sk_buff *msg, - struct ib_device *device, u32 port) +static int fill_port_info(struct sk_buff *msg, struct ib_device *device, + u32 port) { struct ib_port_attr attr; int ret; @@ -194,6 +212,8 @@ static int fill_port_info(struct sk_buff *msg, return -EMSGSIZE; if (nla_put_u8(msg, RDMA_NLDEV_ATTR_PORT_PHYS_STATE, attr.phys_state)) return -EMSGSIZE; + if (provider_fill_port_info(msg, device, port)) + return -EMSGSIZE; return 0; } diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c index 78fc6d9..76a8d75 100644 --- a/drivers/infiniband/core/restrack.c +++ b/drivers/infiniband/core/restrack.c @@ -16,6 +16,8 @@ void rdma_restrack_init(struct rdma_restrack_root *res) { init_rwsem(&res->rwsem); res->fill_res_entry = NULL; + res->fill_dev_info = NULL; + res->fill_port_info = NULL; } static const char *type2str(enum rdma_restrack_type type) diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h index 51f400e..525f885 100644 --- a/include/rdma/restrack.h +++ b/include/rdma/restrack.h @@ -45,6 +45,7 @@ enum rdma_restrack_type { #define RDMA_RESTRACK_HASH_BITS 8 struct rdma_restrack_entry; +struct ib_device; /** * struct rdma_restrack_root - main resource tracking management @@ -66,6 +67,19 @@ struct rdma_restrack_root { */ int (*fill_res_entry)(struct sk_buff *msg, struct rdma_restrack_entry *entry); + /** + * @fill_dev_info: provider-specific fill function + * + * Allows rdma providers to add their own device attributes. + */ + int (*fill_dev_info)(struct sk_buff *msg, struct ib_device *device); + /** + * @fill_port_info: provider-specific fill function + * + * Allows rdma providers to add their own port attributes. + */ + int (*fill_port_info)(struct sk_buff *msg, struct ib_device *device, + u32 port); }; /**