aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2016-04-07 14:39:47 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-08 15:26:06 -0400
commita98cb2581211023539887a11f8391dd615409ab8 (patch)
treec0c3a0e281b9a914d2ba0875939a06ec5a3ea3b9
parent36a857e4f2c9783cd573c948df022011cb386aa4 (diff)
nfp: pass ring count as function parameter
Soon ring resize will call this functions with values different than the current configuration we need to explicitly pass the ring count as parameter. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_common.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index e7c420fdcb0d..c4f0c70e77ce 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -1407,17 +1407,18 @@ static void nfp_net_tx_ring_free(struct nfp_net_tx_ring *tx_ring)
1407/** 1407/**
1408 * nfp_net_tx_ring_alloc() - Allocate resource for a TX ring 1408 * nfp_net_tx_ring_alloc() - Allocate resource for a TX ring
1409 * @tx_ring: TX Ring structure to allocate 1409 * @tx_ring: TX Ring structure to allocate
1410 * @cnt: Ring buffer count
1410 * 1411 *
1411 * Return: 0 on success, negative errno otherwise. 1412 * Return: 0 on success, negative errno otherwise.
1412 */ 1413 */
1413static int nfp_net_tx_ring_alloc(struct nfp_net_tx_ring *tx_ring) 1414static int nfp_net_tx_ring_alloc(struct nfp_net_tx_ring *tx_ring, u32 cnt)
1414{ 1415{
1415 struct nfp_net_r_vector *r_vec = tx_ring->r_vec; 1416 struct nfp_net_r_vector *r_vec = tx_ring->r_vec;
1416 struct nfp_net *nn = r_vec->nfp_net; 1417 struct nfp_net *nn = r_vec->nfp_net;
1417 struct pci_dev *pdev = nn->pdev; 1418 struct pci_dev *pdev = nn->pdev;
1418 int sz; 1419 int sz;
1419 1420
1420 tx_ring->cnt = nn->txd_cnt; 1421 tx_ring->cnt = cnt;
1421 1422
1422 tx_ring->size = sizeof(*tx_ring->txds) * tx_ring->cnt; 1423 tx_ring->size = sizeof(*tx_ring->txds) * tx_ring->cnt;
1423 tx_ring->txds = dma_zalloc_coherent(&pdev->dev, tx_ring->size, 1424 tx_ring->txds = dma_zalloc_coherent(&pdev->dev, tx_ring->size,
@@ -1470,18 +1471,20 @@ static void nfp_net_rx_ring_free(struct nfp_net_rx_ring *rx_ring)
1470 * nfp_net_rx_ring_alloc() - Allocate resource for a RX ring 1471 * nfp_net_rx_ring_alloc() - Allocate resource for a RX ring
1471 * @rx_ring: RX ring to allocate 1472 * @rx_ring: RX ring to allocate
1472 * @fl_bufsz: Size of buffers to allocate 1473 * @fl_bufsz: Size of buffers to allocate
1474 * @cnt: Ring buffer count
1473 * 1475 *
1474 * Return: 0 on success, negative errno otherwise. 1476 * Return: 0 on success, negative errno otherwise.
1475 */ 1477 */
1476static int 1478static int
1477nfp_net_rx_ring_alloc(struct nfp_net_rx_ring *rx_ring, unsigned int fl_bufsz) 1479nfp_net_rx_ring_alloc(struct nfp_net_rx_ring *rx_ring, unsigned int fl_bufsz,
1480 u32 cnt)
1478{ 1481{
1479 struct nfp_net_r_vector *r_vec = rx_ring->r_vec; 1482 struct nfp_net_r_vector *r_vec = rx_ring->r_vec;
1480 struct nfp_net *nn = r_vec->nfp_net; 1483 struct nfp_net *nn = r_vec->nfp_net;
1481 struct pci_dev *pdev = nn->pdev; 1484 struct pci_dev *pdev = nn->pdev;
1482 int sz; 1485 int sz;
1483 1486
1484 rx_ring->cnt = nn->rxd_cnt; 1487 rx_ring->cnt = cnt;
1485 rx_ring->bufsz = fl_bufsz; 1488 rx_ring->bufsz = fl_bufsz;
1486 1489
1487 rx_ring->size = sizeof(*rx_ring->rxds) * rx_ring->cnt; 1490 rx_ring->size = sizeof(*rx_ring->rxds) * rx_ring->cnt;
@@ -1507,7 +1510,8 @@ err_alloc:
1507} 1510}
1508 1511
1509static struct nfp_net_rx_ring * 1512static struct nfp_net_rx_ring *
1510nfp_net_shadow_rx_rings_prepare(struct nfp_net *nn, unsigned int fl_bufsz) 1513nfp_net_shadow_rx_rings_prepare(struct nfp_net *nn, unsigned int fl_bufsz,
1514 u32 buf_cnt)
1511{ 1515{
1512 struct nfp_net_rx_ring *rings; 1516 struct nfp_net_rx_ring *rings;
1513 unsigned int r; 1517 unsigned int r;
@@ -1519,7 +1523,7 @@ nfp_net_shadow_rx_rings_prepare(struct nfp_net *nn, unsigned int fl_bufsz)
1519 for (r = 0; r < nn->num_rx_rings; r++) { 1523 for (r = 0; r < nn->num_rx_rings; r++) {
1520 nfp_net_rx_ring_init(&rings[r], nn->rx_rings[r].r_vec, r); 1524 nfp_net_rx_ring_init(&rings[r], nn->rx_rings[r].r_vec, r);
1521 1525
1522 if (nfp_net_rx_ring_alloc(&rings[r], fl_bufsz)) 1526 if (nfp_net_rx_ring_alloc(&rings[r], fl_bufsz, buf_cnt))
1523 goto err_free_prev; 1527 goto err_free_prev;
1524 1528
1525 if (nfp_net_rx_ring_bufs_alloc(nn, &rings[r])) 1529 if (nfp_net_rx_ring_bufs_alloc(nn, &rings[r]))
@@ -1878,12 +1882,12 @@ static int nfp_net_netdev_open(struct net_device *netdev)
1878 if (err) 1882 if (err)
1879 goto err_free_prev_vecs; 1883 goto err_free_prev_vecs;
1880 1884
1881 err = nfp_net_tx_ring_alloc(nn->r_vecs[r].tx_ring); 1885 err = nfp_net_tx_ring_alloc(nn->r_vecs[r].tx_ring, nn->txd_cnt);
1882 if (err) 1886 if (err)
1883 goto err_cleanup_vec_p; 1887 goto err_cleanup_vec_p;
1884 1888
1885 err = nfp_net_rx_ring_alloc(nn->r_vecs[r].rx_ring, 1889 err = nfp_net_rx_ring_alloc(nn->r_vecs[r].rx_ring,
1886 nn->fl_bufsz); 1890 nn->fl_bufsz, nn->rxd_cnt);
1887 if (err) 1891 if (err)
1888 goto err_free_tx_ring_p; 1892 goto err_free_tx_ring_p;
1889 1893
@@ -2063,7 +2067,8 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu)
2063 } 2067 }
2064 2068
2065 /* Prepare new rings */ 2069 /* Prepare new rings */
2066 tmp_rings = nfp_net_shadow_rx_rings_prepare(nn, new_fl_bufsz); 2070 tmp_rings = nfp_net_shadow_rx_rings_prepare(nn, new_fl_bufsz,
2071 nn->rxd_cnt);
2067 if (!tmp_rings) 2072 if (!tmp_rings)
2068 return -ENOMEM; 2073 return -ENOMEM;
2069 2074