aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-common.h2
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-dev.c28
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c45
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c19
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-main.c19
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe.h6
-rw-r--r--drivers/net/phy/amd-xgbe-phy.c98
7 files changed, 127 insertions, 90 deletions
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
index 29a09271b64a..34c28aac767f 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
@@ -365,6 +365,8 @@
365#define MAC_HWF0R_TXCOESEL_WIDTH 1 365#define MAC_HWF0R_TXCOESEL_WIDTH 1
366#define MAC_HWF0R_VLHASH_INDEX 4 366#define MAC_HWF0R_VLHASH_INDEX 4
367#define MAC_HWF0R_VLHASH_WIDTH 1 367#define MAC_HWF0R_VLHASH_WIDTH 1
368#define MAC_HWF1R_ADDR64_INDEX 14
369#define MAC_HWF1R_ADDR64_WIDTH 2
368#define MAC_HWF1R_ADVTHWORD_INDEX 13 370#define MAC_HWF1R_ADVTHWORD_INDEX 13
369#define MAC_HWF1R_ADVTHWORD_WIDTH 1 371#define MAC_HWF1R_ADVTHWORD_WIDTH 1
370#define MAC_HWF1R_DBGMEMA_INDEX 19 372#define MAC_HWF1R_DBGMEMA_INDEX 19
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index 400757b49872..80dd7a92f357 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -1068,7 +1068,7 @@ static void xgbe_tx_desc_reset(struct xgbe_ring_data *rdata)
1068 rdesc->desc3 = 0; 1068 rdesc->desc3 = 0;
1069 1069
1070 /* Make sure ownership is written to the descriptor */ 1070 /* Make sure ownership is written to the descriptor */
1071 wmb(); 1071 dma_wmb();
1072} 1072}
1073 1073
1074static void xgbe_tx_desc_init(struct xgbe_channel *channel) 1074static void xgbe_tx_desc_init(struct xgbe_channel *channel)
@@ -1124,12 +1124,12 @@ static void xgbe_rx_desc_reset(struct xgbe_ring_data *rdata)
1124 * is written to the descriptor(s) before setting the OWN bit 1124 * is written to the descriptor(s) before setting the OWN bit
1125 * for the descriptor 1125 * for the descriptor
1126 */ 1126 */
1127 wmb(); 1127 dma_wmb();
1128 1128
1129 XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, OWN, 1); 1129 XGMAC_SET_BITS_LE(rdesc->desc3, RX_NORMAL_DESC3, OWN, 1);
1130 1130
1131 /* Make sure ownership is written to the descriptor */ 1131 /* Make sure ownership is written to the descriptor */
1132 wmb(); 1132 dma_wmb();
1133} 1133}
1134 1134
1135static void xgbe_rx_desc_init(struct xgbe_channel *channel) 1135static void xgbe_rx_desc_init(struct xgbe_channel *channel)
@@ -1358,18 +1358,20 @@ static void xgbe_tx_start_xmit(struct xgbe_channel *channel,
1358 struct xgbe_prv_data *pdata = channel->pdata; 1358 struct xgbe_prv_data *pdata = channel->pdata;
1359 struct xgbe_ring_data *rdata; 1359 struct xgbe_ring_data *rdata;
1360 1360
1361 /* Make sure everything is written before the register write */
1362 wmb();
1363
1361 /* Issue a poll command to Tx DMA by writing address 1364 /* Issue a poll command to Tx DMA by writing address
1362 * of next immediate free descriptor */ 1365 * of next immediate free descriptor */
1363 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); 1366 rdata = XGBE_GET_DESC_DATA(ring, ring->cur);
1364 XGMAC_DMA_IOWRITE(channel, DMA_CH_TDTR_LO, 1367 XGMAC_DMA_IOWRITE(channel, DMA_CH_TDTR_LO,
1365 lower_32_bits(rdata->rdesc_dma)); 1368 lower_32_bits(rdata->rdesc_dma));
1366 1369
1367 /* Start the Tx coalescing timer */ 1370 /* Start the Tx timer */
1368 if (pdata->tx_usecs && !channel->tx_timer_active) { 1371 if (pdata->tx_usecs && !channel->tx_timer_active) {
1369 channel->tx_timer_active = 1; 1372 channel->tx_timer_active = 1;
1370 hrtimer_start(&channel->tx_timer, 1373 mod_timer(&channel->tx_timer,
1371 ktime_set(0, pdata->tx_usecs * NSEC_PER_USEC), 1374 jiffies + usecs_to_jiffies(pdata->tx_usecs));
1372 HRTIMER_MODE_REL);
1373 } 1375 }
1374 1376
1375 ring->tx.xmit_more = 0; 1377 ring->tx.xmit_more = 0;
@@ -1565,7 +1567,7 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
1565 * is written to the descriptor(s) before setting the OWN bit 1567 * is written to the descriptor(s) before setting the OWN bit
1566 * for the first descriptor 1568 * for the first descriptor
1567 */ 1569 */
1568 wmb(); 1570 dma_wmb();
1569 1571
1570 /* Set OWN bit for the first descriptor */ 1572 /* Set OWN bit for the first descriptor */
1571 rdata = XGBE_GET_DESC_DATA(ring, start_index); 1573 rdata = XGBE_GET_DESC_DATA(ring, start_index);
@@ -1577,7 +1579,7 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
1577#endif 1579#endif
1578 1580
1579 /* Make sure ownership is written to the descriptor */ 1581 /* Make sure ownership is written to the descriptor */
1580 wmb(); 1582 dma_wmb();
1581 1583
1582 ring->cur = cur_index + 1; 1584 ring->cur = cur_index + 1;
1583 if (!packet->skb->xmit_more || 1585 if (!packet->skb->xmit_more ||
@@ -1613,7 +1615,7 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
1613 return 1; 1615 return 1;
1614 1616
1615 /* Make sure descriptor fields are read after reading the OWN bit */ 1617 /* Make sure descriptor fields are read after reading the OWN bit */
1616 rmb(); 1618 dma_rmb();
1617 1619
1618#ifdef XGMAC_ENABLE_RX_DESC_DUMP 1620#ifdef XGMAC_ENABLE_RX_DESC_DUMP
1619 xgbe_dump_rx_desc(ring, rdesc, ring->cur); 1621 xgbe_dump_rx_desc(ring, rdesc, ring->cur);
@@ -2004,7 +2006,8 @@ static void xgbe_config_tx_fifo_size(struct xgbe_prv_data *pdata)
2004 for (i = 0; i < pdata->tx_q_count; i++) 2006 for (i = 0; i < pdata->tx_q_count; i++)
2005 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TQS, fifo_size); 2007 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_TQOMR, TQS, fifo_size);
2006 2008
2007 netdev_notice(pdata->netdev, "%d Tx queues, %d byte fifo per queue\n", 2009 netdev_notice(pdata->netdev,
2010 "%d Tx hardware queues, %d byte fifo per queue\n",
2008 pdata->tx_q_count, ((fifo_size + 1) * 256)); 2011 pdata->tx_q_count, ((fifo_size + 1) * 256));
2009} 2012}
2010 2013
@@ -2019,7 +2022,8 @@ static void xgbe_config_rx_fifo_size(struct xgbe_prv_data *pdata)
2019 for (i = 0; i < pdata->rx_q_count; i++) 2022 for (i = 0; i < pdata->rx_q_count; i++)
2020 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RQS, fifo_size); 2023 XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, RQS, fifo_size);
2021 2024
2022 netdev_notice(pdata->netdev, "%d Rx queues, %d byte fifo per queue\n", 2025 netdev_notice(pdata->netdev,
2026 "%d Rx hardware queues, %d byte fifo per queue\n",
2023 pdata->rx_q_count, ((fifo_size + 1) * 256)); 2027 pdata->rx_q_count, ((fifo_size + 1) * 256));
2024} 2028}
2025 2029
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 885b02b5be07..347fe2419a18 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -411,11 +411,9 @@ static irqreturn_t xgbe_dma_isr(int irq, void *data)
411 return IRQ_HANDLED; 411 return IRQ_HANDLED;
412} 412}
413 413
414static enum hrtimer_restart xgbe_tx_timer(struct hrtimer *timer) 414static void xgbe_tx_timer(unsigned long data)
415{ 415{
416 struct xgbe_channel *channel = container_of(timer, 416 struct xgbe_channel *channel = (struct xgbe_channel *)data;
417 struct xgbe_channel,
418 tx_timer);
419 struct xgbe_prv_data *pdata = channel->pdata; 417 struct xgbe_prv_data *pdata = channel->pdata;
420 struct napi_struct *napi; 418 struct napi_struct *napi;
421 419
@@ -437,8 +435,6 @@ static enum hrtimer_restart xgbe_tx_timer(struct hrtimer *timer)
437 channel->tx_timer_active = 0; 435 channel->tx_timer_active = 0;
438 436
439 DBGPR("<--xgbe_tx_timer\n"); 437 DBGPR("<--xgbe_tx_timer\n");
440
441 return HRTIMER_NORESTART;
442} 438}
443 439
444static void xgbe_init_tx_timers(struct xgbe_prv_data *pdata) 440static void xgbe_init_tx_timers(struct xgbe_prv_data *pdata)
@@ -454,9 +450,8 @@ static void xgbe_init_tx_timers(struct xgbe_prv_data *pdata)
454 break; 450 break;
455 451
456 DBGPR(" %s adding tx timer\n", channel->name); 452 DBGPR(" %s adding tx timer\n", channel->name);
457 hrtimer_init(&channel->tx_timer, CLOCK_MONOTONIC, 453 setup_timer(&channel->tx_timer, xgbe_tx_timer,
458 HRTIMER_MODE_REL); 454 (unsigned long)channel);
459 channel->tx_timer.function = xgbe_tx_timer;
460 } 455 }
461 456
462 DBGPR("<--xgbe_init_tx_timers\n"); 457 DBGPR("<--xgbe_init_tx_timers\n");
@@ -475,8 +470,7 @@ static void xgbe_stop_tx_timers(struct xgbe_prv_data *pdata)
475 break; 470 break;
476 471
477 DBGPR(" %s deleting tx timer\n", channel->name); 472 DBGPR(" %s deleting tx timer\n", channel->name);
478 channel->tx_timer_active = 0; 473 del_timer_sync(&channel->tx_timer);
479 hrtimer_cancel(&channel->tx_timer);
480 } 474 }
481 475
482 DBGPR("<--xgbe_stop_tx_timers\n"); 476 DBGPR("<--xgbe_stop_tx_timers\n");
@@ -519,6 +513,7 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
519 RXFIFOSIZE); 513 RXFIFOSIZE);
520 hw_feat->tx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, 514 hw_feat->tx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R,
521 TXFIFOSIZE); 515 TXFIFOSIZE);
516 hw_feat->dma_width = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADDR64);
522 hw_feat->dcb = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN); 517 hw_feat->dcb = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN);
523 hw_feat->sph = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN); 518 hw_feat->sph = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN);
524 hw_feat->tso = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN); 519 hw_feat->tso = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN);
@@ -553,6 +548,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
553 break; 548 break;
554 } 549 }
555 550
551 /* Translate the address width setting into actual number */
552 switch (hw_feat->dma_width) {
553 case 0:
554 hw_feat->dma_width = 32;
555 break;
556 case 1:
557 hw_feat->dma_width = 40;
558 break;
559 case 2:
560 hw_feat->dma_width = 48;
561 break;
562 default:
563 hw_feat->dma_width = 32;
564 }
565
556 /* The Queue, Channel and TC counts are zero based so increment them 566 /* The Queue, Channel and TC counts are zero based so increment them
557 * to get the actual number 567 * to get the actual number
558 */ 568 */
@@ -692,6 +702,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
692 DBGPR("-->xgbe_init_rx_coalesce\n"); 702 DBGPR("-->xgbe_init_rx_coalesce\n");
693 703
694 pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS); 704 pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS);
705 pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS;
695 pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES; 706 pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES;
696 707
697 hw_if->config_rx_coalesce(pdata); 708 hw_if->config_rx_coalesce(pdata);
@@ -1800,6 +1811,9 @@ static void xgbe_rx_refresh(struct xgbe_channel *channel)
1800 ring->dirty++; 1811 ring->dirty++;
1801 } 1812 }
1802 1813
1814 /* Make sure everything is written before the register write */
1815 wmb();
1816
1803 /* Update the Rx Tail Pointer Register with address of 1817 /* Update the Rx Tail Pointer Register with address of
1804 * the last cleaned entry */ 1818 * the last cleaned entry */
1805 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty - 1); 1819 rdata = XGBE_GET_DESC_DATA(ring, ring->dirty - 1);
@@ -1807,16 +1821,15 @@ static void xgbe_rx_refresh(struct xgbe_channel *channel)
1807 lower_32_bits(rdata->rdesc_dma)); 1821 lower_32_bits(rdata->rdesc_dma));
1808} 1822}
1809 1823
1810static struct sk_buff *xgbe_create_skb(struct xgbe_prv_data *pdata, 1824static struct sk_buff *xgbe_create_skb(struct napi_struct *napi,
1811 struct xgbe_ring_data *rdata, 1825 struct xgbe_ring_data *rdata,
1812 unsigned int *len) 1826 unsigned int *len)
1813{ 1827{
1814 struct net_device *netdev = pdata->netdev;
1815 struct sk_buff *skb; 1828 struct sk_buff *skb;
1816 u8 *packet; 1829 u8 *packet;
1817 unsigned int copy_len; 1830 unsigned int copy_len;
1818 1831
1819 skb = netdev_alloc_skb_ip_align(netdev, rdata->rx.hdr.dma_len); 1832 skb = napi_alloc_skb(napi, rdata->rx.hdr.dma_len);
1820 if (!skb) 1833 if (!skb)
1821 return NULL; 1834 return NULL;
1822 1835
@@ -1863,7 +1876,7 @@ static int xgbe_tx_poll(struct xgbe_channel *channel)
1863 1876
1864 /* Make sure descriptor fields are read after reading the OWN 1877 /* Make sure descriptor fields are read after reading the OWN
1865 * bit */ 1878 * bit */
1866 rmb(); 1879 dma_rmb();
1867 1880
1868#ifdef XGMAC_ENABLE_TX_DESC_DUMP 1881#ifdef XGMAC_ENABLE_TX_DESC_DUMP
1869 xgbe_dump_tx_desc(ring, ring->dirty, 1, 0); 1882 xgbe_dump_tx_desc(ring, ring->dirty, 1, 0);
@@ -1986,7 +1999,7 @@ read_again:
1986 rdata->rx.hdr.dma_len, 1999 rdata->rx.hdr.dma_len,
1987 DMA_FROM_DEVICE); 2000 DMA_FROM_DEVICE);
1988 2001
1989 skb = xgbe_create_skb(pdata, rdata, &put_len); 2002 skb = xgbe_create_skb(napi, rdata, &put_len);
1990 if (!skb) { 2003 if (!skb) {
1991 error = 1; 2004 error = 1;
1992 goto skip_data; 2005 goto skip_data;
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
index ebf489351555..b4f6eaaa08f0 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
@@ -291,7 +291,6 @@ static int xgbe_get_settings(struct net_device *netdev,
291 return -ENODEV; 291 return -ENODEV;
292 292
293 ret = phy_ethtool_gset(pdata->phydev, cmd); 293 ret = phy_ethtool_gset(pdata->phydev, cmd);
294 cmd->transceiver = XCVR_EXTERNAL;
295 294
296 DBGPR("<--xgbe_get_settings\n"); 295 DBGPR("<--xgbe_get_settings\n");
297 296
@@ -378,18 +377,14 @@ static int xgbe_get_coalesce(struct net_device *netdev,
378 struct ethtool_coalesce *ec) 377 struct ethtool_coalesce *ec)
379{ 378{
380 struct xgbe_prv_data *pdata = netdev_priv(netdev); 379 struct xgbe_prv_data *pdata = netdev_priv(netdev);
381 struct xgbe_hw_if *hw_if = &pdata->hw_if;
382 unsigned int riwt;
383 380
384 DBGPR("-->xgbe_get_coalesce\n"); 381 DBGPR("-->xgbe_get_coalesce\n");
385 382
386 memset(ec, 0, sizeof(struct ethtool_coalesce)); 383 memset(ec, 0, sizeof(struct ethtool_coalesce));
387 384
388 riwt = pdata->rx_riwt; 385 ec->rx_coalesce_usecs = pdata->rx_usecs;
389 ec->rx_coalesce_usecs = hw_if->riwt_to_usec(pdata, riwt);
390 ec->rx_max_coalesced_frames = pdata->rx_frames; 386 ec->rx_max_coalesced_frames = pdata->rx_frames;
391 387
392 ec->tx_coalesce_usecs = pdata->tx_usecs;
393 ec->tx_max_coalesced_frames = pdata->tx_frames; 388 ec->tx_max_coalesced_frames = pdata->tx_frames;
394 389
395 DBGPR("<--xgbe_get_coalesce\n"); 390 DBGPR("<--xgbe_get_coalesce\n");
@@ -403,13 +398,14 @@ static int xgbe_set_coalesce(struct net_device *netdev,
403 struct xgbe_prv_data *pdata = netdev_priv(netdev); 398 struct xgbe_prv_data *pdata = netdev_priv(netdev);
404 struct xgbe_hw_if *hw_if = &pdata->hw_if; 399 struct xgbe_hw_if *hw_if = &pdata->hw_if;
405 unsigned int rx_frames, rx_riwt, rx_usecs; 400 unsigned int rx_frames, rx_riwt, rx_usecs;
406 unsigned int tx_frames, tx_usecs; 401 unsigned int tx_frames;
407 402
408 DBGPR("-->xgbe_set_coalesce\n"); 403 DBGPR("-->xgbe_set_coalesce\n");
409 404
410 /* Check for not supported parameters */ 405 /* Check for not supported parameters */
411 if ((ec->rx_coalesce_usecs_irq) || 406 if ((ec->rx_coalesce_usecs_irq) ||
412 (ec->rx_max_coalesced_frames_irq) || 407 (ec->rx_max_coalesced_frames_irq) ||
408 (ec->tx_coalesce_usecs) ||
413 (ec->tx_coalesce_usecs_irq) || 409 (ec->tx_coalesce_usecs_irq) ||
414 (ec->tx_max_coalesced_frames_irq) || 410 (ec->tx_max_coalesced_frames_irq) ||
415 (ec->stats_block_coalesce_usecs) || 411 (ec->stats_block_coalesce_usecs) ||
@@ -439,17 +435,17 @@ static int xgbe_set_coalesce(struct net_device *netdev,
439 } 435 }
440 436
441 rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs); 437 rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs);
438 rx_usecs = ec->rx_coalesce_usecs;
442 rx_frames = ec->rx_max_coalesced_frames; 439 rx_frames = ec->rx_max_coalesced_frames;
443 440
444 /* Use smallest possible value if conversion resulted in zero */ 441 /* Use smallest possible value if conversion resulted in zero */
445 if (ec->rx_coalesce_usecs && !rx_riwt) 442 if (rx_usecs && !rx_riwt)
446 rx_riwt = 1; 443 rx_riwt = 1;
447 444
448 /* Check the bounds of values for Rx */ 445 /* Check the bounds of values for Rx */
449 if (rx_riwt > XGMAC_MAX_DMA_RIWT) { 446 if (rx_riwt > XGMAC_MAX_DMA_RIWT) {
450 rx_usecs = hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT);
451 netdev_alert(netdev, "rx-usec is limited to %d usecs\n", 447 netdev_alert(netdev, "rx-usec is limited to %d usecs\n",
452 rx_usecs); 448 hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT));
453 return -EINVAL; 449 return -EINVAL;
454 } 450 }
455 if (rx_frames > pdata->rx_desc_count) { 451 if (rx_frames > pdata->rx_desc_count) {
@@ -458,7 +454,6 @@ static int xgbe_set_coalesce(struct net_device *netdev,
458 return -EINVAL; 454 return -EINVAL;
459 } 455 }
460 456
461 tx_usecs = ec->tx_coalesce_usecs;
462 tx_frames = ec->tx_max_coalesced_frames; 457 tx_frames = ec->tx_max_coalesced_frames;
463 458
464 /* Check the bounds of values for Tx */ 459 /* Check the bounds of values for Tx */
@@ -469,10 +464,10 @@ static int xgbe_set_coalesce(struct net_device *netdev,
469 } 464 }
470 465
471 pdata->rx_riwt = rx_riwt; 466 pdata->rx_riwt = rx_riwt;
467 pdata->rx_usecs = rx_usecs;
472 pdata->rx_frames = rx_frames; 468 pdata->rx_frames = rx_frames;
473 hw_if->config_rx_coalesce(pdata); 469 hw_if->config_rx_coalesce(pdata);
474 470
475 pdata->tx_usecs = tx_usecs;
476 pdata->tx_frames = tx_frames; 471 pdata->tx_frames = tx_frames;
477 hw_if->config_tx_coalesce(pdata); 472 hw_if->config_tx_coalesce(pdata);
478 473
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 32dd65137051..2e4c22d94a6b 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -374,15 +374,6 @@ static int xgbe_probe(struct platform_device *pdev)
374 pdata->awcache = XGBE_DMA_SYS_AWCACHE; 374 pdata->awcache = XGBE_DMA_SYS_AWCACHE;
375 } 375 }
376 376
377 /* Set the DMA mask */
378 if (!dev->dma_mask)
379 dev->dma_mask = &dev->coherent_dma_mask;
380 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
381 if (ret) {
382 dev_err(dev, "dma_set_mask_and_coherent failed\n");
383 goto err_io;
384 }
385
386 /* Get the device interrupt */ 377 /* Get the device interrupt */
387 ret = platform_get_irq(pdev, 0); 378 ret = platform_get_irq(pdev, 0);
388 if (ret < 0) { 379 if (ret < 0) {
@@ -409,6 +400,16 @@ static int xgbe_probe(struct platform_device *pdev)
409 /* Set default configuration data */ 400 /* Set default configuration data */
410 xgbe_default_config(pdata); 401 xgbe_default_config(pdata);
411 402
403 /* Set the DMA mask */
404 if (!dev->dma_mask)
405 dev->dma_mask = &dev->coherent_dma_mask;
406 ret = dma_set_mask_and_coherent(dev,
407 DMA_BIT_MASK(pdata->hw_feat.dma_width));
408 if (ret) {
409 dev_err(dev, "dma_set_mask_and_coherent failed\n");
410 goto err_io;
411 }
412
412 /* Calculate the number of Tx and Rx rings to be created 413 /* Calculate the number of Tx and Rx rings to be created
413 * -Tx (DMA) Channels map 1-to-1 to Tx Queues so set 414 * -Tx (DMA) Channels map 1-to-1 to Tx Queues so set
414 * the number of Tx queues to the number of Tx channels 415 * the number of Tx queues to the number of Tx channels
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index 1eea3e5a5d08..dd742426eb04 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -222,7 +222,7 @@
222 ((_idx) & ((_ring)->rdesc_count - 1))) 222 ((_idx) & ((_ring)->rdesc_count - 1)))
223 223
224/* Default coalescing parameters */ 224/* Default coalescing parameters */
225#define XGMAC_INIT_DMA_TX_USECS 50 225#define XGMAC_INIT_DMA_TX_USECS 1000
226#define XGMAC_INIT_DMA_TX_FRAMES 25 226#define XGMAC_INIT_DMA_TX_FRAMES 25
227 227
228#define XGMAC_MAX_DMA_RIWT 0xff 228#define XGMAC_MAX_DMA_RIWT 0xff
@@ -410,7 +410,7 @@ struct xgbe_channel {
410 unsigned int saved_ier; 410 unsigned int saved_ier;
411 411
412 unsigned int tx_timer_active; 412 unsigned int tx_timer_active;
413 struct hrtimer tx_timer; 413 struct timer_list tx_timer;
414 414
415 struct xgbe_ring *tx_ring; 415 struct xgbe_ring *tx_ring;
416 struct xgbe_ring *rx_ring; 416 struct xgbe_ring *rx_ring;
@@ -632,6 +632,7 @@ struct xgbe_hw_features {
632 unsigned int rx_fifo_size; /* MTL Receive FIFO Size */ 632 unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
633 unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */ 633 unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
634 unsigned int adv_ts_hi; /* Advance Timestamping High Word */ 634 unsigned int adv_ts_hi; /* Advance Timestamping High Word */
635 unsigned int dma_width; /* DMA width */
635 unsigned int dcb; /* DCB Feature */ 636 unsigned int dcb; /* DCB Feature */
636 unsigned int sph; /* Split Header Feature */ 637 unsigned int sph; /* Split Header Feature */
637 unsigned int tso; /* TCP Segmentation Offload */ 638 unsigned int tso; /* TCP Segmentation Offload */
@@ -715,6 +716,7 @@ struct xgbe_prv_data {
715 716
716 /* Rx coalescing settings */ 717 /* Rx coalescing settings */
717 unsigned int rx_riwt; 718 unsigned int rx_riwt;
719 unsigned int rx_usecs;
718 unsigned int rx_frames; 720 unsigned int rx_frames;
719 721
720 /* Current Rx buffer size */ 722 /* Current Rx buffer size */
diff --git a/drivers/net/phy/amd-xgbe-phy.c b/drivers/net/phy/amd-xgbe-phy.c
index 32efbd48f326..fb276f64cd64 100644
--- a/drivers/net/phy/amd-xgbe-phy.c
+++ b/drivers/net/phy/amd-xgbe-phy.c
@@ -78,6 +78,7 @@
78#include <linux/bitops.h> 78#include <linux/bitops.h>
79#include <linux/property.h> 79#include <linux/property.h>
80#include <linux/acpi.h> 80#include <linux/acpi.h>
81#include <linux/jiffies.h>
81 82
82MODULE_AUTHOR("Tom Lendacky <thomas.lendacky@amd.com>"); 83MODULE_AUTHOR("Tom Lendacky <thomas.lendacky@amd.com>");
83MODULE_LICENSE("Dual BSD/GPL"); 84MODULE_LICENSE("Dual BSD/GPL");
@@ -100,6 +101,8 @@ MODULE_DESCRIPTION("AMD 10GbE (amd-xgbe) PHY driver");
100#define XGBE_PHY_SPEED_2500 1 101#define XGBE_PHY_SPEED_2500 1
101#define XGBE_PHY_SPEED_10000 2 102#define XGBE_PHY_SPEED_10000 2
102 103
104#define XGBE_AN_MS_TIMEOUT 500
105
103#define XGBE_AN_INT_CMPLT 0x01 106#define XGBE_AN_INT_CMPLT 0x01
104#define XGBE_AN_INC_LINK 0x02 107#define XGBE_AN_INC_LINK 0x02
105#define XGBE_AN_PG_RCV 0x04 108#define XGBE_AN_PG_RCV 0x04
@@ -434,6 +437,7 @@ struct amd_xgbe_phy_priv {
434 unsigned int an_supported; 437 unsigned int an_supported;
435 unsigned int parallel_detect; 438 unsigned int parallel_detect;
436 unsigned int fec_ability; 439 unsigned int fec_ability;
440 unsigned long an_start;
437 441
438 unsigned int lpm_ctrl; /* CTRL1 for resume */ 442 unsigned int lpm_ctrl; /* CTRL1 for resume */
439}; 443};
@@ -902,8 +906,23 @@ static enum amd_xgbe_phy_an amd_xgbe_an_page_received(struct phy_device *phydev)
902{ 906{
903 struct amd_xgbe_phy_priv *priv = phydev->priv; 907 struct amd_xgbe_phy_priv *priv = phydev->priv;
904 enum amd_xgbe_phy_rx *state; 908 enum amd_xgbe_phy_rx *state;
909 unsigned long an_timeout;
905 int ret; 910 int ret;
906 911
912 if (!priv->an_start) {
913 priv->an_start = jiffies;
914 } else {
915 an_timeout = priv->an_start +
916 msecs_to_jiffies(XGBE_AN_MS_TIMEOUT);
917 if (time_after(jiffies, an_timeout)) {
918 /* Auto-negotiation timed out, reset state */
919 priv->kr_state = AMD_XGBE_RX_BPA;
920 priv->kx_state = AMD_XGBE_RX_BPA;
921
922 priv->an_start = jiffies;
923 }
924 }
925
907 state = amd_xgbe_phy_in_kr_mode(phydev) ? &priv->kr_state 926 state = amd_xgbe_phy_in_kr_mode(phydev) ? &priv->kr_state
908 : &priv->kx_state; 927 : &priv->kx_state;
909 928
@@ -932,8 +951,8 @@ static enum amd_xgbe_phy_an amd_xgbe_an_incompat_link(struct phy_device *phydev)
932 if (amd_xgbe_phy_in_kr_mode(phydev)) { 951 if (amd_xgbe_phy_in_kr_mode(phydev)) {
933 priv->kr_state = AMD_XGBE_RX_ERROR; 952 priv->kr_state = AMD_XGBE_RX_ERROR;
934 953
935 if (!(phydev->supported & SUPPORTED_1000baseKX_Full) && 954 if (!(phydev->advertising & SUPPORTED_1000baseKX_Full) &&
936 !(phydev->supported & SUPPORTED_2500baseX_Full)) 955 !(phydev->advertising & SUPPORTED_2500baseX_Full))
937 return AMD_XGBE_AN_NO_LINK; 956 return AMD_XGBE_AN_NO_LINK;
938 957
939 if (priv->kx_state != AMD_XGBE_RX_BPA) 958 if (priv->kx_state != AMD_XGBE_RX_BPA)
@@ -941,7 +960,7 @@ static enum amd_xgbe_phy_an amd_xgbe_an_incompat_link(struct phy_device *phydev)
941 } else { 960 } else {
942 priv->kx_state = AMD_XGBE_RX_ERROR; 961 priv->kx_state = AMD_XGBE_RX_ERROR;
943 962
944 if (!(phydev->supported & SUPPORTED_10000baseKR_Full)) 963 if (!(phydev->advertising & SUPPORTED_10000baseKR_Full))
945 return AMD_XGBE_AN_NO_LINK; 964 return AMD_XGBE_AN_NO_LINK;
946 965
947 if (priv->kr_state != AMD_XGBE_RX_BPA) 966 if (priv->kr_state != AMD_XGBE_RX_BPA)
@@ -1078,6 +1097,7 @@ again:
1078 priv->an_state = AMD_XGBE_AN_READY; 1097 priv->an_state = AMD_XGBE_AN_READY;
1079 priv->kr_state = AMD_XGBE_RX_BPA; 1098 priv->kr_state = AMD_XGBE_RX_BPA;
1080 priv->kx_state = AMD_XGBE_RX_BPA; 1099 priv->kx_state = AMD_XGBE_RX_BPA;
1100 priv->an_start = 0;
1081 } 1101 }
1082 1102
1083 if (cur_state != priv->an_state) 1103 if (cur_state != priv->an_state)
@@ -1101,7 +1121,7 @@ static int amd_xgbe_an_init(struct phy_device *phydev)
1101 if (ret < 0) 1121 if (ret < 0)
1102 return ret; 1122 return ret;
1103 1123
1104 if (phydev->supported & SUPPORTED_10000baseR_FEC) 1124 if (phydev->advertising & SUPPORTED_10000baseR_FEC)
1105 ret |= 0xc000; 1125 ret |= 0xc000;
1106 else 1126 else
1107 ret &= ~0xc000; 1127 ret &= ~0xc000;
@@ -1113,13 +1133,13 @@ static int amd_xgbe_an_init(struct phy_device *phydev)
1113 if (ret < 0) 1133 if (ret < 0)
1114 return ret; 1134 return ret;
1115 1135
1116 if (phydev->supported & SUPPORTED_10000baseKR_Full) 1136 if (phydev->advertising & SUPPORTED_10000baseKR_Full)
1117 ret |= 0x80; 1137 ret |= 0x80;
1118 else 1138 else
1119 ret &= ~0x80; 1139 ret &= ~0x80;
1120 1140
1121 if ((phydev->supported & SUPPORTED_1000baseKX_Full) || 1141 if ((phydev->advertising & SUPPORTED_1000baseKX_Full) ||
1122 (phydev->supported & SUPPORTED_2500baseX_Full)) 1142 (phydev->advertising & SUPPORTED_2500baseX_Full))
1123 ret |= 0x20; 1143 ret |= 0x20;
1124 else 1144 else
1125 ret &= ~0x20; 1145 ret &= ~0x20;
@@ -1131,12 +1151,12 @@ static int amd_xgbe_an_init(struct phy_device *phydev)
1131 if (ret < 0) 1151 if (ret < 0)
1132 return ret; 1152 return ret;
1133 1153
1134 if (phydev->supported & SUPPORTED_Pause) 1154 if (phydev->advertising & SUPPORTED_Pause)
1135 ret |= 0x400; 1155 ret |= 0x400;
1136 else 1156 else
1137 ret &= ~0x400; 1157 ret &= ~0x400;
1138 1158
1139 if (phydev->supported & SUPPORTED_Asym_Pause) 1159 if (phydev->advertising & SUPPORTED_Asym_Pause)
1140 ret |= 0x800; 1160 ret |= 0x800;
1141 else 1161 else
1142 ret &= ~0x800; 1162 ret &= ~0x800;
@@ -1212,38 +1232,14 @@ static int amd_xgbe_phy_config_init(struct phy_device *phydev)
1212 priv->an_irq_allocated = 1; 1232 priv->an_irq_allocated = 1;
1213 } 1233 }
1214 1234
1215 ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FEC_ABILITY);
1216 if (ret < 0)
1217 return ret;
1218 priv->fec_ability = ret & XGBE_PHY_FEC_MASK;
1219
1220 /* Initialize supported features */
1221 phydev->supported = SUPPORTED_Autoneg;
1222 phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
1223 phydev->supported |= SUPPORTED_Backplane;
1224 phydev->supported |= SUPPORTED_10000baseKR_Full;
1225 switch (priv->speed_set) {
1226 case AMD_XGBE_PHY_SPEEDSET_1000_10000:
1227 phydev->supported |= SUPPORTED_1000baseKX_Full;
1228 break;
1229 case AMD_XGBE_PHY_SPEEDSET_2500_10000:
1230 phydev->supported |= SUPPORTED_2500baseX_Full;
1231 break;
1232 }
1233
1234 if (priv->fec_ability & XGBE_PHY_FEC_ENABLE)
1235 phydev->supported |= SUPPORTED_10000baseR_FEC;
1236
1237 phydev->advertising = phydev->supported;
1238
1239 /* Set initial mode - call the mode setting routines 1235 /* Set initial mode - call the mode setting routines
1240 * directly to insure we are properly configured 1236 * directly to insure we are properly configured
1241 */ 1237 */
1242 if (phydev->supported & SUPPORTED_10000baseKR_Full) 1238 if (phydev->advertising & SUPPORTED_10000baseKR_Full)
1243 ret = amd_xgbe_phy_xgmii_mode(phydev); 1239 ret = amd_xgbe_phy_xgmii_mode(phydev);
1244 else if (phydev->supported & SUPPORTED_1000baseKX_Full) 1240 else if (phydev->advertising & SUPPORTED_1000baseKX_Full)
1245 ret = amd_xgbe_phy_gmii_mode(phydev); 1241 ret = amd_xgbe_phy_gmii_mode(phydev);
1246 else if (phydev->supported & SUPPORTED_2500baseX_Full) 1242 else if (phydev->advertising & SUPPORTED_2500baseX_Full)
1247 ret = amd_xgbe_phy_gmii_2500_mode(phydev); 1243 ret = amd_xgbe_phy_gmii_2500_mode(phydev);
1248 else 1244 else
1249 ret = -EINVAL; 1245 ret = -EINVAL;
@@ -1315,10 +1311,10 @@ static int __amd_xgbe_phy_config_aneg(struct phy_device *phydev)
1315 disable_irq(priv->an_irq); 1311 disable_irq(priv->an_irq);
1316 1312
1317 /* Start auto-negotiation in a supported mode */ 1313 /* Start auto-negotiation in a supported mode */
1318 if (phydev->supported & SUPPORTED_10000baseKR_Full) 1314 if (phydev->advertising & SUPPORTED_10000baseKR_Full)
1319 ret = amd_xgbe_phy_set_mode(phydev, AMD_XGBE_MODE_KR); 1315 ret = amd_xgbe_phy_set_mode(phydev, AMD_XGBE_MODE_KR);
1320 else if ((phydev->supported & SUPPORTED_1000baseKX_Full) || 1316 else if ((phydev->advertising & SUPPORTED_1000baseKX_Full) ||
1321 (phydev->supported & SUPPORTED_2500baseX_Full)) 1317 (phydev->advertising & SUPPORTED_2500baseX_Full))
1322 ret = amd_xgbe_phy_set_mode(phydev, AMD_XGBE_MODE_KX); 1318 ret = amd_xgbe_phy_set_mode(phydev, AMD_XGBE_MODE_KX);
1323 else 1319 else
1324 ret = -EINVAL; 1320 ret = -EINVAL;
@@ -1746,6 +1742,29 @@ static int amd_xgbe_phy_probe(struct phy_device *phydev)
1746 sizeof(priv->serdes_dfe_tap_ena)); 1742 sizeof(priv->serdes_dfe_tap_ena));
1747 } 1743 }
1748 1744
1745 /* Initialize supported features */
1746 phydev->supported = SUPPORTED_Autoneg;
1747 phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
1748 phydev->supported |= SUPPORTED_Backplane;
1749 phydev->supported |= SUPPORTED_10000baseKR_Full;
1750 switch (priv->speed_set) {
1751 case AMD_XGBE_PHY_SPEEDSET_1000_10000:
1752 phydev->supported |= SUPPORTED_1000baseKX_Full;
1753 break;
1754 case AMD_XGBE_PHY_SPEEDSET_2500_10000:
1755 phydev->supported |= SUPPORTED_2500baseX_Full;
1756 break;
1757 }
1758
1759 ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FEC_ABILITY);
1760 if (ret < 0)
1761 return ret;
1762 priv->fec_ability = ret & XGBE_PHY_FEC_MASK;
1763 if (priv->fec_ability & XGBE_PHY_FEC_ENABLE)
1764 phydev->supported |= SUPPORTED_10000baseR_FEC;
1765
1766 phydev->advertising = phydev->supported;
1767
1749 phydev->priv = priv; 1768 phydev->priv = priv;
1750 1769
1751 if (!priv->adev || acpi_disabled) 1770 if (!priv->adev || acpi_disabled)
@@ -1817,6 +1836,7 @@ static struct phy_driver amd_xgbe_phy_driver[] = {
1817 .phy_id_mask = XGBE_PHY_MASK, 1836 .phy_id_mask = XGBE_PHY_MASK,
1818 .name = "AMD XGBE PHY", 1837 .name = "AMD XGBE PHY",
1819 .features = 0, 1838 .features = 0,
1839 .flags = PHY_IS_INTERNAL,
1820 .probe = amd_xgbe_phy_probe, 1840 .probe = amd_xgbe_phy_probe,
1821 .remove = amd_xgbe_phy_remove, 1841 .remove = amd_xgbe_phy_remove,
1822 .soft_reset = amd_xgbe_phy_soft_reset, 1842 .soft_reset = amd_xgbe_phy_soft_reset,