Skip to content

Commit 86a362c

Browse files
Russell Kingdavem330
authored andcommitted
phylink: get rid of separate Cisco SGMII and 802.3z modes
Since the handling of SGMII and 802.3z is now the same, combine the MLO_AN_xxx constants into a single MLO_AN_INBAND, and use the PHY interface mode to distinguish between Cisco SGMII and 802.3z. Signed-off-by: Russell King <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cf4f267 commit 86a362c

File tree

2 files changed

+21
-37
lines changed

2 files changed

+21
-37
lines changed

drivers/net/phy/phylink.c

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ static const char *phylink_an_mode_str(unsigned int mode)
117117
static const char *modestr[] = {
118118
[MLO_AN_PHY] = "phy",
119119
[MLO_AN_FIXED] = "fixed",
120-
[MLO_AN_SGMII] = "SGMII",
121-
[MLO_AN_8023Z] = "802.3z",
120+
[MLO_AN_INBAND] = "inband",
122121
};
123122

124123
return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown";
@@ -244,6 +243,7 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
244243
phylink_set(pl->supported, Asym_Pause);
245244
phylink_set(pl->supported, Pause);
246245
pl->link_config.an_enabled = true;
246+
pl->link_an_mode = MLO_AN_INBAND;
247247

248248
switch (pl->link_config.interface) {
249249
case PHY_INTERFACE_MODE_SGMII:
@@ -253,17 +253,14 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
253253
phylink_set(pl->supported, 100baseT_Full);
254254
phylink_set(pl->supported, 1000baseT_Half);
255255
phylink_set(pl->supported, 1000baseT_Full);
256-
pl->link_an_mode = MLO_AN_SGMII;
257256
break;
258257

259258
case PHY_INTERFACE_MODE_1000BASEX:
260259
phylink_set(pl->supported, 1000baseX_Full);
261-
pl->link_an_mode = MLO_AN_8023Z;
262260
break;
263261

264262
case PHY_INTERFACE_MODE_2500BASEX:
265263
phylink_set(pl->supported, 2500baseX_Full);
266-
pl->link_an_mode = MLO_AN_8023Z;
267264
break;
268265

269266
case PHY_INTERFACE_MODE_10GKR:
@@ -280,7 +277,6 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
280277
phylink_set(pl->supported, 10000baseLR_Full);
281278
phylink_set(pl->supported, 10000baseLRM_Full);
282279
phylink_set(pl->supported, 10000baseER_Full);
283-
pl->link_an_mode = MLO_AN_SGMII;
284280
break;
285281

286282
default:
@@ -422,8 +418,7 @@ static void phylink_resolve(struct work_struct *w)
422418
phylink_mac_config(pl, &link_state);
423419
break;
424420

425-
case MLO_AN_SGMII:
426-
case MLO_AN_8023Z:
421+
case MLO_AN_INBAND:
427422
phylink_get_mac_state(pl, &link_state);
428423
if (pl->phydev) {
429424
bool changed = false;
@@ -654,7 +649,8 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
654649
int ret;
655650

656651
if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED ||
657-
pl->link_an_mode == MLO_AN_8023Z))
652+
(pl->link_an_mode == MLO_AN_INBAND &&
653+
phy_interface_mode_is_8023z(pl->link_interface))))
658654
return -EINVAL;
659655

660656
ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface);
@@ -677,7 +673,8 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
677673

678674
/* Fixed links and 802.3z are handled without needing a PHY */
679675
if (pl->link_an_mode == MLO_AN_FIXED ||
680-
pl->link_an_mode == MLO_AN_8023Z)
676+
(pl->link_an_mode == MLO_AN_INBAND &&
677+
phy_interface_mode_is_8023z(pl->link_interface)))
681678
return 0;
682679

683680
phy_node = of_parse_phandle(dn, "phy-handle", 0);
@@ -851,8 +848,7 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
851848
phylink_get_ksettings(&link_state, kset);
852849
break;
853850

854-
case MLO_AN_SGMII:
855-
case MLO_AN_8023Z:
851+
case MLO_AN_INBAND:
856852
/* If there is a phy attached, then use the reported
857853
* settings from the phy with no modification.
858854
*/
@@ -1029,8 +1025,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
10291025
phylink_mac_config(pl, config);
10301026
break;
10311027

1032-
case MLO_AN_SGMII:
1033-
case MLO_AN_8023Z:
1028+
case MLO_AN_INBAND:
10341029
phylink_mac_config(pl, config);
10351030
phylink_mac_an_restart(pl);
10361031
break;
@@ -1247,9 +1242,7 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id,
12471242
case MLO_AN_PHY:
12481243
return -EOPNOTSUPP;
12491244

