aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHariprasad Shenai <hariprasad@chelsio.com>2016-09-16 22:42:39 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-19 01:37:32 -0400
commit0fbc81b3ad513fecaaf62b48f42b89fcd57f7682 (patch)
treed87e58df6ccb3e1ed05c417118efa4478eb3e83e
parente8bc8f9a670e26e91562e724a2114243898bd616 (diff)
chcr/cxgb4i/cxgbit/RDMA/cxgb4: Allocate resources dynamically for all cxgb4 ULD's
Allocate resources dynamically to cxgb4's Upper layer driver's(ULD) like cxgbit, iw_cxgb4 and cxgb4i. Allocate resources when they register with cxgb4 driver and free them while unregistering. All the queues and the interrupts for them will be allocated during ULD probe only and freed during remove. Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/crypto/chelsio/chcr_core.c10
-rw-r--r--drivers/infiniband/hw/cxgb4/device.c4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h47
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c127
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c613
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c223
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h31
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c18
-rw-r--r--drivers/scsi/cxgbi/cxgb4i/cxgb4i.c3
-rw-r--r--drivers/target/iscsi/cxgbit/cxgbit_main.c3
10 files changed, 385 insertions, 694 deletions
diff --git a/drivers/crypto/chelsio/chcr_core.c b/drivers/crypto/chelsio/chcr_core.c
index 2f6156b672ce..fb5f9bbfa09c 100644
--- a/drivers/crypto/chelsio/chcr_core.c
+++ b/drivers/crypto/chelsio/chcr_core.c
@@ -39,12 +39,10 @@ static chcr_handler_func work_handlers[NUM_CPL_CMDS] = {
39 [CPL_FW6_PLD] = cpl_fw6_pld_handler, 39 [CPL_FW6_PLD] = cpl_fw6_pld_handler,
40}; 40};
41 41
42static struct cxgb4_pci_uld_info chcr_uld_info = { 42static struct cxgb4_uld_info chcr_uld_info = {
43 .name = DRV_MODULE_NAME, 43 .name = DRV_MODULE_NAME,
44 .nrxq = 4, 44 .nrxq = MAX_ULD_QSETS,
45 .rxq_size = 1024, 45 .rxq_size = 1024,
46 .nciq = 0,
47 .ciq_size = 0,
48 .add = chcr_uld_add, 46 .add = chcr_uld_add,
49 .state_change = chcr_uld_state_change, 47 .state_change = chcr_uld_state_change,
50 .rx_handler = chcr_uld_rx_handler, 48 .rx_handler = chcr_uld_rx_handler,
@@ -205,7 +203,7 @@ static int chcr_uld_state_change(void *handle, enum cxgb4_state state)
205 203
206static int __init chcr_crypto_init(void) 204static int __init chcr_crypto_init(void)
207{ 205{
208 if (cxgb4_register_pci_uld(CXGB4_PCI_ULD1, &chcr_uld_info)) { 206 if (cxgb4_register_uld(CXGB4_ULD_CRYPTO, &chcr_uld_info)) {
209 pr_err("ULD register fail: No chcr crypto support in cxgb4"); 207 pr_err("ULD register fail: No chcr crypto support in cxgb4");
210 return -1; 208 return -1;
211 } 209 }
@@ -228,7 +226,7 @@ static void __exit chcr_crypto_exit(void)
228 kfree(u_ctx); 226 kfree(u_ctx);
229 } 227 }
230 mutex_unlock(&dev_mutex); 228 mutex_unlock(&dev_mutex);
231 cxgb4_unregister_pci_uld(CXGB4_PCI_ULD1); 229 cxgb4_unregister_uld(CXGB4_ULD_CRYPTO);
232} 230}
233 231
234module_init(chcr_crypto_init); 232module_init(chcr_crypto_init);
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 071d7332ec06..f170b63e6eb9 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -1475,6 +1475,10 @@ static int c4iw_uld_control(void *handle, enum cxgb4_control control, ...)
1475 1475
1476static struct cxgb4_uld_info c4iw_uld_info = { 1476static struct cxgb4_uld_info c4iw_uld_info = {
1477 .name = DRV_NAME, 1477 .name = DRV_NAME,
1478 .nrxq = MAX_ULD_QSETS,
1479 .rxq_size = 511,
1480 .ciq = true,
1481 .lro = false,
1478 .add = c4iw_uld_add, 1482 .add = c4iw_uld_add,
1479 .rx_handler = c4iw_uld_rx_handler, 1483 .rx_handler = c4iw_uld_rx_handler,
1480 .state_change = c4iw_uld_state_change, 1484 .state_change = c4iw_uld_state_change,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 45955691edc7..1f9867db3b78 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -437,11 +437,6 @@ enum {
437 MAX_ETH_QSETS = 32, /* # of Ethernet Tx/Rx queue sets */ 437 MAX_ETH_QSETS = 32, /* # of Ethernet Tx/Rx queue sets */
438 MAX_OFLD_QSETS = 16, /* # of offload Tx, iscsi Rx queue sets */ 438 MAX_OFLD_QSETS = 16, /* # of offload Tx, iscsi Rx queue sets */
439 MAX_CTRL_QUEUES = NCHAN, /* # of control Tx queues */ 439 MAX_CTRL_QUEUES = NCHAN, /* # of control Tx queues */
440 MAX_RDMA_QUEUES = NCHAN, /* # of streaming RDMA Rx queues */
441 MAX_RDMA_CIQS = 32, /* # of RDMA concentrator IQs */
442
443 /* # of streaming iSCSIT Rx queues */
444 MAX_ISCSIT_QUEUES = MAX_OFLD_QSETS,
445}; 440};
446 441
447enum { 442enum {
@@ -458,8 +453,7 @@ enum {
458enum { 453enum {
459 INGQ_EXTRAS = 2, /* firmware event queue and */ 454 INGQ_EXTRAS = 2, /* firmware event queue and */
460 /* forwarded interrupts */ 455 /* forwarded interrupts */
461 MAX_INGQ = MAX_ETH_QSETS + MAX_OFLD_QSETS + MAX_RDMA_QUEUES + 456 MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS,
462 MAX_RDMA_CIQS + MAX_ISCSIT_QUEUES + INGQ_EXTRAS,
463}; 457};
464 458
465struct adapter; 459struct adapter;
@@ -704,10 +698,6 @@ struct sge {
704 struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES]; 698 struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
705 699
706 struct sge_eth_rxq ethrxq[MAX_ETH_QSETS]; 700 struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
707 struct sge_ofld_rxq iscsirxq[MAX_OFLD_QSETS];
708 struct sge_ofld_rxq iscsitrxq[MAX_ISCSIT_QUEUES];
709 struct sge_ofld_rxq rdmarxq[MAX_RDMA_QUEUES];
710 struct sge_ofld_rxq rdmaciq[MAX_RDMA_CIQS];
711 struct sge_rspq fw_evtq ____cacheline_aligned_in_smp; 701 struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
712 struct sge_uld_rxq_info **uld_rxq_info; 702 struct sge_uld_rxq_info **uld_rxq_info;
713 703
@@ -717,15 +707,8 @@ struct sge {
717 u16 max_ethqsets; /* # of available Ethernet queue sets */ 707 u16 max_ethqsets; /* # of available Ethernet queue sets */
718 u16 ethqsets; /* # of active Ethernet queue sets */ 708 u16 ethqsets; /* # of active Ethernet queue sets */
719 u16 ethtxq_rover; /* Tx queue to clean up next */ 709 u16 ethtxq_rover; /* Tx queue to clean up next */
720 u16 iscsiqsets; /* # of active iSCSI queue sets */ 710 u16 ofldqsets; /* # of active ofld queue sets */
721 u16 niscsitq; /* # of available iSCST Rx queues */
722 u16 rdmaqs; /* # of available RDMA Rx queues */
723 u16 rdmaciqs; /* # of available RDMA concentrator IQs */
724 u16 nqs_per_uld; /* # of Rx queues per ULD */ 711 u16 nqs_per_uld; /* # of Rx queues per ULD */
725 u16 iscsi_rxq[MAX_OFLD_QSETS];
726 u16 iscsit_rxq[MAX_ISCSIT_QUEUES];
727 u16 rdma_rxq[MAX_RDMA_QUEUES];
728 u16 rdma_ciq[MAX_RDMA_CIQS];
729 u16 timer_val[SGE_NTIMERS]; 712 u16 timer_val[SGE_NTIMERS];
730 u8 counter_val[SGE_NCOUNTERS]; 713 u8 counter_val[SGE_NCOUNTERS];
731 u32 fl_pg_order; /* large page allocation size */ 714 u32 fl_pg_order; /* large page allocation size */
@@ -749,10 +732,7 @@ struct sge {
749}; 732};
750 733
751#define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++) 734#define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
752#define for_each_iscsirxq(sge, i) for (i = 0; i < (sge)->iscsiqsets; i++) 735#define for_each_ofldtxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
753#define for_each_iscsitrxq(sge, i) for (i = 0; i < (sge)->niscsitq; i++)
754#define for_each_rdmarxq(sge, i) for (i = 0; i < (sge)->rdmaqs; i++)
755#define for_each_rdmaciq(sge, i) for (i = 0; i < (sge)->rdmaciqs; i++)
756 736
757struct l2t_data; 737struct l2t_data;
758 738
@@ -786,6 +766,7 @@ struct uld_msix_bmap {
786struct uld_msix_info { 766struct uld_msix_info {
787 unsigned short vec; 767 unsigned short vec;
788 char desc[IFNAMSIZ + 10]; 768 char desc[IFNAMSIZ + 10];
769 unsigned int idx;
789}; 770};
790 771
791struct vf_info { 772struct vf_info {
@@ -818,7 +799,7 @@ struct adapter {
818 } msix_info[MAX_INGQ + 1]; 799 } msix_info[MAX_INGQ + 1];
819 struct uld_msix_info *msix_info_ulds; /* msix info for uld's */ 800 struct uld_msix_info *msix_info_ulds; /* msix info for uld's */
820 struct uld_msix_bmap msix_bmap_ulds; /* msix bitmap for all uld */ 801 struct uld_msix_bmap msix_bmap_ulds; /* msix bitmap for all uld */
821 unsigned int msi_idx; 802 int msi_idx;
822 803
823 struct doorbell_stats db_stats; 804 struct doorbell_stats db_stats;
824 struct sge sge; 805 struct sge sge;
@@ -836,9 +817,10 @@ struct adapter {
836 unsigned int clipt_start; 817 unsigned int clipt_start;
837 unsigned int clipt_end; 818 unsigned int clipt_end;
838 struct clip_tbl *clipt; 819 struct clip_tbl *clipt;
839 struct cxgb4_pci_uld_info *uld; 820 struct cxgb4_uld_info *uld;
840 void *uld_handle[CXGB4_ULD_MAX]; 821 void *uld_handle[CXGB4_ULD_MAX];
841 unsigned int num_uld; 822 unsigned int num_uld;
823 unsigned int num_ofld_uld;
842 struct list_head list_node; 824 struct list_head list_node;
843 struct list_head rcu_node; 825 struct list_head rcu_node;
844 struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */ 826 struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */
@@ -858,6 +840,8 @@ struct adapter {
858#define T4_OS_LOG_MBOX_CMDS 256 840#define T4_OS_LOG_MBOX_CMDS 256
859 struct mbox_cmd_log *mbox_log; 841 struct mbox_cmd_log *mbox_log;
860 842
843 struct mutex uld_mutex;
844
861 struct dentry *debugfs_root; 845 struct dentry *debugfs_root;
862 bool use_bd; /* Use SGE Back Door intfc for reading SGE Contexts */ 846 bool use_bd; /* Use SGE Back Door intfc for reading SGE Contexts */
863 bool trace_rss; /* 1 implies that different RSS flit per filter is 847 bool trace_rss; /* 1 implies that different RSS flit per filter is
@@ -1051,6 +1035,11 @@ static inline int is_pci_uld(const struct adapter *adap)
1051 return adap->params.crypto; 1035 return adap->params.crypto;
1052} 1036}
1053 1037
1038static inline int is_uld(const struct adapter *adap)
1039{
1040 return (adap->params.offload || adap->params.crypto);
1041}
1042
1054static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr) 1043static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
1055{ 1044{
1056 return readl(adap->regs + reg_addr); 1045 return readl(adap->regs + reg_addr);
@@ -1277,6 +1266,8 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
1277int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq, 1266int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
1278 struct net_device *dev, unsigned int iqid, 1267 struct net_device *dev, unsigned int iqid,
1279 unsigned int cmplqid); 1268 unsigned int cmplqid);
1269int t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid,
1270 unsigned int cmplqid);
1280int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq, 1271int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
1281 struct net_device *dev, unsigned int iqid); 1272 struct net_device *dev, unsigned int iqid);
1282irqreturn_t t4_sge_intr_msix(int irq, void *cookie); 1273irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
@@ -1635,7 +1626,9 @@ void t4_idma_monitor(struct adapter *adapter,
1635 int hz, int ticks); 1626 int hz, int ticks);
1636int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf, 1627int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
1637 unsigned int naddr, u8 *addr); 1628 unsigned int naddr, u8 *addr);
1638void uld_mem_free(struct adapter *adap); 1629void t4_uld_mem_free(struct adapter *adap);
1639int uld_mem_alloc(struct adapter *adap); 1630int t4_uld_mem_alloc(struct adapter *adap);
1631void t4_uld_clean_up(struct adapter *adap);
1632void t4_register_netevent_notifier(void);
1640void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl); 1633void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
1641#endif /* __CXGB4_H__ */ 1634#endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 91fb50850fff..52be9a4ef97a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2432,17 +2432,11 @@ static int sge_qinfo_show(struct seq_file *seq, void *v)
2432{ 2432{
2433 struct adapter *adap = seq->private; 2433 struct adapter *adap = seq->private;
2434 int eth_entries = DIV_ROUND_UP(adap->sge.ethqsets, 4); 2434 int eth_entries = DIV_ROUND_UP(adap->sge.ethqsets, 4);
2435 int iscsi_entries = DIV_ROUND_UP(adap->sge.iscsiqsets, 4); 2435 int ofld_entries = DIV_ROUND_UP(adap->sge.ofldqsets, 4);
2436 int iscsit_entries = DIV_ROUND_UP(adap->sge.niscsitq, 4);
2437 int rdma_entries = DIV_ROUND_UP(adap->sge.rdmaqs, 4);
2438 int ciq_entries = DIV_ROUND_UP(adap->sge.rdmaciqs, 4);
2439 int ctrl_entries = DIV_ROUND_UP(MAX_CTRL_QUEUES, 4); 2436 int ctrl_entries = DIV_ROUND_UP(MAX_CTRL_QUEUES, 4);
2440 int i, r = (uintptr_t)v - 1; 2437 int i, r = (uintptr_t)v - 1;
2441 int iscsi_idx = r - eth_entries; 2438 int ofld_idx = r - eth_entries;
2442 int iscsit_idx = iscsi_idx - iscsi_entries; 2439 int ctrl_idx = ofld_idx - ofld_entries;
2443 int rdma_idx = iscsit_idx - iscsit_entries;
2444 int ciq_idx = rdma_idx - rdma_entries;
2445 int ctrl_idx = ciq_idx - ciq_entries;
2446 int fq_idx = ctrl_idx - ctrl_entries; 2440 int fq_idx = ctrl_idx - ctrl_entries;
2447 2441
2448 if (r) 2442 if (r)
@@ -2518,119 +2512,17 @@ do { \
2518 RL("FLLow:", fl.low); 2512 RL("FLLow:", fl.low);
2519 RL("FLStarving:", fl.starving); 2513 RL("FLStarving:", fl.starving);
2520 2514
2521 } else if (iscsi_idx < iscsi_entries) { 2515 } else if (ofld_idx < ofld_entries) {
2522 const struct sge_ofld_rxq *rx =
2523 &adap->sge.iscsirxq[iscsi_idx * 4];
2524 const struct sge_ofld_txq *tx = 2516 const struct sge_ofld_txq *tx =
2525 &adap->sge.ofldtxq[iscsi_idx * 4]; 2517 &adap->sge.ofldtxq[ofld_idx * 4];
2526 int n = min(4, adap->sge.iscsiqsets - 4 * iscsi_idx); 2518 int n = min(4, adap->sge.ofldqsets - 4 * ofld_idx);
2527 2519
2528 S("QType:", "iSCSI"); 2520 S("QType:", "OFLD-Txq");
2529 T("TxQ ID:", q.cntxt_id); 2521 T("TxQ ID:", q.cntxt_id);
2530 T("TxQ size:", q.size); 2522 T("TxQ size:", q.size);
2531 T("TxQ inuse:", q.in_use); 2523 T("TxQ inuse:", q.in_use);
2532 T("TxQ CIDX:", q.cidx); 2524 T("TxQ CIDX:", q.cidx);
2533 T("TxQ PIDX:", q.pidx); 2525 T("TxQ PIDX:", q.pidx);
2534 R("RspQ ID:", rspq.abs_id);
2535 R("RspQ size:", rspq.size);
2536 R("RspQE size:", rspq.iqe_len);
2537 R("RspQ CIDX:", rspq.cidx);
2538 R("RspQ Gen:", rspq.gen);
2539 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2540 S3("u", "Intr pktcnt:",
2541 adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
2542 R("FL ID:", fl.cntxt_id);
2543 R("FL size:", fl.size - 8);
2544 R("FL pend:", fl.pend_cred);
2545 R("FL avail:", fl.avail);
2546 R("FL PIDX:", fl.pidx);
2547 R("FL CIDX:", fl.cidx);
2548 RL("RxPackets:", stats.pkts);
2549 RL("RxImmPkts:", stats.imm);
2550 RL("RxNoMem:", stats.nomem);
2551 RL("FLAllocErr:", fl.alloc_failed);
2552 RL("FLLrgAlcErr:", fl.large_alloc_failed);
2553 RL("FLMapErr:", fl.mapping_err);
2554 RL("FLLow:", fl.low);
2555 RL("FLStarving:", fl.starving);
2556
2557 } else if (iscsit_idx < iscsit_entries) {
2558 const struct sge_ofld_rxq *rx =
2559 &adap->sge.iscsitrxq[iscsit_idx * 4];
2560 int n = min(4, adap->sge.niscsitq - 4 * iscsit_idx);
2561
2562 S("QType:", "iSCSIT");
2563 R("RspQ ID:", rspq.abs_id);
2564 R("RspQ size:", rspq.size);
2565 R("RspQE size:", rspq.iqe_len);
2566 R("RspQ CIDX:", rspq.cidx);
2567 R("RspQ Gen:", rspq.gen);
2568 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2569 S3("u", "Intr pktcnt:",
2570 adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
2571 R("FL ID:", fl.cntxt_id);
2572 R("FL size:", fl.size - 8);
2573 R("FL pend:", fl.pend_cred);
2574 R("FL avail:", fl.avail);
2575 R("FL PIDX:", fl.pidx);
2576 R("FL CIDX:", fl.cidx);
2577 RL("RxPackets:", stats.pkts);
2578 RL("RxImmPkts:", stats.imm);
2579 RL("RxNoMem:", stats.nomem);
2580 RL("FLAllocErr:", fl.alloc_failed);
2581 RL("FLLrgAlcErr:", fl.large_alloc_failed);
2582 RL("FLMapErr:", fl.mapping_err);
2583 RL("FLLow:", fl.low);
2584 RL("FLStarving:", fl.starving);
2585
2586 } else if (rdma_idx < rdma_entries) {
2587 const struct sge_ofld_rxq *rx =
2588 &adap->sge.rdmarxq[rdma_idx * 4];
2589 int n = min(4, adap->sge.rdmaqs - 4 * rdma_idx);
2590
2591 S("QType:", "RDMA-CPL");
2592 S("Interface:",
2593 rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
2594 R("RspQ ID:", rspq.abs_id);
2595 R("RspQ size:", rspq.size);
2596 R("RspQE size:", rspq.iqe_len);
2597 R("RspQ CIDX:", rspq.cidx);
2598 R("RspQ Gen:", rspq.gen);
2599 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2600 S3("u", "Intr pktcnt:",
2601 adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
2602 R("FL ID:", fl.cntxt_id);
2603 R("FL size:", fl.size - 8);
2604 R("FL pend:", fl.pend_cred);
2605 R("FL avail:", fl.avail);
2606 R("FL PIDX:", fl.pidx);
2607 R("FL CIDX:", fl.cidx);
2608 RL("RxPackets:", stats.pkts);
2609 RL("RxImmPkts:", stats.imm);
2610 RL("RxNoMem:", stats.nomem);
2611 RL("FLAllocErr:", fl.alloc_failed);
2612 RL("FLLrgAlcErr:", fl.large_alloc_failed);
2613 RL("FLMapErr:", fl.mapping_err);
2614 RL("FLLow:", fl.low);
2615 RL("FLStarving:", fl.starving);
2616
2617 } else if (ciq_idx < ciq_entries) {
2618 const struct sge_ofld_rxq *rx = &adap->sge.rdmaciq[ciq_idx * 4];
2619 int n = min(4, adap->sge.rdmaciqs - 4 * ciq_idx);
2620
2621 S("QType:", "RDMA-CIQ");
2622 S("Interface:",
2623 rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
2624 R("RspQ ID:", rspq.abs_id);
2625 R("RspQ size:", rspq.size);
2626 R("RspQE size:", rspq.iqe_len);
2627 R("RspQ CIDX:", rspq.cidx);
2628 R("RspQ Gen:", rspq.gen);
2629 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2630 S3("u", "Intr pktcnt:",
2631 adap->sge.counter_val[rx[i].rspq.pktcnt_idx]);
2632 RL("RxAN:", stats.an);
2633 RL("RxNoMem:", stats.nomem);
2634 2526
2635 } else if (ctrl_idx < ctrl_entries) { 2527 } else if (ctrl_idx < ctrl_entries) {
2636 const struct sge_ctrl_txq *tx = &adap->sge.ctrlq[ctrl_idx * 4]; 2528 const struct sge_ctrl_txq *tx = &adap->sge.ctrlq[ctrl_idx * 4];
@@ -2672,10 +2564,7 @@ do { \
2672static int sge_queue_entries(const struct adapter *adap) 2564static int sge_queue_entries(const struct adapter *adap)
2673{ 2565{
2674 return DIV_ROUND_UP(adap->sge.ethqsets, 4) + 2566 return DIV_ROUND_UP(adap->sge.ethqsets, 4) +
2675 DIV_ROUND_UP(adap->sge.iscsiqsets, 4) + 2567 DIV_ROUND_UP(adap->sge.ofldqsets, 4) +
2676 DIV_ROUND_UP(adap->sge.niscsitq, 4) +
2677 DIV_ROUND_UP(adap->sge.rdmaqs, 4) +
2678 DIV_ROUND_UP(adap->sge.rdmaciqs, 4) +
2679 DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1; 2568 DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1;
2680} 2569}
2681 2570
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 44cc9767936f..d1ebb84c073e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -226,11 +226,6 @@ static struct dentry *cxgb4_debugfs_root;
226 226
227LIST_HEAD(adapter_list); 227LIST_HEAD(adapter_list);
228DEFINE_MUTEX(uld_mutex); 228DEFINE_MUTEX(uld_mutex);
229/* Adapter list to be accessed from atomic context */
230static LIST_HEAD(adap_rcu_list);
231static DEFINE_SPINLOCK(adap_rcu_lock);
232static struct cxgb4_uld_info ulds[CXGB4_ULD_MAX];
233static const char *const uld_str[] = { "RDMA", "iSCSI", "iSCSIT" };
234 229
235static void link_report(struct net_device *dev) 230static void link_report(struct net_device *dev)
236{ 231{
@@ -678,56 +673,6 @@ out:
678 return 0; 673 return 0;
679} 674}
680 675
681/* Flush the aggregated lro sessions */
682static void uldrx_flush_handler(struct sge_rspq *q)
683{
684 if (ulds[q->uld].lro_flush)
685 ulds[q->uld].lro_flush(&q->lro_mgr);
686}
687
688/**
689 * uldrx_handler - response queue handler for ULD queues
690 * @q: the response queue that received the packet
691 * @rsp: the response queue descriptor holding the offload message
692 * @gl: the gather list of packet fragments
693 *
694 * Deliver an ingress offload packet to a ULD. All processing is done by
695 * the ULD, we just maintain statistics.
696 */
697static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
698 const struct pkt_gl *gl)
699{
700 struct sge_ofld_rxq *rxq = container_of(q, struct sge_ofld_rxq, rspq);
701 int ret;
702
703 /* FW can send CPLs encapsulated in a CPL_FW4_MSG.
704 */
705 if (((const struct rss_header *)rsp)->opcode == CPL_FW4_MSG &&
706 ((const struct cpl_fw4_msg *)(rsp + 1))->type == FW_TYPE_RSSCPL)
707 rsp += 2;
708
709 if (q->flush_handler)
710 ret = ulds[q->uld].lro_rx_handler(q->adap->uld_handle[q->uld],
711 rsp, gl, &q->lro_mgr,
712 &q->napi);
713 else
714 ret = ulds[q->uld].rx_handler(q->adap->uld_handle[q->uld],
715 rsp, gl);
716
717 if (ret) {
718 rxq->stats.nomem++;
719 return -1;
720 }
721
722 if (gl == NULL)
723 rxq->stats.imm++;
724 else if (gl == CXGB4_MSG_AN)
725 rxq->stats.an++;
726 else
727 rxq->stats.pkts++;
728 return 0;
729}
730
731static void disable_msi(struct adapter *adapter) 676static void disable_msi(struct adapter *adapter)
732{ 677{
733 if (adapter->flags & USING_MSIX) { 678 if (adapter->flags & USING_MSIX) {
@@ -779,30 +724,12 @@ static void name_msix_vecs(struct adapter *adap)
779 snprintf(adap->msix_info[msi_idx].desc, n, "%s-Rx%d", 724 snprintf(adap->msix_info[msi_idx].desc, n, "%s-Rx%d",
780 d->name, i); 725 d->name, i);
781 } 726 }
782
783 /* offload queues */
784 for_each_iscsirxq(&adap->sge, i)
785 snprintf(adap->msix_info[msi_idx++].desc, n, "%s-iscsi%d",
786 adap->port[0]->name, i);
787
788 for_each_iscsitrxq(&adap->sge, i)
789 snprintf(adap->msix_info[msi_idx++].desc, n, "%s-iSCSIT%d",
790 adap->port[0]->name, i);
791
792 for_each_rdmarxq(&adap->sge, i)
793 snprintf(adap->msix_info[msi_idx++].desc, n, "%s-rdma%d",
794 adap->port[0]->name, i);
795
796 for_each_rdmaciq(&adap->sge, i)
797 snprintf(adap->msix_info[msi_idx++].desc, n, "%s-rdma-ciq%d",
798 adap->port[0]->name, i);
799} 727}
800 728
801static int request_msix_queue_irqs(struct adapter *adap) 729static int request_msix_queue_irqs(struct adapter *adap)
802{ 730{
803 struct sge *s = &adap->sge; 731 struct sge *s = &adap->sge;
804 int err, ethqidx, iscsiqidx = 0, rdmaqidx = 0, rdmaciqqidx = 0; 732 int err, ethqidx;
805 int iscsitqidx = 0;
806 int msi_index = 2; 733 int msi_index = 2;
807 734
808 err = request_irq(adap->msix_info[1].vec, t4_sge_intr_msix, 0, 735 err = request_irq(adap->msix_info[1].vec, t4_sge_intr_msix, 0,
@@ -819,57 +746,9 @@ static int request_msix_queue_irqs(struct adapter *adap)
819 goto unwind; 746 goto unwind;
820 msi_index++; 747 msi_index++;
821 } 748 }
822 for_each_iscsirxq(s, iscsiqidx) {
823 err = request_irq(adap->msix_info[msi_index].vec,
824 t4_sge_intr_msix, 0,
825 adap->msix_info[msi_index].desc,
826 &s->iscsirxq[iscsiqidx].rspq);
827 if (err)
828 goto unwind;
829 msi_index++;
830 }
831 for_each_iscsitrxq(s, iscsitqidx) {
832 err = request_irq(adap->msix_info[msi_index].vec,
833 t4_sge_intr_msix, 0,
834 adap->msix_info[msi_index].desc,
835 &s->iscsitrxq[iscsitqidx].rspq);
836 if (err)
837 goto unwind;
838 msi_index++;
839 }
840 for_each_rdmarxq(s, rdmaqidx) {
841 err = request_irq(adap->msix_info[msi_index].vec,
842 t4_sge_intr_msix, 0,
843 adap->msix_info[msi_index].desc,
844 &s->rdmarxq[rdmaqidx].rspq);
845 if (err)
846 goto unwind;
847 msi_index++;
848 }
849 for_each_rdmaciq(s, rdmaciqqidx) {
850 err = request_irq(adap->msix_info[msi_index].vec,
851 t4_sge_intr_msix, 0,
852 adap->msix_info[msi_index].desc,
853 &s->rdmaciq[rdmaciqqidx].rspq);
854 if (err)
855 goto unwind;
856 msi_index++;
857 }
858 return 0; 749 return 0;
859 750
860unwind: 751unwind:
861 while (--rdmaciqqidx >= 0)
862 free_irq(adap->msix_info[--msi_index].vec,
863 &s->rdmaciq[rdmaciqqidx].rspq);
864 while (--rdmaqidx >= 0)
865 free_irq(adap->msix_info[--msi_index].vec,
866 &s->rdmarxq[rdmaqidx].rspq);
867 while (--iscsitqidx >= 0)
868 free_irq(adap->msix_info[--msi_index].vec,
869 &s->iscsitrxq[iscsitqidx].rspq);
870 while (--iscsiqidx >= 0)
871 free_irq(adap->msix_info[--msi_index].vec,
872 &s->iscsirxq[iscsiqidx].rspq);
873 while (--ethqidx >= 0) 752 while (--ethqidx >= 0)
874 free_irq(adap->msix_info[--msi_index].vec, 753 free_irq(adap->msix_info[--msi_index].vec,
875 &s->ethrxq[ethqidx].rspq); 754 &s->ethrxq[ethqidx].rspq);
@@ -885,16 +764,6 @@ static void free_msix_queue_irqs(struct adapter *adap)
885 free_irq(adap->msix_info[1].vec, &s->fw_evtq); 764 free_irq(adap->msix_info[1].vec, &s->fw_evtq);
886 for_each_ethrxq(s, i) 765 for_each_ethrxq(s, i)
887 free_irq(adap->msix_info[msi_index++].vec, &s->ethrxq[i].rspq); 766 free_irq(adap->msix_info[msi_index++].vec, &s->ethrxq[i].rspq);
888 for_each_iscsirxq(s, i)
889 free_irq(adap->msix_info[msi_index++].vec,
890 &s->iscsirxq[i].rspq);
891 for_each_iscsitrxq(s, i)
892 free_irq(adap->msix_info[msi_index++].vec,
893 &s->iscsitrxq[i].rspq);
894 for_each_rdmarxq(s, i)
895 free_irq(adap->msix_info[msi_index++].vec, &s->rdmarxq[i].rspq);
896 for_each_rdmaciq(s, i)
897 free_irq(adap->msix_info[msi_index++].vec, &s->rdmaciq[i].rspq);
898} 767}
899 768
900/** 769/**
@@ -1033,42 +902,11 @@ static void enable_rx(struct adapter *adap)
1033 } 902 }
1034} 903}
1035 904
1036static int alloc_ofld_rxqs(struct adapter *adap, struct sge_ofld_rxq *q,
1037 unsigned int nq, unsigned int per_chan, int msi_idx,
1038 u16 *ids, bool lro)
1039{
1040 int i, err;
1041
1042 for (i = 0; i < nq; i++, q++) {
1043 if (msi_idx > 0)
1044 msi_idx++;
1045 err = t4_sge_alloc_rxq(adap, &q->rspq, false,
1046 adap->port[i / per_chan],
1047 msi_idx, q->fl.size ? &q->fl : NULL,
1048 uldrx_handler,
1049 lro ? uldrx_flush_handler : NULL,
1050 0);
1051 if (err)
1052 return err;
1053 memset(&q->stats, 0, sizeof(q->stats));
1054 if (ids)
1055 ids[i] = q->rspq.abs_id;
1056 }
1057 return 0;
1058}
1059 905
1060/** 906static int setup_fw_sge_queues(struct adapter *adap)
1061 * setup_sge_queues - configure SGE Tx/Rx/response queues
1062 * @adap: the adapter
1063 *
1064 * Determines how many sets of SGE queues to use and initializes them.
1065 * We support multiple queue sets per port if we have MSI-X, otherwise
1066 * just one queue set per port.
1067 */
1068static int setup_sge_queues(struct adapter *adap)
1069{ 907{
1070 int err, i, j;
1071 struct sge *s = &adap->sge; 908 struct sge *s = &adap->sge;
909 int err = 0;
1072 910
1073 bitmap_zero(s->starving_fl, s->egr_sz); 911 bitmap_zero(s->starving_fl, s->egr_sz);
1074 bitmap_zero(s->txq_maperr, s->egr_sz); 912 bitmap_zero(s->txq_maperr, s->egr_sz);
@@ -1083,25 +921,27 @@ static int setup_sge_queues(struct adapter *adap)
1083 adap->msi_idx = -((int)s->intrq.abs_id + 1); 921 adap->msi_idx = -((int)s->intrq.abs_id + 1);
1084 } 922 }
1085 923
1086 /* NOTE: If you add/delete any Ingress/Egress Queue allocations in here,
1087 * don't forget to update the following which need to be
1088 * synchronized to and changes here.
1089 *
1090 * 1. The calculations of MAX_INGQ in cxgb4.h.
1091 *
1092 * 2. Update enable_msix/name_msix_vecs/request_msix_queue_irqs
1093 * to accommodate any new/deleted Ingress Queues
1094 * which need MSI-X Vectors.
1095 *
1096 * 3. Update sge_qinfo_show() to include information on the
1097 * new/deleted queues.
1098 */
1099 err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0], 924 err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0],
1100 adap->msi_idx, NULL, fwevtq_handler, NULL, -1); 925 adap->msi_idx, NULL, fwevtq_handler, NULL, -1);
1101 if (err) { 926 if (err)
1102freeout: t4_free_sge_resources(adap); 927 t4_free_sge_resources(adap);
1103 return err; 928 return err;
1104 } 929}
930
931/**
932 * setup_sge_queues - configure SGE Tx/Rx/response queues
933 * @adap: the adapter
934 *
935 * Determines how many sets of SGE queues to use and initializes them.
936 * We support multiple queue sets per port if we have MSI-X, otherwise
937 * just one queue set per port.
938 */
939static int setup_sge_queues(struct adapter *adap)
940{
941 int err, i, j;
942 struct sge *s = &adap->sge;
943 struct sge_uld_rxq_info *rxq_info = s->uld_rxq_info[CXGB4_ULD_RDMA];
944 unsigned int cmplqid = 0;
1105 945
1106 for_each_port(adap, i) { 946 for_each_port(adap, i) {
1107 struct net_device *dev = adap->port[i]; 947 struct net_device *dev = adap->port[i];
@@ -1132,8 +972,8 @@ freeout: t4_free_sge_resources(adap);
1132 } 972 }
1133 } 973 }
1134 974
1135 j = s->iscsiqsets / adap->params.nports; /* iscsi queues per channel */ 975 j = s->ofldqsets / adap->params.nports; /* iscsi queues per channel */
1136 for_each_iscsirxq(s, i) { 976 for_each_ofldtxq(s, i) {
1137 err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i], 977 err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i],
1138 adap->port[i / j], 978 adap->port[i / j],
1139 s->fw_evtq.cntxt_id); 979 s->fw_evtq.cntxt_id);
@@ -1141,30 +981,15 @@ freeout: t4_free_sge_resources(adap);
1141 goto freeout; 981 goto freeout;
1142 } 982 }
1143 983
1144#define ALLOC_OFLD_RXQS(firstq, nq, per_chan, ids, lro) do { \
1145 err = alloc_ofld_rxqs(adap, firstq, nq, per_chan, adap->msi_idx, ids, lro); \
1146 if (err) \
1147 goto freeout; \
1148 if (adap->msi_idx > 0) \
1149 adap->msi_idx += nq; \
1150} while (0)
1151
1152 ALLOC_OFLD_RXQS(s->iscsirxq, s->iscsiqsets, j, s->iscsi_rxq, false);
1153 ALLOC_OFLD_RXQS(s->iscsitrxq, s->niscsitq, j, s->iscsit_rxq, true);
1154 ALLOC_OFLD_RXQS(s->rdmarxq, s->rdmaqs, 1, s->rdma_rxq, false);
1155 j = s->rdmaciqs / adap->params.nports; /* rdmaq queues per channel */
1156 ALLOC_OFLD_RXQS(s->rdmaciq, s->rdmaciqs, j, s->rdma_ciq, false);
1157
1158#undef ALLOC_OFLD_RXQS
1159
1160 for_each_port(adap, i) { 984 for_each_port(adap, i) {
1161 /* 985 /* Note that cmplqid below is 0 if we don't
1162 * Note that ->rdmarxq[i].rspq.cntxt_id below is 0 if we don't
1163 * have RDMA queues, and that's the right value. 986 * have RDMA queues, and that's the right value.
1164 */ 987 */
988 if (rxq_info)
989 cmplqid = rxq_info->uldrxq[i].rspq.cntxt_id;
990
1165 err = t4_sge_alloc_ctrl_txq(adap, &s->ctrlq[i], adap->port[i], 991 err = t4_sge_alloc_ctrl_txq(adap, &s->ctrlq[i], adap->port[i],
1166 s->fw_evtq.cntxt_id, 992 s->fw_evtq.cntxt_id, cmplqid);
1167 s->rdmarxq[i].rspq.cntxt_id);
1168 if (err) 993 if (err)
1169 goto freeout; 994 goto freeout;
1170 } 995 }
@@ -1175,6 +1000,9 @@ freeout: t4_free_sge_resources(adap);
1175 RSSCONTROL_V(netdev2pinfo(adap->port[0])->tx_chan) | 1000 RSSCONTROL_V(netdev2pinfo(adap->port[0])->tx_chan) |
1176 QUEUENUMBER_V(s->ethrxq[0].rspq.abs_id)); 1001 QUEUENUMBER_V(s->ethrxq[0].rspq.abs_id));
1177 return 0; 1002 return 0;
1003freeout:
1004 t4_free_sge_resources(adap);
1005 return err;
1178} 1006}
1179 1007
1180/* 1008/*
@@ -2317,7 +2145,7 @@ static void disable_dbs(struct adapter *adap)
2317 2145
2318 for_each_ethrxq(&adap->sge, i) 2146 for_each_ethrxq(&adap->sge, i)
2319 disable_txq_db(&adap->sge.ethtxq[i].q); 2147 disable_txq_db(&adap->sge.ethtxq[i].q);
2320 for_each_iscsirxq(&adap->sge, i) 2148 for_each_ofldtxq(&adap->sge, i)
2321 disable_txq_db(&adap->sge.ofldtxq[i].q); 2149 disable_txq_db(&adap->sge.ofldtxq[i].q);
2322 for_each_port(adap, i) 2150 for_each_port(adap, i)
2323 disable_txq_db(&adap->sge.ctrlq[i].q); 2151 disable_txq_db(&adap->sge.ctrlq[i].q);
@@ -2329,7 +2157,7 @@ static void enable_dbs(struct adapter *adap)
2329 2157
2330 for_each_ethrxq(&adap->sge, i) 2158 for_each_ethrxq(&adap->sge, i)
2331 enable_txq_db(adap, &adap->sge.ethtxq[i].q); 2159 enable_txq_db(adap, &adap->sge.ethtxq[i].q);
2332 for_each_iscsirxq(&adap->sge, i) 2160 for_each_ofldtxq(&adap->sge, i)
2333 enable_txq_db(adap, &adap->sge.ofldtxq[i].q); 2161 enable_txq_db(adap, &adap->sge.ofldtxq[i].q);
2334 for_each_port(adap, i) 2162 for_each_port(adap, i)
2335 enable_txq_db(adap, &adap->sge.ctrlq[i].q); 2163 enable_txq_db(adap, &adap->sge.ctrlq[i].q);
@@ -2337,9 +2165,10 @@ static void enable_dbs(struct adapter *adap)
2337 2165
2338static void notify_rdma_uld(struct adapter *adap, enum cxgb4_control cmd) 2166static void notify_rdma_uld(struct adapter *adap, enum cxgb4_control cmd)
2339{ 2167{
2340 if (adap->uld_handle[CXGB4_ULD_RDMA]) 2168 enum cxgb4_uld type = CXGB4_ULD_RDMA;
2341 ulds[CXGB4_ULD_RDMA].control(adap->uld_handle[CXGB4_ULD_RDMA], 2169
2342 cmd); 2170 if (adap->uld && adap->uld[type].handle)
2171 adap->uld[type].control(adap->uld[type].handle, cmd);
2343} 2172}
2344 2173
2345static void process_db_full(struct work_struct *work) 2174static void process_db_full(struct work_struct *work)
@@ -2393,13 +2222,14 @@ out:
2393 if (ret) 2222 if (ret)
2394 CH_WARN(adap, "DB drop recovery failed.\n"); 2223 CH_WARN(adap, "DB drop recovery failed.\n");
2395} 2224}
2225
2396static void recover_all_queues(struct adapter *adap) 2226static void recover_all_queues(struct adapter *adap)
2397{ 2227{
2398 int i; 2228 int i;
2399 2229
2400 for_each_ethrxq(&adap->sge, i) 2230 for_each_ethrxq(&adap->sge, i)
2401 sync_txq_pidx(adap, &adap->sge.ethtxq[i].q); 2231 sync_txq_pidx(adap, &adap->sge.ethtxq[i].q);
2402 for_each_iscsirxq(&adap->sge, i) 2232 for_each_ofldtxq(&adap->sge, i)
2403 sync_txq_pidx(adap, &adap->sge.ofldtxq[i].q); 2233 sync_txq_pidx(adap, &adap->sge.ofldtxq[i].q);
2404 for_each_port(adap, i) 2234 for_each_port(adap, i)
2405 sync_txq_pidx(adap, &adap->sge.ctrlq[i].q); 2235 sync_txq_pidx(adap, &adap->sge.ctrlq[i].q);
@@ -2464,94 +2294,12 @@ void t4_db_dropped(struct adapter *adap)
2464 queue_work(adap->workq, &adap->db_drop_task); 2294 queue_work(adap->workq, &adap->db_drop_task);
2465} 2295}
2466 2296
2467static void uld_attach(struct adapter *adap, unsigned int uld) 2297void t4_register_netevent_notifier(void)
2468{ 2298{
2469 void *handle;
2470 struct cxgb4_lld_info lli;
2471 unsigned short i;
2472
2473 lli.pdev = adap->pdev;
2474 lli.pf = adap->pf;
2475 lli.l2t = adap->l2t;
2476 lli.tids = &adap->tids;
2477 lli.ports = adap->port;
2478 lli.vr = &adap->vres;
2479 lli.mtus = adap->params.mtus;
2480 if (uld == CXGB4_ULD_RDMA) {
2481 lli.rxq_ids = adap->sge.rdma_rxq;
2482 lli.ciq_ids = adap->sge.rdma_ciq;
2483 lli.nrxq = adap->sge.rdmaqs;
2484 lli.nciq = adap->sge.rdmaciqs;
2485 } else if (uld == CXGB4_ULD_ISCSI) {
2486 lli.rxq_ids = adap->sge.iscsi_rxq;
2487 lli.nrxq = adap->sge.iscsiqsets;
2488 } else if (uld == CXGB4_ULD_ISCSIT) {
2489 lli.rxq_ids = adap->sge.iscsit_rxq;
2490 lli.nrxq = adap->sge.niscsitq;
2491 }
2492 lli.ntxq = adap->sge.iscsiqsets;
2493 lli.nchan = adap->params.nports;
2494 lli.nports = adap->params.nports;
2495 lli.wr_cred = adap->params.ofldq_wr_cred;
2496 lli.adapter_type = adap->params.chip;
2497 lli.iscsi_iolen = MAXRXDATA_G(t4_read_reg(adap, TP_PARA_REG2_A));
2498 lli.iscsi_tagmask = t4_read_reg(adap, ULP_RX_ISCSI_TAGMASK_A);
2499 lli.iscsi_pgsz_order = t4_read_reg(adap, ULP_RX_ISCSI_PSZ_A);
2500 lli.iscsi_llimit = t4_read_reg(adap, ULP_RX_ISCSI_LLIMIT_A);
2501 lli.iscsi_ppm = &adap->iscsi_ppm;
2502 lli.cclk_ps = 1000000000 / adap->params.vpd.cclk;
2503 lli.udb_density = 1 << adap->params.sge.eq_qpp;
2504 lli.ucq_density = 1 << adap->params.sge.iq_qpp;
2505 lli.filt_mode = adap->params.tp.vlan_pri_map;
2506 /* MODQ_REQ_MAP sets queues 0-3 to chan 0-3 */
2507 for (i = 0; i < NCHAN; i++)
2508 lli.tx_modq[i] = i;
2509 lli.gts_reg = adap->regs + MYPF_REG(SGE_PF_GTS_A);
2510 lli.db_reg = adap->regs + MYPF_REG(SGE_PF_KDOORBELL_A);
2511 lli.fw_vers = adap->params.fw_vers;
2512 lli.dbfifo_int_thresh = dbfifo_int_thresh;
2513 lli.sge_ingpadboundary = adap->sge.fl_align;
2514 lli.sge_egrstatuspagesize = adap->sge.stat_len;
2515 lli.sge_pktshift = adap->sge.pktshift;
2516 lli.enable_fw_ofld_conn = adap->flags & FW_OFLD_CONN;
2517 lli.max_ordird_qp = adap->params.max_ordird_qp;
2518 lli.max_ird_adapter = adap->params.max_ird_adapter;
2519 lli.ulptx_memwrite_dsgl = adap->params.ulptx_memwrite_dsgl;
2520 lli.nodeid = dev_to_node(adap->pdev_dev);
2521
2522 handle = ulds[uld].add(&lli);
2523 if (IS_ERR(handle)) {
2524 dev_warn(adap->pdev_dev,
2525 "could not attach to the %s driver, error %ld\n",
2526 uld_str[uld], PTR_ERR(handle));
2527 return;
2528 }
2529
2530 adap->uld_handle[uld] = handle;
2531
2532 if (!netevent_registered) { 2299 if (!netevent_registered) {
2533 register_netevent_notifier(&cxgb4_netevent_nb); 2300 register_netevent_notifier(&cxgb4_netevent_nb);
2534 netevent_registered = true; 2301 netevent_registered = true;
2535 } 2302 }
2536
2537 if (adap->flags & FULL_INIT_DONE)
2538 ulds[uld].state_change(handle, CXGB4_STATE_UP);
2539}
2540
2541static void attach_ulds(struct adapter *adap)
2542{
2543 unsigned int i;
2544
2545 spin_lock(&adap_rcu_lock);
2546 list_add_tail_rcu(&adap->rcu_node, &adap_rcu_list);
2547 spin_unlock(&adap_rcu_lock);
2548
2549 mutex_lock(&uld_mutex);
2550 list_add_tail(&adap->list_node, &adapter_list);
2551 for (i = 0; i < CXGB4_ULD_MAX; i++)
2552 if (ulds[i].add)
2553 uld_attach(adap, i);
2554 mutex_unlock(&uld_mutex);
2555} 2303}
2556 2304
2557static void detach_ulds(struct adapter *adap) 2305static void detach_ulds(struct adapter *adap)
@@ -2561,12 +2309,6 @@ static void detach_ulds(struct adapter *adap)
2561 mutex_lock(&uld_mutex); 2309 mutex_lock(&uld_mutex);
2562 list_del(&adap->list_node); 2310 list_del(&adap->list_node);
2563 for (i = 0; i < CXGB4_ULD_MAX; i++) 2311 for (i = 0; i < CXGB4_ULD_MAX; i++)
2564 if (adap->uld_handle[i]) {
2565 ulds[i].state_change(adap->uld_handle[i],
2566 CXGB4_STATE_DETACH);
2567 adap->uld_handle[i] = NULL;
2568 }
2569 for (i = 0; i < CXGB4_PCI_ULD_MAX; i++)
2570 if (adap->uld && adap->uld[i].handle) { 2312 if (adap->uld && adap->uld[i].handle) {
2571 adap->uld[i].state_change(adap->uld[i].handle, 2313 adap->uld[i].state_change(adap->uld[i].handle,
2572 CXGB4_STATE_DETACH); 2314 CXGB4_STATE_DETACH);
@@ -2577,10 +2319,6 @@ static void detach_ulds(struct adapter *adap)
2577 netevent_registered = false; 2319 netevent_registered = false;
2578 } 2320 }
2579 mutex_unlock(&uld_mutex); 2321 mutex_unlock(&uld_mutex);
2580
2581 spin_lock(&adap_rcu_lock);
2582 list_del_rcu(&adap->rcu_node);
2583 spin_unlock(&adap_rcu_lock);
2584} 2322}
2585 2323
2586static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state) 2324static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state)
@@ -2589,65 +2327,12 @@ static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state)
2589 2327
2590 mutex_lock(&uld_mutex); 2328 mutex_lock(&uld_mutex);
2591 for (i = 0; i < CXGB4_ULD_MAX; i++) 2329 for (i = 0; i < CXGB4_ULD_MAX; i++)
2592 if (adap->uld_handle[i])
2593 ulds[i].state_change(adap->uld_handle[i], new_state);
2594 for (i = 0; i < CXGB4_PCI_ULD_MAX; i++)
2595 if (adap->uld && adap->uld[i].handle) 2330 if (adap->uld && adap->uld[i].handle)
2596 adap->uld[i].state_change(adap->uld[i].handle, 2331 adap->uld[i].state_change(adap->uld[i].handle,
2597 new_state); 2332 new_state);
2598 mutex_unlock(&uld_mutex); 2333 mutex_unlock(&uld_mutex);
2599} 2334}
2600 2335
2601/**
2602 * cxgb4_register_uld - register an upper-layer driver
2603 * @type: the ULD type
2604 * @p: the ULD methods
2605 *
2606 * Registers an upper-layer driver with this driver and notifies the ULD
2607 * about any presently available devices that support its type. Returns
2608 * %-EBUSY if a ULD of the same type is already registered.
2609 */
2610int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p)
2611{
2612 int ret = 0;
2613 struct adapter *adap;
2614
2615 if (type >= CXGB4_ULD_MAX)
2616 return -EINVAL;
2617 mutex_lock(&uld_mutex);
2618 if (ulds[type].add) {
2619 ret = -EBUSY;
2620 goto out;
2621 }
2622 ulds[type] = *p;
2623 list_for_each_entry(adap, &adapter_list, list_node)
2624 uld_attach(adap, type);
2625out: mutex_unlock(&uld_mutex);
2626 return ret;
2627}
2628EXPORT_SYMBOL(cxgb4_register_uld);
2629
2630/**
2631 * cxgb4_unregister_uld - unregister an upper-layer driver
2632 * @type: the ULD type
2633 *
2634 * Unregisters an existing upper-layer driver.
2635 */
2636int cxgb4_unregister_uld(enum cxgb4_uld type)
2637{
2638 struct adapter *adap;
2639
2640 if (type >= CXGB4_ULD_MAX)
2641 return -EINVAL;
2642 mutex_lock(&uld_mutex);
2643 list_for_each_entry(adap, &adapter_list, list_node)
2644 adap->uld_handle[type] = NULL;
2645 ulds[type].add = NULL;
2646 mutex_unlock(&uld_mutex);
2647 return 0;
2648}
2649EXPORT_SYMBOL(cxgb4_unregister_uld);
2650
2651#if IS_ENABLED(CONFIG_IPV6) 2336#if IS_ENABLED(CONFIG_IPV6)
2652static int cxgb4_inet6addr_handler(struct notifier_block *this, 2337static int cxgb4_inet6addr_handler(struct notifier_block *this,
2653 unsigned long event, void *data) 2338 unsigned long event, void *data)
@@ -2752,7 +2437,6 @@ static int cxgb_up(struct adapter *adap)
2752 adap->msix_info[0].desc, adap); 2437 adap->msix_info[0].desc, adap);
2753 if (err) 2438 if (err)
2754 goto irq_err; 2439 goto irq_err;
2755
2756 err = request_msix_queue_irqs(adap); 2440 err = request_msix_queue_irqs(adap);
2757 if (err) { 2441 if (err) {
2758 free_irq(adap->msix_info[0].vec, adap); 2442 free_irq(adap->msix_info[0].vec, adap);
@@ -4262,6 +3946,7 @@ static int adap_init0(struct adapter *adap)
4262 adap->params.ofldq_wr_cred = val[5]; 3946 adap->params.ofldq_wr_cred = val[5];
4263 3947
4264 adap->params.offload = 1; 3948 adap->params.offload = 1;
3949 adap->num_ofld_uld += 1;
4265 } 3950 }
4266 if (caps_cmd.rdmacaps) { 3951 if (caps_cmd.rdmacaps) {
4267 params[0] = FW_PARAM_PFVF(STAG_START); 3952 params[0] = FW_PARAM_PFVF(STAG_START);
@@ -4314,6 +3999,7 @@ static int adap_init0(struct adapter *adap)
4314 "max_ordird_qp %d max_ird_adapter %d\n", 3999 "max_ordird_qp %d max_ird_adapter %d\n",
4315 adap->params.max_ordird_qp, 4000 adap->params.max_ordird_qp,
4316 adap->params.max_ird_adapter); 4001 adap->params.max_ird_adapter);
4002 adap->num_ofld_uld += 2;
4317 } 4003 }
4318 if (caps_cmd.iscsicaps) { 4004 if (caps_cmd.iscsicaps) {
4319 params[0] = FW_PARAM_PFVF(ISCSI_START); 4005 params[0] = FW_PARAM_PFVF(ISCSI_START);
@@ -4324,6 +4010,8 @@ static int adap_init0(struct adapter *adap)
4324 goto bye; 4010 goto bye;
4325 adap->vres.iscsi.start = val[0]; 4011 adap->vres.iscsi.start = val[0];
4326 adap->vres.iscsi.size = val[1] - val[0] + 1; 4012 adap->vres.iscsi.size = val[1] - val[0] + 1;
4013 /* LIO target and cxgb4i initiaitor */
4014 adap->num_ofld_uld += 2;
4327 } 4015 }
4328 if (caps_cmd.cryptocaps) { 4016 if (caps_cmd.cryptocaps) {
4329 /* Should query params here...TODO */ 4017 /* Should query params here...TODO */
@@ -4523,14 +4211,14 @@ static void cfg_queues(struct adapter *adap)
4523#ifndef CONFIG_CHELSIO_T4_DCB 4211#ifndef CONFIG_CHELSIO_T4_DCB
4524 int q10g = 0; 4212 int q10g = 0;
4525#endif 4213#endif
4526 int ciq_size;
4527 4214
4528 /* Reduce memory usage in kdump environment, disable all offload. 4215 /* Reduce memory usage in kdump environment, disable all offload.
4529 */ 4216 */
4530 if (is_kdump_kernel()) { 4217 if (is_kdump_kernel()) {
4531 adap->params.offload = 0; 4218 adap->params.offload = 0;
4532 adap->params.crypto = 0; 4219 adap->params.crypto = 0;
4533 } else if (adap->num_uld && uld_mem_alloc(adap)) { 4220 } else if (is_uld(adap) && t4_uld_mem_alloc(adap)) {
4221 adap->params.offload = 0;
4534 adap->params.crypto = 0; 4222 adap->params.crypto = 0;
4535 } 4223 }
4536 4224
@@ -4576,33 +4264,18 @@ static void cfg_queues(struct adapter *adap)
4576 s->ethqsets = qidx; 4264 s->ethqsets = qidx;
4577 s->max_ethqsets = qidx; /* MSI-X may lower it later */ 4265 s->max_ethqsets = qidx; /* MSI-X may lower it later */
4578 4266
4579 if (is_offload(adap)) { 4267 if (is_uld(adap)) {
4580 /* 4268 /*
4581 * For offload we use 1 queue/channel if all ports are up to 1G, 4269 * For offload we use 1 queue/channel if all ports are up to 1G,
4582 * otherwise we divide all available queues amongst the channels 4270 * otherwise we divide all available queues amongst the channels
4583 * capped by the number of available cores. 4271 * capped by the number of available cores.
4584 */ 4272 */
4585 if (n10g) { 4273 if (n10g) {
4586 i = min_t(int, ARRAY_SIZE(s->iscsirxq), 4274 i = num_online_cpus();
4587 num_online_cpus()); 4275 s->ofldqsets = roundup(i, adap->params.nports);
4588 s->iscsiqsets = roundup(i, adap->params.nports); 4276 } else {
4589 } else 4277 s->ofldqsets = adap->params.nports;
4590 s->iscsiqsets = adap->params.nports; 4278 }
4591 /* For RDMA one Rx queue per channel suffices */
4592 s->rdmaqs = adap->params.nports;
4593 /* Try and allow at least 1 CIQ per cpu rounding down
4594 * to the number of ports, with a minimum of 1 per port.
4595 * A 2 port card in a 6 cpu system: 6 CIQs, 3 / port.
4596 * A 4 port card in a 6 cpu system: 4 CIQs, 1 / port.
4597 * A 4 port card in a 2 cpu system: 4 CIQs, 1 / port.
4598 */
4599 s->rdmaciqs = min_t(int, MAX_RDMA_CIQS, num_online_cpus());
4600 s->rdmaciqs = (s->rdmaciqs / adap->params.nports) *
4601 adap->params.nports;
4602 s->rdmaciqs = max_t(int, s->rdmaciqs, adap->params.nports);
4603
4604 if (!is_t4(adap->params.chip))
4605 s->niscsitq = s->iscsiqsets;
4606 } 4279 }
4607 4280
4608 for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) { 4281 for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
@@ -4621,47 +4294,8 @@ static void cfg_queues(struct adapter *adap)
4621 for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++) 4294 for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++)
4622 s->ofldtxq[i].q.size = 1024; 4295 s->ofldtxq[i].q.size = 1024;
4623 4296
4624 for (i = 0; i < ARRAY_SIZE(s->iscsirxq); i++) {
4625 struct sge_ofld_rxq *r = &s->iscsirxq[i];
4626
4627 init_rspq(adap, &r->rspq, 5, 1, 1024, 64);
4628 r->rspq.uld = CXGB4_ULD_ISCSI;
4629 r->fl.size = 72;
4630 }
4631
4632 if (!is_t4(adap->params.chip)) {
4633 for (i = 0; i < ARRAY_SIZE(s->iscsitrxq); i++) {
4634 struct sge_ofld_rxq *r = &s->iscsitrxq[i];
4635
4636 init_rspq(adap, &r->rspq, 5, 1, 1024, 64);
4637 r->rspq.uld = CXGB4_ULD_ISCSIT;
4638 r->fl.size = 72;
4639 }
4640 }
4641
4642 for (i = 0; i < ARRAY_SIZE(s->rdmarxq); i++) {
4643 struct sge_ofld_rxq *r = &s->rdmarxq[i];
4644
4645 init_rspq(adap, &r->rspq, 5, 1, 511, 64);
4646 r->rspq.uld = CXGB4_ULD_RDMA;
4647 r->fl.size = 72;
4648 }
4649
4650 ciq_size = 64 + adap->vres.cq.size + adap->tids.nftids;
4651 if (ciq_size > SGE_MAX_IQ_SIZE) {
4652 CH_WARN(adap, "CIQ size too small for available IQs\n");
4653 ciq_size = SGE_MAX_IQ_SIZE;
4654 }
4655
4656 for (i = 0; i < ARRAY_SIZE(s->rdmaciq); i++) {
4657 struct sge_ofld_rxq *r = &s->rdmaciq[i];
4658
4659 init_rspq(adap, &r->rspq, 5, 1, ciq_size, 64);
4660 r->rspq.uld = CXGB4_ULD_RDMA;
4661 }
4662
4663 init_rspq(adap, &s->fw_evtq, 0, 1, 1024, 64); 4297 init_rspq(adap, &s->fw_evtq, 0, 1, 1024, 64);
4664 init_rspq(adap, &s->intrq, 0, 1, 2 * MAX_INGQ, 64); 4298 init_rspq(adap, &s->intrq, 0, 1, 512, 64);
4665} 4299}
4666 4300
4667/* 4301/*
@@ -4695,7 +4329,15 @@ static void reduce_ethqs(struct adapter *adap, int n)
4695static int get_msix_info(struct adapter *adap) 4329static int get_msix_info(struct adapter *adap)
4696{ 4330{
4697 struct uld_msix_info *msix_info; 4331 struct uld_msix_info *msix_info;
4698 int max_ingq = (MAX_OFLD_QSETS * adap->num_uld); 4332 unsigned int max_ingq = 0;
4333
4334 if (is_offload(adap))
4335 max_ingq += MAX_OFLD_QSETS * adap->num_ofld_uld;
4336 if (is_pci_uld(adap))
4337 max_ingq += MAX_OFLD_QSETS * adap->num_uld;
4338
4339 if (!max_ingq)
4340 goto out;
4699 4341
4700 msix_info = kcalloc(max_ingq, sizeof(*msix_info), GFP_KERNEL); 4342 msix_info = kcalloc(max_ingq, sizeof(*msix_info), GFP_KERNEL);
4701 if (!msix_info) 4343 if (!msix_info)
@@ -4709,12 +4351,13 @@ static int get_msix_info(struct adapter *adap)
4709 } 4351 }
4710 spin_lock_init(&adap->msix_bmap_ulds.lock); 4352 spin_lock_init(&adap->msix_bmap_ulds.lock);
4711 adap->msix_info_ulds = msix_info; 4353 adap->msix_info_ulds = msix_info;
4354out:
4712 return 0; 4355 return 0;
4713} 4356}
4714 4357
4715static void free_msix_info(struct adapter *adap) 4358static void free_msix_info(struct adapter *adap)
4716{ 4359{
4717 if (!adap->num_uld) 4360 if (!(adap->num_uld && adap->num_ofld_uld))
4718 return; 4361 return;
4719 4362
4720 kfree(adap->msix_info_ulds); 4363 kfree(adap->msix_info_ulds);
@@ -4733,32 +4376,32 @@ static int enable_msix(struct adapter *adap)
4733 struct msix_entry *entries; 4376 struct msix_entry *entries;
4734 int max_ingq = MAX_INGQ; 4377 int max_ingq = MAX_INGQ;
4735 4378
4736 max_ingq += (MAX_OFLD_QSETS * adap->num_uld); 4379 if (is_pci_uld(adap))
4380 max_ingq += (MAX_OFLD_QSETS * adap->num_uld);
4381 if (is_offload(adap))
4382 max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld);
4737 entries = kmalloc(sizeof(*entries) * (max_ingq + 1), 4383 entries = kmalloc(sizeof(*entries) * (max_ingq + 1),
4738 GFP_KERNEL); 4384 GFP_KERNEL);
4739 if (!entries) 4385 if (!entries)
4740 return -ENOMEM; 4386 return -ENOMEM;
4741 4387
4742 /* map for msix */ 4388 /* map for msix */
4743 if (is_pci_uld(adap) && get_msix_info(adap)) 4389 if (get_msix_info(adap)) {
4390 adap->params.offload = 0;
4744 adap->params.crypto = 0; 4391 adap->params.crypto = 0;
4392 }
4745 4393
4746 for (i = 0; i < max_ingq + 1; ++i) 4394 for (i = 0; i < max_ingq + 1; ++i)
4747 entries[i].entry = i; 4395 entries[i].entry = i;
4748 4396
4749 want = s->max_ethqsets + EXTRA_VECS; 4397 want = s->max_ethqsets + EXTRA_VECS;
4750 if (is_offload(adap)) { 4398 if (is_offload(adap)) {
4751 want += s->rdmaqs + s->rdmaciqs + s->iscsiqsets + 4399 want += adap->num_ofld_uld * s->ofldqsets;
4752 s->niscsitq; 4400 ofld_need = adap->num_ofld_uld * nchan;
4753 /* need nchan for each possible ULD */
4754 if (is_t4(adap->params.chip))
4755 ofld_need = 3 * nchan;
4756 else
4757 ofld_need = 4 * nchan;
4758 } 4401 }
4759 if (is_pci_uld(adap)) { 4402 if (is_pci_uld(adap)) {
4760 want += netif_get_num_default_rss_queues() * nchan; 4403 want += adap->num_uld * s->ofldqsets;
4761 uld_need = nchan; 4404 uld_need = adap->num_uld * nchan;
4762 } 4405 }
4763#ifdef CONFIG_CHELSIO_T4_DCB 4406#ifdef CONFIG_CHELSIO_T4_DCB
4764 /* For Data Center Bridging we need 8 Ethernet TX Priority Queues for 4407 /* For Data Center Bridging we need 8 Ethernet TX Priority Queues for
@@ -4786,43 +4429,25 @@ static int enable_msix(struct adapter *adap)
4786 if (i < s->ethqsets) 4429 if (i < s->ethqsets)
4787 reduce_ethqs(adap, i); 4430 reduce_ethqs(adap, i);
4788 } 4431 }
4789 if (is_pci_uld(adap)) { 4432 if (is_uld(adap)) {
4790 if (allocated < want) 4433 if (allocated < want)
4791 s->nqs_per_uld = nchan; 4434 s->nqs_per_uld = nchan;
4792 else 4435 else
4793 s->nqs_per_uld = netif_get_num_default_rss_queues() * 4436 s->nqs_per_uld = s->ofldqsets;
4794 nchan;
4795 } 4437 }
4796 4438
4797 if (is_offload(adap)) { 4439 for (i = 0; i < (s->max_ethqsets + EXTRA_VECS); ++i)
4798 if (allocated < want) {
4799 s->rdmaqs = nchan;
4800 s->rdmaciqs = nchan;
4801
4802 if (!is_t4(adap->params.chip))
4803 s->niscsitq = nchan;
4804 }
4805
4806 /* leftovers go to OFLD */
4807 i = allocated - EXTRA_VECS - s->max_ethqsets -
4808 s->rdmaqs - s->rdmaciqs - s->niscsitq;
4809 if (is_pci_uld(adap))
4810 i -= s->nqs_per_uld * adap->num_uld;
4811 s->iscsiqsets = (i / nchan) * nchan; /* round down */
4812
4813 }
4814
4815 for (i = 0; i < (allocated - (s->nqs_per_uld * adap->num_uld)); ++i)
4816 adap->msix_info[i].vec = entries[i].vector; 4440 adap->msix_info[i].vec = entries[i].vector;
4817 if (is_pci_uld(adap)) { 4441 if (is_uld(adap)) {
4818 for (j = 0 ; i < allocated; ++i, j++) 4442 for (j = 0 ; i < allocated; ++i, j++) {
4819 adap->msix_info_ulds[j].vec = entries[i].vector; 4443 adap->msix_info_ulds[j].vec = entries[i].vector;
4444 adap->msix_info_ulds[j].idx = i;
4445 }
4820 adap->msix_bmap_ulds.mapsize = j; 4446 adap->msix_bmap_ulds.mapsize = j;
4821 } 4447 }
4822 dev_info(adap->pdev_dev, "%d MSI-X vectors allocated, " 4448 dev_info(adap->pdev_dev, "%d MSI-X vectors allocated, "
4823 "nic %d iscsi %d rdma cpl %d rdma ciq %d uld %d\n", 4449 "nic %d per uld %d\n",
4824 allocated, s->max_ethqsets, s->iscsiqsets, s->rdmaqs, 4450 allocated, s->max_ethqsets, s->nqs_per_uld);
4825 s->rdmaciqs, s->nqs_per_uld);
4826 4451
4827 kfree(entries); 4452 kfree(entries);
4828 return 0; 4453 return 0;
@@ -5535,10 +5160,14 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5535 /* PCIe EEH recovery on powerpc platforms needs fundamental reset */ 5160 /* PCIe EEH recovery on powerpc platforms needs fundamental reset */
5536 pdev->needs_freset = 1; 5161 pdev->needs_freset = 1;
5537 5162
5538 if (is_offload(adapter)) 5163 if (is_uld(adapter)) {
5539 attach_ulds(adapter); 5164 mutex_lock(&uld_mutex);
5165 list_add_tail(&adapter->list_node, &adapter_list);
5166 mutex_unlock(&uld_mutex);
5167 }
5540 5168
5541 print_adapter_info(adapter); 5169 print_adapter_info(adapter);
5170 setup_fw_sge_queues(adapter);
5542 return 0; 5171 return 0;
5543 5172
5544sriov: 5173sriov:
@@ -5593,8 +5222,8 @@ sriov:
5593 free_some_resources(adapter); 5222 free_some_resources(adapter);
5594 if (adapter->flags & USING_MSIX) 5223 if (adapter->flags & USING_MSIX)
5595 free_msix_info(adapter); 5224 free_msix_info(adapter);
5596 if (adapter->num_uld) 5225 if (adapter->num_uld || adapter->num_ofld_uld)
5597 uld_mem_free(adapter); 5226 t4_uld_mem_free(adapter);
5598 out_unmap_bar: 5227 out_unmap_bar:
5599 if (!is_t4(adapter->params.chip)) 5228 if (!is_t4(adapter->params.chip))
5600 iounmap(adapter->bar2); 5229 iounmap(adapter->bar2);
@@ -5631,7 +5260,7 @@ static void remove_one(struct pci_dev *pdev)
5631 */ 5260 */
5632 destroy_workqueue(adapter->workq); 5261 destroy_workqueue(adapter->workq);
5633 5262
5634 if (is_offload(adapter)) 5263 if (is_uld(adapter))
5635 detach_ulds(adapter); 5264 detach_ulds(adapter);
5636 5265
5637 disable_interrupts(adapter); 5266 disable_interrupts(adapter);
@@ -5658,8 +5287,8 @@ static void remove_one(struct pci_dev *pdev)
5658 5287
5659 if (adapter->flags & USING_MSIX) 5288 if (adapter->flags & USING_MSIX)
5660 free_msix_info(adapter); 5289 free_msix_info(adapter);
5661 if (adapter->num_uld) 5290 if (adapter->num_uld || adapter->num_ofld_uld)
5662 uld_mem_free(adapter); 5291 t4_uld_mem_free(adapter);
5663 free_some_resources(adapter); 5292 free_some_resources(adapter);
5664#if IS_ENABLED(CONFIG_IPV6) 5293#if IS_ENABLED(CONFIG_IPV6)
5665 t4_cleanup_clip_tbl(adapter); 5294 t4_cleanup_clip_tbl(adapter);
@@ -5690,12 +5319,58 @@ static void remove_one(struct pci_dev *pdev)
5690#endif 5319#endif
5691} 5320}
5692 5321
5322/* "Shutdown" quiesces the device, stopping Ingress Packet and Interrupt
5323 * delivery. This is essentially a stripped down version of the PCI remove()
5324 * function where we do the minimal amount of work necessary to shutdown any
5325 * further activity.
5326 */
5327static void shutdown_one(struct pci_dev *pdev)
5328{
5329 struct adapter *adapter = pci_get_drvdata(pdev);
5330
5331 /* As with remove_one() above (see extended comment), we only want do
5332 * do cleanup on PCI Devices which went all the way through init_one()
5333 * ...
5334 */
5335 if (!adapter) {
5336 pci_release_regions(pdev);
5337 return;
5338 }
5339
5340 if (adapter->pf == 4) {
5341 int i;
5342
5343 for_each_port(adapter, i)
5344 if (adapter->port[i]->reg_state == NETREG_REGISTERED)
5345 cxgb_close(adapter->port[i]);
5346
5347 t4_uld_clean_up(adapter);
5348 disable_interrupts(adapter);
5349 disable_msi(adapter);
5350
5351 t4_sge_stop(adapter);
5352 if (adapter->flags & FW_OK)
5353 t4_fw_bye(adapter, adapter->mbox);
5354 }
5355#ifdef CONFIG_PCI_IOV
5356 else {
5357 if (adapter->port[0])
5358 unregister_netdev(adapter->port[0]);
5359 iounmap(adapter->regs);
5360 kfree(adapter->vfinfo);
5361 kfree(adapter);
5362 pci_disable_sriov(pdev);
5363 pci_release_regions(pdev);
5364 }
5365#endif
5366}
5367
5693static struct pci_driver cxgb4_driver = { 5368static struct pci_driver cxgb4_driver = {
5694 .name = KBUILD_MODNAME, 5369 .name = KBUILD_MODNAME,
5695 .id_table = cxgb4_pci_tbl, 5370 .id_table = cxgb4_pci_tbl,
5696 .probe = init_one, 5371 .probe = init_one,
5697 .remove = remove_one, 5372 .remove = remove_one,
5698 .shutdown = remove_one, 5373 .shutdown = shutdown_one,
5699#ifdef CONFIG_PCI_IOV 5374#ifdef CONFIG_PCI_IOV
5700 .sriov_configure = cxgb4_iov_configure, 5375 .sriov_configure = cxgb4_iov_configure,
5701#endif 5376#endif
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index 5d402bace6c1..fc04e3b878e8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -82,6 +82,24 @@ static void free_msix_idx_in_bmap(struct adapter *adap, unsigned int msix_idx)
82 spin_unlock_irqrestore(&bmap->lock, flags); 82 spin_unlock_irqrestore(&bmap->lock, flags);
83} 83}
84 84
85/* Flush the aggregated lro sessions */
86static void uldrx_flush_handler(struct sge_rspq *q)
87{
88 struct adapter *adap = q->adap;
89
90 if (adap->uld[q->uld].lro_flush)
91 adap->uld[q->uld].lro_flush(&q->lro_mgr);
92}
93
94/**
95 * uldrx_handler - response queue handler for ULD queues
96 * @q: the response queue that received the packet
97 * @rsp: the response queue descriptor holding the offload message
98 * @gl: the gather list of packet fragments
99 *
100 * Deliver an ingress offload packet to a ULD. All processing is done by
101 * the ULD, we just maintain statistics.
102 */
85static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp, 103static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
86 const struct pkt_gl *gl) 104 const struct pkt_gl *gl)
87{ 105{
@@ -124,8 +142,8 @@ static int alloc_uld_rxqs(struct adapter *adap,
124 struct sge_ofld_rxq *q = rxq_info->uldrxq + offset; 142 struct sge_ofld_rxq *q = rxq_info->uldrxq + offset;
125 unsigned short *ids = rxq_info->rspq_id + offset; 143 unsigned short *ids = rxq_info->rspq_id + offset;
126 unsigned int per_chan = nq / adap->params.nports; 144 unsigned int per_chan = nq / adap->params.nports;
127 unsigned int msi_idx, bmap_idx; 145 unsigned int bmap_idx = 0;
128 int i, err; 146 int i, err, msi_idx;
129 147
130 if (adap->flags & USING_MSIX) 148 if (adap->flags & USING_MSIX)
131 msi_idx = 1; 149 msi_idx = 1;
@@ -135,14 +153,14 @@ static int alloc_uld_rxqs(struct adapter *adap,
135 for (i = 0; i < nq; i++, q++) { 153 for (i = 0; i < nq; i++, q++) {
136 if (msi_idx >= 0) { 154 if (msi_idx >= 0) {
137 bmap_idx = get_msix_idx_from_bmap(adap); 155 bmap_idx = get_msix_idx_from_bmap(adap);
138 adap->msi_idx++; 156 msi_idx = adap->msix_info_ulds[bmap_idx].idx;
139 } 157 }
140 err = t4_sge_alloc_rxq(adap, &q->rspq, false, 158 err = t4_sge_alloc_rxq(adap, &q->rspq, false,
141 adap->port[i / per_chan], 159 adap->port[i / per_chan],
142 adap->msi_idx, 160 msi_idx,
143 q->fl.size ? &q->fl : NULL, 161 q->fl.size ? &q->fl : NULL,
144 uldrx_handler, 162 uldrx_handler,
145 NULL, 163 lro ? uldrx_flush_handler : NULL,
146 0); 164 0);
147 if (err) 165 if (err)
148 goto freeout; 166 goto freeout;
@@ -159,7 +177,6 @@ freeout:
159 if (q->rspq.desc) 177 if (q->rspq.desc)
160 free_rspq_fl(adap, &q->rspq, 178 free_rspq_fl(adap, &q->rspq,
161 q->fl.size ? &q->fl : NULL); 179 q->fl.size ? &q->fl : NULL);
162 adap->msi_idx--;
163 } 180 }
164 181
165 /* We need to free rxq also in case of ciq allocation failure */ 182 /* We need to free rxq also in case of ciq allocation failure */
@@ -169,7 +186,6 @@ freeout:
169 if (q->rspq.desc) 186 if (q->rspq.desc)
170 free_rspq_fl(adap, &q->rspq, 187 free_rspq_fl(adap, &q->rspq,
171 q->fl.size ? &q->fl : NULL); 188 q->fl.size ? &q->fl : NULL);
172 adap->msi_idx--;
173 } 189 }
174 } 190 }
175 return err; 191 return err;
@@ -178,17 +194,38 @@ freeout:
178int setup_sge_queues_uld(struct adapter *adap, unsigned int uld_type, bool lro) 194int setup_sge_queues_uld(struct adapter *adap, unsigned int uld_type, bool lro)
179{ 195{
180 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type]; 196 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type];
197 int i, ret = 0;
181 198
182 if (adap->flags & USING_MSIX) { 199 if (adap->flags & USING_MSIX) {
183 rxq_info->msix_tbl = kzalloc(rxq_info->nrxq + rxq_info->nciq, 200 rxq_info->msix_tbl = kcalloc((rxq_info->nrxq + rxq_info->nciq),
201 sizeof(unsigned short),
184 GFP_KERNEL); 202 GFP_KERNEL);
185 if (!rxq_info->msix_tbl) 203 if (!rxq_info->msix_tbl)
186 return -ENOMEM; 204 return -ENOMEM;
187 } 205 }
188 206
189 return !(!alloc_uld_rxqs(adap, rxq_info, rxq_info->nrxq, 0, lro) && 207 ret = !(!alloc_uld_rxqs(adap, rxq_info, rxq_info->nrxq, 0, lro) &&
190 !alloc_uld_rxqs(adap, rxq_info, rxq_info->nciq, 208 !alloc_uld_rxqs(adap, rxq_info, rxq_info->nciq,
191 rxq_info->nrxq, lro)); 209 rxq_info->nrxq, lro));
210
211 /* Tell uP to route control queue completions to rdma rspq */
212 if (adap->flags & FULL_INIT_DONE &&
213 !ret && uld_type == CXGB4_ULD_RDMA) {
214 struct sge *s = &adap->sge;
215 unsigned int cmplqid;
216 u32 param, cmdop;
217
218 cmdop = FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL;
219 for_each_port(adap, i) {
220 cmplqid = rxq_info->uldrxq[i].rspq.cntxt_id;
221 param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DMAQ) |
222 FW_PARAMS_PARAM_X_V(cmdop) |
223 FW_PARAMS_PARAM_YZ_V(s->ctrlq[i].q.cntxt_id));
224 ret = t4_set_params(adap, adap->mbox, adap->pf,
225 0, 1, &param, &cmplqid);
226 }
227 }
228 return ret;
192} 229}
193 230
194static void t4_free_uld_rxqs(struct adapter *adap, int n, 231static void t4_free_uld_rxqs(struct adapter *adap, int n,
@@ -198,7 +235,6 @@ static void t4_free_uld_rxqs(struct adapter *adap, int n,
198 if (q->rspq.desc) 235 if (q->rspq.desc)
199 free_rspq_fl(adap, &q->rspq, 236 free_rspq_fl(adap, &q->rspq,
200 q->fl.size ? &q->fl : NULL); 237 q->fl.size ? &q->fl : NULL);
201 adap->msi_idx--;
202 } 238 }
203} 239}
204 240
@@ -206,6 +242,21 @@ void free_sge_queues_uld(struct adapter *adap, unsigned int uld_type)
206{ 242{
207 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type]; 243 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type];
208 244
245 if (adap->flags & FULL_INIT_DONE && uld_type == CXGB4_ULD_RDMA) {
246 struct sge *s = &adap->sge;
247 u32 param, cmdop, cmplqid = 0;
248 int i;
249
250 cmdop = FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL;
251 for_each_port(adap, i) {
252 param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DMAQ) |
253 FW_PARAMS_PARAM_X_V(cmdop) |
254 FW_PARAMS_PARAM_YZ_V(s->ctrlq[i].q.cntxt_id));
255 t4_set_params(adap, adap->mbox, adap->pf,
256 0, 1, &param, &cmplqid);
257 }
258 }
259
209 if (rxq_info->nciq) 260 if (rxq_info->nciq)
210 t4_free_uld_rxqs(adap, rxq_info->nciq, 261 t4_free_uld_rxqs(adap, rxq_info->nciq,
211 rxq_info->uldrxq + rxq_info->nrxq); 262 rxq_info->uldrxq + rxq_info->nrxq);
@@ -215,26 +266,38 @@ void free_sge_queues_uld(struct adapter *adap, unsigned int uld_type)
215} 266}
216 267
217int cfg_queues_uld(struct adapter *adap, unsigned int uld_type, 268int cfg_queues_uld(struct adapter *adap, unsigned int uld_type,
218 const struct cxgb4_pci_uld_info *uld_info) 269 const struct cxgb4_uld_info *uld_info)
219{ 270{
220 struct sge *s = &adap->sge; 271 struct sge *s = &adap->sge;
221 struct sge_uld_rxq_info *rxq_info; 272 struct sge_uld_rxq_info *rxq_info;
222 int i, nrxq; 273 int i, nrxq, ciq_size;
223 274
224 rxq_info = kzalloc(sizeof(*rxq_info), GFP_KERNEL); 275 rxq_info = kzalloc(sizeof(*rxq_info), GFP_KERNEL);
225 if (!rxq_info) 276 if (!rxq_info)
226 return -ENOMEM; 277 return -ENOMEM;
227 278
228 if (uld_info->nrxq > s->nqs_per_uld) 279 if (adap->flags & USING_MSIX && uld_info->nrxq > s->nqs_per_uld) {
229 rxq_info->nrxq = s->nqs_per_uld; 280 i = s->nqs_per_uld;
230 else 281 rxq_info->nrxq = roundup(i, adap->params.nports);
231 rxq_info->nrxq = uld_info->nrxq; 282 } else {
232 if (!uld_info->nciq) 283 i = min_t(int, uld_info->nrxq,
284 num_online_cpus());
285 rxq_info->nrxq = roundup(i, adap->params.nports);
286 }
287 if (!uld_info->ciq) {
233 rxq_info->nciq = 0; 288 rxq_info->nciq = 0;
234 else if (uld_info->nciq && uld_info->nciq > s->nqs_per_uld) 289 } else {
235 rxq_info->nciq = s->nqs_per_uld; 290 if (adap->flags & USING_MSIX)
236 else 291 rxq_info->nciq = min_t(int, s->nqs_per_uld,
237 rxq_info->nciq = uld_info->nciq; 292 num_online_cpus());
293 else
294 rxq_info->nciq = min_t(int, MAX_OFLD_QSETS,
295 num_online_cpus());
296 rxq_info->nciq = ((rxq_info->nciq / adap->params.nports) *
297 adap->params.nports);
298 rxq_info->nciq = max_t(int, rxq_info->nciq,
299 adap->params.nports);
300 }
238 301
239 nrxq = rxq_info->nrxq + rxq_info->nciq; /* total rxq's */ 302 nrxq = rxq_info->nrxq + rxq_info->nciq; /* total rxq's */
240 rxq_info->uldrxq = kcalloc(nrxq, sizeof(struct sge_ofld_rxq), 303 rxq_info->uldrxq = kcalloc(nrxq, sizeof(struct sge_ofld_rxq),
@@ -259,12 +322,17 @@ int cfg_queues_uld(struct adapter *adap, unsigned int uld_type,
259 r->fl.size = 72; 322 r->fl.size = 72;
260 } 323 }
261 324
325 ciq_size = 64 + adap->vres.cq.size + adap->tids.nftids;
326 if (ciq_size > SGE_MAX_IQ_SIZE) {
327 dev_warn(adap->pdev_dev, "CIQ size too small for available IQs\n");
328 ciq_size = SGE_MAX_IQ_SIZE;
329 }
330
262 for (i = rxq_info->nrxq; i < nrxq; i++) { 331 for (i = rxq_info->nrxq; i < nrxq; i++) {
263 struct sge_ofld_rxq *r = &rxq_info->uldrxq[i]; 332 struct sge_ofld_rxq *r = &rxq_info->uldrxq[i];
264 333
265 init_rspq(adap, &r->rspq, 5, 1, uld_info->ciq_size, 64); 334 init_rspq(adap, &r->rspq, 5, 1, ciq_size, 64);
266 r->rspq.uld = uld_type; 335 r->rspq.uld = uld_type;
267 r->fl.size = 72;
268 } 336 }
269 337
270 memcpy(rxq_info->name, uld_info->name, IFNAMSIZ); 338 memcpy(rxq_info->name, uld_info->name, IFNAMSIZ);
@@ -285,7 +353,8 @@ void free_queues_uld(struct adapter *adap, unsigned int uld_type)
285int request_msix_queue_irqs_uld(struct adapter *adap, unsigned int uld_type) 353int request_msix_queue_irqs_uld(struct adapter *adap, unsigned int uld_type)
286{ 354{
287 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type]; 355 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type];
288 int idx, bmap_idx, err = 0; 356 int err = 0;
357 unsigned int idx, bmap_idx;
289 358
290 for_each_uldrxq(rxq_info, idx) { 359 for_each_uldrxq(rxq_info, idx) {
291 bmap_idx = rxq_info->msix_tbl[idx]; 360 bmap_idx = rxq_info->msix_tbl[idx];
@@ -310,10 +379,10 @@ unwind:
310void free_msix_queue_irqs_uld(struct adapter *adap, unsigned int uld_type) 379void free_msix_queue_irqs_uld(struct adapter *adap, unsigned int uld_type)
311{ 380{
312 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type]; 381 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type];
313 int idx; 382 unsigned int idx, bmap_idx;
314 383
315 for_each_uldrxq(rxq_info, idx) { 384 for_each_uldrxq(rxq_info, idx) {
316 unsigned int bmap_idx = rxq_info->msix_tbl[idx]; 385 bmap_idx = rxq_info->msix_tbl[idx];
317 386
318 free_msix_idx_in_bmap(adap, bmap_idx); 387 free_msix_idx_in_bmap(adap, bmap_idx);
319 free_irq(adap->msix_info_ulds[bmap_idx].vec, 388 free_irq(adap->msix_info_ulds[bmap_idx].vec,
@@ -325,10 +394,10 @@ void name_msix_vecs_uld(struct adapter *adap, unsigned int uld_type)
325{ 394{
326 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type]; 395 struct sge_uld_rxq_info *rxq_info = adap->sge.uld_rxq_info[uld_type];
327 int n = sizeof(adap->msix_info_ulds[0].desc); 396 int n = sizeof(adap->msix_info_ulds[0].desc);
328 int idx; 397 unsigned int idx, bmap_idx;
329 398
330 for_each_uldrxq(rxq_info, idx) { 399 for_each_uldrxq(rxq_info, idx) {
331 unsigned int bmap_idx = rxq_info->msix_tbl[idx]; 400 bmap_idx = rxq_info->msix_tbl[idx];
332 401
333 snprintf(adap->msix_info_ulds[bmap_idx].desc, n, "%s-%s%d", 402 snprintf(adap->msix_info_ulds[bmap_idx].desc, n, "%s-%s%d",
334 adap->port[0]->name, rxq_info->name, idx); 403 adap->port[0]->name, rxq_info->name, idx);
@@ -390,15 +459,15 @@ static void uld_queue_init(struct adapter *adap, unsigned int uld_type,
390 lli->nciq = rxq_info->nciq; 459 lli->nciq = rxq_info->nciq;
391} 460}
392 461
393int uld_mem_alloc(struct adapter *adap) 462int t4_uld_mem_alloc(struct adapter *adap)
394{ 463{
395 struct sge *s = &adap->sge; 464 struct sge *s = &adap->sge;
396 465
397 adap->uld = kcalloc(adap->num_uld, sizeof(*adap->uld), GFP_KERNEL); 466 adap->uld = kcalloc(CXGB4_ULD_MAX, sizeof(*adap->uld), GFP_KERNEL);
398 if (!adap->uld) 467 if (!adap->uld)
399 return -ENOMEM; 468 return -ENOMEM;
400 469
401 s->uld_rxq_info = kzalloc(adap->num_uld * 470 s->uld_rxq_info = kzalloc(CXGB4_ULD_MAX *
402 sizeof(struct sge_uld_rxq_info *), 471 sizeof(struct sge_uld_rxq_info *),
403 GFP_KERNEL); 472 GFP_KERNEL);
404 if (!s->uld_rxq_info) 473 if (!s->uld_rxq_info)
@@ -410,7 +479,7 @@ err_uld:
410 return -ENOMEM; 479 return -ENOMEM;
411} 480}
412 481
413void uld_mem_free(struct adapter *adap) 482void t4_uld_mem_free(struct adapter *adap)
414{ 483{
415 struct sge *s = &adap->sge; 484 struct sge *s = &adap->sge;
416 485
@@ -418,6 +487,26 @@ void uld_mem_free(struct adapter *adap)
418 kfree(adap->uld); 487 kfree(adap->uld);
419} 488}
420 489
490void t4_uld_clean_up(struct adapter *adap)
491{
492 struct sge_uld_rxq_info *rxq_info;
493 unsigned int i;
494
495 if (!adap->uld)
496 return;
497 for (i = 0; i < CXGB4_ULD_MAX; i++) {
498 if (!adap->uld[i].handle)
499 continue;
500 rxq_info = adap->sge.uld_rxq_info[i];
501 if (adap->flags & FULL_INIT_DONE)
502 quiesce_rx_uld(adap, i);
503 if (adap->flags & USING_MSIX)
504 free_msix_queue_irqs_uld(adap, i);
505 free_sge_queues_uld(adap, i);
506 free_queues_uld(adap, i);
507 }
508}
509
421static void uld_init(struct adapter *adap, struct cxgb4_lld_info *lld) 510static void uld_init(struct adapter *adap, struct cxgb4_lld_info *lld)
422{ 511{
423 int i; 512 int i;
@@ -429,10 +518,15 @@ static void uld_init(struct adapter *adap, struct cxgb4_lld_info *lld)
429 lld->ports = adap->port; 518 lld->ports = adap->port;
430 lld->vr = &adap->vres; 519 lld->vr = &adap->vres;
431 lld->mtus = adap->params.mtus; 520 lld->mtus = adap->params.mtus;
432 lld->ntxq = adap->sge.iscsiqsets; 521 lld->ntxq = adap->sge.ofldqsets;
433 lld->nchan = adap->params.nports; 522 lld->nchan = adap->params.nports;
434 lld->nports = adap->params.nports; 523 lld->nports = adap->params.nports;
435 lld->wr_cred = adap->params.ofldq_wr_cred; 524 lld->wr_cred = adap->params.ofldq_wr_cred;
525 lld->iscsi_iolen = MAXRXDATA_G(t4_read_reg(adap, TP_PARA_REG2_A));
526 lld->iscsi_tagmask = t4_read_reg(adap, ULP_RX_ISCSI_TAGMASK_A);
527 lld->iscsi_pgsz_order = t4_read_reg(adap, ULP_RX_ISCSI_PSZ_A);
528 lld->iscsi_llimit = t4_read_reg(adap, ULP_RX_ISCSI_LLIMIT_A);
529 lld->iscsi_ppm = &adap->iscsi_ppm;
436 lld->adapter_type = adap->params.chip; 530 lld->adapter_type = adap->params.chip;
437 lld->cclk_ps = 1000000000 / adap->params.vpd.cclk; 531 lld->cclk_ps = 1000000000 / adap->params.vpd.cclk;
438 lld->udb_density = 1 << adap->params.sge.eq_qpp; 532 lld->udb_density = 1 << adap->params.sge.eq_qpp;
@@ -472,23 +566,37 @@ static void uld_attach(struct adapter *adap, unsigned int uld)
472 } 566 }
473 567
474 adap->uld[uld].handle = handle; 568 adap->uld[uld].handle = handle;
569 t4_register_netevent_notifier();
475 570
476 if (adap->flags & FULL_INIT_DONE) 571 if (adap->flags & FULL_INIT_DONE)
477 adap->uld[uld].state_change(handle, CXGB4_STATE_UP); 572 adap->uld[uld].state_change(handle, CXGB4_STATE_UP);
478} 573}
479 574
480int cxgb4_register_pci_uld(enum cxgb4_pci_uld type, 575/**
481 struct cxgb4_pci_uld_info *p) 576 * cxgb4_register_uld - register an upper-layer driver
577 * @type: the ULD type
578 * @p: the ULD methods
579 *
580 * Registers an upper-layer driver with this driver and notifies the ULD
581 * about any presently available devices that support its type. Returns
582 * %-EBUSY if a ULD of the same type is already registered.
583 */
584int cxgb4_register_uld(enum cxgb4_uld type,
585 const struct cxgb4_uld_info *p)
482{ 586{
483 int ret = 0; 587 int ret = 0;
588 unsigned int adap_idx = 0;
484 struct adapter *adap; 589 struct adapter *adap;
485 590
486 if (type >= CXGB4_PCI_ULD_MAX) 591 if (type >= CXGB4_ULD_MAX)
487 return -EINVAL; 592 return -EINVAL;
488 593
489 mutex_lock(&uld_mutex); 594 mutex_lock(&uld_mutex);
490 list_for_each_entry(adap, &adapter_list, list_node) { 595 list_for_each_entry(adap, &adapter_list, list_node) {
491 if (!is_pci_uld(adap)) 596 if ((type == CXGB4_ULD_CRYPTO && !is_pci_uld(adap)) ||
597 (type != CXGB4_ULD_CRYPTO && !is_offload(adap)))
598 continue;
599 if (type == CXGB4_ULD_ISCSIT && is_t4(adap->params.chip))
492 continue; 600 continue;
493 ret = cfg_queues_uld(adap, type, p); 601 ret = cfg_queues_uld(adap, type, p);
494 if (ret) 602 if (ret)
@@ -510,11 +618,14 @@ int cxgb4_register_pci_uld(enum cxgb4_pci_uld type,
510 } 618 }
511 adap->uld[type] = *p; 619 adap->uld[type] = *p;
512 uld_attach(adap, type); 620 uld_attach(adap, type);
621 adap_idx++;
513 } 622 }
514 mutex_unlock(&uld_mutex); 623 mutex_unlock(&uld_mutex);
515 return 0; 624 return 0;
516 625
517free_irq: 626free_irq:
627 if (adap->flags & FULL_INIT_DONE)
628 quiesce_rx_uld(adap, type);
518 if (adap->flags & USING_MSIX) 629 if (adap->flags & USING_MSIX)
519 free_msix_queue_irqs_uld(adap, type); 630 free_msix_queue_irqs_uld(adap, type);
520free_rxq: 631free_rxq:
@@ -522,21 +633,49 @@ free_rxq:
522free_queues: 633free_queues:
523 free_queues_uld(adap, type); 634 free_queues_uld(adap, type);
524out: 635out:
636
637 list_for_each_entry(adap, &adapter_list, list_node) {
638 if ((type == CXGB4_ULD_CRYPTO && !is_pci_uld(adap)) ||
639 (type != CXGB4_ULD_CRYPTO && !is_offload(adap)))
640 continue;
641 if (type == CXGB4_ULD_ISCSIT && is_t4(adap->params.chip))
642 continue;
643 if (!adap_idx)
644 break;
645 adap->uld[type].handle = NULL;
646 adap->uld[type].add = NULL;
647 if (adap->flags & FULL_INIT_DONE)
648 quiesce_rx_uld(adap, type);
649 if (adap->flags & USING_MSIX)
650 free_msix_queue_irqs_uld(adap, type);
651 free_sge_queues_uld(adap, type);
652 free_queues_uld(adap, type);
653 adap_idx--;
654 }
525 mutex_unlock(&uld_mutex); 655 mutex_unlock(&uld_mutex);
526 return ret; 656 return ret;
527} 657}
528EXPORT_SYMBOL(cxgb4_register_pci_uld); 658EXPORT_SYMBOL(cxgb4_register_uld);
529 659
530int cxgb4_unregister_pci_uld(enum cxgb4_pci_uld type) 660/**
661 * cxgb4_unregister_uld - unregister an upper-layer driver
662 * @type: the ULD type
663 *
664 * Unregisters an existing upper-layer driver.
665 */
666int cxgb4_unregister_uld(enum cxgb4_uld type)
531{ 667{
532 struct adapter *adap; 668 struct adapter *adap;
533 669
534 if (type >= CXGB4_PCI_ULD_MAX) 670 if (type >= CXGB4_ULD_MAX)
535 return -EINVAL; 671 return -EINVAL;
536 672
537 mutex_lock(&uld_mutex); 673 mutex_lock(&uld_mutex);
538 list_for_each_entry(adap, &adapter_list, list_node) { 674 list_for_each_entry(adap, &adapter_list, list_node) {
539 if (!is_pci_uld(adap)) 675 if ((type == CXGB4_ULD_CRYPTO && !is_pci_uld(adap)) ||
676 (type != CXGB4_ULD_CRYPTO && !is_offload(adap)))
677 continue;
678 if (type == CXGB4_ULD_ISCSIT && is_t4(adap->params.chip))
540 continue; 679 continue;
541 adap->uld[type].handle = NULL; 680 adap->uld[type].handle = NULL;
542 adap->uld[type].add = NULL; 681 adap->uld[type].add = NULL;
@@ -551,4 +690,4 @@ int cxgb4_unregister_pci_uld(enum cxgb4_pci_uld type)
551 690
552 return 0; 691 return 0;
553} 692}
554EXPORT_SYMBOL(cxgb4_unregister_pci_uld); 693EXPORT_SYMBOL(cxgb4_unregister_uld);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index ab4037222f8d..b3544f6b88ca 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -42,6 +42,8 @@
42#include <linux/atomic.h> 42#include <linux/atomic.h>
43#include "cxgb4.h" 43#include "cxgb4.h"
44 44
45#define MAX_ULD_QSETS 16
46
45/* CPL message priority levels */ 47/* CPL message priority levels */
46enum { 48enum {
47 CPL_PRIORITY_DATA = 0, /* data messages */ 49 CPL_PRIORITY_DATA = 0, /* data messages */
@@ -189,9 +191,11 @@ static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)
189} 191}
190 192
191enum cxgb4_uld { 193enum cxgb4_uld {
194 CXGB4_ULD_INIT,
192 CXGB4_ULD_RDMA, 195 CXGB4_ULD_RDMA,
193 CXGB4_ULD_ISCSI, 196 CXGB4_ULD_ISCSI,
194 CXGB4_ULD_ISCSIT, 197 CXGB4_ULD_ISCSIT,
198 CXGB4_ULD_CRYPTO,
195 CXGB4_ULD_MAX 199 CXGB4_ULD_MAX
196}; 200};
197 201
@@ -284,31 +288,11 @@ struct cxgb4_lld_info {
284 288
285struct cxgb4_uld_info { 289struct cxgb4_uld_info {
286 const char *name; 290 const char *name;
287 void *(*add)(const struct cxgb4_lld_info *p);
288 int (*rx_handler)(void *handle, const __be64 *rsp,
289 const struct pkt_gl *gl);
290 int (*state_change)(void *handle, enum cxgb4_state new_state);
291 int (*control)(void *handle, enum cxgb4_control control, ...);
292 int (*lro_rx_handler)(void *handle, const __be64 *rsp,
293 const struct pkt_gl *gl,
294 struct t4_lro_mgr *lro_mgr,
295 struct napi_struct *napi);
296 void (*lro_flush)(struct t4_lro_mgr *);
297};
298
299enum cxgb4_pci_uld {
300 CXGB4_PCI_ULD1,
301 CXGB4_PCI_ULD_MAX
302};
303
304struct cxgb4_pci_uld_info {
305 const char *name;
306 bool lro;
307 void *handle; 291 void *handle;
308 unsigned int nrxq; 292 unsigned int nrxq;
309 unsigned int nciq;
310 unsigned int rxq_size; 293 unsigned int rxq_size;
311 unsigned int ciq_size; 294 bool ciq;
295 bool lro;
312 void *(*add)(const struct cxgb4_lld_info *p); 296 void *(*add)(const struct cxgb4_lld_info *p);
313 int (*rx_handler)(void *handle, const __be64 *rsp, 297 int (*rx_handler)(void *handle, const __be64 *rsp,
314 const struct pkt_gl *gl); 298 const struct pkt_gl *gl);
@@ -323,9 +307,6 @@ struct cxgb4_pci_uld_info {
323 307
324int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p); 308int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p);
325int cxgb4_unregister_uld(enum cxgb4_uld type); 309int cxgb4_unregister_uld(enum cxgb4_uld type);
326int cxgb4_register_pci_uld(enum cxgb4_pci_uld type,
327 struct cxgb4_pci_uld_info *p);
328int cxgb4_unregister_pci_uld(enum cxgb4_pci_uld type);
329int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb); 310int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb);
330unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo); 311unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo);
331unsigned int cxgb4_port_chan(const struct net_device *dev); 312unsigned int cxgb4_port_chan(const struct net_device *dev);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 9a607dbc6ca8..1e74fd6085df 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2860,6 +2860,18 @@ int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
2860 return 0; 2860 return 0;
2861} 2861}
2862 2862
2863int t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid,
2864 unsigned int cmplqid)
2865{
2866 u32 param, val;
2867
2868 param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DMAQ) |
2869 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL) |
2870 FW_PARAMS_PARAM_YZ_V(eqid));
2871 val = cmplqid;
2872 return t4_set_params(adap, adap->mbox, adap->pf, 0, 1, &param, &val);
2873}
2874
2863int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq, 2875int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
2864 struct net_device *dev, unsigned int iqid) 2876 struct net_device *dev, unsigned int iqid)
2865{ 2877{
@@ -3014,12 +3026,6 @@ void t4_free_sge_resources(struct adapter *adap)
3014 } 3026 }
3015 } 3027 }
3016 3028
3017 /* clean up RDMA and iSCSI Rx queues */
3018 t4_free_ofld_rxqs(adap, adap->sge.iscsiqsets, adap->sge.iscsirxq);
3019 t4_free_ofld_rxqs(adap, adap->sge.niscsitq, adap->sge.iscsitrxq);
3020 t4_free_ofld_rxqs(adap, adap->sge.rdmaqs, adap->sge.rdmarxq);
3021 t4_free_ofld_rxqs(adap, adap->sge.rdmaciqs, adap->sge.rdmaciq);
3022
3023 /* clean up offload Tx queues */ 3029 /* clean up offload Tx queues */
3024 for (i = 0; i < ARRAY_SIZE(adap->sge.ofldtxq); i++) { 3030 for (i = 0; i < ARRAY_SIZE(adap->sge.ofldtxq); i++) {
3025 struct sge_ofld_txq *q = &adap->sge.ofldtxq[i]; 3031 struct sge_ofld_txq *q = &adap->sge.ofldtxq[i];
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index e4ba2d2616cd..7c0d7af0d3b7 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -84,6 +84,9 @@ static inline int send_tx_flowc_wr(struct cxgbi_sock *);
84 84
85static const struct cxgb4_uld_info cxgb4i_uld_info = { 85static const struct cxgb4_uld_info cxgb4i_uld_info = {
86 .name = DRV_MODULE_NAME, 86 .name = DRV_MODULE_NAME,
87 .nrxq = MAX_ULD_QSETS,
88 .rxq_size = 1024,
89 .lro = false,
87 .add = t4_uld_add, 90 .add = t4_uld_add,
88 .rx_handler = t4_uld_rx_handler, 91 .rx_handler = t4_uld_rx_handler,
89 .state_change = t4_uld_state_change, 92 .state_change = t4_uld_state_change,
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_main.c b/drivers/target/iscsi/cxgbit/cxgbit_main.c
index 27dd11aff934..ad26b9372f10 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_main.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_main.c
@@ -652,6 +652,9 @@ static struct iscsit_transport cxgbit_transport = {
652 652
653static struct cxgb4_uld_info cxgbit_uld_info = { 653static struct cxgb4_uld_info cxgbit_uld_info = {
654 .name = DRV_NAME, 654 .name = DRV_NAME,
655 .nrxq = MAX_ULD_QSETS,
656 .rxq_size = 1024,
657 .lro = true,
655 .add = cxgbit_uld_add, 658 .add = cxgbit_uld_add,
656 .state_change = cxgbit_uld_state_change, 659 .state_change = cxgbit_uld_state_change,
657 .lro_rx_handler = cxgbit_uld_lro_rx_handler, 660 .lro_rx_handler = cxgbit_uld_lro_rx_handler,