Skip to content

Commit 2cd2e9f

Browse files
Russell Kingclaudiubeznea
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 <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
1 parent b2b0414 commit 2cd2e9f

10 files changed

Lines changed: 59 additions & 65 deletions

File tree

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
@@ -3411,8 +3411,8 @@ static void mvneta_validate(struct phylink_config *config,
34113411
phylink_helper_basex_speed(state);
34123412
}
34133413

3414-
static int mvneta_mac_link_state(struct phylink_config *config,
3415-
struct phylink_link_state *state)
3414+
static void mvneta_mac_pcs_get_state(struct phylink_config *config,
3415+
struct phylink_link_state *state)
34163416
{
34173417
struct net_device *ndev = to_net_dev(config->dev);
34183418
struct mvneta_port *pp = netdev_priv(ndev);
@@ -3438,8 +3438,6 @@ static int mvneta_mac_link_state(struct phylink_config *config,
34383438
state->pause |= MLO_PAUSE_RX;
34393439
if (gmac_stat & MVNETA_GMAC_TX_FLOW_CTRL_ENABLE)
34403440
state->pause |= MLO_PAUSE_TX;
3441-
3442-
return 1;
34433441
}
34443442

34453443
static void mvneta_mac_an_restart(struct phylink_config *config)
@@ -3632,7 +3630,7 @@ static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
36323630

36333631
static const struct phylink_mac_ops mvneta_phylink_ops = {
36343632
.validate = mvneta_validate,
3635-
.mac_link_state = mvneta_mac_link_state,
3633+
.mac_pcs_get_state = mvneta_mac_pcs_get_state,
36363634
.mac_an_restart = mvneta_mac_an_restart,
36373635
.mac_config = mvneta_mac_config,
36383636
.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
@@ -4817,8 +4817,8 @@ static void mvpp2_phylink_validate(struct phylink_config *config,
48174817
bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
48184818
}
48194819

4820-
static void mvpp22_xlg_link_state(struct mvpp2_port *port,
4821-
struct phylink_link_state *state)
4820+
static void mvpp22_xlg_pcs_get_state(struct mvpp2_port *port,
4821+
struct phylink_link_state *state)
48224822
{
48234823
u32 val;
48244824

@@ -4837,8 +4837,8 @@ static void mvpp22_xlg_link_state(struct mvpp2_port *port,
48374837
state->pause |= MLO_PAUSE_RX;
48384838
}
48394839

4840-
static void mvpp2_gmac_link_state(struct mvpp2_port *port,
4841-
struct phylink_link_state *state)
4840+
static void mvpp2_gmac_pcs_get_state(struct mvpp2_port *port,
4841+
struct phylink_link_state *state)
48424842
{
48434843
u32 val;
48444844

@@ -4871,8 +4871,8 @@ static void mvpp2_gmac_link_state(struct mvpp2_port *port,
48714871
state->pause |= MLO_PAUSE_TX;
48724872
}
48734873

4874-
static int mvpp2_phylink_mac_link_state(struct phylink_config *config,
4875-
struct phylink_link_state *state)
4874+
static void mvpp2_phylink_mac_pcs_get_state(struct phylink_config *config,
4875+
struct phylink_link_state *state)
48764876
{
48774877
struct mvpp2_port *port = container_of(config, struct mvpp2_port,
48784878
phylink_config);
@@ -4882,13 +4882,12 @@ static int mvpp2_phylink_mac_link_state(struct phylink_config *config,
48824882
mode &= MVPP22_XLG_CTRL3_MACMODESELECT_MASK;
48834883

48844884
if (mode == MVPP22_XLG_CTRL3_MACMODESELECT_10G) {
4885-
mvpp22_xlg_link_state(port, state);
4886-
return 1;
4885+
mvpp22_xlg_pcs_get_state(port, state);
4886+
return;
48874887
}
48884888
}
48894889

4890-
mvpp2_gmac_link_state(port, state);
4891-
return 1;
4890+
mvpp2_gmac_pcs_get_state(port, state);
48924891
}
48934892

48944893
static void mvpp2_mac_an_restart(struct phylink_config *config)
@@ -5180,7 +5179,7 @@ static void mvpp2_mac_link_down(struct phylink_config *config,
51805179

51815180
static const struct phylink_mac_ops mvpp2_phylink_ops = {
51825181
.validate = mvpp2_phylink_validate,
5183-
.mac_link_state = mvpp2_phylink_mac_link_state,
5182+
.mac_pcs_get_state = mvpp2_phylink_mac_pcs_get_state,
51845183
.mac_an_restart = mvpp2_mac_an_restart,
51855184
.mac_config = mvpp2_mac_config,
51865185
.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
@@ -867,10 +867,10 @@ static void stmmac_validate(struct phylink_config *config,
867867
__ETHTOOL_LINK_MODE_MASK_NBITS);
868868
}
869869

870-
static int stmmac_mac_link_state(struct phylink_config *config,
871-
struct phylink_link_state *state)
870+
static void stmmac_mac_pcs_get_state(struct phylink_config *config,
871+
struct phylink_link_state *state)
872872
{
873-
return -EOPNOTSUPP;
873+
state->link = 0;
874874
}
875875

876876
static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
@@ -964,7 +964,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
964964

965965
static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
966966
.validate = stmmac_validate,
967-
.mac_link_state = stmmac_mac_link_state,
967+
.mac_pcs_get_state = stmmac_mac_pcs_get_state,
968968
.mac_config = stmmac_mac_config,
969969
.mac_an_restart = stmmac_mac_an_restart,
970970
.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
@@ -359,9 +359,9 @@ static void phylink_mac_an_restart(struct phylink *pl)
359359
pl->ops->mac_an_restart(pl->config);
360360
}
361361

362-
static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *state)
362+
static void phylink_mac_pcs_get_state(struct phylink *pl,
363+
struct phylink_link_state *state)
363364
{
364-
365365
linkmode_copy(state->advertising, pl->link_config.advertising);
366366
linkmode_zero(state->lp_advertising);
367367
state->interface = pl->link_config.interface;
@@ -372,7 +372,7 @@ static int phylink_get_mac_state(struct phylink *pl, struct phylink_link_state *
372372
state->an_complete = 0;
373373
state->link = 1;
374374

375-
return pl->ops->mac_link_state(pl->config, state);
375+
pl->ops->mac_pcs_get_state(pl->config, state);
376376
}
377377

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

496496
case MLO_AN_INBAND:
497-
phylink_get_mac_state(pl, &link_state);
497+
phylink_mac_pcs_get_state(pl, &link_state);
498498

499499
/* If we have a phy, the "up" state is the union of
500500
* both the PHY and the MAC */
@@ -1153,7 +1153,7 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
11531153
if (pl->phydev)
11541154
break;
11551155

1156-
phylink_get_mac_state(pl, &link_state);
1156+
phylink_mac_pcs_get_state(pl, &link_state);
11571157

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

15731573
case MLO_AN_INBAND:
15741574
if (phy_id == 0) {
1575-
val = phylink_get_mac_state(pl, &state);
1576-
if (val < 0)
1577-
return val;
1578-
1575+
phylink_mac_pcs_get_state(pl, &state);
15791576
val = phylink_mii_emul_read(reg, &state);
15801577
}
15811578
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
@@ -164,8 +164,8 @@ void dsa_port_link_unregister_of(struct dsa_port *dp);
164164
void dsa_port_phylink_validate(struct phylink_config *config,
165165
unsigned long *supported,
166166
struct phylink_link_state *state);
167-
int dsa_port_phylink_mac_link_state(struct phylink_config *config,
168-
struct phylink_link_state *state);
167+
void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
168+
struct phylink_link_state *state);
169169
void dsa_port_phylink_mac_config(struct phylink_config *config,
170170
unsigned int mode,
171171
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)