From patchwork Thu Apr 20 08:15:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 9689845 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 E3D9060326 for ; Thu, 20 Apr 2017 08:16:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D16402845C for ; Thu, 20 Apr 2017 08:16:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C295728464; Thu, 20 Apr 2017 08:16:13 +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, UNPARSEABLE_RELAY 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 1674B2845C for ; Thu, 20 Apr 2017 08:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943557AbdDTIQL (ORCPT ); Thu, 20 Apr 2017 04:16:11 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:40170 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S942133AbdDTIQH (ORCPT ); Thu, 20 Apr 2017 04:16:07 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v3K8FtAu026919 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Apr 2017 08:15:56 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v3K8FtJE023010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Apr 2017 08:15:55 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v3K8Frl2010698; Thu, 20 Apr 2017 08:15:54 GMT Received: from redman.cn.oracle.com (/10.113.194.127) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 20 Apr 2017 01:15:52 -0700 From: Zhu Yanjun To: dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, linux-rdma@vger.kernel.org, yuval.shaia@oracle.com, haakon.bugge@oracle.com, wen.gang.wang@oracle.com, joe.jin@oracle.com, junxiao.bi@oracle.com Subject: [PATCH 1/1] IB/ipoib: add get_settings in ethtool Date: Thu, 20 Apr 2017 04:15:41 -0400 Message-Id: <1492676141-19639-1-git-send-email-yanjun.zhu@oracle.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 In order to let the bonding driver report the correct speed of the underlaying interfaces, when they are IPoIB, the ethtool function get_settings() in the IPoIB driver is implemented. Run ethtool command, the result is as below: [root@xxx ~]#ethtool ib0 Settings for ib0: Supported ports: [ ] Supported link modes: Not reported Supported pause frame use: No Supports auto-negotiation: No Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Speed: 40000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: off MDI-X: Unknown The speed of ipoib can be reached. Cc: Joe Jin Cc: Junxiao Bi Reviewed-by: HÃ¥kon Bugge Reviewed-by: Yuval Shaia Reviewed-by: Wengang Wang Signed-off-by: Zhu Yanjun --- drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c index bac455a..8c81566 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c @@ -155,7 +155,58 @@ static int ipoib_get_sset_count(struct net_device __always_unused *dev, return -EOPNOTSUPP; } +static int ipoib_get_settings(struct net_device *netdev, + struct ethtool_cmd *ecmd) +{ + struct ipoib_dev_priv *priv = netdev_priv(netdev); + struct ib_port_attr attr; + u32 speed; + int ret; + + if (!netif_carrier_ok(netdev)) { + ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); + ecmd->duplex = DUPLEX_UNKNOWN; + return 0; + } + + ret = ib_query_port(priv->ca, priv->port, &attr); + if (ret) + return ret; + + switch (attr.active_speed) { + case IB_SPEED_DDR: + speed = 5000; /* in deci-Mb/sec */ + break; + case IB_SPEED_QDR: + speed = 10000; + break; + case IB_SPEED_FDR10: + speed = 10000; + break; + case IB_SPEED_FDR: + speed = 14000; + break; + case IB_SPEED_EDR: + speed = 25000; + break; + case IB_SPEED_SDR: + default: + speed = 2500; + break; + } + + speed *= ib_width_enum_to_int(attr.active_width); + if (speed < 0) + return -EINVAL; + + ethtool_cmd_speed_set(ecmd, speed); + ecmd->duplex = DUPLEX_FULL; + + return 0; +} + static const struct ethtool_ops ipoib_ethtool_ops = { + .get_settings = ipoib_get_settings, .get_drvinfo = ipoib_get_drvinfo, .get_coalesce = ipoib_get_coalesce, .set_coalesce = ipoib_set_coalesce,