From: Ben Hutchings <bhutchings@solarflare.com>
To: David Decotigny <decot@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
mirq-linux@rere.qmqm.pl, Stanislaw Gruszka <sgruszka@redhat.com>,
Alexander Duyck <alexander.h.duyck@intel.com>,
Eilon Greenstein <eilong@broadcom.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCHv2 4/4] ethtool: cosmetic: Use ethtool ethtool_cmd_speed API
Date: Wed, 27 Apr 2011 20:43:50 +0100 [thread overview]
Message-ID: <1303933430.2875.145.camel@bwh-desktop> (raw)
In-Reply-To: <1303929290-21037-5-git-send-email-decot@google.com>
On Wed, 2011-04-27 at 11:34 -0700, David Decotigny wrote:
> This updates the network drivers so that they don't access the
> ethtool_cmd::speed field directly, but use ethtoo_cmd_speed() instead.
>
> For most of the drivers, these changes are purely cosmetic and don't
> fix any problem, such as for those 1GbE/10GbE drivers that indirectly
> call their own ethtool get_settings()/mii_ethtool_gset(). The changes
> are meant to enforce code consistency and provide robustness with
> future larger throughputs, at the expense of a few CPU cycles for each
> ethtool operation.
>
> All the drivers compiled with make allyesconfig ion x86_64 have been
> updated.
>
> Tested: make allyesconfig on x86_64 + e1000e/bnx2x work
> Signed-off-by: David Decotigny <decot@google.com>
[...]
> --- a/drivers/net/mdio.c
> +++ b/drivers/net/mdio.c
> @@ -290,33 +290,36 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
> if (modes & (ADVERTISED_10000baseT_Full |
> ADVERTISED_10000baseKX4_Full |
> ADVERTISED_10000baseKR_Full)) {
> - ecmd->speed = SPEED_10000;
> + ethtool_cmd_speed_set(ecmd, SPEED_10000);
> ecmd->duplex = DUPLEX_FULL;
> } else if (modes & (ADVERTISED_1000baseT_Full |
> ADVERTISED_1000baseT_Half |
> ADVERTISED_1000baseKX_Full)) {
> - ecmd->speed = SPEED_1000;
> + ethtool_cmd_speed_set(ecmd, SPEED_1000);
> ecmd->duplex = !(modes & ADVERTISED_1000baseT_Half);
> } else if (modes & (ADVERTISED_100baseT_Full |
> ADVERTISED_100baseT_Half)) {
> - ecmd->speed = SPEED_100;
> + ethtool_cmd_speed_set(ecmd, SPEED_100);
> ecmd->duplex = !!(modes & ADVERTISED_100baseT_Full);
> } else {
> - ecmd->speed = SPEED_10;
> + ethtool_cmd_speed_set(ecmd, SPEED_10);
> ecmd->duplex = !!(modes & ADVERTISED_10baseT_Full);
> }
> } else {
> /* Report forced settings */
> + u32 speed;
> reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
> MDIO_CTRL1);
> - ecmd->speed = (((reg & MDIO_PMA_CTRL1_SPEED1000) ? 100 : 1) *
> - ((reg & MDIO_PMA_CTRL1_SPEED100) ? 100 : 10));
> + speed = (((reg & MDIO_PMA_CTRL1_SPEED1000) ? 100 : 1)
> + * ((reg & MDIO_PMA_CTRL1_SPEED100) ? 100 : 10));
> ecmd->duplex = (reg & MDIO_CTRL1_FULLDPLX ||
> - ecmd->speed == SPEED_10000);
> + speed == SPEED_10000);
> + ethtool_cmd_speed_set(ecmd, speed);
> }
>
> /* 10GBASE-T MDI/MDI-X */
> - if (ecmd->port == PORT_TP && ecmd->speed == SPEED_10000) {
> + if (ecmd->port == PORT_TP
> + && (ethtool_cmd_speed(ecmd) == SPEED_10000)) {
> switch (mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
> MDIO_PMA_10GBT_SWAPPOL)) {
> case MDIO_PMA_10GBT_SWAPPOL_ABNX | MDIO_PMA_10GBT_SWAPPOL_CDNX:
It seems like the scope of speed should be the whole function. Then you
could just have one call to ethtool_cmd_speed_set() after the
'if (ecmd->autoneg) ... else ...' statement, and no need to use
ethtool_cmd_speed().
[...]
> --- a/drivers/net/tulip/de2104x.c
> +++ b/drivers/net/tulip/de2104x.c
> @@ -1518,15 +1518,15 @@ static int __de_get_settings(struct de_private *de, struct ethtool_cmd *ecmd)
> switch (de->media_type) {
> case DE_MEDIA_AUI:
> ecmd->port = PORT_AUI;
> - ecmd->speed = 5;
> + ethtool_cmd_speed_set(ecmd, 5);
> break;
> case DE_MEDIA_BNC:
> ecmd->port = PORT_BNC;
> - ecmd->speed = 2;
> + ethtool_cmd_speed_set(ecmd, 2);
> break;
> default:
> ecmd->port = PORT_TP;
> - ecmd->speed = SPEED_10;
> + ethtool_cmd_speed_set(ecmd, SPEED_10);
> break;
> }
[...]
As I commented on the previous patch, this should always report a speed
of 10.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
prev parent reply other threads:[~2011-04-27 19:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-17 0:54 [PATCH 1/5] ethtool: cosmetics: enforce const-ness in ethtool_cmd_speed David Decotigny
2011-04-17 0:54 ` [PATCH 2/5] bnx2x: cosmetics: Using ethtool_cmd_speed() API David Decotigny
2011-04-17 0:54 ` [PATCH 3/5] ethtool: Call ethtool's get/set_settings callbacks with cleaned data David Decotigny
2011-04-17 0:54 ` [PATCH 4/5] ethtool: Use the full 32 bit speed range in ethtool's set_settings David Decotigny
2011-04-17 2:02 ` Ben Hutchings
2011-04-17 0:54 ` [PATCH 5/5] ethtool: cosmetic: Use the ethtool speed_cmd_speed API David Decotigny
[not found] ` <1303001651-4074-3-git-send-email-decot@google.com>
2011-04-17 1:53 ` [PATCH 3/5] ethtool: Call ethtool's get/set_settings callbacks with cleaned data Ben Hutchings
2011-04-17 2:06 ` [PATCH 1/5] ethtool: cosmetics: enforce const-ness in ethtool_cmd_speed Ben Hutchings
2011-04-27 18:34 ` [PATCHv2 0/4] ethtool: generalize use of ethtool_cmd_speed API David Decotigny
2011-04-27 18:34 ` [PATCHv2 1/4] ethtool: cosmetics: enforce const-ness in ethtool_cmd_speed David Decotigny
2011-04-27 18:34 ` [PATCHv2 2/4] ethtool: Call ethtool's get/set_settings callbacks with cleaned data David Decotigny
2011-04-27 18:34 ` [PATCHv2 3/4] ethtool: Use the full 32 bit speed range in ethtool's set_settings David Decotigny
2011-04-27 19:27 ` Ben Hutchings
2011-04-27 22:05 ` David Decotigny
2011-04-27 23:10 ` Ben Hutchings
2011-04-27 22:23 ` Stephen Hemminger
2011-04-27 18:34 ` [PATCHv2 4/4] ethtool: cosmetic: Use ethtool ethtool_cmd_speed API David Decotigny
2011-04-27 18:34 ` [PATCHv2] acenic: Fix using the specified speed when configuring NIC David Decotigny
[not found] ` <1303929290-21037-2-git-send-email-decot@google.com>
2011-04-27 18:41 ` [PATCHv2 1/4] ethtool: cosmetics: enforce const-ness in ethtool_cmd_speed Ben Hutchings
[not found] ` <1303929290-21037-3-git-send-email-decot@google.com>
2011-04-27 18:53 ` [PATCHv2 2/4] ethtool: Call ethtool's get/set_settings callbacks with cleaned data Ben Hutchings
[not found] ` <1303929290-21037-5-git-send-email-decot@google.com>
2011-04-27 19:43 ` Ben Hutchings [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303933430.2875.145.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=decot@google.com \
--cc=eilong@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).