Skip to content

Commit da6c806

Browse files
Rajesh Borundiadavem330
authored andcommitted
qlcnic: Use shared interrupt vector for Tx and Rx
o VF will use shared MSI-X interrupt vector for Tx and Rx. o When QLCNIC_INTR_SHARED flag is set Tx and Rx will share MSI-X interrupt vector. Tx will use a separate MSI-X interrupt vector from Rx otherwise. Signed-off-by: Rajesh Borundia <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f846833 commit da6c806

File tree

5 files changed

+80
-22
lines changed

5 files changed

+80
-22
lines changed

drivers/net/ethernet/qlogic/qlcnic/qlcnic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ struct qlcnic_ipaddr {
897897
#define QLCNIC_FW_RESET_OWNER 0x2000
898898
#define QLCNIC_FW_HANG 0x4000
899899
#define QLCNIC_FW_LRO_MSS_CAP 0x8000
900+
#define QLCNIC_TX_INTR_SHARED 0x10000
900901
#define QLCNIC_IS_MSI_FAMILY(adapter) \
901902
((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED))
902903

drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
410410
num_intr));
411411
/* account for AEN interrupt MSI-X based interrupts */
412412
num_msix += 1;
413-
num_msix += adapter->max_drv_tx_rings;
413+
414+
if (!(adapter->flags & QLCNIC_TX_INTR_SHARED))
415+
num_msix += adapter->max_drv_tx_rings;
416+
414417
err = qlcnic_enable_msix(adapter, num_msix);
415418
if (err == -ENOMEM)
416419
return err;
@@ -1243,6 +1246,7 @@ int qlcnic_83xx_create_tx_ctx(struct qlcnic_adapter *adapter,
12431246
struct qlcnic_tx_mbx mbx;
12441247
struct qlcnic_tx_mbx_out *mbx_out;
12451248
struct qlcnic_hardware_context *ahw = adapter->ahw;
1249+
u32 msix_vector;
12461250

12471251
/* Reset host resources */
12481252
tx->producer = 0;
@@ -1257,10 +1261,16 @@ int qlcnic_83xx_create_tx_ctx(struct qlcnic_adapter *adapter,
12571261
mbx.cnsmr_index_low = LSD(tx->hw_cons_phys_addr);
12581262
mbx.cnsmr_index_high = MSD(tx->hw_cons_phys_addr);
12591263
mbx.size = tx->num_desc;
1260-
if (adapter->flags & QLCNIC_MSIX_ENABLED)
1261-
msix_id = ahw->intr_tbl[adapter->max_sds_rings + ring].id;
1262-
else
1264+
if (adapter->flags & QLCNIC_MSIX_ENABLED) {
1265+
if (!(adapter->flags & QLCNIC_TX_INTR_SHARED))
1266+
msix_vector = adapter->max_sds_rings + ring;
1267+
else
1268+
msix_vector = adapter->max_sds_rings - 1;
1269+
msix_id = ahw->intr_tbl[msix_vector].id;
1270+
} else {
12631271
msix_id = QLCRDX(ahw, QLCNIC_DEF_INT_ID);
1272+
}
1273+
12641274
if (adapter->ahw->diag_test != QLCNIC_LOOPBACK_TEST)
12651275
mbx.intr_id = msix_id;
12661276
else
@@ -1282,7 +1292,8 @@ int qlcnic_83xx_create_tx_ctx(struct qlcnic_adapter *adapter,
12821292
mbx_out = (struct qlcnic_tx_mbx_out *)&cmd.rsp.arg[2];
12831293
tx->crb_cmd_producer = ahw->pci_base0 + mbx_out->host_prod;
12841294
tx->ctx_id = mbx_out->ctx_id;
1285-
if (adapter->flags & QLCNIC_MSIX_ENABLED) {
1295+
if ((adapter->flags & QLCNIC_MSIX_ENABLED) &&
1296+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
12861297
intr_mask = ahw->intr_tbl[adapter->max_sds_rings + ring].src;
12871298
tx->crb_intr_mask = ahw->pci_base0 + intr_mask;
12881299
}

drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,29 @@ static int qlcnic_83xx_process_rcv_ring(struct qlcnic_host_sds_ring *sds_ring,
16911691
return count;
16921692
}
16931693

1694+
static int qlcnic_83xx_msix_sriov_vf_poll(struct napi_struct *napi, int budget)
1695+
{
1696+
int tx_complete;
1697+
int work_done;
1698+
struct qlcnic_host_sds_ring *sds_ring;
1699+
struct qlcnic_adapter *adapter;
1700+
struct qlcnic_host_tx_ring *tx_ring;
1701+
1702+
sds_ring = container_of(napi, struct qlcnic_host_sds_ring, napi);
1703+
adapter = sds_ring->adapter;
1704+
/* tx ring count = 1 */
1705+
tx_ring = adapter->tx_ring;
1706+
1707+
tx_complete = qlcnic_process_cmd_ring(adapter, tx_ring, budget);
1708+
work_done = qlcnic_83xx_process_rcv_ring(sds_ring, budget);
1709+
if ((work_done < budget) && tx_complete) {
1710+
napi_complete(&sds_ring->napi);
1711+
qlcnic_83xx_enable_intr(adapter, sds_ring);
1712+
}
1713+
1714+
return work_done;
1715+
}
1716+
16941717
static int qlcnic_83xx_poll(struct napi_struct *napi, int budget)
16951718
{
16961719
int tx_complete;
@@ -1768,7 +1791,8 @@ void qlcnic_83xx_napi_enable(struct qlcnic_adapter *adapter)
17681791
qlcnic_83xx_enable_intr(adapter, sds_ring);
17691792
}
17701793

1771-
if (adapter->flags & QLCNIC_MSIX_ENABLED) {
1794+
if ((adapter->flags & QLCNIC_MSIX_ENABLED) &&
1795+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
17721796
for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
17731797
tx_ring = &adapter->tx_ring[ring];
17741798
napi_enable(&tx_ring->napi);
@@ -1795,7 +1819,8 @@ void qlcnic_83xx_napi_disable(struct qlcnic_adapter *adapter)
17951819
napi_disable(&sds_ring->napi);
17961820
}
17971821

1798-
if (adapter->flags & QLCNIC_MSIX_ENABLED) {
1822+
if ((adapter->flags & QLCNIC_MSIX_ENABLED) &&
1823+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
17991824
for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
18001825
tx_ring = &adapter->tx_ring[ring];
18011826
qlcnic_83xx_disable_tx_intr(adapter, tx_ring);
@@ -1808,7 +1833,7 @@ void qlcnic_83xx_napi_disable(struct qlcnic_adapter *adapter)
18081833
int qlcnic_83xx_napi_add(struct qlcnic_adapter *adapter,
18091834
struct net_device *netdev)
18101835
{
1811-
int ring, max_sds_rings;
1836+
int ring, max_sds_rings, temp;
18121837
struct qlcnic_host_sds_ring *sds_ring;
18131838
struct qlcnic_host_tx_ring *tx_ring;
18141839
struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
@@ -1819,22 +1844,32 @@ int qlcnic_83xx_napi_add(struct qlcnic_adapter *adapter,
18191844
max_sds_rings = adapter->max_sds_rings;
18201845
for (ring = 0; ring < adapter->max_sds_rings; ring++) {
18211846
sds_ring = &recv_ctx->sds_rings[ring];
1822-
if (adapter->flags & QLCNIC_MSIX_ENABLED)
1823-
netif_napi_add(netdev, &sds_ring->napi,
1824-
qlcnic_83xx_rx_poll,
1825-
QLCNIC_NETDEV_WEIGHT * 2);
1826-
else
1847+
if (adapter->flags & QLCNIC_MSIX_ENABLED) {
1848+
if (!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
1849+
netif_napi_add(netdev, &sds_ring->napi,
1850+
qlcnic_83xx_rx_poll,
1851+
QLCNIC_NETDEV_WEIGHT * 2);
1852+
} else {
1853+
temp = QLCNIC_NETDEV_WEIGHT / max_sds_rings;
1854+
netif_napi_add(netdev, &sds_ring->napi,
1855+
qlcnic_83xx_msix_sriov_vf_poll,
1856+
temp);
1857+
}
1858+
1859+
} else {
18271860
netif_napi_add(netdev, &sds_ring->napi,
18281861
qlcnic_83xx_poll,
18291862
QLCNIC_NETDEV_WEIGHT / max_sds_rings);
1863+
}
18301864
}
18311865

18321866
if (qlcnic_alloc_tx_rings(adapter, netdev)) {
18331867
qlcnic_free_sds_rings(recv_ctx);
18341868
return -ENOMEM;
18351869
}
18361870

1837-
if (adapter->flags & QLCNIC_MSIX_ENABLED) {
1871+
if ((adapter->flags & QLCNIC_MSIX_ENABLED) &&
1872+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
18381873
for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
18391874
tx_ring = &adapter->tx_ring[ring];
18401875
netif_napi_add(netdev, &tx_ring->napi,
@@ -1860,7 +1895,8 @@ void qlcnic_83xx_napi_del(struct qlcnic_adapter *adapter)
18601895

18611896
qlcnic_free_sds_rings(adapter->recv_ctx);
18621897

1863-
if ((adapter->flags & QLCNIC_MSIX_ENABLED)) {
1898+
if ((adapter->flags & QLCNIC_MSIX_ENABLED) &&
1899+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
18641900
for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
18651901
tx_ring = &adapter->tx_ring[ring];
18661902
netif_napi_del(&tx_ring->napi);

drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,15 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
400400
{
401401
struct pci_dev *pdev = adapter->pdev;
402402
int err = -1, i;
403-
int max_tx_rings;
403+
int max_tx_rings, tx_vector;
404+
405+
if (adapter->flags & QLCNIC_TX_INTR_SHARED) {
406+
max_tx_rings = 0;
407+
tx_vector = 0;
408+
} else {
409+
max_tx_rings = adapter->max_drv_tx_rings;
410+
tx_vector = 1;
411+
}
404412

405413
if (!adapter->msix_entries) {
406414
adapter->msix_entries = kcalloc(num_msix,
@@ -423,7 +431,6 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
423431
if (qlcnic_83xx_check(adapter)) {
424432
adapter->ahw->num_msix = num_msix;
425433
/* subtract mail box and tx ring vectors */
426-
max_tx_rings = adapter->max_drv_tx_rings;
427434
adapter->max_sds_rings = num_msix -
428435
max_tx_rings - 1;
429436
} else {
@@ -436,11 +443,11 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
436443
"Unable to allocate %d MSI-X interrupt vectors\n",
437444
num_msix);
438445
if (qlcnic_83xx_check(adapter)) {
439-
if (err < QLC_83XX_MINIMUM_VECTOR)
446+
if (err < (QLC_83XX_MINIMUM_VECTOR - tx_vector))
440447
return err;
441-
err -= (adapter->max_drv_tx_rings + 1);
448+
err -= (max_tx_rings + 1);
442449
num_msix = rounddown_pow_of_two(err);
443-
num_msix += (adapter->max_drv_tx_rings + 1);
450+
num_msix += (max_tx_rings + 1);
444451
} else {
445452
num_msix = rounddown_pow_of_two(err);
446453
}
@@ -1285,7 +1292,8 @@ qlcnic_request_irq(struct qlcnic_adapter *adapter)
12851292
}
12861293
}
12871294
if (qlcnic_83xx_check(adapter) &&
1288-
(adapter->flags & QLCNIC_MSIX_ENABLED)) {
1295+
(adapter->flags & QLCNIC_MSIX_ENABLED) &&
1296+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
12891297
handler = qlcnic_msix_tx_intr;
12901298
for (ring = 0; ring < adapter->max_drv_tx_rings;
12911299
ring++) {
@@ -1321,7 +1329,8 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter)
13211329
free_irq(sds_ring->irq, sds_ring);
13221330
}
13231331
}
1324-
if (qlcnic_83xx_check(adapter)) {
1332+
if (qlcnic_83xx_check(adapter) &&
1333+
!(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
13251334
for (ring = 0; ring < adapter->max_drv_tx_rings;
13261335
ring++) {
13271336
tx_ring = &adapter->tx_ring[ring];

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ int qlcnic_sriov_vf_init(struct qlcnic_adapter *adapter, int pci_using_dac)
137137
spin_lock_init(&ahw->mbx_lock);
138138
set_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
139139
ahw->msix_supported = 1;
140+
adapter->flags |= QLCNIC_TX_INTR_SHARED;
140141

141142
if (qlcnic_sriov_setup_vf(adapter, pci_using_dac))
142143
return -EIO;

0 commit comments

Comments
 (0)