Skip to content

Commit 4ee9b0d

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: phylink: remove an_enabled
The Autoneg bit in the advertising bitmap and state->an_enabled are always identical. state->an_enabled is now no longer used by any drivers, so lets kill this duplication. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 459fd2f commit 4ee9b0d

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

drivers/net/phy/phylink.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
843843
phylink_set(pl->supported, Autoneg);
844844
phylink_set(pl->supported, Asym_Pause);
845845
phylink_set(pl->supported, Pause);
846-
pl->link_config.an_enabled = true;
847846
pl->cfg_link_an_mode = MLO_AN_INBAND;
848847

849848
switch (pl->link_config.interface) {
@@ -945,9 +944,6 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
945944
"failed to validate link configuration for in-band status\n");
946945
return -EINVAL;
947946
}
948-
949-
/* Check if MAC/PCS also supports Autoneg. */
950-
pl->link_config.an_enabled = phylink_test(pl->supported, Autoneg);
951947
}
952948

953949
return 0;
@@ -957,7 +953,8 @@ static void phylink_apply_manual_flow(struct phylink *pl,
957953
struct phylink_link_state *state)
958954
{
959955
/* If autoneg is disabled, pause AN is also disabled */
960-
if (!state->an_enabled)
956+
if (!linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
957+
state->advertising))
961958
state->pause &= ~MLO_PAUSE_AN;
962959

963960
/* Manual configuration of pause modes */
@@ -997,21 +994,22 @@ static void phylink_mac_config(struct phylink *pl,
997994
const struct phylink_link_state *state)
998995
{
999996
phylink_dbg(pl,
1000-
"%s: mode=%s/%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n",
997+
"%s: mode=%s/%s/%s/%s/%s adv=%*pb pause=%02x link=%u\n",
1001998
__func__, phylink_an_mode_str(pl->cur_link_an_mode),
1002999
phy_modes(state->interface),
10031000
phy_speed_to_str(state->speed),
10041001
phy_duplex_to_str(state->duplex),
10051002
phy_rate_matching_to_str(state->rate_matching),
10061003
__ETHTOOL_LINK_MODE_MASK_NBITS, state->advertising,
1007-
state->pause, state->link, state->an_enabled);
1004+
state->pause, state->link);
10081005

10091006
pl->mac_ops->mac_config(pl->config, pl->cur_link_an_mode, state);
10101007
}
10111008

10121009
static void phylink_mac_pcs_an_restart(struct phylink *pl)
10131010
{
1014-
if (pl->link_config.an_enabled &&
1011+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
1012+
pl->link_config.advertising) &&
10151013
phy_interface_mode_is_8023z(pl->link_config.interface) &&
10161014
phylink_autoneg_inband(pl->cur_link_an_mode)) {
10171015
if (pl->pcs)
@@ -1138,9 +1136,9 @@ static void phylink_mac_pcs_get_state(struct phylink *pl,
11381136
linkmode_copy(state->advertising, pl->link_config.advertising);
11391137
linkmode_zero(state->lp_advertising);
11401138
state->interface = pl->link_config.interface;
1141-
state->an_enabled = pl->link_config.an_enabled;
11421139
state->rate_matching = pl->link_config.rate_matching;
1143-
if (state->an_enabled) {
1140+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
1141+
state->advertising)) {
11441142
state->speed = SPEED_UNKNOWN;
11451143
state->duplex = DUPLEX_UNKNOWN;
11461144
state->pause = MLO_PAUSE_NONE;
@@ -1531,7 +1529,6 @@ struct phylink *phylink_create(struct phylink_config *config,
15311529
pl->link_config.pause = MLO_PAUSE_AN;
15321530
pl->link_config.speed = SPEED_UNKNOWN;
15331531
pl->link_config.duplex = DUPLEX_UNKNOWN;
1534-
pl->link_config.an_enabled = true;
15351532
pl->mac_ops = mac_ops;
15361533
__set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
15371534
timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
@@ -2136,8 +2133,9 @@ static void phylink_get_ksettings(const struct phylink_link_state *state,
21362133
kset->base.speed = state->speed;
21372134
kset->base.duplex = state->duplex;
21382135
}
2139-
kset->base.autoneg = state->an_enabled ? AUTONEG_ENABLE :
2140-
AUTONEG_DISABLE;
2136+
kset->base.autoneg = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
2137+
state->advertising) ?
2138+
AUTONEG_ENABLE : AUTONEG_DISABLE;
21412139
}
21422140

21432141
/**
@@ -2284,9 +2282,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
22842282
/* We have ruled out the case with a PHY attached, and the
22852283
* fixed-link cases. All that is left are in-band links.
22862284
*/
2287-
config.an_enabled = kset->base.autoneg == AUTONEG_ENABLE;
22882285
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, config.advertising,
2289-
config.an_enabled);
2286+
kset->base.autoneg == AUTONEG_ENABLE);
22902287

