Skip to content

Commit 8d2681f

Browse files
committed
Merge branch 'net-phy-convert-advertise-and-supported-to-linkmode'
Andrew Lunn says: ==================== net: phy: convert advertise and supported to linkmode This is the last part in converting phylib to make use of a linux bitmap, not a u32, to represent links modes. This will allow support for PHYs > 1Gbps, which need to use link modes represented by a bit > 32. A number of MAC and PHY drivers need changes to support this. However the previous two patchesets reduced the number somewhat, the helpers which were introduced have been modified instead of the actual drivers. The follow on patches then make use of the extra bits, adding support for more link modes. Given how invasive this change is, i expect the build is broken for some architectures i did not test. I will fixup the breakage as fast as i can. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 899a3cb + cb6402f commit 8d2681f

File tree

41 files changed

+769
-370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+769
-370
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,8 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int port,
658658
if (phydev->asym_pause)
659659
rmt_adv |= LPA_PAUSE_ASYM;
660660

661-
lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
661+
lcl_adv = linkmode_adv_to_lcl_adv_t(
662+
phydev->advertising);
662663
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
663664

664665
if (flowctrl & FLOW_CTRL_TX)

drivers/net/ethernet/aeroflex/greth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static int greth_mdio_probe(struct net_device *dev)
12831283
else
12841284
phy_set_max_speed(phy, SPEED_100);
12851285

1286-
phy->advertising = phy->supported;
1286+
linkmode_copy(phy->advertising, phy->supported);
12871287

12881288
greth->link = 0;
12891289
greth->speed = 0;

drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ static void xgbe_phy_free_phy_device(struct xgbe_prv_data *pdata)
857857

858858
static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata)
859859
{
860+
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
860861
struct xgbe_phy_data *phy_data = pdata->phy_data;
861862
unsigned int phy_id = phy_data->phydev->phy_id;
862863

@@ -878,9 +879,15 @@ static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata)
878879
phy_write(phy_data->phydev, 0x04, 0x0d01);
879880
phy_write(phy_data->phydev, 0x00, 0x9140);
880881

881-
phy_data->phydev->supported = PHY_10BT_FEATURES |
882-
PHY_100BT_FEATURES |
883-
PHY_1000BT_FEATURES;
882+
linkmode_set_bit_array(phy_10_100_features_array,
883+
ARRAY_SIZE(phy_10_100_features_array),
884+
supported);
885+
linkmode_set_bit_array(phy_gbit_features_array,
886+
ARRAY_SIZE(phy_gbit_features_array),
887+
supported);
888+
889+
linkmode_copy(phy_data->phydev->supported, supported);
890+
884891
phy_support_asym_pause(phy_data->phydev);
885892

886893
netif_dbg(pdata, drv, pdata->netdev,
@@ -891,6 +898,7 @@ static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata)
891898

892899
static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata)
893900
{
901+
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
894902
struct xgbe_phy_data *phy_data = pdata->phy_data;
895903
struct xgbe_sfp_eeprom *sfp_eeprom = &phy_data->sfp_eeprom;
896904
unsigned int phy_id = phy_data->phydev->phy_id;
@@ -951,9 +959,13 @@ static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata)
951959
reg = phy_read(phy_data->phydev, 0x00);
952960
phy_write(phy_data->phydev, 0x00, reg & ~0x00800);
953961

954-
phy_data->phydev->supported = (PHY_10BT_FEATURES |
955-
PHY_100BT_FEATURES |
956-
PHY_1000BT_FEATURES);
962+
linkmode_set_bit_array(phy_10_100_features_array,
963+
ARRAY_SIZE(phy_10_100_features_array),
964+
supported);
965+
linkmode_set_bit_array(phy_gbit_features_array,
966+
ARRAY_SIZE(phy_gbit_features_array),
967+
supported);
968+
linkmode_copy(phy_data->phydev->supported, supported);
957969
phy_support_asym_pause(phy_data->phydev);
958970

959971
netif_dbg(pdata, drv, pdata->netdev,
@@ -976,7 +988,6 @@ static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata)
976988
struct ethtool_link_ksettings *lks = &pdata->phy.lks;
977989
struct xgbe_phy_data *phy_data = pdata->phy_data;
978990
struct phy_device *phydev;
979-
u32 advertising;
980991
int ret;
981992

982993
/* If we already have a PHY, just return */
@@ -1036,9 +1047,8 @@ static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata)
10361047

10371048
xgbe_phy_external_phy_quirks(pdata);
10381049

