All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 1/1] IB/ipoib: add get_settings in ethtool
@ 2017-04-26  9:02 Zhu Yanjun
       [not found] ` <1493197354-3025-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu Yanjun @ 2017-04-26  9:02 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA,
	haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA,
	wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA,
	joe.jin-QHcLZuEGTsvQT0dZR+AlfA,
	junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA

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.

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>
Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 50 ++++++++++++++++++++++++++++
 include/uapi/linux/ethtool.h                 |  1 +
 2 files changed, 51 insertions(+)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index bac455a..7ebe52a 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
@@ -155,7 +155,57 @@ static int ipoib_get_sset_count(struct net_device __always_unused *dev,
 	return -EOPNOTSUPP;
 }
 
+/* Return lane speed in unit of 1e6 bit/sec */
+static inline int ib_speed_enum_to_int(int speed)
+{
+	switch (speed) {
+	case IB_SPEED_SDR:
+		return SPEED_2500;
+	case IB_SPEED_DDR:
+		return SPEED_5000;
+	case IB_SPEED_QDR:
+	case IB_SPEED_FDR10:
+		return SPEED_10000;
+	case IB_SPEED_FDR:
+		return SPEED_14000;
+	case IB_SPEED_EDR:
+		return SPEED_25000;
+	}
+
+	return SPEED_UNKNOWN;
+}
+
+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;
+	int ret, speed, width;
+
+	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 < 0)
+		return -EINVAL;
+
+	speed = ib_speed_enum_to_int(attr.active_speed);
+	width = ib_width_enum_to_int(attr.active_width);
+
+	if (speed < 0 || width < 0)
+		return -EINVAL;
+
+	ethtool_cmd_speed_set(ecmd, speed * width);
+	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,
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 3dc91a4..55c3dcd 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1493,6 +1493,7 @@ enum ethtool_link_mode_bit_indices {
 #define SPEED_2500		2500
 #define SPEED_5000		5000
 #define SPEED_10000		10000
+#define SPEED_14000		14000
 #define SPEED_20000		20000
 #define SPEED_25000		25000
 #define SPEED_40000		40000
-- 
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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 1/1] IB/ipoib: add get_settings in ethtool
       [not found] ` <1493197354-3025-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-04-26  9:31   ` Thomas Bogendoerfer
       [not found]     ` <20170426113125.b7d64c5b0760e0316e6aedf6-l3A5Bk7waGM@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Bogendoerfer @ 2017-04-26  9:31 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA,
	haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA,
	wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA,
	joe.jin-QHcLZuEGTsvQT0dZR+AlfA,
	junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA

On Wed, 26 Apr 2017 05:02:34 -0400
Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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.

FYI get_settings is DEPRECATED. Wouldn't it make more sense to directly
implement get_link_ksettings ?

Thomas.

-- 
SUSE Linux GmbH
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 1/1] IB/ipoib: add get_settings in ethtool
       [not found]     ` <20170426113125.b7d64c5b0760e0316e6aedf6-l3A5Bk7waGM@public.gmane.org>
@ 2017-05-01 18:59       ` Doug Ledford
       [not found]         ` <1493665155.3041.186.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Ledford @ 2017-05-01 18:59 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Zhu Yanjun
  Cc: sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA,
	haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA,
	wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA,
	joe.jin-QHcLZuEGTsvQT0dZR+AlfA,
	junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA

On Wed, 2017-04-26 at 11:31 +0200, Thomas Bogendoerfer wrote:
> On Wed, 26 Apr 2017 05:02:34 -0400
> Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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.
> 
> FYI get_settings is DEPRECATED. Wouldn't it make more sense to
> directly
> implement get_link_ksettings ?

Indeed, please redo this patchset using the preferred method of getting
link settings.  Thanks.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* (unknown), 
       [not found]         ` <1493665155.3041.186.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2017-05-04  5:24           ` Zhu Yanjun
       [not found]             ` <1493875491-32048-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu Yanjun @ 2017-05-04  5:24 UTC (permalink / raw)
  To: tbogendoerfer-l3A5Bk7waGM, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA,
	haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA,
	wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA
  Cc: joe.jin-QHcLZuEGTsvQT0dZR+AlfA, junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA


Hi, all

The V3 patch is to replace get_settings with get_link_ksettings.

