History

Merge branch 'amd-xgbe-next'

Tom Lendacky says: ==================== amd-xgbe: AMD XGBE driver updates 2018-05-21 The following updates are included in this driver update series: - Fix the debug output for the max channels count - Read (once) and save the port property registers during probe - Remove the use of the comm_owned field - Remove unused SFP diagnostic support indicator field - Add ethtool --module-info support - Add ethtool --show-ring/--set-ring support - Update the driver in preparation for ethtool --set-channels support - Add ethtool --show-channels/--set-channels support - Update the driver to always perform link training in KR mode - Advertise FEC support when using a KR re-driver - Update the BelFuse quirk to now support SGMII - Improve 100Mbps auto-negotiation for BelFuse parts This patch series is based on net-next. --- Changes since v1: - Update the --set-channels support to the use of the combined, rx and tx options as specified in the ethtool man page (in other words, don't create combined channels based on the min of the tx and rx channels specified). ====================

David S. Miller committed 8 years ago

Commit 7c08c412 parents 50b464b 76cce0a7 files · +699 −258Browse files

Unified · Split

7 files
  1. drivers/net/ethernet/amd/xgbe/xgbe-drv.c +92 −45
  2. drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +217 −0
  3. drivers/net/ethernet/amd/xgbe/xgbe-main.c +1 −19
  4. drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +80 −87
  5. drivers/net/ethernet/amd/xgbe/xgbe-pci.c +27 −9
  6. drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c +251 −98
  7. drivers/net/ethernet/amd/xgbe/xgbe.h +31 −0
drivers/net/ethernet/amd/xgbe/xgbe-drv.c+92−45
@@ -1312,14 +1312,83 @@ int xgbe_powerup(struct net_device *netdev, unsigned int caller) · 1311 unmodified lines
1312 return 0;1312 return 0;
1313}1313}
1314 1314
1315static void xgbe_free_memory(struct xgbe_prv_data *pdata)
1316{
1317 struct xgbe_desc_if *desc_if = &pdata->desc_if;
1318
1319 /* Free the ring descriptors and buffers */
1320 desc_if->free_ring_resources(pdata);
1321
1322 /* Free the channel and ring structures */
1323 xgbe_free_channels(pdata);
1324}
1325
1326static int xgbe_alloc_memory(struct xgbe_prv_data *pdata)
1327{
1328 struct xgbe_desc_if *desc_if = &pdata->desc_if;
1329 struct net_device *netdev = pdata->netdev;
1330 int ret;
1331
1332 if (pdata->new_tx_ring_count) {
1333 pdata->tx_ring_count = pdata->new_tx_ring_count;
1334 pdata->tx_q_count = pdata->tx_ring_count;
1335 pdata->new_tx_ring_count = 0;
1336 }
1337
1338 if (pdata->new_rx_ring_count) {
1339 pdata->rx_ring_count = pdata->new_rx_ring_count;
1340 pdata->new_rx_ring_count = 0;
1341 }
1342
1343 /* Calculate the Rx buffer size before allocating rings */
1344 pdata->rx_buf_size = xgbe_calc_rx_buf_size(netdev, netdev->mtu);
1345
1346 /* Allocate the channel and ring structures */
1347 ret = xgbe_alloc_channels(pdata);
1348 if (ret)
1349 return ret;
1350
1351 /* Allocate the ring descriptors and buffers */
1352 ret = desc_if->alloc_ring_resources(pdata);
1353 if (ret)
1354 goto err_channels;
1355
1356 /* Initialize the service and Tx timers */
1357 xgbe_init_timers(pdata);
1358
1359 return 0;
1360
1361err_channels:
1362 xgbe_free_memory(pdata);
1363
1364 return ret;
1365}
1366
1315static int xgbe_start(struct xgbe_prv_data *pdata)1367static int xgbe_start(struct xgbe_prv_data *pdata)
1316{1368{
1317 struct xgbe_hw_if *hw_if = &pdata->hw_if;1369 struct xgbe_hw_if *hw_if = &pdata->hw_if;
1318 struct xgbe_phy_if *phy_if = &pdata->phy_if;1370 struct xgbe_phy_if *phy_if = &pdata->phy_if;
1319 struct net_device *netdev = pdata->netdev;1371 struct net_device *netdev = pdata->netdev;
1372 unsigned int i;
1320 int ret;1373 int ret;
1321 1374
1322 DBGPR("-->xgbe_start\n");1375 /* Set the number of queues */
1376 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count);
1377 if (ret) {
1378 netdev_err(netdev, "error setting real tx queue count\n");
1379 return ret;
1380 }
1381
1382 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count);
1383 if (ret) {
1384 netdev_err(netdev, "error setting real rx queue count\n");
1385 return ret;
1386 }
1387
1388 /* Set RSS lookup table data for programming */
1389 for (i = 0; i < XGBE_RSS_MAX_TABLE_SIZE; i++)
1390 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH,
1391 i % pdata->rx_ring_count);
1323 1392
1324 ret = hw_if->init(pdata);1393 ret = hw_if->init(pdata);
1325 if (ret)1394 if (ret)
@@ -1347,8 +1416,6 @@ static int xgbe_start(struct xgbe_prv_data *pdata) · 21 unmodified lines
1347 1416
1348 clear_bit(XGBE_STOPPED, &pdata->dev_state);1417 clear_bit(XGBE_STOPPED, &pdata->dev_state);
1349 1418
1350 DBGPR("<--xgbe_start\n");
1351
1352 return 0;1419 return 0;
1353 1420
1354err_irqs:1421err_irqs:
@@ -1426,10 +1493,22 @@ static void xgbe_stopdev(struct work_struct *work) · 71 unmodified lines
1426 netdev_alert(pdata->netdev, "device stopped\n");1493 netdev_alert(pdata->netdev, "device stopped\n");
1427}1494}
1428 1495
1429static void xgbe_restart_dev(struct xgbe_prv_data *pdata)1496void xgbe_full_restart_dev(struct xgbe_prv_data *pdata)
1430{1497{
1431 DBGPR("-->xgbe_restart_dev\n");1498 /* If not running, "restart" will happen on open */
1499 if (!netif_running(pdata->netdev))
1500 return;
1501
1502 xgbe_stop(pdata);
1503
1504 xgbe_free_memory(pdata);
1505 xgbe_alloc_memory(pdata);
1506
1507 xgbe_start(pdata);
1508}
1432 1509
1510void xgbe_restart_dev(struct xgbe_prv_data *pdata)
1511{
1433 /* If not running, "restart" will happen on open */1512 /* If not running, "restart" will happen on open */
1434 if (!netif_running(pdata->netdev))1513 if (!netif_running(pdata->netdev))
1435 return;1514 return;
@@ -1440,8 +1519,6 @@ static void xgbe_restart_dev(struct xgbe_prv_data *pdata) · 4 unmodified lines
1440 xgbe_free_rx_data(pdata);1519 xgbe_free_rx_data(pdata);
1441 1520
1442 xgbe_start(pdata);1521 xgbe_start(pdata);
1443
1444 DBGPR("<--xgbe_restart_dev\n");
1445}1522}
1446 1523
1447static void xgbe_restart(struct work_struct *work)1524static void xgbe_restart(struct work_struct *work)
@@ -1827,11 +1904,8 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata, · 379 unmodified lines
1827static int xgbe_open(struct net_device *netdev)1904static int xgbe_open(struct net_device *netdev)
1828{1905{
1829 struct xgbe_prv_data *pdata = netdev_priv(netdev);1906 struct xgbe_prv_data *pdata = netdev_priv(netdev);
1830 struct xgbe_desc_if *desc_if = &pdata->desc_if;
1831 int ret;1907 int ret;
1832 1908
1833 DBGPR("-->xgbe_open\n");
1834
1835 /* Create the various names based on netdev name */1909 /* Create the various names based on netdev name */
1836 snprintf(pdata->an_name, sizeof(pdata->an_name) - 1, "%s-pcs",1910 snprintf(pdata->an_name, sizeof(pdata->an_name) - 1, "%s-pcs",
1837 netdev_name(netdev));1911 netdev_name(netdev));
@@ -1876,43 +1950,25 @@ static int xgbe_open(struct net_device *netdev) · 38 unmodified lines
1876 goto err_sysclk;1950 goto err_sysclk;
1877 }1951 }
1878 1952
1879 /* Calculate the Rx buffer size before allocating rings */
1880 ret = xgbe_calc_rx_buf_size(netdev, netdev->mtu);
1881 if (ret < 0)
1882 goto err_ptpclk;
1883 pdata->rx_buf_size = ret;
1884
1885 /* Allocate the channel and ring structures */
1886 ret = xgbe_alloc_channels(pdata);
1887 if (ret)
1888 goto err_ptpclk;
1889
1890 /* Allocate the ring descriptors and buffers */
1891 ret = desc_if->alloc_ring_resources(pdata);
1892 if (ret)
1893 goto err_channels;
1894
1895 INIT_WORK(&pdata->service_work, xgbe_service);1953 INIT_WORK(&pdata->service_work, xgbe_service);
1896 INIT_WORK(&pdata->restart_work, xgbe_restart);1954 INIT_WORK(&pdata->restart_work, xgbe_restart);
1897 INIT_WORK(&pdata->stopdev_work, xgbe_stopdev);1955 INIT_WORK(&pdata->stopdev_work, xgbe_stopdev);
1898 INIT_WORK(&pdata->tx_tstamp_work, xgbe_tx_tstamp);1956 INIT_WORK(&pdata->tx_tstamp_work, xgbe_tx_tstamp);
1899 xgbe_init_timers(pdata);1957
1958 ret = xgbe_alloc_memory(pdata);
1959 if (ret)
1960 goto err_ptpclk;
1900 1961
1901 ret = xgbe_start(pdata);1962 ret = xgbe_start(pdata);
1902 if (ret)1963 if (ret)
1903 goto err_rings;1964 goto err_mem;
1904 1965
1905 clear_bit(XGBE_DOWN, &pdata->dev_state);1966 clear_bit(XGBE_DOWN, &pdata->dev_state);
1906 1967
1907 DBGPR("<--xgbe_open\n");
1908
1909 return 0;1968 return 0;
1910 1969
1911err_rings:1970err_mem:
1912 desc_if->free_ring_resources(pdata);1971 xgbe_free_memory(pdata);
1913
1914err_channels:
1915 xgbe_free_channels(pdata);
1916 1972
1917err_ptpclk:1973err_ptpclk:
1918 clk_disable_unprepare(pdata->ptpclk);1974 clk_disable_unprepare(pdata->ptpclk);
@@ -1932,18 +1988,11 @@ err_dev_wq: · 13 unmodified lines
1932static int xgbe_close(struct net_device *netdev)1988static int xgbe_close(struct net_device *netdev)
1933{1989{
1934 struct xgbe_prv_data *pdata = netdev_priv(netdev);1990 struct xgbe_prv_data *pdata = netdev_priv(netdev);
1935 struct xgbe_desc_if *desc_if = &pdata->desc_if;
1936
1937 DBGPR("-->xgbe_close\n");
1938 1991
1939 /* Stop the device */1992 /* Stop the device */
1940 xgbe_stop(pdata);1993 xgbe_stop(pdata);
1941 1994
1942 /* Free the ring descriptors and buffers */1995 xgbe_free_memory(pdata);
1943 desc_if->free_ring_resources(pdata);
1944
1945 /* Free the channel and ring structures */
1946 xgbe_free_channels(pdata);
1947 1996
1948 /* Disable the clocks */1997 /* Disable the clocks */
1949 clk_disable_unprepare(pdata->ptpclk);1998 clk_disable_unprepare(pdata->ptpclk);
@@ -1957,8 +2006,6 @@ static int xgbe_close(struct net_device *netdev) · 7 unmodified lines
1957 2006
1958 set_bit(XGBE_DOWN, &pdata->dev_state);2007 set_bit(XGBE_DOWN, &pdata->dev_state);
1959 2008
1960 DBGPR("<--xgbe_close\n");
1961
1962 return 0;2009 return 0;
1963}2010}
1964 2011
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c+217−0
@@ -626,6 +626,217 @@ static int xgbe_get_ts_info(struct net_device *netdev, · 625 unmodified lines
626 return 0;626 return 0;
627}627}
628 628
629static int xgbe_get_module_info(struct net_device *netdev,
630 struct ethtool_modinfo *modinfo)
631{
632 struct xgbe_prv_data *pdata = netdev_priv(netdev);
633
634 return pdata->phy_if.module_info(pdata, modinfo);
635}
636
637static int xgbe_get_module_eeprom(struct net_device *netdev,
638 struct ethtool_eeprom *eeprom, u8 *data)
639{
640 struct xgbe_prv_data *pdata = netdev_priv(netdev);
641
642 return pdata->phy_if.module_eeprom(pdata, eeprom, data);
643}
644
645static void xgbe_get_ringparam(struct net_device *netdev,
646 struct ethtool_ringparam *ringparam)
647{
648 struct xgbe_prv_data *pdata = netdev_priv(netdev);
649
650 ringparam->rx_max_pending = XGBE_RX_DESC_CNT_MAX;
651 ringparam->tx_max_pending = XGBE_TX_DESC_CNT_MAX;
652 ringparam->rx_pending = pdata->rx_desc_count;
653 ringparam->tx_pending = pdata->tx_desc_count;
654}
655
656static int xgbe_set_ringparam(struct net_device *netdev,
657 struct ethtool_ringparam *ringparam)
658{
659 struct xgbe_prv_data *pdata = netdev_priv(netdev);
660 unsigned int rx, tx;
661
662 if (ringparam->rx_mini_pending || ringparam->rx_jumbo_pending) {
663 netdev_err(netdev, "unsupported ring parameter\n");
664 return -EINVAL;
665 }
666
667 if ((ringparam->rx_pending < XGBE_RX_DESC_CNT_MIN) ||
668 (ringparam->rx_pending > XGBE_RX_DESC_CNT_MAX)) {
669 netdev_err(netdev,
670 "rx ring parameter must be between %u and %u\n",
671 XGBE_RX_DESC_CNT_MIN, XGBE_RX_DESC_CNT_MAX);
672 return -EINVAL;
673 }
674
675 if ((ringparam->tx_pending < XGBE_TX_DESC_CNT_MIN) ||
676 (ringparam->tx_pending > XGBE_TX_DESC_CNT_MAX)) {
677 netdev_err(netdev,
678 "tx ring parameter must be between %u and %u\n",
679 XGBE_TX_DESC_CNT_MIN, XGBE_TX_DESC_CNT_MAX);
680 return -EINVAL;
681 }
682
683 rx = __rounddown_pow_of_two(ringparam->rx_pending);
684 if (rx != ringparam->rx_pending)
685 netdev_notice(netdev,
686 "rx ring parameter rounded to power of two: %u\n",
687 rx);
688
689 tx = __rounddown_pow_of_two(ringparam->tx_pending);
690 if (tx != ringparam->tx_pending)
691 netdev_notice(netdev,
692 "tx ring parameter rounded to power of two: %u\n",
693 tx);
694
695 if ((rx == pdata->rx_desc_count) &&
696 (tx == pdata->tx_desc_count))
697 goto out;
698
699 pdata->rx_desc_count = rx;
700 pdata->tx_desc_count = tx;
701
702 xgbe_restart_dev(pdata);
703
704out:
705 return 0;
706}
707
708static void xgbe_get_channels(struct net_device *netdev,
709 struct ethtool_channels *channels)
710{
711 struct xgbe_prv_data *pdata = netdev_priv(netdev);
712 unsigned int rx, tx, combined;
713
714 /* Calculate maximums allowed:
715 * - Take into account the number of available IRQs
716 * - Do not take into account the number of online CPUs so that
717 * the user can over-subscribe if desired
718 * - Tx is additionally limited by the number of hardware queues
719 */
720 rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count);
721 rx = min(rx, pdata->channel_irq_count);
722 tx = min(pdata->hw_feat.tx_ch_cnt, pdata->tx_max_channel_count);
723 tx = min(tx, pdata->channel_irq_count);
724 tx = min(tx, pdata->tx_max_q_count);
725
726 combined = min(rx, tx);
727
728 channels->max_combined = combined;
729 channels->max_rx = rx ? rx - 1 : 0;
730 channels->max_tx = tx ? tx - 1 : 0;
731
732 /* Get current settings based on device state */
733 rx = pdata->new_rx_ring_count ? : pdata->rx_ring_count;
734 tx = pdata->new_tx_ring_count ? : pdata->tx_ring_count;
735
736 combined = min(rx, tx);
737 rx -= combined;
738 tx -= combined;
739
740 channels->combined_count = combined;
741 channels->rx_count = rx;
742 channels->tx_count = tx;
743}
744
745static void xgbe_print_set_channels_input(struct net_device *netdev,
746 struct ethtool_channels *channels)
747{
748 netdev_err(netdev, "channel inputs: combined=%u, rx-only=%u, tx-only=%u\n",
749 channels->combined_count, channels->rx_count,
750 channels->tx_count);
751}
752
753static int xgbe_set_channels(struct net_device *netdev,
754 struct ethtool_channels *channels)
755{
756 struct xgbe_prv_data *pdata = netdev_priv(netdev);
757 unsigned int rx, rx_curr, tx, tx_curr, combined;
758
759 /* Calculate maximums allowed:
760 * - Take into account the number of available IRQs
761 * - Do not take into account the number of online CPUs so that
762 * the user can over-subscribe if desired
763 * - Tx is additionally limited by the number of hardware queues
764 */
765 rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count);
766 rx = min(rx, pdata->channel_irq_count);
767 tx = min(pdata->hw_feat.tx_ch_cnt, pdata->tx_max_channel_count);
768 tx = min(tx, pdata->tx_max_q_count);
769 tx = min(tx, pdata->channel_irq_count);
770
771 combined = min(rx, tx);
772
773 /* Should not be setting other count */
774 if (channels->other_count) {
775 netdev_err(netdev,
776 "other channel count must be zero\n");
777 return -EINVAL;
778 }
779
780 /* Require at least one Combined (Rx and Tx) channel */
781 if (!channels->combined_count) {
782 netdev_err(netdev,
783 "at least one combined Rx/Tx channel is required\n");
784 xgbe_print_set_channels_input(netdev, channels);
785 return -EINVAL;
786 }
787
788 /* Check combined channels */
789 if (channels->combined_count > combined) {
790 netdev_err(netdev,
791 "combined channel count cannot exceed %u\n",
792 combined);
793 xgbe_print_set_channels_input(netdev, channels);
794 return -EINVAL;
795 }
796
797 /* Can have some Rx-only or Tx-only channels, but not both */
798 if (channels->rx_count && channels->tx_count) {
799 netdev_err(netdev,
800 "cannot specify both Rx-only and Tx-only channels\n");
801 xgbe_print_set_channels_input(netdev, channels);
802 return -EINVAL;
803 }
804
805 /* Check that we don't exceed the maximum number of channels */
806 if ((channels->combined_count + channels->rx_count) > rx) {
807 netdev_err(netdev,
808 "total Rx channels (%u) requested exceeds maximum available (%u)\n",
809 channels->combined_count + channels->rx_count, rx);
810 xgbe_print_set_channels_input(netdev, channels);
811 return -EINVAL;
812 }
813
814 if ((channels->combined_count + channels->tx_count) > tx) {
815 netdev_err(netdev,
816 "total Tx channels (%u) requested exceeds maximum available (%u)\n",
817 channels->combined_count + channels->tx_count, tx);
818 xgbe_print_set_channels_input(netdev, channels);
819 return -EINVAL;
820 }
821
822 rx = channels->combined_count + channels->rx_count;
823 tx = channels->combined_count + channels->tx_count;
824
825 rx_curr = pdata->new_rx_ring_count ? : pdata->rx_ring_count;
826 tx_curr = pdata->new_tx_ring_count ? : pdata->tx_ring_count;
827
828 if ((rx == rx_curr) && (tx == tx_curr))
829 goto out;
830
831 pdata->new_rx_ring_count = rx;
832 pdata->new_tx_ring_count = tx;
833
834 xgbe_full_restart_dev(pdata);
835
836out:
837 return 0;
838}
839
629static const struct ethtool_ops xgbe_ethtool_ops = {840static const struct ethtool_ops xgbe_ethtool_ops = {
630 .get_drvinfo = xgbe_get_drvinfo,841 .get_drvinfo = xgbe_get_drvinfo,
631 .get_msglevel = xgbe_get_msglevel,842 .get_msglevel = xgbe_get_msglevel,
@@ -646,6 +857,12 @@ static const struct ethtool_ops xgbe_ethtool_ops = { · 14 unmodified lines
646 .get_ts_info = xgbe_get_ts_info,857 .get_ts_info = xgbe_get_ts_info,
647 .get_link_ksettings = xgbe_get_link_ksettings,858 .get_link_ksettings = xgbe_get_link_ksettings,
648 .set_link_ksettings = xgbe_set_link_ksettings,859 .set_link_ksettings = xgbe_set_link_ksettings,
860 .get_module_info = xgbe_get_module_info,
861 .get_module_eeprom = xgbe_get_module_eeprom,
862 .get_ringparam = xgbe_get_ringparam,
863 .set_ringparam = xgbe_set_ringparam,
864 .get_channels = xgbe_get_channels,
865 .set_channels = xgbe_set_channels,
649};866};
650 867
651const struct ethtool_ops *xgbe_get_ethtool_ops(void)868const struct ethtool_ops *xgbe_get_ethtool_ops(void)
drivers/net/ethernet/amd/xgbe/xgbe-main.c+1−19
@@ -265,7 +265,6 @@ int xgbe_config_netdev(struct xgbe_prv_data *pdata) · 264 unmodified lines
265{265{
266 struct net_device *netdev = pdata->netdev;266 struct net_device *netdev = pdata->netdev;
267 struct device *dev = pdata->dev;267 struct device *dev = pdata->dev;
268 unsigned int i;
269 int ret;268 int ret;
270 269
271 netdev->irq = pdata->dev_irq;270 netdev->irq = pdata->dev_irq;
@@ -324,26 +323,9 @@ int xgbe_config_netdev(struct xgbe_prv_data *pdata) · 52 unmodified lines
324 pdata->tx_ring_count, pdata->rx_ring_count);323 pdata->tx_ring_count, pdata->rx_ring_count);
325 }324 }
326 325
327 /* Set the number of queues */326 /* Initialize RSS hash key */
328 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count);
329 if (ret) {
330 dev_err(dev, "error setting real tx queue count\n");
331 return ret;
332 }
333
334 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count);
335 if (ret) {
336 dev_err(dev, "error setting real rx queue count\n");
337 return ret;
338 }
339
340 /* Initialize RSS hash key and lookup table */
341 netdev_rss_key_fill(pdata->rss_key, sizeof(pdata->rss_key));327 netdev_rss_key_fill(pdata->rss_key, sizeof(pdata->rss_key));
342 328
343 for (i = 0; i < XGBE_RSS_MAX_TABLE_SIZE; i++)
344 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH,
345 i % pdata->rx_ring_count);
346
347 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, IP2TE, 1);329 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, IP2TE, 1);
348 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, TCP4TE, 1);330 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, TCP4TE, 1);
349 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1);331 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1);
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c+80−87
@@ -126,6 +126,24 @@ · 125 unmodified lines
126#include "xgbe.h"126#include "xgbe.h"
127#include "xgbe-common.h"127#include "xgbe-common.h"
128 128
129static int xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata,
130 struct ethtool_eeprom *eeprom, u8 *data)
131{
132 if (!pdata->phy_if.phy_impl.module_eeprom)
133 return -ENXIO;
134
135 return pdata->phy_if.phy_impl.module_eeprom(pdata, eeprom, data);
136}
137
138static int xgbe_phy_module_info(struct xgbe_prv_data *pdata,
139 struct ethtool_modinfo *modinfo)
140{
141 if (!pdata->phy_if.phy_impl.module_info)
142 return -ENXIO;
143
144 return pdata->phy_if.phy_impl.module_info(pdata, modinfo);
145}
146
129static void xgbe_an37_clear_interrupts(struct xgbe_prv_data *pdata)147static void xgbe_an37_clear_interrupts(struct xgbe_prv_data *pdata)
130{148{
131 int reg;149 int reg;
@@ -198,31 +216,8 @@ static void xgbe_an_clear_interrupts_all(struct xgbe_prv_data *pdata) · 66 unmodified lines
198 xgbe_an37_clear_interrupts(pdata);216 xgbe_an37_clear_interrupts(pdata);
199}217}
200 218
201static void xgbe_an73_enable_kr_training(struct xgbe_prv_data *pdata)
202{
203 unsigned int reg;
204
205 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
206
207 reg |= XGBE_KR_TRAINING_ENABLE;
208 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg);
209}
210
211static void xgbe_an73_disable_kr_training(struct xgbe_prv_data *pdata)
212{
213 unsigned int reg;
214
215 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
216
217 reg &= ~XGBE_KR_TRAINING_ENABLE;
218 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg);
219}
220
221static void xgbe_kr_mode(struct xgbe_prv_data *pdata)219static void xgbe_kr_mode(struct xgbe_prv_data *pdata)
222{220{
223 /* Enable KR training */
224 xgbe_an73_enable_kr_training(pdata);
225
226 /* Set MAC to 10G speed */221 /* Set MAC to 10G speed */
227 pdata->hw_if.set_speed(pdata, SPEED_10000);222 pdata->hw_if.set_speed(pdata, SPEED_10000);
228 223
@@ -232,9 +227,6 @@ static void xgbe_kr_mode(struct xgbe_prv_data *pdata) · 3 unmodified lines
232 227
233static void xgbe_kx_2500_mode(struct xgbe_prv_data *pdata)228static void xgbe_kx_2500_mode(struct xgbe_prv_data *pdata)
234{229{
235 /* Disable KR training */
236 xgbe_an73_disable_kr_training(pdata);
237
238 /* Set MAC to 2.5G speed */230 /* Set MAC to 2.5G speed */
239 pdata->hw_if.set_speed(pdata, SPEED_2500);231 pdata->hw_if.set_speed(pdata, SPEED_2500);
240 232
@@ -244,9 +236,6 @@ static void xgbe_kx_2500_mode(struct xgbe_prv_data *pdata) · 3 unmodified lines
244 236
245static void xgbe_kx_1000_mode(struct xgbe_prv_data *pdata)237static void xgbe_kx_1000_mode(struct xgbe_prv_data *pdata)
246{238{
247 /* Disable KR training */
248 xgbe_an73_disable_kr_training(pdata);
249
250 /* Set MAC to 1G speed */239 /* Set MAC to 1G speed */
251 pdata->hw_if.set_speed(pdata, SPEED_1000);240 pdata->hw_if.set_speed(pdata, SPEED_1000);
252 241
@@ -260,9 +249,6 @@ static void xgbe_sfi_mode(struct xgbe_prv_data *pdata) · 7 unmodified lines
260 if (pdata->kr_redrv)249 if (pdata->kr_redrv)
261 return xgbe_kr_mode(pdata);250 return xgbe_kr_mode(pdata);
262 251
263 /* Disable KR training */
264 xgbe_an73_disable_kr_training(pdata);
265
266 /* Set MAC to 10G speed */252 /* Set MAC to 10G speed */
267 pdata->hw_if.set_speed(pdata, SPEED_10000);253 pdata->hw_if.set_speed(pdata, SPEED_10000);
268 254
@@ -272,9 +258,6 @@ static void xgbe_sfi_mode(struct xgbe_prv_data *pdata) · 3 unmodified lines
272 258
273static void xgbe_x_mode(struct xgbe_prv_data *pdata)259static void xgbe_x_mode(struct xgbe_prv_data *pdata)
274{260{
275 /* Disable KR training */
276 xgbe_an73_disable_kr_training(pdata);
277
278 /* Set MAC to 1G speed */261 /* Set MAC to 1G speed */
279 pdata->hw_if.set_speed(pdata, SPEED_1000);262 pdata->hw_if.set_speed(pdata, SPEED_1000);
280 263
@@ -284,9 +267,6 @@ static void xgbe_x_mode(struct xgbe_prv_data *pdata) · 3 unmodified lines
284 267
285static void xgbe_sgmii_1000_mode(struct xgbe_prv_data *pdata)268static void xgbe_sgmii_1000_mode(struct xgbe_prv_data *pdata)
286{269{
287 /* Disable KR training */
288 xgbe_an73_disable_kr_training(pdata);
289
290 /* Set MAC to 1G speed */270 /* Set MAC to 1G speed */
291 pdata->hw_if.set_speed(pdata, SPEED_1000);271 pdata->hw_if.set_speed(pdata, SPEED_1000);
292 272
@@ -296,9 +276,6 @@ static void xgbe_sgmii_1000_mode(struct xgbe_prv_data *pdata) · 3 unmodified lines
296 276
297static void xgbe_sgmii_100_mode(struct xgbe_prv_data *pdata)277static void xgbe_sgmii_100_mode(struct xgbe_prv_data *pdata)
298{278{
299 /* Disable KR training */
300 xgbe_an73_disable_kr_training(pdata);
301
302 /* Set MAC to 1G speed */279 /* Set MAC to 1G speed */
303 pdata->hw_if.set_speed(pdata, SPEED_1000);280 pdata->hw_if.set_speed(pdata, SPEED_1000);
304 281
@@ -354,13 +331,15 @@ static void xgbe_switch_mode(struct xgbe_prv_data *pdata) · 49 unmodified lines
354 xgbe_change_mode(pdata, pdata->phy_if.phy_impl.switch_mode(pdata));331 xgbe_change_mode(pdata, pdata->phy_if.phy_impl.switch_mode(pdata));
355}332}
356 333
357static void xgbe_set_mode(struct xgbe_prv_data *pdata,334static bool xgbe_set_mode(struct xgbe_prv_data *pdata,
358 enum xgbe_mode mode)335 enum xgbe_mode mode)
359{336{
360 if (mode == xgbe_cur_mode(pdata))337 if (mode == xgbe_cur_mode(pdata))
361 return;338 return false;
362 339
363 xgbe_change_mode(pdata, mode);340 xgbe_change_mode(pdata, mode);
341
342 return true;
364}343}
365 344
366static bool xgbe_use_mode(struct xgbe_prv_data *pdata,345static bool xgbe_use_mode(struct xgbe_prv_data *pdata,
@@ -407,6 +386,12 @@ static void xgbe_an73_set(struct xgbe_prv_data *pdata, bool enable, · 40 unmodified lines
407{386{
408 unsigned int reg;387 unsigned int reg;
409 388
389 /* Disable KR training for now */
390 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
391 reg &= ~XGBE_KR_TRAINING_ENABLE;
392 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg);
393
394 /* Update AN settings */
410 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_CTRL1);395 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_CTRL1);
411 reg &= ~MDIO_AN_CTRL1_ENABLE;396 reg &= ~MDIO_AN_CTRL1_ENABLE;
412 397
@@ -504,21 +489,19 @@ static enum xgbe_an xgbe_an73_tx_training(struct xgbe_prv_data *pdata, · 91 unmodified lines
504 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FECCTRL, reg);489 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FECCTRL, reg);
505 490
506 /* Start KR training */491 /* Start KR training */
507 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);492 if (pdata->phy_if.phy_impl.kr_training_pre)
508 if (reg & XGBE_KR_TRAINING_ENABLE) {493 pdata->phy_if.phy_impl.kr_training_pre(pdata);
509 if (pdata->phy_if.phy_impl.kr_training_pre)
510 pdata->phy_if.phy_impl.kr_training_pre(pdata);
511 494
512 reg |= XGBE_KR_TRAINING_START;495 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
513 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL,496 reg |= XGBE_KR_TRAINING_ENABLE;
514 reg);497 reg |= XGBE_KR_TRAINING_START;
498 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg);
515 499
516 netif_dbg(pdata, link, pdata->netdev,500 netif_dbg(pdata, link, pdata->netdev,
517 "KR training initiated\n");501 "KR training initiated\n");
518 502
519 if (pdata->phy_if.phy_impl.kr_training_post)503 if (pdata->phy_if.phy_impl.kr_training_post)
520 pdata->phy_if.phy_impl.kr_training_post(pdata);504 pdata->phy_if.phy_impl.kr_training_post(pdata);
521 }
522 505
523 return XGBE_AN_PAGE_RECEIVED;506 return XGBE_AN_PAGE_RECEIVED;
524}507}
@@ -1197,21 +1180,23 @@ static int xgbe_phy_config_fixed(struct xgbe_prv_data *pdata) · 672 unmodified lines
1197 return 0;1180 return 0;
1198}1181}
1199 1182
1200static int __xgbe_phy_config_aneg(struct xgbe_prv_data *pdata)1183static int __xgbe_phy_config_aneg(struct xgbe_prv_data *pdata, bool set_mode)
1201{1184{
1202 int ret;1185 int ret;
1203 1186
1187 mutex_lock(&pdata->an_mutex);
1188
1204 set_bit(XGBE_LINK_INIT, &pdata->dev_state);1189 set_bit(XGBE_LINK_INIT, &pdata->dev_state);
1205 pdata->link_check = jiffies;1190 pdata->link_check = jiffies;
1206 1191
1207 ret = pdata->phy_if.phy_impl.an_config(pdata);1192 ret = pdata->phy_if.phy_impl.an_config(pdata);
1208 if (ret)1193 if (ret)
1209 return ret;1194 goto out;
1210 1195
1211 if (pdata->phy.autoneg != AUTONEG_ENABLE) {1196 if (pdata->phy.autoneg != AUTONEG_ENABLE) {
1212 ret = xgbe_phy_config_fixed(pdata);1197 ret = xgbe_phy_config_fixed(pdata);
1213 if (ret || !pdata->kr_redrv)1198 if (ret || !pdata->kr_redrv)
1214 return ret;1199 goto out;
1215 1200
1216 netif_dbg(pdata, link, pdata->netdev, "AN redriver support\n");1201 netif_dbg(pdata, link, pdata->netdev, "AN redriver support\n");
1217 } else {1202 } else {
@@ -1221,24 +1206,27 @@ static int __xgbe_phy_config_aneg(struct xgbe_prv_data *pdata) · 3 unmodified lines
1221 /* Disable auto-negotiation interrupt */1206 /* Disable auto-negotiation interrupt */
1222 disable_irq(pdata->an_irq);1207 disable_irq(pdata->an_irq);
1223 1208
1224 /* Start auto-negotiation in a supported mode */1209 if (set_mode) {
1225 if (xgbe_use_mode(pdata, XGBE_MODE_KR)) {1210 /* Start auto-negotiation in a supported mode */
1226 xgbe_set_mode(pdata, XGBE_MODE_KR);1211 if (xgbe_use_mode(pdata, XGBE_MODE_KR)) {
1227 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_2500)) {1212 xgbe_set_mode(pdata, XGBE_MODE_KR);
1228 xgbe_set_mode(pdata, XGBE_MODE_KX_2500);1213 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_2500)) {
1229 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_1000)) {1214 xgbe_set_mode(pdata, XGBE_MODE_KX_2500);
1230 xgbe_set_mode(pdata, XGBE_MODE_KX_1000);1215 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_1000)) {
1231 } else if (xgbe_use_mode(pdata, XGBE_MODE_SFI)) {1216 xgbe_set_mode(pdata, XGBE_MODE_KX_1000);
1232 xgbe_set_mode(pdata, XGBE_MODE_SFI);1217 } else if (xgbe_use_mode(pdata, XGBE_MODE_SFI)) {
1233 } else if (xgbe_use_mode(pdata, XGBE_MODE_X)) {1218 xgbe_set_mode(pdata, XGBE_MODE_SFI);
1234 xgbe_set_mode(pdata, XGBE_MODE_X);1219 } else if (xgbe_use_mode(pdata, XGBE_MODE_X)) {
1235 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_1000)) {1220 xgbe_set_mode(pdata, XGBE_MODE_X);
1236 xgbe_set_mode(pdata, XGBE_MODE_SGMII_1000);1221 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_1000)) {
1237 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_100)) {1222 xgbe_set_mode(pdata, XGBE_MODE_SGMII_1000);
1238 xgbe_set_mode(pdata, XGBE_MODE_SGMII_100);1223 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_100)) {
1239 } else {1224 xgbe_set_mode(pdata, XGBE_MODE_SGMII_100);
1240 enable_irq(pdata->an_irq);1225 } else {
1241 return -EINVAL;1226 enable_irq(pdata->an_irq);
1227 ret = -EINVAL;
1228 goto out;
1229 }
1242 }1230 }
1243 1231
1244 /* Disable and stop any in progress auto-negotiation */1232 /* Disable and stop any in progress auto-negotiation */
@@ -1258,16 +1246,7 @@ static int __xgbe_phy_config_aneg(struct xgbe_prv_data *pdata) · 13 unmodified lines
1258 xgbe_an_init(pdata);1246 xgbe_an_init(pdata);
1259 xgbe_an_restart(pdata);1247 xgbe_an_restart(pdata);
1260 1248
1261 return 0;1249out:
1262}
1263
1264static int xgbe_phy_config_aneg(struct xgbe_prv_data *pdata)
1265{
1266 int ret;
1267
1268 mutex_lock(&pdata->an_mutex);
1269
1270 ret = __xgbe_phy_config_aneg(pdata);
1271 if (ret)1250 if (ret)
1272 set_bit(XGBE_LINK_ERR, &pdata->dev_state);1251 set_bit(XGBE_LINK_ERR, &pdata->dev_state);
1273 else1252 else
@@ -1278,6 +1257,16 @@ static int xgbe_phy_config_aneg(struct xgbe_prv_data *pdata) · 4 unmodified lines
1278 return ret;1257 return ret;
1279}1258}
1280 1259
1260static int xgbe_phy_config_aneg(struct xgbe_prv_data *pdata)
1261{
1262 return __xgbe_phy_config_aneg(pdata, true);
1263}
1264
1265static int xgbe_phy_reconfig_aneg(struct xgbe_prv_data *pdata)
1266{
1267 return __xgbe_phy_config_aneg(pdata, false);
1268}
1269
1281static bool xgbe_phy_aneg_done(struct xgbe_prv_data *pdata)1270static bool xgbe_phy_aneg_done(struct xgbe_prv_data *pdata)
1282{1271{
1283 return (pdata->an_result == XGBE_AN_COMPLETE);1272 return (pdata->an_result == XGBE_AN_COMPLETE);
@@ -1334,7 +1323,8 @@ static void xgbe_phy_status_result(struct xgbe_prv_data *pdata) · 50 unmodified lines
1334 1323
1335 pdata->phy.duplex = DUPLEX_FULL;1324 pdata->phy.duplex = DUPLEX_FULL;
1336 1325
1337 xgbe_set_mode(pdata, mode);1326 if (xgbe_set_mode(pdata, mode) && pdata->an_again)
1327 xgbe_phy_reconfig_aneg(pdata);
1338}1328}
1339 1329
1340static void xgbe_phy_status(struct xgbe_prv_data *pdata)1330static void xgbe_phy_status(struct xgbe_prv_data *pdata)
@@ -1639,4 +1629,7 @@ void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *phy_if) · 298 unmodified lines
1639 phy_if->phy_valid_speed = xgbe_phy_valid_speed;1629 phy_if->phy_valid_speed = xgbe_phy_valid_speed;
1640 1630
1641 phy_if->an_isr = xgbe_an_combined_isr;1631 phy_if->an_isr = xgbe_an_combined_isr;
1632
1633 phy_if->module_info = xgbe_phy_module_info;
1634 phy_if->module_eeprom = xgbe_phy_module_eeprom;
1642}1635}
drivers/net/ethernet/amd/xgbe/xgbe-pci.c+27−9
@@ -335,16 +335,33 @@ static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 334 unmodified lines
335 pdata->awcr = XGBE_DMA_PCI_AWCR;335 pdata->awcr = XGBE_DMA_PCI_AWCR;
336 pdata->awarcr = XGBE_DMA_PCI_AWARCR;336 pdata->awarcr = XGBE_DMA_PCI_AWARCR;
337 337
338 /* Read the port property registers */
339 pdata->pp0 = XP_IOREAD(pdata, XP_PROP_0);
340 pdata->pp1 = XP_IOREAD(pdata, XP_PROP_1);
341 pdata->pp2 = XP_IOREAD(pdata, XP_PROP_2);
342 pdata->pp3 = XP_IOREAD(pdata, XP_PROP_3);
343 pdata->pp4 = XP_IOREAD(pdata, XP_PROP_4);
344 if (netif_msg_probe(pdata)) {
345 dev_dbg(dev, "port property 0 = %#010x\n", pdata->pp0);
346 dev_dbg(dev, "port property 1 = %#010x\n", pdata->pp1);
347 dev_dbg(dev, "port property 2 = %#010x\n", pdata->pp2);
348 dev_dbg(dev, "port property 3 = %#010x\n", pdata->pp3);
349 dev_dbg(dev, "port property 4 = %#010x\n", pdata->pp4);
350 }
351
338 /* Set the maximum channels and queues */352 /* Set the maximum channels and queues */
339 reg = XP_IOREAD(pdata, XP_PROP_1);353 pdata->tx_max_channel_count = XP_GET_BITS(pdata->pp1, XP_PROP_1,
340 pdata->tx_max_channel_count = XP_GET_BITS(reg, XP_PROP_1, MAX_TX_DMA);354 MAX_TX_DMA);
341 pdata->rx_max_channel_count = XP_GET_BITS(reg, XP_PROP_1, MAX_RX_DMA);355 pdata->rx_max_channel_count = XP_GET_BITS(pdata->pp1, XP_PROP_1,
342 pdata->tx_max_q_count = XP_GET_BITS(reg, XP_PROP_1, MAX_TX_QUEUES);356 MAX_RX_DMA);
343 pdata->rx_max_q_count = XP_GET_BITS(reg, XP_PROP_1, MAX_RX_QUEUES);357 pdata->tx_max_q_count = XP_GET_BITS(pdata->pp1, XP_PROP_1,
358 MAX_TX_QUEUES);
359 pdata->rx_max_q_count = XP_GET_BITS(pdata->pp1, XP_PROP_1,
360 MAX_RX_QUEUES);
344 if (netif_msg_probe(pdata)) {361 if (netif_msg_probe(pdata)) {
345 dev_dbg(dev, "max tx/rx channel count = %u/%u\n",362 dev_dbg(dev, "max tx/rx channel count = %u/%u\n",
346 pdata->tx_max_channel_count,363 pdata->tx_max_channel_count,
347 pdata->tx_max_channel_count);364 pdata->rx_max_channel_count);
348 dev_dbg(dev, "max tx/rx hw queue count = %u/%u\n",365 dev_dbg(dev, "max tx/rx hw queue count = %u/%u\n",
349 pdata->tx_max_q_count, pdata->rx_max_q_count);366 pdata->tx_max_q_count, pdata->rx_max_q_count);
350 }367 }
@@ -353,12 +370,13 @@ static int xgbe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 2 unmodified lines
353 xgbe_set_counts(pdata);370 xgbe_set_counts(pdata);
354 371
355 /* Set the maximum fifo amounts */372 /* Set the maximum fifo amounts */
356 reg = XP_IOREAD(pdata, XP_PROP_2);373 pdata->tx_max_fifo_size = XP_GET_BITS(pdata->pp2, XP_PROP_2,
357 pdata->tx_max_fifo_size = XP_GET_BITS(reg, XP_PROP_2, TX_FIFO_SIZE);374 TX_FIFO_SIZE);
358 pdata->tx_max_fifo_size *= 16384;375 pdata->tx_max_fifo_size *= 16384;
359 pdata->tx_max_fifo_size = min(pdata->tx_max_fifo_size,376 pdata->tx_max_fifo_size = min(pdata->tx_max_fifo_size,
360 pdata->vdata->tx_max_fifo_size);377 pdata->vdata->tx_max_fifo_size);
361 pdata->rx_max_fifo_size = XP_GET_BITS(reg, XP_PROP_2, RX_FIFO_SIZE);378 pdata->rx_max_fifo_size = XP_GET_BITS(pdata->pp2, XP_PROP_2,
379 RX_FIFO_SIZE);
362 pdata->rx_max_fifo_size *= 16384;380 pdata->rx_max_fifo_size *= 16384;
363 pdata->rx_max_fifo_size = min(pdata->rx_max_fifo_size,381 pdata->rx_max_fifo_size = min(pdata->rx_max_fifo_size,
364 pdata->vdata->rx_max_fifo_size);382 pdata->vdata->rx_max_fifo_size);
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c+251−98
@@ -119,6 +119,7 @@ · 118 unmodified lines
119#include <linux/kmod.h>119#include <linux/kmod.h>
120#include <linux/mdio.h>120#include <linux/mdio.h>
121#include <linux/phy.h>121#include <linux/phy.h>
122#include <linux/ethtool.h>
122 123
123#include "xgbe.h"124#include "xgbe.h"
124#include "xgbe-common.h"125#include "xgbe-common.h"
@@ -270,6 +271,15 @@ struct xgbe_sfp_eeprom { · 145 unmodified lines
270 u8 vendor[32];271 u8 vendor[32];
271};272};
272 273
274#define XGBE_SFP_DIAGS_SUPPORTED(_x) \
275 ((_x)->extd[XGBE_SFP_EXTD_SFF_8472] && \
276 !((_x)->extd[XGBE_SFP_EXTD_DIAG] & XGBE_SFP_EXTD_DIAG_ADDR_CHANGE))
277
278#define XGBE_SFP_EEPROM_BASE_LEN 256
279#define XGBE_SFP_EEPROM_DIAG_LEN 256
280#define XGBE_SFP_EEPROM_MAX (XGBE_SFP_EEPROM_BASE_LEN + \
281 XGBE_SFP_EEPROM_DIAG_LEN)
282
273#define XGBE_BEL_FUSE_VENDOR "BEL-FUSE "283#define XGBE_BEL_FUSE_VENDOR "BEL-FUSE "
274#define XGBE_BEL_FUSE_PARTNO "1GBT-SFP06 "284#define XGBE_BEL_FUSE_PARTNO "1GBT-SFP06 "
275 285
@@ -327,8 +337,6 @@ struct xgbe_phy_data { · 51 unmodified lines
327 337
328 unsigned int mdio_addr;338 unsigned int mdio_addr;
329 339
330 unsigned int comm_owned;
331
332 /* SFP Support */340 /* SFP Support */
333 enum xgbe_sfp_comm sfp_comm;341 enum xgbe_sfp_comm sfp_comm;
334 unsigned int sfp_mux_address;342 unsigned int sfp_mux_address;
@@ -345,7 +353,6 @@ struct xgbe_phy_data { · 10 unmodified lines
345 unsigned int sfp_rx_los;353 unsigned int sfp_rx_los;
346 unsigned int sfp_tx_fault;354 unsigned int sfp_tx_fault;
347 unsigned int sfp_mod_absent;355 unsigned int sfp_mod_absent;
348 unsigned int sfp_diags;
349 unsigned int sfp_changed;356 unsigned int sfp_changed;
350 unsigned int sfp_phy_avail;357 unsigned int sfp_phy_avail;
351 unsigned int sfp_cable_len;358 unsigned int sfp_cable_len;
@@ -382,12 +389,6 @@ static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata); · 30 unmodified lines
382static int xgbe_phy_i2c_xfer(struct xgbe_prv_data *pdata,389static int xgbe_phy_i2c_xfer(struct xgbe_prv_data *pdata,
383 struct xgbe_i2c_op *i2c_op)390 struct xgbe_i2c_op *i2c_op)
384{391{
385 struct xgbe_phy_data *phy_data = pdata->phy_data;
386
387 /* Be sure we own the bus */
388 if (WARN_ON(!phy_data->comm_owned))
389 return -EIO;
390
391 return pdata->i2c_if.i2c_xfer(pdata, i2c_op);392 return pdata->i2c_if.i2c_xfer(pdata, i2c_op);
392}393}
393 394
@@ -549,10 +550,6 @@ static int xgbe_phy_sfp_get_mux(struct xgbe_prv_data *pdata) · 155 unmodified lines
549 550
550static void xgbe_phy_put_comm_ownership(struct xgbe_prv_data *pdata)551static void xgbe_phy_put_comm_ownership(struct xgbe_prv_data *pdata)
551{552{
552 struct xgbe_phy_data *phy_data = pdata->phy_data;
553
554 phy_data->comm_owned = 0;
555
556 mutex_unlock(&xgbe_phy_comm_lock);553 mutex_unlock(&xgbe_phy_comm_lock);
557}554}
558 555
@@ -562,9 +559,6 @@ static int xgbe_phy_get_comm_ownership(struct xgbe_prv_data *pdata) · 3 unmodified lines
562 unsigned long timeout;559 unsigned long timeout;
563 unsigned int mutex_id;560 unsigned int mutex_id;
564 561
565 if (phy_data->comm_owned)
566 return 0;
567
568 /* The I2C and MDIO/GPIO bus is multiplexed between multiple devices,562 /* The I2C and MDIO/GPIO bus is multiplexed between multiple devices,
569 * the driver needs to take the software mutex and then the hardware563 * the driver needs to take the software mutex and then the hardware
570 * mutexes before being able to use the busses.564 * mutexes before being able to use the busses.
@@ -593,7 +587,6 @@ static int xgbe_phy_get_comm_ownership(struct xgbe_prv_data *pdata) · 22 unmodified lines
593 XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id);587 XP_IOWRITE(pdata, XP_I2C_MUTEX, mutex_id);
594 XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id);588 XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id);
595 589
596 phy_data->comm_owned = 1;
597 return 0;590 return 0;
598 }591 }
599 592
@@ -867,6 +860,9 @@ static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata) · 267 unmodified lines
867 struct xgbe_phy_data *phy_data = pdata->phy_data;860 struct xgbe_phy_data *phy_data = pdata->phy_data;
868 unsigned int phy_id = phy_data->phydev->phy_id;861 unsigned int phy_id = phy_data->phydev->phy_id;
869 862
863 if (phy_data->port_mode != XGBE_PORT_MODE_SFP)
864 return false;
865
870 if ((phy_id & 0xfffffff0) != 0x01ff0cc0)866 if ((phy_id & 0xfffffff0) != 0x01ff0cc0)
871 return false;867 return false;
872 868
@@ -892,8 +888,83 @@ static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata) · 19 unmodified lines
892 return true;888 return true;
893}889}
894 890
891static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata)
892{
893 struct xgbe_phy_data *phy_data = pdata->phy_data;
894 struct xgbe_sfp_eeprom *sfp_eeprom = &phy_data->sfp_eeprom;
895 unsigned int phy_id = phy_data->phydev->phy_id;
896 int reg;
897
898 if (phy_data->port_mode != XGBE_PORT_MODE_SFP)
899 return false;
900
901 if (memcmp(&sfp_eeprom->base[XGBE_SFP_BASE_VENDOR_NAME],
902 XGBE_BEL_FUSE_VENDOR, XGBE_SFP_BASE_VENDOR_NAME_LEN))
903 return false;
904
905 /* For Bel-Fuse, use the extra AN flag */
906 pdata->an_again = 1;
907
908 if (memcmp(&sfp_eeprom->base[XGBE_SFP_BASE_VENDOR_PN],
909 XGBE_BEL_FUSE_PARTNO, XGBE_SFP_BASE_VENDOR_PN_LEN))
910 return false;
911
912 if ((phy_id & 0xfffffff0) != 0x03625d10)
913 return false;
914
915 /* Disable RGMII mode */
916 phy_write(phy_data->phydev, 0x18, 0x7007);
917 reg = phy_read(phy_data->phydev, 0x18);
918 phy_write(phy_data->phydev, 0x18, reg & ~0x0080);
919
920 /* Enable fiber register bank */
921 phy_write(phy_data->phydev, 0x1c, 0x7c00);
922 reg = phy_read(phy_data->phydev, 0x1c);
923 reg &= 0x03ff;
924 reg &= ~0x0001;
925 phy_write(phy_data->phydev, 0x1c, 0x8000 | 0x7c00 | reg | 0x0001);
926
927 /* Power down SerDes */
928 reg = phy_read(phy_data->phydev, 0x00);
929 phy_write(phy_data->phydev, 0x00, reg | 0x00800);
930
931 /* Configure SGMII-to-Copper mode */
932 phy_write(phy_data->phydev, 0x1c, 0x7c00);
933 reg = phy_read(phy_data->phydev, 0x1c);
934 reg &= 0x03ff;
935 reg &= ~0x0006;
936 phy_write(phy_data->phydev, 0x1c, 0x8000 | 0x7c00 | reg | 0x0004);
937
938 /* Power up SerDes */
939 reg = phy_read(phy_data->phydev, 0x00);
940 phy_write(phy_data->phydev, 0x00, reg & ~0x00800);
941
942 /* Enable copper register bank */
943 phy_write(phy_data->phydev, 0x1c, 0x7c00);
944 reg = phy_read(phy_data->phydev, 0x1c);
945 reg &= 0x03ff;
946 reg &= ~0x0001;
947 phy_write(phy_data->phydev, 0x1c, 0x8000 | 0x7c00 | reg);
948
949 /* Power up SerDes */
950 reg = phy_read(phy_data->phydev, 0x00);
951 phy_write(phy_data->phydev, 0x00, reg & ~0x00800);
952
953 phy_data->phydev->supported = PHY_GBIT_FEATURES;
954 phy_data->phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
955 phy_data->phydev->advertising = phy_data->phydev->supported;
956
957 netif_dbg(pdata, drv, pdata->netdev,
958 "BelFuse PHY quirk in place\n");
959
960 return true;
961}
962
895static void xgbe_phy_external_phy_quirks(struct xgbe_prv_data *pdata)963static void xgbe_phy_external_phy_quirks(struct xgbe_prv_data *pdata)
896{964{
965 if (xgbe_phy_belfuse_phy_quirks(pdata))
966 return;
967
897 if (xgbe_phy_finisar_phy_quirks(pdata))968 if (xgbe_phy_finisar_phy_quirks(pdata))
898 return;969 return;
899}970}
@@ -910,6 +981,9 @@ static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) · 10 unmodified lines
910 if (phy_data->phydev)981 if (phy_data->phydev)
911 return 0;982 return 0;
912 983
984 /* Clear the extra AN flag */
985 pdata->an_again = 0;
986
913 /* Check for the use of an external PHY */987 /* Check for the use of an external PHY */
914 if (phy_data->phydev_mode == XGBE_MDIO_MODE_NONE)988 if (phy_data->phydev_mode == XGBE_MDIO_MODE_NONE)
915 return 0;989 return 0;
@@ -1034,37 +1108,6 @@ static bool xgbe_phy_check_sfp_mod_absent(struct xgbe_phy_data *phy_data) · 118 unmodified lines
1034 return false;1108 return false;
1035}1109}
1036 1110
1037static bool xgbe_phy_belfuse_parse_quirks(struct xgbe_prv_data *pdata)
1038{
1039 struct xgbe_phy_data *phy_data = pdata->phy_data;
1040 struct xgbe_sfp_eeprom *sfp_eeprom = &phy_data->sfp_eeprom;
1041
1042 if (memcmp(&sfp_eeprom->base[XGBE_SFP_BASE_VENDOR_NAME],
1043 XGBE_BEL_FUSE_VENDOR, XGBE_SFP_BASE_VENDOR_NAME_LEN))
1044 return false;
1045
1046 if (!memcmp(&sfp_eeprom->base[XGBE_SFP_BASE_VENDOR_PN],
1047 XGBE_BEL_FUSE_PARTNO, XGBE_SFP_BASE_VENDOR_PN_LEN)) {
1048 phy_data->sfp_base = XGBE_SFP_BASE_1000_SX;
1049 phy_data->sfp_cable = XGBE_SFP_CABLE_ACTIVE;
1050 phy_data->sfp_speed = XGBE_SFP_SPEED_1000;
1051 if (phy_data->sfp_changed)
1052 netif_dbg(pdata, drv, pdata->netdev,
1053 "Bel-Fuse SFP quirk in place\n");
1054 return true;
1055 }
1056
1057 return false;
1058}
1059
1060static bool xgbe_phy_sfp_parse_quirks(struct xgbe_prv_data *pdata)
1061{
1062 if (xgbe_phy_belfuse_parse_quirks(pdata))
1063 return true;
1064
1065 return false;
1066}
1067
1068static void xgbe_phy_sfp_parse_eeprom(struct xgbe_prv_data *pdata)1111static void xgbe_phy_sfp_parse_eeprom(struct xgbe_prv_data *pdata)
1069{1112{
1070 struct xgbe_phy_data *phy_data = pdata->phy_data;1113 struct xgbe_phy_data *phy_data = pdata->phy_data;
@@ -1083,9 +1126,6 @@ static void xgbe_phy_sfp_parse_eeprom(struct xgbe_prv_data *pdata) · 12 unmodified lines
1083 phy_data->sfp_tx_fault = xgbe_phy_check_sfp_tx_fault(phy_data);1126 phy_data->sfp_tx_fault = xgbe_phy_check_sfp_tx_fault(phy_data);
1084 phy_data->sfp_rx_los = xgbe_phy_check_sfp_rx_los(phy_data);1127 phy_data->sfp_rx_los = xgbe_phy_check_sfp_rx_los(phy_data);
1085 1128
1086 if (xgbe_phy_sfp_parse_quirks(pdata))
1087 return;
1088
1089 /* Assume ACTIVE cable unless told it is PASSIVE */1129 /* Assume ACTIVE cable unless told it is PASSIVE */
1090 if (sfp_base[XGBE_SFP_BASE_CABLE] & XGBE_SFP_BASE_CABLE_PASSIVE) {1130 if (sfp_base[XGBE_SFP_BASE_CABLE] & XGBE_SFP_BASE_CABLE_PASSIVE) {
1091 phy_data->sfp_cable = XGBE_SFP_CABLE_PASSIVE;1131 phy_data->sfp_cable = XGBE_SFP_CABLE_PASSIVE;
@@ -1227,13 +1267,6 @@ static int xgbe_phy_sfp_read_eeprom(struct xgbe_prv_data *pdata) · 135 unmodified lines
1227 1267
1228 memcpy(&phy_data->sfp_eeprom, &sfp_eeprom, sizeof(sfp_eeprom));1268 memcpy(&phy_data->sfp_eeprom, &sfp_eeprom, sizeof(sfp_eeprom));
1229 1269
1230 if (sfp_eeprom.extd[XGBE_SFP_EXTD_SFF_8472]) {
1231 u8 diag_type = sfp_eeprom.extd[XGBE_SFP_EXTD_DIAG];
1232
1233 if (!(diag_type & XGBE_SFP_EXTD_DIAG_ADDR_CHANGE))
1234 phy_data->sfp_diags = 1;
1235 }
1236
1237 xgbe_phy_free_phy_device(pdata);1270 xgbe_phy_free_phy_device(pdata);
1238 } else {1271 } else {
1239 phy_data->sfp_changed = 0;1272 phy_data->sfp_changed = 0;
@@ -1283,7 +1316,6 @@ static void xgbe_phy_sfp_reset(struct xgbe_phy_data *phy_data) · 43 unmodified lines
1283 phy_data->sfp_rx_los = 0;1316 phy_data->sfp_rx_los = 0;
1284 phy_data->sfp_tx_fault = 0;1317 phy_data->sfp_tx_fault = 0;
1285 phy_data->sfp_mod_absent = 1;1318 phy_data->sfp_mod_absent = 1;
1286 phy_data->sfp_diags = 0;
1287 phy_data->sfp_base = XGBE_SFP_BASE_UNKNOWN;1319 phy_data->sfp_base = XGBE_SFP_BASE_UNKNOWN;
1288 phy_data->sfp_cable = XGBE_SFP_CABLE_UNKNOWN;1320 phy_data->sfp_cable = XGBE_SFP_CABLE_UNKNOWN;
1289 phy_data->sfp_speed = XGBE_SFP_SPEED_UNKNOWN;1321 phy_data->sfp_speed = XGBE_SFP_SPEED_UNKNOWN;
@@ -1326,6 +1358,130 @@ put: · 36 unmodified lines
1326 xgbe_phy_put_comm_ownership(pdata);1358 xgbe_phy_put_comm_ownership(pdata);
1327}1359}
1328 1360
1361static int xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata,
1362 struct ethtool_eeprom *eeprom, u8 *data)
1363{
1364 struct xgbe_phy_data *phy_data = pdata->phy_data;
1365 u8 eeprom_addr, eeprom_data[XGBE_SFP_EEPROM_MAX];
1366 struct xgbe_sfp_eeprom *sfp_eeprom;
1367 unsigned int i, j, rem;
1368 int ret;
1369
1370 rem = eeprom->len;
1371
1372 if (!eeprom->len) {
1373 ret = -EINVAL;
1374 goto done;
1375 }
1376
1377 if ((eeprom->offset + eeprom->len) > XGBE_SFP_EEPROM_MAX) {
1378 ret = -EINVAL;
1379 goto done;
1380 }
1381
1382 if (phy_data->port_mode != XGBE_PORT_MODE_SFP) {
1383 ret = -ENXIO;
1384 goto done;
1385 }
1386
1387 if (!netif_running(pdata->netdev)) {
1388 ret = -EIO;
1389 goto done;
1390 }
1391
1392 if (phy_data->sfp_mod_absent) {
1393 ret = -EIO;
1394 goto done;
1395 }
1396
1397 ret = xgbe_phy_get_comm_ownership(pdata);
1398 if (ret) {
1399 ret = -EIO;
1400 goto done;
1401 }
1402
1403 ret = xgbe_phy_sfp_get_mux(pdata);
1404 if (ret) {
1405 netdev_err(pdata->netdev, "I2C error setting SFP MUX\n");
1406 ret = -EIO;
1407 goto put_own;
1408 }
1409
1410 /* Read the SFP serial ID eeprom */
1411 eeprom_addr = 0;
1412 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS,
1413 &eeprom_addr, sizeof(eeprom_addr),
1414 eeprom_data, XGBE_SFP_EEPROM_BASE_LEN);
1415 if (ret) {
1416 netdev_err(pdata->netdev,
1417 "I2C error reading SFP EEPROM\n");
1418 ret = -EIO;
1419 goto put_mux;
1420 }
1421
1422 sfp_eeprom = (struct xgbe_sfp_eeprom *)eeprom_data;
1423
1424 if (XGBE_SFP_DIAGS_SUPPORTED(sfp_eeprom)) {
1425 /* Read the SFP diagnostic eeprom */
1426 eeprom_addr = 0;
1427 ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_DIAG_INFO_ADDRESS,
1428 &eeprom_addr, sizeof(eeprom_addr),
1429 eeprom_data + XGBE_SFP_EEPROM_BASE_LEN,
1430 XGBE_SFP_EEPROM_DIAG_LEN);
1431 if (ret) {
1432 netdev_err(pdata->netdev,
1433 "I2C error reading SFP DIAGS\n");
1434 ret = -EIO;
1435 goto put_mux;
1436 }
1437 }
1438
1439 for (i = 0, j = eeprom->offset; i < eeprom->len; i++, j++) {
1440 if ((j >= XGBE_SFP_EEPROM_BASE_LEN) &&
1441 !XGBE_SFP_DIAGS_SUPPORTED(sfp_eeprom))
1442 break;
1443
1444 data[i] = eeprom_data[j];
1445 rem--;
1446 }
1447
1448put_mux:
1449 xgbe_phy_sfp_put_mux(pdata);
1450
1451put_own:
1452 xgbe_phy_put_comm_ownership(pdata);
1453
1454done:
1455 eeprom->len -= rem;
1456
1457 return ret;
1458}
1459
1460static int xgbe_phy_module_info(struct xgbe_prv_data *pdata,
1461 struct ethtool_modinfo *modinfo)
1462{
1463 struct xgbe_phy_data *phy_data = pdata->phy_data;
1464
1465 if (phy_data->port_mode != XGBE_PORT_MODE_SFP)
1466 return -ENXIO;
1467
1468 if (!netif_running(pdata->netdev))
1469 return -EIO;
1470
1471 if (phy_data->sfp_mod_absent)
1472 return -EIO;
1473
1474 if (XGBE_SFP_DIAGS_SUPPORTED(&phy_data->sfp_eeprom)) {
1475 modinfo->type = ETH_MODULE_SFF_8472;
1476 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
1477 } else {
1478 modinfo->type = ETH_MODULE_SFF_8079;
1479 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
1480 }
1481
1482 return 0;
1483}
1484
1329static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata)1485static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata)
1330{1486{
1331 struct ethtool_link_ksettings *lks = &pdata->phy.lks;1487 struct ethtool_link_ksettings *lks = &pdata->phy.lks;
@@ -1611,6 +1767,10 @@ static void xgbe_phy_an_advertising(struct xgbe_prv_data *pdata, · 279 unmodified lines
1611 XGBE_CLR_ADV(dlks, 1000baseKX_Full);1767 XGBE_CLR_ADV(dlks, 1000baseKX_Full);
1612 XGBE_CLR_ADV(dlks, 10000baseKR_Full);1768 XGBE_CLR_ADV(dlks, 10000baseKR_Full);
1613 1769
1770 /* Advertise FEC support is present */
1771 if (pdata->fec_ability & MDIO_PMA_10GBR_FECABLE_ABLE)
1772 XGBE_SET_ADV(dlks, 10000baseR_FEC);
1773
1614 switch (phy_data->port_mode) {1774 switch (phy_data->port_mode) {
1615 case XGBE_PORT_MODE_BACKPLANE:1775 case XGBE_PORT_MODE_BACKPLANE:
1616 XGBE_SET_ADV(dlks, 10000baseKR_Full);1776 XGBE_SET_ADV(dlks, 10000baseKR_Full);
@@ -2421,22 +2581,21 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) · 804 unmodified lines
2421static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata)2581static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata)
2422{2582{
2423 struct xgbe_phy_data *phy_data = pdata->phy_data;2583 struct xgbe_phy_data *phy_data = pdata->phy_data;
2424 unsigned int reg;
2425
2426 reg = XP_IOREAD(pdata, XP_PROP_3);
2427 2584
2428 phy_data->sfp_gpio_address = XGBE_GPIO_ADDRESS_PCA9555 +2585 phy_data->sfp_gpio_address = XGBE_GPIO_ADDRESS_PCA9555 +
2429 XP_GET_BITS(reg, XP_PROP_3, GPIO_ADDR);2586 XP_GET_BITS(pdata->pp3, XP_PROP_3,
2587 GPIO_ADDR);
2430 2588
2431 phy_data->sfp_gpio_mask = XP_GET_BITS(reg, XP_PROP_3, GPIO_MASK);2589 phy_data->sfp_gpio_mask = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2590 GPIO_MASK);
2432 2591
2433 phy_data->sfp_gpio_rx_los = XP_GET_BITS(reg, XP_PROP_3,2592 phy_data->sfp_gpio_rx_los = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2434 GPIO_RX_LOS);2593 GPIO_RX_LOS);
2435 phy_data->sfp_gpio_tx_fault = XP_GET_BITS(reg, XP_PROP_3,2594 phy_data->sfp_gpio_tx_fault = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2436 GPIO_TX_FAULT);2595 GPIO_TX_FAULT);
2437 phy_data->sfp_gpio_mod_absent = XP_GET_BITS(reg, XP_PROP_3,2596 phy_data->sfp_gpio_mod_absent = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2438 GPIO_MOD_ABS);2597 GPIO_MOD_ABS);
2439 phy_data->sfp_gpio_rate_select = XP_GET_BITS(reg, XP_PROP_3,2598 phy_data->sfp_gpio_rate_select = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2440 GPIO_RATE_SELECT);2599 GPIO_RATE_SELECT);
2441 2600
2442 if (netif_msg_probe(pdata)) {2601 if (netif_msg_probe(pdata)) {
@@ -2458,18 +2617,17 @@ static void xgbe_phy_sfp_gpio_setup(struct xgbe_prv_data *pdata) · 15 unmodified lines
2458static void xgbe_phy_sfp_comm_setup(struct xgbe_prv_data *pdata)2617static void xgbe_phy_sfp_comm_setup(struct xgbe_prv_data *pdata)
2459{2618{
2460 struct xgbe_phy_data *phy_data = pdata->phy_data;2619 struct xgbe_phy_data *phy_data = pdata->phy_data;
2461 unsigned int reg, mux_addr_hi, mux_addr_lo;2620 unsigned int mux_addr_hi, mux_addr_lo;
2462 2621
2463 reg = XP_IOREAD(pdata, XP_PROP_4);2622 mux_addr_hi = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_HI);
2464 2623 mux_addr_lo = XP_GET_BITS(pdata->pp4, XP_PROP_4, MUX_ADDR_LO);
2465 mux_addr_hi = XP_GET_BITS(reg, XP_PROP_4, MUX_ADDR_HI);
2466 mux_addr_lo = XP_GET_BITS(reg, XP_PROP_4, MUX_ADDR_LO);
2467 if (mux_addr_lo == XGBE_SFP_DIRECT)2624 if (mux_addr_lo == XGBE_SFP_DIRECT)
2468 return;2625 return;
2469 2626
2470 phy_data->sfp_comm = XGBE_SFP_COMM_PCA9545;2627 phy_data->sfp_comm = XGBE_SFP_COMM_PCA9545;
2471 phy_data->sfp_mux_address = (mux_addr_hi << 2) + mux_addr_lo;2628 phy_data->sfp_mux_address = (mux_addr_hi << 2) + mux_addr_lo;
2472 phy_data->sfp_mux_channel = XP_GET_BITS(reg, XP_PROP_4, MUX_CHAN);2629 phy_data->sfp_mux_channel = XP_GET_BITS(pdata->pp4, XP_PROP_4,
2630 MUX_CHAN);
2473 2631
2474 if (netif_msg_probe(pdata)) {2632 if (netif_msg_probe(pdata)) {
2475 dev_dbg(pdata->dev, "SFP: mux_address=%#x\n",2633 dev_dbg(pdata->dev, "SFP: mux_address=%#x\n",
@@ -2592,13 +2750,11 @@ static bool xgbe_phy_redrv_error(struct xgbe_phy_data *phy_data) · 116 unmodified lines
2592static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata)2750static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata)
2593{2751{
2594 struct xgbe_phy_data *phy_data = pdata->phy_data;2752 struct xgbe_phy_data *phy_data = pdata->phy_data;
2595 unsigned int reg;
2596 2753
2597 if (phy_data->conn_type != XGBE_CONN_TYPE_MDIO)2754 if (phy_data->conn_type != XGBE_CONN_TYPE_MDIO)
2598 return 0;2755 return 0;
2599 2756
2600 reg = XP_IOREAD(pdata, XP_PROP_3);2757 phy_data->mdio_reset = XP_GET_BITS(pdata->pp3, XP_PROP_3, MDIO_RESET);
2601 phy_data->mdio_reset = XP_GET_BITS(reg, XP_PROP_3, MDIO_RESET);
2602 switch (phy_data->mdio_reset) {2758 switch (phy_data->mdio_reset) {
2603 case XGBE_MDIO_RESET_NONE:2759 case XGBE_MDIO_RESET_NONE:
2604 case XGBE_MDIO_RESET_I2C_GPIO:2760 case XGBE_MDIO_RESET_I2C_GPIO:
@@ -2612,12 +2768,12 @@ static int xgbe_phy_mdio_reset_setup(struct xgbe_prv_data *pdata) · 7 unmodified lines
2612 2768
2613 if (phy_data->mdio_reset == XGBE_MDIO_RESET_I2C_GPIO) {2769 if (phy_data->mdio_reset == XGBE_MDIO_RESET_I2C_GPIO) {
2614 phy_data->mdio_reset_addr = XGBE_GPIO_ADDRESS_PCA9555 +2770 phy_data->mdio_reset_addr = XGBE_GPIO_ADDRESS_PCA9555 +
2615 XP_GET_BITS(reg, XP_PROP_3,2771 XP_GET_BITS(pdata->pp3, XP_PROP_3,
2616 MDIO_RESET_I2C_ADDR);2772 MDIO_RESET_I2C_ADDR);
2617 phy_data->mdio_reset_gpio = XP_GET_BITS(reg, XP_PROP_3,2773 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2618 MDIO_RESET_I2C_GPIO);2774 MDIO_RESET_I2C_GPIO);
2619 } else if (phy_data->mdio_reset == XGBE_MDIO_RESET_INT_GPIO) {2775 } else if (phy_data->mdio_reset == XGBE_MDIO_RESET_INT_GPIO) {
2620 phy_data->mdio_reset_gpio = XP_GET_BITS(reg, XP_PROP_3,2776 phy_data->mdio_reset_gpio = XP_GET_BITS(pdata->pp3, XP_PROP_3,
2621 MDIO_RESET_INT_GPIO);2777 MDIO_RESET_INT_GPIO);
2622 }2778 }
2623 2779
@@ -2707,12 +2863,9 @@ static bool xgbe_phy_conn_type_mismatch(struct xgbe_prv_data *pdata) · 83 unmodified lines
2707 2863
2708static bool xgbe_phy_port_enabled(struct xgbe_prv_data *pdata)2864static bool xgbe_phy_port_enabled(struct xgbe_prv_data *pdata)
2709{2865{
2710 unsigned int reg;2866 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS))
2711
2712 reg = XP_IOREAD(pdata, XP_PROP_0);
2713 if (!XP_GET_BITS(reg, XP_PROP_0, PORT_SPEEDS))
2714 return false;2867 return false;
2715 if (!XP_GET_BITS(reg, XP_PROP_0, CONN_TYPE))2868 if (!XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE))
2716 return false;2869 return false;
2717 2870
2718 return true;2871 return true;
@@ -2921,7 +3074,6 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata) · 202 unmodified lines
2921 struct ethtool_link_ksettings *lks = &pdata->phy.lks;3074 struct ethtool_link_ksettings *lks = &pdata->phy.lks;
2922 struct xgbe_phy_data *phy_data;3075 struct xgbe_phy_data *phy_data;
2923 struct mii_bus *mii;3076 struct mii_bus *mii;
2924 unsigned int reg;
2925 int ret;3077 int ret;
2926 3078
2927 /* Check if enabled */3079 /* Check if enabled */
@@ -2940,12 +3092,11 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata) · 12 unmodified lines
2940 return -ENOMEM;3092 return -ENOMEM;
2941 pdata->phy_data = phy_data;3093 pdata->phy_data = phy_data;
2942 3094
2943 reg = XP_IOREAD(pdata, XP_PROP_0);3095 phy_data->port_mode = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_MODE);
2944 phy_data->port_mode = XP_GET_BITS(reg, XP_PROP_0, PORT_MODE);3096 phy_data->port_id = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_ID);
2945 phy_data->port_id = XP_GET_BITS(reg, XP_PROP_0, PORT_ID);3097 phy_data->port_speeds = XP_GET_BITS(pdata->pp0, XP_PROP_0, PORT_SPEEDS);
2946 phy_data->port_speeds = XP_GET_BITS(reg, XP_PROP_0, PORT_SPEEDS);3098 phy_data->conn_type = XP_GET_BITS(pdata->pp0, XP_PROP_0, CONN_TYPE);
2947 phy_data->conn_type = XP_GET_BITS(reg, XP_PROP_0, CONN_TYPE);3099 phy_data->mdio_addr = XP_GET_BITS(pdata->pp0, XP_PROP_0, MDIO_ADDR);
2948 phy_data->mdio_addr = XP_GET_BITS(reg, XP_PROP_0, MDIO_ADDR);
2949 if (netif_msg_probe(pdata)) {3100 if (netif_msg_probe(pdata)) {
2950 dev_dbg(pdata->dev, "port mode=%u\n", phy_data->port_mode);3101 dev_dbg(pdata->dev, "port mode=%u\n", phy_data->port_mode);
2951 dev_dbg(pdata->dev, "port id=%u\n", phy_data->port_id);3102 dev_dbg(pdata->dev, "port id=%u\n", phy_data->port_id);
@@ -2954,12 +3105,11 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata) · 2 unmodified lines
2954 dev_dbg(pdata->dev, "mdio addr=%u\n", phy_data->mdio_addr);3105 dev_dbg(pdata->dev, "mdio addr=%u\n", phy_data->mdio_addr);
2955 }3106 }
2956 3107
2957 reg = XP_IOREAD(pdata, XP_PROP_4);3108 phy_data->redrv = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_PRESENT);
2958 phy_data->redrv = XP_GET_BITS(reg, XP_PROP_4, REDRV_PRESENT);3109 phy_data->redrv_if = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_IF);
2959 phy_data->redrv_if = XP_GET_BITS(reg, XP_PROP_4, REDRV_IF);3110 phy_data->redrv_addr = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_ADDR);
2960 phy_data->redrv_addr = XP_GET_BITS(reg, XP_PROP_4, REDRV_ADDR);3111 phy_data->redrv_lane = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_LANE);
2961 phy_data->redrv_lane = XP_GET_BITS(reg, XP_PROP_4, REDRV_LANE);3112 phy_data->redrv_model = XP_GET_BITS(pdata->pp4, XP_PROP_4, REDRV_MODEL);
2962 phy_data->redrv_model = XP_GET_BITS(reg, XP_PROP_4, REDRV_MODEL);
2963 if (phy_data->redrv && netif_msg_probe(pdata)) {3113 if (phy_data->redrv && netif_msg_probe(pdata)) {
2964 dev_dbg(pdata->dev, "redrv present\n");3114 dev_dbg(pdata->dev, "redrv present\n");
2965 dev_dbg(pdata->dev, "redrv i/f=%u\n", phy_data->redrv_if);3115 dev_dbg(pdata->dev, "redrv i/f=%u\n", phy_data->redrv_if);
@@ -3231,4 +3381,7 @@ void xgbe_init_function_ptrs_phy_v2(struct xgbe_phy_if *phy_if) · 265 unmodified lines
3231 3381
3232 phy_impl->kr_training_pre = xgbe_phy_kr_training_pre;3382 phy_impl->kr_training_pre = xgbe_phy_kr_training_pre;
3233 phy_impl->kr_training_post = xgbe_phy_kr_training_post;3383 phy_impl->kr_training_post = xgbe_phy_kr_training_post;
3384
3385 phy_impl->module_info = xgbe_phy_module_info;
3386 phy_impl->module_eeprom = xgbe_phy_module_eeprom;
3234}3387}
drivers/net/ethernet/amd/xgbe/xgbe.h+31−0
@@ -144,6 +144,11 @@ · 143 unmodified lines
144#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)144#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
145#define XGBE_RX_DESC_CNT 512145#define XGBE_RX_DESC_CNT 512
146 146
147#define XGBE_TX_DESC_CNT_MIN 64
148#define XGBE_TX_DESC_CNT_MAX 4096
149#define XGBE_RX_DESC_CNT_MIN 64
150#define XGBE_RX_DESC_CNT_MAX 4096
151
147#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))152#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
148 153
149/* Descriptors required for maximum contiguous TSO/GSO packet */154/* Descriptors required for maximum contiguous TSO/GSO packet */
@@ -835,6 +840,7 @@ struct xgbe_hw_if { · 685 unmodified lines
835 * Optional routines:840 * Optional routines:
836 * an_pre, an_post841 * an_pre, an_post
837 * kr_training_pre, kr_training_post842 * kr_training_pre, kr_training_post
843 * module_info, module_eeprom
838 */844 */
839struct xgbe_phy_impl_if {845struct xgbe_phy_impl_if {
840 /* Perform Setup/teardown actions */846 /* Perform Setup/teardown actions */
@@ -883,6 +889,12 @@ struct xgbe_phy_impl_if { · 42 unmodified lines
883 /* Pre/Post KR training enablement support */889 /* Pre/Post KR training enablement support */
884 void (*kr_training_pre)(struct xgbe_prv_data *);890 void (*kr_training_pre)(struct xgbe_prv_data *);
885 void (*kr_training_post)(struct xgbe_prv_data *);891 void (*kr_training_post)(struct xgbe_prv_data *);
892
893 /* SFP module related info */
894 int (*module_info)(struct xgbe_prv_data *pdata,
895 struct ethtool_modinfo *modinfo);
896 int (*module_eeprom)(struct xgbe_prv_data *pdata,
897 struct ethtool_eeprom *eeprom, u8 *data);
886};898};
887 899
888struct xgbe_phy_if {900struct xgbe_phy_if {
@@ -905,6 +917,12 @@ struct xgbe_phy_if { · 16 unmodified lines
905 /* For single interrupt support */917 /* For single interrupt support */
906 irqreturn_t (*an_isr)(struct xgbe_prv_data *);918 irqreturn_t (*an_isr)(struct xgbe_prv_data *);
907 919
920 /* For ethtool PHY support */
921 int (*module_info)(struct xgbe_prv_data *pdata,
922 struct ethtool_modinfo *modinfo);
923 int (*module_eeprom)(struct xgbe_prv_data *pdata,
924 struct ethtool_eeprom *eeprom, u8 *data);
925
908 /* PHY implementation specific services */926 /* PHY implementation specific services */
909 struct xgbe_phy_impl_if phy_impl;927 struct xgbe_phy_impl_if phy_impl;
910};928};
@@ -1027,6 +1045,13 @@ struct xgbe_prv_data { · 116 unmodified lines
1027 void __iomem *xprop_regs; /* XGBE property registers */1045 void __iomem *xprop_regs; /* XGBE property registers */
1028 void __iomem *xi2c_regs; /* XGBE I2C CSRs */1046 void __iomem *xi2c_regs; /* XGBE I2C CSRs */
1029 1047
1048 /* Port property registers */
1049 unsigned int pp0;
1050 unsigned int pp1;
1051 unsigned int pp2;
1052 unsigned int pp3;
1053 unsigned int pp4;
1054
1030 /* Overall device lock */1055 /* Overall device lock */
1031 spinlock_t lock;1056 spinlock_t lock;
1032 1057
@@ -1097,6 +1122,9 @@ struct xgbe_prv_data { · 64 unmodified lines
1097 unsigned int rx_ring_count;1122 unsigned int rx_ring_count;
1098 unsigned int rx_desc_count;1123 unsigned int rx_desc_count;
1099 1124
1125 unsigned int new_tx_ring_count;
1126 unsigned int new_rx_ring_count;
1127
1100 unsigned int tx_max_q_count;1128 unsigned int tx_max_q_count;
1101 unsigned int rx_max_q_count;1129 unsigned int rx_max_q_count;
1102 unsigned int tx_q_count;1130 unsigned int tx_q_count;
@@ -1233,6 +1261,7 @@ struct xgbe_prv_data { · 130 unmodified lines
1233 enum xgbe_rx kr_state;1261 enum xgbe_rx kr_state;
1234 enum xgbe_rx kx_state;1262 enum xgbe_rx kx_state;
1235 struct work_struct an_work;1263 struct work_struct an_work;
1264 unsigned int an_again;
1236 unsigned int an_supported;1265 unsigned int an_supported;
1237 unsigned int parallel_detect;1266 unsigned int parallel_detect;
1238 unsigned int fec_ability;1267 unsigned int fec_ability;
@@ -1310,6 +1339,8 @@ int xgbe_powerup(struct net_device *, unsigned int); · 71 unmodified lines
1310int xgbe_powerdown(struct net_device *, unsigned int);1339int xgbe_powerdown(struct net_device *, unsigned int);
1311void xgbe_init_rx_coalesce(struct xgbe_prv_data *);1340void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
1312void xgbe_init_tx_coalesce(struct xgbe_prv_data *);1341void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
1342void xgbe_restart_dev(struct xgbe_prv_data *pdata);
1343void xgbe_full_restart_dev(struct xgbe_prv_data *pdata);
1313 1344
1314#ifdef CONFIG_DEBUG_FS1345#ifdef CONFIG_DEBUG_FS
1315void xgbe_debugfs_init(struct xgbe_prv_data *);1346void xgbe_debugfs_init(struct xgbe_prv_data *);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t