summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/netronome
diff options
context:
space:
mode:
authorJakub Kicinski2016-11-03 18:12:02 +0100
committerDavid S. Miller2016-11-04 19:56:15 +0100
commite31230f9260f7bcf069e3962111f7e4656a1bfd4 (patch)
tree7d8a96f1a1db0b848e89368a608ce606034e0364 /drivers/net/ethernet/netronome
parentnfp: loosen relation between rings and IRQs vectors (diff)
downloadkernel-qcow2-linux-e31230f9260f7bcf069e3962111f7e4656a1bfd4.tar.gz
kernel-qcow2-linux-e31230f9260f7bcf069e3962111f7e4656a1bfd4.tar.xz
kernel-qcow2-linux-e31230f9260f7bcf069e3962111f7e4656a1bfd4.zip
nfp: add helper to reassign rings to IRQ vectors
Instead of fixing ring -> vector relations up in ring swap functions put the reassignment into a helper function which will reinit all links. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/netronome')
-rw-r--r--drivers/net/ethernet/netronome/nfp/nfp_net_common.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 97cc21eae466..2a4e1f1cb3c9 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -1601,16 +1601,11 @@ err_free_prev:
static void
nfp_net_tx_ring_set_swap(struct nfp_net *nn, struct nfp_net_ring_set *s)
{
- struct nfp_net_tx_ring *rings = s->rings;
struct nfp_net_ring_set new = *s;
- unsigned int r;
s->dcnt = nn->txd_cnt;
s->rings = nn->tx_rings;
- for (r = 0; r < nn->num_tx_rings; r++)
- nn->tx_rings[r].r_vec->tx_ring = &rings[r];
-
nn->txd_cnt = new.dcnt;
nn->tx_rings = new.rings;
}
@@ -1728,17 +1723,12 @@ err_free_ring:
static void
nfp_net_rx_ring_set_swap(struct nfp_net *nn, struct nfp_net_ring_set *s)
{
- struct nfp_net_rx_ring *rings = s->rings;
struct nfp_net_ring_set new = *s;
- unsigned int r;
s->mtu = nn->netdev->mtu;
s->dcnt = nn->rxd_cnt;
s->rings = nn->rx_rings;
- for (r = 0; r < nn->num_rx_rings; r++)
- nn->rx_rings[r].r_vec->rx_ring = &rings[r];
-
nn->netdev->mtu = new.mtu;
nn->fl_bufsz = nfp_net_calc_fl_bufsz(nn, new.mtu);
nn->rxd_cnt = new.dcnt;
@@ -1759,6 +1749,14 @@ nfp_net_rx_ring_set_free(struct nfp_net *nn, struct nfp_net_ring_set *s)
kfree(rings);
}
+static void
+nfp_net_vector_assign_rings(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,
+ int idx)
+{
+ r_vec->rx_ring = idx < nn->num_rx_rings ? &nn->rx_rings[idx] : NULL;
+ r_vec->tx_ring = idx < nn->num_tx_rings ? &nn->tx_rings[idx] : NULL;
+}
+
static int
nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,
int idx)
@@ -1766,20 +1764,6 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,
struct msix_entry *entry = &nn->irq_entries[r_vec->irq_idx];
int err;
- if (idx < nn->num_tx_rings) {
- r_vec->tx_ring = &nn->tx_rings[idx];
- nfp_net_tx_ring_init(r_vec->tx_ring, r_vec, idx);
- } else {
- r_vec->tx_ring = NULL;
- }
-
- if (idx < nn->num_rx_rings) {
- r_vec->rx_ring = &nn->rx_rings[idx];
- nfp_net_rx_ring_init(r_vec->rx_ring, r_vec, idx);
- } else {
- r_vec->rx_ring = NULL;
- }
-
snprintf(r_vec->name, sizeof(r_vec->name),
"%s-rxtx-%d", nn->netdev->name, idx);
err = request_irq(entry->vector, r_vec->handler, 0, r_vec->name, r_vec);
@@ -2100,6 +2084,9 @@ static int nfp_net_netdev_open(struct net_device *netdev)
goto err_free_rx_rings;
}
+ for (r = 0; r < nn->max_r_vecs; r++)
+ nfp_net_vector_assign_rings(nn, &nn->r_vecs[r], r);
+
err = netif_set_real_num_tx_queues(netdev, nn->num_tx_rings);
if (err)
goto err_free_rings;
@@ -2247,11 +2234,16 @@ nfp_net_ring_swap_enable(struct nfp_net *nn,
struct nfp_net_ring_set *rx,
struct nfp_net_ring_set *tx)
{
+ unsigned int r;
+
if (rx)
nfp_net_rx_ring_set_swap(nn, rx);
if (tx)
nfp_net_tx_ring_set_swap(nn, tx);
+ for (r = 0; r < nn->max_r_vecs; r++)
+ nfp_net_vector_assign_rings(nn, &nn->r_vecs[r], r);
+
return __nfp_net_set_config_and_enable(nn);
}