Lines Matching +full:io +full:- +full:expander
6 * Copyright (c) 1999-2008 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com)
9 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
23 LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
42 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
89 /* scsi-mid layer global parameter is max_report_luns, which is 511 */
141 "---- IO UNIT PAGE 0 ------------\n", ioc->name)); in mptsas_print_phy_data()
143 ioc->name, le16_to_cpu(phy_data->AttachedDeviceHandle))); in mptsas_print_phy_data()
145 ioc->name, le16_to_cpu(phy_data->ControllerDevHandle))); in mptsas_print_phy_data()
147 ioc->name, phy_data->Port)); in mptsas_print_phy_data()
149 ioc->name, phy_data->PortFlags)); in mptsas_print_phy_data()
151 ioc->name, phy_data->PhyFlags)); in mptsas_print_phy_data()
153 ioc->name, phy_data->NegotiatedLinkRate)); in mptsas_print_phy_data()
155 "Controller PHY Device Info=0x%X\n", ioc->name, in mptsas_print_phy_data()
156 le32_to_cpu(phy_data->ControllerPhyDeviceInfo))); in mptsas_print_phy_data()
158 ioc->name, le32_to_cpu(phy_data->DiscoveryStatus))); in mptsas_print_phy_data()
165 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); in mptsas_print_phy_pg0()
168 "---- SAS PHY PAGE 0 ------------\n", ioc->name)); in mptsas_print_phy_pg0()
170 "Attached Device Handle=0x%X\n", ioc->name, in mptsas_print_phy_pg0()
171 le16_to_cpu(pg0->AttachedDevHandle))); in mptsas_print_phy_pg0()
173 ioc->name, (unsigned long long)le64_to_cpu(sas_address))); in mptsas_print_phy_pg0()
175 "Attached PHY Identifier=0x%X\n", ioc->name, in mptsas_print_phy_pg0()
176 pg0->AttachedPhyIdentifier)); in mptsas_print_phy_pg0()
178 ioc->name, le32_to_cpu(pg0->AttachedDeviceInfo))); in mptsas_print_phy_pg0()
180 ioc->name, pg0->ProgrammedLinkRate)); in mptsas_print_phy_pg0()
182 ioc->name, pg0->ChangeCount)); in mptsas_print_phy_pg0()
184 ioc->name, le32_to_cpu(pg0->PhyInfo))); in mptsas_print_phy_pg0()
190 "---- SAS PHY PAGE 1 ------------\n", ioc->name)); in mptsas_print_phy_pg1()
192 ioc->name, pg1->InvalidDwordCount)); in mptsas_print_phy_pg1()
194 "Running Disparity Error Count=0x%x\n", ioc->name, in mptsas_print_phy_pg1()
195 pg1->RunningDisparityErrorCount)); in mptsas_print_phy_pg1()
197 "Loss Dword Synch Count=0x%x\n", ioc->name, in mptsas_print_phy_pg1()
198 pg1->LossDwordSynchCount)); in mptsas_print_phy_pg1()
200 "PHY Reset Problem Count=0x%x\n\n", ioc->name, in mptsas_print_phy_pg1()
201 pg1->PhyResetProblemCount)); in mptsas_print_phy_pg1()
208 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); in mptsas_print_device_pg0()
211 "---- SAS DEVICE PAGE 0 ---------\n", ioc->name)); in mptsas_print_device_pg0()
213 ioc->name, le16_to_cpu(pg0->DevHandle))); in mptsas_print_device_pg0()
215 ioc->name, le16_to_cpu(pg0->ParentDevHandle))); in mptsas_print_device_pg0()
217 ioc->name, le16_to_cpu(pg0->EnclosureHandle))); in mptsas_print_device_pg0()
219 ioc->name, le16_to_cpu(pg0->Slot))); in mptsas_print_device_pg0()
221 ioc->name, (unsigned long long)le64_to_cpu(sas_address))); in mptsas_print_device_pg0()
223 ioc->name, pg0->TargetID)); in mptsas_print_device_pg0()
225 ioc->name, pg0->Bus)); in mptsas_print_device_pg0()
227 ioc->name, pg0->PhyNum)); in mptsas_print_device_pg0()
229 ioc->name, le16_to_cpu(pg0->AccessStatus))); in mptsas_print_device_pg0()
231 ioc->name, le32_to_cpu(pg0->DeviceInfo))); in mptsas_print_device_pg0()
233 ioc->name, le16_to_cpu(pg0->Flags))); in mptsas_print_device_pg0()
235 ioc->name, pg0->PhysicalPort)); in mptsas_print_device_pg0()
241 "---- SAS EXPANDER PAGE 1 ------------\n", ioc->name)); in mptsas_print_expander_pg1()
243 ioc->name, pg1->PhysicalPort)); in mptsas_print_expander_pg1()
245 ioc->name, pg1->PhyIdentifier)); in mptsas_print_expander_pg1()
247 ioc->name, pg1->NegotiatedLinkRate)); in mptsas_print_expander_pg1()
249 ioc->name, pg1->ProgrammedLinkRate)); in mptsas_print_expander_pg1()
251 ioc->name, pg1->HwLinkRate)); in mptsas_print_expander_pg1()
253 ioc->name, le16_to_cpu(pg1->OwnerDevHandle))); in mptsas_print_expander_pg1()
255 "Attached Device Handle=0x%X\n\n", ioc->name, in mptsas_print_expander_pg1()
256 le16_to_cpu(pg1->AttachedDevHandle))); in mptsas_print_expander_pg1()
265 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_fw_event_off()
266 ioc->fw_events_off = 1; in mptsas_fw_event_off()
267 ioc->sas_discovery_quiesce_io = 0; in mptsas_fw_event_off()
268 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_fw_event_off()
278 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_fw_event_on()
279 ioc->fw_events_off = 0; in mptsas_fw_event_on()
280 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_fw_event_on()
290 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_add_fw_event()
291 list_add_tail(&fw_event->list, &ioc->fw_event_list); in mptsas_add_fw_event()
292 fw_event->users = 1; in mptsas_add_fw_event()
293 INIT_DELAYED_WORK(&fw_event->work, mptsas_firmware_event_work); in mptsas_add_fw_event()
295 "on cpuid %d\n", ioc->name, __func__, in mptsas_add_fw_event()
297 queue_delayed_work_on(smp_processor_id(), ioc->fw_event_q, in mptsas_add_fw_event()
298 &fw_event->work, delay); in mptsas_add_fw_event()
299 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_add_fw_event()
308 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_requeue_fw_event()
310 "(fw_event=0x%p)on cpuid %d\n", ioc->name, __func__, in mptsas_requeue_fw_event()
312 fw_event->retries++; in mptsas_requeue_fw_event()
313 queue_delayed_work_on(smp_processor_id(), ioc->fw_event_q, in mptsas_requeue_fw_event()
314 &fw_event->work, msecs_to_jiffies(delay)); in mptsas_requeue_fw_event()
315 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_requeue_fw_event()
322 ioc->name, __func__, fw_event)); in __mptsas_free_fw_event()
323 list_del(&fw_event->list); in __mptsas_free_fw_event()
333 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_free_fw_event()
334 fw_event->users--; in mptsas_free_fw_event()
335 if (!fw_event->users) in mptsas_free_fw_event()
337 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_free_fw_event()
347 MPT_SCSI_HOST *hd = shost_priv(ioc->sh); in mptsas_cleanup_fw_event_q()
351 if (!list_empty(&hd->target_reset_list)) { in mptsas_cleanup_fw_event_q()
353 &hd->target_reset_list, list) { in mptsas_cleanup_fw_event_q()
356 ioc->name, __func__, in mptsas_cleanup_fw_event_q()
357 target_reset_list->sas_event_data.TargetID)); in mptsas_cleanup_fw_event_q()
358 list_del(&target_reset_list->list); in mptsas_cleanup_fw_event_q()
363 if (list_empty(&ioc->fw_event_list) || !ioc->fw_event_q) in mptsas_cleanup_fw_event_q()
366 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_cleanup_fw_event_q()
368 while (!list_empty(&ioc->fw_event_list)) { in mptsas_cleanup_fw_event_q()
371 fw_event = list_first_entry(&ioc->fw_event_list, in mptsas_cleanup_fw_event_q()
373 fw_event->users++; in mptsas_cleanup_fw_event_q()
374 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_cleanup_fw_event_q()
375 if (cancel_delayed_work_sync(&fw_event->work)) in mptsas_cleanup_fw_event_q()
378 spin_lock_irqsave(&ioc->fw_event_lock, flags); in mptsas_cleanup_fw_event_q()
380 fw_event->users--; in mptsas_cleanup_fw_event_q()
381 fw_event->users--; in mptsas_cleanup_fw_event_q()
382 WARN_ON_ONCE(fw_event->users); in mptsas_cleanup_fw_event_q()
385 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); in mptsas_cleanup_fw_event_q()
391 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in phy_to_ioc()
392 return ((MPT_SCSI_HOST *)shost->hostdata)->ioc; in phy_to_ioc()
397 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); in rphy_to_ioc()
398 return ((MPT_SCSI_HOST *)shost->hostdata)->ioc; in rphy_to_ioc()
412 list_for_each_entry(port_info, &ioc->sas_topology, list) in mptsas_find_portinfo_by_handle()
413 for (i = 0; i < port_info->num_phys; i++) in mptsas_find_portinfo_by_handle()
414 if (port_info->phy_info[i].identify.handle == handle) { in mptsas_find_portinfo_by_handle()
423 * mptsas_find_portinfo_by_sas_address - find and return portinfo for
426 * @sas_address: expander sas address
438 if (sas_address >= ioc->hba_port_sas_addr && in mptsas_find_portinfo_by_sas_address()
439 sas_address < (ioc->hba_port_sas_addr + in mptsas_find_portinfo_by_sas_address()
440 ioc->hba_port_num_phy)) in mptsas_find_portinfo_by_sas_address()
441 return ioc->hba_port_info; in mptsas_find_portinfo_by_sas_address()
443 mutex_lock(&ioc->sas_topology_mutex); in mptsas_find_portinfo_by_sas_address()
444 list_for_each_entry(port_info, &ioc->sas_topology, list) in mptsas_find_portinfo_by_sas_address()
445 for (i = 0; i < port_info->num_phys; i++) in mptsas_find_portinfo_by_sas_address()
446 if (port_info->phy_info[i].identify.sas_address == in mptsas_find_portinfo_by_sas_address()
452 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_find_portinfo_by_sas_address()
462 if ((attached->sas_address) && in mptsas_is_end_device()
463 (attached->device_info & in mptsas_is_end_device()
465 ((attached->device_info & in mptsas_is_end_device()
467 (attached->device_info & in mptsas_is_end_device()
469 (attached->device_info & in mptsas_is_end_device()
487 port_info = port_details->port_info; in mptsas_port_delete()
488 phy_info = port_info->phy_info; in mptsas_port_delete()
491 "bitmask=0x%016llX\n", ioc->name, __func__, port_details, in mptsas_port_delete()
492 port_details->num_phys, (unsigned long long) in mptsas_port_delete()
493 port_details->phy_bitmask)); in mptsas_port_delete()
495 for (i = 0; i < port_info->num_phys; i++, phy_info++) { in mptsas_port_delete()
496 if(phy_info->port_details != port_details) in mptsas_port_delete()
498 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); in mptsas_port_delete()
500 phy_info->port_details = NULL; in mptsas_port_delete()
508 if (phy_info->port_details) in mptsas_get_rphy()
509 return phy_info->port_details->rphy; in mptsas_get_rphy()
517 if (phy_info->port_details) { in mptsas_set_rphy()
518 phy_info->port_details->rphy = rphy; in mptsas_set_rphy()
520 ioc->name, rphy)); in mptsas_set_rphy()
525 &rphy->dev, MYIOC_s_FMT "add:", ioc->name)); in mptsas_set_rphy()
527 ioc->name, rphy, rphy->dev.release)); in mptsas_set_rphy()
534 if (phy_info->port_details) in mptsas_get_port()
535 return phy_info->port_details->port; in mptsas_get_port()
543 if (phy_info->port_details) in mptsas_set_port()
544 phy_info->port_details->port = port; in mptsas_set_port()
548 &port->dev, MYIOC_s_FMT "add:", ioc->name)); in mptsas_set_port()
550 ioc->name, port, port->dev.release)); in mptsas_set_port()
557 if (phy_info->port_details) in mptsas_get_starget()
558 return phy_info->port_details->starget; in mptsas_get_starget()
567 if (phy_info->port_details) in mptsas_set_starget()
568 phy_info->port_details->starget = starget; in mptsas_set_starget()
572 * mptsas_add_device_component - adds a new device component to our lists
576 * @sas_address: expander sas address
594 mutex_lock(&ioc->sas_device_info_mutex); in mptsas_add_device_component()
595 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list, in mptsas_add_device_component()
597 if (!sas_info->is_logical_volume && in mptsas_add_device_component()
598 (sas_info->sas_address == sas_address || in mptsas_add_device_component()
599 (sas_info->fw.channel == channel && in mptsas_add_device_component()
600 sas_info->fw.id == id))) { in mptsas_add_device_component()
601 list_del(&sas_info->list); in mptsas_add_device_component()
613 sas_info->fw.id = id; in mptsas_add_device_component()
614 sas_info->fw.channel = channel; in mptsas_add_device_component()
616 sas_info->sas_address = sas_address; in mptsas_add_device_component()
617 sas_info->device_info = device_info; in mptsas_add_device_component()
618 sas_info->slot = slot; in mptsas_add_device_component()
619 sas_info->enclosure_logical_id = enclosure_logical_id; in mptsas_add_device_component()
620 INIT_LIST_HEAD(&sas_info->list); in mptsas_add_device_component()
621 list_add_tail(&sas_info->list, &ioc->sas_device_info_list); in mptsas_add_device_component()
626 shost_for_each_device(sdev, ioc->sh) { in mptsas_add_device_component()
628 rphy = dev_to_rphy(starget->dev.parent); in mptsas_add_device_component()
629 if (rphy->identify.sas_address == sas_address) { in mptsas_add_device_component()
630 sas_info->os.id = starget->id; in mptsas_add_device_component()
631 sas_info->os.channel = starget->channel; in mptsas_add_device_component()
636 mutex_unlock(&ioc->sas_device_info_mutex); in mptsas_add_device_component()
641 * mptsas_add_device_component_by_fw - adds a new device component by FW ID
673 …* mptsas_add_device_component_starget_ir - Handle Integrated RAID, adding each individual device t…
694 cfg.pageAddr = starget->id; in mptsas_add_device_component_starget_ir()
705 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mptsas_add_device_component_starget_ir()
717 if (!buffer->NumPhysDisks) in mptsas_add_device_component_starget_ir()
723 for (i = 0; i < buffer->NumPhysDisks; i++) { in mptsas_add_device_component_starget_ir()
726 buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) in mptsas_add_device_component_starget_ir()
732 mutex_lock(&ioc->sas_device_info_mutex); in mptsas_add_device_component_starget_ir()
733 list_for_each_entry(sas_info, &ioc->sas_device_info_list, in mptsas_add_device_component_starget_ir()
735 if (!sas_info->is_logical_volume && in mptsas_add_device_component_starget_ir()
736 (sas_info->fw.channel == phys_disk.PhysDiskBus && in mptsas_add_device_component_starget_ir()
737 sas_info->fw.id == phys_disk.PhysDiskID)) { in mptsas_add_device_component_starget_ir()
738 sas_info->is_hidden_raid_component = 1; in mptsas_add_device_component_starget_ir()
739 sas_info->volume_id = starget->id; in mptsas_add_device_component_starget_ir()
742 mutex_unlock(&ioc->sas_device_info_mutex); in mptsas_add_device_component_starget_ir()
749 mutex_lock(&ioc->sas_device_info_mutex); in mptsas_add_device_component_starget_ir()
750 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list, in mptsas_add_device_component_starget_ir()
752 if (sas_info->is_logical_volume && sas_info->fw.id == in mptsas_add_device_component_starget_ir()
753 starget->id) { in mptsas_add_device_component_starget_ir()
754 list_del(&sas_info->list); in mptsas_add_device_component_starget_ir()
761 sas_info->fw.id = starget->id; in mptsas_add_device_component_starget_ir()
762 sas_info->os.id = starget->id; in mptsas_add_device_component_starget_ir()
763 sas_info->os.channel = starget->channel; in mptsas_add_device_component_starget_ir()
764 sas_info->is_logical_volume = 1; in mptsas_add_device_component_starget_ir()
765 INIT_LIST_HEAD(&sas_info->list); in mptsas_add_device_component_starget_ir()
766 list_add_tail(&sas_info->list, &ioc->sas_device_info_list); in mptsas_add_device_component_starget_ir()
768 mutex_unlock(&ioc->sas_device_info_mutex); in mptsas_add_device_component_starget_ir()
772 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mptsas_add_device_component_starget_ir()
777 * mptsas_add_device_component_starget - adds a SCSI target device component
790 rphy = dev_to_rphy(starget->dev.parent); in mptsas_add_device_component_starget()
792 rphy->identify.sas_address); in mptsas_add_device_component_starget()
800 phy_info->attached.handle_enclosure); in mptsas_add_device_component_starget()
802 mptsas_add_device_component(ioc, phy_info->attached.channel, in mptsas_add_device_component_starget()
803 phy_info->attached.id, phy_info->attached.sas_address, in mptsas_add_device_component_starget()
804 phy_info->attached.device_info, in mptsas_add_device_component_starget()
805 phy_info->attached.slot, enclosure_info.enclosure_logical_id); in mptsas_add_device_component_starget()
809 …* mptsas_del_device_component_by_os - Once a device has been removed, we mark the entry in the lis…
823 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list, in mptsas_del_device_component_by_os()
825 if (sas_info->os.channel == channel && sas_info->os.id == id) in mptsas_del_device_component_by_os()
826 sas_info->is_cached = 1; in mptsas_del_device_component_by_os()
831 * mptsas_del_device_components - Cleaning the list
840 mutex_lock(&ioc->sas_device_info_mutex); in mptsas_del_device_components()
841 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list, in mptsas_del_device_components()
843 list_del(&sas_info->list); in mptsas_del_device_components()
846 mutex_unlock(&ioc->sas_device_info_mutex); in mptsas_del_device_components()
864 mutex_lock(&ioc->sas_topology_mutex); in mptsas_setup_wide_ports()
866 phy_info = port_info->phy_info; in mptsas_setup_wide_ports()
867 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { in mptsas_setup_wide_ports()
868 if (phy_info->attached.handle) in mptsas_setup_wide_ports()
870 port_details = phy_info->port_details; in mptsas_setup_wide_ports()
873 if (port_details->num_phys < 2) in mptsas_setup_wide_ports()
881 ioc->name, __func__, port_details, i)); in mptsas_setup_wide_ports()
882 port_details->num_phys--; in mptsas_setup_wide_ports()
883 port_details->phy_bitmask &= ~ (1 << phy_info->phy_id); in mptsas_setup_wide_ports()
884 memset(&phy_info->attached, 0, sizeof(struct mptsas_devinfo)); in mptsas_setup_wide_ports()
885 if (phy_info->phy) { in mptsas_setup_wide_ports()
887 &phy_info->phy->dev, MYIOC_s_FMT in mptsas_setup_wide_ports()
888 "delete phy %d, phy-obj (0x%p)\n", ioc->name, in mptsas_setup_wide_ports()
889 phy_info->phy_id, phy_info->phy)); in mptsas_setup_wide_ports()
890 sas_port_delete_phy(port_details->port, phy_info->phy); in mptsas_setup_wide_ports()
892 phy_info->port_details = NULL; in mptsas_setup_wide_ports()
898 phy_info = port_info->phy_info; in mptsas_setup_wide_ports()
899 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { in mptsas_setup_wide_ports()
900 sas_address = phy_info->attached.sas_address; in mptsas_setup_wide_ports()
902 ioc->name, i, (unsigned long long)sas_address)); in mptsas_setup_wide_ports()
905 port_details = phy_info->port_details; in mptsas_setup_wide_ports()
914 port_details->num_phys = 1; in mptsas_setup_wide_ports()
915 port_details->port_info = port_info; in mptsas_setup_wide_ports()
916 if (phy_info->phy_id < 64 ) in mptsas_setup_wide_ports()
917 port_details->phy_bitmask |= in mptsas_setup_wide_ports()
918 (1 << phy_info->phy_id); in mptsas_setup_wide_ports()
919 phy_info->sas_port_add_phy=1; in mptsas_setup_wide_ports()
922 ioc->name, i, (unsigned long long)sas_address)); in mptsas_setup_wide_ports()
923 phy_info->port_details = port_details; in mptsas_setup_wide_ports()
926 if (i == port_info->num_phys - 1) in mptsas_setup_wide_ports()
928 phy_info_cmp = &port_info->phy_info[i + 1]; in mptsas_setup_wide_ports()
929 for (j = i + 1 ; j < port_info->num_phys ; j++, in mptsas_setup_wide_ports()
931 if (!phy_info_cmp->attached.sas_address) in mptsas_setup_wide_ports()
933 if (sas_address != phy_info_cmp->attached.sas_address) in mptsas_setup_wide_ports()
935 if (phy_info_cmp->port_details == port_details ) in mptsas_setup_wide_ports()
939 ioc->name, j, (unsigned long long) in mptsas_setup_wide_ports()
940 phy_info_cmp->attached.sas_address)); in mptsas_setup_wide_ports()
941 if (phy_info_cmp->port_details) { in mptsas_setup_wide_ports()
942 port_details->rphy = in mptsas_setup_wide_ports()
944 port_details->port = in mptsas_setup_wide_ports()
946 port_details->starget = in mptsas_setup_wide_ports()
948 port_details->num_phys = in mptsas_setup_wide_ports()
949 phy_info_cmp->port_details->num_phys; in mptsas_setup_wide_ports()
950 if (!phy_info_cmp->port_details->num_phys) in mptsas_setup_wide_ports()
951 kfree(phy_info_cmp->port_details); in mptsas_setup_wide_ports()
953 phy_info_cmp->sas_port_add_phy=1; in mptsas_setup_wide_ports()
957 phy_info_cmp->port_details = port_details; in mptsas_setup_wide_ports()
958 if (phy_info_cmp->phy_id < 64 ) in mptsas_setup_wide_ports()
959 port_details->phy_bitmask |= in mptsas_setup_wide_ports()
960 (1 << phy_info_cmp->phy_id); in mptsas_setup_wide_ports()
961 port_details->num_phys++; in mptsas_setup_wide_ports()
967 for (i = 0; i < port_info->num_phys; i++) { in mptsas_setup_wide_ports()
968 port_details = port_info->phy_info[i].port_details; in mptsas_setup_wide_ports()
973 "bitmask=0x%016llX\n", ioc->name, __func__, in mptsas_setup_wide_ports()
974 port_details, i, port_details->num_phys, in mptsas_setup_wide_ports()
975 (unsigned long long)port_details->phy_bitmask)); in mptsas_setup_wide_ports()
977 ioc->name, port_details->port, port_details->rphy)); in mptsas_setup_wide_ports()
980 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_setup_wide_ports()
984 * mptsas_find_vtarget - find a virtual target device (FC LUN device or
999 shost_for_each_device(sdev, ioc->sh) { in mptsas_find_vtarget()
1000 vdevice = sdev->hostdata; in mptsas_find_vtarget()
1002 (vdevice->vtarget == NULL)) in mptsas_find_vtarget()
1004 if ((vdevice->vtarget->tflags & in mptsas_find_vtarget()
1006 vdevice->vtarget->raidVolume)) in mptsas_find_vtarget()
1008 if (vdevice->vtarget->id == id && in mptsas_find_vtarget()
1009 vdevice->vtarget->channel == channel) in mptsas_find_vtarget()
1010 vtarget = vdevice->vtarget; in mptsas_find_vtarget()
1026 ioc->name, __func__, __LINE__); in mptsas_queue_device_delete()
1029 memcpy(fw_event->event_data, sas_event_data, in mptsas_queue_device_delete()
1031 fw_event->event = MPI_EVENT_SAS_DEVICE_STATUS_CHANGE; in mptsas_queue_device_delete()
1032 fw_event->ioc = ioc; in mptsas_queue_device_delete()
1044 ioc->name, __func__, __LINE__); in mptsas_queue_rescan()
1047 fw_event->event = -1; in mptsas_queue_rescan()
1048 fw_event->ioc = ioc; in mptsas_queue_rescan()
1054 * mptsas_target_reset - Issues TARGET_RESET to end device using
1077 "%s, no msg frames @%d!!\n", ioc->name, in mptsas_target_reset()
1083 ioc->name, mf)); in mptsas_target_reset()
1089 pScsiTm->TargetID = id; in mptsas_target_reset()
1090 pScsiTm->Bus = channel; in mptsas_target_reset()
1091 pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT; in mptsas_target_reset()
1092 pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET; in mptsas_target_reset()
1093 pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION; in mptsas_target_reset()
1099 ioc->name, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, channel, id)); in mptsas_target_reset()
1125 * mptsas_target_reset_queue - queue a target reset
1139 MPT_SCSI_HOST *hd = shost_priv(ioc->sh); in mptsas_target_reset_queue()
1144 id = sas_event_data->TargetID; in mptsas_target_reset_queue()
1145 channel = sas_event_data->Bus; in mptsas_target_reset_queue()
1149 mptsas_block_io_starget(vtarget->starget); in mptsas_target_reset_queue()
1150 vtarget->deleted = 1; /* block IO */ in mptsas_target_reset_queue()
1158 ioc->name, __func__, __LINE__)); in mptsas_target_reset_queue()
1162 memcpy(&target_reset_list->sas_event_data, sas_event_data, in mptsas_target_reset_queue()
1164 list_add_tail(&target_reset_list->list, &hd->target_reset_list); in mptsas_target_reset_queue()
1166 target_reset_list->time_count = jiffies; in mptsas_target_reset_queue()
1169 target_reset_list->target_reset_issued = 1; in mptsas_target_reset_queue()
1174 * mptsas_schedule_target_reset- send pending target reset
1186 MPT_SCSI_HOST *hd = shost_priv(ioc->sh); in mptsas_schedule_target_reset()
1187 struct list_head *head = &hd->target_reset_list; in mptsas_schedule_target_reset()
1197 target_reset_list = list_entry(head->next, in mptsas_schedule_target_reset()
1200 id = target_reset_list->sas_event_data.TargetID; in mptsas_schedule_target_reset()
1201 channel = target_reset_list->sas_event_data.Bus; in mptsas_schedule_target_reset()
1202 target_reset_list->time_count = jiffies; in mptsas_schedule_target_reset()
1205 target_reset_list->target_reset_issued = 1; in mptsas_schedule_target_reset()
1211 * mptsas_taskmgmt_complete - complete SAS task management function
1223 MPT_SCSI_HOST *hd = shost_priv(ioc->sh); in mptsas_taskmgmt_complete()
1224 struct list_head *head = &hd->target_reset_list; in mptsas_taskmgmt_complete()
1230 "(mf = %p, mr = %p)\n", ioc->name, mf, mr)); in mptsas_taskmgmt_complete()
1240 "term_cmnds = %d\n", ioc->name, in mptsas_taskmgmt_complete()
1241 pScsiTmReply->Bus, pScsiTmReply->TargetID, in mptsas_taskmgmt_complete()
1242 pScsiTmReply->TaskType, in mptsas_taskmgmt_complete()
1243 le16_to_cpu(pScsiTmReply->IOCStatus), in mptsas_taskmgmt_complete()
1244 le32_to_cpu(pScsiTmReply->IOCLogInfo), in mptsas_taskmgmt_complete()
1245 pScsiTmReply->ResponseCode, in mptsas_taskmgmt_complete()
1246 le32_to_cpu(pScsiTmReply->TerminationCount))); in mptsas_taskmgmt_complete()
1248 if (pScsiTmReply->ResponseCode) in mptsas_taskmgmt_complete()
1250 pScsiTmReply->ResponseCode); in mptsas_taskmgmt_complete()
1252 if (pScsiTmReply->TaskType == in mptsas_taskmgmt_complete()
1253 MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK || pScsiTmReply->TaskType == in mptsas_taskmgmt_complete()
1255 ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD; in mptsas_taskmgmt_complete()
1256 ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_RF_VALID; in mptsas_taskmgmt_complete()
1257 memcpy(ioc->taskmgmt_cmds.reply, mr, in mptsas_taskmgmt_complete()
1258 min(MPT_DEFAULT_FRAME_SIZE, 4 * mr->u.reply.MsgLength)); in mptsas_taskmgmt_complete()
1259 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) { in mptsas_taskmgmt_complete()
1260 ioc->taskmgmt_cmds.status &= ~MPT_MGMT_STATUS_PENDING; in mptsas_taskmgmt_complete()
1261 complete(&ioc->taskmgmt_cmds.done); in mptsas_taskmgmt_complete()
1272 target_reset_list = list_entry(head->next, in mptsas_taskmgmt_complete()
1277 ioc->name, jiffies_to_msecs(jiffies - in mptsas_taskmgmt_complete()
1278 target_reset_list->time_count)/1000)); in mptsas_taskmgmt_complete()
1280 id = pScsiTmReply->TargetID; in mptsas_taskmgmt_complete()
1281 channel = pScsiTmReply->Bus; in mptsas_taskmgmt_complete()
1282 target_reset_list->time_count = jiffies; in mptsas_taskmgmt_complete()
1287 if (!target_reset_list->target_reset_issued) { in mptsas_taskmgmt_complete()
1289 target_reset_list->target_reset_issued = 1; in mptsas_taskmgmt_complete()
1296 list_del(&target_reset_list->list); in mptsas_taskmgmt_complete()
1297 if (!ioc->fw_events_off) in mptsas_taskmgmt_complete()
1299 &target_reset_list->sas_event_data); in mptsas_taskmgmt_complete()
1302 ioc->schedule_target_reset(ioc); in mptsas_taskmgmt_complete()
1308 * mptsas_ioc_reset - issue an IOC reset for this reset phase
1321 if ((ioc->bus_type != SAS) || (!rc)) in mptsas_ioc_reset()
1324 hd = shost_priv(ioc->sh); in mptsas_ioc_reset()
1325 if (!hd->ioc) in mptsas_ioc_reset()
1331 "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__)); in mptsas_ioc_reset()
1336 "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__)); in mptsas_ioc_reset()
1340 "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__)); in mptsas_ioc_reset()
1341 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) { in mptsas_ioc_reset()
1342 ioc->sas_mgmt.status |= MPT_MGMT_STATUS_DID_IOCRESET; in mptsas_ioc_reset()
1343 complete(&ioc->sas_mgmt.done); in mptsas_ioc_reset()
1358 * enum device_state - TUR device state
1388 cfg.physAddr = -1; in mptsas_sas_enclosure_pg0()
1398 error = -ENXIO; in mptsas_sas_enclosure_pg0()
1402 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_enclosure_pg0()
1405 error = -ENOMEM; in mptsas_sas_enclosure_pg0()
1417 memcpy(&le_identifier, &buffer->EnclosureLogicalID, sizeof(__le64)); in mptsas_sas_enclosure_pg0()
1418 enclosure->enclosure_logical_id = le64_to_cpu(le_identifier); in mptsas_sas_enclosure_pg0()
1419 enclosure->enclosure_handle = le16_to_cpu(buffer->EnclosureHandle); in mptsas_sas_enclosure_pg0()
1420 enclosure->flags = le16_to_cpu(buffer->Flags); in mptsas_sas_enclosure_pg0()
1421 enclosure->num_slot = le16_to_cpu(buffer->NumSlots); in mptsas_sas_enclosure_pg0()
1422 enclosure->start_slot = le16_to_cpu(buffer->StartSlot); in mptsas_sas_enclosure_pg0()
1423 enclosure->start_id = buffer->StartTargetID; in mptsas_sas_enclosure_pg0()
1424 enclosure->start_channel = buffer->StartBus; in mptsas_sas_enclosure_pg0()
1425 enclosure->sep_id = buffer->SEPTargetID; in mptsas_sas_enclosure_pg0()
1426 enclosure->sep_channel = buffer->SEPBus; in mptsas_sas_enclosure_pg0()
1429 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_enclosure_pg0()
1436 * mptsas_add_end_device - report a new end device to sas transport layer
1454 "%s: exit at line=%d\n", ioc->name, in mptsas_add_end_device()
1459 fw_id = phy_info->attached.id; in mptsas_add_end_device()
1463 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_add_end_device()
1471 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_add_end_device()
1476 if (phy_info->attached.device_info & in mptsas_add_end_device()
1479 if (phy_info->attached.device_info & in mptsas_add_end_device()
1482 if (phy_info->attached.device_info & in mptsas_add_end_device()
1487 " phy %d, sas_addr 0x%llx\n", ioc->name, ds, in mptsas_add_end_device()
1488 phy_info->attached.channel, phy_info->attached.id, in mptsas_add_end_device()
1489 phy_info->attached.phy_id, (unsigned long long) in mptsas_add_end_device()
1490 phy_info->attached.sas_address); in mptsas_add_end_device()
1492 mptsas_parse_device_info(&identify, &phy_info->attached); in mptsas_add_end_device()
1496 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_add_end_device()
1498 return 5; /* non-fatal: an rphy can be added later */ in mptsas_add_end_device()
1501 rphy->identify = identify; in mptsas_add_end_device()
1504 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_add_end_device()
1514 * mptsas_del_end_device - report a deleted end device to sas transport layer
1534 fw_id = phy_info->attached.id; in mptsas_del_end_device()
1535 sas_address = phy_info->attached.sas_address; in mptsas_del_end_device()
1537 if (!phy_info->port_details) { in mptsas_del_end_device()
1539 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_del_end_device()
1546 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_del_end_device()
1551 if (phy_info->attached.device_info & MPI_SAS_DEVICE_INFO_SSP_INITIATOR in mptsas_del_end_device()
1552 || phy_info->attached.device_info in mptsas_del_end_device()
1554 || phy_info->attached.device_info in mptsas_del_end_device()
1557 if (phy_info->attached.device_info & in mptsas_del_end_device()
1560 if (phy_info->attached.device_info & in mptsas_del_end_device()
1563 if (phy_info->attached.device_info & in mptsas_del_end_device()
1567 dev_printk(KERN_DEBUG, &rphy->dev, MYIOC_s_FMT in mptsas_del_end_device()
1569 "sas_addr 0x%llx\n", ioc->name, ds, phy_info->attached.channel, in mptsas_del_end_device()
1570 phy_info->attached.id, phy_info->attached.phy_id, in mptsas_del_end_device()
1576 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_del_end_device()
1580 port_info = phy_info->portinfo; in mptsas_del_end_device()
1581 phy_info_parent = port_info->phy_info; in mptsas_del_end_device()
1582 for (i = 0; i < port_info->num_phys; i++, phy_info_parent++) { in mptsas_del_end_device()
1583 if (!phy_info_parent->phy) in mptsas_del_end_device()
1585 if (phy_info_parent->attached.sas_address != in mptsas_del_end_device()
1588 dev_printk(KERN_DEBUG, &phy_info_parent->phy->dev, in mptsas_del_end_device()
1589 MYIOC_s_FMT "delete phy %d, phy-obj (0x%p)\n", in mptsas_del_end_device()
1590 ioc->name, phy_info_parent->phy_id, in mptsas_del_end_device()
1591 phy_info_parent->phy); in mptsas_del_end_device()
1592 sas_port_delete_phy(port, phy_info_parent->phy); in mptsas_del_end_device()
1595 dev_printk(KERN_DEBUG, &port->dev, MYIOC_s_FMT in mptsas_del_end_device()
1596 "delete port %d, sas_addr (0x%llx)\n", ioc->name, in mptsas_del_end_device()
1597 port->port_identifier, (unsigned long long)sas_address); in mptsas_del_end_device()
1600 mptsas_port_delete(ioc, phy_info->port_details); in mptsas_del_end_device()
1612 sas_device->sas_address); in mptsas_refreshing_device_handles()
1615 port_info = phy_info->portinfo; in mptsas_refreshing_device_handles()
1618 mutex_lock(&ioc->sas_topology_mutex); in mptsas_refreshing_device_handles()
1619 for (i = 0; i < port_info->num_phys; i++) { in mptsas_refreshing_device_handles()
1620 if (port_info->phy_info[i].attached.sas_address != in mptsas_refreshing_device_handles()
1621 sas_device->sas_address) in mptsas_refreshing_device_handles()
1623 port_info->phy_info[i].attached.channel = sas_device->channel; in mptsas_refreshing_device_handles()
1624 port_info->phy_info[i].attached.id = sas_device->id; in mptsas_refreshing_device_handles()
1625 port_info->phy_info[i].attached.sas_address = in mptsas_refreshing_device_handles()
1626 sas_device->sas_address; in mptsas_refreshing_device_handles()
1627 port_info->phy_info[i].attached.handle = sas_device->handle; in mptsas_refreshing_device_handles()
1628 port_info->phy_info[i].attached.handle_parent = in mptsas_refreshing_device_handles()
1629 sas_device->handle_parent; in mptsas_refreshing_device_handles()
1630 port_info->phy_info[i].attached.handle_enclosure = in mptsas_refreshing_device_handles()
1631 sas_device->handle_enclosure; in mptsas_refreshing_device_handles()
1633 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_refreshing_device_handles()
1639 * mptsas_firmware_event_work - work thread for processing fw events
1649 MPT_ADAPTER *ioc = fw_event->ioc; in mptsas_firmware_event_work()
1652 if (fw_event->event == -1) { in mptsas_firmware_event_work()
1653 if (ioc->in_rescan) { in mptsas_firmware_event_work()
1656 ioc->name, __func__)); in mptsas_firmware_event_work()
1660 "reset\n", ioc->name, __func__)); in mptsas_firmware_event_work()
1661 ioc->in_rescan = 1; in mptsas_firmware_event_work()
1664 ioc->in_rescan = 0; in mptsas_firmware_event_work()
1671 if (ioc->fw_events_off) { in mptsas_firmware_event_work()
1677 "event = (0x%02x)\n", ioc->name, __func__, fw_event, in mptsas_firmware_event_work()
1678 (fw_event->event & 0xFF))); in mptsas_firmware_event_work()
1680 switch (fw_event->event) { in mptsas_firmware_event_work()
1715 struct Scsi_Host *host = sdev->host; in mptsas_slave_configure()
1717 MPT_ADAPTER *ioc = hd->ioc; in mptsas_slave_configure()
1718 VirtDevice *vdevice = sdev->hostdata; in mptsas_slave_configure()
1720 if (vdevice->vtarget->deleted) { in mptsas_slave_configure()
1722 vdevice->vtarget->deleted = 0; in mptsas_slave_configure()
1729 if (sdev->channel == MPTSAS_RAID_CHANNEL) { in mptsas_slave_configure()
1745 struct Scsi_Host *host = dev_to_shost(&starget->dev); in mptsas_target_alloc()
1752 MPT_ADAPTER *ioc = hd->ioc; in mptsas_target_alloc()
1756 return -ENOMEM; in mptsas_target_alloc()
1758 vtarget->starget = starget; in mptsas_target_alloc()
1759 vtarget->ioc_id = ioc->id; in mptsas_target_alloc()
1760 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; in mptsas_target_alloc()
1761 id = starget->id; in mptsas_target_alloc()
1767 if (starget->channel == MPTSAS_RAID_CHANNEL) { in mptsas_target_alloc()
1768 if (!ioc->raid_data.pIocPg2) { in mptsas_target_alloc()
1770 return -ENXIO; in mptsas_target_alloc()
1772 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { in mptsas_target_alloc()
1773 if (id == ioc->raid_data.pIocPg2-> in mptsas_target_alloc()
1775 channel = ioc->raid_data.pIocPg2-> in mptsas_target_alloc()
1779 vtarget->raidVolume = 1; in mptsas_target_alloc()
1783 rphy = dev_to_rphy(starget->dev.parent); in mptsas_target_alloc()
1784 mutex_lock(&ioc->sas_topology_mutex); in mptsas_target_alloc()
1785 list_for_each_entry(p, &ioc->sas_topology, list) { in mptsas_target_alloc()
1786 for (i = 0; i < p->num_phys; i++) { in mptsas_target_alloc()
1787 if (p->phy_info[i].attached.sas_address != in mptsas_target_alloc()
1788 rphy->identify.sas_address) in mptsas_target_alloc()
1790 id = p->phy_info[i].attached.id; in mptsas_target_alloc()
1791 channel = p->phy_info[i].attached.channel; in mptsas_target_alloc()
1792 mptsas_set_starget(&p->phy_info[i], starget); in mptsas_target_alloc()
1800 vtarget->tflags |= in mptsas_target_alloc()
1802 p->phy_info[i].attached.phys_disk_num = id; in mptsas_target_alloc()
1804 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_target_alloc()
1808 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_target_alloc()
1811 return -ENXIO; in mptsas_target_alloc()
1814 vtarget->id = id; in mptsas_target_alloc()
1815 vtarget->channel = channel; in mptsas_target_alloc()
1816 starget->hostdata = vtarget; in mptsas_target_alloc()
1823 struct Scsi_Host *host = dev_to_shost(&starget->dev); in mptsas_target_destroy()
1828 MPT_ADAPTER *ioc = hd->ioc; in mptsas_target_destroy()
1831 if (!starget->hostdata) in mptsas_target_destroy()
1834 vtarget = starget->hostdata; in mptsas_target_destroy()
1836 mptsas_del_device_component_by_os(ioc, starget->channel, in mptsas_target_destroy()
1837 starget->id); in mptsas_target_destroy()
1840 if (starget->channel == MPTSAS_RAID_CHANNEL) in mptsas_target_destroy()
1843 rphy = dev_to_rphy(starget->dev.parent); in mptsas_target_destroy()
1844 list_for_each_entry(p, &ioc->sas_topology, list) { in mptsas_target_destroy()
1845 for (i = 0; i < p->num_phys; i++) { in mptsas_target_destroy()
1846 if (p->phy_info[i].attached.sas_address != in mptsas_target_destroy()
1847 rphy->identify.sas_address) in mptsas_target_destroy()
1852 "sas_addr 0x%llx\n", ioc->name, in mptsas_target_destroy()
1853 p->phy_info[i].attached.channel, in mptsas_target_destroy()
1854 p->phy_info[i].attached.id, in mptsas_target_destroy()
1855 p->phy_info[i].attached.phy_id, (unsigned long long) in mptsas_target_destroy()
1856 p->phy_info[i].attached.sas_address); in mptsas_target_destroy()
1858 mptsas_set_starget(&p->phy_info[i], NULL); in mptsas_target_destroy()
1863 vtarget->starget = NULL; in mptsas_target_destroy()
1864 kfree(starget->hostdata); in mptsas_target_destroy()
1865 starget->hostdata = NULL; in mptsas_target_destroy()
1872 struct Scsi_Host *host = sdev->host; in mptsas_slave_alloc()
1879 MPT_ADAPTER *ioc = hd->ioc; in mptsas_slave_alloc()
1884 ioc->name, sizeof(VirtDevice)); in mptsas_slave_alloc()
1885 return -ENOMEM; in mptsas_slave_alloc()
1888 vdevice->vtarget = starget->hostdata; in mptsas_slave_alloc()
1890 if (sdev->channel == MPTSAS_RAID_CHANNEL) in mptsas_slave_alloc()
1893 rphy = dev_to_rphy(sdev->sdev_target->dev.parent); in mptsas_slave_alloc()
1894 mutex_lock(&ioc->sas_topology_mutex); in mptsas_slave_alloc()
1895 list_for_each_entry(p, &ioc->sas_topology, list) { in mptsas_slave_alloc()
1896 for (i = 0; i < p->num_phys; i++) { in mptsas_slave_alloc()
1897 if (p->phy_info[i].attached.sas_address != in mptsas_slave_alloc()
1898 rphy->identify.sas_address) in mptsas_slave_alloc()
1900 vdevice->lun = sdev->lun; in mptsas_slave_alloc()
1905 p->phy_info[i].attached.channel, in mptsas_slave_alloc()
1906 p->phy_info[i].attached.id)) in mptsas_slave_alloc()
1907 sdev->no_uld_attach = 1; in mptsas_slave_alloc()
1908 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_slave_alloc()
1912 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_slave_alloc()
1915 return -ENXIO; in mptsas_slave_alloc()
1918 vdevice->vtarget->num_luns++; in mptsas_slave_alloc()
1919 sdev->hostdata = vdevice; in mptsas_slave_alloc()
1928 VirtDevice *vdevice = SCpnt->device->hostdata; in mptsas_qcmd()
1930 if (!vdevice || !vdevice->vtarget || vdevice->vtarget->deleted) { in mptsas_qcmd()
1931 SCpnt->result = DID_NO_CONNECT << 16; in mptsas_qcmd()
1937 ioc = hd->ioc; in mptsas_qcmd()
1939 if (ioc->sas_discovery_quiesce_io) in mptsas_qcmd()
1942 if (ioc->debug_level & MPT_DEBUG_SCSI) in mptsas_qcmd()
1949 * mptsas_eh_timed_out - resets the scsi_cmnd timeout
1962 hd = shost_priv(sc->device->host); in mptsas_eh_timed_out()
1969 ioc = hd->ioc; in mptsas_eh_timed_out()
1970 if (ioc->bus_type != SAS) { in mptsas_eh_timed_out()
1979 if (ioc->ioc_reset_in_progress) { in mptsas_eh_timed_out()
1982 ioc->name, __func__, sc)); in mptsas_eh_timed_out()
1985 vdevice = sc->device->hostdata; in mptsas_eh_timed_out()
1986 if (vdevice && vdevice->vtarget && (vdevice->vtarget->inDMD in mptsas_eh_timed_out()
1987 || vdevice->vtarget->deleted)) { in mptsas_eh_timed_out()
1990 ioc->name, __func__, sc)); in mptsas_eh_timed_out()
2019 .this_id = -1,
2039 return -EINVAL; in mptsas_get_linkerrors()
2050 cfg.physAddr = -1; in mptsas_get_linkerrors()
2051 cfg.pageAddr = phy->identify.phy_identifier; in mptsas_get_linkerrors()
2060 return -ENXIO; in mptsas_get_linkerrors()
2062 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_get_linkerrors()
2065 return -ENOMEM; in mptsas_get_linkerrors()
2076 phy->invalid_dword_count = le32_to_cpu(buffer->InvalidDwordCount); in mptsas_get_linkerrors()
2077 phy->running_disparity_error_count = in mptsas_get_linkerrors()
2078 le32_to_cpu(buffer->RunningDisparityErrorCount); in mptsas_get_linkerrors()
2079 phy->loss_of_dword_sync_count = in mptsas_get_linkerrors()
2080 le32_to_cpu(buffer->LossDwordSynchCount); in mptsas_get_linkerrors()
2081 phy->phy_reset_problem_count = in mptsas_get_linkerrors()
2082 le32_to_cpu(buffer->PhyResetProblemCount); in mptsas_get_linkerrors()
2085 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_get_linkerrors()
2093 ioc->sas_mgmt.status |= MPT_MGMT_STATUS_COMMAND_GOOD; in mptsas_mgmt_done()
2095 ioc->sas_mgmt.status |= MPT_MGMT_STATUS_RF_VALID; in mptsas_mgmt_done()
2096 memcpy(ioc->sas_mgmt.reply, reply, in mptsas_mgmt_done()
2097 min(ioc->reply_sz, 4 * reply->u.reply.MsgLength)); in mptsas_mgmt_done()
2100 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) { in mptsas_mgmt_done()
2101 ioc->sas_mgmt.status &= ~MPT_MGMT_STATUS_PENDING; in mptsas_mgmt_done()
2102 complete(&ioc->sas_mgmt.done); in mptsas_mgmt_done()
2116 int error = -ERESTARTSYS; in mptsas_phy_reset()
2118 /* FIXME: fusion doesn't allow non-local phy reset */ in mptsas_phy_reset()
2120 return -EINVAL; in mptsas_phy_reset()
2123 if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP) in mptsas_phy_reset()
2124 return -ENXIO; in mptsas_phy_reset()
2126 if (mutex_lock_interruptible(&ioc->sas_mgmt.mutex)) in mptsas_phy_reset()
2131 error = -ENOMEM; in mptsas_phy_reset()
2138 req->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL; in mptsas_phy_reset()
2139 req->MsgContext = hdr->MsgContext; in mptsas_phy_reset()
2140 req->Operation = hard_reset ? in mptsas_phy_reset()
2142 req->PhyNum = phy->identify.phy_identifier; in mptsas_phy_reset()
2144 INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status) in mptsas_phy_reset()
2147 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, in mptsas_phy_reset()
2149 if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptsas_phy_reset()
2150 error = -ETIME; in mptsas_phy_reset()
2152 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptsas_phy_reset()
2160 if ((ioc->sas_mgmt.status & in mptsas_phy_reset()
2162 error = -ENXIO; in mptsas_phy_reset()
2167 reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply; in mptsas_phy_reset()
2168 if (reply->IOCStatus != MPI_IOCSTATUS_SUCCESS) { in mptsas_phy_reset()
2170 ioc->name, __func__, reply->IOCStatus, reply->IOCLogInfo); in mptsas_phy_reset()
2171 error = -ENXIO; in mptsas_phy_reset()
2178 CLEAR_MGMT_STATUS(ioc->sas_mgmt.status) in mptsas_phy_reset()
2179 mutex_unlock(&ioc->sas_mgmt.mutex); in mptsas_phy_reset()
2193 mutex_lock(&ioc->sas_topology_mutex); in mptsas_get_enclosure_identifier()
2194 list_for_each_entry(p, &ioc->sas_topology, list) { in mptsas_get_enclosure_identifier()
2195 for (i = 0; i < p->num_phys; i++) { in mptsas_get_enclosure_identifier()
2196 if (p->phy_info[i].attached.sas_address == in mptsas_get_enclosure_identifier()
2197 rphy->identify.sas_address) { in mptsas_get_enclosure_identifier()
2198 enclosure_handle = p->phy_info[i]. in mptsas_get_enclosure_identifier()
2204 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_get_enclosure_identifier()
2205 return -ENXIO; in mptsas_get_enclosure_identifier()
2208 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_get_enclosure_identifier()
2225 mutex_lock(&ioc->sas_topology_mutex); in mptsas_get_bay_identifier()
2226 list_for_each_entry(p, &ioc->sas_topology, list) { in mptsas_get_bay_identifier()
2227 for (i = 0; i < p->num_phys; i++) { in mptsas_get_bay_identifier()
2228 if (p->phy_info[i].attached.sas_address == in mptsas_get_bay_identifier()
2229 rphy->identify.sas_address) { in mptsas_get_bay_identifier()
2230 rc = p->phy_info[i].attached.slot; in mptsas_get_bay_identifier()
2235 rc = -ENXIO; in mptsas_get_bay_identifier()
2237 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_get_bay_identifier()
2244 MPT_ADAPTER *ioc = ((MPT_SCSI_HOST *) shost->hostdata)->ioc; in mptsas_smp_handler()
2252 int ret = -EINVAL; in mptsas_smp_handler()
2255 if (job->request_payload.sg_cnt > 1 || in mptsas_smp_handler()
2256 job->reply_payload.sg_cnt > 1) { in mptsas_smp_handler()
2258 ioc->name, __func__, job->request_payload.payload_len, in mptsas_smp_handler()
2259 job->reply_payload.payload_len); in mptsas_smp_handler()
2263 ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex); in mptsas_smp_handler()
2269 ret = -ENOMEM; in mptsas_smp_handler()
2276 smpreq->RequestDataLength = in mptsas_smp_handler()
2277 cpu_to_le16(job->request_payload.payload_len - 4); in mptsas_smp_handler()
2278 smpreq->Function = MPI_FUNCTION_SMP_PASSTHROUGH; in mptsas_smp_handler()
2281 sas_address = rphy->identify.sas_address; in mptsas_smp_handler()
2285 mutex_lock(&ioc->sas_topology_mutex); in mptsas_smp_handler()
2286 port_info = ioc->hba_port_info; in mptsas_smp_handler()
2287 if (port_info && port_info->phy_info) in mptsas_smp_handler()
2289 port_info->phy_info[0].phy->identify.sas_address; in mptsas_smp_handler()
2290 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_smp_handler()
2293 *((u64 *)&smpreq->SASAddress) = cpu_to_le64(sas_address); in mptsas_smp_handler()
2304 if (!dma_map_sg(&ioc->pcidev->dev, job->request_payload.sg_list, in mptsas_smp_handler()
2308 flagsLength |= (sg_dma_len(job->request_payload.sg_list) - 4); in mptsas_smp_handler()
2309 ioc->add_sge(psge, flagsLength, in mptsas_smp_handler()
2310 sg_dma_address(job->request_payload.sg_list)); in mptsas_smp_handler()
2311 psge += ioc->SGE_size; in mptsas_smp_handler()
2321 if (!dma_map_sg(&ioc->pcidev->dev, job->reply_payload.sg_list, in mptsas_smp_handler()
2324 flagsLength |= sg_dma_len(job->reply_payload.sg_list) + 4; in mptsas_smp_handler()
2325 ioc->add_sge(psge, flagsLength, in mptsas_smp_handler()
2326 sg_dma_address(job->reply_payload.sg_list)); in mptsas_smp_handler()
2328 INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status) in mptsas_smp_handler()
2331 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); in mptsas_smp_handler()
2332 if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptsas_smp_handler()
2333 ret = -ETIME; in mptsas_smp_handler()
2336 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptsas_smp_handler()
2344 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_RF_VALID) { in mptsas_smp_handler()
2347 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply; in mptsas_smp_handler()
2348 memcpy(job->reply, smprep, sizeof(*smprep)); in mptsas_smp_handler()
2349 job->reply_len = sizeof(*smprep); in mptsas_smp_handler()
2350 reslen = smprep->ResponseDataLength; in mptsas_smp_handler()
2354 ioc->name, __func__); in mptsas_smp_handler()
2355 ret = -ENXIO; in mptsas_smp_handler()
2359 dma_unmap_sg(&ioc->pcidev->dev, job->reply_payload.sg_list, 1, in mptsas_smp_handler()
2362 dma_unmap_sg(&ioc->pcidev->dev, job->request_payload.sg_list, 1, in mptsas_smp_handler()
2368 CLEAR_MGMT_STATUS(ioc->sas_mgmt.status) in mptsas_smp_handler()
2369 mutex_unlock(&ioc->sas_mgmt.mutex); in mptsas_smp_handler()
2402 cfg.physAddr = -1; in mptsas_sas_io_unit_pg0()
2412 error = -ENXIO; in mptsas_sas_io_unit_pg0()
2416 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_io_unit_pg0()
2419 error = -ENOMEM; in mptsas_sas_io_unit_pg0()
2430 port_info->num_phys = buffer->NumPhys; in mptsas_sas_io_unit_pg0()
2431 port_info->phy_info = kcalloc(port_info->num_phys, in mptsas_sas_io_unit_pg0()
2433 if (!port_info->phy_info) { in mptsas_sas_io_unit_pg0()
2434 error = -ENOMEM; in mptsas_sas_io_unit_pg0()
2438 ioc->nvdata_version_persistent = in mptsas_sas_io_unit_pg0()
2439 le16_to_cpu(buffer->NvdataVersionPersistent); in mptsas_sas_io_unit_pg0()
2440 ioc->nvdata_version_default = in mptsas_sas_io_unit_pg0()
2441 le16_to_cpu(buffer->NvdataVersionDefault); in mptsas_sas_io_unit_pg0()
2443 for (i = 0; i < port_info->num_phys; i++) { in mptsas_sas_io_unit_pg0()
2444 mptsas_print_phy_data(ioc, &buffer->PhyData[i]); in mptsas_sas_io_unit_pg0()
2445 port_info->phy_info[i].phy_id = i; in mptsas_sas_io_unit_pg0()
2446 port_info->phy_info[i].port_id = in mptsas_sas_io_unit_pg0()
2447 buffer->PhyData[i].Port; in mptsas_sas_io_unit_pg0()
2448 port_info->phy_info[i].negotiated_link_rate = in mptsas_sas_io_unit_pg0()
2449 buffer->PhyData[i].NegotiatedLinkRate; in mptsas_sas_io_unit_pg0()
2450 port_info->phy_info[i].portinfo = port_info; in mptsas_sas_io_unit_pg0()
2451 port_info->phy_info[i].handle = in mptsas_sas_io_unit_pg0()
2452 le16_to_cpu(buffer->PhyData[i].ControllerDevHandle); in mptsas_sas_io_unit_pg0()
2456 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_io_unit_pg0()
2478 cfg.cfghdr.ehdr->PageType = MPI_CONFIG_PAGETYPE_EXTENDED; in mptsas_sas_io_unit_pg1()
2479 cfg.cfghdr.ehdr->ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT; in mptsas_sas_io_unit_pg1()
2480 cfg.cfghdr.ehdr->PageVersion = MPI_SASIOUNITPAGE1_PAGEVERSION; in mptsas_sas_io_unit_pg1()
2481 cfg.cfghdr.ehdr->PageNumber = 1; in mptsas_sas_io_unit_pg1()
2487 error = -ENXIO; in mptsas_sas_io_unit_pg1()
2491 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_io_unit_pg1()
2494 error = -ENOMEM; in mptsas_sas_io_unit_pg1()
2505 ioc->io_missing_delay = in mptsas_sas_io_unit_pg1()
2506 le16_to_cpu(buffer->IODeviceMissingDelay); in mptsas_sas_io_unit_pg1()
2507 device_missing_delay = buffer->ReportDeviceMissingDelay; in mptsas_sas_io_unit_pg1()
2508 ioc->device_missing_delay = (device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_UNIT_16) ? in mptsas_sas_io_unit_pg1()
2513 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_io_unit_pg1()
2542 cfg.physAddr = -1; in mptsas_sas_phy_pg0()
2551 error = -ENXIO; in mptsas_sas_phy_pg0()
2555 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_phy_pg0()
2558 error = -ENOMEM; in mptsas_sas_phy_pg0()
2571 phy_info->hw_link_rate = buffer->HwLinkRate; in mptsas_sas_phy_pg0()
2572 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate; in mptsas_sas_phy_pg0()
2573 phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle); in mptsas_sas_phy_pg0()
2574 phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle); in mptsas_sas_phy_pg0()
2577 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_phy_pg0()
2604 cfg.physAddr = -1; in mptsas_sas_device_pg0()
2614 error = -ENXIO; in mptsas_sas_device_pg0()
2618 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_device_pg0()
2621 error = -ENOMEM; in mptsas_sas_device_pg0()
2631 error = -ENODEV; in mptsas_sas_device_pg0()
2641 device_info->handle = le16_to_cpu(buffer->DevHandle); in mptsas_sas_device_pg0()
2642 device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle); in mptsas_sas_device_pg0()
2643 device_info->handle_enclosure = in mptsas_sas_device_pg0()
2644 le16_to_cpu(buffer->EnclosureHandle); in mptsas_sas_device_pg0()
2645 device_info->slot = le16_to_cpu(buffer->Slot); in mptsas_sas_device_pg0()
2646 device_info->phy_id = buffer->PhyNum; in mptsas_sas_device_pg0()
2647 device_info->port_id = buffer->PhysicalPort; in mptsas_sas_device_pg0()
2648 device_info->id = buffer->TargetID; in mptsas_sas_device_pg0()
2649 device_info->phys_disk_num = ~0; in mptsas_sas_device_pg0()
2650 device_info->channel = buffer->Bus; in mptsas_sas_device_pg0()
2651 memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64)); in mptsas_sas_device_pg0()
2652 device_info->sas_address = le64_to_cpu(sas_address); in mptsas_sas_device_pg0()
2653 device_info->device_info = in mptsas_sas_device_pg0()
2654 le32_to_cpu(buffer->DeviceInfo); in mptsas_sas_device_pg0()
2655 device_info->flags = le16_to_cpu(buffer->Flags); in mptsas_sas_device_pg0()
2658 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_device_pg0()
2685 cfg.physAddr = -1; in mptsas_sas_expander_pg0()
2697 error = -ENXIO; in mptsas_sas_expander_pg0()
2701 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_expander_pg0()
2704 error = -ENOMEM; in mptsas_sas_expander_pg0()
2713 error = -ENODEV; in mptsas_sas_expander_pg0()
2721 port_info->num_phys = (buffer->NumPhys) ? buffer->NumPhys : 1; in mptsas_sas_expander_pg0()
2722 port_info->phy_info = kcalloc(port_info->num_phys, in mptsas_sas_expander_pg0()
2724 if (!port_info->phy_info) { in mptsas_sas_expander_pg0()
2725 error = -ENOMEM; in mptsas_sas_expander_pg0()
2729 memcpy(&sas_address, &buffer->SASAddress, sizeof(__le64)); in mptsas_sas_expander_pg0()
2730 for (i = 0; i < port_info->num_phys; i++) { in mptsas_sas_expander_pg0()
2731 port_info->phy_info[i].portinfo = port_info; in mptsas_sas_expander_pg0()
2732 port_info->phy_info[i].handle = in mptsas_sas_expander_pg0()
2733 le16_to_cpu(buffer->DevHandle); in mptsas_sas_expander_pg0()
2734 port_info->phy_info[i].identify.sas_address = in mptsas_sas_expander_pg0()
2736 port_info->phy_info[i].identify.handle_parent = in mptsas_sas_expander_pg0()
2737 le16_to_cpu(buffer->ParentDevHandle); in mptsas_sas_expander_pg0()
2741 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_expander_pg0()
2766 cfg.physAddr = -1; in mptsas_sas_expander_pg1()
2777 error = -ENXIO; in mptsas_sas_expander_pg1()
2781 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, in mptsas_sas_expander_pg1()
2784 error = -ENOMEM; in mptsas_sas_expander_pg1()
2794 error = -ENODEV; in mptsas_sas_expander_pg1()
2805 phy_info->phy_id = buffer->PhyIdentifier; in mptsas_sas_expander_pg1()
2806 phy_info->port_id = buffer->PhysicalPort; in mptsas_sas_expander_pg1()
2807 phy_info->negotiated_link_rate = buffer->NegotiatedLinkRate; in mptsas_sas_expander_pg1()
2808 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate; in mptsas_sas_expander_pg1()
2809 phy_info->hw_link_rate = buffer->HwLinkRate; in mptsas_sas_expander_pg1()
2810 phy_info->identify.handle = le16_to_cpu(buffer->OwnerDevHandle); in mptsas_sas_expander_pg1()
2811 phy_info->attached.handle = le16_to_cpu(buffer->AttachedDevHandle); in mptsas_sas_expander_pg1()
2814 dma_free_coherent(&ioc->pcidev->dev, hdr.ExtPageLength * 4, buffer, in mptsas_sas_expander_pg1()
2848 * mptsas_exp_repmanufacture_info - sets expander manufacturer info
2850 * @sas_address: expander sas address
2853 * For an edge expander or a fanout expander:
2856 * Return: 0 for success, non-zero for failure.
2876 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mptsas_exp_repmanufacture_info()
2877 if (ioc->ioc_reset_in_progress) { in mptsas_exp_repmanufacture_info()
2878 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mptsas_exp_repmanufacture_info()
2880 __func__, ioc->name); in mptsas_exp_repmanufacture_info()
2881 return -EFAULT; in mptsas_exp_repmanufacture_info()
2883 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mptsas_exp_repmanufacture_info()
2885 ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex); in mptsas_exp_repmanufacture_info()
2891 ret = -ENOMEM; in mptsas_exp_repmanufacture_info()
2900 data_out = dma_alloc_coherent(&ioc->pcidev->dev, sz, &data_out_dma, in mptsas_exp_repmanufacture_info()
2905 ret = -ENOMEM; in mptsas_exp_repmanufacture_info()
2910 manufacture_request->smp_frame_type = 0x40; in mptsas_exp_repmanufacture_info()
2911 manufacture_request->function = 1; in mptsas_exp_repmanufacture_info()
2912 manufacture_request->reserved = 0; in mptsas_exp_repmanufacture_info()
2913 manufacture_request->request_length = 0; in mptsas_exp_repmanufacture_info()
2915 smpreq->Function = MPI_FUNCTION_SMP_PASSTHROUGH; in mptsas_exp_repmanufacture_info()
2916 smpreq->PhysicalPort = 0xFF; in mptsas_exp_repmanufacture_info()
2917 *((u64 *)&smpreq->SASAddress) = cpu_to_le64(sas_address); in mptsas_exp_repmanufacture_info()
2918 smpreq->RequestDataLength = sizeof(struct rep_manu_request); in mptsas_exp_repmanufacture_info()
2930 ioc->add_sge(psge, flagsLength, data_out_dma); in mptsas_exp_repmanufacture_info()
2931 psge += ioc->SGE_size; in mptsas_exp_repmanufacture_info()
2939 ioc->add_sge(psge, flagsLength, data_out_dma + in mptsas_exp_repmanufacture_info()
2942 INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status) in mptsas_exp_repmanufacture_info()
2945 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ); in mptsas_exp_repmanufacture_info()
2946 if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptsas_exp_repmanufacture_info()
2947 ret = -ETIME; in mptsas_exp_repmanufacture_info()
2950 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptsas_exp_repmanufacture_info()
2959 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_RF_VALID) { in mptsas_exp_repmanufacture_info()
2962 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply; in mptsas_exp_repmanufacture_info()
2963 if (le16_to_cpu(smprep->ResponseDataLength) != in mptsas_exp_repmanufacture_info()
2968 memtostr(edev->vendor_id, manufacture_reply->vendor_id); in mptsas_exp_repmanufacture_info()
2969 memtostr(edev->product_id, manufacture_reply->product_id); in mptsas_exp_repmanufacture_info()
2970 memtostr(edev->product_rev, manufacture_reply->product_rev); in mptsas_exp_repmanufacture_info()
2971 edev->level = manufacture_reply->sas_format; in mptsas_exp_repmanufacture_info()
2972 if (manufacture_reply->sas_format) { in mptsas_exp_repmanufacture_info()
2973 memtostr(edev->component_vendor_id, in mptsas_exp_repmanufacture_info()
2974 manufacture_reply->component_vendor_id); in mptsas_exp_repmanufacture_info()
2975 tmp = (u8 *)&manufacture_reply->component_id; in mptsas_exp_repmanufacture_info()
2976 edev->component_id = tmp[0] << 8 | tmp[1]; in mptsas_exp_repmanufacture_info()
2977 edev->component_revision_id = in mptsas_exp_repmanufacture_info()
2978 manufacture_reply->component_revision_id; in mptsas_exp_repmanufacture_info()
2983 ioc->name, __func__); in mptsas_exp_repmanufacture_info()
2984 ret = -ENXIO; in mptsas_exp_repmanufacture_info()
2988 dma_free_coherent(&ioc->pcidev->dev, sz, data_out, in mptsas_exp_repmanufacture_info()
2994 CLEAR_MGMT_STATUS(ioc->sas_mgmt.status) in mptsas_exp_repmanufacture_info()
2995 mutex_unlock(&ioc->sas_mgmt.mutex); in mptsas_exp_repmanufacture_info()
3006 identify->sas_address = device_info->sas_address; in mptsas_parse_device_info()
3007 identify->phy_identifier = device_info->phy_id; in mptsas_parse_device_info()
3013 protocols = device_info->device_info & 0x78; in mptsas_parse_device_info()
3014 identify->initiator_port_protocols = 0; in mptsas_parse_device_info()
3016 identify->initiator_port_protocols |= SAS_PROTOCOL_SSP; in mptsas_parse_device_info()
3018 identify->initiator_port_protocols |= SAS_PROTOCOL_STP; in mptsas_parse_device_info()
3020 identify->initiator_port_protocols |= SAS_PROTOCOL_SMP; in mptsas_parse_device_info()
3022 identify->initiator_port_protocols |= SAS_PROTOCOL_SATA; in mptsas_parse_device_info()
3028 protocols = device_info->device_info & 0x780; in mptsas_parse_device_info()
3029 identify->target_port_protocols = 0; in mptsas_parse_device_info()
3031 identify->target_port_protocols |= SAS_PROTOCOL_SSP; in mptsas_parse_device_info()
3033 identify->target_port_protocols |= SAS_PROTOCOL_STP; in mptsas_parse_device_info()
3035 identify->target_port_protocols |= SAS_PROTOCOL_SMP; in mptsas_parse_device_info()
3037 identify->target_port_protocols |= SAS_PROTOCOL_SATA; in mptsas_parse_device_info()
3042 switch (device_info->device_info & in mptsas_parse_device_info()
3045 identify->device_type = SAS_PHY_UNUSED; in mptsas_parse_device_info()
3048 identify->device_type = SAS_END_DEVICE; in mptsas_parse_device_info()
3051 identify->device_type = SAS_EDGE_EXPANDER_DEVICE; in mptsas_parse_device_info()
3054 identify->device_type = SAS_FANOUT_EXPANDER_DEVICE; in mptsas_parse_device_info()
3069 error = -ENODEV; in mptsas_probe_one_phy()
3073 if (!phy_info->phy) { in mptsas_probe_one_phy()
3076 error = -ENOMEM; in mptsas_probe_one_phy()
3080 phy = phy_info->phy; in mptsas_probe_one_phy()
3082 mptsas_parse_device_info(&phy->identify, &phy_info->identify); in mptsas_probe_one_phy()
3087 switch (phy_info->negotiated_link_rate) { in mptsas_probe_one_phy()
3089 phy->negotiated_linkrate = SAS_PHY_DISABLED; in mptsas_probe_one_phy()
3092 phy->negotiated_linkrate = SAS_LINK_RATE_FAILED; in mptsas_probe_one_phy()
3095 phy->negotiated_linkrate = SAS_LINK_RATE_1_5_GBPS; in mptsas_probe_one_phy()
3098 phy->negotiated_linkrate = SAS_LINK_RATE_3_0_GBPS; in mptsas_probe_one_phy()
3101 phy->negotiated_linkrate = SAS_LINK_RATE_6_0_GBPS; in mptsas_probe_one_phy()
3106 phy->negotiated_linkrate = SAS_LINK_RATE_UNKNOWN; in mptsas_probe_one_phy()
3113 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) { in mptsas_probe_one_phy()
3115 phy->maximum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; in mptsas_probe_one_phy()
3118 phy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; in mptsas_probe_one_phy()
3127 switch (phy_info->programmed_link_rate & in mptsas_probe_one_phy()
3130 phy->maximum_linkrate = SAS_LINK_RATE_1_5_GBPS; in mptsas_probe_one_phy()
3133 phy->maximum_linkrate = SAS_LINK_RATE_3_0_GBPS; in mptsas_probe_one_phy()
3142 switch (phy_info->hw_link_rate & MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) { in mptsas_probe_one_phy()
3144 phy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; in mptsas_probe_one_phy()
3147 phy->minimum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS; in mptsas_probe_one_phy()
3156 switch (phy_info->programmed_link_rate & in mptsas_probe_one_phy()
3159 phy->minimum_linkrate = SAS_LINK_RATE_1_5_GBPS; in mptsas_probe_one_phy()
3162 phy->minimum_linkrate = SAS_LINK_RATE_3_0_GBPS; in mptsas_probe_one_phy()
3168 if (!phy_info->phy) { in mptsas_probe_one_phy()
3175 phy_info->phy = phy; in mptsas_probe_one_phy()
3178 if (!phy_info->attached.handle || in mptsas_probe_one_phy()
3179 !phy_info->port_details) in mptsas_probe_one_phy()
3183 ioc = phy_to_ioc(phy_info->phy); in mptsas_probe_one_phy()
3185 if (phy_info->sas_port_add_phy) { in mptsas_probe_one_phy()
3190 error = -ENOMEM; in mptsas_probe_one_phy()
3196 "%s: exit at line=%d\n", ioc->name, in mptsas_probe_one_phy()
3201 devtprintk(ioc, dev_printk(KERN_DEBUG, &port->dev, in mptsas_probe_one_phy()
3203 ioc->name, port->port_identifier, in mptsas_probe_one_phy()
3204 (unsigned long long)phy_info-> in mptsas_probe_one_phy()
3209 ioc->name, phy_info->phy_id)); in mptsas_probe_one_phy()
3210 sas_port_add_phy(port, phy_info->phy); in mptsas_probe_one_phy()
3211 phy_info->sas_port_add_phy = 0; in mptsas_probe_one_phy()
3212 devtprintk(ioc, dev_printk(KERN_DEBUG, &phy_info->phy->dev, in mptsas_probe_one_phy()
3213 MYIOC_s_FMT "add phy %d, phy-obj (0x%p)\n", ioc->name, in mptsas_probe_one_phy()
3214 phy_info->phy_id, phy_info->phy)); in mptsas_probe_one_phy()
3216 if (!mptsas_get_rphy(phy_info) && port && !port->rphy) { in mptsas_probe_one_phy()
3222 parent = dev->parent->parent; in mptsas_probe_one_phy()
3228 if (mptsas_is_end_device(&phy_info->attached) && in mptsas_probe_one_phy()
3229 phy_info->attached.handle_parent) { in mptsas_probe_one_phy()
3233 mptsas_parse_device_info(&identify, &phy_info->attached); in mptsas_probe_one_phy()
3238 port_info = ioc->hba_port_info; in mptsas_probe_one_phy()
3240 for (i = 0; i < port_info->num_phys; i++) in mptsas_probe_one_phy()
3241 if (port_info->phy_info[i].identify.sas_address == in mptsas_probe_one_phy()
3250 parent_rphy->identify.sas_address) { in mptsas_probe_one_phy()
3270 "%s: exit at line=%d\n", ioc->name, in mptsas_probe_one_phy()
3275 rphy->identify = identify; in mptsas_probe_one_phy()
3279 "%s: exit at line=%d\n", ioc->name, in mptsas_probe_one_phy()
3295 phy_info->attached.channel, in mptsas_probe_one_phy()
3296 phy_info->attached.id); in mptsas_probe_one_phy()
3297 if (vtarget && vtarget->inDMD) { in mptsas_probe_one_phy()
3299 vtarget->inDMD = 0; in mptsas_probe_one_phy()
3310 int error = -ENOMEM, i; in mptsas_probe_hba_phys()
3321 mutex_lock(&ioc->sas_topology_mutex); in mptsas_probe_hba_phys()
3322 port_info = ioc->hba_port_info; in mptsas_probe_hba_phys()
3324 ioc->hba_port_info = port_info = hba; in mptsas_probe_hba_phys()
3325 ioc->hba_port_num_phy = port_info->num_phys; in mptsas_probe_hba_phys()
3326 list_add_tail(&port_info->list, &ioc->sas_topology); in mptsas_probe_hba_phys()
3328 for (i = 0; i < hba->num_phys; i++) { in mptsas_probe_hba_phys()
3329 port_info->phy_info[i].negotiated_link_rate = in mptsas_probe_hba_phys()
3330 hba->phy_info[i].negotiated_link_rate; in mptsas_probe_hba_phys()
3331 port_info->phy_info[i].handle = in mptsas_probe_hba_phys()
3332 hba->phy_info[i].handle; in mptsas_probe_hba_phys()
3333 port_info->phy_info[i].port_id = in mptsas_probe_hba_phys()
3334 hba->phy_info[i].port_id; in mptsas_probe_hba_phys()
3336 kfree(hba->phy_info); in mptsas_probe_hba_phys()
3340 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_probe_hba_phys()
3342 ioc->num_ports = port_info->num_phys; in mptsas_probe_hba_phys()
3344 for (i = 0; i < port_info->num_phys; i++) { in mptsas_probe_hba_phys()
3345 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], in mptsas_probe_hba_phys()
3348 port_info->phy_info[i].identify.handle = in mptsas_probe_hba_phys()
3349 port_info->phy_info[i].handle; in mptsas_probe_hba_phys()
3350 mptsas_sas_device_pg0(ioc, &port_info->phy_info[i].identify, in mptsas_probe_hba_phys()
3353 port_info->phy_info[i].identify.handle); in mptsas_probe_hba_phys()
3354 if (!ioc->hba_port_sas_addr) in mptsas_probe_hba_phys()
3355 ioc->hba_port_sas_addr = in mptsas_probe_hba_phys()
3356 port_info->phy_info[i].identify.sas_address; in mptsas_probe_hba_phys()
3357 port_info->phy_info[i].identify.phy_id = in mptsas_probe_hba_phys()
3358 port_info->phy_info[i].phy_id = i; in mptsas_probe_hba_phys()
3359 if (port_info->phy_info[i].attached.handle) in mptsas_probe_hba_phys()
3361 &port_info->phy_info[i].attached, in mptsas_probe_hba_phys()
3364 port_info->phy_info[i].attached.handle); in mptsas_probe_hba_phys()
3369 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++) in mptsas_probe_hba_phys()
3370 mptsas_probe_one_phy(&ioc->sh->shost_gendev, in mptsas_probe_hba_phys()
3371 &port_info->phy_info[i], ioc->sas_index, 1); in mptsas_probe_hba_phys()
3388 u64 sas_address; /* expander sas address */ in mptsas_expander_refresh()
3391 handle = port_info->phy_info[0].handle; in mptsas_expander_refresh()
3392 sas_address = port_info->phy_info[0].identify.sas_address; in mptsas_expander_refresh()
3393 for (i = 0; i < port_info->num_phys; i++) { in mptsas_expander_refresh()
3394 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i], in mptsas_expander_refresh()
3399 &port_info->phy_info[i].identify, in mptsas_expander_refresh()
3402 port_info->phy_info[i].identify.handle); in mptsas_expander_refresh()
3403 port_info->phy_info[i].identify.phy_id = in mptsas_expander_refresh()
3404 port_info->phy_info[i].phy_id; in mptsas_expander_refresh()
3406 if (port_info->phy_info[i].attached.handle) { in mptsas_expander_refresh()
3408 &port_info->phy_info[i].attached, in mptsas_expander_refresh()
3411 port_info->phy_info[i].attached.handle); in mptsas_expander_refresh()
3412 port_info->phy_info[i].attached.phy_id = in mptsas_expander_refresh()
3413 port_info->phy_info[i].phy_id; in mptsas_expander_refresh()
3417 mutex_lock(&ioc->sas_topology_mutex); in mptsas_expander_refresh()
3419 port_info->phy_info[0].identify.handle_parent); in mptsas_expander_refresh()
3421 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_expander_refresh()
3424 for (i = 0, parent_dev = NULL; i < parent->num_phys && !parent_dev; in mptsas_expander_refresh()
3426 if (parent->phy_info[i].attached.sas_address == sas_address) { in mptsas_expander_refresh()
3427 rphy = mptsas_get_rphy(&parent->phy_info[i]); in mptsas_expander_refresh()
3428 parent_dev = &rphy->dev; in mptsas_expander_refresh()
3431 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_expander_refresh()
3434 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++) in mptsas_expander_refresh()
3435 mptsas_probe_one_phy(parent_dev, &port_info->phy_info[i], in mptsas_expander_refresh()
3436 ioc->sas_index, 0); in mptsas_expander_refresh()
3449 port_info->num_phys = (expander_data->NumPhys) ? in mptsas_expander_event_add()
3450 expander_data->NumPhys : 1; in mptsas_expander_event_add()
3451 port_info->phy_info = kcalloc(port_info->num_phys, in mptsas_expander_event_add()
3453 BUG_ON(!port_info->phy_info); in mptsas_expander_event_add()
3454 memcpy(&sas_address, &expander_data->SASAddress, sizeof(__le64)); in mptsas_expander_event_add()
3455 for (i = 0; i < port_info->num_phys; i++) { in mptsas_expander_event_add()
3456 port_info->phy_info[i].portinfo = port_info; in mptsas_expander_event_add()
3457 port_info->phy_info[i].handle = in mptsas_expander_event_add()
3458 le16_to_cpu(expander_data->DevHandle); in mptsas_expander_event_add()
3459 port_info->phy_info[i].identify.sas_address = in mptsas_expander_event_add()
3461 port_info->phy_info[i].identify.handle_parent = in mptsas_expander_event_add()
3462 le16_to_cpu(expander_data->ParentDevHandle); in mptsas_expander_event_add()
3465 mutex_lock(&ioc->sas_topology_mutex); in mptsas_expander_event_add()
3466 list_add_tail(&port_info->list, &ioc->sas_topology); in mptsas_expander_event_add()
3467 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_expander_event_add()
3469 printk(MYIOC_s_INFO_FMT "add expander: num_phys %d, " in mptsas_expander_event_add()
3470 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys, in mptsas_expander_event_add()
3477 * mptsas_delete_expander_siblings - remove siblings attached to expander
3480 * @expander: the expander port_info object
3484 *parent, struct mptsas_portinfo *expander) in mptsas_delete_expander_siblings() argument
3491 phy_info = expander->phy_info; in mptsas_delete_expander_siblings()
3492 for (i = 0; i < expander->num_phys; i++, phy_info++) { in mptsas_delete_expander_siblings()
3496 if (rphy->identify.device_type == SAS_END_DEVICE) in mptsas_delete_expander_siblings()
3500 phy_info = expander->phy_info; in mptsas_delete_expander_siblings()
3501 for (i = 0; i < expander->num_phys; i++, phy_info++) { in mptsas_delete_expander_siblings()
3505 if (rphy->identify.device_type == in mptsas_delete_expander_siblings()
3507 rphy->identify.device_type == in mptsas_delete_expander_siblings()
3510 rphy->identify.sas_address); in mptsas_delete_expander_siblings()
3516 Delete this expander even if the expdevpage is exists in mptsas_delete_expander_siblings()
3517 because the parent expander is already deleted in mptsas_delete_expander_siblings()
3526 * mptsas_expander_delete - remove this expander
3528 * @port_info: expander port_info struct
3529 * @force: Flag to forcefully delete the expander
3548 /* see if expander is still there before deleting */ in mptsas_expander_delete()
3552 port_info->phy_info[0].identify.handle); in mptsas_expander_delete()
3566 port_info->phy_info[0].identify.sas_address; in mptsas_expander_delete()
3568 port_info->phy_info[0].identify.handle_parent); in mptsas_expander_delete()
3575 * to this expander. in mptsas_expander_delete()
3577 phy_info = parent->phy_info; in mptsas_expander_delete()
3579 for (i = 0; i < parent->num_phys; i++, phy_info++) { in mptsas_expander_delete()
3580 if (!phy_info->phy) in mptsas_expander_delete()
3582 if (phy_info->attached.sas_address != in mptsas_expander_delete()
3587 port_details = phy_info->port_details; in mptsas_expander_delete()
3589 dev_printk(KERN_DEBUG, &phy_info->phy->dev, in mptsas_expander_delete()
3590 MYIOC_s_FMT "delete phy %d, phy-obj (0x%p)\n", ioc->name, in mptsas_expander_delete()
3591 phy_info->phy_id, phy_info->phy); in mptsas_expander_delete()
3592 sas_port_delete_phy(port, phy_info->phy); in mptsas_expander_delete()
3595 dev_printk(KERN_DEBUG, &port->dev, in mptsas_expander_delete()
3597 ioc->name, port->port_identifier, in mptsas_expander_delete()
3604 printk(MYIOC_s_INFO_FMT "delete expander: num_phys %d, " in mptsas_expander_delete()
3605 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys, in mptsas_expander_delete()
3611 list_del(&port_info->list); in mptsas_expander_delete()
3612 kfree(port_info->phy_info); in mptsas_expander_delete()
3618 * mptsas_send_expander_event - expanders events
3623 * device handles within the expander objects.
3634 ioc = fw_event->ioc; in mptsas_send_expander_event()
3636 fw_event->event_data; in mptsas_send_expander_event()
3637 memcpy(&sas_address, &expander_data->SASAddress, sizeof(__le64)); in mptsas_send_expander_event()
3641 if (expander_data->ReasonCode == MPI_EVENT_SAS_EXP_RC_ADDED) { in mptsas_send_expander_event()
3643 for (i = 0; i < port_info->num_phys; i++) { in mptsas_send_expander_event()
3644 port_info->phy_info[i].portinfo = port_info; in mptsas_send_expander_event()
3645 port_info->phy_info[i].handle = in mptsas_send_expander_event()
3646 le16_to_cpu(expander_data->DevHandle); in mptsas_send_expander_event()
3647 port_info->phy_info[i].identify.sas_address = in mptsas_send_expander_event()
3649 port_info->phy_info[i].identify.handle_parent = in mptsas_send_expander_event()
3650 le16_to_cpu(expander_data->ParentDevHandle); in mptsas_send_expander_event()
3653 } else if (!port_info && expander_data->NumPhys) in mptsas_send_expander_event()
3655 } else if (expander_data->ReasonCode == in mptsas_send_expander_event()
3664 * mptsas_expander_add - adds a newly discovered expander
3683 "%s: exit at line=%d\n", ioc->name, in mptsas_expander_add()
3687 port_info->num_phys = buffer.num_phys; in mptsas_expander_add()
3688 port_info->phy_info = buffer.phy_info; in mptsas_expander_add()
3689 for (i = 0; i < port_info->num_phys; i++) in mptsas_expander_add()
3690 port_info->phy_info[i].portinfo = port_info; in mptsas_expander_add()
3691 mutex_lock(&ioc->sas_topology_mutex); in mptsas_expander_add()
3692 list_add_tail(&port_info->list, &ioc->sas_topology); in mptsas_expander_add()
3693 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_expander_add()
3694 printk(MYIOC_s_INFO_FMT "add expander: num_phys %d, " in mptsas_expander_add()
3695 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys, in mptsas_expander_add()
3712 ioc = fw_event->ioc; in mptsas_send_link_status_event()
3713 link_data = (MpiEventDataSasPhyLinkStatus_t *)fw_event->event_data; in mptsas_send_link_status_event()
3715 memcpy(&sas_address, &link_data->SASAddress, sizeof(__le64)); in mptsas_send_link_status_event()
3717 link_rate = link_data->LinkRates >> 4; in mptsas_send_link_status_event()
3718 phy_num = link_data->PhyNum; in mptsas_send_link_status_event()
3722 phy_info = &port_info->phy_info[phy_num]; in mptsas_send_link_status_event()
3724 phy_info->negotiated_link_rate = link_rate; in mptsas_send_link_status_event()
3732 if (ioc->old_sas_discovery_protocal) { in mptsas_send_link_status_event()
3734 le16_to_cpu(link_data->DevHandle)); in mptsas_send_link_status_event()
3741 if (port_info == ioc->hba_port_info) in mptsas_send_link_status_event()
3745 } else if (phy_info && phy_info->phy) { in mptsas_send_link_status_event()
3747 phy_info->phy->negotiated_linkrate = in mptsas_send_link_status_event()
3751 phy_info->phy->negotiated_linkrate = in mptsas_send_link_status_event()
3754 phy_info->phy->negotiated_linkrate = in mptsas_send_link_status_event()
3756 if (ioc->device_missing_delay && in mptsas_send_link_status_event()
3757 mptsas_is_end_device(&phy_info->attached)) { in mptsas_send_link_status_event()
3761 id = phy_info->attached.id; in mptsas_send_link_status_event()
3762 channel = phy_info->attached.channel; in mptsas_send_link_status_event()
3765 ioc->name, phy_info->attached.id, in mptsas_send_link_status_event()
3766 phy_info->attached.channel)); in mptsas_send_link_status_event()
3768 shost_for_each_device(sdev, ioc->sh) { in mptsas_send_link_status_event()
3769 vdevice = sdev->hostdata; in mptsas_send_link_status_event()
3771 (vdevice->vtarget == NULL)) in mptsas_send_link_status_event()
3773 if ((vdevice->vtarget->tflags & in mptsas_send_link_status_event()
3775 vdevice->vtarget->raidVolume)) in mptsas_send_link_status_event()
3777 if (vdevice->vtarget->id == id && in mptsas_send_link_status_event()
3778 vdevice->vtarget->channel == in mptsas_send_link_status_event()
3783 "%d\n", ioc->name, in mptsas_send_link_status_event()
3809 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mptsas_not_responding_devices()
3810 if (ioc->ioc_reset_in_progress) { in mptsas_not_responding_devices()
3812 "%s: exiting due to a parallel reset \n", ioc->name, in mptsas_not_responding_devices()
3814 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mptsas_not_responding_devices()
3817 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags); in mptsas_not_responding_devices()
3820 mutex_lock(&ioc->sas_device_info_mutex); in mptsas_not_responding_devices()
3822 list_for_each_entry(sas_info, &ioc->sas_device_info_list, list) { in mptsas_not_responding_devices()
3823 if (sas_info->is_cached) in mptsas_not_responding_devices()
3825 if (!sas_info->is_logical_volume) { in mptsas_not_responding_devices()
3832 (sas_info->fw.channel << 8) + in mptsas_not_responding_devices()
3833 sas_info->fw.id); in mptsas_not_responding_devices()
3837 if (retval == -EBUSY) { in mptsas_not_responding_devices()
3838 spin_lock_irqsave(&ioc->taskmgmt_lock, flags); in mptsas_not_responding_devices()
3839 if (ioc->ioc_reset_in_progress) { in mptsas_not_responding_devices()
3843 ioc->name, __func__)); in mptsas_not_responding_devices()
3845 (&ioc->taskmgmt_lock, flags); in mptsas_not_responding_devices()
3846 mutex_unlock(&ioc-> in mptsas_not_responding_devices()
3850 spin_unlock_irqrestore(&ioc->taskmgmt_lock, in mptsas_not_responding_devices()
3854 if (retval && (retval != -ENODEV)) { in mptsas_not_responding_devices()
3862 ioc->name, __func__, in mptsas_not_responding_devices()
3863 sas_info->sas_address)); in mptsas_not_responding_devices()
3869 sas_info->fw.channel, sas_info->fw.id); in mptsas_not_responding_devices()
3872 vtarget->deleted = 1; in mptsas_not_responding_devices()
3875 sas_info->sas_address); in mptsas_not_responding_devices()
3880 mptsas_volume_delete(ioc, sas_info->fw.id); in mptsas_not_responding_devices()
3882 mutex_unlock(&ioc->sas_device_info_mutex); in mptsas_not_responding_devices()
3885 mutex_lock(&ioc->sas_topology_mutex); in mptsas_not_responding_devices()
3887 list_for_each_entry(port_info, &ioc->sas_topology, list) { in mptsas_not_responding_devices()
3889 if (!(port_info->phy_info[0].identify.device_info & in mptsas_not_responding_devices()
3901 port_info->phy_info[0].identify.sas_address) { in mptsas_not_responding_devices()
3912 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_not_responding_devices()
3916 * mptsas_probe_expanders - adding expanders
3939 port_info->phy_info[i].handle = handle; in mptsas_probe_expanders()
3940 port_info->phy_info[i].identify.handle_parent = in mptsas_probe_expanders()
3951 "%s: exit at line=%d\n", ioc->name, in mptsas_probe_expanders()
3955 port_info->num_phys = buffer.num_phys; in mptsas_probe_expanders()
3956 port_info->phy_info = buffer.phy_info; in mptsas_probe_expanders()
3957 for (i = 0; i < port_info->num_phys; i++) in mptsas_probe_expanders()
3958 port_info->phy_info[i].portinfo = port_info; in mptsas_probe_expanders()
3959 mutex_lock(&ioc->sas_topology_mutex); in mptsas_probe_expanders()
3960 list_add_tail(&port_info->list, &ioc->sas_topology); in mptsas_probe_expanders()
3961 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_probe_expanders()
3962 printk(MYIOC_s_INFO_FMT "add expander: num_phys %d, " in mptsas_probe_expanders()
3963 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys, in mptsas_probe_expanders()
4007 * mptsas_scan_sas_topology - scans new SAS topology
4025 if (!ioc->ir_firmware || !ioc->raid_data.pIocPg2 || in mptsas_scan_sas_topology()
4026 !ioc->raid_data.pIocPg2->NumActiveVolumes) in mptsas_scan_sas_topology()
4028 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { in mptsas_scan_sas_topology()
4029 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL, in mptsas_scan_sas_topology()
4030 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); in mptsas_scan_sas_topology()
4036 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL, in mptsas_scan_sas_topology()
4037 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID); in mptsas_scan_sas_topology()
4038 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL, in mptsas_scan_sas_topology()
4039 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0); in mptsas_scan_sas_topology()
4052 int id = -1; in mptsas_handle_queue_full_event()
4053 int channel = -1; in mptsas_handle_queue_full_event()
4058 ioc = fw_event->ioc; in mptsas_handle_queue_full_event()
4059 qfull_data = (EventDataQueueFull_t *)fw_event->event_data; in mptsas_handle_queue_full_event()
4060 fw_id = qfull_data->TargetID; in mptsas_handle_queue_full_event()
4061 fw_channel = qfull_data->Bus; in mptsas_handle_queue_full_event()
4062 current_depth = le16_to_cpu(qfull_data->CurrentDepth); in mptsas_handle_queue_full_event()
4065 mutex_lock(&ioc->sas_device_info_mutex); in mptsas_handle_queue_full_event()
4067 list_for_each_entry(sas_info, &ioc->sas_device_info_list, in mptsas_handle_queue_full_event()
4069 if (sas_info->is_cached || in mptsas_handle_queue_full_event()
4070 sas_info->is_logical_volume) in mptsas_handle_queue_full_event()
4072 if (sas_info->is_hidden_raid_component && in mptsas_handle_queue_full_event()
4073 (sas_info->fw.channel == fw_channel && in mptsas_handle_queue_full_event()
4074 sas_info->fw.id == fw_id)) { in mptsas_handle_queue_full_event()
4075 id = sas_info->volume_id; in mptsas_handle_queue_full_event()
4081 list_for_each_entry(sas_info, &ioc->sas_device_info_list, in mptsas_handle_queue_full_event()
4083 if (sas_info->is_cached || in mptsas_handle_queue_full_event()
4084 sas_info->is_hidden_raid_component || in mptsas_handle_queue_full_event()
4085 sas_info->is_logical_volume) in mptsas_handle_queue_full_event()
4087 if (sas_info->fw.channel == fw_channel && in mptsas_handle_queue_full_event()
4088 sas_info->fw.id == fw_id) { in mptsas_handle_queue_full_event()
4089 id = sas_info->os.id; in mptsas_handle_queue_full_event()
4090 channel = sas_info->os.channel; in mptsas_handle_queue_full_event()
4098 mutex_unlock(&ioc->sas_device_info_mutex); in mptsas_handle_queue_full_event()
4100 if (id != -1) { in mptsas_handle_queue_full_event()
4101 shost_for_each_device(sdev, ioc->sh) { in mptsas_handle_queue_full_event()
4102 if (sdev->id == id && sdev->channel == channel) { in mptsas_handle_queue_full_event()
4103 if (current_depth > sdev->queue_depth) { in mptsas_handle_queue_full_event()
4107 "depth (%d)\n", sdev->queue_depth, in mptsas_handle_queue_full_event()
4112 sdev->queue_depth - 1); in mptsas_handle_queue_full_event()
4139 mutex_lock(&ioc->sas_topology_mutex); in mptsas_find_phyinfo_by_sas_address()
4140 list_for_each_entry(port_info, &ioc->sas_topology, list) { in mptsas_find_phyinfo_by_sas_address()
4141 for (i = 0; i < port_info->num_phys; i++) { in mptsas_find_phyinfo_by_sas_address()
4143 &port_info->phy_info[i].attached)) in mptsas_find_phyinfo_by_sas_address()
4145 if (port_info->phy_info[i].attached.sas_address in mptsas_find_phyinfo_by_sas_address()
4148 phy_info = &port_info->phy_info[i]; in mptsas_find_phyinfo_by_sas_address()
4152 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_find_phyinfo_by_sas_address()
4157 * mptsas_find_phyinfo_by_phys_disk_num - find phyinfo for the
4177 if (!ioc->raid_data.pIocPg3) in mptsas_find_phyinfo_by_phys_disk_num()
4189 if ((phys_disk->Path[i].Flags & 1) != 0) in mptsas_find_phyinfo_by_phys_disk_num()
4192 if ((id == phys_disk->Path[i].PhysDiskID) && in mptsas_find_phyinfo_by_phys_disk_num()
4193 (channel == phys_disk->Path[i].PhysDiskBus)) { in mptsas_find_phyinfo_by_phys_disk_num()
4194 memcpy(&sas_address, &phys_disk->Path[i].WWID, in mptsas_find_phyinfo_by_phys_disk_num()
4211 mutex_lock(&ioc->sas_topology_mutex); in mptsas_find_phyinfo_by_phys_disk_num()
4212 list_for_each_entry(port_info, &ioc->sas_topology, list) { in mptsas_find_phyinfo_by_phys_disk_num()
4213 for (i = 0; i < port_info->num_phys && !phy_info; i++) { in mptsas_find_phyinfo_by_phys_disk_num()
4215 &port_info->phy_info[i].attached)) in mptsas_find_phyinfo_by_phys_disk_num()
4217 if (port_info->phy_info[i].attached.phys_disk_num == ~0) in mptsas_find_phyinfo_by_phys_disk_num()
4219 if ((port_info->phy_info[i].attached.phys_disk_num == in mptsas_find_phyinfo_by_phys_disk_num()
4221 (port_info->phy_info[i].attached.id == id) && in mptsas_find_phyinfo_by_phys_disk_num()
4222 (port_info->phy_info[i].attached.channel == in mptsas_find_phyinfo_by_phys_disk_num()
4224 phy_info = &port_info->phy_info[i]; in mptsas_find_phyinfo_by_phys_disk_num()
4227 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_find_phyinfo_by_phys_disk_num()
4236 sdev->no_uld_attach = data ? 1 : 0; in mptsas_reprobe_lun()
4273 buffer = dma_alloc_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mptsas_adding_inactive_raid_components()
4285 if (!(buffer->VolumeStatus.Flags & in mptsas_adding_inactive_raid_components()
4289 if (!buffer->NumPhysDisks) in mptsas_adding_inactive_raid_components()
4292 for (i = 0; i < buffer->NumPhysDisks; i++) { in mptsas_adding_inactive_raid_components()
4295 buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0) in mptsas_adding_inactive_raid_components()
4320 dma_free_coherent(&ioc->pcidev->dev, hdr.PageLength * 4, in mptsas_adding_inactive_raid_components()
4337 switch (hot_plug_info->event_type) { in mptsas_hotplug_work()
4341 if (!ioc->raid_data.pIocPg2) in mptsas_hotplug_work()
4344 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) { in mptsas_hotplug_work()
4345 if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == in mptsas_hotplug_work()
4346 hot_plug_info->id) { in mptsas_hotplug_work()
4348 "to add hidden disk - target_id matches " in mptsas_hotplug_work()
4349 "volume_id\n", ioc->name); in mptsas_hotplug_work()
4362 (hot_plug_info->channel << 8) + in mptsas_hotplug_work()
4363 hot_plug_info->id); in mptsas_hotplug_work()
4380 "parent handle of device %x\n", ioc->name, in mptsas_hotplug_work()
4385 if (port_info == ioc->hba_port_info) in mptsas_hotplug_work()
4392 ioc->name, __func__, __LINE__)); in mptsas_hotplug_work()
4402 ioc->name, __func__, __LINE__)); in mptsas_hotplug_work()
4414 hot_plug_info->sas_address); in mptsas_hotplug_work()
4423 ioc, hot_plug_info->phys_disk_num, in mptsas_hotplug_work()
4424 hot_plug_info->channel, in mptsas_hotplug_work()
4425 hot_plug_info->id); in mptsas_hotplug_work()
4434 (hot_plug_info->channel << 8) + hot_plug_info->id)) { in mptsas_hotplug_work()
4436 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4437 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4453 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4454 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4461 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4462 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4466 vtarget = starget->hostdata; in mptsas_hotplug_work()
4469 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4470 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4478 ioc->name, hot_plug_info->channel, hot_plug_info->id, in mptsas_hotplug_work()
4479 hot_plug_info->phys_disk_num, (unsigned long long) in mptsas_hotplug_work()
4482 vtarget->id = hot_plug_info->phys_disk_num; in mptsas_hotplug_work()
4483 vtarget->tflags |= MPT_TARGET_FLAGS_RAID_COMPONENT; in mptsas_hotplug_work()
4484 phy_info->attached.phys_disk_num = hot_plug_info->phys_disk_num; in mptsas_hotplug_work()
4493 (hot_plug_info->channel << 8) + hot_plug_info->id)) { in mptsas_hotplug_work()
4496 ioc->name, __func__, in mptsas_hotplug_work()
4497 hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4512 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4513 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4520 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4521 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4525 vtarget = starget->hostdata; in mptsas_hotplug_work()
4528 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4529 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4533 if (!(vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT)) { in mptsas_hotplug_work()
4535 "%s: fw_id=%d exit at line=%d\n", ioc->name, in mptsas_hotplug_work()
4536 __func__, hot_plug_info->id, __LINE__)); in mptsas_hotplug_work()
4544 ioc->name, hot_plug_info->channel, hot_plug_info->id, in mptsas_hotplug_work()
4545 hot_plug_info->phys_disk_num, (unsigned long long) in mptsas_hotplug_work()
4548 vtarget->tflags &= ~MPT_TARGET_FLAGS_RAID_COMPONENT; in mptsas_hotplug_work()
4549 vtarget->id = hot_plug_info->id; in mptsas_hotplug_work()
4550 phy_info->attached.phys_disk_num = ~0; in mptsas_hotplug_work()
4553 hot_plug_info->channel, hot_plug_info->id); in mptsas_hotplug_work()
4560 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL, in mptsas_hotplug_work()
4561 hot_plug_info->id); in mptsas_hotplug_work()
4562 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL, in mptsas_hotplug_work()
4563 hot_plug_info->id, 0); in mptsas_hotplug_work()
4570 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL, in mptsas_hotplug_work()
4571 hot_plug_info->id); in mptsas_hotplug_work()
4572 scsi_remove_device(hot_plug_info->sdev); in mptsas_hotplug_work()
4573 scsi_device_put(hot_plug_info->sdev); in mptsas_hotplug_work()
4580 hot_plug_info->channel, hot_plug_info->id); in mptsas_hotplug_work()
4599 ioc = fw_event->ioc; in mptsas_send_sas_event()
4601 fw_event->event_data; in mptsas_send_sas_event()
4602 device_info = le32_to_cpu(sas_event_data->DeviceInfo); in mptsas_send_sas_event()
4612 if (sas_event_data->ReasonCode == in mptsas_send_sas_event()
4620 switch (sas_event_data->ReasonCode) { in mptsas_send_sas_event()
4624 hot_plug_info.handle = le16_to_cpu(sas_event_data->DevHandle); in mptsas_send_sas_event()
4625 hot_plug_info.channel = sas_event_data->Bus; in mptsas_send_sas_event()
4626 hot_plug_info.id = sas_event_data->TargetID; in mptsas_send_sas_event()
4627 hot_plug_info.phy_id = sas_event_data->PhyNum; in mptsas_send_sas_event()
4628 memcpy(&sas_address, &sas_event_data->SASAddress, in mptsas_send_sas_event()
4632 if (sas_event_data->ReasonCode & in mptsas_send_sas_event()
4668 ioc = fw_event->ioc; in mptsas_send_raid_event()
4669 raid_event_data = (EVENT_DATA_RAID *)fw_event->event_data; in mptsas_send_raid_event()
4670 status = le32_to_cpu(raid_event_data->SettingsStatus); in mptsas_send_raid_event()
4674 hot_plug_info.id = raid_event_data->VolumeID; in mptsas_send_raid_event()
4675 hot_plug_info.channel = raid_event_data->VolumeBus; in mptsas_send_raid_event()
4676 hot_plug_info.phys_disk_num = raid_event_data->PhysDiskNum; in mptsas_send_raid_event()
4678 if (raid_event_data->ReasonCode == MPI_EVENT_RAID_RC_VOLUME_DELETED || in mptsas_send_raid_event()
4679 raid_event_data->ReasonCode == MPI_EVENT_RAID_RC_VOLUME_CREATED || in mptsas_send_raid_event()
4680 raid_event_data->ReasonCode == in mptsas_send_raid_event()
4682 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL, in mptsas_send_raid_event()
4686 vdevice = sdev->hostdata; in mptsas_send_raid_event()
4690 "ReasonCode=%02x\n", ioc->name, __func__, in mptsas_send_raid_event()
4691 raid_event_data->ReasonCode)); in mptsas_send_raid_event()
4693 switch (raid_event_data->ReasonCode) { in mptsas_send_raid_event()
4705 raid_event_data->PhysDiskNum, &phys_disk); in mptsas_send_raid_event()
4724 vdevice->vtarget->deleted = 1; /* block IO */ in mptsas_send_raid_event()
4738 vdevice->vtarget->deleted = 1; /* block IO */ in mptsas_send_raid_event()
4747 vdevice->vtarget->deleted = 1; /* block IO */ in mptsas_send_raid_event()
4773 * mptsas_issue_tm - send mptsas internal tm request
4783 * Return: 0 on success or -1 on failure.
4798 retval = -1; /* return failure */ in mptsas_issue_tm()
4800 "msg frames!!\n", ioc->name)); in mptsas_issue_tm()
4806 "fw_id = %d, lun = %lld,\n\t task_context = 0x%x\n", ioc->name, mf, in mptsas_issue_tm()
4812 pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT; in mptsas_issue_tm()
4813 pScsiTm->TaskType = type; in mptsas_issue_tm()
4814 pScsiTm->MsgFlags = 0; in mptsas_issue_tm()
4815 pScsiTm->TargetID = id; in mptsas_issue_tm()
4816 pScsiTm->Bus = channel; in mptsas_issue_tm()
4817 pScsiTm->ChainOffset = 0; in mptsas_issue_tm()
4818 pScsiTm->Reserved = 0; in mptsas_issue_tm()
4819 pScsiTm->Reserved1 = 0; in mptsas_issue_tm()
4820 pScsiTm->TaskMsgContext = task_context; in mptsas_issue_tm()
4821 int_to_scsilun(lun, (struct scsi_lun *)pScsiTm->LUN); in mptsas_issue_tm()
4823 INITIALIZE_MGMT_STATUS(ioc->taskmgmt_cmds.status) in mptsas_issue_tm()
4824 CLEAR_MGMT_STATUS(ioc->internal_cmds.status) in mptsas_issue_tm()
4829 timeleft = wait_for_completion_timeout(&ioc->taskmgmt_cmds.done, in mptsas_issue_tm()
4831 if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) { in mptsas_issue_tm()
4832 retval = -1; /* return failure */ in mptsas_issue_tm()
4834 "TaskMgmt request: TIMED OUT!(mr=%p)\n", ioc->name, mf)); in mptsas_issue_tm()
4836 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) in mptsas_issue_tm()
4842 if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_RF_VALID)) { in mptsas_issue_tm()
4843 retval = -1; /* return failure */ in mptsas_issue_tm()
4845 "TaskMgmt request: failed with no reply\n", ioc->name)); in mptsas_issue_tm()
4850 CLEAR_MGMT_STATUS(ioc->taskmgmt_cmds.status) in mptsas_issue_tm()
4855 * mptsas_broadcast_primitive_work - Handle broadcast primitives
4863 MPT_ADAPTER *ioc = fw_event->ioc; in mptsas_broadcast_primitive_work()
4877 "%s - enter\n", ioc->name, __func__)); in mptsas_broadcast_primitive_work()
4879 mutex_lock(&ioc->taskmgmt_cmds.mutex); in mptsas_broadcast_primitive_work()
4881 mutex_unlock(&ioc->taskmgmt_cmds.mutex); in mptsas_broadcast_primitive_work()
4890 pScsiTmReply = (SCSITaskMgmtReply_t *) ioc->taskmgmt_cmds.reply; in mptsas_broadcast_primitive_work()
4892 for (ii = 0; ii < ioc->req_depth; ii++) { in mptsas_broadcast_primitive_work()
4893 if (ioc->fw_events_off) in mptsas_broadcast_primitive_work()
4901 task_context = mf->u.frame.hwhdr.msgctxu.MsgContext; in mptsas_broadcast_primitive_work()
4902 vdevice = sc->device->hostdata; in mptsas_broadcast_primitive_work()
4903 if (!vdevice || !vdevice->vtarget) in mptsas_broadcast_primitive_work()
4905 if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) in mptsas_broadcast_primitive_work()
4907 if (vdevice->vtarget->raidVolume) in mptsas_broadcast_primitive_work()
4909 channel = vdevice->vtarget->channel; in mptsas_broadcast_primitive_work()
4910 id = vdevice->vtarget->id; in mptsas_broadcast_primitive_work()
4911 lun = vdevice->lun; in mptsas_broadcast_primitive_work()
4917 le32_to_cpu(pScsiTmReply->TerminationCount); in mptsas_broadcast_primitive_work()
4918 if ((pScsiTmReply->IOCStatus == MPI_IOCSTATUS_SUCCESS) && in mptsas_broadcast_primitive_work()
4919 (pScsiTmReply->ResponseCode == in mptsas_broadcast_primitive_work()
4921 pScsiTmReply->ResponseCode == in mptsas_broadcast_primitive_work()
4929 le32_to_cpu(pScsiTmReply->TerminationCount); in mptsas_broadcast_primitive_work()
4934 "%s - exit, query_count = %d termination_count = %d\n", in mptsas_broadcast_primitive_work()
4935 ioc->name, __func__, query_count, termination_count)); in mptsas_broadcast_primitive_work()
4937 ioc->broadcast_aen_busy = 0; in mptsas_broadcast_primitive_work()
4939 mutex_unlock(&ioc->taskmgmt_cmds.mutex); in mptsas_broadcast_primitive_work()
4944 ioc->name, __func__, mpt_GetIocState(ioc, 0)); in mptsas_broadcast_primitive_work()
4951 * mptsas_send_ir2_event - handle exposing hidden disk when
4967 ioc = fw_event->ioc; in mptsas_send_ir2_event()
4968 ir2_data = (MPI_EVENT_DATA_IR2 *)fw_event->event_data; in mptsas_send_ir2_event()
4969 reasonCode = ir2_data->ReasonCode; in mptsas_send_ir2_event()
4972 "ReasonCode=%02x\n", ioc->name, __func__, reasonCode)); in mptsas_send_ir2_event()
4975 hot_plug_info.id = ir2_data->TargetID; in mptsas_send_ir2_event()
4976 hot_plug_info.channel = ir2_data->Bus; in mptsas_send_ir2_event()
4982 hot_plug_info.phys_disk_num = ir2_data->PhysDiskNum; in mptsas_send_ir2_event()
4986 hot_plug_info.phys_disk_num = ir2_data->PhysDiskNum; in mptsas_send_ir2_event()
4988 ir2_data->PhysDiskNum, &phys_disk); in mptsas_send_ir2_event()
5002 u32 event = le32_to_cpu(reply->Event); in mptsas_event_process()
5007 if (ioc->bus_type != SAS) in mptsas_event_process()
5011 if (ioc->fw_events_off) in mptsas_event_process()
5019 (EVENT_DATA_SAS_BROADCAST_PRIMITIVE *)reply->Data; in mptsas_event_process()
5020 if (broadcast_event_data->Primitive != in mptsas_event_process()
5023 if (ioc->broadcast_aen_busy) in mptsas_event_process()
5025 ioc->broadcast_aen_busy = 1; in mptsas_event_process()
5031 (EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data; in mptsas_event_process()
5033 ioc_stat = le16_to_cpu(reply->IOCStatus); in mptsas_event_process()
5035 if (sas_event_data->ReasonCode == in mptsas_event_process()
5040 if (sas_event_data->ReasonCode == in mptsas_event_process()
5042 ioc->device_missing_delay && in mptsas_event_process()
5047 id = sas_event_data->TargetID; in mptsas_event_process()
5048 channel = sas_event_data->Bus; in mptsas_event_process()
5055 "fw_id %d fw_channel %d\n", ioc->name, in mptsas_event_process()
5056 le32_to_cpu(reply->IOCLogInfo), in mptsas_event_process()
5058 if (vtarget->raidVolume) { in mptsas_event_process()
5061 ioc->name)); in mptsas_event_process()
5065 ioc->name)); in mptsas_event_process()
5066 vtarget->inDMD = 1; in mptsas_event_process()
5078 (MpiEventDataSasExpanderStatusChange_t *)reply->Data; in mptsas_event_process()
5080 if (ioc->old_sas_discovery_protocal) in mptsas_event_process()
5083 if (expander_data->ReasonCode == in mptsas_event_process()
5085 ioc->device_missing_delay) in mptsas_event_process()
5086 delay = HZ * ioc->device_missing_delay; in mptsas_event_process()
5093 (EventDataSasDiscovery_t *)reply->Data; in mptsas_event_process()
5095 discovery_status = le32_to_cpu(discovery_data->DiscoveryStatus); in mptsas_event_process()
5096 ioc->sas_discovery_quiesce_io = discovery_status ? 1 : 0; in mptsas_event_process()
5097 if (ioc->old_sas_discovery_protocal && !discovery_status) in mptsas_event_process()
5111 event_data_sz = ((reply->MsgLength * 4) - in mptsas_event_process()
5115 printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, in mptsas_event_process()
5119 memcpy(fw_event->event_data, reply->Data, event_data_sz); in mptsas_event_process()
5120 fw_event->event = event; in mptsas_event_process()
5121 fw_event->ioc = ioc; in mptsas_event_process()
5133 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL, id, 0); in mptsas_volume_delete()
5136 if (!ioc->raid_data.pIocPg2) in mptsas_volume_delete()
5138 if (!ioc->raid_data.pIocPg2->NumActiveVolumes) in mptsas_volume_delete()
5140 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) in mptsas_volume_delete()
5141 if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) in mptsas_volume_delete()
5145 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL, id); in mptsas_volume_delete()
5171 ioc->DoneCtx = mptsasDoneCtx; in mptsas_probe()
5172 ioc->TaskCtx = mptsasTaskCtx; in mptsas_probe()
5173 ioc->InternalCtx = mptsasInternalCtx; in mptsas_probe()
5174 ioc->schedule_target_reset = &mptsas_schedule_target_reset; in mptsas_probe()
5175 ioc->schedule_dead_ioc_flush_running_cmds = in mptsas_probe()
5179 if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) { in mptsas_probe()
5182 ioc->name); in mptsas_probe()
5183 error = -ENODEV; in mptsas_probe()
5187 if (!ioc->active) { in mptsas_probe()
5189 ioc->name); in mptsas_probe()
5190 error = -ENODEV; in mptsas_probe()
5194 /* Sanity check - ensure at least 1 port is INITIATOR capable in mptsas_probe()
5197 for (ii = 0; ii < ioc->facts.NumberOfPorts; ii++) { in mptsas_probe()
5198 if (ioc->pfacts[ii].ProtocolFlags & in mptsas_probe()
5206 "is NOT enabled!\n", ioc->name, ioc); in mptsas_probe()
5214 ioc->name); in mptsas_probe()
5215 error = -1; in mptsas_probe()
5219 spin_lock_irqsave(&ioc->FreeQlock, flags); in mptsas_probe()
5223 ioc->sh = sh; in mptsas_probe()
5225 sh->io_port = 0; in mptsas_probe()
5226 sh->n_io_port = 0; in mptsas_probe()
5227 sh->irq = 0; in mptsas_probe()
5230 sh->max_cmd_len = 16; in mptsas_probe()
5231 sh->can_queue = min_t(int, ioc->req_depth - 10, sh->can_queue); in mptsas_probe()
5232 sh->max_id = -1; in mptsas_probe()
5233 sh->max_lun = max_lun; in mptsas_probe()
5234 sh->transportt = mptsas_transport_template; in mptsas_probe()
5238 sh->unique_id = ioc->id; in mptsas_probe()
5240 INIT_LIST_HEAD(&ioc->sas_topology); in mptsas_probe()
5241 mutex_init(&ioc->sas_topology_mutex); in mptsas_probe()
5242 mutex_init(&ioc->sas_discovery_mutex); in mptsas_probe()
5243 mutex_init(&ioc->sas_mgmt.mutex); in mptsas_probe()
5244 init_completion(&ioc->sas_mgmt.done); in mptsas_probe()
5250 * numSGE = 1 + (ZZ-1)*(maxChain -1) + ZZ in mptsas_probe()
5251 * + (req_sz - 64)/sizeof(SGE) in mptsas_probe()
5255 scale = ioc->req_sz/ioc->SGE_size; in mptsas_probe()
5256 if (ioc->sg_addr_size == sizeof(u64)) { in mptsas_probe()
5257 numSGE = (scale - 1) * in mptsas_probe()
5258 (ioc->facts.MaxChainDepth-1) + scale + in mptsas_probe()
5259 (ioc->req_sz - 60) / ioc->SGE_size; in mptsas_probe()
5261 numSGE = 1 + (scale - 1) * in mptsas_probe()
5262 (ioc->facts.MaxChainDepth-1) + scale + in mptsas_probe()
5263 (ioc->req_sz - 64) / ioc->SGE_size; in mptsas_probe()
5266 if (numSGE < sh->sg_tablesize) { in mptsas_probe()
5270 ioc->name, numSGE, sh->sg_tablesize)); in mptsas_probe()
5271 sh->sg_tablesize = numSGE; in mptsas_probe()
5279 "Range from 64 to 8192\n", ioc->name, in mptsas_probe()
5285 ioc->name, mpt_loadtime_max_sectors, sh->max_sectors)); in mptsas_probe()
5286 sh->max_sectors = mpt_loadtime_max_sectors; in mptsas_probe()
5290 hd->ioc = ioc; in mptsas_probe()
5295 ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC); in mptsas_probe()
5296 if (!ioc->ScsiLookup) { in mptsas_probe()
5297 error = -ENOMEM; in mptsas_probe()
5298 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mptsas_probe()
5301 spin_lock_init(&ioc->scsi_lookup_lock); in mptsas_probe()
5304 ioc->name, ioc->ScsiLookup)); in mptsas_probe()
5306 ioc->sas_data.ptClear = mpt_pt_clear; in mptsas_probe()
5308 hd->last_queue_full = 0; in mptsas_probe()
5309 INIT_LIST_HEAD(&hd->target_reset_list); in mptsas_probe()
5310 INIT_LIST_HEAD(&ioc->sas_device_info_list); in mptsas_probe()
5311 mutex_init(&ioc->sas_device_info_mutex); in mptsas_probe()
5313 spin_unlock_irqrestore(&ioc->FreeQlock, flags); in mptsas_probe()
5315 if (ioc->sas_data.ptClear==1) { in mptsas_probe()
5320 error = scsi_add_host(sh, &ioc->pcidev->dev); in mptsas_probe()
5323 "scsi_add_host failed\n", ioc->name)); in mptsas_probe()
5327 /* older firmware doesn't support expander events */ in mptsas_probe()
5328 if ((ioc->facts.HeaderVersion >> 8) < 0xE) in mptsas_probe()
5329 ioc->old_sas_discovery_protocal = 1; in mptsas_probe()
5355 if (!ioc->sh) { in mptsas_remove()
5356 printk(MYIOC_s_INFO_FMT "IOC is in Target mode\n", ioc->name); in mptsas_remove()
5365 ioc->sas_discovery_ignore_events = 1; in mptsas_remove()
5366 sas_remove_host(ioc->sh); in mptsas_remove()
5368 mutex_lock(&ioc->sas_topology_mutex); in mptsas_remove()
5369 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { in mptsas_remove()
5370 list_del(&p->list); in mptsas_remove()
5371 for (i = 0 ; i < p->num_phys ; i++) in mptsas_remove()
5372 mptsas_port_delete(ioc, p->phy_info[i].port_details); in mptsas_remove()
5374 kfree(p->phy_info); in mptsas_remove()
5377 mutex_unlock(&ioc->sas_topology_mutex); in mptsas_remove()
5378 ioc->hba_port_info = NULL; in mptsas_remove()
5422 return -ENODEV; in mptsas_init()