Skip to content

Commit

Permalink
bnxt_en: Add IRQ remapping logic.
Browse files Browse the repository at this point in the history
Add remapping logic so that bnxt_en can use any arbitrary MSIX vectors.
This will allow the driver to reserve one range of MSIX vectors to be
used by both bnxt_en and bnxt_re.  bnxt_en can now skip over the MSIX
vectors used by bnxt_re.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed Apr 1, 2018
1 parent 08654eb commit e5811b8
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2444,8 +2444,10 @@ static void bnxt_free_cp_rings(struct bnxt *bp)

static int bnxt_alloc_cp_rings(struct bnxt *bp)
{
int i, rc;
int i, rc, ulp_base_vec, ulp_msix;

ulp_msix = bnxt_get_ulp_msix_num(bp);
ulp_base_vec = bnxt_get_ulp_msix_base(bp);
for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr;
Expand All @@ -2460,7 +2462,11 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
rc = bnxt_alloc_ring(bp, ring);
if (rc)
return rc;
ring->map_idx = i;

if (ulp_msix && i >= ulp_base_vec)
ring->map_idx = i + ulp_msix;
else
ring->map_idx = i;
}
return 0;
}
Expand Down Expand Up @@ -3384,15 +3390,27 @@ static void bnxt_disable_int(struct bnxt *bp)
}
}

static int bnxt_cp_num_to_irq_num(struct bnxt *bp, int n)
{
struct bnxt_napi *bnapi = bp->bnapi[n];
struct bnxt_cp_ring_info *cpr;

cpr = &bnapi->cp_ring;
return cpr->cp_ring_struct.map_idx;
}

static void bnxt_disable_int_sync(struct bnxt *bp)
{
int i;

atomic_inc(&bp->intr_sem);

bnxt_disable_int(bp);
for (i = 0; i < bp->cp_nr_rings; i++)
synchronize_irq(bp->irq_tbl[i].vector);
for (i = 0; i < bp->cp_nr_rings; i++) {
int map_idx = bnxt_cp_num_to_irq_num(bp, i);

synchronize_irq(bp->irq_tbl[map_idx].vector);
}
}

static void bnxt_enable_int(struct bnxt *bp)
Expand Down Expand Up @@ -5824,6 +5842,7 @@ static void bnxt_setup_msix(struct bnxt *bp)
}

for (i = 0; i < bp->cp_nr_rings; i++) {
int map_idx = bnxt_cp_num_to_irq_num(bp, i);
char *attr;

if (bp->flags & BNXT_FLAG_SHARED_RINGS)
Expand All @@ -5833,9 +5852,9 @@ static void bnxt_setup_msix(struct bnxt *bp)
else
attr = "tx";

snprintf(bp->irq_tbl[i].name, len, "%s-%s-%d", dev->name, attr,
i);
bp->irq_tbl[i].handler = bnxt_msix;
snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name,
attr, i);
bp->irq_tbl[map_idx].handler = bnxt_msix;
}
}

Expand Down Expand Up @@ -6059,7 +6078,9 @@ static void bnxt_free_irq(struct bnxt *bp)
return;

for (i = 0; i < bp->cp_nr_rings; i++) {
irq = &bp->irq_tbl[i];
int map_idx = bnxt_cp_num_to_irq_num(bp, i);

irq = &bp->irq_tbl[map_idx];
if (irq->requested) {
if (irq->have_cpumask) {
irq_set_affinity_hint(irq->vector, NULL);
Expand All @@ -6078,14 +6099,25 @@ static int bnxt_request_irq(struct bnxt *bp)
int i, j, rc = 0;
unsigned long flags = 0;
#ifdef CONFIG_RFS_ACCEL
struct cpu_rmap *rmap = bp->dev->rx_cpu_rmap;
struct cpu_rmap *rmap;
#endif

rc = bnxt_setup_int_mode(bp);
if (rc) {
netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n",
rc);
return rc;
}
#ifdef CONFIG_RFS_ACCEL
rmap = bp->dev->rx_cpu_rmap;
#endif
if (!(bp->flags & BNXT_FLAG_USING_MSIX))
flags = IRQF_SHARED;

for (i = 0, j = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_irq *irq = &bp->irq_tbl[i];
int map_idx = bnxt_cp_num_to_irq_num(bp, i);
struct bnxt_irq *irq = &bp->irq_tbl[map_idx];

#ifdef CONFIG_RFS_ACCEL
if (rmap && bp->bnapi[i]->rx_ring) {
rc = irq_cpu_rmap_add(rmap, irq->vector);
Expand Down Expand Up @@ -6805,13 +6837,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
rc = bnxt_reserve_rings(bp);
if (rc)
return rc;

rc = bnxt_setup_int_mode(bp);
if (rc) {
netdev_err(bp->dev, "bnxt_setup_int_mode err: %x\n",
rc);
return rc;
}
}
if ((bp->flags & BNXT_FLAG_RFS) &&
!(bp->flags & BNXT_FLAG_USING_MSIX)) {
Expand Down

0 comments on commit e5811b8

Please sign in to comment.