Lines Matching full:hw
69 struct csio_hw *hw = file->private_data - mem; in csio_mem_read() local
84 ret = hw->chip_ops->chip_mc_read(hw, 0, pos, in csio_mem_read()
87 ret = hw->chip_ops->chip_edc_read(hw, mem, pos, in csio_mem_read()
113 void csio_add_debugfs_mem(struct csio_hw *hw, const char *name, in csio_add_debugfs_mem() argument
116 debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root, in csio_add_debugfs_mem()
117 (void *)hw + idx, &csio_mem_debugfs_fops, in csio_add_debugfs_mem()
121 static int csio_setup_debugfs(struct csio_hw *hw) in csio_setup_debugfs() argument
125 if (IS_ERR_OR_NULL(hw->debugfs_root)) in csio_setup_debugfs()
128 i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE_A); in csio_setup_debugfs()
130 csio_add_debugfs_mem(hw, "edc0", MEM_EDC0, 5); in csio_setup_debugfs()
132 csio_add_debugfs_mem(hw, "edc1", MEM_EDC1, 5); in csio_setup_debugfs()
134 hw->chip_ops->chip_dfs_create_ext_mem(hw); in csio_setup_debugfs()
139 * csio_dfs_create - Creates and sets up per-hw debugfs.
143 csio_dfs_create(struct csio_hw *hw) in csio_dfs_create() argument
146 hw->debugfs_root = debugfs_create_dir(pci_name(hw->pdev), in csio_dfs_create()
148 csio_setup_debugfs(hw); in csio_dfs_create()
155 * csio_dfs_destroy - Destroys per-hw debugfs.
158 csio_dfs_destroy(struct csio_hw *hw) in csio_dfs_destroy() argument
160 if (hw->debugfs_root) in csio_dfs_destroy()
161 debugfs_remove_recursive(hw->debugfs_root); in csio_dfs_destroy()
243 * csio_hw_init_workers - Initialize the HW module's worker threads.
244 * @hw: HW module.
248 csio_hw_init_workers(struct csio_hw *hw) in csio_hw_init_workers() argument
250 INIT_WORK(&hw->evtq_work, csio_evtq_worker); in csio_hw_init_workers()
254 csio_hw_exit_workers(struct csio_hw *hw) in csio_hw_exit_workers() argument
256 cancel_work_sync(&hw->evtq_work); in csio_hw_exit_workers()
260 csio_create_queues(struct csio_hw *hw) in csio_create_queues() argument
263 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_create_queues()
267 if (hw->flags & CSIO_HWF_Q_FW_ALLOCED) in csio_create_queues()
270 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_create_queues()
271 rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx, in csio_create_queues()
272 0, hw->pport[0].portid, false, NULL); in csio_create_queues()
274 csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv); in csio_create_queues()
280 rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx, in csio_create_queues()
281 csio_get_fwevt_intr_idx(hw), in csio_create_queues()
282 hw->pport[0].portid, true, NULL); in csio_create_queues()
284 csio_err(hw, "FW event IQ config failed!: %d\n", rv); in csio_create_queues()
289 rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx, in csio_create_queues()
290 mgmtm->iq_idx, hw->pport[0].portid, NULL); in csio_create_queues()
293 csio_err(hw, "Mgmt EQ create failed!: %d\n", rv); in csio_create_queues()
298 for (i = 0; i < hw->num_pports; i++) { in csio_create_queues()
299 info = &hw->scsi_cpu_info[i]; in csio_create_queues()
302 struct csio_scsi_qset *sqset = &hw->sqset[i][j]; in csio_create_queues()
304 rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx, in csio_create_queues()
307 csio_err(hw, in csio_create_queues()
312 rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx, in csio_create_queues()
315 csio_err(hw, in csio_create_queues()
323 hw->flags |= CSIO_HWF_Q_FW_ALLOCED; in csio_create_queues()
326 csio_wr_destroy_queues(hw, true); in csio_create_queues()
332 * @hw: HW module.
337 csio_config_queues(struct csio_hw *hw) in csio_config_queues() argument
342 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_config_queues()
346 if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED) in csio_config_queues()
347 return csio_create_queues(hw); in csio_config_queues()
350 hw->num_scsi_msix_cpus = num_online_cpus(); in csio_config_queues()
351 hw->num_sqsets = num_online_cpus() * hw->num_pports; in csio_config_queues()
353 if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) { in csio_config_queues()
354 hw->num_sqsets = CSIO_MAX_SCSI_QSETS; in csio_config_queues()
355 hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU; in csio_config_queues()
359 for (i = 0; i < hw->num_pports; i++) in csio_config_queues()
360 hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus; in csio_config_queues()
362 csio_dbg(hw, "nsqsets:%d scpus:%d\n", in csio_config_queues()
363 hw->num_sqsets, hw->num_scsi_msix_cpus); in csio_config_queues()
365 csio_intr_enable(hw); in csio_config_queues()
367 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_config_queues()
370 hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE, in csio_config_queues()
372 (void *)hw, 0, 0, NULL); in csio_config_queues()
373 if (hw->intr_iq_idx == -1) { in csio_config_queues()
374 csio_err(hw, in csio_config_queues()
381 hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE, in csio_config_queues()
383 CSIO_INGRESS, (void *)hw, in csio_config_queues()
386 if (hw->fwevt_iq_idx == -1) { in csio_config_queues()
387 csio_err(hw, "FW evt queue creation failed\n"); in csio_config_queues()
392 mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE, in csio_config_queues()
394 CSIO_EGRESS, (void *)hw, 0, 0, NULL); in csio_config_queues()
396 csio_err(hw, "Failed to alloc egress queue for mgmt module\n"); in csio_config_queues()
401 mgmtm->iq_idx = hw->fwevt_iq_idx; in csio_config_queues()
404 for (i = 0; i < hw->num_pports; i++) { in csio_config_queues()
405 info = &hw->scsi_cpu_info[i]; in csio_config_queues()
407 for (j = 0; j < hw->num_scsi_msix_cpus; j++) { in csio_config_queues()
408 sqset = &hw->sqset[i][j]; in csio_config_queues()
412 orig = &hw->sqset[i][k]; in csio_config_queues()
418 idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0, in csio_config_queues()
419 CSIO_EGRESS, (void *)hw, 0, 0, in csio_config_queues()
422 csio_err(hw, "EQ creation failed for idx:%d\n", in csio_config_queues()
429 idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE, in csio_config_queues()
431 (void *)hw, 0, 0, in csio_config_queues()
434 csio_err(hw, "IQ creation failed for idx:%d\n", in csio_config_queues()
442 hw->flags |= CSIO_HWF_Q_MEM_ALLOCED; in csio_config_queues()
444 rv = csio_create_queues(hw); in csio_config_queues()
452 rv = csio_request_irqs(hw); in csio_config_queues()
459 csio_intr_disable(hw, false); in csio_config_queues()
465 csio_resource_alloc(struct csio_hw *hw) in csio_resource_alloc() argument
467 struct csio_wrm *wrm = csio_hw_to_wrm(hw); in csio_resource_alloc()
473 hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
475 if (!hw->mb_mempool) in csio_resource_alloc()
478 hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
480 if (!hw->rnode_mempool) in csio_resource_alloc()
483 hw->scsi_dma_pool = dma_pool_create("csio_scsi_dma_pool", in csio_resource_alloc()
484 &hw->pdev->dev, CSIO_SCSI_RSP_LEN, in csio_resource_alloc()
486 if (!hw->scsi_dma_pool) in csio_resource_alloc()
492 mempool_destroy(hw->rnode_mempool); in csio_resource_alloc()
493 hw->rnode_mempool = NULL; in csio_resource_alloc()
495 mempool_destroy(hw->mb_mempool); in csio_resource_alloc()
496 hw->mb_mempool = NULL; in csio_resource_alloc()
502 csio_resource_free(struct csio_hw *hw) in csio_resource_free() argument
504 dma_pool_destroy(hw->scsi_dma_pool); in csio_resource_free()
505 hw->scsi_dma_pool = NULL; in csio_resource_free()
506 mempool_destroy(hw->rnode_mempool); in csio_resource_free()
507 hw->rnode_mempool = NULL; in csio_resource_free()
508 mempool_destroy(hw->mb_mempool); in csio_resource_free()
509 hw->mb_mempool = NULL; in csio_resource_free()
513 * csio_hw_alloc - Allocate and initialize the HW module.
516 * Allocates HW structure, DMA, memory resources, maps BARS to
517 * host memory and initializes HW module.
521 struct csio_hw *hw; in csio_hw_alloc() local
523 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL); in csio_hw_alloc()
524 if (!hw) in csio_hw_alloc()
527 hw->pdev = pdev; in csio_hw_alloc()
528 strncpy(hw->drv_version, CSIO_DRV_VERSION, 32); in csio_hw_alloc()
531 if (csio_resource_alloc(hw)) in csio_hw_alloc()
535 hw->regstart = ioremap_nocache(pci_resource_start(pdev, 0), in csio_hw_alloc()
537 if (!hw->regstart) { in csio_hw_alloc()
538 csio_err(hw, "Could not map BAR 0, regstart = %p\n", in csio_hw_alloc()
539 hw->regstart); in csio_hw_alloc()
543 csio_hw_init_workers(hw); in csio_hw_alloc()
545 if (csio_hw_init(hw)) in csio_hw_alloc()
548 csio_dfs_create(hw); in csio_hw_alloc()
550 csio_dbg(hw, "hw:%p\n", hw); in csio_hw_alloc()
552 return hw; in csio_hw_alloc()
555 csio_hw_exit_workers(hw); in csio_hw_alloc()
556 iounmap(hw->regstart); in csio_hw_alloc()
558 csio_resource_free(hw); in csio_hw_alloc()
560 kfree(hw); in csio_hw_alloc()
566 * csio_hw_free - Uninitialize and free the HW module.
567 * @hw: The HW module
569 * Disable interrupts, uninit the HW module, free resources, free hw.
572 csio_hw_free(struct csio_hw *hw) in csio_hw_free() argument
574 csio_intr_disable(hw, true); in csio_hw_free()
575 csio_hw_exit_workers(hw); in csio_hw_free()
576 csio_hw_exit(hw); in csio_hw_free()
577 iounmap(hw->regstart); in csio_hw_free()
578 csio_dfs_destroy(hw); in csio_hw_free()
579 csio_resource_free(hw); in csio_hw_free()
580 kfree(hw); in csio_hw_free()
585 * @hw: The HW module.
596 csio_shost_init(struct csio_hw *hw, struct device *dev, in csio_shost_init() argument
606 * hw->pdev is the physical port's PCI dev structure, in csio_shost_init()
609 if (dev == &hw->pdev->dev) in csio_shost_init()
632 hw->fres_info.max_ssns); in csio_shost_init()
634 if (dev == &hw->pdev->dev) in csio_shost_init()
640 if (!hw->rln) in csio_shost_init()
641 hw->rln = ln; in csio_shost_init()
644 if (csio_lnode_init(ln, hw, pln)) in csio_shost_init()
647 if (scsi_add_host_with_dma(shost, dev, &hw->pdev->dev)) in csio_shost_init()
669 struct csio_hw *hw = csio_lnode_to_hw(ln); in csio_shost_exit() local
680 spin_lock_irq(&hw->lock); in csio_shost_exit()
681 csio_evtq_flush(hw); in csio_shost_exit()
682 spin_unlock_irq(&hw->lock); in csio_shost_exit()
689 csio_lnode_alloc(struct csio_hw *hw) in csio_lnode_alloc() argument
691 return csio_shost_init(hw, &hw->pdev->dev, false, NULL); in csio_lnode_alloc()
695 csio_lnodes_block_request(struct csio_hw *hw) in csio_lnodes_block_request() argument
704 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_request()
707 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_request()
711 spin_lock_irq(&hw->lock); in csio_lnodes_block_request()
713 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_request()
721 spin_unlock_irq(&hw->lock); in csio_lnodes_block_request()
724 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_request()
734 csio_lnodes_unblock_request(struct csio_hw *hw) in csio_lnodes_unblock_request() argument
743 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_request()
746 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_request()
750 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_request()
752 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_request()
760 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_request()
763 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_request()
772 csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_block_by_port() argument
781 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_by_port()
784 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_by_port()
788 spin_lock_irq(&hw->lock); in csio_lnodes_block_by_port()
790 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_by_port()
801 spin_unlock_irq(&hw->lock); in csio_lnodes_block_by_port()
804 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_by_port()
813 csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_unblock_by_port() argument
822 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_by_port()
825 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_by_port()
829 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
831 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_by_port()
841 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
844 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_by_port()
853 csio_lnodes_exit(struct csio_hw *hw, bool npiv) in csio_lnodes_exit() argument
861 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_exit()
864 csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n"); in csio_lnodes_exit()
869 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
870 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
877 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
881 csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
892 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
894 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
898 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
902 csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
911 * csio_lnode_init_post: Set lnode attributes after starting HW.
933 * - Allocates HW structure, DMA, memory resources, maps BARS to
934 * host memory and initializes HW module.
939 * HW state machine.
948 struct csio_hw *hw; in csio_probe_one() local
960 hw = csio_hw_alloc(pdev); in csio_probe_one()
961 if (!hw) { in csio_probe_one()
967 hw->flags |= CSIO_HWF_ROOT_NO_RELAXED_ORDERING; in csio_probe_one()
969 pci_set_drvdata(pdev, hw); in csio_probe_one()
971 rv = csio_hw_start(hw); in csio_probe_one()
981 sprintf(hw->fwrev_str, "%u.%u.%u.%u\n", in csio_probe_one()
982 FW_HDR_FW_VER_MAJOR_G(hw->fwrev), in csio_probe_one()
983 FW_HDR_FW_VER_MINOR_G(hw->fwrev), in csio_probe_one()
984 FW_HDR_FW_VER_MICRO_G(hw->fwrev), in csio_probe_one()
985 FW_HDR_FW_VER_BUILD_G(hw->fwrev)); in csio_probe_one()
987 for (i = 0; i < hw->num_pports; i++) { in csio_probe_one()
988 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_probe_one()
994 ln->portid = hw->pport[i].portid; in csio_probe_one()
996 spin_lock_irq(&hw->lock); in csio_probe_one()
999 spin_unlock_irq(&hw->lock); in csio_probe_one()
1013 csio_lnodes_block_request(hw); in csio_probe_one()
1014 spin_lock_irq(&hw->lock); in csio_probe_one()
1015 csio_hw_stop(hw); in csio_probe_one()
1016 spin_unlock_irq(&hw->lock); in csio_probe_one()
1017 csio_lnodes_unblock_request(hw); in csio_probe_one()
1018 csio_lnodes_exit(hw, 0); in csio_probe_one()
1019 csio_hw_free(hw); in csio_probe_one()
1035 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_remove_one() local
1038 csio_lnodes_block_request(hw); in csio_remove_one()
1039 spin_lock_irq(&hw->lock); in csio_remove_one()
1045 csio_hw_stop(hw); in csio_remove_one()
1046 spin_unlock_irq(&hw->lock); in csio_remove_one()
1047 csio_lnodes_unblock_request(hw); in csio_remove_one()
1049 csio_lnodes_exit(hw, 0); in csio_remove_one()
1050 csio_hw_free(hw); in csio_remove_one()
1062 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_error_detected() local
1064 csio_lnodes_block_request(hw); in csio_pci_error_detected()
1065 spin_lock_irq(&hw->lock); in csio_pci_error_detected()
1067 /* Post PCI error detected evt to HW s/m in csio_pci_error_detected()
1068 * HW s/m handles this evt by quiescing IOs, unregisters rports in csio_pci_error_detected()
1071 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED); in csio_pci_error_detected()
1072 spin_unlock_irq(&hw->lock); in csio_pci_error_detected()
1073 csio_lnodes_unblock_request(hw); in csio_pci_error_detected()
1074 csio_lnodes_exit(hw, 0); in csio_pci_error_detected()
1075 csio_intr_disable(hw, true); in csio_pci_error_detected()
1089 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_slot_reset() local
1101 /* Bring HW s/m to ready state. in csio_pci_slot_reset()
1104 spin_lock_irq(&hw->lock); in csio_pci_slot_reset()
1105 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_SLOT_RESET); in csio_pci_slot_reset()
1106 ready = csio_is_hw_ready(hw); in csio_pci_slot_reset()
1107 spin_unlock_irq(&hw->lock); in csio_pci_slot_reset()
1112 dev_err(&pdev->dev, "Can't initialize HW when in slot reset\n"); in csio_pci_slot_reset()
1125 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_resume() local
1132 for (i = 0; i < hw->num_pports; i++) { in csio_pci_resume()
1133 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_pci_resume()
1139 ln->portid = hw->pport[i].portid; in csio_pci_resume()
1141 spin_lock_irq(&hw->lock); in csio_pci_resume()
1144 spin_unlock_irq(&hw->lock); in csio_pci_resume()
1158 csio_lnodes_block_request(hw); in csio_pci_resume()
1159 spin_lock_irq(&hw->lock); in csio_pci_resume()
1160 csio_hw_stop(hw); in csio_pci_resume()
1161 spin_unlock_irq(&hw->lock); in csio_pci_resume()
1162 csio_lnodes_unblock_request(hw); in csio_pci_resume()
1163 csio_lnodes_exit(hw, 0); in csio_pci_resume()
1164 csio_hw_free(hw); in csio_pci_resume()