Skip to content

Commit

Permalink
net: systemport: Dynamically allocate number of TX rings
Browse files Browse the repository at this point in the history
In preparation for adding SYSTEMPORT Lite, which has twice as less transmit
queues than SYSTEMPORT make sure we do allocate TX rings based on the
systemport,txq property to get an appropriate memory footprint.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Jan 22, 2017
1 parent 9ca677b commit 7b78be4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions drivers/net/ethernet/broadcom/bcmsysport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1752,13 +1752,24 @@ static int bcm_sysport_probe(struct platform_device *pdev)
if (of_property_read_u32(dn, "systemport,num-rxq", &rxq))
rxq = 1;

/* Sanity check the number of transmit queues */
if (!txq || txq > TDMA_NUM_RINGS)
return -EINVAL;

dev = alloc_etherdev_mqs(sizeof(*priv), txq, rxq);
if (!dev)
return -ENOMEM;

/* Initialize private members */
priv = netdev_priv(dev);

/* Allocate number of TX rings */
priv->tx_rings = devm_kcalloc(&pdev->dev, txq,
sizeof(struct bcm_sysport_tx_ring),
GFP_KERNEL);
if (!priv->tx_rings)
return -ENOMEM;

priv->irq0 = platform_get_irq(pdev, 0);
priv->irq1 = platform_get_irq(pdev, 1);
priv->wol_irq = platform_get_irq(pdev, 2);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/bcmsysport.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ struct bcm_sysport_priv {
int wol_irq;

/* Transmit rings */
struct bcm_sysport_tx_ring tx_rings[TDMA_NUM_RINGS];
struct bcm_sysport_tx_ring *tx_rings;

/* Receive queue */
void __iomem *rx_bds;
Expand Down

0 comments on commit 7b78be4

Please sign in to comment.