1250-
case MLO_AN_SGMII:
1251-
/* No phy, fall through to 8023z method */
1252-
case MLO_AN_8023Z:
1245+
case MLO_AN_INBAND:
12531246
if (phy_id == 0) {
12541247
val = phylink_get_mac_state(pl, &state);
12551248
if (val < 0)
@@ -1274,9 +1267,7 @@ static int phylink_mii_write(struct phylink *pl, unsigned int phy_id,
12741267
case MLO_AN_PHY:
12751268
return -EOPNOTSUPP;
12761269

1277-
case MLO_AN_SGMII:
1278-
/* No phy, fall through to 8023z method */
1279-
case MLO_AN_8023Z:
1270+
case MLO_AN_INBAND:
12801271
break;
12811272
}
12821273

@@ -1291,7 +1282,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
12911282
WARN_ON(!lockdep_rtnl_is_held());
12921283

12931284
if (pl->phydev) {
1294-
/* PHYs only exist for MLO_AN_PHY and MLO_AN_SGMII */
1285+
/* PHYs only exist for MLO_AN_PHY and SGMII */
12951286
switch (cmd) {
12961287
case SIOCGMIIPHY:
12971288
mii->phy_id = pl->phydev->mdio.addr;
@@ -1360,10 +1351,8 @@ static int phylink_sfp_module_insert(void *upstream,
13601351

13611352
switch (iface) {
13621353
case PHY_INTERFACE_MODE_SGMII:
1363-
mode = MLO_AN_SGMII;
1364-
break;
13651354
case PHY_INTERFACE_MODE_1000BASEX:
1366-
mode = MLO_AN_8023Z;
1355+
mode = MLO_AN_INBAND;
13671356
break;
13681357
default:
13691358
return -EINVAL;
@@ -1390,7 +1379,7 @@ static int phylink_sfp_module_insert(void *upstream,
13901379
phylink_an_mode_str(mode), phy_modes(config.interface),
13911380
__ETHTOOL_LINK_MODE_MASK_NBITS, support);
13921381

1393-
if (mode == MLO_AN_8023Z && pl->phydev)
1382+
if (phy_interface_mode_is_8023z(iface) && pl->phydev)
13941383
return -EINVAL;
13951384

13961385
changed = !bitmap_equal(pl->supported, support,

include/linux/phylink.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ enum {
2020

2121
MLO_AN_PHY = 0, /* Conventional PHY */
2222
MLO_AN_FIXED, /* Fixed-link mode */
23-
MLO_AN_SGMII, /* Cisco SGMII protocol */
24-
MLO_AN_8023Z, /* 1000base-X protocol */
23+
MLO_AN_INBAND, /* In-band protocol */
2524
};
2625

2726
static inline bool phylink_autoneg_inband(unsigned int mode)
2827
{
29-
return mode == MLO_AN_SGMII || mode == MLO_AN_8023Z;
28+
return mode == MLO_AN_INBAND;
3029
}
3130

3231
struct phylink_link_state {
@@ -69,22 +68,18 @@ struct phylink_mac_ops {
6968
/**
7069
* mac_config: configure the MAC for the selected mode and state
7170
* @ndev: net_device structure for the MAC
72-
* @mode: one of MLO_AN_FIXED, MLO_AN_PHY, MLO_AN_8023Z, MLO_AN_SGMII
71+
* @mode: one of MLO_AN_FIXED, MLO_AN_PHY, MLO_AN_INBAND
7372
* @state: state structure
7473
*
7574
* The action performed depends on the currently selected mode:
7675
*
7776
* %MLO_AN_FIXED, %MLO_AN_PHY:
7877
* set the specified speed, duplex, pause mode, and phy interface
7978
* mode in the provided @state.
80-
* %MLO_AN_8023Z:
81-
* place the link in 1000base-X mode, advertising the parameters
82-
* given in advertising in @state.
83-
* %MLO_AN_SGMII:
84-
* place the link in Cisco SGMII mode - there is no advertisment
85-
* to make as the PHY communicates the speed and duplex to the
86-
* MAC over the in-band control word. Configuration of the pause
87-
* mode is as per MLO_AN_PHY since this is not included.
79+
* %MLO_AN_INBAND:
80+
* place the link in an inband negotiation mode (such as
81+
* 1000base-X or Cisco SGMII mode depending on the phy interface
82+
* mode), advertising the parameters given in advertising in @state.
8883
*/
8984
void (*mac_config)(struct net_device *ndev, unsigned int mode,
9085
const struct phylink_link_state *state);

0 commit comments

Comments
 (0)