Best Regards,
Zhu Yanjun
--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCHv3 1/1] IB/ipoib: add get_link_ksettings in ethtool
       [not found]             ` <1493875491-32048-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-05-04  5:24               ` Zhu Yanjun
       [not found]                 ` <1493875491-32048-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu Yanjun @ 2017-05-04  5:24 UTC (permalink / raw)
  To: tbogendoerfer-l3A5Bk7waGM, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA,
	haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA,
	wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA
  Cc: joe.jin-QHcLZuEGTsvQT0dZR+AlfA, junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA

In order to let the bonding driver report the correct speed
of the underlaying interfaces, when they are IPoIB, the ethtool
function get_link_ksettings() in the IPoIB driver is implemented.

Cc: Joe Jin <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Suggested-by: Håkon Bugge <Haakon.Bugge-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
Changes V2-->V3
  Replace get_settings with get_link_ksettings.
---
 drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 59 ++++++++++++++++++++++++++++
 include/uapi/linux/ethtool.h                 |  1 +
 2 files changed, 60 insertions(+)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index bac455a..dd00775 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
@@ -155,7 +155,66 @@ static int ipoib_get_sset_count(struct net_device __always_unused *dev,
 	return -EOPNOTSUPP;
 }
 
+/* Return lane speed in unit of 1e6 bit/sec */
+static inline int ib_speed_enum_to_int(int speed)
+{
+	switch (speed) {
+	case IB_SPEED_SDR:
+		return SPEED_2500;
+	case IB_SPEED_DDR:
+		return SPEED_5000;
+	case IB_SPEED_QDR:
+	case IB_SPEED_FDR10:
+		return SPEED_10000;
+	case IB_SPEED_FDR:
+		return SPEED_14000;
+	case IB_SPEED_EDR:
+		return SPEED_25000;
+	}
+
+	return SPEED_UNKNOWN;
+}
+
+static int ipoib_get_link_ksettings(struct net_device *netdev,
+				    struct ethtool_link_ksettings *cmd)
+{
+	struct ipoib_dev_priv *priv = netdev_priv(netdev);
+	struct ib_port_attr attr;
+	int ret, speed, width;
+
+	if (!netif_carrier_ok(netdev)) {
+		cmd->base.speed = SPEED_UNKNOWN;
+		cmd->base.duplex = DUPLEX_UNKNOWN;
+		return 0;
+	}
+
+	ret = ib_query_port(priv->ca, priv->port, &attr);
+	if (ret < 0)
+		return -EINVAL;
+
+	speed = ib_speed_enum_to_int(attr.active_speed);
+	width = ib_width_enum_to_int(attr.active_width);
+
+	if (speed < 0 || width < 0)
+		return -EINVAL;
+
+	/* Except the following are set, the other members of
+	 * the struct ethtool_link_settings are initialized to
+	 * zero in the function __ethtool_get_link_ksettings.
+	 */
+	cmd->base.speed		 = speed * width;
+	cmd->base.duplex	 = DUPLEX_FULL;
+
+	cmd->base.phy_address	 = 0xFF;
+
+	cmd->base.autoneg	 = AUTONEG_ENABLE;
+	cmd->base.port		 = PORT_OTHER;
+
+	return 0;
+}
+
 static const struct ethtool_ops ipoib_ethtool_ops = {
+	.get_link_ksettings	= ipoib_get_link_ksettings,
 	.get_drvinfo		= ipoib_get_drvinfo,
 	.get_coalesce		= ipoib_get_coalesce,
 	.set_coalesce		= ipoib_set_coalesce,
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 3dc91a4..55c3dcd 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1493,6 +1493,7 @@ enum ethtool_link_mode_bit_indices {
 #define SPEED_2500		2500
 #define SPEED_5000		5000
 #define SPEED_10000		10000
+#define SPEED_14000		14000
 #define SPEED_20000		20000
 #define SPEED_25000		25000
 #define SPEED_40000		40000
-- 
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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCHv3 1/1] IB/ipoib: add get_link_ksettings in ethtool
       [not found]                 ` <1493875491-32048-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
@ 2017-05-04 23:45                   ` Doug Ledford
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Ledford @ 2017-05-04 23:45 UTC (permalink / raw)
  To: Zhu Yanjun, tbogendoerfer-l3A5Bk7waGM,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA,
	haakon.bugge-QHcLZuEGTsvQT0dZR+AlfA,
	wen.gang.wang-QHcLZuEGTsvQT0dZR+AlfA
  Cc: joe.jin-QHcLZuEGTsvQT0dZR+AlfA, junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA

On Thu, 2017-05-04 at 01:24 -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_link_ksettings() in the IPoIB driver is implemented.
> 
> Cc: Joe Jin <joe.jin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Cc: Junxiao Bi <junxiao.bi-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Suggested-by: Håkon Bugge <Haakon.Bugge-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Zhu Yanjun <yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Thanks.  Since I had a second pull request to send this merge window,
I've taken this in for that pull request.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-04 23:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  9:02 [PATCHv2 1/1] IB/ipoib: add get_settings in ethtool Zhu Yanjun
     [not found] ` <1493197354-3025-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-04-26  9:31   ` Thomas Bogendoerfer
     [not found]     ` <20170426113125.b7d64c5b0760e0316e6aedf6-l3A5Bk7waGM@public.gmane.org>
2017-05-01 18:59       ` Doug Ledford
     [not found]         ` <1493665155.3041.186.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-05-04  5:24           ` (unknown), Zhu Yanjun
     [not found]             ` <1493875491-32048-1-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-05-04  5:24               ` [PATCHv3 1/1] IB/ipoib: add get_link_ksettings in ethtool Zhu Yanjun
     [not found]                 ` <1493875491-32048-2-git-send-email-yanjun.zhu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-05-04 23:45                   ` Doug Ledford

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.