Lines Matching refs:hw
69 struct csio_hw *hw = file->private_data - mem;
84 ret = hw->chip_ops->chip_mc_read(hw, 0, pos,
87 ret = hw->chip_ops->chip_edc_read(hw, mem, pos,
113 void csio_add_debugfs_mem(struct csio_hw *hw, const char *name,
116 debugfs_create_file_size(name, S_IRUSR, hw->debugfs_root,
117 (void *)hw + idx, &csio_mem_debugfs_fops,
121 static int csio_setup_debugfs(struct csio_hw *hw)
125 if (IS_ERR_OR_NULL(hw->debugfs_root))
128 i = csio_rd_reg32(hw, MA_TARGET_MEM_ENABLE_A);
130 csio_add_debugfs_mem(hw, "edc0", MEM_EDC0, 5);
132 csio_add_debugfs_mem(hw, "edc1", MEM_EDC1, 5);
134 hw->chip_ops->chip_dfs_create_ext_mem(hw);
139 * csio_dfs_create - Creates and sets up per-hw debugfs.
143 csio_dfs_create(struct csio_hw *hw)
146 hw->debugfs_root = debugfs_create_dir(pci_name(hw->pdev),
148 csio_setup_debugfs(hw);
155 * csio_dfs_destroy - Destroys per-hw debugfs.
158 csio_dfs_destroy(struct csio_hw *hw)
160 debugfs_remove_recursive(hw->debugfs_root);
241 * @hw: HW module.
245 csio_hw_init_workers(struct csio_hw *hw)
247 INIT_WORK(&hw->evtq_work, csio_evtq_worker);
251 csio_hw_exit_workers(struct csio_hw *hw)
253 cancel_work_sync(&hw->evtq_work);
257 csio_create_queues(struct csio_hw *hw)
260 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw);
264 if (hw->flags & CSIO_HWF_Q_FW_ALLOCED)
267 if (hw->intr_mode != CSIO_IM_MSIX) {
268 rv = csio_wr_iq_create(hw, NULL, hw->intr_iq_idx,
269 0, hw->pport[0].portid, false, NULL);
271 csio_err(hw, " Forward Interrupt IQ failed!: %d\n", rv);
277 rv = csio_wr_iq_create(hw, NULL, hw->fwevt_iq_idx,
278 csio_get_fwevt_intr_idx(hw),
279 hw->pport[0].portid, true, NULL);
281 csio_err(hw, "FW event IQ config failed!: %d\n", rv);
286 rv = csio_wr_eq_create(hw, NULL, mgmtm->eq_idx,
287 mgmtm->iq_idx, hw->pport[0].portid, NULL);
290 csio_err(hw, "Mgmt EQ create failed!: %d\n", rv);
295 for (i = 0; i < hw->num_pports; i++) {
296 info = &hw->scsi_cpu_info[i];
299 struct csio_scsi_qset *sqset = &hw->sqset[i][j];
301 rv = csio_wr_iq_create(hw, NULL, sqset->iq_idx,
304 csio_err(hw,
309 rv = csio_wr_eq_create(hw, NULL, sqset->eq_idx,
312 csio_err(hw,
320 hw->flags |= CSIO_HWF_Q_FW_ALLOCED;
323 csio_wr_destroy_queues(hw, true);
329 * @hw: HW module.
334 csio_config_queues(struct csio_hw *hw)
339 struct csio_mgmtm *mgmtm = csio_hw_to_mgmtm(hw);
343 if (hw->flags & CSIO_HWF_Q_MEM_ALLOCED)
344 return csio_create_queues(hw);
347 hw->num_scsi_msix_cpus = num_online_cpus();
348 hw->num_sqsets = num_online_cpus() * hw->num_pports;
350 if (hw->num_sqsets > CSIO_MAX_SCSI_QSETS) {
351 hw->num_sqsets = CSIO_MAX_SCSI_QSETS;
352 hw->num_scsi_msix_cpus = CSIO_MAX_SCSI_CPU;
356 for (i = 0; i < hw->num_pports; i++)
357 hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus;
359 csio_dbg(hw, "nsqsets:%d scpus:%d\n",
360 hw->num_sqsets, hw->num_scsi_msix_cpus);
362 csio_intr_enable(hw);
364 if (hw->intr_mode != CSIO_IM_MSIX) {
367 hw->intr_iq_idx = csio_wr_alloc_q(hw, CSIO_INTR_IQSIZE,
369 (void *)hw, 0, 0, NULL);
370 if (hw->intr_iq_idx == -1) {
371 csio_err(hw,
378 hw->fwevt_iq_idx = csio_wr_alloc_q(hw, CSIO_FWEVT_IQSIZE,
380 CSIO_INGRESS, (void *)hw,
383 if (hw->fwevt_iq_idx == -1) {
384 csio_err(hw, "FW evt queue creation failed\n");
389 mgmtm->eq_idx = csio_wr_alloc_q(hw, CSIO_MGMT_EQSIZE,
391 CSIO_EGRESS, (void *)hw, 0, 0, NULL);
393 csio_err(hw, "Failed to alloc egress queue for mgmt module\n");
398 mgmtm->iq_idx = hw->fwevt_iq_idx;
401 for (i = 0; i < hw->num_pports; i++) {
402 info = &hw->scsi_cpu_info[i];
404 for (j = 0; j < hw->num_scsi_msix_cpus; j++) {
405 sqset = &hw->sqset[i][j];
409 orig = &hw->sqset[i][k];
415 idx = csio_wr_alloc_q(hw, csio_scsi_eqsize, 0,
416 CSIO_EGRESS, (void *)hw, 0, 0,
419 csio_err(hw, "EQ creation failed for idx:%d\n",
426 idx = csio_wr_alloc_q(hw, CSIO_SCSI_IQSIZE,
428 (void *)hw, 0, 0,
431 csio_err(hw, "IQ creation failed for idx:%d\n",
439 hw->flags |= CSIO_HWF_Q_MEM_ALLOCED;
441 rv = csio_create_queues(hw);
449 rv = csio_request_irqs(hw);
456 csio_intr_disable(hw, false);
462 csio_resource_alloc(struct csio_hw *hw)
464 struct csio_wrm *wrm = csio_hw_to_wrm(hw);
470 hw->mb_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ,
472 if (!hw->mb_mempool)
475 hw->rnode_mempool = mempool_create_kmalloc_pool(CSIO_MIN_MEMPOOL_SZ,
477 if (!hw->rnode_mempool)
480 hw->scsi_dma_pool = dma_pool_create("csio_scsi_dma_pool",
481 &hw->pdev->dev, CSIO_SCSI_RSP_LEN,
483 if (!hw->scsi_dma_pool)
489 mempool_destroy(hw->rnode_mempool);
490 hw->rnode_mempool = NULL;
492 mempool_destroy(hw->mb_mempool);
493 hw->mb_mempool = NULL;
499 csio_resource_free(struct csio_hw *hw)
501 dma_pool_destroy(hw->scsi_dma_pool);
502 hw->scsi_dma_pool = NULL;
503 mempool_destroy(hw->rnode_mempool);
504 hw->rnode_mempool = NULL;
505 mempool_destroy(hw->mb_mempool);
506 hw->mb_mempool = NULL;
518 struct csio_hw *hw;
520 hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL);
521 if (!hw)
524 hw->pdev = pdev;
525 strncpy(hw->drv_version, CSIO_DRV_VERSION, 32);
528 if (csio_resource_alloc(hw))
532 hw->regstart = ioremap(pci_resource_start(pdev, 0),
534 if (!hw->regstart) {
535 csio_err(hw, "Could not map BAR 0, regstart = %p\n",
536 hw->regstart);
540 csio_hw_init_workers(hw);
542 if (csio_hw_init(hw))
545 csio_dfs_create(hw);
547 csio_dbg(hw, "hw:%p\n", hw);
549 return hw;
552 csio_hw_exit_workers(hw);
553 iounmap(hw->regstart);
555 csio_resource_free(hw);
557 kfree(hw);
564 * @hw: The HW module
566 * Disable interrupts, uninit the HW module, free resources, free hw.
569 csio_hw_free(struct csio_hw *hw)
571 csio_intr_disable(hw, true);
572 csio_hw_exit_workers(hw);
573 csio_hw_exit(hw);
574 iounmap(hw->regstart);
575 csio_dfs_destroy(hw);
576 csio_resource_free(hw);
577 kfree(hw);
582 * @hw: The HW module.
593 csio_shost_init(struct csio_hw *hw, struct device *dev,
603 * hw->pdev is the physical port's PCI dev structure,
606 if (dev == &hw->pdev->dev)
629 hw->fres_info.max_ssns);
631 if (dev == &hw->pdev->dev)
637 if (!hw->rln)
638 hw->rln = ln;
641 if (csio_lnode_init(ln, hw, pln))
644 if (scsi_add_host_with_dma(shost, dev, &hw->pdev->dev))
666 struct csio_hw *hw = csio_lnode_to_hw(ln);
677 spin_lock_irq(&hw->lock);
678 csio_evtq_flush(hw);
679 spin_unlock_irq(&hw->lock);
686 csio_lnode_alloc(struct csio_hw *hw)
688 return csio_shost_init(hw, &hw->pdev->dev, false, NULL);
692 csio_lnodes_block_request(struct csio_hw *hw)
701 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
704 csio_err(hw, "Failed to allocate lnodes_list");
708 spin_lock_irq(&hw->lock);
710 list_for_each(cur_ln, &hw->sln_head) {
718 spin_unlock_irq(&hw->lock);
721 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]);
731 csio_lnodes_unblock_request(struct csio_hw *hw)
740 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
743 csio_err(hw, "Failed to allocate lnodes_list");
747 spin_lock_irq(&hw->lock);
749 list_for_each(cur_ln, &hw->sln_head) {
757 spin_unlock_irq(&hw->lock);
760 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]);
769 csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid)
778 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
781 csio_err(hw, "Failed to allocate lnodes_list");
785 spin_lock_irq(&hw->lock);
787 list_for_each(cur_ln, &hw->sln_head) {
798 spin_unlock_irq(&hw->lock);
801 csio_dbg(hw, "Blocking IOs on lnode: %p\n", lnode_list[ii]);
810 csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid)
819 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
822 csio_err(hw, "Failed to allocate lnodes_list");
826 spin_lock_irq(&hw->lock);
828 list_for_each(cur_ln, &hw->sln_head) {
838 spin_unlock_irq(&hw->lock);
841 csio_dbg(hw, "unblocking IOs on lnode: %p\n", lnode_list[ii]);
850 csio_lnodes_exit(struct csio_hw *hw, bool npiv)
858 lnode_list = kzalloc((sizeof(struct csio_lnode *) * hw->num_lns),
861 csio_err(hw, "lnodes_exit: Failed to allocate lnodes_list.\n");
866 spin_lock_irq(&hw->lock);
867 list_for_each(cur_ln, &hw->sln_head) {
874 spin_unlock_irq(&hw->lock);
878 csio_dbg(hw, "Deleting child lnode: %p\n", lnode_list[ii]);
889 spin_lock_irq(&hw->lock);
891 list_for_each(cur_ln, &hw->sln_head) {
895 spin_unlock_irq(&hw->lock);
899 csio_dbg(hw, "Deleting parent lnode: %p\n", lnode_list[ii]);
945 struct csio_hw *hw;
957 hw = csio_hw_alloc(pdev);
958 if (!hw) {
964 hw->flags |= CSIO_HWF_ROOT_NO_RELAXED_ORDERING;
966 pci_set_drvdata(pdev, hw);
968 rv = csio_hw_start(hw);
978 sprintf(hw->fwrev_str, "%u.%u.%u.%u\n",
979 FW_HDR_FW_VER_MAJOR_G(hw->fwrev),
980 FW_HDR_FW_VER_MINOR_G(hw->fwrev),
981 FW_HDR_FW_VER_MICRO_G(hw->fwrev),
982 FW_HDR_FW_VER_BUILD_G(hw->fwrev));
984 for (i = 0; i < hw->num_pports; i++) {
985 ln = csio_shost_init(hw, &pdev->dev, true, NULL);
991 ln->portid = hw->pport[i].portid;
993 spin_lock_irq(&hw->lock);
996 spin_unlock_irq(&hw->lock);
1010 csio_lnodes_block_request(hw);
1011 spin_lock_irq(&hw->lock);
1012 csio_hw_stop(hw);
1013 spin_unlock_irq(&hw->lock);
1014 csio_lnodes_unblock_request(hw);
1015 csio_lnodes_exit(hw, 0);
1016 csio_hw_free(hw);
1032 struct csio_hw *hw = pci_get_drvdata(pdev);
1035 csio_lnodes_block_request(hw);
1036 spin_lock_irq(&hw->lock);
1042 csio_hw_stop(hw);
1043 spin_unlock_irq(&hw->lock);
1044 csio_lnodes_unblock_request(hw);
1046 csio_lnodes_exit(hw, 0);
1047 csio_hw_free(hw);
1059 struct csio_hw *hw = pci_get_drvdata(pdev);
1061 csio_lnodes_block_request(hw);
1062 spin_lock_irq(&hw->lock);
1068 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_DETECTED);
1069 spin_unlock_irq(&hw->lock);
1070 csio_lnodes_unblock_request(hw);
1071 csio_lnodes_exit(hw, 0);
1072 csio_intr_disable(hw, true);
1086 struct csio_hw *hw = pci_get_drvdata(pdev);
1101 spin_lock_irq(&hw->lock);
1102 csio_post_event(&hw->sm, CSIO_HWE_PCIERR_SLOT_RESET);
1103 ready = csio_is_hw_ready(hw);
1104 spin_unlock_irq(&hw->lock);
1122 struct csio_hw *hw = pci_get_drvdata(pdev);
1129 for (i = 0; i < hw->num_pports; i++) {
1130 ln = csio_shost_init(hw, &pdev->dev, true, NULL);
1136 ln->portid = hw->pport[i].portid;
1138 spin_lock_irq(&hw->lock);
1141 spin_unlock_irq(&hw->lock);
1155 csio_lnodes_block_request(hw);
1156 spin_lock_irq(&hw->lock);
1157 csio_hw_stop(hw);
1158 spin_unlock_irq(&hw->lock);
1159 csio_lnodes_unblock_request(hw);
1160 csio_lnodes_exit(hw, 0);
1161 csio_hw_free(hw);