Skip to content

Commit

Permalink
Merge branch 'amd-xgbe-next'
Browse files Browse the repository at this point in the history
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).
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed May 23, 2018
2 parents 50b464b + 76cce0a commit 7c08c41
Show file tree
Hide file tree
Showing 7 changed files with 699 additions and 258 deletions.
137 changes: 92 additions & 45 deletions drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,14 +1312,83 @@ int xgbe_powerup(struct net_device *netdev, unsigned int caller)
return 0;
}

static void xgbe_free_memory(struct xgbe_prv_data *pdata)
{
struct xgbe_desc_if *desc_if = &pdata->desc_if;

/* Free the ring descriptors and buffers */
desc_if->free_ring_resources(pdata);

/* Free the channel and ring structures */
xgbe_free_channels(pdata);
}

static int xgbe_alloc_memory(struct xgbe_prv_data *pdata)
{
struct xgbe_desc_if *desc_if = &pdata->desc_if;
struct net_device *netdev = pdata->netdev;
int ret;

if (pdata->new_tx_ring_count) {
pdata->tx_ring_count = pdata->new_tx_ring_count;
pdata->tx_q_count = pdata->tx_ring_count;
pdata->new_tx_ring_count = 0;
}

if (pdata->new_rx_ring_count) {
pdata->rx_ring_count = pdata->new_rx_ring_count;
pdata->new_rx_ring_count = 0;
}

/* Calculate the Rx buffer size before allocating rings */
pdata->rx_buf_size = xgbe_calc_rx_buf_size(netdev, netdev->mtu);

/* Allocate the channel and ring structures */
ret = xgbe_alloc_channels(pdata);
if (ret)
return ret;

/* Allocate the ring descriptors and buffers */
ret = desc_if->alloc_ring_resources(pdata);
if (ret)
goto err_channels;

/* Initialize the service and Tx timers */
xgbe_init_timers(pdata);

return 0;

err_channels:
xgbe_free_memory(pdata);

return ret;
}

static int xgbe_start(struct xgbe_prv_data *pdata)
{
struct xgbe_hw_if *hw_if = &pdata->hw_if;
struct xgbe_phy_if *phy_if = &pdata->phy_if;
struct net_device *netdev = pdata->netdev;
unsigned int i;
int ret;

DBGPR("-->xgbe_start\n");
/* Set the number of queues */
ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count);
if (ret) {
netdev_err(netdev, "error setting real tx queue count\n");
return ret;
}

ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count);
if (ret) {
netdev_err(netdev, "error setting real rx queue count\n");
return ret;
}

/* Set RSS lookup table data for programming */
for (i = 0; i < XGBE_RSS_MAX_TABLE_SIZE; i++)
XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH,
i % pdata->rx_ring_count);

ret = hw_if->init(pdata);
if (ret)
Expand Down Expand Up @@ -1347,8 +1416,6 @@ static int xgbe_start(struct xgbe_prv_data *pdata)

clear_bit(XGBE_STOPPED, &pdata->dev_state);

DBGPR("<--xgbe_start\n");

return 0;

err_irqs:
Expand Down Expand Up @@ -1426,10 +1493,22 @@ static void xgbe_stopdev(struct work_struct *work)
netdev_alert(pdata->netdev, "device stopped\n");
}

static void xgbe_restart_dev(struct xgbe_prv_data *pdata)
void xgbe_full_restart_dev(struct xgbe_prv_data *pdata)
{
DBGPR("-->xgbe_restart_dev\n");
/* If not running, "restart" will happen on open */
if (!netif_running(pdata->netdev))
return;

xgbe_stop(pdata);

xgbe_free_memory(pdata);
xgbe_alloc_memory(pdata);

xgbe_start(pdata);
}

void xgbe_restart_dev(struct xgbe_prv_data *pdata)
{
/* If not running, "restart" will happen on open */
if (!netif_running(pdata->netdev))
return;
Expand All @@ -1440,8 +1519,6 @@ static void xgbe_restart_dev(struct xgbe_prv_data *pdata)
xgbe_free_rx_data(pdata);

xgbe_start(pdata);

DBGPR("<--xgbe_restart_dev\n");
}

static void xgbe_restart(struct work_struct *work)
Expand Down Expand Up @@ -1827,11 +1904,8 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata,
static int xgbe_open(struct net_device *netdev)
{
struct xgbe_prv_data *pdata = netdev_priv(netdev);
struct xgbe_desc_if *desc_if = &pdata->desc_if;
int ret;

DBGPR("-->xgbe_open\n");

/* Create the various names based on netdev name */
snprintf(pdata->an_name, sizeof(pdata->an_name) - 1, "%s-pcs",
netdev_name(netdev));
Expand Down Expand Up @@ -1876,43 +1950,25 @@ static int xgbe_open(struct net_device *netdev)
goto err_sysclk;
}

/* Calculate the Rx buffer size before allocating rings */
ret = xgbe_calc_rx_buf_size(netdev, netdev->mtu);
if (ret < 0)
goto err_ptpclk;
pdata->rx_buf_size = ret;

/* Allocate the channel and ring structures */
ret = xgbe_alloc_channels(pdata);
if (ret)
goto err_ptpclk;

/* Allocate the ring descriptors and buffers */
ret = desc_if->alloc_ring_resources(pdata);
if (ret)
goto err_channels;

INIT_WORK(&pdata->service_work, xgbe_service);
INIT_WORK(&pdata->restart_work, xgbe_restart);
INIT_WORK(&pdata->stopdev_work, xgbe_stopdev);
INIT_WORK(&pdata->tx_tstamp_work, xgbe_tx_tstamp);
xgbe_init_timers(pdata);

ret = xgbe_alloc_memory(pdata);
if (ret)
goto err_ptpclk;

ret = xgbe_start(pdata);
if (ret)
goto err_rings;
goto err_mem;

clear_bit(XGBE_DOWN, &pdata->dev_state);

DBGPR("<--xgbe_open\n");

return 0;

err_rings:
desc_if->free_ring_resources(pdata);

err_channels:
xgbe_free_channels(pdata);
err_mem:
xgbe_free_memory(pdata);

err_ptpclk:
clk_disable_unprepare(pdata->ptpclk);
Expand All @@ -1932,18 +1988,11 @@ static int xgbe_open(struct net_device *netdev)
static int xgbe_close(struct net_device *netdev)
{
struct xgbe_prv_data *pdata = netdev_priv(netdev);
struct xgbe_desc_if *desc_if = &pdata->desc_if;

DBGPR("-->xgbe_close\n");

/* Stop the device */
xgbe_stop(pdata);

/* Free the ring descriptors and buffers */
desc_if->free_ring_resources(pdata);

/* Free the channel and ring structures */
xgbe_free_channels(pdata);
xgbe_free_memory(pdata);

/* Disable the clocks */
clk_disable_unprepare(pdata->ptpclk);
Expand All @@ -1957,8 +2006,6 @@ static int xgbe_close(struct net_device *netdev)

set_bit(XGBE_DOWN, &pdata->dev_state);

DBGPR("<--xgbe_close\n");

return 0;
}

Expand Down
Loading

0 comments on commit 7c08c41

Please sign in to comment.