1039-
ethtool_convert_link_mode_to_legacy_u32(&advertising,
1040-
lks->link_modes.advertising);
1041-
phydev->advertising &= advertising;
1050+
linkmode_and(phydev->advertising, phydev->advertising,
1051+
lks->link_modes.advertising);
10421052

10431053
phy_start_aneg(phy_data->phydev);
10441054

@@ -1497,7 +1507,7 @@ static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata)
14971507
if (!phy_data->phydev)
14981508
return;
14991509

1500-
lcl_adv = ethtool_adv_to_lcl_adv_t(phy_data->phydev->advertising);
1510+
lcl_adv = linkmode_adv_to_lcl_adv_t(phy_data->phydev->advertising);
15011511

15021512
if (phy_data->phydev->pause) {
15031513
XGBE_SET_LP_ADV(lks, Pause);
@@ -1815,7 +1825,6 @@ static int xgbe_phy_an_config(struct xgbe_prv_data *pdata)
18151825
{
18161826
struct ethtool_link_ksettings *lks = &pdata->phy.lks;
18171827
struct xgbe_phy_data *phy_data = pdata->phy_data;
1818-
u32 advertising;
18191828
int ret;
18201829

18211830
ret = xgbe_phy_find_phy_device(pdata);
@@ -1825,12 +1834,10 @@ static int xgbe_phy_an_config(struct xgbe_prv_data *pdata)
18251834
if (!phy_data->phydev)
18261835
return 0;
18271836

1828-
ethtool_convert_link_mode_to_legacy_u32(&advertising,
1829-
lks->link_modes.advertising);
1830-
18311837
phy_data->phydev->autoneg = pdata->phy.autoneg;
1832-
phy_data->phydev->advertising = phy_data->phydev->supported &
1833-
advertising;
1838+
linkmode_and(phy_data->phydev->advertising,
1839+
phy_data->phydev->supported,
1840+
lks->link_modes.advertising);
18341841

18351842
if (pdata->phy.autoneg != AUTONEG_ENABLE) {
18361843
phy_data->phydev->speed = pdata->phy.speed;

drivers/net/ethernet/apm/xgene-v2/mdio.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void xge_mdio_remove(struct net_device *ndev)
109109

110110
int xge_mdio_config(struct net_device *ndev)
111111
{
112+
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
112113
struct xge_pdata *pdata = netdev_priv(ndev);
113114
struct device *dev = &pdata->pdev->dev;
114115
struct mii_bus *mdio_bus;
@@ -148,16 +149,17 @@ int xge_mdio_config(struct net_device *ndev)
148149
goto err;
149150
}
150151

151-
phydev->supported &= ~(SUPPORTED_10baseT_Half |
152-
SUPPORTED_10baseT_Full |
153-
SUPPORTED_100baseT_Half |
154-
SUPPORTED_100baseT_Full |
155-
SUPPORTED_1000baseT_Half |
156-
SUPPORTED_AUI |
157-
SUPPORTED_MII |
158-
SUPPORTED_FIBRE |
159-
SUPPORTED_BNC);
160-
phydev->advertising = phydev->supported;
152+
linkmode_set_bit_array(phy_10_100_features_array,
153+
ARRAY_SIZE(phy_10_100_features_array),
154+
mask);
155+
linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, mask);
156+
linkmode_set_bit(ETHTOOL_LINK_MODE_AUI_BIT, mask);
157+
linkmode_set_bit(ETHTOOL_LINK_MODE_MII_BIT, mask);
158+
linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, mask);
159+
linkmode_set_bit(ETHTOOL_LINK_MODE_BNC_BIT, mask);
160+
161+
linkmode_andnot(phydev->supported, phydev->supported, mask);
162+
linkmode_copy(phydev->advertising, phydev->supported);
161163
pdata->phy_speed = SPEED_UNKNOWN;
162164

163165
return 0;

drivers/net/ethernet/arc/emac_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ static int arc_emac_open(struct net_device *ndev)
432432
phy_dev->autoneg = AUTONEG_ENABLE;
433433
phy_dev->speed = 0;
434434
phy_dev->duplex = 0;
435-
phy_dev->advertising &= phy_dev->supported;
435+
linkmode_and(phy_dev->advertising, phy_dev->advertising,
436+
phy_dev->supported);
436437

437438
priv->last_rx_bd = 0;
438439

drivers/net/ethernet/broadcom/b44.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ static void b44_adjust_link(struct net_device *dev)
22482248

22492249
static int b44_register_phy_one(struct b44 *bp)
22502250
{
2251+
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
22512252
struct mii_bus *mii_bus;
22522253
struct ssb_device *sdev = bp->sdev;
22532254
struct phy_device *phydev;
@@ -2303,11 +2304,12 @@ static int b44_register_phy_one(struct b44 *bp)
23032304
}
23042305

23052306
/* mask with MAC supported features */
2306-
phydev->supported &= (SUPPORTED_100baseT_Half |
2307-
SUPPORTED_100baseT_Full |
2308-
SUPPORTED_Autoneg |
2309-
SUPPORTED_MII);
2310-
phydev->advertising = phydev->supported;
2307+
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask);
2308+
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, mask);
2309+
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, mask);
2310+
linkmode_set_bit(ETHTOOL_LINK_MODE_MII_BIT, mask);
2311+
linkmode_and(phydev->supported, phydev->supported, mask);
2312+
linkmode_copy(phydev->advertising, phydev->supported);
23112313

