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()
247 * csio_hw_init_workers - Initialize the HW module's worker threads.
248 * @hw: HW module.
252 csio_hw_init_workers(struct csio_hw *hw) in csio_hw_init_workers() argument
254 INIT_WORK(&hw->evtq_work, csio_evtq_worker); in csio_hw_init_workers()
258 csio_hw_exit_workers(struct csio_hw *hw) in csio_hw_exit_workers() argument
260 cancel_work_sync(&hw->evtq_work); in csio_hw_exit_workers()
265 csio_create_queues(struct csio_hw *hw) in csio_create_queues() argument
268 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_create_queues()
272 if (hw->flags & CSIO_HWF_Q_FW_ALLOCED) in csio_create_queues()
275 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_create_queues()
276 rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx, in csio_create_queues()
277 0, hw->pport[0].portid, false, NULL); in csio_create_queues()
279 csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv); in csio_create_queues()
285 rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx, in csio_create_queues()
286 csio_get_fwevt_intr_idx(hw), in csio_create_queues()
287 hw->pport[0].portid, true, NULL); in csio_create_queues()
289 csio_err(hw, "FW event IQ config failed!: %d\n", rv); in csio_create_queues()
294 rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx, in csio_create_queues()
295 mgmtm->iq_idx, hw->pport[0].portid, NULL); in csio_create_queues()
298 csio_err(hw, "Mgmt EQ create failed!: %d\n", rv); in csio_create_queues()
303 for (i = 0; i < hw->num_pports; i++) { in csio_create_queues()
304 info = &hw->scsi_cpu_info[i]; in csio_create_queues()
307 struct csio_scsi_qset *sqset = &hw->sqset[i][j]; in csio_create_queues()
309 rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx, in csio_create_queues()
312 csio_err(hw, in csio_create_queues()
317 rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx, in csio_create_queues()
320 csio_err(hw, in csio_create_queues()
328 hw->flags |= CSIO_HWF_Q_FW_ALLOCED; in csio_create_queues()
331 csio_wr_destroy_queues(hw, true); in csio_create_queues()
337 * @hw: HW module.
342 csio_config_queues(struct csio_hw *hw) in csio_config_queues() argument
347 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_config_queues()
351 if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED) in csio_config_queues()
352 return csio_create_queues(hw); in csio_config_queues()
355 hw->num_scsi_msix_cpus = num_online_cpus(); in csio_config_queues()
356 hw->num_sqsets = num_online_cpus() * hw->num_pports; in csio_config_queues()
358 if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) { in csio_config_queues()
359 hw->num_sqsets = CSIO_MAX_SCSI_QSETS; in csio_config_queues()
360 hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU; in csio_config_queues()
364 for (i = 0; i < hw->num_pports; i++) in csio_config_queues()
365 hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus; in csio_config_queues()
367 csio_dbg(hw, "nsqsets:%d scpus:%d\n", in csio_config_queues()
368 hw->num_sqsets, hw->num_scsi_msix_cpus); in csio_config_queues()
370 csio_intr_enable(hw); in csio_config_queues()
372 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_config_queues()
375 hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE, in csio_config_queues()
377 (void *)hw, 0, 0, NULL); in csio_config_queues()
378 if (hw->intr_iq_idx == -1) { in csio_config_queues()
379 csio_err(hw, in csio_config_queues()
386 hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE, in csio_config_queues()
388 CSIO_INGRESS, (void *)hw, in csio_config_queues()
391 if (hw->fwevt_iq_idx == -1) { in csio_config_queues()
392 csio_err(hw, "FW evt queue creation failed\n"); in csio_config_queues()
397 mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE, in csio_config_queues()
399 CSIO_EGRESS, (void *)hw, 0, 0, NULL); in csio_config_queues()
401 csio_err(hw, "Failed to alloc egress queue for mgmt module\n"); in csio_config_queues()
406 mgmtm->iq_idx = hw->fwevt_iq_idx; in csio_config_queues()
409 for (i = 0; i < hw->num_pports; i++) { in csio_config_queues()
410 info = &hw->scsi_cpu_info[i]; in csio_config_queues()
412 for (j = 0; j < hw->num_scsi_msix_cpus; j++) { in csio_config_queues()
413 sqset = &hw->sqset[i][j]; in csio_config_queues()
417 orig = &hw->sqset[i][k]; in csio_config_queues()
423 idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0, in csio_config_queues()
424 CSIO_EGRESS, (void *)hw, 0, 0, in csio_config_queues()
427 csio_err(hw, "EQ creation failed for idx:%d\n", in csio_config_queues()
434 idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE, in csio_config_queues()
436 (void *)hw, 0, 0, in csio_config_queues()
439 csio_err(hw, "IQ creation failed for idx:%d\n", in csio_config_queues()
447 hw->flags |= CSIO_HWF_Q_MEM_ALLOCED; in csio_config_queues()
449 rv = csio_create_queues(hw); in csio_config_queues()
457 rv = csio_request_irqs(hw); in csio_config_queues()
464 csio_intr_disable(hw, false); in csio_config_queues()
470 csio_resource_alloc(struct csio_hw *hw) in csio_resource_alloc() argument
472 struct csio_wrm *wrm = csio_hw_to_wrm(hw); in csio_resource_alloc()
478 hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
480 if (!hw->mb_mempool) in csio_resource_alloc()
483 hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
485 if (!hw->rnode_mempool) in csio_resource_alloc()
488 hw->scsi_dma_pool = dma_pool_create("csio_scsi_dma_pool", in csio_resource_alloc()
489 &hw->pdev->dev, CSIO_SCSI_RSP_LEN, in csio_resource_alloc()
491 if (!hw->scsi_dma_pool) in csio_resource_alloc()
497 mempool_destroy(hw->rnode_mempool); in csio_resource_alloc()
498 hw->rnode_mempool = NULL; in csio_resource_alloc()
500 mempool_destroy(hw->mb_mempool); in csio_resource_alloc()
501 hw->mb_mempool = NULL; in csio_resource_alloc()
507 csio_resource_free(struct csio_hw *hw) in csio_resource_free() argument
509 dma_pool_destroy(hw->scsi_dma_pool); in csio_resource_free()
510 hw->scsi_dma_pool = NULL; in csio_resource_free()
511 mempool_destroy(hw->rnode_mempool); in csio_resource_free()
512 hw->rnode_mempool = NULL; in csio_resource_free()
513 mempool_destroy(hw->mb_mempool); in csio_resource_free()
514 hw->mb_mempool = NULL; in csio_resource_free()
518 * csio_hw_alloc - Allocate and initialize the HW module.
521 * Allocates HW structure, DMA, memory resources, maps BARS to
522 * host memory and initializes HW module.
526 struct csio_hw *hw; in csio_hw_alloc() local
528 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL); in csio_hw_alloc()
529 if (!hw) in csio_hw_alloc()
532 hw->pdev = pdev; in csio_hw_alloc()
533 strncpy(hw->drv_version, CSIO_DRV_VERSION, 32); in csio_hw_alloc()
536 if (csio_resource_alloc(hw)) in csio_hw_alloc()
540 hw->regstart = ioremap_nocache(pci_resource_start(pdev, 0), in csio_hw_alloc()
542 if (!hw->regstart) { in csio_hw_alloc()
543 csio_err(hw, "Could not map BAR 0, regstart = %p\n", in csio_hw_alloc()
544 hw->regstart); in csio_hw_alloc()
548 csio_hw_init_workers(hw); in csio_hw_alloc()
550 if (csio_hw_init(hw)) in csio_hw_alloc()
553 csio_dfs_create(hw); in csio_hw_alloc()
555 csio_dbg(hw, "hw:%p\n", hw); in csio_hw_alloc()
557 return hw; in csio_hw_alloc()
560 csio_hw_exit_workers(hw); in csio_hw_alloc()
561 iounmap(hw->regstart); in csio_hw_alloc()
563 csio_resource_free(hw); in csio_hw_alloc()
565 kfree(hw); in csio_hw_alloc()
571 * csio_hw_free - Uninitialize and free the HW module.
572 * @hw: The HW module
574 * Disable interrupts, uninit the HW module, free resources, free hw.
577 csio_hw_free(struct csio_hw *hw) in csio_hw_free() argument
579 csio_intr_disable(hw, true); in csio_hw_free()
580 csio_hw_exit_workers(hw); in csio_hw_free()
581 csio_hw_exit(hw); in csio_hw_free()
582 iounmap(hw->regstart); in csio_hw_free()
583 csio_dfs_destroy(hw); in csio_hw_free()
584 csio_resource_free(hw); in csio_hw_free()
585 kfree(hw); in csio_hw_free()
590 * @hw: The HW module.
601 csio_shost_init(struct csio_hw *hw, struct device *dev, in csio_shost_init() argument
611 * hw->pdev is the physical port's PCI dev structure, in csio_shost_init()
614 if (dev == &hw->pdev->dev) in csio_shost_init()
637 hw->fres_info.max_ssns); in csio_shost_init()
639 if (dev == &hw->pdev->dev) in csio_shost_init()
645 if (!hw->rln) in csio_shost_init()
646 hw->rln = ln; in csio_shost_init()
649 if (csio_lnode_init(ln, hw, pln)) in csio_shost_init()
652 if (scsi_add_host_with_dma(shost, dev, &hw->pdev->dev)) in csio_shost_init()
674 struct csio_hw *hw = csio_lnode_to_hw(ln); in csio_shost_exit() local
685 spin_lock_irq(&hw->lock); in csio_shost_exit()
686 csio_evtq_flush(hw); in csio_shost_exit()
687 spin_unlock_irq(&hw->lock); in csio_shost_exit()
694 csio_lnode_alloc(struct csio_hw *hw) in csio_lnode_alloc() argument
696 return csio_shost_init(hw, &hw->pdev->dev, false, NULL); in csio_lnode_alloc()
700 csio_lnodes_block_request(struct csio_hw *hw) in csio_lnodes_block_request() argument
709 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_request()
712 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_request()
716 spin_lock_irq(&hw->lock); in csio_lnodes_block_request()
718 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_request()
726 spin_unlock_irq(&hw->lock); in csio_lnodes_block_request()
729 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_request()
739 csio_lnodes_unblock_request(struct csio_hw *hw) in csio_lnodes_unblock_request() argument
748 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_request()
751 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_request()
755 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_request()
757 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_request()
765 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_request()
768 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_request()
777 csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_block_by_port() argument
786 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_by_port()
789 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_by_port()
793 spin_lock_irq(&hw->lock); in csio_lnodes_block_by_port()
795 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_by_port()
806 spin_unlock_irq(&hw->lock); in csio_lnodes_block_by_port()
809 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_by_port()
818 csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_unblock_by_port() argument
827 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_by_port()
830 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_by_port()
834 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
836 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_by_port()
846 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
849 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_by_port()
858 csio_lnodes_exit(struct csio_hw *hw, bool npiv) in csio_lnodes_exit() argument
866 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_exit()
869 csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n"); in csio_lnodes_exit()
874 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
875 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
882 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
886 csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
897 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
899 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
903 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
907 csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
916 * csio_lnode_init_post: Set lnode attributes after starting HW.
938 * - Allocates HW structure, DMA, memory resources, maps BARS to
939 * host memory and initializes HW module.
944 * HW state machine.
953 struct csio_hw *hw; in csio_probe_one() local
965 hw = csio_hw_alloc(pdev); in csio_probe_one()
966 if (!hw) { in csio_probe_one()
972 hw->flags |= CSIO_HWF_ROOT_NO_RELAXED_ORDERING; in csio_probe_one()
974 pci_set_drvdata(pdev, hw); in csio_probe_one()
976 rv = csio_hw_start(hw); in csio_probe_one()
986 sprintf(hw->fwrev_str, "%u.%u.%u.%u\n", in csio_probe_one()
987 FW_HDR_FW_VER_MAJOR_G(hw->fwrev), in csio_probe_one()
988 FW_HDR_FW_VER_MINOR_G(hw->fwrev), in csio_probe_one()
989 FW_HDR_FW_VER_MICRO_G(hw->fwrev), in csio_probe_one()
990 FW_HDR_FW_VER_BUILD_G(hw->fwrev)); in csio_probe_one()
992 for (i = 0; i < hw->num_pports; i++) { in csio_probe_one()
993 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_probe_one()
999 ln->portid = hw->pport[i].portid; in csio_probe_one()
1001 spin_lock_irq(&hw->lock); in csio_probe_one()
1004 spin_unlock_irq(&hw->lock); in csio_probe_one()
1018 csio_lnodes_block_request(hw); in csio_probe_one()
1019 spin_lock_irq(&hw->lock); in csio_probe_one()
1020 csio_hw_stop(hw); in csio_probe_one()
1021 spin_unlock_irq(&hw->lock); in csio_probe_one()
1022 csio_lnodes_unblock_request(hw); in csio_probe_one()
1023 csio_lnodes_exit(hw, 0); in csio_probe_one()
1024 csio_hw_free(hw); in csio_probe_one()
1040 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_remove_one() local
1043 csio_lnodes_block_request(hw); in csio_remove_one()
1044 spin_lock_irq(&hw->lock); in csio_remove_one()
1050 csio_hw_stop(hw); in csio_remove_one()
1051 spin_unlock_irq(&hw->lock); in csio_remove_one()
1052 csio_lnodes_unblock_request(hw); in csio_remove_one()
1054 csio_lnodes_exit(hw, 0); in csio_remove_one()
1055 csio_hw_free(hw); in csio_remove_one()
1067 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_error_detected() local
1069 csio_lnodes_block_request(hw); in csio_pci_error_detected()
1070 spin_lock_irq(&hw->lock); in csio_pci_error_detected()
1072 /* Post PCI error detected evt to HW s/m in csio_pci_error_detected()
1073 * HW s/m handles this evt by quiescing IOs, unregisters rports in csio_pci_error_detected()
1076 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED); in csio_pci_error_detected()
1077 spin_unlock_irq(&hw->lock); in csio_pci_error_detected()
1078 csio_lnodes_unblock_request(hw); in csio_pci_error_detected()
1079 csio_lnodes_exit(hw, 0); in csio_pci_error_detected()
1080 csio_intr_disable(hw, true); in csio_pci_error_detected()
1094 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_slot_reset() local
1107 /* Bring HW s/m to ready state. in csio_pci_slot_reset()
1110 spin_lock_irq(&hw->lock); in csio_pci_slot_reset()
1111 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_SLOT_RESET); in csio_pci_slot_reset()
1112 ready = csio_is_hw_ready(hw); in csio_pci_slot_reset()
1113 spin_unlock_irq(&hw->lock); in csio_pci_slot_reset()
1118 dev_err(&pdev->dev, "Can't initialize HW when in slot reset\n"); in csio_pci_slot_reset()
1131 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_resume() local
1138 for (i = 0; i < hw->num_pports; i++) { in csio_pci_resume()
1139 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_pci_resume()
1145 ln->portid = hw->pport[i].portid; in csio_pci_resume()
1147 spin_lock_irq(&hw->lock); in csio_pci_resume()
1150 spin_unlock_irq(&hw->lock); in csio_pci_resume()
1164 csio_lnodes_block_request(hw); in csio_pci_resume()
1165 spin_lock_irq(&hw->lock); in csio_pci_resume()
1166 csio_hw_stop(hw); in csio_pci_resume()
1167 spin_unlock_irq(&hw->lock); in csio_pci_resume()
1168 csio_lnodes_unblock_request(hw); in csio_pci_resume()
1169 csio_lnodes_exit(hw, 0); in csio_pci_resume()
1170 csio_hw_free(hw); in csio_pci_resume()