Skip to content

Commit b50fea1

Browse files
committed
Merge branch 'remove-phylink_state-s-an_enabled-member'
Russell King says: ==================== Remove phylink_state's an_enabled member Now that all the fixes and correctness patches have been merged, it is time to switch the two users that make use of .an_enabled to check the Autoneg bit in the advertising mask, and finally remove the .an_enabled member. The first two patches remove the last uses of .an_enabled, which are in DPAA2 and XPCS. The final patch removes the member. ==================== Link: https://lore.kernel.org/r/ZBnT6yW9UY1sAsiy@shell.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 1cc6571 + 4ee9b0d commit b50fea1

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
159159
struct dpmac_link_state *dpmac_state = &mac->state;
160160
int err;
161161

162-
if (state->an_enabled)
162+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
163+
state->advertising))
163164
dpmac_state->options |= DPMAC_LINK_OPT_AUTONEG;
164165
else
165166
dpmac_state->options &= ~DPMAC_LINK_OPT_AUTONEG;

drivers/net/pcs/pcs-xpcs.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
923923
struct phylink_link_state *state,
924924
const struct xpcs_compat *compat)
925925
{
926+
bool an_enabled;
926927
int ret;
927928

928929
/* Link needs to be read first ... */
@@ -940,11 +941,13 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
940941
return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND, NULL);
941942
}
942943

943-
if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state, compat)) {
944+
an_enabled = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
945+
state->advertising);
946+
if (an_enabled && xpcs_aneg_done_c73(xpcs, state, compat)) {
944947
state->an_complete = true;
945948
xpcs_read_lpa_c73(xpcs, state);
946949
xpcs_resolve_lpa_c73(xpcs, state);
947-
} else if (state->an_enabled) {
950+
} else if (an_enabled) {
948951
state->link = 0;
949952
} else if (state->link) {
950953
xpcs_resolve_pma(xpcs, state);
@@ -999,7 +1002,8 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
9991002
{
10001003
int lpa, bmsr;
10011004

1002-
if (state->an_enabled) {
1005+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
1006+
state->advertising)) {
10031007
/* Reset link state */
10041008
state->link = false;
10051009

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)