23122314
bp->old_link = 0;
23132315
bp->phy_addr = phydev->mdio.addr;

drivers/net/ethernet/broadcom/genet/bcmmii.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
226226
* capabilities, use that knowledge to also configure the
227227
* Reverse MII interface correctly.
228228
*/
229-
if (dev->phydev->supported & PHY_1000BT_FEATURES)
229+
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
230+
dev->phydev->supported))
230231
port_ctrl = PORT_MODE_EXT_RVMII_50;
231232
else
232233
port_ctrl = PORT_MODE_EXT_RVMII_25;
@@ -317,7 +318,7 @@ int bcmgenet_mii_probe(struct net_device *dev)
317318
return ret;
318319
}
319320

320-
phydev->advertising = phydev->supported;
321+
linkmode_copy(phydev->advertising, phydev->supported);
321322

322323
/* The internal PHY has its link interrupts routed to the
323324
* Ethernet MAC ISRs. On GENETv5 there is a hardware issue

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,8 @@ static void tg3_phy_start(struct tg3 *tp)
21572157
phydev->speed = tp->link_config.speed;
21582158
phydev->duplex = tp->link_config.duplex;
21592159
phydev->autoneg = tp->link_config.autoneg;
2160-
phydev->advertising = tp->link_config.advertising;
2160+
ethtool_convert_legacy_u32_to_link_mode(
2161+
phydev->advertising, tp->link_config.advertising);
21612162
}
21622163

21632164
phy_start(phydev);
@@ -4057,8 +4058,9 @@ static int tg3_power_down_prepare(struct tg3 *tp)
40574058
do_low_power = false;
40584059
if ((tp->phy_flags & TG3_PHYFLG_IS_CONNECTED) &&
40594060
!(tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)) {
4061+
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising) = { 0, };
40604062
struct phy_device *phydev;
4061-
u32 phyid, advertising;
4063+
u32 phyid;
40624064

40634065
phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr);
40644066

@@ -4067,25 +4069,33 @@ static int tg3_power_down_prepare(struct tg3 *tp)
40674069
tp->link_config.speed = phydev->speed;
40684070
tp->link_config.duplex = phydev->duplex;
40694071
tp->link_config.autoneg = phydev->autoneg;
4070-
tp->link_config.advertising = phydev->advertising;
4071-
4072-
advertising = ADVERTISED_TP |
4073-
ADVERTISED_Pause |
4074-
ADVERTISED_Autoneg |
4075-
ADVERTISED_10baseT_Half;
4072+
ethtool_convert_link_mode_to_legacy_u32(
4073+
&tp->link_config.advertising,
4074+
phydev->advertising);
4075+
4076+
linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, advertising);
4077+
linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT,
4078+
advertising);
4079+
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
4080+
advertising);
4081+
linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
4082+
advertising);
40764083

40774084
if (tg3_flag(tp, ENABLE_ASF) || device_should_wake) {
4078-
if (tg3_flag(tp, WOL_SPEED_100MB))
4079-
advertising |=
4080-
ADVERTISED_100baseT_Half |
4081-
ADVERTISED_100baseT_Full |
4082-
ADVERTISED_10baseT_Full;
4083-
else
4084-
advertising |= ADVERTISED_10baseT_Full;
4085+
if (tg3_flag(tp, WOL_SPEED_100MB)) {
4086+
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
4087+
advertising);
4088+
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
4089+
advertising);
4090+
linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
4091+
advertising);
4092+
} else {
4093+
linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
4094+
advertising);
4095+
}
40854096
}
40864097

4087-
phydev->advertising = advertising;
4088-
4098+
linkmode_copy(phydev->advertising, advertising);
40894099
phy_start_aneg(phydev);
40904100

40914101
phyid = phydev->drv->phy_id & phydev->drv->phy_id_mask;

drivers/net/ethernet/cavium/octeon/octeon_mgmt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,11 @@ static int octeon_mgmt_open(struct net_device *netdev)
10801080
/* Set the mode of the interface, RGMII/MII. */
10811081
if (OCTEON_IS_MODEL(OCTEON_CN6XXX) && netdev->phydev) {
10821082
union cvmx_agl_prtx_ctl agl_prtx_ctl;
1083-
int rgmii_mode = (netdev->phydev->supported &
1084-
(SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)) != 0;
1083+
int rgmii_mode =
1084+
(linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
1085+
netdev->phydev->supported) |
1086+
linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
1087+
netdev->phydev->supported)) != 0;
10851088

