@@ -615,20 +615,22 @@ static enum xgbe_an xgbe_an73_page_received(struct xgbe_prv_data *pdata)
615
615
616
616
static enum xgbe_an xgbe_an73_incompat_link (struct xgbe_prv_data * pdata )
617
617
{
618
+ struct ethtool_link_ksettings * lks = & pdata -> phy .lks ;
619
+
618
620
/* Be sure we aren't looping trying to negotiate */
619
621
if (xgbe_in_kr_mode (pdata )) {
620
622
pdata -> kr_state = XGBE_RX_ERROR ;
621
623
622
- if (!( pdata -> phy . advertising & ADVERTISED_1000baseKX_Full ) &&
623
- !( pdata -> phy . advertising & ADVERTISED_2500baseX_Full ))
624
+ if (!XGBE_ADV ( lks , 1000b aseKX_Full ) &&
625
+ !XGBE_ADV ( lks , 2500b aseX_Full ))
624
626
return XGBE_AN_NO_LINK ;
625
627
626
628
if (pdata -> kx_state != XGBE_RX_BPA )
627
629
return XGBE_AN_NO_LINK ;
628
630
} else {
629
631
pdata -> kx_state = XGBE_RX_ERROR ;
630
632
631
- if (!( pdata -> phy . advertising & ADVERTISED_10000baseKR_Full ))
633
+ if (!XGBE_ADV ( lks , 10000b aseKR_Full ))
632
634
return XGBE_AN_NO_LINK ;
633
635
634
636
if (pdata -> kr_state != XGBE_RX_BPA )
@@ -944,18 +946,19 @@ static void xgbe_an_state_machine(struct work_struct *work)
944
946
945
947
static void xgbe_an37_init (struct xgbe_prv_data * pdata )
946
948
{
947
- unsigned int advertising , reg ;
949
+ struct ethtool_link_ksettings lks ;
950
+ unsigned int reg ;
948
951
949
- advertising = pdata -> phy_if .phy_impl .an_advertising (pdata );
952
+ pdata -> phy_if .phy_impl .an_advertising (pdata , & lks );
950
953
951
954
/* Set up Advertisement register */
952
955
reg = XMDIO_READ (pdata , MDIO_MMD_VEND2 , MDIO_VEND2_AN_ADVERTISE );
953
- if (advertising & ADVERTISED_Pause )
956
+ if (XGBE_ADV ( & lks , Pause ) )
954
957
reg |= 0x100 ;
955
958
else
956
959
reg &= ~0x100 ;
957
960
958
- if (advertising & ADVERTISED_Asym_Pause )
961
+ if (XGBE_ADV ( & lks , Asym_Pause ) )
959
962
reg |= 0x80 ;
960
963
else
961
964
reg &= ~0x80 ;
@@ -992,13 +995,14 @@ static void xgbe_an37_init(struct xgbe_prv_data *pdata)
992
995
993
996
static void xgbe_an73_init (struct xgbe_prv_data * pdata )
994
997
{
995
- unsigned int advertising , reg ;
998
+ struct ethtool_link_ksettings lks ;
999
+ unsigned int reg ;
996
1000
997
- advertising = pdata -> phy_if .phy_impl .an_advertising (pdata );
1001
+ pdata -> phy_if .phy_impl .an_advertising (pdata , & lks );
998
1002
999
1003
/* Set up Advertisement register 3 first */
1000
1004
reg = XMDIO_READ (pdata , MDIO_MMD_AN , MDIO_AN_ADVERTISE + 2 );
1001
- if (advertising & ADVERTISED_10000baseR_FEC )
1005
+ if (XGBE_ADV ( & lks , 10000b aseR_FEC ) )
1002
1006
reg |= 0xc000 ;
1003
1007
else
1004
1008
reg &= ~0xc000 ;
@@ -1007,13 +1011,13 @@ static void xgbe_an73_init(struct xgbe_prv_data *pdata)
1007
1011
1008
1012
/* Set up Advertisement register 2 next */
1009
1013
reg = XMDIO_READ (pdata , MDIO_MMD_AN , MDIO_AN_ADVERTISE + 1 );
1010
- if (advertising & ADVERTISED_10000baseKR_Full )
1014
+ if (XGBE_ADV ( & lks , 10000b aseKR_Full ) )
1011
1015
reg |= 0x80 ;
1012
1016
else
1013
1017
reg &= ~0x80 ;
1014
1018
1015
- if (( advertising & ADVERTISED_1000baseKX_Full ) ||
1016
- ( advertising & ADVERTISED_2500baseX_Full ))
1019
+ if (XGBE_ADV ( & lks , 1000b aseKX_Full ) ||
1020
+ XGBE_ADV ( & lks , 2500b aseX_Full ))
1017
1021
reg |= 0x20 ;
1018
1022
else
1019
1023
reg &= ~0x20 ;
@@ -1022,12 +1026,12 @@ static void xgbe_an73_init(struct xgbe_prv_data *pdata)
1022
1026
1023
1027
/* Set up Advertisement register 1 last */
1024
1028
reg = XMDIO_READ (pdata , MDIO_MMD_AN , MDIO_AN_ADVERTISE );
1025
- if (advertising & ADVERTISED_Pause )
1029
+ if (XGBE_ADV ( & lks , Pause ) )
1026
1030
reg |= 0x400 ;
1027
1031
else
1028
1032
reg &= ~0x400 ;
1029
1033
1030
- if (advertising & ADVERTISED_Asym_Pause )
1034
+ if (XGBE_ADV ( & lks , Asym_Pause ) )
1031
1035
reg |= 0x800 ;
1032
1036
else
1033
1037
reg &= ~0x800 ;
@@ -1283,9 +1287,10 @@ static enum xgbe_mode xgbe_phy_status_aneg(struct xgbe_prv_data *pdata)
1283
1287
1284
1288
static void xgbe_phy_status_result (struct xgbe_prv_data * pdata )
1285
1289
{
1290
+ struct ethtool_link_ksettings * lks = & pdata -> phy .lks ;
1286
1291
enum xgbe_mode mode ;
1287
1292
1288
- pdata -> phy . lp_advertising = 0 ;
1293
+ XGBE_ZERO_LP_ADV ( lks ) ;
1289
1294
1290
1295
if ((pdata -> phy .autoneg != AUTONEG_ENABLE ) || pdata -> parallel_detect )
1291
1296
mode = xgbe_cur_mode (pdata );
@@ -1515,17 +1520,21 @@ static void xgbe_dump_phy_registers(struct xgbe_prv_data *pdata)
1515
1520
1516
1521
static int xgbe_phy_best_advertised_speed (struct xgbe_prv_data * pdata )
1517
1522
{
1518
- if (pdata -> phy .advertising & ADVERTISED_10000baseKR_Full )
1523
+ struct ethtool_link_ksettings * lks = & pdata -> phy .lks ;
1524
+
1525
+ if (XGBE_ADV (lks , 10000b aseKR_Full ))
1519
1526
return SPEED_10000 ;
1520
- else if (pdata -> phy . advertising & ADVERTISED_10000baseT_Full )
1527
+ else if (XGBE_ADV ( lks , 10000b aseT_Full ) )
1521
1528
return SPEED_10000 ;
1522
- else if (pdata -> phy . advertising & ADVERTISED_2500baseX_Full )
1529
+ else if (XGBE_ADV ( lks , 2500b aseX_Full ) )
1523
1530
return SPEED_2500 ;
1524
- else if (pdata -> phy .advertising & ADVERTISED_1000baseKX_Full )
1531
+ else if (XGBE_ADV (lks , 2500b aseT_Full ))
1532
+ return SPEED_2500 ;
1533
+ else if (XGBE_ADV (lks , 1000b aseKX_Full ))
1525
1534
return SPEED_1000 ;
1526
- else if (pdata -> phy . advertising & ADVERTISED_1000baseT_Full )
1535
+ else if (XGBE_ADV ( lks , 1000b aseT_Full ) )
1527
1536
return SPEED_1000 ;
1528
- else if (pdata -> phy . advertising & ADVERTISED_100baseT_Full )
1537
+ else if (XGBE_ADV ( lks , 100b aseT_Full ) )
1529
1538
return SPEED_100 ;
1530
1539
1531
1540
return SPEED_UNKNOWN ;
@@ -1538,6 +1547,7 @@ static void xgbe_phy_exit(struct xgbe_prv_data *pdata)
1538
1547
1539
1548
static int xgbe_phy_init (struct xgbe_prv_data * pdata )
1540
1549
{
1550
+ struct ethtool_link_ksettings * lks = & pdata -> phy .lks ;
1541
1551
int ret ;
1542
1552
1543
1553
mutex_init (& pdata -> an_mutex );
@@ -1555,11 +1565,13 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata)
1555
1565
ret = pdata -> phy_if .phy_impl .init (pdata );
1556
1566
if (ret )
1557
1567
return ret ;
1558
- pdata -> phy .advertising = pdata -> phy .supported ;
1568
+
1569
+ /* Copy supported link modes to advertising link modes */
1570
+ XGBE_LM_COPY (lks , advertising , lks , supported );
1559
1571
1560
1572
pdata -> phy .address = 0 ;
1561
1573
1562
- if (pdata -> phy . advertising & ADVERTISED_Autoneg ) {
1574
+ if (XGBE_ADV ( lks , Autoneg ) ) {
1563
1575
pdata -> phy .autoneg = AUTONEG_ENABLE ;
1564
1576
pdata -> phy .speed = SPEED_UNKNOWN ;
1565
1577
pdata -> phy .duplex = DUPLEX_UNKNOWN ;
@@ -1576,16 +1588,21 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata)
1576
1588
pdata -> phy .rx_pause = pdata -> rx_pause ;
1577
1589
1578
1590
/* Fix up Flow Control advertising */
1579
- pdata -> phy . advertising &= ~ ADVERTISED_Pause ;
1580
- pdata -> phy . advertising &= ~ ADVERTISED_Asym_Pause ;
1591
+ XGBE_CLR_ADV ( lks , Pause ) ;
1592
+ XGBE_CLR_ADV ( lks , Asym_Pause ) ;
1581
1593
1582
1594
if (pdata -> rx_pause ) {
1583
- pdata -> phy . advertising |= ADVERTISED_Pause ;
1584
- pdata -> phy . advertising |= ADVERTISED_Asym_Pause ;
1595
+ XGBE_SET_ADV ( lks , Pause ) ;
1596
+ XGBE_SET_ADV ( lks , Asym_Pause ) ;
1585
1597
}
1586
1598
1587
- if (pdata -> tx_pause )
1588
- pdata -> phy .advertising ^= ADVERTISED_Asym_Pause ;
1599
+ if (pdata -> tx_pause ) {
1600
+ /* Equivalent to XOR of Asym_Pause */
1601
+ if (XGBE_ADV (lks , Asym_Pause ))
1602
+ XGBE_CLR_ADV (lks , Asym_Pause );
1603
+ else
1604
+ XGBE_SET_ADV (lks , Asym_Pause );
1605
+ }
1589
1606
1590
1607
if (netif_msg_drv (pdata ))
1591
1608
xgbe_dump_phy_registers (pdata );
0 commit comments