From patchwork Mon May 4 06:14:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 6323261 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 0F324BEEE1 for ; Mon, 4 May 2015 06:15:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BD51201C0 for ; Mon, 4 May 2015 06:15:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00B74201BC for ; Mon, 4 May 2015 06:15:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbbEDGPH (ORCPT ); Mon, 4 May 2015 02:15:07 -0400 Received: from mga03.intel.com ([134.134.136.65]:22147 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbbEDGPG (ORCPT ); Mon, 4 May 2015 02:15:06 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 03 May 2015 23:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,364,1427785200"; d="scan'208";a="720145930" Received: from phlsvsds.ph.intel.com ([10.228.195.38]) by fmsmga002.fm.intel.com with ESMTP; 03 May 2015 23:15:04 -0700 Received: from phlsvsds.ph.intel.com (localhost.localdomain [127.0.0.1]) by phlsvsds.ph.intel.com (8.13.8/8.13.8) with ESMTP id t446F4bE000393; Mon, 4 May 2015 02:15:04 -0400 Received: (from iweiny@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id t446F4o3000390; Mon, 4 May 2015 02:15:04 -0400 X-Authentication-Warning: phlsvsds.ph.intel.com: iweiny set sender to ira.weiny@intel.com using -f From: ira.weiny@intel.com To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Ira Weiny Subject: [RFC PATCH 1/5] IB/core: Add Core Capability flags to ib_device Date: Mon, 4 May 2015 02:14:55 -0400 Message-Id: <1430720099-32512-2-git-send-email-ira.weiny@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1430720099-32512-1-git-send-email-ira.weiny@intel.com> References: <1430720099-32512-1-git-send-email-ira.weiny@intel.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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Ira Weiny Add Core capability flags to each port attribute and read those into ib_device upon registration for each port. Signed-off-by: Ira Weiny Signed-off-by: Upinder Malhi Signed-off-by: Roland Dreier --- drivers/infiniband/core/device.c | 41 ++++++++++++++++++++++++++++++++++++++ include/rdma/ib_verbs.h | 22 ++++++++++++++++++++ 2 files changed, 63 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index b360350..6a37255 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -262,6 +262,37 @@ out: return ret; } +static int read_core_cap_flags(struct ib_device *device) +{ + struct ib_port_attr tprops; + int num_ports, ret = -ENOMEM; + u8 port_index; + + num_ports = device->phys_port_cnt; + + device->core_cap_flags = kzalloc(sizeof(*device->core_cap_flags) + * (num_ports+1), + GFP_KERNEL); + if (!device->core_cap_flags) + return -ENOMEM; + + for (port_index = 0; port_index <= num_ports; ++port_index) { + if ((port_index == 0 && device->node_type != RDMA_NODE_IB_SWITCH)) + continue; + + ret = ib_query_port(device, port_index, &tprops); + if (ret) + goto err; + + device->core_cap_flags[port_index] = tprops.core_cap_flags; + } + + return 0; +err: + kfree(device->core_cap_flags); + return ret; +} + /** * ib_register_device - Register an IB device with IB core * @device:Device to register @@ -302,12 +333,21 @@ int ib_register_device(struct ib_device *device, goto out; } + ret = read_core_cap_flags(device); + if (ret) { + dev_err(&device->dev, "Couldn't create Core Capability flags\n"); + kfree(device->gid_tbl_len); + kfree(device->pkey_tbl_len); + goto out; + } + ret = ib_device_register_sysfs(device, port_callback); if (ret) { printk(KERN_WARNING "Couldn't register device %s with driver model\n", device->name); kfree(device->gid_tbl_len); kfree(device->pkey_tbl_len); + kfree(device->core_cap_flags); goto out; } @@ -351,6 +391,7 @@ void ib_unregister_device(struct ib_device *device) kfree(device->gid_tbl_len); kfree(device->pkey_tbl_len); + kfree(device->core_cap_flags); mutex_unlock(&device_mutex); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index c724114..4de2758 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -353,11 +353,32 @@ union rdma_protocol_stats { struct iw_protocol_stats iw; }; +/* Define bits for the various functionality this port needs to be supported by + * the core. + */ +/* Management 0x00000000FFFFFFFF */ +#define RDMA_CORE_CAP_IB_MAD 0x0000000000000001ULL +#define RDMA_CORE_CAP_IB_SMI 0x0000000000000002ULL +#define RDMA_CORE_CAP_IB_CM 0x0000000000000004ULL +#define RDMA_CORE_CAP_IW_CM 0x0000000000000008ULL +#define RDMA_CORE_CAP_IB_SA 0x0000000000000010ULL + +/* Address format 0x0000FFFF00000000 */ +#define RDMA_CORE_CAP_AF_IB 0x0000000100000000ULL +#define RDMA_CORE_CAP_ETH_AH 0x0000000200000000ULL + +/* Protocol 0xFFFF000000000000 */ +#define RDMA_CORE_CAP_PROT_IB 0x0001000000000000ULL +#define RDMA_CORE_CAP_PROT_IBOE 0x0002000000000000ULL +#define RDMA_CORE_CAP_PROT_IWARP 0x0004000000000000ULL +#define RDMA_CORE_CAP_PROT_USNIC_UDP 0x0008000000000000ULL + struct ib_port_attr { enum ib_port_state state; enum ib_mtu max_mtu; enum ib_mtu active_mtu; int gid_tbl_len; + u64 core_cap_flags; u32 port_cap_flags; u32 max_msg_sz; u32 bad_pkey_cntr; @@ -1684,6 +1705,7 @@ struct ib_device { u32 local_dma_lkey; u8 node_type; u8 phys_port_cnt; + u64 *core_cap_flags; /* Per port core capability flags */ }; struct ib_client {