* [PATCH net-next v1 01/18] net: ethtool: propagate get_settings error
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
@ 2015-01-27 1:35 ` David Decotigny
2015-01-28 16:30 ` Ben Hutchings
2015-01-27 1:35 ` [PATCH net-next v1 02/18] net: usnic: remove unused call to ethtool_ops::get_settings David Decotigny
` (16 subsequent siblings)
17 siblings, 1 reply; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:35 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
net/core/ethtool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 91f74f3..52efb7e 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -364,7 +364,7 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
return -EFAULT;
- return 0;
+ return err;
}
static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH net-next v1 01/18] net: ethtool: propagate get_settings error
2015-01-27 1:35 ` [PATCH net-next v1 01/18] net: ethtool: propagate get_settings error David Decotigny
@ 2015-01-28 16:30 ` Ben Hutchings
0 siblings, 0 replies; 22+ messages in thread
From: Ben Hutchings @ 2015-01-28 16:30 UTC (permalink / raw)
To: David Decotigny
Cc: David S. Miller, Amir Vadai, linux-kernel, netdev, linux-api,
Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
[-- Attachment #1: Type: text/plain, Size: 942 bytes --]
On Mon, 2015-01-26 at 17:35 -0800, David Decotigny wrote:
> From: David Decotigny <decot@googlers.com>
>
> Signed-off-by: David Decotigny <decot@googlers.com>
> ---
> net/core/ethtool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index 91f74f3..52efb7e 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -364,7 +364,7 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
>
> if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
> return -EFAULT;
> - return 0;
> + return err;
err cannnot be negative at this point (and if it's positive, that's a
bug in the get_settings implementation which we happen to fix up).
Ben.
> }
>
> static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
--
Ben Hutchings
Teamwork is essential - it allows you to blame someone else.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 02/18] net: usnic: remove unused call to ethtool_ops::get_settings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
2015-01-27 1:35 ` [PATCH net-next v1 01/18] net: ethtool: propagate get_settings error David Decotigny
@ 2015-01-27 1:35 ` David Decotigny
2015-01-27 1:35 ` [PATCH net-next v1 03/18] net: usnic: use __ethtool_get_settings David Decotigny
` (15 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:35 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index 53bd6a2..61337c7c 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -253,13 +253,11 @@ int usnic_ib_query_device(struct ib_device *ibdev,
struct usnic_ib_dev *us_ibdev = to_usdev(ibdev);
union ib_gid gid;
struct ethtool_drvinfo info;
- struct ethtool_cmd cmd;
int qp_per_vf;
usnic_dbg("\n");
mutex_lock(&us_ibdev->usdev_lock);
us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info);
- us_ibdev->netdev->ethtool_ops->get_settings(us_ibdev->netdev, &cmd);
memset(props, 0, sizeof(*props));
usnic_mac_ip_to_gid(us_ibdev->ufdev->mac, us_ibdev->ufdev->inaddr,
&gid.raw[0]);
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 03/18] net: usnic: use __ethtool_get_settings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
2015-01-27 1:35 ` [PATCH net-next v1 01/18] net: ethtool: propagate get_settings error David Decotigny
2015-01-27 1:35 ` [PATCH net-next v1 02/18] net: usnic: remove unused call to ethtool_ops::get_settings David Decotigny
@ 2015-01-27 1:35 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 04/18] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (14 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:35 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index 61337c7c..d71ba62 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -310,7 +310,7 @@ int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
usnic_dbg("\n");
mutex_lock(&us_ibdev->usdev_lock);
- us_ibdev->netdev->ethtool_ops->get_settings(us_ibdev->netdev, &cmd);
+ __ethtool_get_settings(us_ibdev->netdev, &cmd);
memset(props, 0, sizeof(*props));
props->lid = 0;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 04/18] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (2 preceding siblings ...)
2015-01-27 1:35 ` [PATCH net-next v1 03/18] net: usnic: use __ethtool_get_settings David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 05/18] net: tx4939: use __ethtool_get_ksettings David Decotigny
` (13 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
This patch defines a new ETHTOOL_GSETTINGS/SSETTINGS API, handled by
the new get_ksettings/set_ksettings callbacks. This API provides
support for most legacy ethtool_cmd fields, adds support for larger
link mode masks (up to 4064 bits, variable length), and removes
ethtool_cmd deprecated fields (transceiver/maxrxpkt/maxtxpkt).
This API is deprecating the legacy ETHTOOL_GSET/SSET API and provides
the following backward compatibility properties:
- legacy ethtool with legacy drivers: no change, still using the
get_settings/set_settings callbacks.
- legacy ethtool with new get/set_ksettings drivers: the new driver
callbacks are used, data internally converted to legacy
ethtool_cmd. ETHTOOL_GSET will return only the 1st 32b of each link
mode mask. ETHTOOL_SSET will fail if user tries to set the
ethtool_cmd deprecated fields to non-0
(transceiver/maxrxpkt/maxtxpkt). A kernel warning is printed if
driver exports higher bits or if user request changes in deprecated
fields mentioned earlier.
- future ethtool with legacy drivers: no change, still using the
get_settings/set_settings callbacks, internally converted to new
data structure. Note that that "future" ethtool tool will not allow
changes to deprecated fields (transceiver/maxrxpkt/maxtxpkt), as
they cannot be expressed for the kernel.
- future ethtool with new drivers: direct call to the new callbacks.
By "future" ethtool, what is meant is:
- query: first try ETHTOOL_GSETTINGS, and revert to ETHTOOL_GSET if fails
- set: query first and remember which of ETHTOOL_GSETTINGS or
ETHTOOL_GSET was successful
- if ETHTOOL_GSETTINGS was successful, then change config with
ETHTOOL_SSETTINGS. A failure there is final (do not try ETHTOOL_SSET).
- otherwise ETHTOOL_GSET was successful, change config with ETHTOOL_SSET.
A failure there is final (do not try ETHTOOL_SSETTINGS).
The interaction user/kernel via the new API requires a small
ETHTOOL_GSETTINGS handshake first to agree on the length of the link
mode bitmaps. If kernel doesn't agree with user, it returns the bitmap
length it is expecting from user as a negative length (and cmd field
is 0). When kernel and user agree, kernel returns valid info in all
fields (ie. link mode length > 0 and cmd is ETHTOOL_GSETTINGS).
Data structure crossing user/kernel boundary is 32/64-bit
agnostic. Converted internally to a legal kernel bitmap.
The internal __ethtool_get_settings kernel helper will gradually be
replaced by __ethtool_get_ksettings by the time the first ksettings
drivers start to appear. So this patch doesn't change it, it will be
removed before it needs to be changed.
Signed-off-by: David Decotigny <decot@googlers.com>
---
include/linux/ethtool.h | 100 ++++++++-
include/uapi/linux/ethtool.h | 319 ++++++++++++++++++++++------
net/core/ethtool.c | 486 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 826 insertions(+), 79 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 653dc9c..49881b6 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -12,6 +12,7 @@
#ifndef _LINUX_ETHTOOL_H
#define _LINUX_ETHTOOL_H
+#include <linux/bitmap.h>
#include <linux/compat.h>
#include <uapi/linux/ethtool.h>
@@ -40,9 +41,6 @@ struct compat_ethtool_rxnfc {
#include <linux/rculist.h>
-extern int __ethtool_get_settings(struct net_device *dev,
- struct ethtool_cmd *cmd);
-
/**
* enum ethtool_phys_id_state - indicator state for physical identification
* @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
@@ -97,13 +95,84 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
return index % n_rx_rings;
}
+/* number of link mode bits handled internally by kernel */
+#define __ETHTOOL_LINK_MODE_MASK_NBITS (__ETHTOOL_LINK_MODE_LAST+1)
+
+#define __ETHTOOL_LINK_MODE_IS_VALID_BIT(indice) \
+ ((indice) >= 0 && (indice) < __ETHTOOL_LINK_MODE_MASK_NBITS)
+
+typedef struct {
+ unsigned long mask[BITS_TO_LONGS(__ETHTOOL_LINK_MODE_MASK_NBITS)];
+} ethtool_link_mode_mask_t;
+
+/* drivers must ignore parent.cmd and parent.link_mode_masks_nwords
+ * fields, but they are allowed to overwrite them (will be ignored) */
+struct ethtool_ksettings {
+ struct ethtool_settings parent;
+ struct {
+ ethtool_link_mode_mask_t supported;
+ ethtool_link_mode_mask_t advertising;
+ ethtool_link_mode_mask_t lp_advertising;
+ } link_modes;
+};
+
+/* helper function for ethtool_build_link_mode and ethtool_add_link_modes */
+static inline int
+__ethtool_add_link_modes(ethtool_link_mode_mask_t *dst,
+ unsigned nindices,
+ const enum ethtool_link_mode_bit_indices *indices) {
+ unsigned i;
+ int rv = 0;
+
+ for (i = 0 ; i < nindices ; ++i) {
+ if (__ETHTOOL_LINK_MODE_IS_VALID_BIT(indices[i]))
+ set_bit(indices[i], dst->mask);
+ else
+ rv = -1;
+ }
+ return rv;
+}
+
+/* build link mode mask from variadic list of bit indices, return 0
+ * when all indices are valid, -1 otherwise
+ */
+#define ethtool_build_link_mode(dst, ...) \
+ ({ \
+ const enum ethtool_link_mode_bit_indices indices[] = { \
+ __VA_ARGS__ }; \
+ bitmap_zero((dst)->mask, \
+ __ETHTOOL_LINK_MODE_MASK_NBITS); \
+ __ethtool_add_link_modes((dst), \
+ ARRAY_SIZE(indices), indices); \
+ })
+
+/* update link mode mask by setting variadic list of bit indices,
+ * return 0 when all indices are valid, -1 otherwise
+ */
+#define ethtool_add_link_modes(dst, ...) \
+ ({ \
+ const enum ethtool_link_mode_bit_indices indices[] = { \
+ __VA_ARGS__ }; \
+ __ethtool_add_link_modes((dst), \
+ ARRAY_SIZE(indices), indices); \
+ })
+
+extern int __ethtool_get_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *ksettings);
+
+/* DEPRECATED, use __ethtool_get_ksettings */
+extern int __ethtool_get_settings(struct net_device *dev,
+ struct ethtool_cmd *cmd);
+
/**
* struct ethtool_ops - optional netdev operations
- * @get_settings: Get various device settings including Ethernet link
+ * @get_settings: DEPRECATED, use %get_ksettings/%set_ksettings
+ * API. Get various device settings including Ethernet link
* settings. The @cmd parameter is expected to have been cleared
- * before get_settings is called. Returns a negative error code or
- * zero.
- * @set_settings: Set various device settings including Ethernet link
+ * before get_settings is called. Returns a negative error code
+ * or zero.
+ * @set_settings: DEPRECATED, use %get_ksettings/%set_ksettings
+ * API. Set various device settings including Ethernet link
* settings. Returns a negative error code or zero.
* @get_drvinfo: Report driver/device information. Should only set the
* @driver, @version, @fw_version and @bus_info fields. If not
@@ -201,6 +270,18 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
* @get_module_eeprom: Get the eeprom information from the plug-in module
* @get_eee: Get Energy-Efficient (EEE) supported and status.
* @set_eee: Set EEE status (enable/disable) as well as LPI timers.
+ * @get_ksettings: When defined, takes precedence over the
+ * %get_settings method. Get various device settings including Ethernet
+ * link settings. The %cmd and %link_mode_masks_nwords fields should be
+ * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
+ * any change to them will be overwritten by kernel. Returns a negative
+ * error code or zero.
+ * @set_ksettings: When defined, takes precedence over the
+ * %set_settings method. Set various device settings including
+ * Ethernet link settings. The %cmd and %link_mode_masks_nwords fields
+ * should be ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of
+ * the latter), any change to them will be overwritten by
+ * kernel. Returns a negative error code or zero.
*
* All operations are optional (i.e. the function pointer may be set
* to %NULL) and callers must take this into account. Callers must
@@ -280,6 +361,9 @@ struct ethtool_ops {
int (*set_tunable)(struct net_device *,
const struct ethtool_tunable *, const void *);
-
+ int (*get_ksettings)(struct net_device *,
+ struct ethtool_ksettings *);
+ int (*set_ksettings)(struct net_device *,
+ const struct ethtool_ksettings *);
};
#endif /* _LINUX_ETHTOOL_H */
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 5f66d9c..c85cc2f 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -21,7 +21,8 @@
*/
/**
- * struct ethtool_cmd - link control and status
+ * struct ethtool_cmd - DEPRECATED, link control and status
+ * This structure is DEPRECATED, please use struct ethtool_settings.
* @cmd: Command number = %ETHTOOL_GSET or %ETHTOOL_SSET
* @supported: Bitmask of %SUPPORTED_* flags for the link modes,
* physical connectors and other link features for which the
@@ -1108,8 +1109,10 @@ enum ethtool_sfeatures_retval_bits {
/* CMDs currently supported */
-#define ETHTOOL_GSET 0x00000001 /* Get settings. */
-#define ETHTOOL_SSET 0x00000002 /* Set settings. */
+#define ETHTOOL_GSET 0x00000001 /* DEPRECATED, Get settings.
+ Please use ETHTOOL_GSETTINGS */
+#define ETHTOOL_SSET 0x00000002 /* DEPRECATED, Set settings.
+ Please use ETHTOOL_SSETTINGS */
#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */
#define ETHTOOL_GREGS 0x00000004 /* Get NIC registers. */
#define ETHTOOL_GWOL 0x00000005 /* Get wake-on-lan options. */
@@ -1188,73 +1191,137 @@ enum ethtool_sfeatures_retval_bits {
#define ETHTOOL_GTUNABLE 0x00000048 /* Get tunable configuration */
#define ETHTOOL_STUNABLE 0x00000049 /* Set tunable configuration */
+#define ETHTOOL_GSETTINGS 0x0000004a /* Get ethtool_settings */
+#define ETHTOOL_SSETTINGS 0x0000004b /* Set ethtool_settings */
+
+
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
#define SPARC_ETH_SSET ETHTOOL_SSET
-#define SUPPORTED_10baseT_Half (1 << 0)
-#define SUPPORTED_10baseT_Full (1 << 1)
-#define SUPPORTED_100baseT_Half (1 << 2)
-#define SUPPORTED_100baseT_Full (1 << 3)
-#define SUPPORTED_1000baseT_Half (1 << 4)
-#define SUPPORTED_1000baseT_Full (1 << 5)
-#define SUPPORTED_Autoneg (1 << 6)
-#define SUPPORTED_TP (1 << 7)
-#define SUPPORTED_AUI (1 << 8)
-#define SUPPORTED_MII (1 << 9)
-#define SUPPORTED_FIBRE (1 << 10)
-#define SUPPORTED_BNC (1 << 11)
-#define SUPPORTED_10000baseT_Full (1 << 12)
-#define SUPPORTED_Pause (1 << 13)
-#define SUPPORTED_Asym_Pause (1 << 14)
-#define SUPPORTED_2500baseX_Full (1 << 15)
-#define SUPPORTED_Backplane (1 << 16)
-#define SUPPORTED_1000baseKX_Full (1 << 17)
-#define SUPPORTED_10000baseKX4_Full (1 << 18)
-#define SUPPORTED_10000baseKR_Full (1 << 19)
-#define SUPPORTED_10000baseR_FEC (1 << 20)
-#define SUPPORTED_20000baseMLD2_Full (1 << 21)
-#define SUPPORTED_20000baseKR2_Full (1 << 22)
-#define SUPPORTED_40000baseKR4_Full (1 << 23)
-#define SUPPORTED_40000baseCR4_Full (1 << 24)
-#define SUPPORTED_40000baseSR4_Full (1 << 25)
-#define SUPPORTED_40000baseLR4_Full (1 << 26)
-#define SUPPORTED_56000baseKR4_Full (1 << 27)
-#define SUPPORTED_56000baseCR4_Full (1 << 28)
-#define SUPPORTED_56000baseSR4_Full (1 << 29)
-#define SUPPORTED_56000baseLR4_Full (1 << 30)
-
-#define ADVERTISED_10baseT_Half (1 << 0)
-#define ADVERTISED_10baseT_Full (1 << 1)
-#define ADVERTISED_100baseT_Half (1 << 2)
-#define ADVERTISED_100baseT_Full (1 << 3)
-#define ADVERTISED_1000baseT_Half (1 << 4)
-#define ADVERTISED_1000baseT_Full (1 << 5)
-#define ADVERTISED_Autoneg (1 << 6)
-#define ADVERTISED_TP (1 << 7)
-#define ADVERTISED_AUI (1 << 8)
-#define ADVERTISED_MII (1 << 9)
-#define ADVERTISED_FIBRE (1 << 10)
-#define ADVERTISED_BNC (1 << 11)
-#define ADVERTISED_10000baseT_Full (1 << 12)
-#define ADVERTISED_Pause (1 << 13)
-#define ADVERTISED_Asym_Pause (1 << 14)
-#define ADVERTISED_2500baseX_Full (1 << 15)
-#define ADVERTISED_Backplane (1 << 16)
-#define ADVERTISED_1000baseKX_Full (1 << 17)
-#define ADVERTISED_10000baseKX4_Full (1 << 18)
-#define ADVERTISED_10000baseKR_Full (1 << 19)
-#define ADVERTISED_10000baseR_FEC (1 << 20)
-#define ADVERTISED_20000baseMLD2_Full (1 << 21)
-#define ADVERTISED_20000baseKR2_Full (1 << 22)
-#define ADVERTISED_40000baseKR4_Full (1 << 23)
-#define ADVERTISED_40000baseCR4_Full (1 << 24)
-#define ADVERTISED_40000baseSR4_Full (1 << 25)
-#define ADVERTISED_40000baseLR4_Full (1 << 26)
-#define ADVERTISED_56000baseKR4_Full (1 << 27)
-#define ADVERTISED_56000baseCR4_Full (1 << 28)
-#define ADVERTISED_56000baseSR4_Full (1 << 29)
-#define ADVERTISED_56000baseLR4_Full (1 << 30)
+/* Link mode bit indices */
+enum ethtool_link_mode_bit_indices {
+ ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0,
+ ETHTOOL_LINK_MODE_10baseT_Full_BIT = 1,
+ ETHTOOL_LINK_MODE_100baseT_Half_BIT = 2,
+ ETHTOOL_LINK_MODE_100baseT_Full_BIT = 3,
+ ETHTOOL_LINK_MODE_1000baseT_Half_BIT = 4,
+ ETHTOOL_LINK_MODE_1000baseT_Full_BIT = 5,
+ ETHTOOL_LINK_MODE_Autoneg_BIT = 6,
+ ETHTOOL_LINK_MODE_TP_BIT = 7,
+ ETHTOOL_LINK_MODE_AUI_BIT = 8,
+ ETHTOOL_LINK_MODE_MII_BIT = 9,
+ ETHTOOL_LINK_MODE_FIBRE_BIT = 10,
+ ETHTOOL_LINK_MODE_BNC_BIT = 11,
+ ETHTOOL_LINK_MODE_10000baseT_Full_BIT = 12,
+ ETHTOOL_LINK_MODE_Pause_BIT = 13,
+ ETHTOOL_LINK_MODE_Asym_Pause_BIT = 14,
+ ETHTOOL_LINK_MODE_2500baseX_Full_BIT = 15,
+ ETHTOOL_LINK_MODE_Backplane_BIT = 16,
+ ETHTOOL_LINK_MODE_1000baseKX_Full_BIT = 17,
+ ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT = 18,
+ ETHTOOL_LINK_MODE_10000baseKR_Full_BIT = 19,
+ ETHTOOL_LINK_MODE_10000baseR_FEC_BIT = 20,
+ ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 21,
+ ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT = 22,
+ ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT = 23,
+ ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT = 24,
+ ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT = 25,
+ ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT = 26,
+ ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT = 27,
+ ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT = 28,
+ ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT = 29,
+ ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT = 30,
+
+ /* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit
+ 31. Please do NOT define any SUPPORTED_* or ADVERTISED_*
+ macro for bits > 31. The only way to use indices > 31 is to
+ use the new ETHTOOL_GSETTINGS/ETHTOOL_SSETTINGS API */
+
+ __ETHTOOL_LINK_MODE_LAST
+ = ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT,
+};
+
+#define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name) \
+ (1UL << (ETHTOOL_LINK_MODE_ ## base_name ## _BIT))
+
+/* DEPRECATED macros. Please migrate to
+ ETHTOOL_GSETTINGS/ETHTOOL_SSETTINGS API. Please do NOT define any new
+ SUPPORTED_* macro for bits > 31. */
+#define SUPPORTED_10baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
+#define SUPPORTED_10baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
+#define SUPPORTED_100baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
+#define SUPPORTED_100baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
+#define SUPPORTED_1000baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
+#define SUPPORTED_1000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
+#define SUPPORTED_Autoneg __ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
+#define SUPPORTED_TP __ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
+#define SUPPORTED_AUI __ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
+#define SUPPORTED_MII __ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
+#define SUPPORTED_FIBRE __ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
+#define SUPPORTED_BNC __ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
+#define SUPPORTED_10000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
+#define SUPPORTED_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
+#define SUPPORTED_Asym_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
+#define SUPPORTED_2500baseX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
+#define SUPPORTED_Backplane __ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
+#define SUPPORTED_1000baseKX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
+#define SUPPORTED_10000baseKX4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
+#define SUPPORTED_10000baseKR_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
+#define SUPPORTED_10000baseR_FEC __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
+#define SUPPORTED_20000baseMLD2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
+#define SUPPORTED_20000baseKR2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
+#define SUPPORTED_40000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
+#define SUPPORTED_40000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
+#define SUPPORTED_40000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
+#define SUPPORTED_40000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
+#define SUPPORTED_56000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
+#define SUPPORTED_56000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
+#define SUPPORTED_56000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
+#define SUPPORTED_56000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
+/* Please do not define any new SUPPORTED_* macro for bits > 31, see
+ * notice above.
+ */
+
+/*
+ * DEPRECATED macros. Please migrate to
+ * ETHTOOL_GSETTINGS/ETHTOOL_SSETTINGS API. Please do NOT define any new
+ * ADERTISE_* macro for bits > 31.
+ */
+#define ADVERTISED_10baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
+#define ADVERTISED_10baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
+#define ADVERTISED_100baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
+#define ADVERTISED_100baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
+#define ADVERTISED_1000baseT_Half __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
+#define ADVERTISED_1000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
+#define ADVERTISED_Autoneg __ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
+#define ADVERTISED_TP __ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
+#define ADVERTISED_AUI __ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
+#define ADVERTISED_MII __ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
+#define ADVERTISED_FIBRE __ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
+#define ADVERTISED_BNC __ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
+#define ADVERTISED_10000baseT_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
+#define ADVERTISED_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
+#define ADVERTISED_Asym_Pause __ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
+#define ADVERTISED_2500baseX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
+#define ADVERTISED_Backplane __ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
+#define ADVERTISED_1000baseKX_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
+#define ADVERTISED_10000baseKX4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
+#define ADVERTISED_10000baseKR_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
+#define ADVERTISED_10000baseR_FEC __ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
+#define ADVERTISED_20000baseMLD2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
+#define ADVERTISED_20000baseKR2_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
+#define ADVERTISED_40000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
+#define ADVERTISED_40000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
+#define ADVERTISED_40000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
+#define ADVERTISED_40000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
+#define ADVERTISED_56000baseKR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
+#define ADVERTISED_56000baseCR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
+#define ADVERTISED_56000baseSR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
+#define ADVERTISED_56000baseLR4_Full __ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
+/* Please do not define any new ADVERTISED_* macro for bits > 31, see
+ * notice above.
+ */
/* The following are all involved in forcing a particular link
* mode for the device for setting things. When getting the
@@ -1396,4 +1463,124 @@ enum ethtool_reset_flags {
};
#define ETH_RESET_SHARED_SHIFT 16
+
+/**
+ * struct ethtool_settings - link control and status
+ * This structure deprecates struct %ethtool_cmd.
+ *
+ * IMPORTANT, Backward compatibility notice: When implementing new
+ * user-space tools, please first try %ETHTOOL_GSETTINGS, and if
+ * it succeeds use %ETHTOOL_SSETTINGS to change settings; do not
+ * use %ETHTOOL_SSET if %ETHTOOL_GSETTINGS succeeded: stick to
+ * %ETHTOOL_GSETTINGS/%SSETTINGS in that case. Conversely, if
+ * %ETHTOOL_GSETTINGS fails, use %ETHTOOL_GSET to query and
+ * %ETHTOOL_SSET to change settings; do not use
+ * %ETHTOOL_SSETTINGS if %ETHTOOL_GSETTINGS failed: stick to
+ * %ETHTOOL_GSET/%ETHTOOL_SSET in that case.
+ *
+ * @cmd: Command number = %ETHTOOL_GSETTINGS or %ETHTOOL_SSETTINGS
+ * @speed: Link speed (Mbps)
+ * @duplex: Duplex mode; one of %DUPLEX_*
+ * @port: Physical connector type; one of %PORT_*
+ * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
+ * applicable. For clause 45 PHYs this is the PRTAD.
+ * @autoneg: Enable/disable autonegotiation and auto-detection;
+ * either %AUTONEG_DISABLE or %AUTONEG_ENABLE
+ * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO
+ * protocols supported by the interface; 0 if unknown.
+ * Read-only.
+ * @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
+ * %ETH_TP_MDI_*. If the status is unknown or not applicable, the
+ * value will be %ETH_TP_MDI_INVALID. Read-only.
+ * @eth_tp_mdix_ctrl: Ethernet twisted pair MDI(-X) control; one of
+ * %ETH_TP_MDI_*. If MDI(-X) control is not implemented, reads
+ * yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
+ * When written successfully, the link should be renegotiated if
+ * necessary.
+ * @link_mode_masks_nwords: Number of 32-bit words for each of the
+ * supported, advertising, lp_advertising link mode bitmaps. For
+ * %ETHTOOL_GSETTINGS: on entry, number of words passed by user
+ * (>= 0); on return, if handshake in progress, negative if
+ * request size unsupported by kernel: absolute value indicates
+ * kernel recommended size and cmd field is 0, as well as all the
+ * other fields; otherwise (handshake completed), strictly
+ * positive to indicate size used by kernel and cmd field is
+ * %ETHTOOL_GSETTINGS, all other fields populated by driver. For
+ * %ETHTOOL_SSETTINGS: must be valid on entry, ie. a positive
+ * value returned previously by %ETHTOOL_GSETTINGS, otherwise
+ * refused. For drivers: ignore this field (use kernel's
+ * __ETHTOOL_LINK_MODE_MASK_NBITS instead), any change to it will
+ * be overwritten by kernel.
+ * @supported: Bitmap with each bit meaning given by
+ * %ethtool_link_mode_bit_indices for the link modes, physical
+ * connectors and other link features for which the interface
+ * supports autonegotiation or auto-detection. Read-only.
+ * @advertising: Bitmap with each bit meaning given by
+ * %ethtool_link_mode_bit_indices for the link modes, physical
+ * connectors and other link features that are advertised through
+ * autonegotiation or enabled for auto-detection.
+ * @lp_advertising: Bitmap with each bit meaning given by
+ * %ethtool_link_mode_bit_indices for the link modes, and other
+ * link features that the link partner advertised through
+ * autonegotiation; 0 if unknown or not applicable. Read-only.
+ *
+ * If autonegotiation is disabled, the speed and @duplex represent the
+ * fixed link mode and are writable if the driver supports multiple
+ * link modes. If it is enabled then they are read-only; if the link
+ * is up they represent the negotiated link mode; if the link is down,
+ * the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and
+ * @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode.
+ *
+ * Some hardware interfaces may have multiple PHYs and/or physical
+ * connectors fitted or do not allow the driver to detect which are
+ * fitted. For these interfaces @port and/or @phy_address may be
+ * writable, possibly dependent on @autoneg being %AUTONEG_DISABLE.
+ * Otherwise, attempts to write different values may be ignored or
+ * rejected.
+ *
+ * Deprecated %ethtool_cmd fields transceiver, maxtxpkt and maxrxpkt
+ * are not available in %ethtool_settings. Until all drivers are
+ * converted to ignore them or to the new %ethtool_settings API, for
+ * both queries and changes, users should always try
+ * %ETHTOOL_GSETTINGS first, and if it fails with -ENOTSUPP stick only
+ * to %ETHTOOL_GSET and %ETHTOOL_SSET consistently. If it succeeds,
+ * then users should stick to %ETHTOOL_GSETTINGS and
+ * %ETHTOOL_SSETTINGS (which would support drivers implementing either
+ * %ethtool_cmd or %ethtool_settings).
+ *
+ * Users should assume that all fields not marked read-only are
+ * writable and subject to validation by the driver. They should use
+ * %ETHTOOL_GSETTINGS to get the current values before making specific
+ * changes and then applying them with %ETHTOOL_SSETTINGS.
+ *
+ * Drivers that implement %get_ksettings and/or %set_ksettings should
+ * ignore the @cmd and @link_mode_masks_nwords fields (any change to
+ * them overwritten by kernel), and rely only on kernel's internal
+ * %__ETHTOOL_LINK_MODE_MASK_NBITS and
+ * %ethtool_link_mode_mask_t. Drivers that implement %set_ksettings()
+ * should validate all fields other than @cmd
+ * and @link_mode_masks_nwords that are not described as read-only or
+ * deprecated, and must ignore all fields described as read-only.
+ *
+ * Deprecated fields should be ignored by both users and drivers.
+ */
+struct ethtool_settings {
+ __u32 cmd;
+ __u32 speed;
+ __u8 duplex;
+ __u8 port;
+ __u8 phy_address;
+ __u8 autoneg;
+ __u8 mdio_support;
+ __u8 eth_tp_mdix;
+ __u8 eth_tp_mdix_ctrl;
+ __s8 link_mode_masks_nwords;
+ __u32 reserved[8];
+ __u32 link_mode_masks[0];
+ /* layout of link_mode_masks fields:
+ * __u32 map_supported[link_mode_masks_nwords];
+ * __u32 map_advertising[link_mode_masks_nwords];
+ * __u32 map_lp_advertising[link_mode_masks_nwords];
+ */
+};
#endif /* _UAPI_LINUX_ETHTOOL_H */
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 52efb7e..d978d80 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -340,6 +340,388 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
return 0;
}
+/* TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear */
+static void convert_legacy_u32_to_link_mode(ethtool_link_mode_mask_t *dst,
+ u32 legacy_u32)
+{
+ bitmap_zero(dst->mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
+ dst->mask[0] = legacy_u32;
+}
+
+/* return false if src had higher bits set. lower bits always updated.
+ * TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear
+ */
+static bool convert_link_mode_to_legacy_u32(u32 *legacy_u32,
+ const ethtool_link_mode_mask_t *src)
+{
+ bool retval = true;
+
+ /* TODO: following test will soon always be true */
+ if (__ETHTOOL_LINK_MODE_MASK_NBITS > 32) {
+ ethtool_link_mode_mask_t ext;
+
+ bitmap_zero(ext.mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
+ bitmap_fill(ext.mask, 32);
+ bitmap_complement(ext.mask, ext.mask,
+ __ETHTOOL_LINK_MODE_MASK_NBITS);
+ if (bitmap_intersects(ext.mask, src->mask,
+ __ETHTOOL_LINK_MODE_MASK_NBITS)) {
+ /* src mask goes beyond bit 31 */
+ retval = false;
+ }
+ }
+ *legacy_u32 = src->mask[0];
+ return retval;
+}
+
+/* return false if legacy contained non-0 deprecated fields
+ * transceiver/maxtxpkt/maxrxpkt. rest of ksettings always updated
+ * TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear
+ */
+static bool
+convert_legacy_settings_to_ksettings(struct ethtool_ksettings *ksettings,
+ const struct ethtool_cmd *legacy_settings)
+{
+ bool retval = true;
+
+ memset(ksettings, 0, sizeof(*ksettings));
+
+ /* This is used to tell users that driver is still using these
+ * deprecated legacy fields, and they should not use
+ * %ETHTOOL_GSETTINGS/%ETHTOOL_SSETTINGS
+ */
+ if (legacy_settings->transceiver ||
+ legacy_settings->maxtxpkt ||
+ legacy_settings->maxrxpkt)
+ retval = false;
+
+ convert_legacy_u32_to_link_mode(&ksettings->link_modes.supported,
+ legacy_settings->supported);
+ convert_legacy_u32_to_link_mode(&ksettings->link_modes.advertising,
+ legacy_settings->advertising);
+ convert_legacy_u32_to_link_mode(&ksettings->link_modes.lp_advertising,
+ legacy_settings->lp_advertising);
+ ksettings->parent.speed = ethtool_cmd_speed(legacy_settings);
+ ksettings->parent.duplex = legacy_settings->duplex;
+ ksettings->parent.port = legacy_settings->port;
+ ksettings->parent.phy_address = legacy_settings->phy_address;
+ ksettings->parent.autoneg = legacy_settings->autoneg;
+ ksettings->parent.mdio_support = legacy_settings->mdio_support;
+ ksettings->parent.eth_tp_mdix = legacy_settings->eth_tp_mdix;
+ ksettings->parent.eth_tp_mdix_ctrl = legacy_settings->eth_tp_mdix_ctrl;
+ return retval;
+}
+
+/* return false if ksettings link modes had higher bits
+ * set. legacy_settings always updated (best effort)
+ * TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear
+ */
+static bool
+convert_ksettings_to_legacy_settings(struct ethtool_cmd *legacy_settings,
+ const struct ethtool_ksettings *ksettings)
+{
+ bool retval = true;
+
+ memset(legacy_settings, 0, sizeof(*legacy_settings));
+ /* this also clears the deprecated fields in legacy structure:
+ * __u8 transceiver;
+ * __u32 maxtxpkt;
+ * __u32 maxrxpkt;
+ */
+
+ retval &= convert_link_mode_to_legacy_u32(
+ &legacy_settings->supported,
+ &ksettings->link_modes.supported);
+ retval &= convert_link_mode_to_legacy_u32(
+ &legacy_settings->advertising,
+ &ksettings->link_modes.advertising);
+ retval &= convert_link_mode_to_legacy_u32(
+ &legacy_settings->lp_advertising,
+ &ksettings->link_modes.lp_advertising);
+ ethtool_cmd_speed_set(legacy_settings, ksettings->parent.speed);
+ legacy_settings->duplex = ksettings->parent.duplex;
+ legacy_settings->port = ksettings->parent.port;
+ legacy_settings->phy_address = ksettings->parent.phy_address;
+ legacy_settings->autoneg = ksettings->parent.autoneg;
+ legacy_settings->mdio_support = ksettings->parent.mdio_support;
+ legacy_settings->eth_tp_mdix = ksettings->parent.eth_tp_mdix;
+ legacy_settings->eth_tp_mdix_ctrl = ksettings->parent.eth_tp_mdix_ctrl;
+ return retval;
+}
+
+/* number of 32-bit words to store the user's link mode bitmaps */
+#define __ETHTOOL_LINK_MODE_MASK_NU32 \
+ ((__ETHTOOL_LINK_MODE_MASK_NBITS + 31) / 32)
+
+/* layout of the struct passed from/to userland */
+struct ethtool_usettings {
+ struct ethtool_settings parent;
+ struct {
+ __u32 supported[__ETHTOOL_LINK_MODE_MASK_NU32] __aligned(4);
+ __u32 advertising[__ETHTOOL_LINK_MODE_MASK_NU32] __aligned(4);
+ __u32 lp_advertising[
+ __ETHTOOL_LINK_MODE_MASK_NU32]__aligned(4);
+ } link_modes;
+};
+
+/* Internal kernel helper to query a device ethtool_settings.
+ *
+ * Backward compatibility note: for compatibility with legacy drivers
+ * that implement only the ethtool_cmd API, this has to work with both
+ * drivers implementing get_ksettings API and drivers implementing
+ * get_settings API. When drivers implement get_settings and report
+ * ethtool_cmd deprecated fields (transceiver/maxrxpkt/maxtxpkt),
+ * these fields are silently ignored because the resulting struct
+ * ethtool_settings does not report them.
+ */
+int __ethtool_get_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *ksettings)
+{
+ int err;
+ struct ethtool_cmd cmd;
+
+ ASSERT_RTNL();
+
+ if (dev->ethtool_ops->get_ksettings) {
+ memset(ksettings, 0, sizeof(*ksettings));
+ return dev->ethtool_ops->get_ksettings(dev, ksettings);
+ }
+
+ /* TODO: remove what follows when ethtool_ops::get_settings
+ * disappears internally
+ */
+
+ /* driver doesn't support %ethtool_ksettings API. revert to
+ * legacy %ethtool_cmd API, unless it's not supported either.
+ * TODO: remove when ethtool_ops::get_settings disappears internally
+ */
+ err = __ethtool_get_settings(dev, &cmd);
+ if (err < 0)
+ return err;
+
+ /* we ignore deprecated fields transceiver/maxrxpkt/maxtxpkt
+ */
+ convert_legacy_settings_to_ksettings(ksettings, &cmd);
+ return err;
+}
+EXPORT_SYMBOL(__ethtool_get_ksettings);
+
+#if BITS_PER_LONG == 64
+static unsigned long _shl32(__u32 v)
+{
+ return ((unsigned long)v) << 32;
+}
+#endif
+
+/* convert a user's __u32[] bitmap in user space to a kernel internal
+ * bitmap. return 0 on success, errno on error. this assumes that
+ * link_mode_masks_nwords was already verified
+ */
+static int load_ksettings_from_user(struct ethtool_ksettings *to,
+ const void __user *from)
+{
+ struct ethtool_usettings usettings;
+#if BITS_PER_LONG != 32
+ unsigned i;
+#endif
+
+ if (copy_from_user(&usettings, from, sizeof(usettings)))
+ return -EFAULT;
+
+ /* make sure we didn't receive garbage between last allowed bit
+ * and end of last u32 word
+ */
+ if (__ETHTOOL_LINK_MODE_MASK_NBITS % 32) {
+ const u32 allowed = (
+ 1U << (__ETHTOOL_LINK_MODE_MASK_NBITS % 32)) - 1;
+ if (usettings.link_modes.supported[
+ __ETHTOOL_LINK_MODE_MASK_NU32-1] & ~allowed)
+ return -EINVAL;
+ if (usettings.link_modes.advertising[
+ __ETHTOOL_LINK_MODE_MASK_NU32-1] & ~allowed)
+ return -EINVAL;
+ if (usettings.link_modes.lp_advertising[
+ __ETHTOOL_LINK_MODE_MASK_NU32-1] & ~allowed)
+ return -EINVAL;
+ }
+
+#if BITS_PER_LONG == 32
+ compiletime_assert(sizeof(*to) == sizeof(usettings),
+ "sizeof(ulong) != 32");
+ memcpy(to, &usettings, sizeof(*to));
+#elif BITS_PER_LONG == 64
+ memset(to, 0, sizeof(*to));
+ memcpy(&to->parent, &usettings.parent, sizeof(to->parent));
+ for (i = 0 ; i < __ETHTOOL_LINK_MODE_MASK_NU32 ; ++i) {
+ if (0 == (i & 1)) {
+ to->link_modes.supported.mask[i>>1]
+ = usettings.link_modes.supported[i];
+ to->link_modes.advertising.mask[i>>1]
+ = usettings.link_modes.advertising[i];
+ to->link_modes.lp_advertising.mask[i>>1]
+ = usettings.link_modes.lp_advertising[i];
+ } else {
+ to->link_modes.supported.mask[i>>1] |= _shl32(
+ usettings.link_modes.supported[i]);
+ to->link_modes.advertising.mask[i>>1] |= _shl32(
+ usettings.link_modes.advertising[i]);
+ to->link_modes.lp_advertising.mask[i>>1] |= _shl32(
+ usettings.link_modes.lp_advertising[i]);
+ }
+ }
+#else
+# error "unsupported ulong width"
+#endif
+ return 0;
+}
+
+/* convert a kernel internal bitmap to a user space __u32[]
+ * bitmap. return 0 on success, errno on error.
+ */
+static int store_ksettings_for_user(void __user *to,
+ const struct ethtool_ksettings *from)
+{
+ struct ethtool_usettings usettings;
+#if BITS_PER_LONG != 32
+ unsigned i;
+#endif
+
+ compiletime_assert(__ETHTOOL_LINK_MODE_MASK_NU32 <= S8_MAX,
+ "need too many bits for link modes!");
+
+#if BITS_PER_LONG == 32
+ compiletime_assert(sizeof(*from) == sizeof(usettings),
+ "sizeof(ulong) != 32");
+ memcpy(&usettings, from, sizeof(usettings));
+#elif BITS_PER_LONG == 64
+ memset(&usettings, 0, sizeof(usettings));
+ memcpy(&usettings.parent, &from->parent, sizeof(usettings));
+ for (i = 0 ; i < __ETHTOOL_LINK_MODE_MASK_NU32 ; ++i) {
+ if (0 == (i & 1)) {
+ usettings.link_modes.supported[i] = lower_32_bits(
+ from->link_modes.supported.mask[i>>1]);
+ usettings.link_modes.advertising[i] = lower_32_bits(
+ from->link_modes.advertising.mask[i>>1]);
+ usettings.link_modes.lp_advertising[i] = lower_32_bits(
+ from->link_modes.lp_advertising.mask[i>>1]);
+ } else {
+ usettings.link_modes.supported[i] = upper_32_bits(
+ from->link_modes.supported.mask[i>>1]);
+ usettings.link_modes.advertising[i] = upper_32_bits(
+ from->link_modes.advertising.mask[i>>1]);
+ usettings.link_modes.lp_advertising[i] = upper_32_bits(
+ from->link_modes.lp_advertising.mask[i>>1]);
+ }
+ }
+#else
+# error "unsupported ulong width"
+#endif
+ if (copy_to_user(to, &usettings, sizeof(usettings)))
+ return -EFAULT;
+
+ return 0;
+}
+
+/* Query device for its ethtool_settings.
+ *
+ * Backward compatibility note: this function must fail when driver
+ * does not implement ethtool::get_ksettings, even if legacy
+ * ethtool_ops::get_settings is implemented. This tells new versions
+ * of ethtool that they should use the legacy API %ETHTOOL_GSET for
+ * this driver, so that they can correctly access the ethtool_cmd
+ * deprecated fields (transceiver/maxrxpkt/maxtxpkt), until no driver
+ * implements ethtool_ops::get_settings anymore.
+ */
+static int ethtool_get_ksettings(struct net_device *dev, void __user *useraddr)
+{
+ int err;
+ struct ethtool_ksettings ksettings;
+
+ if (!dev->ethtool_ops->get_ksettings)
+ return -EOPNOTSUPP;
+
+ /* handle bitmap nbits handshake */
+ if (copy_from_user(&ksettings.parent, useraddr,
+ sizeof(ksettings.parent)))
+ return -EFAULT;
+
+ if (__ETHTOOL_LINK_MODE_MASK_NU32
+ != ksettings.parent.link_mode_masks_nwords) {
+ /* wrong link mode nbits requested */
+ memset(&ksettings, 0, sizeof(ksettings));
+ /* keep cmd field reset to 0 */
+ /* send back number of words required as negative val */
+ ksettings.parent.link_mode_masks_nwords
+ = -((s8)__ETHTOOL_LINK_MODE_MASK_NU32);
+ err = 0;
+ } else {
+ memset(&ksettings, 0, sizeof(ksettings));
+ err = dev->ethtool_ops->get_ksettings(dev, &ksettings);
+ if (err < 0)
+ return err;
+
+ /* make sure we tell the right values to user */
+ ksettings.parent.cmd = ETHTOOL_GSETTINGS;
+ ksettings.parent.link_mode_masks_nwords
+ = __ETHTOOL_LINK_MODE_MASK_NU32;
+ }
+
+ return store_ksettings_for_user(useraddr, &ksettings);
+}
+
+/* Update device ethtool_settings.
+ *
+ * Backward compatibility note: this function must fail when driver
+ * does not implement ethtool::set_ksettings, even if legacy
+ * ethtool_ops::set_settings is implemented. This tells new versions
+ * of ethtool that they should use the legacy API %ETHTOOL_SSET for
+ * this driver, so that they can correctly update the ethtool_cmd
+ * deprecated fields (transceiver/maxrxpkt/maxtxpkt), until no driver
+ * implements ethtool_ops::get_settings anymore.
+ */
+static int ethtool_set_ksettings(struct net_device *dev, void __user *useraddr)
+{
+ int err;
+ struct ethtool_ksettings ksettings;
+
+ if (!dev->ethtool_ops->set_ksettings)
+ return -EOPNOTSUPP;
+
+ /* make sure nbits field has expected value */
+ if (copy_from_user(&ksettings.parent, useraddr,
+ sizeof(ksettings.parent)))
+ return -EFAULT;
+
+ if (__ETHTOOL_LINK_MODE_MASK_NU32
+ != ksettings.parent.link_mode_masks_nwords)
+ return -EINVAL;
+
+ /* copy the whole structure, now that we know it has expected
+ * format
+ */
+ err = load_ksettings_from_user(&ksettings, useraddr);
+ if (err)
+ return err;
+
+ /* re-check nwords field, just in case */
+ if (__ETHTOOL_LINK_MODE_MASK_NU32
+ != ksettings.parent.link_mode_masks_nwords)
+ return -EINVAL;
+
+ return dev->ethtool_ops->set_ksettings(dev, &ksettings);
+}
+
+/* Internal kernel helper to query a device ethtool_cmd settings.
+ *
+ * Note about transition to ethtool_settings API: We do not need (or
+ * want) this function to support "dev" instances that implement the
+ * ethtool_settings API as we will update the drivers calling this
+ * function to call __ethtool_get_ksettings instead, before the first
+ * drivers implement ethtool_ops::get_ksettings.
+ *
+ * TODO 1: at least make this function static when no driver is using it
+ * TODO 2: remove when ethtool_ops::get_settings disappears internally
+ */
int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
ASSERT_RTNL();
@@ -353,30 +735,118 @@ int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
}
EXPORT_SYMBOL(__ethtool_get_settings);
+/* Query device for its ethtool_cmd settings.
+ *
+ * Backward compatibility note: for compatibility with legacy ethtool,
+ * this has to work with both drivers implementing get_ksettings API
+ * and drivers implementing get_settings API. When drivers implement
+ * get_ksettings and report higher link mode bits, a kernel warning is
+ * logged once (with name of 1st driver/device) to recommend user to
+ * upgrade ethtool, but the command is successful (only the lower link
+ * mode bits reported back to user).
+ *
+ * TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear
+ */
static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
{
int err;
struct ethtool_cmd cmd;
- err = __ethtool_get_settings(dev, &cmd);
- if (err < 0)
- return err;
+ ASSERT_RTNL();
+
+ if (dev->ethtool_ops->get_ksettings) {
+ /* First, use ksettings API if it is supported */
+ struct ethtool_ksettings ksettings;
+
+ memset(&ksettings, 0, sizeof(ksettings));
+ err = dev->ethtool_ops->get_ksettings(dev, &ksettings);
+ if (err < 0)
+ return err;
+ if (!convert_ksettings_to_legacy_settings(&cmd, &ksettings)) {
+ static int __warned;
+
+ /* not all bitmaps could be translated
+ * acurately to legacy API: print warning with
+ * netdev name, but does still succeed
+ */
+ if (!__warned)
+ netdev_warn(dev, "please upgrade ethtool\n");
+ __warned = 1;
+ }
+ /* send a sensible cmd tag back to user */
+ cmd.cmd = ETHTOOL_GSET;
+ } else {
+ /* TODO: return -EOPNOTSUPP when
+ * ethtool_ops::get_settings disappears internally
+ */
+
+ /* driver doesn't support %ethtool_ksettings
+ * API. revert to legacy %ethtool_cmd API, unless it's
+ * not supported either.
+ */
+ err = __ethtool_get_settings(dev, &cmd);
+ if (err < 0)
+ return err;
+ }
if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
return -EFAULT;
+
return err;
}
+/* Update device settings with given ethtool_cmd.
+ *
+ * Backward compatibility note: for compatibility with legacy ethtool,
+ * this has to work with both drivers implementing set_ksettings API
+ * and drivers implementing set_settings API. When drivers implement
+ * set_ksettings and user's request updates deprecated ethtool_cmd
+ * fields (transceiver/maxrxpkt/maxtxpkt), a kernel warning is logged
+ * once (with name of 1st driver/device) to recommend user to upgrade
+ * ethtool, and the request is rejected.
+ *
+ * TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear
+ */
static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
{
struct ethtool_cmd cmd;
- if (!dev->ethtool_ops->set_settings)
- return -EOPNOTSUPP;
+ ASSERT_RTNL();
if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
return -EFAULT;
+ /* first, try new %ethtool_ksettings API. */
+ if (dev->ethtool_ops->set_ksettings) {
+ struct ethtool_ksettings ksettings;
+
+ if (!convert_legacy_settings_to_ksettings(&ksettings, &cmd)) {
+ static int __warned;
+
+ /* rejecting setting deprecated fields
+ * transceiver/maxtxpkt/maxrxpkt
+ */
+ if (!__warned)
+ netdev_warn(dev, "please upgrade ethtool");
+ __warned = 1;
+ return -EINVAL;
+ }
+
+ ksettings.parent.cmd = ETHTOOL_SSETTINGS;
+ ksettings.parent.link_mode_masks_nwords
+ = __ETHTOOL_LINK_MODE_MASK_NU32;
+ return dev->ethtool_ops->set_ksettings(dev, &ksettings);
+ }
+
+ /* legacy %ethtool_cmd API */
+
+ /* TODO: return -EOPNOTSUPP when ethtool_ops::get_settings
+ * disappears internally
+ */
+
+ if (!dev->ethtool_ops->set_settings)
+ return -EOPNOTSUPP;
+
return dev->ethtool_ops->set_settings(dev, &cmd);
}
@@ -1979,6 +2449,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_STUNABLE:
rc = ethtool_set_tunable(dev, useraddr);
break;
+ case ETHTOOL_GSETTINGS:
+ rc = ethtool_get_ksettings(dev, useraddr);
+ break;
+ case ETHTOOL_SSETTINGS:
+ rc = ethtool_set_ksettings(dev, useraddr);
+ break;
default:
rc = -EOPNOTSUPP;
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 05/18] net: tx4939: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (3 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 04/18] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 12:32 ` Sergei Shtylyov
2015-01-27 1:36 ` [PATCH net-next v1 06/18] net: usnic: " David Decotigny
` (12 subsequent siblings)
17 siblings, 1 reply; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
arch/mips/txx9/generic/setup_tx4939.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c
index e3733cd..4a3ebf6 100644
--- a/arch/mips/txx9/generic/setup_tx4939.c
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -320,11 +320,12 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask)
#if IS_ENABLED(CONFIG_TC35815)
static u32 tx4939_get_eth_speed(struct net_device *dev)
{
- struct ethtool_cmd cmd;
- if (__ethtool_get_settings(dev, &cmd))
+ struct ethtool_ksettings cmd;
+
+ if (__ethtool_get_ksettings(dev, &cmd))
return 100; /* default 100Mbps */
- return ethtool_cmd_speed(&cmd);
+ return cmd.parent.speed;
}
static int tx4939_netdev_event(struct notifier_block *this,
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH net-next v1 05/18] net: tx4939: use __ethtool_get_ksettings
2015-01-27 1:36 ` [PATCH net-next v1 05/18] net: tx4939: use __ethtool_get_ksettings David Decotigny
@ 2015-01-27 12:32 ` Sergei Shtylyov
2015-01-27 17:38 ` David Decotigny
0 siblings, 1 reply; 22+ messages in thread
From: Sergei Shtylyov @ 2015-01-27 12:32 UTC (permalink / raw)
To: David Decotigny, David S. Miller, Ben Hutchings, Amir Vadai,
linux-kernel, netdev, linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
Hello.
On 1/27/2015 4:36 AM, David Decotigny wrote:
> From: David Decotigny <decot@googlers.com>
> Signed-off-by: David Decotigny <decot@googlers.com>
> ---
> arch/mips/txx9/generic/setup_tx4939.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
I don't think "net: " prefix applies here.
And you should have CC'ed linux-mips@linux-mips.org.
WBR, Sergei
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH net-next v1 05/18] net: tx4939: use __ethtool_get_ksettings
2015-01-27 12:32 ` Sergei Shtylyov
@ 2015-01-27 17:38 ` David Decotigny
0 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 17:38 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api, Eric Dumazet, Eugenia Emantayev, Or Gerlitz,
Ido Shamay, Joe Perches, Saeed Mahameed,
Govindarajulu Varadarajan, Venkata Duvvuru, Jeff Kirsher,
Eyal Perry, Pravin B Shelar, Ed Swierk
On Tue, Jan 27, 2015 at 4:32 AM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> linux-mips@linux-mips.org.
Thanks, added mips + usnic + fcoe in my copy for the next wave of
reviews. Also updated the subject line.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 06/18] net: usnic: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (4 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 05/18] net: tx4939: use __ethtool_get_ksettings David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 07/18] net: bonding: " David Decotigny
` (11 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
index d71ba62..f6f67c9 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -305,12 +305,12 @@ int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props)
{
struct usnic_ib_dev *us_ibdev = to_usdev(ibdev);
- struct ethtool_cmd cmd;
+ struct ethtool_ksettings cmd;
usnic_dbg("\n");
mutex_lock(&us_ibdev->usdev_lock);
- __ethtool_get_settings(us_ibdev->netdev, &cmd);
+ __ethtool_get_ksettings(us_ibdev->netdev, &cmd);
memset(props, 0, sizeof(*props));
props->lid = 0;
@@ -334,8 +334,8 @@ int usnic_ib_query_port(struct ib_device *ibdev, u8 port,
props->pkey_tbl_len = 1;
props->bad_pkey_cntr = 0;
props->qkey_viol_cntr = 0;
- eth_speed_to_ib_speed(cmd.speed, &props->active_speed,
- &props->active_width);
+ eth_speed_to_ib_speed(cmd.parent.speed, &props->active_speed,
+ &props->active_width);
props->max_mtu = IB_MTU_4096;
props->active_mtu = iboe_get_mtu(us_ibdev->ufdev->mtu);
/* Userspace will adjust for hdrs */
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 07/18] net: bonding: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (5 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 06/18] net: usnic: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 08/18] net: ipvlan: " David Decotigny
` (10 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/bonding/bond_main.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f47bc43..7710386 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -371,22 +371,20 @@ down:
static void bond_update_speed_duplex(struct slave *slave)
{
struct net_device *slave_dev = slave->dev;
- struct ethtool_cmd ecmd;
- u32 slave_speed;
+ struct ethtool_ksettings ecmd;
int res;
slave->speed = SPEED_UNKNOWN;
slave->duplex = DUPLEX_UNKNOWN;
- res = __ethtool_get_settings(slave_dev, &ecmd);
+ res = __ethtool_get_ksettings(slave_dev, &ecmd);
if (res < 0)
return;
- slave_speed = ethtool_cmd_speed(&ecmd);
- if (slave_speed == 0 || slave_speed == ((__u32) -1))
+ if (ecmd.parent.speed == 0 || ecmd.parent.speed == ((__u32) -1))
return;
- switch (ecmd.duplex) {
+ switch (ecmd.parent.duplex) {
case DUPLEX_FULL:
case DUPLEX_HALF:
break;
@@ -394,8 +392,8 @@ static void bond_update_speed_duplex(struct slave *slave)
return;
}
- slave->speed = slave_speed;
- slave->duplex = ecmd.duplex;
+ slave->speed = ecmd.parent.speed;
+ slave->duplex = ecmd.parent.duplex;
return;
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 08/18] net: ipvlan: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (6 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 07/18] net: bonding: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 09/18] net: macvlan: " David Decotigny
` (9 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/ipvlan/ipvlan_main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4f4099d..79e3516 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -342,12 +342,12 @@ static const struct header_ops ipvlan_header_ops = {
.cache_update = eth_header_cache_update,
};
-static int ipvlan_ethtool_get_settings(struct net_device *dev,
- struct ethtool_cmd *cmd)
+static int ipvlan_ethtool_get_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *cmd)
{
const struct ipvl_dev *ipvlan = netdev_priv(dev);
- return __ethtool_get_settings(ipvlan->phy_dev, cmd);
+ return __ethtool_get_ksettings(ipvlan->phy_dev, cmd);
}
static void ipvlan_ethtool_get_drvinfo(struct net_device *dev,
@@ -373,7 +373,7 @@ static void ipvlan_ethtool_set_msglevel(struct net_device *dev, u32 value)
static const struct ethtool_ops ipvlan_ethtool_ops = {
.get_link = ethtool_op_get_link,
- .get_settings = ipvlan_ethtool_get_settings,
+ .get_ksettings = ipvlan_ethtool_get_ksettings,
.get_drvinfo = ipvlan_ethtool_get_drvinfo,
.get_msglevel = ipvlan_ethtool_get_msglevel,
.set_msglevel = ipvlan_ethtool_set_msglevel,
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 09/18] net: macvlan: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (7 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 08/18] net: ipvlan: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 10/18] net: team: " David Decotigny
` (8 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/macvlan.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 1df38bd..ce934c3 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -925,12 +925,12 @@ static void macvlan_ethtool_get_drvinfo(struct net_device *dev,
strlcpy(drvinfo->version, "0.1", sizeof(drvinfo->version));
}
-static int macvlan_ethtool_get_settings(struct net_device *dev,
- struct ethtool_cmd *cmd)
+static int macvlan_ethtool_get_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *cmd)
{
const struct macvlan_dev *vlan = netdev_priv(dev);
- return __ethtool_get_settings(vlan->lowerdev, cmd);
+ return __ethtool_get_ksettings(vlan->lowerdev, cmd);
}
static netdev_features_t macvlan_fix_features(struct net_device *dev,
@@ -998,7 +998,7 @@ static void macvlan_dev_netpoll_cleanup(struct net_device *dev)
static const struct ethtool_ops macvlan_ethtool_ops = {
.get_link = ethtool_op_get_link,
- .get_settings = macvlan_ethtool_get_settings,
+ .get_ksettings = macvlan_ethtool_get_ksettings,
.get_drvinfo = macvlan_ethtool_get_drvinfo,
};
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 10/18] net: team: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (8 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 09/18] net: macvlan: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 11/18] net: fcoe: " David Decotigny
` (7 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/team/team.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 4b2bfc5..77576d1 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2767,12 +2767,12 @@ static void __team_port_change_send(struct team_port *port, bool linkup)
port->state.linkup = linkup;
team_refresh_port_linkup(port);
if (linkup) {
- struct ethtool_cmd ecmd;
+ struct ethtool_ksettings ecmd;
- err = __ethtool_get_settings(port->dev, &ecmd);
+ err = __ethtool_get_ksettings(port->dev, &ecmd);
if (!err) {
- port->state.speed = ethtool_cmd_speed(&ecmd);
- port->state.duplex = ecmd.duplex;
+ port->state.speed = ecmd.parent.speed;
+ port->state.duplex = ecmd.parent.duplex;
goto send_event;
}
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 11/18] net: fcoe: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (9 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 10/18] net: team: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 12/18] net: rdma: " David Decotigny
` (6 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/scsi/fcoe/fcoe_transport.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index bdc8989..6097f0d 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -93,36 +93,40 @@ static struct notifier_block libfcoe_notifier = {
int fcoe_link_speed_update(struct fc_lport *lport)
{
struct net_device *netdev = fcoe_get_netdev(lport);
- struct ethtool_cmd ecmd;
+ struct ethtool_ksettings ecmd;
- if (!__ethtool_get_settings(netdev, &ecmd)) {
+ if (!__ethtool_get_ksettings(netdev, &ecmd)) {
lport->link_supported_speeds &= ~(FC_PORTSPEED_1GBIT |
FC_PORTSPEED_10GBIT |
FC_PORTSPEED_20GBIT |
FC_PORTSPEED_40GBIT);
- if (ecmd.supported & (SUPPORTED_1000baseT_Half |
- SUPPORTED_1000baseT_Full |
- SUPPORTED_1000baseKX_Full))
+ if (ecmd.link_modes.supported.mask[0] & (
+ SUPPORTED_1000baseT_Half |
+ SUPPORTED_1000baseT_Full |
+ SUPPORTED_1000baseKX_Full))
lport->link_supported_speeds |= FC_PORTSPEED_1GBIT;
- if (ecmd.supported & (SUPPORTED_10000baseT_Full |
- SUPPORTED_10000baseKX4_Full |
- SUPPORTED_10000baseKR_Full |
- SUPPORTED_10000baseR_FEC))
+ if (ecmd.link_modes.supported.mask[0] & (
+ SUPPORTED_10000baseT_Full |
+ SUPPORTED_10000baseKX4_Full |
+ SUPPORTED_10000baseKR_Full |
+ SUPPORTED_10000baseR_FEC))
lport->link_supported_speeds |= FC_PORTSPEED_10GBIT;
- if (ecmd.supported & (SUPPORTED_20000baseMLD2_Full |
- SUPPORTED_20000baseKR2_Full))
+ if (ecmd.link_modes.supported.mask[0] & (
+ SUPPORTED_20000baseMLD2_Full |
+ SUPPORTED_20000baseKR2_Full))
lport->link_supported_speeds |= FC_PORTSPEED_20GBIT;
- if (ecmd.supported & (SUPPORTED_40000baseKR4_Full |
- SUPPORTED_40000baseCR4_Full |
- SUPPORTED_40000baseSR4_Full |
- SUPPORTED_40000baseLR4_Full))
+ if (ecmd.link_modes.supported.mask[0] & (
+ SUPPORTED_40000baseKR4_Full |
+ SUPPORTED_40000baseCR4_Full |
+ SUPPORTED_40000baseSR4_Full |
+ SUPPORTED_40000baseLR4_Full))
lport->link_supported_speeds |= FC_PORTSPEED_40GBIT;
- switch (ethtool_cmd_speed(&ecmd)) {
+ switch (ecmd.parent.speed) {
case SPEED_1000:
lport->link_speed = FC_PORTSPEED_1GBIT;
break;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 12/18] net: rdma: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (10 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 11/18] net: fcoe: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 13/18] net: 8021q: " David Decotigny
` (5 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
include/rdma/ib_addr.h | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index ce55906..782bb8c 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -241,24 +241,22 @@ static inline enum ib_mtu iboe_get_mtu(int mtu)
static inline int iboe_get_rate(struct net_device *dev)
{
- struct ethtool_cmd cmd;
- u32 speed;
+ struct ethtool_ksettings cmd;
int err;
rtnl_lock();
- err = __ethtool_get_settings(dev, &cmd);
+ err = __ethtool_get_ksettings(dev, &cmd);
rtnl_unlock();
if (err)
return IB_RATE_PORT_CURRENT;
- speed = ethtool_cmd_speed(&cmd);
- if (speed >= 40000)
+ if (cmd.parent.speed >= 40000)
return IB_RATE_40_GBPS;
- else if (speed >= 30000)
+ else if (cmd.parent.speed >= 30000)
return IB_RATE_30_GBPS;
- else if (speed >= 20000)
+ else if (cmd.parent.speed >= 20000)
return IB_RATE_20_GBPS;
- else if (speed >= 10000)
+ else if (cmd.parent.speed >= 10000)
return IB_RATE_10_GBPS;
else
return IB_RATE_PORT_CURRENT;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 13/18] net: 8021q: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (11 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 12/18] net: rdma: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 14/18] net: bridge: " David Decotigny
` (4 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
net/8021q/vlan_dev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 1189564..b301bf6 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -655,12 +655,12 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
return features;
}
-static int vlan_ethtool_get_settings(struct net_device *dev,
- struct ethtool_cmd *cmd)
+static int vlan_ethtool_get_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *cmd)
{
const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
- return __ethtool_get_settings(vlan->real_dev, cmd);
+ return __ethtool_get_ksettings(vlan->real_dev, cmd);
}
static void vlan_ethtool_get_drvinfo(struct net_device *dev,
@@ -768,7 +768,7 @@ static void vlan_dev_netpoll_cleanup(struct net_device *dev)
#endif /* CONFIG_NET_POLL_CONTROLLER */
static const struct ethtool_ops vlan_ethtool_ops = {
- .get_settings = vlan_ethtool_get_settings,
+ .get_ksettings = vlan_ethtool_get_ksettings,
.get_drvinfo = vlan_ethtool_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_ts_info = vlan_ethtool_get_ts_info,
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 14/18] net: bridge: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (12 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 13/18] net: 8021q: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 15/18] net: core: " David Decotigny
` (3 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
net/bridge/br_if.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index b087d27..57282a5 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -35,10 +35,10 @@
*/
static int port_cost(struct net_device *dev)
{
- struct ethtool_cmd ecmd;
+ struct ethtool_ksettings ecmd;
- if (!__ethtool_get_settings(dev, &ecmd)) {
- switch (ethtool_cmd_speed(&ecmd)) {
+ if (!__ethtool_get_ksettings(dev, &ecmd)) {
+ switch (ecmd.parent.speed) {
case SPEED_10000:
return 2;
case SPEED_1000:
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 15/18] net: core: use __ethtool_get_ksettings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (13 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 14/18] net: bridge: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 16/18] net: ethtool: remove unused __ethtool_get_settings David Decotigny
` (2 subsequent siblings)
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
net/core/net-sysfs.c | 15 +++++++++------
net/packet/af_packet.c | 11 +++++------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 9993412..f54ae21 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -191,9 +191,10 @@ static ssize_t speed_show(struct device *dev,
return restart_syscall();
if (netif_running(netdev)) {
- struct ethtool_cmd cmd;
- if (!__ethtool_get_settings(netdev, &cmd))
- ret = sprintf(buf, fmt_udec, ethtool_cmd_speed(&cmd));
+ struct ethtool_ksettings cmd;
+
+ if (!__ethtool_get_ksettings(netdev, &cmd))
+ ret = sprintf(buf, fmt_udec, cmd.parent.speed);
}
rtnl_unlock();
return ret;
@@ -210,10 +211,12 @@ static ssize_t duplex_show(struct device *dev,
return restart_syscall();
if (netif_running(netdev)) {
- struct ethtool_cmd cmd;
- if (!__ethtool_get_settings(netdev, &cmd)) {
+ struct ethtool_ksettings cmd;
+
+ if (!__ethtool_get_ksettings(netdev, &cmd)) {
const char *duplex;
- switch (cmd.duplex) {
+
+ switch (cmd.parent.duplex) {
case DUPLEX_HALF:
duplex = "half";
break;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 9c28cec..fe2fcbe 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -554,9 +554,8 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po,
{
struct net_device *dev;
unsigned int mbits = 0, msec = 0, div = 0, tmo = 0;
- struct ethtool_cmd ecmd;
+ struct ethtool_ksettings ecmd;
int err;
- u32 speed;
rtnl_lock();
dev = __dev_get_by_index(sock_net(&po->sk), po->ifindex);
@@ -564,19 +563,19 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po,
rtnl_unlock();
return DEFAULT_PRB_RETIRE_TOV;
}
- err = __ethtool_get_settings(dev, &ecmd);
- speed = ethtool_cmd_speed(&ecmd);
+ err = __ethtool_get_ksettings(dev, &ecmd);
rtnl_unlock();
if (!err) {
/*
* If the link speed is so slow you don't really
* need to worry about perf anyways
*/
- if (speed < SPEED_1000 || speed == SPEED_UNKNOWN) {
+ if (ecmd.parent.speed < SPEED_1000 ||
+ ecmd.parent.speed == SPEED_UNKNOWN) {
return DEFAULT_PRB_RETIRE_TOV;
} else {
msec = 1;
- div = speed / 1000;
+ div = ecmd.parent.speed / 1000;
}
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 16/18] net: ethtool: remove unused __ethtool_get_settings
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (14 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 15/18] net: core: " David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 17/18] net: mlx4: identify predicate for debug messages David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 18/18] net: mlx4: use new ETHTOOL_G/SSETTINGS API David Decotigny
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
replaced by __ethtool_get_ksettings.
Signed-off-by: David Decotigny <decot@googlers.com>
---
include/linux/ethtool.h | 4 ----
net/core/ethtool.c | 46 ++++++++++++----------------------------------
2 files changed, 12 insertions(+), 38 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 49881b6..d9c8fab 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -160,10 +160,6 @@ __ethtool_add_link_modes(ethtool_link_mode_mask_t *dst,
extern int __ethtool_get_ksettings(struct net_device *dev,
struct ethtool_ksettings *ksettings);
-/* DEPRECATED, use __ethtool_get_ksettings */
-extern int __ethtool_get_settings(struct net_device *dev,
- struct ethtool_cmd *cmd);
-
/**
* struct ethtool_ops - optional netdev operations
* @get_settings: DEPRECATED, use %get_ksettings/%set_ksettings
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index d978d80..1a2b8a6 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -487,15 +487,16 @@ int __ethtool_get_ksettings(struct net_device *dev,
return dev->ethtool_ops->get_ksettings(dev, ksettings);
}
- /* TODO: remove what follows when ethtool_ops::get_settings
- * disappears internally
- */
-
/* driver doesn't support %ethtool_ksettings API. revert to
* legacy %ethtool_cmd API, unless it's not supported either.
* TODO: remove when ethtool_ops::get_settings disappears internally
*/
- err = __ethtool_get_settings(dev, &cmd);
+ if (!dev->ethtool_ops->get_settings)
+ return -EOPNOTSUPP;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.cmd = ETHTOOL_GSET;
+ err = dev->ethtool_ops->get_settings(dev, &cmd);
if (err < 0)
return err;
@@ -711,30 +712,6 @@ static int ethtool_set_ksettings(struct net_device *dev, void __user *useraddr)
return dev->ethtool_ops->set_ksettings(dev, &ksettings);
}
-/* Internal kernel helper to query a device ethtool_cmd settings.
- *
- * Note about transition to ethtool_settings API: We do not need (or
- * want) this function to support "dev" instances that implement the
- * ethtool_settings API as we will update the drivers calling this
- * function to call __ethtool_get_ksettings instead, before the first
- * drivers implement ethtool_ops::get_ksettings.
- *
- * TODO 1: at least make this function static when no driver is using it
- * TODO 2: remove when ethtool_ops::get_settings disappears internally
- */
-int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
- ASSERT_RTNL();
-
- if (!dev->ethtool_ops->get_settings)
- return -EOPNOTSUPP;
-
- memset(cmd, 0, sizeof(struct ethtool_cmd));
- cmd->cmd = ETHTOOL_GSET;
- return dev->ethtool_ops->get_settings(dev, cmd);
-}
-EXPORT_SYMBOL(__ethtool_get_settings);
-
/* Query device for its ethtool_cmd settings.
*
* Backward compatibility note: for compatibility with legacy ethtool,
@@ -776,15 +753,16 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
/* send a sensible cmd tag back to user */
cmd.cmd = ETHTOOL_GSET;
} else {
- /* TODO: return -EOPNOTSUPP when
- * ethtool_ops::get_settings disappears internally
- */
-
/* driver doesn't support %ethtool_ksettings
* API. revert to legacy %ethtool_cmd API, unless it's
* not supported either.
*/
- err = __ethtool_get_settings(dev, &cmd);
+ if (!dev->ethtool_ops->get_settings)
+ return -EOPNOTSUPP;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.cmd = ETHTOOL_GSET;
+ err = dev->ethtool_ops->get_settings(dev, &cmd);
if (err < 0)
return err;
}
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 17/18] net: mlx4: identify predicate for debug messages
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (15 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 16/18] net: ethtool: remove unused __ethtool_get_settings David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
2015-01-27 1:36 ` [PATCH net-next v1 18/18] net: mlx4: use new ETHTOOL_G/SSETTINGS API David Decotigny
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 944a112..96bf728 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -869,9 +869,11 @@ __printf(3, 4)
void en_print(const char *level, const struct mlx4_en_priv *priv,
const char *format, ...);
+#define en_dbg_enabled(mlevel, priv) \
+ (NETIF_MSG_##mlevel & (priv)->msg_enable)
#define en_dbg(mlevel, priv, format, ...) \
do { \
- if (NETIF_MSG_##mlevel & (priv)->msg_enable) \
+ if (en_dbg_enabled(mlevel, priv)) \
en_print(KERN_DEBUG, priv, format, ##__VA_ARGS__); \
} while (0)
#define en_warn(priv, format, ...) \
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH net-next v1 18/18] net: mlx4: use new ETHTOOL_G/SSETTINGS API
2015-01-27 1:35 [PATCH net-next v1 00/18] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny
` (16 preceding siblings ...)
2015-01-27 1:36 ` [PATCH net-next v1 17/18] net: mlx4: identify predicate for debug messages David Decotigny
@ 2015-01-27 1:36 ` David Decotigny
17 siblings, 0 replies; 22+ messages in thread
From: David Decotigny @ 2015-01-27 1:36 UTC (permalink / raw)
To: David S. Miller, Ben Hutchings, Amir Vadai, linux-kernel, netdev,
linux-api
Cc: Eric Dumazet, Eugenia Emantayev, Or Gerlitz, Ido Shamay,
Joe Perches, Saeed Mahameed, Govindarajulu Varadarajan,
Venkata Duvvuru, Jeff Kirsher, Eyal Perry, Pravin B Shelar,
Ed Swierk, David Decotigny
From: David Decotigny <decot@googlers.com>
Signed-off-by: David Decotigny <decot@googlers.com>
---
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 326 ++++++++++++------------
drivers/net/ethernet/mellanox/mlx4/en_main.c | 1 +
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 +
3 files changed, 161 insertions(+), 167 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 569eda9..4ad34064 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -388,34 +388,30 @@ static u32 mlx4_en_autoneg_get(struct net_device *dev)
return autoneg;
}
-static u32 ptys_get_supported_port(struct mlx4_ptys_reg *ptys_reg)
+static void ptys2ethtool_update_supported_port(ethtool_link_mode_mask_t *mask,
+ struct mlx4_ptys_reg *ptys_reg)
{
u32 eth_proto = be32_to_cpu(ptys_reg->eth_proto_cap);
if (eth_proto & (MLX4_PROT_MASK(MLX4_10GBASE_T)
| MLX4_PROT_MASK(MLX4_1000BASE_T)
| MLX4_PROT_MASK(MLX4_100BASE_TX))) {
- return SUPPORTED_TP;
- }
-
- if (eth_proto & (MLX4_PROT_MASK(MLX4_10GBASE_CR)
+ ethtool_add_link_modes(mask, ETHTOOL_LINK_MODE_TP_BIT);
+ } else if (eth_proto & (MLX4_PROT_MASK(MLX4_10GBASE_CR)
| MLX4_PROT_MASK(MLX4_10GBASE_SR)
| MLX4_PROT_MASK(MLX4_56GBASE_SR4)
| MLX4_PROT_MASK(MLX4_40GBASE_CR4)
| MLX4_PROT_MASK(MLX4_40GBASE_SR4)
| MLX4_PROT_MASK(MLX4_1000BASE_CX_SGMII))) {
- return SUPPORTED_FIBRE;
- }
-
- if (eth_proto & (MLX4_PROT_MASK(MLX4_56GBASE_KR4)
+ ethtool_add_link_modes(mask, ETHTOOL_LINK_MODE_FIBRE_BIT);
+ } else if (eth_proto & (MLX4_PROT_MASK(MLX4_56GBASE_KR4)
| MLX4_PROT_MASK(MLX4_40GBASE_KR4)
| MLX4_PROT_MASK(MLX4_20GBASE_KR2)
| MLX4_PROT_MASK(MLX4_10GBASE_KR)
| MLX4_PROT_MASK(MLX4_10GBASE_KX4)
| MLX4_PROT_MASK(MLX4_1000BASE_KX))) {
- return SUPPORTED_Backplane;
+ ethtool_add_link_modes(mask, ETHTOOL_LINK_MODE_Backplane_BIT);
}
- return 0;
}
static u32 ptys_get_active_port(struct mlx4_ptys_reg *ptys_reg)
@@ -461,122 +457,91 @@ static u32 ptys_get_active_port(struct mlx4_ptys_reg *ptys_reg)
enum ethtool_report {
SUPPORTED = 0,
ADVERTISED = 1,
- SPEED = 2
};
+struct ptys2ethtool_config {
+ ethtool_link_mode_mask_t link_modes[2]; /* SUPPORTED/ADVERTISED */
+ u32 speed;
+};
+
+#define MLX4_BUILD_PTYS2ETHTOOL_CONFIG(reg_, speed_, ...) \
+ ({ \
+ struct ptys2ethtool_config *cfg; \
+ cfg = &ptys2ethtool_map[reg_]; \
+ cfg->speed = speed_; \
+ ethtool_build_link_mode(&cfg->link_modes[SUPPORTED], \
+ __VA_ARGS__); \
+ ethtool_build_link_mode(&cfg->link_modes[ADVERTISED], \
+ __VA_ARGS__); \
+ })
+
/* Translates mlx4 link mode to equivalent ethtool Link modes/speed */
-static u32 ptys2ethtool_map[MLX4_LINK_MODES_SZ][3] = {
- [MLX4_100BASE_TX] = {
- SUPPORTED_100baseT_Full,
- ADVERTISED_100baseT_Full,
- SPEED_100
- },
-
- [MLX4_1000BASE_T] = {
- SUPPORTED_1000baseT_Full,
- ADVERTISED_1000baseT_Full,
- SPEED_1000
- },
- [MLX4_1000BASE_CX_SGMII] = {
- SUPPORTED_1000baseKX_Full,
- ADVERTISED_1000baseKX_Full,
- SPEED_1000
- },
- [MLX4_1000BASE_KX] = {
- SUPPORTED_1000baseKX_Full,
- ADVERTISED_1000baseKX_Full,
- SPEED_1000
- },
-
- [MLX4_10GBASE_T] = {
- SUPPORTED_10000baseT_Full,
- ADVERTISED_10000baseT_Full,
- SPEED_10000
- },
- [MLX4_10GBASE_CX4] = {
- SUPPORTED_10000baseKX4_Full,
- ADVERTISED_10000baseKX4_Full,
- SPEED_10000
- },
- [MLX4_10GBASE_KX4] = {
- SUPPORTED_10000baseKX4_Full,
- ADVERTISED_10000baseKX4_Full,
- SPEED_10000
- },
- [MLX4_10GBASE_KR] = {
- SUPPORTED_10000baseKR_Full,
- ADVERTISED_10000baseKR_Full,
- SPEED_10000
- },
- [MLX4_10GBASE_CR] = {
- SUPPORTED_10000baseKR_Full,
- ADVERTISED_10000baseKR_Full,
- SPEED_10000
- },
- [MLX4_10GBASE_SR] = {
- SUPPORTED_10000baseKR_Full,
- ADVERTISED_10000baseKR_Full,
- SPEED_10000
- },
-
- [MLX4_20GBASE_KR2] = {
- SUPPORTED_20000baseMLD2_Full | SUPPORTED_20000baseKR2_Full,
- ADVERTISED_20000baseMLD2_Full | ADVERTISED_20000baseKR2_Full,
- SPEED_20000
- },
-
- [MLX4_40GBASE_CR4] = {
- SUPPORTED_40000baseCR4_Full,
- ADVERTISED_40000baseCR4_Full,
- SPEED_40000
- },
- [MLX4_40GBASE_KR4] = {
- SUPPORTED_40000baseKR4_Full,
- ADVERTISED_40000baseKR4_Full,
- SPEED_40000
- },
- [MLX4_40GBASE_SR4] = {
- SUPPORTED_40000baseSR4_Full,
- ADVERTISED_40000baseSR4_Full,
- SPEED_40000
- },
-
- [MLX4_56GBASE_KR4] = {
- SUPPORTED_56000baseKR4_Full,
- ADVERTISED_56000baseKR4_Full,
- SPEED_56000
- },
- [MLX4_56GBASE_CR4] = {
- SUPPORTED_56000baseCR4_Full,
- ADVERTISED_56000baseCR4_Full,
- SPEED_56000
- },
- [MLX4_56GBASE_SR4] = {
- SUPPORTED_56000baseSR4_Full,
- ADVERTISED_56000baseSR4_Full,
- SPEED_56000
- },
+static struct ptys2ethtool_config ptys2ethtool_map[MLX4_LINK_MODES_SZ];
+
+void __init mlx4_en_init_ptys2ethtool_map(void)
+{
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_100BASE_TX, SPEED_100,
+ ETHTOOL_LINK_MODE_100baseT_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_1000BASE_T, SPEED_1000,
+ ETHTOOL_LINK_MODE_1000baseT_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_1000BASE_CX_SGMII, SPEED_1000,
+ ETHTOOL_LINK_MODE_1000baseKX_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_1000BASE_KX, SPEED_1000,
+ ETHTOOL_LINK_MODE_1000baseKX_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_10GBASE_T, SPEED_10000,
+ ETHTOOL_LINK_MODE_10000baseT_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_10GBASE_CX4, SPEED_10000,
+ ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_10GBASE_KX4, SPEED_10000,
+ ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_10GBASE_KR, SPEED_10000,
+ ETHTOOL_LINK_MODE_10000baseKR_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_10GBASE_CR, SPEED_10000,
+ ETHTOOL_LINK_MODE_10000baseKR_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_10GBASE_SR, SPEED_10000,
+ ETHTOOL_LINK_MODE_10000baseKR_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_20GBASE_KR2, SPEED_20000,
+ ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT,
+ ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_40GBASE_CR4, SPEED_40000,
+ ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_40GBASE_KR4, SPEED_40000,
+ ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_40GBASE_SR4, SPEED_40000,
+ ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_56GBASE_KR4, SPEED_56000,
+ ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_56GBASE_CR4, SPEED_56000,
+ ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT);
+ MLX4_BUILD_PTYS2ETHTOOL_CONFIG(MLX4_56GBASE_SR4, SPEED_56000,
+ ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT);
};
-static u32 ptys2ethtool_link_modes(u32 eth_proto, enum ethtool_report report)
+static void ptys2ethtool_update_link_modes(ethtool_link_mode_mask_t *link_modes,
+ u32 eth_proto,
+ enum ethtool_report report)
{
int i;
- u32 link_modes = 0;
-
for (i = 0; i < MLX4_LINK_MODES_SZ; i++) {
if (eth_proto & MLX4_PROT_MASK(i))
- link_modes |= ptys2ethtool_map[i][report];
+ bitmap_or(link_modes->mask,
+ link_modes->mask,
+ ptys2ethtool_map[i].link_modes[report].mask,
+ __ETHTOOL_LINK_MODE_MASK_NBITS);
}
- return link_modes;
}
-static u32 ethtool2ptys_link_modes(u32 link_modes, enum ethtool_report report)
+static u32 ethtool2ptys_link_modes(const ethtool_link_mode_mask_t *link_modes,
+ enum ethtool_report report)
{
int i;
u32 ptys_modes = 0;
for (i = 0; i < MLX4_LINK_MODES_SZ; i++) {
- if (ptys2ethtool_map[i][report] & link_modes)
+ if (bitmap_intersects(
+ ptys2ethtool_map[i].link_modes[report].mask,
+ link_modes->mask,
+ __ETHTOOL_LINK_MODE_MASK_NBITS))
ptys_modes |= 1 << i;
}
return ptys_modes;
@@ -589,14 +554,14 @@ static u32 speed2ptys_link_modes(u32 speed)
u32 ptys_modes = 0;
for (i = 0; i < MLX4_LINK_MODES_SZ; i++) {
- if (ptys2ethtool_map[i][SPEED] == speed)
+ if (ptys2ethtool_map[i].speed == speed)
ptys_modes |= 1 << i;
}
return ptys_modes;
}
-static int ethtool_get_ptys_settings(struct net_device *dev,
- struct ethtool_cmd *cmd)
+static int ethtool_get_ptys_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *ksettings)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_ptys_reg ptys_reg;
@@ -624,79 +589,94 @@ static int ethtool_get_ptys_settings(struct net_device *dev,
en_dbg(DRV, priv, "ptys_reg.eth_proto_lp_adv %x\n",
be32_to_cpu(ptys_reg.eth_proto_lp_adv));
- cmd->supported = 0;
- cmd->advertising = 0;
+ /* reset supported/advertising masks */
+ ethtool_build_link_mode(&ksettings->link_modes.supported);
+ ethtool_build_link_mode(&ksettings->link_modes.advertising);
- cmd->supported |= ptys_get_supported_port(&ptys_reg);
+ ptys2ethtool_update_supported_port(&ksettings->link_modes.supported,
+ &ptys_reg);
eth_proto = be32_to_cpu(ptys_reg.eth_proto_cap);
- cmd->supported |= ptys2ethtool_link_modes(eth_proto, SUPPORTED);
+ ptys2ethtool_update_link_modes(&ksettings->link_modes.supported,
+ eth_proto, SUPPORTED);
eth_proto = be32_to_cpu(ptys_reg.eth_proto_admin);
- cmd->advertising |= ptys2ethtool_link_modes(eth_proto, ADVERTISED);
+ ptys2ethtool_update_link_modes(&ksettings->link_modes.advertising,
+ eth_proto, ADVERTISED);
- cmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
- cmd->advertising |= (priv->prof->tx_pause) ? ADVERTISED_Pause : 0;
+ ethtool_add_link_modes(&ksettings->link_modes.supported,
+ ETHTOOL_LINK_MODE_Pause_BIT,
+ ETHTOOL_LINK_MODE_Pause_BIT);
- cmd->advertising |= (priv->prof->tx_pause ^ priv->prof->rx_pause) ?
- ADVERTISED_Asym_Pause : 0;
+ if (priv->prof->tx_pause)
+ ethtool_add_link_modes(&ksettings->link_modes.advertising,
+ ETHTOOL_LINK_MODE_Pause_BIT);
+ if (priv->prof->tx_pause ^ priv->prof->rx_pause)
+ ethtool_add_link_modes(&ksettings->link_modes.advertising,
+ ETHTOOL_LINK_MODE_Asym_Pause_BIT);
- cmd->port = ptys_get_active_port(&ptys_reg);
- cmd->transceiver = (SUPPORTED_TP & cmd->supported) ?
- XCVR_EXTERNAL : XCVR_INTERNAL;
+ ksettings->parent.port = ptys_get_active_port(&ptys_reg);
if (mlx4_en_autoneg_get(dev)) {
- cmd->supported |= SUPPORTED_Autoneg;
- cmd->advertising |= ADVERTISED_Autoneg;
+ ethtool_add_link_modes(&ksettings->link_modes.supported,
+ ETHTOOL_LINK_MODE_Autoneg_BIT);
+ ethtool_add_link_modes(&ksettings->link_modes.advertising,
+ ETHTOOL_LINK_MODE_Autoneg_BIT);
}
- cmd->autoneg = (priv->port_state.flags & MLX4_EN_PORT_ANC) ?
+ ksettings->parent.autoneg
+ = (priv->port_state.flags & MLX4_EN_PORT_ANC) ?
AUTONEG_ENABLE : AUTONEG_DISABLE;
eth_proto = be32_to_cpu(ptys_reg.eth_proto_lp_adv);
- cmd->lp_advertising = ptys2ethtool_link_modes(eth_proto, ADVERTISED);
- cmd->lp_advertising |= (priv->port_state.flags & MLX4_EN_PORT_ANC) ?
- ADVERTISED_Autoneg : 0;
+ ethtool_build_link_mode(&ksettings->link_modes.lp_advertising);
+ ptys2ethtool_update_link_modes(&ksettings->link_modes.lp_advertising,
+ eth_proto, ADVERTISED);
+ if (priv->port_state.flags & MLX4_EN_PORT_ANC)
+ ethtool_add_link_modes(&ksettings->link_modes.lp_advertising,
+ ETHTOOL_LINK_MODE_Autoneg_BIT);
- cmd->phy_address = 0;
- cmd->mdio_support = 0;
- cmd->maxtxpkt = 0;
- cmd->maxrxpkt = 0;
- cmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
- cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
+ ksettings->parent.phy_address = 0;
+ ksettings->parent.mdio_support = 0;
+ ksettings->parent.eth_tp_mdix = ETH_TP_MDI_INVALID;
+ ksettings->parent.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
return ret;
}
-static void ethtool_get_default_settings(struct net_device *dev,
- struct ethtool_cmd *cmd)
+static void ethtool_get_default_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *ksettings)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
int trans_type;
- cmd->autoneg = AUTONEG_DISABLE;
- cmd->supported = SUPPORTED_10000baseT_Full;
- cmd->advertising = ADVERTISED_10000baseT_Full;
+ ksettings->parent.autoneg = AUTONEG_DISABLE;
+ ethtool_build_link_mode(&ksettings->link_modes.supported,
+ ETHTOOL_LINK_MODE_10000baseT_Full_BIT);
+ ethtool_build_link_mode(&ksettings->link_modes.advertising,
+ ETHTOOL_LINK_MODE_10000baseT_Full_BIT);
trans_type = priv->port_state.transceiver;
if (trans_type > 0 && trans_type <= 0xC) {
- cmd->port = PORT_FIBRE;
- cmd->transceiver = XCVR_EXTERNAL;
- cmd->supported |= SUPPORTED_FIBRE;
- cmd->advertising |= ADVERTISED_FIBRE;
+ ksettings->parent.port = PORT_FIBRE;
+ ethtool_add_link_modes(&ksettings->link_modes.supported,
+ ETHTOOL_LINK_MODE_FIBRE_BIT);
+ ethtool_add_link_modes(&ksettings->link_modes.advertising,
+ ETHTOOL_LINK_MODE_FIBRE_BIT);
} else if (trans_type == 0x80 || trans_type == 0) {
- cmd->port = PORT_TP;
- cmd->transceiver = XCVR_INTERNAL;
- cmd->supported |= SUPPORTED_TP;
- cmd->advertising |= ADVERTISED_TP;
+ ksettings->parent.port = PORT_TP;
+ ethtool_add_link_modes(&ksettings->link_modes.supported,
+ ETHTOOL_LINK_MODE_TP_BIT);
+ ethtool_add_link_modes(&ksettings->link_modes.advertising,
+ ETHTOOL_LINK_MODE_TP_BIT);
} else {
- cmd->port = -1;
- cmd->transceiver = -1;
+ ksettings->parent.port = -1;
}
}
-static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int mlx4_en_get_ksettings(struct net_device *dev,
+ struct ethtool_ksettings *ksettings)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
int ret = -EINVAL;
@@ -709,16 +689,16 @@ static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
priv->port_state.flags & MLX4_EN_PORT_ANE);
if (priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL)
- ret = ethtool_get_ptys_settings(dev, cmd);
+ ret = ethtool_get_ptys_ksettings(dev, ksettings);
if (ret) /* ETH PROT CRTL is not supported or PTYS CMD failed */
- ethtool_get_default_settings(dev, cmd);
+ ethtool_get_default_ksettings(dev, ksettings);
if (netif_carrier_ok(dev)) {
- ethtool_cmd_speed_set(cmd, priv->port_state.link_speed);
- cmd->duplex = DUPLEX_FULL;
+ ksettings->parent.speed = priv->port_state.link_speed;
+ ksettings->parent.duplex = DUPLEX_FULL;
} else {
- ethtool_cmd_speed_set(cmd, SPEED_UNKNOWN);
- cmd->duplex = DUPLEX_UNKNOWN;
+ ksettings->parent.speed = SPEED_UNKNOWN;
+ ksettings->parent.duplex = DUPLEX_UNKNOWN;
}
return 0;
}
@@ -742,21 +722,33 @@ static __be32 speed_set_ptys_admin(struct mlx4_en_priv *priv, u32 speed,
return proto_admin;
}
-static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int mlx4_en_set_ksettings(struct net_device *dev,
+ const struct ethtool_ksettings *ksettings)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_ptys_reg ptys_reg;
__be32 proto_admin;
int ret;
- u32 ptys_adv = ethtool2ptys_link_modes(cmd->advertising, ADVERTISED);
- int speed = ethtool_cmd_speed(cmd);
+ u32 ptys_adv = ethtool2ptys_link_modes(
+ &ksettings->link_modes.advertising, ADVERTISED);
+ const int speed = ksettings->parent.speed;
+
+ if (en_dbg_enabled(DRV, priv)) {
+ char dbg_link_mode_buff[64];
- en_dbg(DRV, priv, "Set Speed=%d adv=0x%x autoneg=%d duplex=%d\n",
- speed, cmd->advertising, cmd->autoneg, cmd->duplex);
+ bitmap_scnprintf(dbg_link_mode_buff,
+ sizeof(dbg_link_mode_buff),
+ ksettings->link_modes.supported.mask,
+ __ETHTOOL_LINK_MODE_MASK_NBITS);
+ en_dbg(DRV, priv,
+ "Set Speed=%d adv={%s} autoneg=%d duplex=%d\n",
+ speed, dbg_link_mode_buff,
+ ksettings->parent.autoneg, ksettings->parent.duplex);
+ }
if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL) ||
- (cmd->duplex == DUPLEX_HALF))
+ (ksettings->parent.duplex == DUPLEX_HALF))
return -EINVAL;
memset(&ptys_reg, 0, sizeof(ptys_reg));
@@ -1822,8 +1814,8 @@ static int mlx4_en_get_module_eeprom(struct net_device *dev,
const struct ethtool_ops mlx4_en_ethtool_ops = {
.get_drvinfo = mlx4_en_get_drvinfo,
- .get_settings = mlx4_en_get_settings,
- .set_settings = mlx4_en_set_settings,
+ .get_ksettings = mlx4_en_get_ksettings,
+ .set_ksettings = mlx4_en_set_ksettings,
.get_link = ethtool_op_get_link,
.get_strings = mlx4_en_get_strings,
.get_sset_count = mlx4_en_get_sset_count,
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_main.c b/drivers/net/ethernet/mellanox/mlx4/en_main.c
index c643d2b..b435349 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_main.c
@@ -348,6 +348,7 @@ static void mlx4_en_verify_params(void)
static int __init mlx4_en_init(void)
{
mlx4_en_verify_params();
+ mlx4_en_init_ptys2ethtool_map();
return mlx4_register_interface(&mlx4_en_interface);
}
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 96bf728..609fc3e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -749,6 +749,7 @@ static inline bool mlx4_en_cq_busy_polling(struct mlx4_en_cq *cq)
#define MLX4_EN_WOL_DO_MODIFY (1ULL << 63)
+void mlx4_en_init_ptys2ethtool_map(void);
void mlx4_en_update_loopback_state(struct net_device *dev,
netdev_features_t features);
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply [flat|nested] 22+ messages in thread