10861089
agl_prtx_ctl.u64 = cvmx_read_csr(p->agl_prt_ctl);
10871090
agl_prtx_ctl.s.mode = rgmii_mode ? 0 : 1;

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,7 @@ static void dpaa_adjust_link(struct net_device *net_dev)
24752475

24762476
static int dpaa_phy_init(struct net_device *net_dev)
24772477
{
2478+
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
24782479
struct mac_device *mac_dev;
24792480
struct phy_device *phy_dev;
24802481
struct dpaa_priv *priv;
@@ -2491,7 +2492,9 @@ static int dpaa_phy_init(struct net_device *net_dev)
24912492
}
24922493

24932494
/* Remove any features not supported by the controller */
2494-
phy_dev->supported &= mac_dev->if_support;
2495+
ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support);
2496+
linkmode_and(phy_dev->supported, phy_dev->supported, mask);
2497+
24952498
phy_support_asym_pause(phy_dev);
24962499

24972500
mac_dev->phy_dev = phy_dev;

drivers/net/ethernet/freescale/fman/mac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
393393
*/
394394

395395
/* get local capabilities */
396-
lcl_adv = ethtool_adv_to_lcl_adv_t(phy_dev->advertising);
396+
lcl_adv = linkmode_adv_to_lcl_adv_t(phy_dev->advertising);
397397

398398
/* get link partner capabilities */
399399
rmt_adv = 0;

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,14 +1784,20 @@ static phy_interface_t gfar_get_interface(struct net_device *dev)
17841784
*/
17851785
static int init_phy(struct net_device *dev)
17861786
{
1787+
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
17871788
struct gfar_private *priv = netdev_priv(dev);
1788-
uint gigabit_support =
1789-
priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
1790-
GFAR_SUPPORTED_GBIT : 0;
17911789
phy_interface_t interface;
17921790
struct phy_device *phydev;
17931791
struct ethtool_eee edata;
17941792

1793+
linkmode_set_bit_array(phy_10_100_features_array,
1794+
ARRAY_SIZE(phy_10_100_features_array),
1795+
mask);
1796+
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, mask);
1797+
linkmode_set_bit(ETHTOOL_LINK_MODE_MII_BIT, mask);
1798+
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT)
1799+
linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, mask);
1800+
17951801
priv->oldlink = 0;
17961802
priv->oldspeed = 0;
17971803
priv->oldduplex = -1;
@@ -1809,8 +1815,8 @@ static int init_phy(struct net_device *dev)
18091815
gfar_configure_serdes(dev);
18101816

18111817
/* Remove any features not supported by the controller */
1812-
phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
1813-
phydev->advertising = phydev->supported;
1818+
linkmode_and(phydev->supported, phydev->supported, mask);
1819+
linkmode_copy(phydev->advertising, phydev->supported);
18141820

18151821
/* Add support for flow control */
18161822
phy_support_asym_pause(phydev);
@@ -3656,7 +3662,7 @@ static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
36563662
if (phydev->asym_pause)
36573663
rmt_adv |= LPA_PAUSE_ASYM;
36583664

3659-
lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
3665+
lcl_adv = linkmode_adv_to_lcl_adv_t(phydev->advertising);
36603666
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
36613667
if (flowctrl & FLOW_CTRL_TX)
36623668
val |= MACCFG1_TX_FLOW;

drivers/net/ethernet/freescale/ucc_geth.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,12 +1742,7 @@ static int init_phy(struct net_device *dev)
17421742
if (priv->phy_interface == PHY_INTERFACE_MODE_SGMII)
17431743
uec_configure_serdes(dev);
17441744

1745-
phy_set_max_speed(phydev, SPEED_100);
1746-
1747-
if (priv->max_speed == SPEED_1000)
1748-
phydev->supported |= ADVERTISED_1000baseT_Full;
1749-
1750-
phydev->advertising = phydev->supported;
1745+
phy_set_max_speed(phydev, priv->max_speed);
17511746

17521747
priv->phydev = phydev;
17531748

0 commit comments

Comments
 (0)