From: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH 1/1] IB/ipoib: add get_settings in ethtool
Date: Thu, 20 Apr 2017 13:20:11 +0300 [thread overview]
Message-ID: <20170420102010.GB3338@yuval-lap> (raw)
In-Reply-To: <1492676141-19639-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
On Thu, Apr 20, 2017 at 04:15:41AM -0400, Zhu Yanjun wrote:
> 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 <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Håkon Bugge <haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Wengang Wang <wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> ---
> 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;
> + }
Can you consider using the constants from ethtool.h instead of the above
numbers?
> +
> + 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,
> --
> 2.7.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-04-20 10:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 8:15 [PATCH 1/1] IB/ipoib: add get_settings in ethtool Zhu Yanjun
[not found] ` <1492676141-19639-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-04-20 10:20 ` Yuval Shaia [this message]
2017-04-20 10:44 ` Håkon Bugge
2017-04-20 10:54 ` Yuval Shaia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170420102010.GB3338@yuval-lap \
--to=yuval.shaia-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.