22912288
/* If this link is with an SFP, ensure that changes to advertised modes
22922289
* also cause the associated interface to be selected such that the
@@ -2320,13 +2317,14 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
23202317
}
23212318

23222319
/* If autonegotiation is enabled, we must have an advertisement */
2323-
if (config.an_enabled && phylink_is_empty_linkmode(config.advertising))
2320+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
2321+
config.advertising) &&
2322+
phylink_is_empty_linkmode(config.advertising))
23242323
return -EINVAL;
23252324

23262325
mutex_lock(&pl->state_mutex);
23272326
pl->link_config.speed = config.speed;
23282327
pl->link_config.duplex = config.duplex;
2329-
pl->link_config.an_enabled = config.an_enabled;
23302328

23312329
if (pl->link_config.interface != config.interface) {
23322330
/* The interface changed, e.g. 1000base-X <-> 2500base-X */
@@ -2932,7 +2930,6 @@ static int phylink_sfp_config_phy(struct phylink *pl, u8 mode,
29322930
config.speed = SPEED_UNKNOWN;
29332931
config.duplex = DUPLEX_UNKNOWN;
29342932
config.pause = MLO_PAUSE_AN;
2935-
config.an_enabled = pl->link_config.an_enabled;
29362933

29372934
/* Ignore errors if we're expecting a PHY to attach later */
29382935
ret = phylink_validate(pl, support, &config);
@@ -3001,7 +2998,6 @@ static int phylink_sfp_config_optical(struct phylink *pl)
30012998
config.speed = SPEED_UNKNOWN;
30022999
config.duplex = DUPLEX_UNKNOWN;
30033000
config.pause = MLO_PAUSE_AN;
3004-
config.an_enabled = true;
30053001

30063002
/* For all the interfaces that are supported, reduce the sfp_support
30073003
* mask to only those link modes that can be supported.
@@ -3300,7 +3296,8 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
33003296
/* If there is no link or autonegotiation is disabled, the LP advertisement
33013297
* data is not meaningful, so don't go any further.
33023298
*/
3303-
if (!state->link || !state->an_enabled)
3299+
if (!state->link || !linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
3300+
state->advertising))
33043301
return;
33053302

33063303
switch (state->interface) {

include/linux/phylink.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ static inline bool phylink_autoneg_inband(unsigned int mode)
9393
* the medium link mode (@speed and @duplex) and the speed/duplex of the phy
9494
* interface mode (@interface) are different.
9595
* @link: true if the link is up.
96-
* @an_enabled: true if autonegotiation is enabled/desired.
9796
* @an_complete: true if autonegotiation has completed.
9897
*/
9998
struct phylink_link_state {
@@ -105,7 +104,6 @@ struct phylink_link_state {
105104
int pause;
106105
int rate_matching;
107106
unsigned int link:1;
108-
unsigned int an_enabled:1;
109107
unsigned int an_complete:1;
110108
};
111109

0 commit comments

Comments
 (0)