From: Gal Pressman <galp@mellanox.com>
To: netdev@vger.kernel.org,
"John W. Linville" <linville@tuxdriver.com>,
Vidya Sagar Ravipati <vidya@cumulusnetworks.com>,
Saeed Mahameed <saeedm@mellanox.com>
Cc: David Decotigny <decot@googlers.com>,
Ben Hutchings <ben@decadent.org.uk>,
Gal Pressman <galp@mellanox.com>
Subject: [PATCH RFC 1/2] ethtool: Add get actual port speed
Date: Wed, 2 Nov 2016 17:35:13 +0200 [thread overview]
Message-ID: <1478100914-23610-2-git-send-email-galp@mellanox.com> (raw)
In-Reply-To: <1478100914-23610-1-git-send-email-galp@mellanox.com>
Add an additional actual speed field when using ethtool DEVNAME.
Actual speed will show the actual bandwidth exposed for the machine,
which may be different from the HCA operating speed.
Signed-off-by: Gal Pressman <galp@mellanox.com>
---
include/linux/ethtool.h | 1 +
include/uapi/linux/ethtool.h | 2 ++
net/core/ethtool.c | 20 ++++++++++++++++++++
3 files changed, 23 insertions(+)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 9ded8c6..215baa1 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -311,6 +311,7 @@ struct ethtool_ops {
void (*set_msglevel)(struct net_device *, u32);
int (*nway_reset)(struct net_device *);
u32 (*get_link)(struct net_device *);
+ int (*get_actual_speed)(struct net_device *);
int (*get_eeprom_len)(struct net_device *);
int (*get_eeprom)(struct net_device *,
struct ethtool_eeprom *, u8 *);
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 099a420..63057a2 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -1315,6 +1315,8 @@ struct ethtool_per_queue_op {
#define ETHTOOL_GLINKSETTINGS 0x0000004c /* Get ethtool_link_settings */
#define ETHTOOL_SLINKSETTINGS 0x0000004d /* Set ethtool_link_settings */
+#define ETHTOOL_GASPD 0x0000004e /* Get port actual speed */
+
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 9774898..a1921fd 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1516,6 +1516,22 @@ static int ethtool_get_link(struct net_device *dev, char __user *useraddr)
return 0;
}
+static int ethtool_get_actual_speed(struct net_device *dev,
+ char __user *useraddr)
+{
+ struct ethtool_value edata = { .cmd = ETHTOOL_GASPD };
+
+ if (!dev->ethtool_ops->get_actual_speed)
+ return -EOPNOTSUPP;
+
+ edata.data = dev->ethtool_ops->get_actual_speed(dev);
+
+ if (copy_to_user(useraddr, &edata, sizeof(edata)))
+ return -EFAULT;
+
+ return 0;
+}
+
static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
int (*getter)(struct net_device *,
struct ethtool_eeprom *, u8 *),
@@ -2450,6 +2466,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_GDRVINFO:
case ETHTOOL_GMSGLVL:
case ETHTOOL_GLINK:
+ case ETHTOOL_GASPD:
case ETHTOOL_GCOALESCE:
case ETHTOOL_GRINGPARAM:
case ETHTOOL_GPAUSEPARAM:
@@ -2531,6 +2548,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_GLINK:
rc = ethtool_get_link(dev, useraddr);
break;
+ case ETHTOOL_GASPD:
+ rc = ethtool_get_actual_speed(dev, useraddr);
+ break;
case ETHTOOL_GEEPROM:
rc = ethtool_get_eeprom(dev, useraddr);
break;
--
2.7.4
next prev parent reply other threads:[~2016-11-02 15:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 15:35 [PATCH RFC 0/2] ethtool: Add actual port speed reporting Gal Pressman
2016-11-02 15:35 ` Gal Pressman [this message]
2016-11-02 15:35 ` [PATCH RFC 2/2] net/mlx5e: Add support for ethtool get actual speed callback Gal Pressman
2016-11-02 15:50 ` [PATCH RFC 0/2] ethtool: Add actual port speed reporting Mintz, Yuval
2016-11-03 16:59 ` Gal Pressman
2016-11-03 17:09 ` Rick Jones
2016-11-09 9:32 ` Saeed Mahameed
2016-11-03 7:02 ` Or Gerlitz
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=1478100914-23610-2-git-send-email-galp@mellanox.com \
--to=galp@mellanox.com \
--cc=ben@decadent.org.uk \
--cc=decot@googlers.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=vidya@cumulusnetworks.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox