Lines Matching refs:hw
68 struct csio_hw *hw = file->private_data - mem;
83 ret = hw->chip_ops->chip_mc_read(hw, 0, pos,
86 ret = hw->chip_ops->chip_edc_read(hw, mem, pos,
112 void csio_add_debugfs_mem(struct csio_hw *hw, const char *name,
115 debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root,
116 (void *)hw + idx, &csio_mem_debugfs_fops,
120 static int csio_setup_debugfs(struct csio_hw *hw)
124 if (IS_ERR_OR_NULL(hw->debugfs_root))
127 i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE_A);
129 csio_add_debugfs_mem(hw, "edc0", MEM_EDC0, 5);
131 csio_add_debugfs_mem(hw, "edc1", MEM_EDC1, 5);
133 hw->chip_ops->chip_dfs_create_ext_mem(hw);
138 * csio_dfs_create - Creates and sets up per-hw debugfs.
142 csio_dfs_create(struct csio_hw *hw)
145 hw->debugfs_root = debugfs_create_dir(pci_name(hw->pdev),
147 csio_setup_debugfs(hw);
154 * csio_dfs_destroy - Destroys per-hw debugfs.
157 csio_dfs_destroy(struct csio_hw *hw)
159 debugfs_remove_recursive(hw->debugfs_root);
240 * @hw: HW module.
244 csio_hw_init_workers(struct csio_hw *hw)
246 INIT_WORK(&hw->evtq_work, csio_evtq_worker);
250 csio_hw_exit_workers(struct csio_hw *hw)
252 cancel_work_sync(&hw->evtq_work);
256 csio_create_queues(struct csio_hw *hw)
259 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw);
263 if (hw->flags & CSIO_HWF_Q_FW_ALLOCED)
266 if (hw->intr_mode != CSIO_IM_MSIX) {
267 rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx,
268 0, hw->pport[0].portid, false, NULL);
270 csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv);
276 rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx,
277 csio_get_fwevt_intr_idx(hw),
278 hw->pport[0].portid, true, NULL);
280 csio_err(hw, "FW event IQ config failed!: %d\n", rv);
285 rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx,
286 mgmtm->iq_idx, hw->pport[0].portid, NULL);
289 csio_err(hw, "Mgmt EQ create failed!: %d\n", rv);
294 for (i = 0; i < hw->num_pports; i++) {
295 info = &hw->scsi_cpu_info[i];
298 struct csio_scsi_qset *sqset = &hw->sqset[i][j];
300 rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx,
303 csio_err(hw,
308 rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx,
311 csio_err(hw,
319 hw->flags |= CSIO_HWF_Q_FW_ALLOCED;
322 csio_wr_destroy_queues(hw, true);
328 * @hw: HW module.
333 csio_config_queues(struct csio_hw *hw)
338 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw);
342 if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED)
343 return csio_create_queues(hw);
346 hw->num_scsi_msix_cpus = num_online_cpus();
347 hw->num_sqsets = num_online_cpus() * hw->num_pports;
349 if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) {
350 hw->num_sqsets = CSIO_MAX_SCSI_QSETS;
351 hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU;
355 for (i = 0; i < hw->num_pports; i++)
356 hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus;
358 csio_dbg(hw, "nsqsets:%d scpus:%d\n",
359 hw->num_sqsets, hw->num_scsi_msix_cpus);
361 csio_intr_enable(hw);
363 if (hw->intr_mode != CSIO_IM_MSIX) {
366 hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE,
368 (void *)hw, 0, 0, NULL);
369 if (hw->intr_iq_idx == -1) {
370 csio_err(hw,
377 hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE,
379 CSIO_INGRESS, (void *)hw,
382 if (hw->fwevt_iq_idx == -1) {
383 csio_err(hw, "FW evt queue creation failed\n");
388 mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE,
390 CSIO_EGRESS, (void *)hw, 0, 0, NULL);
392 csio_err(hw, "Failed to alloc egress queue for mgmt module\n");
397 mgmtm->iq_idx = hw->fwevt_iq_idx;
400 for (i = 0; i < hw->num_pports; i++) {
401 info = &hw->scsi_cpu_info[i];
403 for (j = 0; j < hw->num_scsi_msix_cpus; j++) {
404 sqset = &hw->sqset[i][j];
408 orig = &hw->sqset[i][k];
414 idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0,
415 CSIO_EGRESS, (void *)hw, 0, 0,
418 csio_err(hw, "EQ creation failed for idx:%d\n",
425 idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE,
427 (void *)hw, 0, 0,
430 csio_err(hw, "IQ creation failed for idx:%d\n",
438 hw->flags |= CSIO_HWF_Q_MEM_ALLOCED;
440 rv = csio_create_queues(hw);
448 rv = csio_request_irqs(hw);
455 csio_intr_disable(hw, false);
461 csio_resource_alloc(struct csio_hw *hw)
463 struct csio_wrm *wrm = csio_hw_to_wrm(hw);
469 hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ,
471 if (!hw->mb_mempool)
474 hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ,
476 if (!hw->rnode_mempool)
479 hw->scsi_dma_pool = dma_pool_create("csio_scsi_dma_pool",
480 &hw->pdev->dev, CSIO_SCSI_RSP_LEN,
482 if (!hw->scsi_dma_pool)
488 mempool_destroy(hw->rnode_mempool);
489 hw->rnode_mempool = NULL;
491 mempool_destroy(hw->mb_mempool);
492 hw->mb_mempool = NULL;
498 csio_resource_free(struct csio_hw *hw)
500 dma_pool_destroy(hw->scsi_dma_pool);
501 hw->scsi_dma_pool = NULL;
502 mempool_destroy(hw->rnode_mempool);
503 hw->rnode_mempool = NULL;
504 mempool_destroy(hw->mb_mempool);
505 hw->mb_mempool = NULL;
517 struct csio_hw *hw;
519 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL);
520 if (!hw)
523 hw->pdev = pdev;
524 strncpy(hw->drv_version, CSIO_DRV_VERSION, 32);
527 if (csio_resource_alloc(hw))
531 hw->regstart = ioremap(pci_resource_start(pdev, 0),
533 if (!hw->regstart) {
534 csio_err(hw, "Could not map BAR 0, regstart = %p\n",
535 hw->regstart);
539 csio_hw_init_workers(hw);
541 if (csio_hw_init(hw))
544 csio_dfs_create(hw);
546 csio_dbg(hw, "hw:%p\n", hw);
548 return hw;
551 csio_hw_exit_workers(hw);
552 iounmap(hw->regstart);
554 csio_resource_free(hw);
556 kfree(hw);
563 * @hw: The HW module
565 * Disable interrupts, uninit the HW module, free resources, free hw.
568 csio_hw_free(struct csio_hw *hw)
570 csio_intr_disable(hw, true);
571 csio_hw_exit_workers(hw);
572 csio_hw_exit(hw);
573 iounmap(hw->regstart);
574 csio_dfs_destroy(hw);
575 csio_resource_free(hw);
576 kfree(hw);
581 * @hw: The HW module.
592 csio_shost_init(struct csio_hw *hw, struct device *dev,
602 * hw->pdev is the physical port's PCI dev structure,
605 if (dev == &hw->pdev->dev)
628 hw->fres_info.max_ssns);
630 if (dev == &hw->pdev->dev)
636 if (!hw->rln)
637 hw->rln = ln;
640 if (csio_lnode_init(ln, hw, pln))
643 if (scsi_add_host_with_dma(shost, dev, &hw->pdev->dev))
665 struct csio_hw *hw = csio_lnode_to_hw(ln);
676 spin_lock_irq(&hw->lock);
677 csio_evtq_flush(hw);
678 spin_unlock_irq(&hw->lock);
685 csio_lnode_alloc(struct csio_hw *hw)
687 return csio_shost_init(hw, &hw->pdev->dev, false, NULL);
691 csio_lnodes_block_request(struct csio_hw *hw)
700 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
703 csio_err(hw, "Failed to allocate lnodes_list");
707 spin_lock_irq(&hw->lock);
709 list_for_each(cur_ln, &hw->sln_head) {
717 spin_unlock_irq(&hw->lock);
720 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]);
730 csio_lnodes_unblock_request(struct csio_hw *hw)
739 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
742 csio_err(hw, "Failed to allocate lnodes_list");
746 spin_lock_irq(&hw->lock);
748 list_for_each(cur_ln, &hw->sln_head) {
756 spin_unlock_irq(&hw->lock);
759 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]);
768 csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid)
777 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
780 csio_err(hw, "Failed to allocate lnodes_list");
784 spin_lock_irq(&hw->lock);
786 list_for_each(cur_ln, &hw->sln_head) {
797 spin_unlock_irq(&hw->lock);
800 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]);
809 csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid)
818 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
821 csio_err(hw, "Failed to allocate lnodes_list");
825 spin_lock_irq(&hw->lock);
827 list_for_each(cur_ln, &hw->sln_head) {
837 spin_unlock_irq(&hw->lock);
840 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]);
849 csio_lnodes_exit(struct csio_hw *hw, bool npiv)
857 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
860 csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n");
865 spin_lock_irq(&hw->lock);
866 list_for_each(cur_ln, &hw->sln_head) {
873 spin_unlock_irq(&hw->lock);
877 csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]);
888 spin_lock_irq(&hw->lock);
890 list_for_each(cur_ln, &hw->sln_head) {
894 spin_unlock_irq(&hw->lock);
898 csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]);
944 struct csio_hw *hw;
956 hw = csio_hw_alloc(pdev);
957 if (!hw) {
963 hw->flags |= CSIO_HWF_ROOT_NO_RELAXED_ORDERING;
965 pci_set_drvdata(pdev, hw);
967 rv = csio_hw_start(hw);
977 sprintf(hw->fwrev_str, "%u.%u.%u.%u\n",
978 FW_HDR_FW_VER_MAJOR_G(hw->fwrev),
979 FW_HDR_FW_VER_MINOR_G(hw->fwrev),
980 FW_HDR_FW_VER_MICRO_G(hw->fwrev),
981 FW_HDR_FW_VER_BUILD_G(hw->fwrev));
983 for (i = 0; i < hw->num_pports; i++) {
984 ln = csio_shost_init(hw, &pdev->dev, true, NULL);
990 ln->portid = hw->pport[i].portid;
992 spin_lock_irq(&hw->lock);
995 spin_unlock_irq(&hw->lock);
1009 csio_lnodes_block_request(hw);
1010 spin_lock_irq(&hw->lock);
1011 csio_hw_stop(hw);
1012 spin_unlock_irq(&hw->lock);
1013 csio_lnodes_unblock_request(hw);
1014 csio_lnodes_exit(hw, 0);
1015 csio_hw_free(hw);
1031 struct csio_hw *hw = pci_get_drvdata(pdev);
1034 csio_lnodes_block_request(hw);
1035 spin_lock_irq(&hw->lock);
1041 csio_hw_stop(hw);
1042 spin_unlock_irq(&hw->lock);
1043 csio_lnodes_unblock_request(hw);
1045 csio_lnodes_exit(hw, 0);
1046 csio_hw_free(hw);
1058 struct csio_hw *hw = pci_get_drvdata(pdev);
1060 csio_lnodes_block_request(hw);
1061 spin_lock_irq(&hw->lock);
1067 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED);
1068 spin_unlock_irq(&hw->lock);
1069 csio_lnodes_unblock_request(hw);
1070 csio_lnodes_exit(hw, 0);
1071 csio_intr_disable(hw, true);
1085 struct csio_hw *hw = pci_get_drvdata(pdev);
1100 spin_lock_irq(&hw->lock);
1101 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_SLOT_RESET);
1102 ready = csio_is_hw_ready(hw);
1103 spin_unlock_irq(&hw->lock);
1121 struct csio_hw *hw = pci_get_drvdata(pdev);
1128 for (i = 0; i < hw->num_pports; i++) {
1129 ln = csio_shost_init(hw, &pdev->dev, true, NULL);
1135 ln->portid = hw->pport[i].portid;
1137 spin_lock_irq(&hw->lock);
1140 spin_unlock_irq(&hw->lock);
1154 csio_lnodes_block_request(hw);
1155 spin_lock_irq(&hw->lock);
1156 csio_hw_stop(hw);
1157 spin_unlock_irq(&hw->lock);
1158 csio_lnodes_unblock_request(hw);
1159 csio_lnodes_exit(hw, 0);
1160 csio_hw_free(hw);