Skip to content

Commit d46b7e4

Browse files
Russell KingJakub Kicinski
authored andcommitted
net: phylink: rename mac_link_state() op to mac_pcs_get_state()
Rename the mac_link_state() method to mac_pcs_get_state() to make it clear that it should be returning the MACs PCS current state, which is used for inband negotiation rather than just reading back what the MAC has been configured for. Update the documentation to explicitly mention that this is for inband. We drop the return value as well; most of phylink doesn't check the return value and it is not clear what it should do on error - instead arrange for state->link to be false. Signed-off-by: Russell King <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ab81836 commit d46b7e4

File tree

10 files changed

+59
-65
lines changed

10 files changed

+59
-65
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,10 @@ static void macb_validate(struct phylink_config *config,
505505
__ETHTOOL_LINK_MODE_MASK_NBITS);
506506
}
507507

508-
static int macb_mac_link_state(struct phylink_config *config,
509-
struct phylink_link_state *state)
508+
static void macb_mac_pcs_get_state(struct phylink_config *config,
509+
struct phylink_link_state *state)
510510
{
511-
return -EOPNOTSUPP;
511+
state->link = 0;
512512
}
513513

514514
static void macb_mac_an_restart(struct phylink_config *config)
@@ -604,7 +604,7 @@ static void macb_mac_link_up(struct phylink_config *config, unsigned int mode,
604604

605605
static const struct phylink_mac_ops macb_phylink_ops = {
606606
.validate = macb_validate,
607-
.mac_link_state = macb_mac_link_state,
607+
.mac_pcs_get_state = macb_mac_pcs_get_state,
608608
.mac_an_restart = macb_mac_an_restart,
609609
.mac_config = macb_mac_config,
610610
.mac_link_down = macb_mac_link_down,

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3694,8 +3694,8 @@ static void mvneta_validate(struct phylink_config *config,
36943694
phylink_helper_basex_speed(state);
36953695
}
36963696

3697-
static int mvneta_mac_link_state(struct phylink_config *config,
3698-
struct phylink_link_state *state)
3697+
static void mvneta_mac_pcs_get_state(struct phylink_config *config,
3698+
struct phylink_link_state *state)
36993699
{
37003700
struct net_device *ndev = to_net_dev(config->dev);
37013701
struct mvneta_port *pp = netdev_priv(ndev);
@@ -3721,8 +3721,6 @@ static int mvneta_mac_link_state(struct phylink_config *config,
37213721
state->pause |= MLO_PAUSE_RX;
37223722
if (gmac_stat & MVNETA_GMAC_TX_FLOW_CTRL_ENABLE)
37233723
state->pause |= MLO_PAUSE_TX;
3724-
3725-
return 1;
37263724
}
37273725

37283726
static void mvneta_mac_an_restart(struct phylink_config *config)
@@ -3915,7 +3913,7 @@ static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
39153913

39163914
static const struct phylink_mac_ops mvneta_phylink_ops = {
39173915
.validate = mvneta_validate,
3918-
.mac_link_state = mvneta_mac_link_state,
3916+
.mac_pcs_get_state = mvneta_mac_pcs_get_state,
39193917
.mac_an_restart = mvneta_mac_an_restart,
39203918
.mac_config = mvneta_mac_config,
39213919
.mac_link_down = mvneta_mac_link_down,

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4823,8 +4823,8 @@ static void mvpp2_phylink_validate(struct phylink_config *config,
48234823
bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
48244824
}
48254825

4826-
static void mvpp22_xlg_link_state(struct mvpp2_port *port,
4827-
struct phylink_link_state *state)
4826+
static void mvpp22_xlg_pcs_get_state(struct mvpp2_port *port,
4827+
struct phylink_link_state *state)
48284828
{
48294829
u32 val;
48304830

@@ -4843,8 +4843,8 @@ static void mvpp22_xlg_link_state(struct mvpp2_port *port,
48434843
state->pause |= MLO_PAUSE_RX;
48444844
}
48454845

4846-
static void mvpp2_gmac_link_state(struct mvpp2_port *port,
4847-
struct phylink_link_state *state)
4846+
static void mvpp2_gmac_pcs_get_state(struct mvpp2_port *port,
4847+
struct phylink_link_state *state)
48484848
{
48494849
u32 val;
48504850

@@ -4877,8 +4877,8 @@ static void mvpp2_gmac_link_state(struct mvpp2_port *port,
48774877
state->pause |= MLO_PAUSE_TX;
48784878
}
48794879

4880-
static int mvpp2_phylink_mac_link_state(struct phylink_config *config,
4881-
struct phylink_link_state *state)
4880+
static void mvpp2_phylink_mac_pcs_get_state(struct phylink_config *config,
4881+
struct phylink_link_state *state)
48824882
{
48834883
struct mvpp2_port *port = container_of(config, struct mvpp2_port,
48844884
phylink_config);
@@ -4888,13 +4888,12 @@ static int mvpp2_phylink_mac_link_state(struct phylink_config *config,
48884888
mode &= MVPP22_XLG_CTRL3_MACMODESELECT_MASK;
48894889

48904890
if (mode == MVPP22_XLG_CTRL3_MACMODESELECT_10G) {
4891-
mvpp22_xlg_link_state(port, state);
4892-
return 1;
4891+
mvpp22_xlg_pcs_get_state(port, state);
4892+
return;
48934893
}
48944894
}
48954895

4896-
mvpp2_gmac_link_state(port, state);
4897-
return 1;
4896+
mvpp2_gmac_pcs_get_state(port, state);
48984897
}
48994898

49004899
static void mvpp2_mac_an_restart(struct phylink_config *config)
@@ -5186,7 +5185,7 @@ static void mvpp2_mac_link_down(struct phylink_config *config,
51865185

51875186
static const struct phylink_mac_ops mvpp2_phylink_ops = {
51885187
.validate = mvpp2_phylink_validate,
5189-
.mac_link_state = mvpp2_phylink_mac_link_state,
5188+
.mac_pcs_get_state = mvpp2_phylink_mac_pcs_get_state,
51905189
.mac_an_restart = mvpp2_mac_an_restart,
51915190
.mac_config = mvpp2_mac_config,
51925191
.mac_link_up = mvpp2_mac_link_up,

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
361361
mac->id, phy_modes(state->interface), err);
362362
}
363363

364-
static int mtk_mac_link_state(struct phylink_config *config,
365-
struct phylink_link_state *state)
364+
static void mtk_mac_pcs_get_state(struct phylink_config *config,
365+
struct phylink_link_state *state)
366366
{
367367
struct mtk_mac *mac = container_of(config, struct mtk_mac,
368368
phylink_config);
@@ -391,8 +391,6 @@ static int mtk_mac_link_state(struct phylink_config *config,
391391
state->pause |= MLO_PAUSE_RX;
392392
if (pmsr & MAC_MSR_TX_FC)
393393
state->pause |= MLO_PAUSE_TX;
394-
395-
return 1;
396394
}
397395

398396
static void mtk_mac_an_restart(struct phylink_config *config)
@@ -514,7 +512,7 @@ static void mtk_validate(struct phylink_config *config,
514512

515513
static const struct phylink_mac_ops mtk_phylink_ops = {
516514
.validate = mtk_validate,
517-
.mac_link_state = mtk_mac_link_state,
515+
.mac_pcs_get_state = mtk_mac_pcs_get_state,
518516
.mac_an_restart = mtk_mac_an_restart,
519517
.mac_config = mtk_mac_config,
520518
.mac_link_down = mtk_mac_link_down,

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,10 @@ static void stmmac_validate(struct phylink_config *config,
868868
__ETHTOOL_LINK_MODE_MASK_NBITS);
869869
}
870870

871-
static int stmmac_mac_link_state(struct phylink_config *config,
872-
struct phylink_link_state *state)
871+
static void stmmac_mac_pcs_get_state(struct phylink_config *config,
872+
struct phylink_link_state *state)
873873
{
874-
return -EOPNOTSUPP;
874+
state->link = 0;
875875
}
876876

877877
static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
@@ -965,7 +965,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
965965

966966
static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
967967
.validate = stmmac_validate,
968-
.mac_link_state = stmmac_mac_link_state,
968+
.mac_pcs_get_state = stmmac_mac_pcs_get_state,
969969
.mac_config = stmmac_mac_config,
970970
.mac_an_restart = stmmac_mac_an_restart,
971971
.mac_link_down = stmmac_mac_link_down,

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,8 @@ static void axienet_validate(struct phylink_config *config,
14051405
__ETHTOOL_LINK_MODE_MASK_NBITS);
14061406
}
14071407

1408-
static int axienet_mac_link_state(struct phylink_config *config,
1409-
struct phylink_link_state *state)
1408+
static void axienet_mac_pcs_get_state(struct phylink_config *config,
1409+
struct phylink_link_state *state)
14101410
{
14111411
struct net_device *ndev = to_net_dev(config->dev);
14121412
struct axienet_local *lp = netdev_priv(ndev);
@@ -1431,8 +1431,6 @@ static int axienet_mac_link_state(struct phylink_config *config,
14311431

14321432
state->an_complete = 0;
14331433
state->duplex = 1;
1434-
1435-
return 1;
14361434
}
14371435

14381436
static void axienet_mac_an_restart(struct phylink_config *config)
@@ -1497,7 +1495,7 @@ static void axienet_mac_link_up(struct phylink_config *config,
14971495

14981496
static const struct phylink_mac_ops axienet_phylink_ops = {
14991497
.validate = axienet_validate,
1500-
.mac_link_state = axienet_mac_link_state,
1498+
.mac_pcs_get_state = axienet_mac_pcs_get_state,
15011499
.mac_an_restart = axienet_mac_an_restart,
15021500
.mac_config = axienet_mac_config,
15031501
.mac_link_down = axienet_mac_link_down,

drivers/net/phy/phylink.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ static void phylink_mac_an_restart(struct phylink *pl)
357357
pl->ops->mac_an_restart(pl->config);
358358
}
359359

360-
static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *state)
360+
static void phylink_mac_pcs_get_state(struct phylink *pl,
361+
struct phylink_link_state *state)
361362
{
362-
363363
linkmode_copy(state->advertising, pl->link_config.advertising);
364364
linkmode_zero(state->lp_advertising);
365365
state->interface = pl->link_config.interface;
@@ -370,7 +370,7 @@ static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *
370370
state->an_complete = 0;
371371
state->link = 1;
372372

373-
return pl->ops->mac_link_state(pl->config, state);
373+
pl->ops->mac_pcs_get_state(pl->config, state);
374374
}
375375

376376
/* The fixed state is... fixed except for the link state,
@@ -493,7 +493,7 @@ static void phylink_resolve(struct work_struct *w)
493493
break;
494494

495495
case MLO_AN_INBAND:
496-
phylink_get_mac_state(pl, &link_state);
496+
phylink_mac_pcs_get_state(pl, &link_state);
497497

498498
/* If we have a phy, the "up" state is the union of
499499
* both the PHY and the MAC */
@@ -1142,7 +1142,7 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
11421142
if (pl->phydev)
11431143
break;
11441144

1145-
phylink_get_mac_state(pl, &link_state);
1145+
phylink_mac_pcs_get_state(pl, &link_state);
11461146

11471147
/* The MAC is reporting the link results from its own PCS
11481148
* layer via in-band status. Report these as the current
@@ -1561,10 +1561,7 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id,
15611561

15621562
case MLO_AN_INBAND:
15631563
if (phy_id == 0) {
1564-
val = phylink_get_mac_state(pl, &state);
1565-
if (val < 0)
1566-
return val;
1567-
1564+
phylink_mac_pcs_get_state(pl, &state);
15681565
val = phylink_mii_emul_read(reg, &state);
15691566
}
15701567
break;

include/linux/phylink.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct phylink_config {
7272
/**
7373
* struct phylink_mac_ops - MAC operations structure.
7474
* @validate: Validate and update the link configuration.
75-
* @mac_link_state: Read the current link state from the hardware.
75+
* @mac_pcs_get_state: Read the current link state from the hardware.
7676
* @mac_config: configure the MAC for the selected mode and state.
7777
* @mac_an_restart: restart 802.3z BaseX autonegotiation.
7878
* @mac_link_down: take the link down.
@@ -84,8 +84,8 @@ struct phylink_mac_ops {
8484
void (*validate)(struct phylink_config *config,
8585
unsigned long *supported,
8686
struct phylink_link_state *state);
87-
int (*mac_link_state)(struct phylink_config *config,
88-
struct phylink_link_state *state);
87+
void (*mac_pcs_get_state)(struct phylink_config *config,
88+
struct phylink_link_state *state);
8989
void (*mac_config)(struct phylink_config *config, unsigned int mode,
9090
const struct phylink_link_state *state);
9191
void (*mac_an_restart)(struct phylink_config *config);
@@ -127,18 +127,19 @@ void validate(struct phylink_config *config, unsigned long *supported,
127127
struct phylink_link_state *state);
128128

129129
/**
130-
* mac_link_state() - Read the current link state from the hardware
130+
* mac_pcs_get_state() - Read the current inband link state from the hardware
131131
* @config: a pointer to a &struct phylink_config.
132132
* @state: a pointer to a &struct phylink_link_state.
133133
*
134-
* Read the current link state from the MAC, reporting the current
135-
* speed in @state->speed, duplex mode in @state->duplex, pause mode
136-
* in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
137-
* negotiation completion state in @state->an_complete, and link
138-
* up state in @state->link.
134+
* Read the current inband link state from the MAC PCS, reporting the
135+
* current speed in @state->speed, duplex mode in @state->duplex, pause
136+
* mode in @state->pause using the %MLO_PAUSE_RX and %MLO_PAUSE_TX bits,
137+
* negotiation completion state in @state->an_complete, and link up state
138+
* in @state->link. If possible, @state->lp_advertising should also be
139+
* populated.
139140
*/
140-
int mac_link_state(struct phylink_config *config,
141-
struct phylink_link_state *state);
141+
void mac_pcs_get_state(struct phylink_config *config,
142+
struct phylink_link_state *state);
142143

143144
/**
144145
* mac_config() - configure the MAC for the selected mode and state
@@ -166,7 +167,7 @@ int mac_link_state(struct phylink_config *config,
166167
* 1000base-X or Cisco SGMII mode depending on the @state->interface
167168
* mode). In both cases, link state management (whether the link
168169
* is up or not) is performed by the MAC, and reported via the
169-
* mac_link_state() callback. Changes in link state must be made
170+
* mac_pcs_get_state() callback. Changes in link state must be made
170171
* by calling phylink_mac_change().
171172
*
172173
* If in 802.3z mode, the link speed is fixed, dependent on the

net/dsa/dsa_priv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ void dsa_port_link_unregister_of(struct dsa_port *dp);
153153
void dsa_port_phylink_validate(struct phylink_config *config,
154154
unsigned long *supported,
155155
struct phylink_link_state *state);
156-
int dsa_port_phylink_mac_link_state(struct phylink_config *config,
157-
struct phylink_link_state *state);
156+
void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
157+
struct phylink_link_state *state);
158158
void dsa_port_phylink_mac_config(struct phylink_config *config,
159159
unsigned int mode,
160160
const struct phylink_link_state *state);

net/dsa/port.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,19 +429,22 @@ void dsa_port_phylink_validate(struct phylink_config *config,
429429
}
430430
EXPORT_SYMBOL_GPL(dsa_port_phylink_validate);
431431

432-
int dsa_port_phylink_mac_link_state(struct phylink_config *config,
433-
struct phylink_link_state *state)
432+
void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
433+
struct phylink_link_state *state)
434434
{
435435
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
436436
struct dsa_switch *ds = dp->ds;
437437

438-
/* Only called for SGMII and 802.3z */
439-
if (!ds->ops->phylink_mac_link_state)
440-
return -EOPNOTSUPP;
438+
/* Only called for inband modes */
439+
if (!ds->ops->phylink_mac_link_state) {
440+
state->link = 0;
441+
return;
442+
}
441443

442-
return ds->ops->phylink_mac_link_state(ds, dp->index, state);
444+
if (ds->ops->phylink_mac_link_state(ds, dp->index, state) < 0)
445+
state->link = 0;
443446
}
444-
EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_state);
447+
EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_pcs_get_state);
445448

446449
void dsa_port_phylink_mac_config(struct phylink_config *config,
447450
unsigned int mode,
@@ -510,7 +513,7 @@ EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_up);
510513

511514
const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
512515
.validate = dsa_port_phylink_validate,
513-
.mac_link_state = dsa_port_phylink_mac_link_state,
516+
.mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state,
514517
.mac_config = dsa_port_phylink_mac_config,
515518
.mac_an_restart = dsa_port_phylink_mac_an_restart,
516519
.mac_link_down = dsa_port_phylink_mac_link_down,

0 commit comments

Comments
 (0)