Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1280338 > unrolled thread
| Started by | David Decotigny <ddecotig@gmail.com> |
|---|---|
| First post | 2015-11-30 23:10 +0100 |
| Last post | 2015-12-02 18:40 +0100 |
| Articles | 19 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH net-next v3 00/17] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 11/17] net: rdma: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 12/17] net: 8021q: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 14/17] net: core: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 13/17] net: bridge: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 01/17] net: usnic: remove unused call to ethtool_ops::get_settings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 08/17] net: macvlan: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 07/17] net: ipvlan: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:10 +0100
[PATCH net-next v3 02/17] net: usnic: use __ethtool_get_settings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:20 +0100
[PATCH net-next v3 05/17] net: usnic: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:20 +0100
[PATCH net-next v3 06/17] net: bonding: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:20 +0100
[PATCH net-next v3 10/17] net: fcoe: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:20 +0100
[PATCH net-next v3 04/17] tx4939: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:20 +0100
Re: [PATCH net-next v3 04/17] tx4939: use __ethtool_get_ksettings Ralf Baechle <ralf@linux-mips.org> - 2015-12-01 01:00 +0100
[PATCH net-next v3 09/17] net: team: use __ethtool_get_ksettings David Decotigny <ddecotig@gmail.com> - 2015-11-30 23:20 +0100
Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API Ben Hutchings <ben@decadent.org.uk> - 2015-12-01 03:00 +0100
Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API David Miller <davem@davemloft.net> - 2015-12-02 04:20 +0100
Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API David Decotigny <ddecotig@gmail.com> - 2015-12-02 07:10 +0100
Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API David Miller <davem@davemloft.net> - 2015-12-02 18:40 +0100
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 00/17] RFC: new ETHTOOL_GSETTINGS/SSETTINGS API |
| Message-ID | <qAENX-YF-3@gated-at.bofh.it> |
From: David Decotigny <decot@googlers.com>
History:
v3
- rebased v2 on top of latest net-next, minor checkpatch/printf %*pb
updates
v2
- keep return 0 in get_settings when successful, instead of
propagating positive result from driver's get_settings callback.
v1
- original submission
The main goal of this series is to support ethtool link mode masks
larger than 32 bits. It implements a new ioctl pair
(ETHTOOL_GSETTINGS/SSETTINGS), its associated callbacks
(get/set_settings) and a new struct ethtool_settings, which should
eventually replace legacy ethtool_cmd. Internally, the kernel uses
fixed length link mode masks defined at compilation time in ethtool.h
(for now: 31 bits), that can be increased by changing
__ETHTOOL_LINK_MODE_LAST in ethtool.h (absolute max is 4064 bits,
checked at compile time), and the user/kernel interface allows this
length to be arbitrary within 1..4064. This should allow some
flexibility without using too much malloc/stack space, at the cost of
a small kernel/user handshake for the user to determine the sizes of
those bitmaps.
Along the way, I chose to drop in the new structure the 3 ethtool_cmd
fields marked "deprecated" (transceiver/maxrxpkt/maxtxpkt). They are
still available for old drivers via the old ETHTOOL_GSET/SSET API, but
are not available to drivers that switch to new API. Of those 3
fields, ethtool_cmd::transceiver seems to be still actively used by
several drivers, maybe we should not consider this field deprecated?
The 2 other fields are basically not used. This transition requires
some care in the way old and new ethtool talk to the kernel.
More technical details provided in the description for main patch. In
particular details about backward compatibility properties.
Some questions to more experts than me:
- the kernel/interface multiplexes the "tell me the bitmap length"
handshake and the "give me the settings" inside the new
ETHTOOL_GSETTINGS cmd. I was thinking of making this into 2
separate cmds: 1 cmd ETHTOOL_GKERNELPROPERTIES which would be
kernel-wide rather than device-specific, would return properties
like "length of the link mode bitmaps", and possibly others. And
ETHTOOL_GSETTINGS would expect the proper bitmaps
- the link mode bitmaps are piggybacked at tail of the new struct
ethtool_settings. Since its user-visible definition does not assume
specific bitmap width, I am using a 0-length array as the publicly
visible placeholder. But then, the kernel needs to specialize it
(struct ethtool_ksettings) to specify its current link mode
masks. This means that kernel code is "littered" with
"ksettings->parent.field" to access "field" inside
ethtool_settings:
+ I don't like the field name "parent", any suggestion welcome
+ and/or: I could use ethtool_settings everywhere (instead of a new
ethtool_ksettings) and an accessor to retrieve the link mode
masks?
+ or: we could decide to make the link mode masks statically
bounded again, ie. make their width public, but larger than
current 32, and unchangeable forever. This would make everything
straightforward, but we might hit limits later, or have an
unneeded memory/stack usage for unused bits.
any preference?
- crossing user/kernel boundary requires conversion of the kernel
bitmaps (unsigned long[]) to something more strict (in my case:
u32) to accomodate for 32/64 compat. Maybe I should add a
copy_bitmap_from_user/copy_bitmap_to_user API inside bitmap.h
instead of defining my own in ethtool.c?
- I am using a typedef struct (ethtool_link_mode_mask_t) to build and
hold the new masks. Makes it handy to use in the drivers (see mlx4
for an example). Not very nice.
- I foresee bugs where people use the legacy/deprecated SUPPORTED_x
macros instead of the new ETHTOOL_LINK_MODE_x_BIT enums in the new
get/set__ksettings callbacks. Not sure how to prevent problems with
this.
The only driver which was converted for now is mlx4. I am not
considering fcoe as fully converted, but I updated it a minima to be
able to remove __ethtool_get_settings, now known as
__ethtool_get_ksettings.
Tested with legacy and "future" ethtool on 64b x86 kernel and 32+64b
ethtool, and on a 32b x86 kernel + 32b ethtool.
############################################
# Patch Set Summary:
David Decotigny (17):
net: usnic: remove unused call to ethtool_ops::get_settings
net: usnic: use __ethtool_get_settings
net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API
tx4939: use __ethtool_get_ksettings
net: usnic: use __ethtool_get_ksettings
net: bonding: use __ethtool_get_ksettings
net: ipvlan: use __ethtool_get_ksettings
net: macvlan: use __ethtool_get_ksettings
net: team: use __ethtool_get_ksettings
net: fcoe: use __ethtool_get_ksettings
net: rdma: use __ethtool_get_ksettings
net: 8021q: use __ethtool_get_ksettings
net: bridge: use __ethtool_get_ksettings
net: core: use __ethtool_get_ksettings
net: ethtool: remove unused __ethtool_get_settings
net: mlx4: convenience predicate for debug messages
net: mlx4: use new ETHTOOL_G/SSETTINGS API
arch/mips/txx9/generic/setup_tx4939.c | 7 +-
drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 10 +-
drivers/net/bonding/bond_main.c | 14 +-
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 323 ++++++++--------
drivers/net/ethernet/mellanox/mlx4/en_main.c | 1 +
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 5 +-
drivers/net/ipvlan/ipvlan_main.c | 8 +-
drivers/net/macvlan.c | 8 +-
drivers/net/team/team.c | 8 +-
drivers/scsi/fcoe/fcoe_transport.c | 36 +-
include/linux/ethtool.h | 97 ++++-
include/rdma/ib_addr.h | 14 +-
include/uapi/linux/ethtool.h | 323 ++++++++++++----
net/8021q/vlan_dev.c | 8 +-
net/bridge/br_if.c | 6 +-
net/core/ethtool.c | 478 +++++++++++++++++++++++-
net/core/net-sysfs.c | 15 +-
net/packet/af_packet.c | 11 +-
18 files changed, 1046 insertions(+), 326 deletions(-)
--
2.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 11/17] net: rdma: use __ethtool_get_ksettings |
| Message-ID | <qAENY-YF-19@gated-at.bofh.it> |
| In reply to | #1280338 |
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 1152859..1820f26 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -254,24 +254,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 12/17] net: 8021q: use __ethtool_get_ksettings |
| Message-ID | <qAENY-YF-17@gated-at.bofh.it> |
| In reply to | #1280338 |
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 fded865..e607fee 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -620,12 +620,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,
@@ -740,7 +740,7 @@ static int vlan_dev_get_iflink(const struct net_device *dev)
}
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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 14/17] net: core: use __ethtool_get_ksettings |
| Message-ID | <qAENY-YF-21@gated-at.bofh.it> |
| In reply to | #1280338 |
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 f88a62a..3dd4bb1 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -199,9 +199,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_dec, ethtool_cmd_speed(&cmd));
+ struct ethtool_ksettings cmd;
+
+ if (!__ethtool_get_ksettings(netdev, &cmd))
+ ret = sprintf(buf, fmt_dec, cmd.parent.speed);
}
rtnl_unlock();
return ret;
@@ -218,10 +219,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 1cf928f..8847dad 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -557,9 +557,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);
@@ -567,19 +566,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 13/17] net: bridge: use __ethtool_get_ksettings |
| Message-ID | <qAENY-YF-23@gated-at.bofh.it> |
| In reply to | #1280338 |
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 ec02f58..e6de008 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -36,10 +36,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 01/17] net: usnic: remove unused call to ethtool_ops::get_settings |
| Message-ID | <qAENY-YF-33@gated-at.bofh.it> |
| In reply to | #1280338 |
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 f8e3211..5b60579 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -269,7 +269,6 @@ 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");
@@ -278,7 +277,6 @@ int usnic_ib_query_device(struct ib_device *ibdev,
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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 08/17] net: macvlan: use __ethtool_get_ksettings |
| Message-ID | <qAENY-YF-29@gated-at.bofh.it> |
| In reply to | #1280338 |
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 06c8bfe..a95b793 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -940,12 +940,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,
@@ -1020,7 +1020,7 @@ static int macvlan_dev_get_iflink(const 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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:10 +0100 |
| Subject | [PATCH net-next v3 07/17] net: ipvlan: use __ethtool_get_ksettings |
| Message-ID | <qAENY-YF-31@gated-at.bofh.it> |
| In reply to | #1280338 |
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 a9268db..63b3aa5 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -346,12 +346,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,
@@ -377,7 +377,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:20 +0100 |
| Subject | [PATCH net-next v3 02/17] net: usnic: use __ethtool_get_settings |
| Message-ID | <qAEXD-11R-5@gated-at.bofh.it> |
| In reply to | #1280338 |
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 5b60579..e082170 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -329,7 +329,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:20 +0100 |
| Subject | [PATCH net-next v3 05/17] net: usnic: use __ethtool_get_ksettings |
| Message-ID | <qAEXE-11R-25@gated-at.bofh.it> |
| In reply to | #1280338 |
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 e082170..e0d12d4 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
@@ -324,12 +324,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;
@@ -353,8 +353,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:20 +0100 |
| Subject | [PATCH net-next v3 06/17] net: bonding: use __ethtool_get_ksettings |
| Message-ID | <qAEXE-11R-21@gated-at.bofh.it> |
| In reply to | #1280338 |
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 9e0f8a7..67d724d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -374,22 +374,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;
@@ -397,8 +395,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:20 +0100 |
| Subject | [PATCH net-next v3 10/17] net: fcoe: use __ethtool_get_ksettings |
| Message-ID | <qAEXE-11R-29@gated-at.bofh.it> |
| In reply to | #1280338 |
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 d7597c0..9049197 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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:20 +0100 |
| Subject | [PATCH net-next v3 04/17] tx4939: use __ethtool_get_ksettings |
| Message-ID | <qAEXE-11R-31@gated-at.bofh.it> |
| In reply to | #1280338 |
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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ralf Baechle <ralf@linux-mips.org> |
|---|---|
| Date | 2015-12-01 01:00 +0100 |
| Subject | Re: [PATCH net-next v3 04/17] tx4939: use __ethtool_get_ksettings |
| Message-ID | <qAGwq-1UV-17@gated-at.bofh.it> |
| In reply to | #1280358 |
On Mon, Nov 30, 2015 at 02:05:42PM -0800, David Decotigny wrote: Acked-by: Ralf Baechle <ralf@linux-mips.org> Ralf -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-11-30 23:20 +0100 |
| Subject | [PATCH net-next v3 09/17] net: team: use __ethtool_get_ksettings |
| Message-ID | <qAEXE-11R-15@gated-at.bofh.it> |
| In reply to | #1280338 |
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 651d35e..288ca01 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2776,12 +2776,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.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-01 03:00 +0100 |
| Subject | Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API |
| Message-ID | <qAIox-360-7@gated-at.bofh.it> |
| In reply to | #1280338 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, 2015-11-30 at 14:05 -0800, David Decotigny wrote:
> 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).
As you have to introduce new commands and a new structure, please
include the word 'link' in their names.
[...]
> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
> index 653dc9c..6de122d 100644
> --- a/include/linux/ethtool.h
> +++ b/include/linux/ethtool.h
> @@ -12,6 +12,7 @@
> #ifndef _LINUX_ETHTOOL_H
> #define _LINUX_ETHTOOL_H
>
> +#include
> #include
> #include
>
> @@ -40,9 +41,6 @@ struct compat_ethtool_rxnfc {
>
> #include
>
> -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,85 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
> return index % n_rx_rings;
> }
>
> +#define __ETHTOOL_LINK_MODE_IS_VALID_BIT(indice) \
> + ((indice) >= 0 && (indice) <= __ETHTOOL_LINK_MODE_LAST)
'indice'? Shoudn't this be 'index' or 'mode'?
>
> +/* number of link mode bits handled internally by kernel */
> +#define __ETHTOOL_LINK_MODE_MASK_NBITS (__ETHTOOL_LINK_MODE_LAST+1)
Spaces around the + sign.
>
> +typedef struct {
> + unsigned long mask[BITS_TO_LONGS(__ETHTOOL_LINK_MODE_MASK_NBITS)];
> +} ethtool_link_mode_mask_t;
checkpatch claims you shouldn't introduce such typedefs.
[...]
>
> +/**
> + * struct ethtool_settings - link control and status
> + * This structure deprecates struct %ethtool_cmd.
We do the deprecating; the structures are purely passive.
[...]
>
> + * Deprecated fields should be ignored by both users and drivers.
Delete this last paragraph.
[...]
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -352,6 +352,388 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
> return 0;
> }
>
> +/* TODO: remove when %ETHTOOL_GSET/%ETHTOOL_SSET disappear */
Please delete this TODO and all the similar ones; we don't remove
userland APIs just because they're deprecated.
[...]
>
> +/* 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)
Should use DIV_ROUND_UP().
>
> +/* 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);
Why __aligned(4)? Do you have any reason to think that some padding
might be added otherwise?
[...]
> +#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));
This memset() looks redundant.
> + 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;
> +}
I think the array conversion ought to be a separate function that you
can call 3 times here, rather than repeating it here. In fact that
could be a general function in lib/bitmap.c.
Similarly for the opposite conversion below.
[...]
> 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 */
> + int err;
> + 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");
ethtool isn't the only program that uses this API, not by a long way.
And since it's the program at fault, not the device, it doesn't make a
lot of sense to use netdev_warn().
So I suggest a message more like that in warn_legacy_capability_use()
in kernel/capability.c.
[...]
> 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");
I don't think this makes sense - it's not as if ethtool will
automatically try to set these without it being explicitly requested by
the user. Just return -EINVAL without logging anything.
> + __warned = 1;
> + return -EINVAL;
> + }
[...]
Ben.
--
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilers
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-12-02 04:20 +0100 |
| Subject | Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API |
| Message-ID | <qB67v-1EX-1@gated-at.bofh.it> |
| In reply to | #1280338 |
From: David Decotigny <ddecotig@gmail.com> Date: Mon, 30 Nov 2015 14:05:41 -0800 > 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). Please do not define the mask using a non-fixed type. I know it makes it easier to use the various bitmap helper routines if you use 'long', but here it is clearly superior to use "u32" for the bitmap type and do the bit operations by hand if necessary. Otherwise you have to have all of this ulong size CPP conditional code which is incredibly ugly. Furthermore you have to use fixed sized types anyways so that we don't need compat code to deal with 32-bit userspace applications making these ethtool calls into a 64-bit kernel. THanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Decotigny <ddecotig@gmail.com> |
|---|---|
| Date | 2015-12-02 07:10 +0100 |
| Subject | Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API |
| Message-ID | <qB8M1-3nY-11@gated-at.bofh.it> |
| In reply to | #1281430 |
Hello,
There is a set of conversion routines ulong[]<->u32[] to address this
32/64-bit compat issue. Using a u32-based bitmap would require drivers
to handle the u32 bitmaps themselves, this might be confusing,
considering there is a standard bitmap api; and might be error-prone
as well. Plus there is %*pb[l] format that's very helpful for
debugging. That's why I preferred to handle the relative complexity of
u32 bitmaps with the CPP conditionals in the non-driver code that
handles the user/kernel interactions, and drivers can use the standard
bitmap api transparently.
I was currently moving/rewriting the u32/ulong conversion code to
bitmap.{c,h} as Ben Hutchings was suggesting, which should hopefully
make the code more digestible; and could possibly be used for other
user/kernel interfaces. How about I send an updated version with this
solution, and if it's still not right, I'll revisit with either u32[]
everywhere or fixed-size bitmap instead of variable-size as here? Or
maybe another option would be to implement a new u32[]
bitmap_u32.{c,h} api, possibly using a set of macro tricks to share
code with bitmap.{c,h}?
On Tue, Dec 1, 2015 at 7:13 PM, David Miller <davem@davemloft.net> wrote:
> From: David Decotigny <ddecotig@gmail.com>
> Date: Mon, 30 Nov 2015 14:05:41 -0800
>
>> 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).
>
> Please do not define the mask using a non-fixed type. I know it makes
> it easier to use the various bitmap helper routines if you use 'long',
> but here it is clearly superior to use "u32" for the bitmap type and
> do the bit operations by hand if necessary.
>
> Otherwise you have to have all of this ulong size CPP conditional code
> which is incredibly ugly.
>
> Furthermore you have to use fixed sized types anyways so that we don't
> need compat code to deal with 32-bit userspace applications making
> these ethtool calls into a 64-bit kernel.
>
> THanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-12-02 18:40 +0100 |
| Subject | Re: [PATCH net-next v3 03/17] net: ethtool: add new ETHTOOL_GSETTINGS/SSETTINGS API |
| Message-ID | <qBjxM-1Sz-13@gated-at.bofh.it> |
| In reply to | #1281468 |
From: David Decotigny <ddecotig@gmail.com> Date: Tue, 1 Dec 2015 22:00:58 -0800 > There is a set of conversion routines ulong[]<->u32[] to address this > 32/64-bit compat issue. And it's extremely ugly. There is nothing stopping you from adding bitmap_set32() et al. helpers to facilitate things. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web