Lines Matching full:hw

68 	struct csio_hw *hw = file->private_data - mem;  in csio_mem_read()  local
83 ret = hw->chip_ops->chip_mc_read(hw, 0, pos, in csio_mem_read()
86 ret = hw->chip_ops->chip_edc_read(hw, mem, pos, in csio_mem_read()
112 void csio_add_debugfs_mem(struct csio_hw *hw, const char *name, in csio_add_debugfs_mem() argument
115 debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root, in csio_add_debugfs_mem()
116 (void *)hw + idx, &csio_mem_debugfs_fops, in csio_add_debugfs_mem()
120 static int csio_setup_debugfs(struct csio_hw *hw) in csio_setup_debugfs() argument
124 if (IS_ERR_OR_NULL(hw->debugfs_root)) in csio_setup_debugfs()
127 i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE_A); in csio_setup_debugfs()
129 csio_add_debugfs_mem(hw, "edc0", MEM_EDC0, 5); in csio_setup_debugfs()
131 csio_add_debugfs_mem(hw, "edc1", MEM_EDC1, 5); in csio_setup_debugfs()
133 hw->chip_ops->chip_dfs_create_ext_mem(hw); in csio_setup_debugfs()
138 * csio_dfs_create - Creates and sets up per-hw debugfs.
142 csio_dfs_create(struct csio_hw *hw) in csio_dfs_create() argument
145 hw->debugfs_root = debugfs_create_dir(pci_name(hw->pdev), in csio_dfs_create()
147 csio_setup_debugfs(hw); in csio_dfs_create()
154 * csio_dfs_destroy - Destroys per-hw debugfs.
157 csio_dfs_destroy(struct csio_hw *hw) in csio_dfs_destroy() argument
159 debugfs_remove_recursive(hw->debugfs_root); in csio_dfs_destroy()
239 * csio_hw_init_workers - Initialize the HW module's worker threads.
240 * @hw: HW module.
244 csio_hw_init_workers(struct csio_hw *hw) in csio_hw_init_workers() argument
246 INIT_WORK(&hw->evtq_work, csio_evtq_worker); in csio_hw_init_workers()
250 csio_hw_exit_workers(struct csio_hw *hw) in csio_hw_exit_workers() argument
252 cancel_work_sync(&hw->evtq_work); in csio_hw_exit_workers()
256 csio_create_queues(struct csio_hw *hw) in csio_create_queues() argument
259 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_create_queues()
263 if (hw->flags & CSIO_HWF_Q_FW_ALLOCED) in csio_create_queues()
266 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_create_queues()
267 rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx, in csio_create_queues()
268 0, hw->pport[0].portid, false, NULL); in csio_create_queues()
270 csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv); in csio_create_queues()
276 rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx, in csio_create_queues()
277 csio_get_fwevt_intr_idx(hw), in csio_create_queues()
278 hw->pport[0].portid, true, NULL); in csio_create_queues()
280 csio_err(hw, "FW event IQ config failed!: %d\n", rv); in csio_create_queues()
285 rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx, in csio_create_queues()
286 mgmtm->iq_idx, hw->pport[0].portid, NULL); in csio_create_queues()
289 csio_err(hw, "Mgmt EQ create failed!: %d\n", rv); in csio_create_queues()
294 for (i = 0; i < hw->num_pports; i++) { in csio_create_queues()
295 info = &hw->scsi_cpu_info[i]; in csio_create_queues()
298 struct csio_scsi_qset *sqset = &hw->sqset[i][j]; in csio_create_queues()
300 rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx, in csio_create_queues()
303 csio_err(hw, in csio_create_queues()
308 rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx, in csio_create_queues()
311 csio_err(hw, in csio_create_queues()
319 hw->flags |= CSIO_HWF_Q_FW_ALLOCED; in csio_create_queues()
322 csio_wr_destroy_queues(hw, true); in csio_create_queues()
328 * @hw: HW module.
333 csio_config_queues(struct csio_hw *hw) in csio_config_queues() argument
338 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw); in csio_config_queues()
342 if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED) in csio_config_queues()
343 return csio_create_queues(hw); in csio_config_queues()
346 hw->num_scsi_msix_cpus = num_online_cpus(); in csio_config_queues()
347 hw->num_sqsets = num_online_cpus() * hw->num_pports; in csio_config_queues()
349 if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) { in csio_config_queues()
350 hw->num_sqsets = CSIO_MAX_SCSI_QSETS; in csio_config_queues()
351 hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU; in csio_config_queues()
355 for (i = 0; i < hw->num_pports; i++) in csio_config_queues()
356 hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus; in csio_config_queues()
358 csio_dbg(hw, "nsqsets:%d scpus:%d\n", in csio_config_queues()
359 hw->num_sqsets, hw->num_scsi_msix_cpus); in csio_config_queues()
361 csio_intr_enable(hw); in csio_config_queues()
363 if (hw->intr_mode != CSIO_IM_MSIX) { in csio_config_queues()
366 hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE, in csio_config_queues()
368 (void *)hw, 0, 0, NULL); in csio_config_queues()
369 if (hw->intr_iq_idx == -1) { in csio_config_queues()
370 csio_err(hw, in csio_config_queues()
377 hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE, in csio_config_queues()
379 CSIO_INGRESS, (void *)hw, in csio_config_queues()
382 if (hw->fwevt_iq_idx == -1) { in csio_config_queues()
383 csio_err(hw, "FW evt queue creation failed\n"); in csio_config_queues()
388 mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE, in csio_config_queues()
390 CSIO_EGRESS, (void *)hw, 0, 0, NULL); in csio_config_queues()
392 csio_err(hw, "Failed to alloc egress queue for mgmt module\n"); in csio_config_queues()
397 mgmtm->iq_idx = hw->fwevt_iq_idx; in csio_config_queues()
400 for (i = 0; i < hw->num_pports; i++) { in csio_config_queues()
401 info = &hw->scsi_cpu_info[i]; in csio_config_queues()
403 for (j = 0; j < hw->num_scsi_msix_cpus; j++) { in csio_config_queues()
404 sqset = &hw->sqset[i][j]; in csio_config_queues()
408 orig = &hw->sqset[i][k]; in csio_config_queues()
414 idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0, in csio_config_queues()
415 CSIO_EGRESS, (void *)hw, 0, 0, in csio_config_queues()
418 csio_err(hw, "EQ creation failed for idx:%d\n", in csio_config_queues()
425 idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE, in csio_config_queues()
427 (void *)hw, 0, 0, in csio_config_queues()
430 csio_err(hw, "IQ creation failed for idx:%d\n", in csio_config_queues()
438 hw->flags |= CSIO_HWF_Q_MEM_ALLOCED; in csio_config_queues()
440 rv = csio_create_queues(hw); in csio_config_queues()
448 rv = csio_request_irqs(hw); in csio_config_queues()
455 csio_intr_disable(hw, false); in csio_config_queues()
461 csio_resource_alloc(struct csio_hw *hw) in csio_resource_alloc() argument
463 struct csio_wrm *wrm = csio_hw_to_wrm(hw); in csio_resource_alloc()
469 hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
471 if (!hw->mb_mempool) in csio_resource_alloc()
474 hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ, in csio_resource_alloc()
476 if (!hw->rnode_mempool) in csio_resource_alloc()
479 hw->scsi_dma_pool = dma_pool_create("csio_scsi_dma_pool", in csio_resource_alloc()
480 &hw->pdev->dev, CSIO_SCSI_RSP_LEN, in csio_resource_alloc()
482 if (!hw->scsi_dma_pool) in csio_resource_alloc()
488 mempool_destroy(hw->rnode_mempool); in csio_resource_alloc()
489 hw->rnode_mempool = NULL; in csio_resource_alloc()
491 mempool_destroy(hw->mb_mempool); in csio_resource_alloc()
492 hw->mb_mempool = NULL; in csio_resource_alloc()
498 csio_resource_free(struct csio_hw *hw) in csio_resource_free() argument
500 dma_pool_destroy(hw->scsi_dma_pool); in csio_resource_free()
501 hw->scsi_dma_pool = NULL; in csio_resource_free()
502 mempool_destroy(hw->rnode_mempool); in csio_resource_free()
503 hw->rnode_mempool = NULL; in csio_resource_free()
504 mempool_destroy(hw->mb_mempool); in csio_resource_free()
505 hw->mb_mempool = NULL; in csio_resource_free()
509 * csio_hw_alloc - Allocate and initialize the HW module.
512 * Allocates HW structure, DMA, memory resources, maps BARS to
513 * host memory and initializes HW module.
517 struct csio_hw *hw; in csio_hw_alloc() local
519 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL); in csio_hw_alloc()
520 if (!hw) in csio_hw_alloc()
523 hw->pdev = pdev; in csio_hw_alloc()
524 strscpy(hw->drv_version, CSIO_DRV_VERSION, in csio_hw_alloc()
525 sizeof(hw->drv_version)); 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()