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 debugfs_remove_recursive(hw->debugfs_root); in csio_dfs_destroy()
240 * csio_hw_init_workers - Initialize the HW module's worker threads.
241 * @hw: HW module.
245 csio_hw_init_workers(struct csio_hw *hw) in csio_hw_init_workers() argument
247 INIT_WORK(&hw->evtq_work, csio_evtq_worker); in csio_hw_init_workers()
251 csio_hw_exit_workers(struct csio_hw *hw) in csio_hw_exit_workers() argument
253 cancel_work_sync(&hw->evtq_work); in csio_hw_exit_workers()
257 csio_create_queues(struct csio_hw *hw) in csio_create_queues() argument
260 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_create_queues()
264 if (hw->flags & CSIO_HWF_Q_FW_ALLOCED) in csio_create_queues()
267 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_create_queues()
268 rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx, in csio_create_queues()
269 0, hw->pport[0].portid, false, NULL); in csio_create_queues()
271 csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv); in csio_create_queues()
277 rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx, in csio_create_queues()
278 csio_get_fwevt_intr_idx(hw), in csio_create_queues()
279 hw->pport[0].portid, true, NULL); in csio_create_queues()
281 csio_err(hw, "FW event IQ config failed!: %d\n", rv); in csio_create_queues()
286 rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx, in csio_create_queues()
287 mgmtm->iq_idx, hw->pport[0].portid, NULL); in csio_create_queues()
290 csio_err(hw, "Mgmt EQ create failed!: %d\n", rv); in csio_create_queues()
295 for (i = 0; i < hw->num_pports; i++) { in csio_create_queues()
296 info = &hw->scsi_cpu_info[i]; in csio_create_queues()
299 struct csio_scsi_qset *sqset = &hw->sqset[i][j]; in csio_create_queues()
301 rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx, in csio_create_queues()
304 csio_err(hw, in csio_create_queues()
309 rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx, in csio_create_queues()
312 csio_err(hw, in csio_create_queues()
320 hw->flags |= CSIO_HWF_Q_FW_ALLOCED; in csio_create_queues()
323 csio_wr_destroy_queues(hw, true); in csio_create_queues()
329 * @hw: HW module.
334 csio_config_queues(struct csio_hw *hw) in csio_config_queues() argument
339 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_config_queues()
343 if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED) in csio_config_queues()
344 return csio_create_queues(hw); in csio_config_queues()
347 hw->num_scsi_msix_cpus = num_online_cpus(); in csio_config_queues()
348 hw->num_sqsets = num_online_cpus() * hw->num_pports; in csio_config_queues()
350 if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) { in csio_config_queues()
351 hw->num_sqsets = CSIO_MAX_SCSI_QSETS; in csio_config_queues()
352 hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU; in csio_config_queues()
356 for (i = 0; i < hw->num_pports; i++) in csio_config_queues()
357 hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus; in csio_config_queues()
359 csio_dbg(hw, "nsqsets:%d scpus:%d\n", in csio_config_queues()
360 hw->num_sqsets, hw->num_scsi_msix_cpus); in csio_config_queues()
362 csio_intr_enable(hw); in csio_config_queues()
364 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_config_queues()
367 hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE, in csio_config_queues()
369 (void *)hw, 0, 0, NULL); in csio_config_queues()
370 if (hw->intr_iq_idx == -1) { in csio_config_queues()
371 csio_err(hw, in csio_config_queues()
378 hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE, in csio_config_queues()
380 CSIO_INGRESS, (void *)hw, in csio_config_queues()
383 if (hw->fwevt_iq_idx == -1) { in csio_config_queues()
384 csio_err(hw, "FW evt queue creation failed\n"); in csio_config_queues()
389 mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE, in csio_config_queues()
391 CSIO_EGRESS, (void *)hw, 0, 0, NULL); in csio_config_queues()
393 csio_err(hw, "Failed to alloc egress queue for mgmt module\n"); in csio_config_queues()
398 mgmtm->iq_idx = hw->fwevt_iq_idx; in csio_config_queues()
401 for (i = 0; i < hw->num_pports; i++) { in csio_config_queues()
402 info = &hw->scsi_cpu_info[i]; in csio_config_queues()
404 for (j = 0; j < hw->num_scsi_msix_cpus; j++) { in csio_config_queues()
405 sqset = &hw->sqset[i][j]; in csio_config_queues()
409 orig = &hw->sqset[i][k]; in csio_config_queues()
415 idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0, in csio_config_queues()
416 CSIO_EGRESS, (void *)hw, 0, 0, in csio_config_queues()
419 csio_err(hw, "EQ creation failed for idx:%d\n", in csio_config_queues()
426 idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE, in csio_config_queues()
428 (void *)hw, 0, 0, in csio_config_queues()
431 csio_err(hw, "IQ creation failed for idx:%d\n", in csio_config_queues()
439 hw->flags |= CSIO_HWF_Q_MEM_ALLOCED; in csio_config_queues()
441 rv = csio_create_queues(hw); in csio_config_queues()
449 rv = csio_request_irqs(hw); in csio_config_queues()
456 csio_intr_disable(hw, false); in csio_config_queues()
462 csio_resource_alloc(struct csio_hw *hw) in csio_resource_alloc() argument
464 struct csio_wrm *wrm = csio_hw_to_wrm(hw); in csio_resource_alloc()
470 hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
472 if (!hw->mb_mempool) in csio_resource_alloc()
475 hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
477 if (!hw->rnode_mempool) in csio_resource_alloc()
480 hw->scsi_dma_pool = dma_pool_create("csio_scsi_dma_pool", in csio_resource_alloc()
481 &hw->pdev->dev, CSIO_SCSI_RSP_LEN, in csio_resource_alloc()
483 if (!hw->scsi_dma_pool) in csio_resource_alloc()
489 mempool_destroy(hw->rnode_mempool); in csio_resource_alloc()
490 hw->rnode_mempool = NULL; in csio_resource_alloc()
492 mempool_destroy(hw->mb_mempool); in csio_resource_alloc()
493 hw->mb_mempool = NULL; in csio_resource_alloc()
499 csio_resource_free(struct csio_hw *hw) in csio_resource_free() argument
501 dma_pool_destroy(hw->scsi_dma_pool); in csio_resource_free()
502 hw->scsi_dma_pool = NULL; in csio_resource_free()
503 mempool_destroy(hw->rnode_mempool); in csio_resource_free()
504 hw->rnode_mempool = NULL; in csio_resource_free()
505 mempool_destroy(hw->mb_mempool); in csio_resource_free()
506 hw->mb_mempool = NULL; in csio_resource_free()
510 * csio_hw_alloc - Allocate and initialize the HW module.
513 * Allocates HW structure, DMA, memory resources, maps BARS to
514 * host memory and initializes HW module.
518 struct csio_hw *hw; in csio_hw_alloc() local
520 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL); in csio_hw_alloc()
521 if (!hw) in csio_hw_alloc()
524 hw->pdev = pdev; in csio_hw_alloc()
525 strncpy(hw->drv_version, CSIO_DRV_VERSION, 32); in csio_hw_alloc()
528 if (csio_resource_alloc(hw)) in csio_hw_alloc()
532 hw->regstart = ioremap(pci_resource_start(pdev, 0), in csio_hw_alloc()
534 if (!hw->regstart) { in csio_hw_alloc()
535 csio_err(hw, "Could not map BAR 0, regstart = %p\n", in csio_hw_alloc()
536 hw->regstart); in csio_hw_alloc()
540 csio_hw_init_workers(hw); in csio_hw_alloc()
542 if (csio_hw_init(hw)) in csio_hw_alloc()
545 csio_dfs_create(hw); in csio_hw_alloc()
547 csio_dbg(hw, "hw:%p\n", hw); in csio_hw_alloc()
549 return hw; in csio_hw_alloc()
552 csio_hw_exit_workers(hw); in csio_hw_alloc()
553 iounmap(hw->regstart); in csio_hw_alloc()
555 csio_resource_free(hw); in csio_hw_alloc()
557 kfree(hw); in csio_hw_alloc()
563 * csio_hw_free - Uninitialize and free the HW module.
564 * @hw: The HW module
566 * Disable interrupts, uninit the HW module, free resources, free hw.
569 csio_hw_free(struct csio_hw *hw) in csio_hw_free() argument
571 csio_intr_disable(hw, true); in csio_hw_free()
572 csio_hw_exit_workers(hw); in csio_hw_free()
573 csio_hw_exit(hw); in csio_hw_free()
574 iounmap(hw->regstart); in csio_hw_free()
575 csio_dfs_destroy(hw); in csio_hw_free()
576 csio_resource_free(hw); in csio_hw_free()
577 kfree(hw); in csio_hw_free()
582 * @hw: The HW module.
593 csio_shost_init(struct csio_hw *hw, struct device *dev, in csio_shost_init() argument
603 * hw->pdev is the physical port's PCI dev structure, in csio_shost_init()
606 if (dev == &hw->pdev->dev) in csio_shost_init()
629 hw->fres_info.max_ssns); in csio_shost_init()
631 if (dev == &hw->pdev->dev) in csio_shost_init()
637 if (!hw->rln) in csio_shost_init()
638 hw->rln = ln; in csio_shost_init()
641 if (csio_lnode_init(ln, hw, pln)) in csio_shost_init()
644 if (scsi_add_host_with_dma(shost, dev, &hw->pdev->dev)) in csio_shost_init()
666 struct csio_hw *hw = csio_lnode_to_hw(ln); in csio_shost_exit() local
677 spin_lock_irq(&hw->lock); in csio_shost_exit()
678 csio_evtq_flush(hw); in csio_shost_exit()
679 spin_unlock_irq(&hw->lock); in csio_shost_exit()
686 csio_lnode_alloc(struct csio_hw *hw) in csio_lnode_alloc() argument
688 return csio_shost_init(hw, &hw->pdev->dev, false, NULL); in csio_lnode_alloc()
692 csio_lnodes_block_request(struct csio_hw *hw) in csio_lnodes_block_request() argument
701 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_request()
704 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_request()
708 spin_lock_irq(&hw->lock); in csio_lnodes_block_request()
710 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_request()
718 spin_unlock_irq(&hw->lock); in csio_lnodes_block_request()
721 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_request()
731 csio_lnodes_unblock_request(struct csio_hw *hw) in csio_lnodes_unblock_request() argument
740 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_request()
743 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_request()
747 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_request()
749 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_request()
757 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_request()
760 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_request()
769 csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_block_by_port() argument
778 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_by_port()
781 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_by_port()
785 spin_lock_irq(&hw->lock); in csio_lnodes_block_by_port()
787 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_by_port()
798 spin_unlock_irq(&hw->lock); in csio_lnodes_block_by_port()
801 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_by_port()
810 csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_unblock_by_port() argument
819 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_by_port()
822 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_by_port()
826 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
828 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_by_port()
838 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
841 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_by_port()
850 csio_lnodes_exit(struct csio_hw *hw, bool npiv) in csio_lnodes_exit() argument
858 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_exit()
861 csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n"); in csio_lnodes_exit()
866 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
867 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
874 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
878 csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
889 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
891 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
895 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
899 csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
908 * csio_lnode_init_post: Set lnode attributes after starting HW.
930 * - Allocates HW structure, DMA, memory resources, maps BARS to
931 * host memory and initializes HW module.
936 * HW state machine.
945 struct csio_hw *hw; in csio_probe_one() local
957 hw = csio_hw_alloc(pdev); in csio_probe_one()
958 if (!hw) { in csio_probe_one()
964 hw->flags |= CSIO_HWF_ROOT_NO_RELAXED_ORDERING; in csio_probe_one()
966 pci_set_drvdata(pdev, hw); in csio_probe_one()
968 rv = csio_hw_start(hw); in csio_probe_one()
978 sprintf(hw->fwrev_str, "%u.%u.%u.%u\n", in csio_probe_one()
979 FW_HDR_FW_VER_MAJOR_G(hw->fwrev), in csio_probe_one()
980 FW_HDR_FW_VER_MINOR_G(hw->fwrev), in csio_probe_one()
981 FW_HDR_FW_VER_MICRO_G(hw->fwrev), in csio_probe_one()
982 FW_HDR_FW_VER_BUILD_G(hw->fwrev)); in csio_probe_one()
984 for (i = 0; i < hw->num_pports; i++) { in csio_probe_one()
985 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_probe_one()
991 ln->portid = hw->pport[i].portid; in csio_probe_one()
993 spin_lock_irq(&hw->lock); in csio_probe_one()
996 spin_unlock_irq(&hw->lock); in csio_probe_one()
1010 csio_lnodes_block_request(hw); in csio_probe_one()
1011 spin_lock_irq(&hw->lock); in csio_probe_one()
1012 csio_hw_stop(hw); in csio_probe_one()
1013 spin_unlock_irq(&hw->lock); in csio_probe_one()
1014 csio_lnodes_unblock_request(hw); in csio_probe_one()
1015 csio_lnodes_exit(hw, 0); in csio_probe_one()
1016 csio_hw_free(hw); in csio_probe_one()
1032 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_remove_one() local
1035 csio_lnodes_block_request(hw); in csio_remove_one()
1036 spin_lock_irq(&hw->lock); in csio_remove_one()
1042 csio_hw_stop(hw); in csio_remove_one()
1043 spin_unlock_irq(&hw->lock); in csio_remove_one()
1044 csio_lnodes_unblock_request(hw); in csio_remove_one()
1046 csio_lnodes_exit(hw, 0); in csio_remove_one()
1047 csio_hw_free(hw); in csio_remove_one()
1059 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_error_detected() local
1061 csio_lnodes_block_request(hw); in csio_pci_error_detected()
1062 spin_lock_irq(&hw->lock); in csio_pci_error_detected()
1064 /* Post PCI error detected evt to HW s/m in csio_pci_error_detected()
1065 * HW s/m handles this evt by quiescing IOs, unregisters rports in csio_pci_error_detected()
1068 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED); in csio_pci_error_detected()
1069 spin_unlock_irq(&hw->lock); in csio_pci_error_detected()
1070 csio_lnodes_unblock_request(hw); in csio_pci_error_detected()
1071 csio_lnodes_exit(hw, 0); in csio_pci_error_detected()
1072 csio_intr_disable(hw, true); in csio_pci_error_detected()
1086 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_slot_reset() local
1098 /* Bring HW s/m to ready state. in csio_pci_slot_reset()
1101 spin_lock_irq(&hw->lock); in csio_pci_slot_reset()
1102 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_SLOT_RESET); in csio_pci_slot_reset()
1103 ready = csio_is_hw_ready(hw); in csio_pci_slot_reset()
1104 spin_unlock_irq(&hw->lock); in csio_pci_slot_reset()
1109 dev_err(&pdev->dev, "Can't initialize HW when in slot reset\n"); in csio_pci_slot_reset()
1122 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_resume() local
1129 for (i = 0; i < hw->num_pports; i++) { in csio_pci_resume()
1130 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_pci_resume()
1136 ln->portid = hw->pport[i].portid; in csio_pci_resume()
1138 spin_lock_irq(&hw->lock); in csio_pci_resume()
1141 spin_unlock_irq(&hw->lock); in csio_pci_resume()
1155 csio_lnodes_block_request(hw); in csio_pci_resume()
1156 spin_lock_irq(&hw->lock); in csio_pci_resume()
1157 csio_hw_stop(hw); in csio_pci_resume()
1158 spin_unlock_irq(&hw->lock); in csio_pci_resume()
1159 csio_lnodes_unblock_request(hw); in csio_pci_resume()
1160 csio_lnodes_exit(hw, 0); in csio_pci_resume()
1161 csio_hw_free(hw); in csio_pci_resume()