Skip to content

Commit

Permalink
amd-xgbe: Prepare for supporting PCI devices
Browse files Browse the repository at this point in the history
Update the driver framework to separate out platform/ACPI specific code
from general code during device initialization. This will allow for the
introduction of PCI device support.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Lendacky, Thomas authored and David S. Miller committed Nov 4, 2016
1 parent 4b8acdf commit bd8255d
Show file tree
Hide file tree
Showing 6 changed files with 755 additions and 510 deletions.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/amd/xgbe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ obj-$(CONFIG_AMD_XGBE) += amd-xgbe.o
amd-xgbe-objs := xgbe-main.o xgbe-drv.o xgbe-dev.o \
xgbe-desc.o xgbe-ethtool.o xgbe-mdio.o \
xgbe-ptp.o \
xgbe-phy-v1.o
xgbe-phy-v1.o \
xgbe-platform.o

amd-xgbe-$(CONFIG_AMD_XGBE_DCB) += xgbe-dcb.o
amd-xgbe-$(CONFIG_DEBUG_FS) += xgbe-debugfs.o
16 changes: 4 additions & 12 deletions drivers/net/ethernet/amd/xgbe/xgbe-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,24 +2088,16 @@ static void xgbe_config_flow_control_threshold(struct xgbe_prv_data *pdata)

static unsigned int xgbe_get_tx_fifo_size(struct xgbe_prv_data *pdata)
{
unsigned int fifo_size;

/* Calculate the configured fifo size */
fifo_size = 1 << (pdata->hw_feat.tx_fifo_size + 7);

/* The configured value may not be the actual amount of fifo RAM */
return min_t(unsigned int, XGMAC_FIFO_TX_MAX, fifo_size);
return min_t(unsigned int, pdata->tx_max_fifo_size,
pdata->hw_feat.tx_fifo_size);
}

static unsigned int xgbe_get_rx_fifo_size(struct xgbe_prv_data *pdata)
{
unsigned int fifo_size;

/* Calculate the configured fifo size */
fifo_size = 1 << (pdata->hw_feat.rx_fifo_size + 7);

/* The configured value may not be the actual amount of fifo RAM */
return min_t(unsigned int, XGMAC_FIFO_RX_MAX, fifo_size);
return min_t(unsigned int, pdata->rx_max_fifo_size,
pdata->hw_feat.rx_fifo_size);
}

static void xgbe_calculate_equal_fifo(unsigned int fifo_size,
Expand Down
22 changes: 6 additions & 16 deletions drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/tcp.h>
#include <linux/if_vlan.h>
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -590,6 +576,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");
}

Expand Down
Loading

0 comments on commit bd8255d

Please sign in to comment.