From: Alan Brady <alan.brady@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v3 01/14 net-next] i40e: rename 'cmd' variables in ethtool interface
Date: Thu, 5 Oct 2017 14:53:31 -0700 [thread overview]
Message-ID: <20171005215344.2886-2-alan.brady@intel.com> (raw)
In-Reply-To: <20171005215344.2886-1-alan.brady@intel.com>
After the switch to the new ethtool API, ethtool passes us
ethtool_ksettings structs instead of ethtool_command structs, however we
were still referring to them as 'cmd' variables. This renames them to
'ks' variables which makes the code easier to understand.
Signed-off-by: Alan Brady <alan.brady@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 139 +++++++++++++------------
1 file changed, 70 insertions(+), 69 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 72d5f2cdf419..4ed5deab7e68 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -378,12 +378,12 @@ static void i40e_phy_type_to_ethtool(struct i40e_pf *pf, u32 *supported,
/**
* i40e_get_settings_link_up - Get the Link settings for when link is up
* @hw: hw structure
- * @ecmd: ethtool command to fill in
+ * @ks: ethtool ksettings to fill in
* @netdev: network interface device structure
- *
+ * @pf: pointer to physical function struct
**/
static void i40e_get_settings_link_up(struct i40e_hw *hw,
- struct ethtool_link_ksettings *cmd,
+ struct ethtool_link_ksettings *ks,
struct net_device *netdev,
struct i40e_pf *pf)
{
@@ -394,9 +394,9 @@ static void i40e_get_settings_link_up(struct i40e_hw *hw,
u32 supported, advertising;
ethtool_convert_link_mode_to_legacy_u32(&supported,
- cmd->link_modes.supported);
+ ks->link_modes.supported);
ethtool_convert_link_mode_to_legacy_u32(&advertising,
- cmd->link_modes.advertising);
+ ks->link_modes.advertising);
/* Initialize supported and advertised settings based on phy settings */
switch (hw_link_info->phy_type) {
@@ -528,48 +528,49 @@ static void i40e_get_settings_link_up(struct i40e_hw *hw,
/* Set speed and duplex */
switch (link_speed) {
case I40E_LINK_SPEED_40GB:
- cmd->base.speed = SPEED_40000;
+ ks->base.speed = SPEED_40000;
break;
case I40E_LINK_SPEED_25GB:
#ifdef SPEED_25000
- cmd->base.speed = SPEED_25000;
+ ks->base.speed = SPEED_25000;
#else
netdev_info(netdev,
"Speed is 25G, display not supported by this version of ethtool.\n");
#endif
break;
case I40E_LINK_SPEED_20GB:
- cmd->base.speed = SPEED_20000;
+ ks->base.speed = SPEED_20000;
break;
case I40E_LINK_SPEED_10GB:
- cmd->base.speed = SPEED_10000;
+ ks->base.speed = SPEED_10000;
break;
case I40E_LINK_SPEED_1GB:
- cmd->base.speed = SPEED_1000;
+ ks->base.speed = SPEED_1000;
break;
case I40E_LINK_SPEED_100MB:
- cmd->base.speed = SPEED_100;
+ ks->base.speed = SPEED_100;
break;
default:
break;
}
- cmd->base.duplex = DUPLEX_FULL;
+ ks->base.duplex = DUPLEX_FULL;
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+ ethtool_convert_legacy_u32_to_link_mode(ks->link_modes.supported,
supported);
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+ ethtool_convert_legacy_u32_to_link_mode(ks->link_modes.advertising,
advertising);
}
/**
* i40e_get_settings_link_down - Get the Link settings for when link is down
* @hw: hw structure
- * @ecmd: ethtool command to fill in
+ * @ks: ethtool ksettings to fill in
+ * @pf: pointer to physical function struct
*
* Reports link settings that can be determined when link is down
**/
static void i40e_get_settings_link_down(struct i40e_hw *hw,
- struct ethtool_link_ksettings *cmd,
+ struct ethtool_link_ksettings *ks,
struct i40e_pf *pf)
{
u32 supported, advertising;
@@ -579,25 +580,25 @@ static void i40e_get_settings_link_down(struct i40e_hw *hw,
*/
i40e_phy_type_to_ethtool(pf, &supported, &advertising);
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
+ ethtool_convert_legacy_u32_to_link_mode(ks->link_modes.supported,
supported);
- ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
+ ethtool_convert_legacy_u32_to_link_mode(ks->link_modes.advertising,
advertising);
/* With no link speed and duplex are unknown */
- cmd->base.speed = SPEED_UNKNOWN;
- cmd->base.duplex = DUPLEX_UNKNOWN;
+ ks->base.speed = SPEED_UNKNOWN;
+ ks->base.duplex = DUPLEX_UNKNOWN;
}
/**
- * i40e_get_settings - Get Link Speed and Duplex settings
+ * i40e_get_link_ksettings - Get Link Speed and Duplex settings
* @netdev: network interface device structure
- * @ecmd: ethtool command
+ * @ks: ethtool ksettings
*
* Reports speed/duplex settings based on media_type
**/
static int i40e_get_link_ksettings(struct net_device *netdev,
- struct ethtool_link_ksettings *cmd)
+ struct ethtool_link_ksettings *ks)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_pf *pf = np->vsi->back;
@@ -607,74 +608,74 @@ static int i40e_get_link_ksettings(struct net_device *netdev,
u32 advertising;
if (link_up)
- i40e_get_settings_link_up(hw, cmd, netdev, pf);
+ i40e_get_settings_link_up(hw, ks, netdev, pf);
else
- i40e_get_settings_link_down(hw, cmd, pf);
+ i40e_get_settings_link_down(hw, ks, pf);
/* Now set the settings that don't rely on link being up/down */
/* Set autoneg settings */
- cmd->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
- AUTONEG_ENABLE : AUTONEG_DISABLE);
+ ks->base.autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ?
+ AUTONEG_ENABLE : AUTONEG_DISABLE);
switch (hw->phy.media_type) {
case I40E_MEDIA_TYPE_BACKPLANE:
- ethtool_link_ksettings_add_link_mode(cmd, supported,
+ ethtool_link_ksettings_add_link_mode(ks, supported,
Autoneg);
- ethtool_link_ksettings_add_link_mode(cmd, supported,
+ ethtool_link_ksettings_add_link_mode(ks, supported,
Backplane);
- ethtool_link_ksettings_add_link_mode(cmd, advertising,
+ ethtool_link_ksettings_add_link_mode(ks, advertising,
Autoneg);
- ethtool_link_ksettings_add_link_mode(cmd, advertising,
+ ethtool_link_ksettings_add_link_mode(ks, advertising,
Backplane);
- cmd->base.port = PORT_NONE;
+ ks->base.port = PORT_NONE;
break;
case I40E_MEDIA_TYPE_BASET:
- ethtool_link_ksettings_add_link_mode(cmd, supported, TP);
- ethtool_link_ksettings_add_link_mode(cmd, advertising, TP);
- cmd->base.port = PORT_TP;
+ ethtool_link_ksettings_add_link_mode(ks, supported, TP);
+ ethtool_link_ksettings_add_link_mode(ks, advertising, TP);
+ ks->base.port = PORT_TP;
break;
case I40E_MEDIA_TYPE_DA:
case I40E_MEDIA_TYPE_CX4:
- ethtool_link_ksettings_add_link_mode(cmd, supported, FIBRE);
- ethtool_link_ksettings_add_link_mode(cmd, advertising, FIBRE);
- cmd->base.port = PORT_DA;
+ ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
+ ethtool_link_ksettings_add_link_mode(ks, advertising, FIBRE);
+ ks->base.port = PORT_DA;
break;
case I40E_MEDIA_TYPE_FIBER:
- ethtool_link_ksettings_add_link_mode(cmd, supported, FIBRE);
- cmd->base.port = PORT_FIBRE;
+ ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
+ ks->base.port = PORT_FIBRE;
break;
case I40E_MEDIA_TYPE_UNKNOWN:
default:
- cmd->base.port = PORT_OTHER;
+ ks->base.port = PORT_OTHER;
break;
}
/* Set flow control settings */
- ethtool_link_ksettings_add_link_mode(cmd, supported, Pause);
+ ethtool_link_ksettings_add_link_mode(ks, supported, Pause);
switch (hw->fc.requested_mode) {
case I40E_FC_FULL:
- ethtool_link_ksettings_add_link_mode(cmd, advertising,
+ ethtool_link_ksettings_add_link_mode(ks, advertising,
Pause);
break;
case I40E_FC_TX_PAUSE:
- ethtool_link_ksettings_add_link_mode(cmd, advertising,
+ ethtool_link_ksettings_add_link_mode(ks, advertising,
Asym_Pause);
break;
case I40E_FC_RX_PAUSE:
- ethtool_link_ksettings_add_link_mode(cmd, advertising,
+ ethtool_link_ksettings_add_link_mode(ks, advertising,
Pause);
- ethtool_link_ksettings_add_link_mode(cmd, advertising,
+ ethtool_link_ksettings_add_link_mode(ks, advertising,
Asym_Pause);
break;
default:
ethtool_convert_link_mode_to_legacy_u32(
- &advertising, cmd->link_modes.advertising);
+ &advertising, ks->link_modes.advertising);
advertising &= ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause);
ethtool_convert_legacy_u32_to_link_mode(
- cmd->link_modes.advertising, advertising);
+ ks->link_modes.advertising, advertising);
break;
}
@@ -682,14 +683,14 @@ static int i40e_get_link_ksettings(struct net_device *netdev,
}
/**
- * i40e_set_settings - Set Speed and Duplex
+ * i40e_set_link_ksettings - Set Speed and Duplex
* @netdev: network interface device structure
- * @ecmd: ethtool command
+ * @ks: ethtool ksettings
*
* Set speed/duplex per media_types advertised/forced
**/
static int i40e_set_link_ksettings(struct net_device *netdev,
- const struct ethtool_link_ksettings *cmd)
+ const struct ethtool_link_ksettings *ks)
{
struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_aq_get_phy_abilities_resp abilities;
@@ -697,8 +698,8 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
struct i40e_pf *pf = np->vsi->back;
struct i40e_vsi *vsi = np->vsi;
struct i40e_hw *hw = &pf->hw;
- struct ethtool_link_ksettings safe_cmd;
- struct ethtool_link_ksettings copy_cmd;
+ struct ethtool_link_ksettings safe_ks;
+ struct ethtool_link_ksettings copy_ks;
i40e_status status = 0;
bool change = false;
int timeout = 50;
@@ -733,31 +734,31 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
return -EOPNOTSUPP;
}
- /* copy the cmd to copy_cmd to avoid modifying the origin */
- memcpy(©_cmd, cmd, sizeof(struct ethtool_link_ksettings));
+ /* copy the ksettings to copy_ks to avoid modifying the origin */
+ memcpy(©_ks, ks, sizeof(struct ethtool_link_ksettings));
/* get our own copy of the bits to check against */
- memset(&safe_cmd, 0, sizeof(struct ethtool_link_ksettings));
- i40e_get_link_ksettings(netdev, &safe_cmd);
+ memset(&safe_ks, 0, sizeof(struct ethtool_link_ksettings));
+ i40e_get_link_ksettings(netdev, &safe_ks);
- /* save autoneg and speed out of cmd */
- autoneg = cmd->base.autoneg;
+ /* save autoneg and speed out of ksettings */
+ autoneg = ks->base.autoneg;
ethtool_convert_link_mode_to_legacy_u32(&advertise,
- cmd->link_modes.advertising);
+ ks->link_modes.advertising);
/* set autoneg and speed back to what they currently are */
- copy_cmd.base.autoneg = safe_cmd.base.autoneg;
+ copy_ks.base.autoneg = safe_ks.base.autoneg;
ethtool_convert_link_mode_to_legacy_u32(
- &tmp, safe_cmd.link_modes.advertising);
+ &tmp, safe_ks.link_modes.advertising);
ethtool_convert_legacy_u32_to_link_mode(
- copy_cmd.link_modes.advertising, tmp);
+ copy_ks.link_modes.advertising, tmp);
- copy_cmd.base.cmd = safe_cmd.base.cmd;
+ copy_ks.base.cmd = safe_ks.base.cmd;
- /* If copy_cmd and safe_cmd are not the same now, then they are
+ /* If copy_ks and safe_ks are not the same now, then they are
* trying to set something that we do not support
*/
- if (memcmp(©_cmd, &safe_cmd, sizeof(struct ethtool_link_ksettings)))
+ if (memcmp(©_ks, &safe_ks, sizeof(struct ethtool_link_ksettings)))
return -EOPNOTSUPP;
while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) {
@@ -787,7 +788,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) {
/* If autoneg is not supported, return error */
if (!ethtool_link_ksettings_test_link_mode(
- &safe_cmd, supported, Autoneg)) {
+ &safe_ks, supported, Autoneg)) {
netdev_info(netdev, "Autoneg not supported on this phy\n");
err = -EINVAL;
goto done;
@@ -804,7 +805,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
* that can disable it, so otherwise return error
*/
if (ethtool_link_ksettings_test_link_mode(
- &safe_cmd, supported, Autoneg) &&
+ &safe_ks, supported, Autoneg) &&
hw->phy.link_info.phy_type !=
I40E_PHY_TYPE_10GBASE_T) {
netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
@@ -819,7 +820,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
}
ethtool_convert_link_mode_to_legacy_u32(&tmp,
- safe_cmd.link_modes.supported);
+ safe_ks.link_modes.supported);
if (advertise & ~tmp) {
err = -EINVAL;
goto done;
--
2.14.1
next prev parent reply other threads:[~2017-10-05 21:53 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 21:53 [Intel-wired-lan] [PATCH v3 00/14 net-next] i40e: refactor ethtool interface Alan Brady
2017-10-05 21:53 ` Alan Brady [this message]
2017-10-10 17:38 ` [Intel-wired-lan] [PATCH v3 01/14 net-next] i40e: rename 'cmd' variables in " Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 02/14 net-next] i40e: remove ifdef SPEED_25000 Alan Brady
2017-10-10 17:39 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 03/14 net-next] i40e: add function header for i40e_get_rxfh Alan Brady
2017-10-10 17:39 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 04/14 net-next] i40e: fix clearing link masks in i40e_get_link_ksettings Alan Brady
2017-10-10 17:40 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 05/14 net-next] i40e: fix i40e_phy_type_to_ethtool function header Alan Brady
2017-10-10 17:41 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 06/14 net-next] i40e: fix comment typo Alan Brady
2017-10-10 17:41 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 07/14 net-next] i40e: fix whitespace issues in i40e_ethtool.c Alan Brady
2017-10-10 17:42 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 08/14 net-next] i40e: group autoneg PHY types together Alan Brady
2017-10-10 17:42 ` Bowers, AndrewX
2017-10-10 19:08 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 09/14 net-next] i40e: Add new phy types for 25G AOC and ACC support Alan Brady
2017-10-10 17:43 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 10/14 net-next] ethtool: add ethtool_intersect_link_masks Alan Brady
2017-10-10 17:43 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 11/14 net-next] i40e: convert i40e_phy_type_to_ethtool to new API Alan Brady
2017-10-10 17:44 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 12/14 net-next] i40e: convert i40e_get_settings_link_up " Alan Brady
2017-10-10 17:44 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 13/14 net-next] i40e: rename 'change' variable to 'autoneg_changed' Alan Brady
2017-10-10 17:45 ` Bowers, AndrewX
2017-10-05 21:53 ` [Intel-wired-lan] [PATCH v3 14/14 net-next] i40e: convert i40e_set_link_ksettings to new API Alan Brady
2017-10-10 17:45 ` Bowers, AndrewX
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=20171005215344.2886-2-alan.brady@intel.com \
--to=alan.brady@intel.com \
--cc=intel-wired-lan@osuosl.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.