From patchwork Fri Oct 22 12:32:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 273951 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9MCXFf7032733 for ; Fri, 22 Oct 2010 12:33:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755931Ab0JVMdO (ORCPT ); Fri, 22 Oct 2010 08:33:14 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:65020 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755361Ab0JVMdO (ORCPT ); Fri, 22 Oct 2010 08:33:14 -0400 Received: by bwz11 with SMTP id 11so467380bwz.19 for ; Fri, 22 Oct 2010 05:33:12 -0700 (PDT) Received: by 10.204.122.11 with SMTP id j11mr2058037bkr.171.1287750718938; Fri, 22 Oct 2010 05:31:58 -0700 (PDT) Received: from localhost ([82.166.227.17]) by mx.google.com with ESMTPS id u4sm2101324bkz.17.2010.10.22.05.31.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 22 Oct 2010 05:31:58 -0700 (PDT) Date: Fri, 22 Oct 2010 14:32:05 +0200 From: root To: Roland Dreier Cc: RDMA list Subject: [PATCH] IB core: Add link layer information to sysfs Message-ID: <20101022123205.GA8923@mtldesk30> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 22 Oct 2010 12:33:16 +0000 (UTC) diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 3627300..934e27d 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -222,6 +222,19 @@ static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused, } } +static ssize_t link_layer_show(struct ib_port *p, struct port_attribute *unused, + char *buf) +{ + switch (rdma_port_get_link_layer(p->ibdev, p->port_num)) { + case IB_LINK_LAYER_INFINIBAND: + return sprintf(buf, "%s\n", "IB"); + case IB_LINK_LAYER_ETHERNET: + return sprintf(buf, "%s\n", "Ethernet"); + default: + return sprintf(buf, "%s\n", "Unknown"); + } +} + static PORT_ATTR_RO(state); static PORT_ATTR_RO(lid); static PORT_ATTR_RO(lid_mask_count); @@ -230,6 +243,7 @@ static PORT_ATTR_RO(sm_sl); static PORT_ATTR_RO(cap_mask); static PORT_ATTR_RO(rate); static PORT_ATTR_RO(phys_state); +static PORT_ATTR_RO(link_layer); static struct attribute *port_default_attrs[] = { &port_attr_state.attr, @@ -240,6 +254,7 @@ static struct attribute *port_default_attrs[] = { &port_attr_cap_mask.attr, &port_attr_rate.attr, &port_attr_phys_state.attr, + &port_attr_link_layer.attr, NULL };