Lines Matching refs:ioc

112 static inline void mptsas_set_rphy(MPT_ADAPTER *ioc,
115 (MPT_ADAPTER *ioc, u64 sas_address);
116 static int mptsas_sas_device_pg0(MPT_ADAPTER *ioc,
118 static int mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc,
120 static int mptsas_add_end_device(MPT_ADAPTER *ioc,
122 static void mptsas_del_end_device(MPT_ADAPTER *ioc,
126 (MPT_ADAPTER *ioc, u64 sas_address);
127 static void mptsas_expander_delete(MPT_ADAPTER *ioc,
130 static void mptsas_not_responding_devices(MPT_ADAPTER *ioc);
131 static void mptsas_scan_sas_topology(MPT_ADAPTER *ioc);
134 static void mptsas_volume_delete(MPT_ADAPTER *ioc, u8 id);
135 void mptsas_schedule_target_reset(void *ioc);
137 static void mptsas_print_phy_data(MPT_ADAPTER *ioc,
140 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
141 "---- IO UNIT PAGE 0 ------------\n", ioc->name));
142 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n",
143 ioc->name, le16_to_cpu(phy_data->AttachedDeviceHandle)));
144 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Controller Handle=0x%X\n",
145 ioc->name, le16_to_cpu(phy_data->ControllerDevHandle)));
146 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port=0x%X\n",
147 ioc->name, phy_data->Port));
148 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Port Flags=0x%X\n",
149 ioc->name, phy_data->PortFlags));
150 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Flags=0x%X\n",
151 ioc->name, phy_data->PhyFlags));
152 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n",
153 ioc->name, phy_data->NegotiatedLinkRate));
154 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
155 "Controller PHY Device Info=0x%X\n", ioc->name,
157 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DiscoveryStatus=0x%X\n\n",
158 ioc->name, le32_to_cpu(phy_data->DiscoveryStatus)));
161 static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0)
167 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
168 "---- SAS PHY PAGE 0 ------------\n", ioc->name));
169 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
170 "Attached Device Handle=0x%X\n", ioc->name,
172 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n",
173 ioc->name, (unsigned long long)le64_to_cpu(sas_address)));
174 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
175 "Attached PHY Identifier=0x%X\n", ioc->name,
177 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Attached Device Info=0x%X\n",
178 ioc->name, le32_to_cpu(pg0->AttachedDeviceInfo)));
179 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n",
180 ioc->name, pg0->ProgrammedLinkRate));
181 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Change Count=0x%X\n",
182 ioc->name, pg0->ChangeCount));
183 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Info=0x%X\n\n",
184 ioc->name, le32_to_cpu(pg0->PhyInfo)));
187 static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1)
189 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
190 "---- SAS PHY PAGE 1 ------------\n", ioc->name));
191 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Invalid Dword Count=0x%x\n",
192 ioc->name, pg1->InvalidDwordCount));
193 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
194 "Running Disparity Error Count=0x%x\n", ioc->name,
196 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
197 "Loss Dword Synch Count=0x%x\n", ioc->name,
199 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
200 "PHY Reset Problem Count=0x%x\n\n", ioc->name,
204 static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0)
210 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
211 "---- SAS DEVICE PAGE 0 ---------\n", ioc->name));
212 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handle=0x%X\n",
213 ioc->name, le16_to_cpu(pg0->DevHandle)));
214 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Handle=0x%X\n",
215 ioc->name, le16_to_cpu(pg0->ParentDevHandle)));
216 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Enclosure Handle=0x%X\n",
217 ioc->name, le16_to_cpu(pg0->EnclosureHandle)));
218 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Slot=0x%X\n",
219 ioc->name, le16_to_cpu(pg0->Slot)));
220 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SAS Address=0x%llX\n",
221 ioc->name, (unsigned long long)le64_to_cpu(sas_address)));
222 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Target ID=0x%X\n",
223 ioc->name, pg0->TargetID));
224 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Bus=0x%X\n",
225 ioc->name, pg0->Bus));
226 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Parent Phy Num=0x%X\n",
227 ioc->name, pg0->PhyNum));
228 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Access Status=0x%X\n",
229 ioc->name, le16_to_cpu(pg0->AccessStatus)));
230 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Device Info=0x%X\n",
231 ioc->name, le32_to_cpu(pg0->DeviceInfo)));
232 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Flags=0x%X\n",
233 ioc->name, le16_to_cpu(pg0->Flags)));
234 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n\n",
235 ioc->name, pg0->PhysicalPort));
238 static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1)
240 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
241 "---- SAS EXPANDER PAGE 1 ------------\n", ioc->name));
242 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Physical Port=0x%X\n",
243 ioc->name, pg1->PhysicalPort));
244 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PHY Identifier=0x%X\n",
245 ioc->name, pg1->PhyIdentifier));
246 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Negotiated Link Rate=0x%X\n",
247 ioc->name, pg1->NegotiatedLinkRate));
248 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Programmed Link Rate=0x%X\n",
249 ioc->name, pg1->ProgrammedLinkRate));
250 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Hardware Link Rate=0x%X\n",
251 ioc->name, pg1->HwLinkRate));
252 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Owner Device Handle=0x%X\n",
253 ioc->name, le16_to_cpu(pg1->OwnerDevHandle)));
254 dsasprintk(ioc, printk(MYIOC_s_DEBUG_FMT
255 "Attached Device Handle=0x%X\n\n", ioc->name,
261 mptsas_fw_event_off(MPT_ADAPTER *ioc)
265 spin_lock_irqsave(&ioc->fw_event_lock, flags);
266 ioc->fw_events_off = 1;
267 ioc->sas_discovery_quiesce_io = 0;
268 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
274 mptsas_fw_event_on(MPT_ADAPTER *ioc)
278 spin_lock_irqsave(&ioc->fw_event_lock, flags);
279 ioc->fw_events_off = 0;
280 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
285 mptsas_add_fw_event(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
290 spin_lock_irqsave(&ioc->fw_event_lock, flags);
291 list_add_tail(&fw_event->list, &ioc->fw_event_list);
293 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: add (fw_event=0x%p)"
294 "on cpuid %d\n", ioc->name, __func__,
296 queue_delayed_work_on(smp_processor_id(), ioc->fw_event_q,
298 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
303 mptsas_requeue_fw_event(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
307 spin_lock_irqsave(&ioc->fw_event_lock, flags);
308 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: reschedule task "
309 "(fw_event=0x%p)on cpuid %d\n", ioc->name, __func__,
312 queue_delayed_work_on(smp_processor_id(), ioc->fw_event_q,
314 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
319 mptsas_free_fw_event(MPT_ADAPTER *ioc, struct fw_event_work *fw_event)
323 spin_lock_irqsave(&ioc->fw_event_lock, flags);
324 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: kfree (fw_event=0x%p)\n",
325 ioc->name, __func__, fw_event));
328 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
334 mptsas_cleanup_fw_event_q(MPT_ADAPTER *ioc)
338 MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
344 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
346 ioc->name, __func__,
353 if (list_empty(&ioc->fw_event_list) ||
354 !ioc->fw_event_q || in_interrupt())
357 list_for_each_entry_safe(fw_event, next, &ioc->fw_event_list, list) {
359 mptsas_free_fw_event(ioc, fw_event);
367 return ((MPT_SCSI_HOST *)shost->hostdata)->ioc;
373 return ((MPT_SCSI_HOST *)shost->hostdata)->ioc;
382 mptsas_find_portinfo_by_handle(MPT_ADAPTER *ioc, u16 handle)
387 list_for_each_entry(port_info, &ioc->sas_topology, list)
399 * @ioc: Pointer to MPT_ADAPTER structure
406 mptsas_find_portinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address)
411 if (sas_address >= ioc->hba_port_sas_addr &&
412 sas_address < (ioc->hba_port_sas_addr +
413 ioc->hba_port_num_phy))
414 return ioc->hba_port_info;
416 mutex_lock(&ioc->sas_topology_mutex);
417 list_for_each_entry(port_info, &ioc->sas_topology, list)
425 mutex_unlock(&ioc->sas_topology_mutex);
451 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
463 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: [%p]: num_phys=%02d "
464 "bitmask=0x%016llX\n", ioc->name, __func__, port_details,
472 mptsas_set_rphy(ioc, phy_info, NULL);
488 mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
492 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
493 ioc->name, rphy));
497 dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
498 &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
499 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
500 ioc->name, rphy, rphy->dev.release));
514 mptsas_set_port(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_port *port)
520 dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
521 &port->dev, MYIOC_s_FMT "add:", ioc->name));
522 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "port=%p release=%p\n",
523 ioc->name, port, port->dev.release));
546 * @ioc: Pointer to MPT_ADAPTER structure
554 mptsas_add_device_component(MPT_ADAPTER *ioc, u8 channel, u8 id,
565 mutex_lock(&ioc->sas_device_info_mutex);
566 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
592 list_add_tail(&sas_info->list, &ioc->sas_device_info_list);
597 shost_for_each_device(sdev, ioc->sh) {
607 mutex_unlock(&ioc->sas_device_info_mutex);
613 * @ioc: Pointer to MPT_ADAPTER structure
619 mptsas_add_device_component_by_fw(MPT_ADAPTER *ioc, u8 channel, u8 id)
625 rc = mptsas_sas_device_pg0(ioc, &sas_device,
633 mptsas_sas_enclosure_pg0(ioc, &enclosure_info,
638 mptsas_add_device_component(ioc, sas_device.channel,
645 * @ioc: Pointer to MPT_ADAPTER structure
651 mptsas_add_device_component_starget_ir(MPT_ADAPTER *ioc,
671 if (mpt_config(ioc, &cfg) != 0)
677 buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
686 if (mpt_config(ioc, &cfg) != 0)
697 if (mpt_raid_phys_disk_pg0(ioc,
701 mptsas_add_device_component_by_fw(ioc, phys_disk.PhysDiskBus,
704 mutex_lock(&ioc->sas_device_info_mutex);
705 list_for_each_entry(sas_info, &ioc->sas_device_info_list,
714 mutex_unlock(&ioc->sas_device_info_mutex);
721 mutex_lock(&ioc->sas_device_info_mutex);
722 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
738 list_add_tail(&sas_info->list, &ioc->sas_device_info_list);
740 mutex_unlock(&ioc->sas_device_info_mutex);
744 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer,
750 * @ioc: Pointer to MPT_ADAPTER structure
755 mptsas_add_device_component_starget(MPT_ADAPTER *ioc,
765 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
771 mptsas_sas_enclosure_pg0(ioc, &enclosure_info,
776 mptsas_add_device_component(ioc, phy_info->attached.channel,
784 * @ioc: Pointer to MPT_ADAPTER structure
790 mptsas_del_device_component_by_os(MPT_ADAPTER *ioc, u8 channel, u8 id)
797 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
806 * @ioc: Pointer to MPT_ADAPTER structure
810 mptsas_del_device_components(MPT_ADAPTER *ioc)
814 mutex_lock(&ioc->sas_device_info_mutex);
815 list_for_each_entry_safe(sas_info, next, &ioc->sas_device_info_list,
820 mutex_unlock(&ioc->sas_device_info_mutex);
831 mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
838 mutex_lock(&ioc->sas_topology_mutex);
853 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
855 ioc->name, __func__, port_details, i));
860 devtprintk(ioc, dev_printk(KERN_DEBUG,
862 "delete phy %d, phy-obj (0x%p)\n", ioc->name,
875 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "phy_id=%d sas_address=0x%018llX\n",
876 ioc->name, i, (unsigned long long)sas_address));
894 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tForming port\n\t\t"
896 ioc->name, i, (unsigned long long)sas_address));
911 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
913 ioc->name, j, (unsigned long long)
945 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
947 "bitmask=0x%016llX\n", ioc->name, __func__,
950 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\t\tport = %p rphy=%p\n",
951 ioc->name, port_details->port, port_details->rphy));
953 dsaswideprintk(ioc, printk("\n"));
954 mutex_unlock(&ioc->sas_topology_mutex);
960 * @ioc
966 mptsas_find_vtarget(MPT_ADAPTER *ioc, u8 channel, u8 id)
972 shost_for_each_device(sdev, ioc->sh) {
989 mptsas_queue_device_delete(MPT_ADAPTER *ioc,
1000 ioc->name, __func__, __LINE__);
1006 fw_event->ioc = ioc;
1007 mptsas_add_fw_event(ioc, fw_event, msecs_to_jiffies(1));
1011 mptsas_queue_rescan(MPT_ADAPTER *ioc)
1020 ioc->name, __func__, __LINE__);
1024 fw_event->ioc = ioc;
1025 mptsas_add_fw_event(ioc, fw_event, msecs_to_jiffies(1));
1034 * @ioc
1043 mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
1047 if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0)
1051 mf = mpt_get_msg_frame(mptsasDeviceResetCtx, ioc);
1053 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
1054 "%s, no msg frames @%d!!\n", ioc->name,
1059 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request (mf=%p)\n",
1060 ioc->name, mf));
1072 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf);
1074 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1076 ioc->name, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, channel, id));
1078 mpt_put_msg_frame_hi_pri(mptsasDeviceResetCtx, ioc, mf);
1084 mpt_clear_taskmgmt_in_progress_flag(ioc);
1108 * @ioc
1113 mptsas_target_reset_queue(MPT_ADAPTER *ioc,
1116 MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
1124 vtarget = mptsas_find_vtarget(ioc, channel, id);
1133 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
1135 ioc->name, __func__, __LINE__));
1145 if (mptsas_target_reset(ioc, channel, id)) {
1162 MPT_ADAPTER *ioc = (MPT_ADAPTER *)(iocp);
1163 MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
1182 if (mptsas_target_reset(ioc, channel, id))
1190 * @ioc: Pointer to MPT_ADAPTER structure
1197 mptsas_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
1199 MPT_SCSI_HOST *hd = shost_priv(ioc->sh);
1205 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt completed: "
1206 "(mf = %p, mr = %p)\n", ioc->name, mf, mr));
1210 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1214 "term_cmnds = %d\n", ioc->name,
1223 mptscsih_taskmgmt_response_code(ioc,
1230 ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD;
1231 ioc->taskmgmt_cmds.status |= MPT_MGMT_STATUS_RF_VALID;
1232 memcpy(ioc->taskmgmt_cmds.reply, mr,
1234 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_PENDING) {
1235 ioc->taskmgmt_cmds.status &= ~MPT_MGMT_STATUS_PENDING;
1236 complete(&ioc->taskmgmt_cmds.done);
1242 mpt_clear_taskmgmt_in_progress_flag(ioc);
1250 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1252 ioc->name, jiffies_to_msecs(jiffies -
1263 if (mptsas_target_reset(ioc, channel, id))
1272 if (!ioc->fw_events_off)
1273 mptsas_queue_device_delete(ioc,
1277 ioc->schedule_target_reset(ioc);
1285 * @ioc
1290 mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1295 rc = mptscsih_ioc_reset(ioc, reset_phase);
1296 if ((ioc->bus_type != SAS) || (!rc))
1299 hd = shost_priv(ioc->sh);
1300 if (!hd->ioc)
1305 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1306 "%s: MPT_IOC_SETUP_RESET\n", ioc->name, __func__));
1307 mptsas_fw_event_off(ioc);
1310 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1311 "%s: MPT_IOC_PRE_RESET\n", ioc->name, __func__));
1314 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1315 "%s: MPT_IOC_POST_RESET\n", ioc->name, __func__));
1316 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) {
1317 ioc->sas_mgmt.status |= MPT_MGMT_STATUS_DID_IOCRESET;
1318 complete(&ioc->sas_mgmt.done);
1320 mptsas_cleanup_fw_event_q(ioc);
1321 mptsas_queue_rescan(ioc);
1346 mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure,
1369 error = mpt_config(ioc, &cfg);
1377 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
1387 error = mpt_config(ioc, &cfg);
1404 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
1412 * @ioc: Pointer to MPT_ADAPTER structure
1419 mptsas_add_end_device(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info)
1428 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1429 "%s: exit at line=%d\n", ioc->name,
1437 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1438 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1445 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1446 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1462 " phy %d, sas_addr 0x%llx\n", ioc->name, ds,
1470 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1471 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1478 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1479 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1484 mptsas_set_rphy(ioc, phy_info, rphy);
1490 * @ioc: Pointer to MPT_ADAPTER structure
1495 mptsas_del_end_device(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info)
1513 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1514 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1520 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1521 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1544 "sas_addr 0x%llx\n", ioc->name, ds, phy_info->attached.channel,
1550 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1551 "%s: fw_id=%d exit at line=%d\n", ioc->name,
1565 ioc->name, phy_info_parent->phy_id,
1571 "delete port %d, sas_addr (0x%llx)\n", ioc->name,
1574 mptsas_set_port(ioc, phy_info, NULL);
1575 mptsas_port_delete(ioc, phy_info->port_details);
1579 mptsas_refreshing_device_handles(MPT_ADAPTER *ioc,
1586 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
1593 mutex_lock(&ioc->sas_topology_mutex);
1608 mutex_unlock(&ioc->sas_topology_mutex);
1624 MPT_ADAPTER *ioc = fw_event->ioc;
1628 if (ioc->in_rescan) {
1629 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1631 ioc->name, __func__));
1634 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: rescan after "
1635 "reset\n", ioc->name, __func__));
1636 ioc->in_rescan = 1;
1637 mptsas_not_responding_devices(ioc);
1638 mptsas_scan_sas_topology(ioc);
1639 ioc->in_rescan = 0;
1640 mptsas_free_fw_event(ioc, fw_event);
1641 mptsas_fw_event_on(ioc);
1646 if (ioc->fw_events_off) {
1647 mptsas_free_fw_event(ioc, fw_event);
1651 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s: fw_event=(0x%p), "
1652 "event = (0x%02x)\n", ioc->name, __func__, fw_event,
1666 mptbase_sas_persist_operation(ioc,
1668 mptsas_free_fw_event(ioc, fw_event);
1692 MPT_ADAPTER *ioc = hd->ioc;
1705 mptsas_add_device_component_starget_ir(ioc, scsi_target(sdev));
1711 mptsas_add_device_component_starget(ioc, scsi_target(sdev));
1727 MPT_ADAPTER *ioc = hd->ioc;
1734 vtarget->ioc_id = ioc->id;
1743 if (!ioc->raid_data.pIocPg2) {
1747 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
1748 if (id == ioc->raid_data.pIocPg2->
1750 channel = ioc->raid_data.pIocPg2->
1759 mutex_lock(&ioc->sas_topology_mutex);
1760 list_for_each_entry(p, &ioc->sas_topology, list) {
1772 if (mptscsih_is_phys_disk(ioc, channel, id)) {
1773 id = mptscsih_raid_id_to_num(ioc,
1779 mutex_unlock(&ioc->sas_topology_mutex);
1783 mutex_unlock(&ioc->sas_topology_mutex);
1803 MPT_ADAPTER *ioc = hd->ioc;
1811 mptsas_del_device_component_by_os(ioc, starget->channel,
1819 list_for_each_entry(p, &ioc->sas_topology, list) {
1827 "sas_addr 0x%llx\n", ioc->name,
1854 MPT_ADAPTER *ioc = hd->ioc;
1859 ioc->name, sizeof(VirtDevice));
1869 mutex_lock(&ioc->sas_topology_mutex);
1870 list_for_each_entry(p, &ioc->sas_topology, list) {
1879 if (mptscsih_is_phys_disk(ioc,
1883 mutex_unlock(&ioc->sas_topology_mutex);
1887 mutex_unlock(&ioc->sas_topology_mutex);
1902 MPT_ADAPTER *ioc;
1912 ioc = hd->ioc;
1914 if (ioc->sas_discovery_quiesce_io)
1917 if (ioc->debug_level & MPT_DEBUG_SCSI)
1935 MPT_ADAPTER *ioc;
1946 ioc = hd->ioc;
1947 if (ioc->bus_type != SAS) {
1956 if (ioc->ioc_reset_in_progress) {
1957 dtmprintk(ioc, printk(MYIOC_s_WARN_FMT ": %s: ioc is in reset,"
1959 ioc->name, __func__, sc));
1965 dtmprintk(ioc, printk(MYIOC_s_WARN_FMT ": %s: target removed "
1967 ioc->name, __func__, sc));
2005 MPT_ADAPTER *ioc = phy_to_ioc(phy);
2031 error = mpt_config(ioc, &cfg);
2037 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2045 error = mpt_config(ioc, &cfg);
2049 mptsas_print_phy_pg1(ioc, buffer);
2060 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2065 static int mptsas_mgmt_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req,
2068 ioc->sas_mgmt.status |= MPT_MGMT_STATUS_COMMAND_GOOD;
2070 ioc->sas_mgmt.status |= MPT_MGMT_STATUS_RF_VALID;
2071 memcpy(ioc->sas_mgmt.reply, reply,
2072 min(ioc->reply_sz, 4 * reply->u.reply.MsgLength));
2075 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_PENDING) {
2076 ioc->sas_mgmt.status &= ~MPT_MGMT_STATUS_PENDING;
2077 complete(&ioc->sas_mgmt.done);
2085 MPT_ADAPTER *ioc = phy_to_ioc(phy);
2101 if (mutex_lock_interruptible(&ioc->sas_mgmt.mutex))
2104 mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
2119 INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status)
2120 mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
2122 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done,
2124 if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
2126 mpt_free_msg_frame(ioc, mf);
2127 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET)
2130 mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
2135 if ((ioc->sas_mgmt.status &
2142 reply = (SasIoUnitControlReply_t *)ioc->sas_mgmt.reply;
2145 ioc->name, __func__, reply->IOCStatus, reply->IOCLogInfo);
2153 CLEAR_MGMT_STATUS(ioc->sas_mgmt.status)
2154 mutex_unlock(&ioc->sas_mgmt.mutex);
2162 MPT_ADAPTER *ioc = rphy_to_ioc(rphy);
2168 mutex_lock(&ioc->sas_topology_mutex);
2169 list_for_each_entry(p, &ioc->sas_topology, list) {
2179 mutex_unlock(&ioc->sas_topology_mutex);
2183 mutex_unlock(&ioc->sas_topology_mutex);
2185 error = mptsas_sas_enclosure_pg0(ioc, &enclosure_info,
2196 MPT_ADAPTER *ioc = rphy_to_ioc(rphy);
2200 mutex_lock(&ioc->sas_topology_mutex);
2201 list_for_each_entry(p, &ioc->sas_topology, list) {
2212 mutex_unlock(&ioc->sas_topology_mutex);
2219 MPT_ADAPTER *ioc = ((MPT_SCSI_HOST *) shost->hostdata)->ioc;
2233 ioc->name, __func__);
2240 ioc->name, __func__, req->bio->bi_vcnt, blk_rq_bytes(req),
2245 ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex);
2249 mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
2266 mutex_lock(&ioc->sas_topology_mutex);
2267 port_info = ioc->hba_port_info;
2271 mutex_unlock(&ioc->sas_topology_mutex);
2286 dma_addr_out = pci_map_single(ioc->pcidev, bio_data(req->bio),
2290 ioc->add_sge(psge, flagsLength, dma_addr_out);
2291 psge += ioc->SGE_size;
2301 dma_addr_in = pci_map_single(ioc->pcidev, bio_data(rsp->bio),
2305 ioc->add_sge(psge, flagsLength, dma_addr_in);
2307 INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status)
2308 mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
2310 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
2311 if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
2313 mpt_free_msg_frame(ioc, mf);
2315 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET)
2318 mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
2323 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_RF_VALID) {
2326 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
2334 ioc->name, __func__);
2339 pci_unmap_single(ioc->pcidev, dma_addr_out, blk_rq_bytes(req),
2342 pci_unmap_single(ioc->pcidev, dma_addr_in, blk_rq_bytes(rsp),
2346 mpt_free_msg_frame(ioc, mf);
2348 CLEAR_MGMT_STATUS(ioc->sas_mgmt.status)
2349 mutex_unlock(&ioc->sas_mgmt.mutex);
2365 mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
2388 error = mpt_config(ioc, &cfg);
2396 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2406 error = mpt_config(ioc, &cfg);
2418 ioc->nvdata_version_persistent =
2420 ioc->nvdata_version_default =
2424 mptsas_print_phy_data(ioc, &buffer->PhyData[i]);
2436 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2443 mptsas_sas_io_unit_pg1(MPT_ADAPTER *ioc)
2463 error = mpt_config(ioc, &cfg);
2471 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2481 error = mpt_config(ioc, &cfg);
2485 ioc->io_missing_delay =
2488 ioc->device_missing_delay = (device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_UNIT_16) ?
2493 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2500 mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
2526 error = mpt_config(ioc, &cfg);
2535 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2545 error = mpt_config(ioc, &cfg);
2549 mptsas_print_phy_pg0(ioc, buffer);
2557 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2564 mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
2590 error = mpt_config(ioc, &cfg);
2598 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2608 error = mpt_config(ioc, &cfg);
2618 mptsas_print_device_pg0(ioc, buffer);
2638 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2645 mptsas_sas_expander_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info,
2672 error = mpt_config(ioc, &cfg);
2681 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2691 error = mpt_config(ioc, &cfg);
2721 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2728 mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
2752 error = mpt_config(ioc, &cfg);
2761 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2771 error = mpt_config(ioc, &cfg);
2782 mptsas_print_expander_pg1(ioc, buffer);
2794 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
2829 * @ioc: per adapter object
2838 mptsas_exp_repmanufacture_info(MPT_ADAPTER *ioc,
2855 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
2856 if (ioc->ioc_reset_in_progress) {
2857 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
2859 __func__, ioc->name);
2862 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
2864 ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex);
2868 mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
2879 data_out = pci_alloc_consistent(ioc->pcidev, sz, &data_out_dma);
2908 ioc->add_sge(psge, flagsLength, data_out_dma);
2909 psge += ioc->SGE_size;
2917 ioc->add_sge(psge, flagsLength, data_out_dma +
2920 INITIALIZE_MGMT_STATUS(ioc->sas_mgmt.status)
2921 mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
2923 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
2924 if (!(ioc->sas_mgmt.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
2926 mpt_free_msg_frame(ioc, mf);
2928 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_DID_IOCRESET)
2931 mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
2937 if (ioc->sas_mgmt.status & MPT_MGMT_STATUS_RF_VALID) {
2940 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
2965 ioc->name, __func__);
2970 pci_free_consistent(ioc->pcidev, sz, data_out, data_out_dma);
2973 mpt_free_msg_frame(ioc, mf);
2975 CLEAR_MGMT_STATUS(ioc->sas_mgmt.status)
2976 mutex_unlock(&ioc->sas_mgmt.mutex);
3043 MPT_ADAPTER *ioc;
3164 ioc = phy_to_ioc(phy_info->phy);
3176 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
3177 "%s: exit at line=%d\n", ioc->name,
3181 mptsas_set_port(ioc, phy_info, port);
3182 devtprintk(ioc, dev_printk(KERN_DEBUG, &port->dev,
3184 ioc->name, port->port_identifier,
3188 dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3190 ioc->name, phy_info->phy_id));
3193 devtprintk(ioc, dev_printk(KERN_DEBUG, &phy_info->phy->dev,
3194 MYIOC_s_FMT "add phy %d, phy-obj (0x%p)\n", ioc->name,
3219 port_info = ioc->hba_port_info;
3250 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
3251 "%s: exit at line=%d\n", ioc->name,
3259 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
3260 "%s: exit at line=%d\n", ioc->name,
3265 mptsas_set_rphy(ioc, phy_info, rphy);
3268 mptsas_exp_repmanufacture_info(ioc,
3275 vtarget = mptsas_find_vtarget(ioc,
3288 mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
3297 error = mptsas_sas_io_unit_pg0(ioc, hba);
3301 mptsas_sas_io_unit_pg1(ioc);
3302 mutex_lock(&ioc->sas_topology_mutex);
3303 port_info = ioc->hba_port_info;
3305 ioc->hba_port_info = port_info = hba;
3306 ioc->hba_port_num_phy = port_info->num_phys;
3307 list_add_tail(&port_info->list, &ioc->sas_topology);
3321 mutex_unlock(&ioc->sas_topology_mutex);
3323 ioc->num_ports = port_info->num_phys;
3326 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
3331 mptsas_sas_device_pg0(ioc, &port_info->phy_info[i].identify,
3335 if (!ioc->hba_port_sas_addr)
3336 ioc->hba_port_sas_addr =
3341 mptsas_sas_device_pg0(ioc,
3348 mptsas_setup_wide_ports(ioc, port_info);
3350 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
3351 mptsas_probe_one_phy(&ioc->sh->shost_gendev,
3352 &port_info->phy_info[i], ioc->sas_index, 1);
3363 mptsas_expander_refresh(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
3375 mptsas_sas_expander_pg1(ioc, &port_info->phy_info[i],
3379 mptsas_sas_device_pg0(ioc,
3388 mptsas_sas_device_pg0(ioc,
3398 mutex_lock(&ioc->sas_topology_mutex);
3399 parent = mptsas_find_portinfo_by_handle(ioc,
3402 mutex_unlock(&ioc->sas_topology_mutex);
3412 mutex_unlock(&ioc->sas_topology_mutex);
3414 mptsas_setup_wide_ports(ioc, port_info);
3415 for (i = 0; i < port_info->num_phys; i++, ioc->sas_index++)
3417 ioc->sas_index, 0);
3421 mptsas_expander_event_add(MPT_ADAPTER *ioc,
3448 mutex_lock(&ioc->sas_topology_mutex);
3449 list_add_tail(&port_info->list, &ioc->sas_topology);
3450 mutex_unlock(&ioc->sas_topology_mutex);
3453 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
3456 mptsas_expander_refresh(ioc, port_info);
3461 * @ioc: Pointer to MPT_ADAPTER structure
3466 mptsas_delete_expander_siblings(MPT_ADAPTER *ioc, struct mptsas_portinfo
3480 mptsas_del_end_device(ioc, phy_info);
3492 port_info = mptsas_find_portinfo_by_sas_address(ioc,
3502 mptsas_expander_delete(ioc, port_info, 1);
3510 * @ioc: Pointer to MPT_ADAPTER structure
3516 static void mptsas_expander_delete(MPT_ADAPTER *ioc,
3532 mptsas_sas_expander_pg0(ioc, &buffer,
3550 parent = mptsas_find_portinfo_by_handle(ioc,
3552 mptsas_delete_expander_siblings(ioc, parent, port_info);
3573 MYIOC_s_FMT "delete phy %d, phy-obj (0x%p)\n", ioc->name,
3580 ioc->name, port->port_identifier,
3583 mptsas_port_delete(ioc, port_details);
3588 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
3602 * @ioc: Pointer to MPT_ADAPTER structure
3612 MPT_ADAPTER *ioc;
3618 ioc = fw_event->ioc;
3623 port_info = mptsas_find_portinfo_by_sas_address(ioc, sas_address);
3636 mptsas_expander_refresh(ioc, port_info);
3638 mptsas_expander_event_add(ioc, expander_data);
3641 mptsas_expander_delete(ioc, port_info, 0);
3643 mptsas_free_fw_event(ioc, fw_event);
3649 * @ioc: Pointer to MPT_ADAPTER structure
3654 mptsas_expander_add(MPT_ADAPTER *ioc, u16 handle)
3659 if ((mptsas_sas_expander_pg0(ioc, &buffer,
3666 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
3667 "%s: exit at line=%d\n", ioc->name,
3675 mutex_lock(&ioc->sas_topology_mutex);
3676 list_add_tail(&port_info->list, &ioc->sas_topology);
3677 mutex_unlock(&ioc->sas_topology_mutex);
3679 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
3681 mptsas_expander_refresh(ioc, port_info);
3688 MPT_ADAPTER *ioc;
3696 ioc = fw_event->ioc;
3704 port_info = mptsas_find_portinfo_by_sas_address(ioc, sas_address);
3716 if (ioc->old_sas_discovery_protocal) {
3717 port_info = mptsas_expander_add(ioc,
3725 if (port_info == ioc->hba_port_info)
3726 mptsas_probe_hba_phys(ioc);
3728 mptsas_expander_refresh(ioc, port_info);
3740 if (ioc->device_missing_delay &&
3747 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3749 ioc->name, phy_info->attached.id,
3752 shost_for_each_device(sdev, ioc->sh) {
3764 devtprintk(ioc,
3767 "%d\n", ioc->name,
3775 mptsas_free_fw_event(ioc, fw_event);
3779 mptsas_not_responding_devices(MPT_ADAPTER *ioc)
3791 mpt_findImVolumes(ioc);
3793 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
3794 if (ioc->ioc_reset_in_progress) {
3795 dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3796 "%s: exiting due to a parallel reset \n", ioc->name,
3798 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
3801 spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
3804 mutex_lock(&ioc->sas_device_info_mutex);
3806 list_for_each_entry(sas_info, &ioc->sas_device_info_list, list) {
3813 retval = mptsas_sas_device_pg0(ioc, &sas_device,
3822 spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
3823 if (ioc->ioc_reset_in_progress) {
3824 dfailprintk(ioc,
3827 ioc->name, __func__));
3829 (&ioc->taskmgmt_lock, flags);
3830 mutex_unlock(&ioc->
3834 spin_unlock_irqrestore(&ioc->taskmgmt_lock,
3843 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3846 ioc->name, __func__,
3852 vtarget = mptsas_find_vtarget(ioc,
3858 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
3862 mptsas_del_end_device(ioc, phy_info);
3866 mptsas_volume_delete(ioc, sas_info->fw.id);
3868 mutex_unlock(&ioc->sas_device_info_mutex);
3871 mutex_lock(&ioc->sas_topology_mutex);
3873 list_for_each_entry(port_info, &ioc->sas_topology, list) {
3881 while (!mptsas_sas_expander_pg0(ioc, &buffer,
3895 mptsas_expander_delete(ioc, port_info, 0);
3899 mutex_unlock(&ioc->sas_topology_mutex);
3904 * @ioc: Pointer to MPT_ADAPTER structure
3908 mptsas_probe_expanders(MPT_ADAPTER *ioc)
3915 while (!mptsas_sas_expander_pg0(ioc, &buffer,
3920 port_info = mptsas_find_portinfo_by_sas_address(ioc,
3930 mptsas_expander_refresh(ioc, port_info);
3937 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
3938 "%s: exit at line=%d\n", ioc->name,
3946 mutex_lock(&ioc->sas_topology_mutex);
3947 list_add_tail(&port_info->list, &ioc->sas_topology);
3948 mutex_unlock(&ioc->sas_topology_mutex);
3950 "sas_addr (0x%llx)\n", ioc->name, port_info->num_phys,
3952 mptsas_expander_refresh(ioc, port_info);
3957 mptsas_probe_devices(MPT_ADAPTER *ioc)
3964 while (!(mptsas_sas_device_pg0(ioc, &sas_device,
3982 phy_info = mptsas_refreshing_device_handles(ioc, &sas_device);
3989 mptsas_add_end_device(ioc, phy_info);
3995 * @ioc: Pointer to MPT_ADAPTER structure
4000 mptsas_scan_sas_topology(MPT_ADAPTER *ioc)
4005 mptsas_probe_hba_phys(ioc);
4006 mptsas_probe_expanders(ioc);
4007 mptsas_probe_devices(ioc);
4012 if (!ioc->ir_firmware || !ioc->raid_data.pIocPg2 ||
4013 !ioc->raid_data.pIocPg2->NumActiveVolumes)
4015 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
4016 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
4017 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
4023 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL,
4024 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID);
4025 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
4026 ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
4034 MPT_ADAPTER *ioc;
4045 ioc = fw_event->ioc;
4052 mutex_lock(&ioc->sas_device_info_mutex);
4053 if (mptscsih_is_phys_disk(ioc, fw_channel, fw_id)) {
4054 list_for_each_entry(sas_info, &ioc->sas_device_info_list,
4068 list_for_each_entry(sas_info, &ioc->sas_device_info_list,
4085 mutex_unlock(&ioc->sas_device_info_mutex);
4088 shost_for_each_device(sdev, ioc->sh) {
4115 mptsas_free_fw_event(ioc, fw_event);
4120 mptsas_find_phyinfo_by_sas_address(MPT_ADAPTER *ioc, u64 sas_address)
4126 mutex_lock(&ioc->sas_topology_mutex);
4127 list_for_each_entry(port_info, &ioc->sas_topology, list) {
4139 mutex_unlock(&ioc->sas_topology_mutex);
4145 * @ioc: Pointer to MPT_ADAPTER structure
4152 mptsas_find_phyinfo_by_phys_disk_num(MPT_ADAPTER *ioc, u8 phys_disk_num,
4163 if (!ioc->raid_data.pIocPg3)
4166 num_paths = mpt_raid_phys_disk_get_num_paths(ioc, phys_disk_num);
4173 mpt_raid_phys_disk_pg1(ioc, phys_disk_num, phys_disk);
4182 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
4197 mutex_lock(&ioc->sas_topology_mutex);
4198 list_for_each_entry(port_info, &ioc->sas_topology, list) {
4213 mutex_unlock(&ioc->sas_topology_mutex);
4234 mptsas_adding_inactive_raid_components(MPT_ADAPTER *ioc, u8 channel, u8 id)
4253 if (mpt_config(ioc, &cfg) != 0)
4259 buffer = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4,
4268 if (mpt_config(ioc, &cfg) != 0)
4280 if (mpt_raid_phys_disk_pg0(ioc,
4284 if (mptsas_sas_device_pg0(ioc, &sas_device,
4299 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
4301 mptsas_add_end_device(ioc, phy_info);
4306 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer,
4313 mptsas_hotplug_work(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
4327 if (!ioc->raid_data.pIocPg2)
4330 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
4331 if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID ==
4335 "volume_id\n", ioc->name);
4336 mptsas_free_fw_event(ioc, fw_event);
4340 mpt_findImVolumes(ioc);
4344 mptsas_sas_device_pg0(ioc, &sas_device,
4360 phy_info = mptsas_refreshing_device_handles(ioc, &sas_device);
4364 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4366 "parent handle of device %x\n", ioc->name,
4368 port_info = mptsas_find_portinfo_by_handle(ioc,
4371 if (port_info == ioc->hba_port_info)
4372 mptsas_probe_hba_phys(ioc);
4374 mptsas_expander_refresh(ioc, port_info);
4376 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4378 ioc->name, __func__, __LINE__));
4382 (ioc, &sas_device);
4386 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4388 ioc->name, __func__, __LINE__));
4395 mptsas_add_end_device(ioc, phy_info);
4399 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
4401 mptsas_del_end_device(ioc, phy_info);
4406 mpt_findImVolumes(ioc);
4409 ioc, hot_plug_info->phys_disk_num,
4412 mptsas_del_end_device(ioc, phy_info);
4417 if (mptsas_sas_device_pg0(ioc, &sas_device,
4421 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4422 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4435 ioc, sas_device.sas_address);
4438 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4439 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4446 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4447 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4454 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4455 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4460 mpt_findImVolumes(ioc);
4464 ioc->name, hot_plug_info->channel, hot_plug_info->id,
4476 if (mptsas_sas_device_pg0(ioc, &sas_device,
4480 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4482 ioc->name, __func__,
4494 phy_info = mptsas_find_phyinfo_by_sas_address(ioc,
4497 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4498 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4505 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4506 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4513 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4514 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4520 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
4521 "%s: fw_id=%d exit at line=%d\n", ioc->name,
4526 mpt_findImVolumes(ioc);
4530 ioc->name, hot_plug_info->channel, hot_plug_info->id,
4538 mptsas_add_device_component_by_fw(ioc,
4544 mpt_findImVolumes(ioc);
4546 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL,
4548 scsi_add_device(ioc->sh, MPTSAS_RAID_CHANNEL,
4554 mpt_findImVolumes(ioc);
4556 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL,
4564 mpt_findImVolumes(ioc);
4565 mptsas_adding_inactive_raid_components(ioc,
4573 mptsas_free_fw_event(ioc, fw_event);
4579 MPT_ADAPTER *ioc;
4585 ioc = fw_event->ioc;
4594 mptsas_free_fw_event(ioc, fw_event);
4600 mptbase_sas_persist_operation(ioc,
4602 mptsas_free_fw_event(ioc, fw_event);
4623 mptsas_hotplug_work(ioc, fw_event, &hot_plug_info);
4627 mptbase_sas_persist_operation(ioc,
4629 mptsas_free_fw_event(ioc, fw_event);
4637 mptsas_free_fw_event(ioc, fw_event);
4645 MPT_ADAPTER *ioc;
4654 ioc = fw_event->ioc;
4668 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
4675 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Entering %s: "
4676 "ReasonCode=%02x\n", ioc->name, __func__,
4690 mpt_raid_phys_disk_pg0(ioc,
4753 mptsas_hotplug_work(ioc, fw_event, &hot_plug_info);
4755 mptsas_free_fw_event(ioc, fw_event);
4760 * @ioc: Pointer to MPT_ADAPTER structure
4772 mptsas_issue_tm(MPT_ADAPTER *ioc, u8 type, u8 channel, u8 id, u64 lun,
4781 mf = mpt_get_msg_frame(mptsasDeviceResetCtx, ioc);
4784 dtmprintk(ioc, printk(MYIOC_s_WARN_FMT "TaskMgmt request: no "
4785 "msg frames!!\n", ioc->name));
4789 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt request: mr = %p, "
4791 "fw_id = %d, lun = %lld,\n\t task_context = 0x%x\n", ioc->name, mf,
4808 INITIALIZE_MGMT_STATUS(ioc->taskmgmt_cmds.status)
4809 CLEAR_MGMT_STATUS(ioc->internal_cmds.status)
4811 mpt_put_msg_frame_hi_pri(mptsasDeviceResetCtx, ioc, mf);
4814 timeleft = wait_for_completion_timeout(&ioc->taskmgmt_cmds.done,
4816 if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
4818 dtmprintk(ioc, printk(MYIOC_s_ERR_FMT
4819 "TaskMgmt request: TIMED OUT!(mr=%p)\n", ioc->name, mf));
4820 mpt_free_msg_frame(ioc, mf);
4821 if (ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET)
4827 if (!(ioc->taskmgmt_cmds.status & MPT_MGMT_STATUS_RF_VALID)) {
4829 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4830 "TaskMgmt request: failed with no reply\n", ioc->name));
4835 CLEAR_MGMT_STATUS(ioc->taskmgmt_cmds.status)
4848 MPT_ADAPTER *ioc = fw_event->ioc;
4861 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4862 "%s - enter\n", ioc->name, __func__));
4864 mutex_lock(&ioc->taskmgmt_cmds.mutex);
4865 if (mpt_set_taskmgmt_in_progress_flag(ioc) != 0) {
4866 mutex_unlock(&ioc->taskmgmt_cmds.mutex);
4867 mptsas_requeue_fw_event(ioc, fw_event, 1000);
4874 mpt_findImVolumes(ioc);
4875 pScsiTmReply = (SCSITaskMgmtReply_t *) ioc->taskmgmt_cmds.reply;
4877 for (ii = 0; ii < ioc->req_depth; ii++) {
4878 if (ioc->fw_events_off)
4880 sc = mptscsih_get_scsi_lookup(ioc, ii);
4883 mf = MPT_INDEX_2_MFPTR(ioc, ii);
4897 if (mptsas_issue_tm(ioc, MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK,
4909 if (mptsas_issue_tm(ioc,
4918 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4920 ioc->name, __func__, query_count, termination_count));
4922 ioc->broadcast_aen_busy = 0;
4923 mpt_clear_taskmgmt_in_progress_flag(ioc);
4924 mutex_unlock(&ioc->taskmgmt_cmds.mutex);
4929 ioc->name, __func__, mpt_GetIocState(ioc, 0));
4930 mpt_Soft_Hard_ResetHandler(ioc, CAN_SLEEP);
4932 mptsas_free_fw_event(ioc, fw_event);
4939 * @ioc: Pointer to MPT_ADAPTER structure
4946 MPT_ADAPTER *ioc;
4952 ioc = fw_event->ioc;
4956 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Entering %s: "
4957 "ReasonCode=%02x\n", ioc->name, __func__, reasonCode));
4972 mpt_raid_phys_disk_pg0(ioc,
4978 mptsas_free_fw_event(ioc, fw_event);
4981 mptsas_hotplug_work(ioc, fw_event, &hot_plug_info);
4985 mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
4992 if (ioc->bus_type != SAS)
4996 if (ioc->fw_events_off)
5008 if (ioc->broadcast_aen_busy)
5010 ioc->broadcast_aen_busy = 1;
5022 mptsas_target_reset_queue(ioc, sas_event_data);
5027 ioc->device_missing_delay &&
5035 vtarget = mptsas_find_vtarget(ioc, channel, id);
5037 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5040 "fw_id %d fw_channel %d\n", ioc->name,
5044 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5046 ioc->name));
5048 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5050 ioc->name));
5065 if (ioc->old_sas_discovery_protocal)
5070 ioc->device_missing_delay)
5071 delay = HZ * ioc->device_missing_delay;
5081 ioc->sas_discovery_quiesce_io = discovery_status ? 1 : 0;
5082 if (ioc->old_sas_discovery_protocal && !discovery_status)
5083 mptsas_queue_rescan(ioc);
5101 printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name,
5107 fw_event->ioc = ioc;
5108 mptsas_add_fw_event(ioc, fw_event, delay);
5112 /* Delete a volume when no longer listed in ioc pg2
5114 static void mptsas_volume_delete(MPT_ADAPTER *ioc, u8 id)
5119 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL, id, 0);
5122 if (!ioc->raid_data.pIocPg2)
5124 if (!ioc->raid_data.pIocPg2->NumActiveVolumes)
5126 for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
5127 if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id)
5131 "id %d\n", ioc->name, MPTSAS_RAID_CHANNEL, id);
5142 MPT_ADAPTER *ioc;
5155 ioc = pci_get_drvdata(pdev);
5156 mptsas_fw_event_off(ioc);
5157 ioc->DoneCtx = mptsasDoneCtx;
5158 ioc->TaskCtx = mptsasTaskCtx;
5159 ioc->InternalCtx = mptsasInternalCtx;
5160 ioc->schedule_target_reset = &mptsas_schedule_target_reset;
5161 ioc->schedule_dead_ioc_flush_running_cmds =
5165 if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) {
5168 ioc->name);
5173 if (!ioc->active) {
5175 ioc->name);
5183 for (ii = 0; ii < ioc->facts.NumberOfPorts; ii++) {
5184 if (ioc->pfacts[ii].ProtocolFlags &
5191 "Skipping ioc=%p because SCSI Initiator mode "
5192 "is NOT enabled!\n", ioc->name, ioc);
5200 ioc->name);
5205 spin_lock_irqsave(&ioc->FreeQlock, flags);
5209 ioc->sh = sh;
5217 sh->can_queue = min_t(int, ioc->req_depth - 10, sh->can_queue);
5224 sh->unique_id = ioc->id;
5226 INIT_LIST_HEAD(&ioc->sas_topology);
5227 mutex_init(&ioc->sas_topology_mutex);
5228 mutex_init(&ioc->sas_discovery_mutex);
5229 mutex_init(&ioc->sas_mgmt.mutex);
5230 init_completion(&ioc->sas_mgmt.done);
5241 scale = ioc->req_sz/ioc->SGE_size;
5242 if (ioc->sg_addr_size == sizeof(u64)) {
5244 (ioc->facts.MaxChainDepth-1) + scale +
5245 (ioc->req_sz - 60) / ioc->SGE_size;
5248 (ioc->facts.MaxChainDepth-1) + scale +
5249 (ioc->req_sz - 64) / ioc->SGE_size;
5254 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5256 ioc->name, numSGE, sh->sg_tablesize));
5265 "Range from 64 to 8192\n", ioc->name,
5269 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5271 ioc->name, mpt_loadtime_max_sectors, sh->max_sectors));
5276 hd->ioc = ioc;
5281 ioc->ScsiLookup = kcalloc(ioc->req_depth, sizeof(void *), GFP_ATOMIC);
5282 if (!ioc->ScsiLookup) {
5284 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
5287 spin_lock_init(&ioc->scsi_lookup_lock);
5289 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
5290 ioc->name, ioc->ScsiLookup));
5292 ioc->sas_data.ptClear = mpt_pt_clear;
5296 INIT_LIST_HEAD(&ioc->sas_device_info_list);
5297 mutex_init(&ioc->sas_device_info_mutex);
5299 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
5301 if (ioc->sas_data.ptClear==1) {
5303 ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
5306 error = scsi_add_host(sh, &ioc->pcidev->dev);
5308 dprintk(ioc, printk(MYIOC_s_ERR_FMT
5309 "scsi_add_host failed\n", ioc->name));
5314 if ((ioc->facts.HeaderVersion >> 8) < 0xE)
5315 ioc->old_sas_discovery_protocal = 1;
5316 mptsas_scan_sas_topology(ioc);
5317 mptsas_fw_event_on(ioc);
5329 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
5331 mptsas_fw_event_off(ioc);
5332 mptsas_cleanup_fw_event_q(ioc);
5337 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
5341 if (!ioc->sh) {
5342 printk(MYIOC_s_INFO_FMT "IOC is in Target mode\n", ioc->name);
5349 mptsas_del_device_components(ioc);
5351 ioc->sas_discovery_ignore_events = 1;
5352 sas_remove_host(ioc->sh);
5354 mutex_lock(&ioc->sas_topology_mutex);
5355 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
5358 mptsas_port_delete(ioc, p->phy_info[i].port_details);
5363 mutex_unlock(&ioc->sas_topology_mutex);
5364 ioc->hba_port_info = NULL;