]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - drivers/net/ethernet/amd/xgbe/xgbe-drv.c
amd-xgbe: Add PCI device support
[thirdparty/kernel/stable.git] / drivers / net / ethernet / amd / xgbe / xgbe-drv.c
index 7f9216db026fa2ee8abe1cf695415ad0be237dc8..efa01a5a81b66647b92cbe68a79bb6f38a795498 100644 (file)
  *     THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <linux/platform_device.h>
 #include <linux/spinlock.h>
 #include <linux/tcp.h>
 #include <linux/if_vlan.h>
@@ -160,18 +159,8 @@ static int xgbe_alloc_channels(struct xgbe_prv_data *pdata)
                channel->dma_regs = pdata->xgmac_regs + DMA_CH_BASE +
                                    (DMA_CH_INC * i);
 
-               if (pdata->per_channel_irq) {
-                       /* Get the DMA interrupt (offset 1) */
-                       ret = platform_get_irq(pdata->pdev, i + 1);
-                       if (ret < 0) {
-                               netdev_err(pdata->netdev,
-                                          "platform_get_irq %u failed\n",
-                                          i + 1);
-                               goto err_irq;
-                       }
-
-                       channel->dma_irq = ret;
-               }
+               if (pdata->per_channel_irq)
+                       channel->dma_irq = pdata->channel_irq[i];
 
                if (i < pdata->tx_ring_count) {
                        spin_lock_init(&tx_ring->lock);
@@ -194,9 +183,6 @@ static int xgbe_alloc_channels(struct xgbe_prv_data *pdata)
 
        return 0;
 
-err_irq:
-       kfree(rx_ring);
-
 err_rx_ring:
        kfree(tx_ring);
 
@@ -257,11 +243,6 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu)
 {
        unsigned int rx_buf_size;
 
-       if (mtu > XGMAC_JUMBO_PACKET_MTU) {
-               netdev_alert(netdev, "MTU exceeds maximum supported value\n");
-               return -EINVAL;
-       }
-
        rx_buf_size = mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
        rx_buf_size = clamp_val(rx_buf_size, XGBE_RX_MIN_BUF_SIZE, PAGE_SIZE);
 
@@ -393,6 +374,10 @@ static irqreturn_t xgbe_isr(int irq, void *data)
                }
        }
 
+       /* If there is not a separate AN irq, handle it here */
+       if (pdata->dev_irq == pdata->an_irq)
+               pdata->phy_if.an_isr(irq, pdata);
+
 isr_done:
        return IRQ_HANDLED;
 }
@@ -595,6 +580,10 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
        hw_feat->tx_ch_cnt++;
        hw_feat->tc_cnt++;
 
+       /* Translate the fifo sizes into actual numbers */
+       hw_feat->rx_fifo_size = 1 << (hw_feat->rx_fifo_size + 7);
+       hw_feat->tx_fifo_size = 1 << (hw_feat->tx_fifo_size + 7);
+
        DBGPR("<--xgbe_get_all_hw_features\n");
 }
 
@@ -783,7 +772,7 @@ static void xgbe_free_rx_data(struct xgbe_prv_data *pdata)
        DBGPR("<--xgbe_free_rx_data\n");
 }
 
-static int xgbe_phy_init(struct xgbe_prv_data *pdata)
+static int xgbe_phy_reset(struct xgbe_prv_data *pdata)
 {
        pdata->phy_link = -1;
        pdata->phy_speed = SPEED_UNKNOWN;
@@ -879,16 +868,16 @@ static int xgbe_start(struct xgbe_prv_data *pdata)
 
        hw_if->init(pdata);
 
-       ret = phy_if->phy_start(pdata);
-       if (ret)
-               goto err_phy;
-
        xgbe_napi_enable(pdata, 1);
 
        ret = xgbe_request_irqs(pdata);
        if (ret)
                goto err_napi;
 
+       ret = phy_if->phy_start(pdata);
+       if (ret)
+               goto err_irqs;
+
        hw_if->enable_tx(pdata);
        hw_if->enable_rx(pdata);
 
@@ -901,12 +890,12 @@ static int xgbe_start(struct xgbe_prv_data *pdata)
 
        return 0;
 
+err_irqs:
+       xgbe_free_irqs(pdata);
+
 err_napi:
        xgbe_napi_disable(pdata, 1);
 
-       phy_if->phy_stop(pdata);
-
-err_phy:
        hw_if->exit(pdata);
 
        return ret;
@@ -1297,8 +1286,8 @@ static int xgbe_open(struct net_device *netdev)
 
        DBGPR("-->xgbe_open\n");
 
-       /* Initialize the phy */
-       ret = xgbe_phy_init(pdata);
+       /* Reset the phy settings */
+       ret = xgbe_phy_reset(pdata);
        if (ret)
                return ret;