Lines Matching refs: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()
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()
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()
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()
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_pci_pool = pci_pool_create("csio_scsi_pci_pool", hw->pdev, in csio_resource_alloc()
490 if (!hw->scsi_pci_pool) in csio_resource_alloc()
496 mempool_destroy(hw->rnode_mempool); in csio_resource_alloc()
497 hw->rnode_mempool = NULL; in csio_resource_alloc()
499 mempool_destroy(hw->mb_mempool); in csio_resource_alloc()
500 hw->mb_mempool = NULL; in csio_resource_alloc()
506 csio_resource_free(struct csio_hw *hw) in csio_resource_free() argument
508 pci_pool_destroy(hw->scsi_pci_pool); in csio_resource_free()
509 hw->scsi_pci_pool = NULL; in csio_resource_free()
510 mempool_destroy(hw->rnode_mempool); in csio_resource_free()
511 hw->rnode_mempool = NULL; in csio_resource_free()
512 mempool_destroy(hw->mb_mempool); in csio_resource_free()
513 hw->mb_mempool = NULL; in csio_resource_free()
525 struct csio_hw *hw; in csio_hw_alloc() local
527 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL); in csio_hw_alloc()
528 if (!hw) in csio_hw_alloc()
531 hw->pdev = pdev; in csio_hw_alloc()
532 strncpy(hw->drv_version, CSIO_DRV_VERSION, 32); in csio_hw_alloc()
535 if (csio_resource_alloc(hw)) in csio_hw_alloc()
539 hw->regstart = ioremap_nocache(pci_resource_start(pdev, 0), in csio_hw_alloc()
541 if (!hw->regstart) { in csio_hw_alloc()
542 csio_err(hw, "Could not map BAR 0, regstart = %p\n", in csio_hw_alloc()
543 hw->regstart); in csio_hw_alloc()
547 csio_hw_init_workers(hw); in csio_hw_alloc()
549 if (csio_hw_init(hw)) in csio_hw_alloc()
552 csio_dfs_create(hw); in csio_hw_alloc()
554 csio_dbg(hw, "hw:%p\n", hw); in csio_hw_alloc()
556 return hw; in csio_hw_alloc()
559 csio_hw_exit_workers(hw); in csio_hw_alloc()
560 iounmap(hw->regstart); in csio_hw_alloc()
562 csio_resource_free(hw); in csio_hw_alloc()
564 kfree(hw); in csio_hw_alloc()
576 csio_hw_free(struct csio_hw *hw) in csio_hw_free() argument
578 csio_intr_disable(hw, true); in csio_hw_free()
579 csio_hw_exit_workers(hw); in csio_hw_free()
580 csio_hw_exit(hw); in csio_hw_free()
581 iounmap(hw->regstart); in csio_hw_free()
582 csio_dfs_destroy(hw); in csio_hw_free()
583 csio_resource_free(hw); in csio_hw_free()
584 kfree(hw); in csio_hw_free()
600 csio_shost_init(struct csio_hw *hw, struct device *dev, in csio_shost_init() argument
613 if (dev == &hw->pdev->dev) in csio_shost_init()
636 hw->fres_info.max_ssns); in csio_shost_init()
638 if (dev == &hw->pdev->dev) in csio_shost_init()
644 if (!hw->rln) in csio_shost_init()
645 hw->rln = ln; in csio_shost_init()
648 if (csio_lnode_init(ln, hw, pln)) in csio_shost_init()
673 struct csio_hw *hw = csio_lnode_to_hw(ln); in csio_shost_exit() local
684 spin_lock_irq(&hw->lock); in csio_shost_exit()
685 csio_evtq_flush(hw); in csio_shost_exit()
686 spin_unlock_irq(&hw->lock); in csio_shost_exit()
693 csio_lnode_alloc(struct csio_hw *hw) in csio_lnode_alloc() argument
695 return csio_shost_init(hw, &hw->pdev->dev, false, NULL); in csio_lnode_alloc()
699 csio_lnodes_block_request(struct csio_hw *hw) in csio_lnodes_block_request() argument
708 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_request()
711 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_request()
715 spin_lock_irq(&hw->lock); in csio_lnodes_block_request()
717 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_request()
725 spin_unlock_irq(&hw->lock); in csio_lnodes_block_request()
728 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_request()
738 csio_lnodes_unblock_request(struct csio_hw *hw) in csio_lnodes_unblock_request() argument
747 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_request()
750 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_request()
754 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_request()
756 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_request()
764 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_request()
767 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_request()
776 csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_block_by_port() argument
785 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_block_by_port()
788 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_block_by_port()
792 spin_lock_irq(&hw->lock); in csio_lnodes_block_by_port()
794 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_block_by_port()
805 spin_unlock_irq(&hw->lock); in csio_lnodes_block_by_port()
808 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_block_by_port()
817 csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid) in csio_lnodes_unblock_by_port() argument
826 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_unblock_by_port()
829 csio_err(hw, "Failed to allocate lnodes_list"); in csio_lnodes_unblock_by_port()
833 spin_lock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
835 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_unblock_by_port()
845 spin_unlock_irq(&hw->lock); in csio_lnodes_unblock_by_port()
848 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]); in csio_lnodes_unblock_by_port()
857 csio_lnodes_exit(struct csio_hw *hw, bool npiv) in csio_lnodes_exit() argument
865 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns), in csio_lnodes_exit()
868 csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n"); in csio_lnodes_exit()
873 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
874 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
881 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
885 csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
896 spin_lock_irq(&hw->lock); in csio_lnodes_exit()
898 list_for_each(cur_ln, &hw->sln_head) { in csio_lnodes_exit()
902 spin_unlock_irq(&hw->lock); in csio_lnodes_exit()
906 csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]); in csio_lnodes_exit()
952 struct csio_hw *hw; in csio_probe_one() local
963 hw = csio_hw_alloc(pdev); in csio_probe_one()
964 if (!hw) { in csio_probe_one()
969 pci_set_drvdata(pdev, hw); in csio_probe_one()
971 if (csio_hw_start(hw) != 0) { in csio_probe_one()
977 sprintf(hw->fwrev_str, "%u.%u.%u.%u\n", in csio_probe_one()
978 FW_HDR_FW_VER_MAJOR_G(hw->fwrev), in csio_probe_one()
979 FW_HDR_FW_VER_MINOR_G(hw->fwrev), in csio_probe_one()
980 FW_HDR_FW_VER_MICRO_G(hw->fwrev), in csio_probe_one()
981 FW_HDR_FW_VER_BUILD_G(hw->fwrev)); in csio_probe_one()
983 for (i = 0; i < hw->num_pports; i++) { in csio_probe_one()
984 ln = csio_shost_init(hw, &pdev->dev, true, NULL); in csio_probe_one()
990 ln->portid = hw->pport[i].portid; in csio_probe_one()
992 spin_lock_irq(&hw->lock); in csio_probe_one()
995 spin_unlock_irq(&hw->lock); in csio_probe_one()
1009 csio_lnodes_block_request(hw); in csio_probe_one()
1010 spin_lock_irq(&hw->lock); in csio_probe_one()
1011 csio_hw_stop(hw); in csio_probe_one()
1012 spin_unlock_irq(&hw->lock); in csio_probe_one()
1013 csio_lnodes_unblock_request(hw); in csio_probe_one()
1014 csio_lnodes_exit(hw, 0); in csio_probe_one()
1015 csio_hw_free(hw); in csio_probe_one()
1031 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_remove_one() local
1034 csio_lnodes_block_request(hw); in csio_remove_one()
1035 spin_lock_irq(&hw->lock); in csio_remove_one()
1041 csio_hw_stop(hw); in csio_remove_one()
1042 spin_unlock_irq(&hw->lock); in csio_remove_one()
1043 csio_lnodes_unblock_request(hw); in csio_remove_one()
1045 csio_lnodes_exit(hw, 0); in csio_remove_one()
1046 csio_hw_free(hw); in csio_remove_one()
1058 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_error_detected() local
1060 csio_lnodes_block_request(hw); in csio_pci_error_detected()
1061 spin_lock_irq(&hw->lock); in csio_pci_error_detected()
1067 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED); in csio_pci_error_detected()
1068 spin_unlock_irq(&hw->lock); in csio_pci_error_detected()
1069 csio_lnodes_unblock_request(hw); in csio_pci_error_detected()
1070 csio_lnodes_exit(hw, 0); in csio_pci_error_detected()
1071 csio_intr_disable(hw, true); in csio_pci_error_detected()
1085 struct csio_hw *hw = pci_get_drvdata(pdev); in csio_pci_slot_reset() local
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()
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()