Lines Matching +full:phy +full:- +full:handle
5 * Copyright (C) 2012-2014 LSI Corporation
6 * Copyright (C) 2013-2014 Avago Technologies
7 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
41 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
64 * _transport_get_port_id_by_sas_phy - get zone's port id that Phy belong to
65 * @phy: sas_phy object
70 _transport_get_port_id_by_sas_phy(struct sas_phy *phy) in _transport_get_port_id_by_sas_phy() argument
73 struct hba_port *port = phy->hostdata; in _transport_get_port_id_by_sas_phy()
76 port_id = port->port_id; in _transport_get_port_id_by_sas_phy()
82 * _transport_sas_node_find_by_sas_address - sas node search
86 * Context: Calling function should acquire ioc->sas_node_lock.
88 * Search for either hba phys or expander device based on handle, then returns
95 if (ioc->sas_hba.sas_address == sas_address) in _transport_sas_node_find_by_sas_address()
96 return &ioc->sas_hba; in _transport_sas_node_find_by_sas_address()
103 * _transport_get_port_id_by_rphy - Get Port number from rphy object
121 if (rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE || in _transport_get_port_id_by_rphy()
122 rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE) { in _transport_get_port_id_by_rphy()
123 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_get_port_id_by_rphy()
125 &ioc->sas_expander_list, list) { in _transport_get_port_id_by_rphy()
126 if (sas_expander->rphy == rphy) { in _transport_get_port_id_by_rphy()
127 port_id = sas_expander->port->port_id; in _transport_get_port_id_by_rphy()
131 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_port_id_by_rphy()
132 } else if (rphy->identify.device_type == SAS_END_DEVICE) { in _transport_get_port_id_by_rphy()
133 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_port_id_by_rphy()
136 port_id = sas_device->port->port_id; in _transport_get_port_id_by_rphy()
139 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_port_id_by_rphy()
146 * _transport_convert_phy_link_rate -
192 * _transport_set_identify - set identify for phys and end devices
194 * @handle: device handle
199 * Return: 0 for success, non-zero for failure.
202 _transport_set_identify(struct MPT3SAS_ADAPTER *ioc, u16 handle, in _transport_set_identify() argument
210 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_set_identify()
212 return -EFAULT; in _transport_set_identify()
216 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) { in _transport_set_identify()
219 return -ENXIO; in _transport_set_identify()
225 ioc_err(ioc, "handle(0x%04x), ioc_status(0x%04x) failure at %s:%d/%s()!\n", in _transport_set_identify()
226 handle, ioc_status, __FILE__, __LINE__, __func__); in _transport_set_identify()
227 return -EIO; in _transport_set_identify()
234 identify->sas_address = le64_to_cpu(sas_device_pg0.SASAddress); in _transport_set_identify()
236 /* phy number of the parent device this device is linked to */ in _transport_set_identify()
237 identify->phy_identifier = sas_device_pg0.PhyNum; in _transport_set_identify()
242 identify->device_type = SAS_PHY_UNUSED; in _transport_set_identify()
245 identify->device_type = SAS_END_DEVICE; in _transport_set_identify()
248 identify->device_type = SAS_EDGE_EXPANDER_DEVICE; in _transport_set_identify()
251 identify->device_type = SAS_FANOUT_EXPANDER_DEVICE; in _transport_set_identify()
257 identify->initiator_port_protocols |= SAS_PROTOCOL_SSP; in _transport_set_identify()
259 identify->initiator_port_protocols |= SAS_PROTOCOL_STP; in _transport_set_identify()
261 identify->initiator_port_protocols |= SAS_PROTOCOL_SMP; in _transport_set_identify()
263 identify->initiator_port_protocols |= SAS_PROTOCOL_SATA; in _transport_set_identify()
267 identify->target_port_protocols |= SAS_PROTOCOL_SSP; in _transport_set_identify()
269 identify->target_port_protocols |= SAS_PROTOCOL_STP; in _transport_set_identify()
271 identify->target_port_protocols |= SAS_PROTOCOL_SMP; in _transport_set_identify()
273 identify->target_port_protocols |= SAS_PROTOCOL_SATA; in _transport_set_identify()
279 * mpt3sas_transport_done - internal transport layer callback handler.
286 * The callback index passed is `ioc->transport_cb_idx`
298 if (ioc->transport_cmds.status == MPT3_CMD_NOT_USED) in mpt3sas_transport_done()
300 if (ioc->transport_cmds.smid != smid) in mpt3sas_transport_done()
302 ioc->transport_cmds.status |= MPT3_CMD_COMPLETE; in mpt3sas_transport_done()
304 memcpy(ioc->transport_cmds.reply, mpi_reply, in mpt3sas_transport_done()
305 mpi_reply->MsgLength*4); in mpt3sas_transport_done()
306 ioc->transport_cmds.status |= MPT3_CMD_REPLY_VALID; in mpt3sas_transport_done()
308 ioc->transport_cmds.status &= ~MPT3_CMD_PENDING; in mpt3sas_transport_done()
309 complete(&ioc->transport_cmds.done); in mpt3sas_transport_done()
342 * _transport_expander_report_manufacture - obtain SMP report_manufacture
350 * Return: 0 for success, non-zero for failure.
370 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_expander_report_manufacture()
372 return -EFAULT; in _transport_expander_report_manufacture()
375 mutex_lock(&ioc->transport_cmds.mutex); in _transport_expander_report_manufacture()
377 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_expander_report_manufacture()
379 rc = -EAGAIN; in _transport_expander_report_manufacture()
382 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_expander_report_manufacture()
388 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_expander_report_manufacture()
391 rc = -EAGAIN; in _transport_expander_report_manufacture()
397 ioc->transport_cmds.smid = smid; in _transport_expander_report_manufacture()
401 data_out = dma_alloc_coherent(&ioc->pdev->dev, data_out_sz + data_in_sz, in _transport_expander_report_manufacture()
406 rc = -ENOMEM; in _transport_expander_report_manufacture()
414 manufacture_request->smp_frame_type = 0x40; in _transport_expander_report_manufacture()
415 manufacture_request->function = 1; in _transport_expander_report_manufacture()
416 manufacture_request->reserved = 0; in _transport_expander_report_manufacture()
417 manufacture_request->request_length = 0; in _transport_expander_report_manufacture()
420 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_expander_report_manufacture()
421 mpi_request->PhysicalPort = port_id; in _transport_expander_report_manufacture()
422 mpi_request->SASAddress = cpu_to_le64(sas_address); in _transport_expander_report_manufacture()
423 mpi_request->RequestDataLength = cpu_to_le16(data_out_sz); in _transport_expander_report_manufacture()
424 psge = &mpi_request->SGL; in _transport_expander_report_manufacture()
426 ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma, in _transport_expander_report_manufacture()
430 ioc_info(ioc, "report_manufacture - send to sas_addr(0x%016llx)\n", in _transport_expander_report_manufacture()
432 init_completion(&ioc->transport_cmds.done); in _transport_expander_report_manufacture()
433 ioc->put_smid_default(ioc, smid); in _transport_expander_report_manufacture()
434 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_expander_report_manufacture()
436 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_expander_report_manufacture()
440 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_expander_report_manufacture()
445 dtransportprintk(ioc, ioc_info(ioc, "report_manufacture - complete\n")); in _transport_expander_report_manufacture()
447 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_expander_report_manufacture()
450 mpi_reply = ioc->transport_cmds.reply; in _transport_expander_report_manufacture()
453 ioc_info(ioc, "report_manufacture - reply data transfer size(%d)\n", in _transport_expander_report_manufacture()
454 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_expander_report_manufacture()
456 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_expander_report_manufacture()
461 strncpy(edev->vendor_id, manufacture_reply->vendor_id, in _transport_expander_report_manufacture()
463 strncpy(edev->product_id, manufacture_reply->product_id, in _transport_expander_report_manufacture()
465 strncpy(edev->product_rev, manufacture_reply->product_rev, in _transport_expander_report_manufacture()
467 edev->level = manufacture_reply->sas_format & 1; in _transport_expander_report_manufacture()
468 if (edev->level) { in _transport_expander_report_manufacture()
469 strncpy(edev->component_vendor_id, in _transport_expander_report_manufacture()
470 manufacture_reply->component_vendor_id, in _transport_expander_report_manufacture()
472 tmp = (u8 *)&manufacture_reply->component_id; in _transport_expander_report_manufacture()
473 edev->component_id = tmp[0] << 8 | tmp[1]; in _transport_expander_report_manufacture()
474 edev->component_revision_id = in _transport_expander_report_manufacture()
475 manufacture_reply->component_revision_id; in _transport_expander_report_manufacture()
479 ioc_info(ioc, "report_manufacture - no reply\n")); in _transport_expander_report_manufacture()
485 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_expander_report_manufacture()
487 dma_free_coherent(&ioc->pdev->dev, data_out_sz + data_in_sz, in _transport_expander_report_manufacture()
490 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_expander_report_manufacture()
496 * _transport_delete_port - helper function to removing a port
504 u64 sas_address = mpt3sas_port->remote_identify.sas_address; in _transport_delete_port()
505 struct hba_port *port = mpt3sas_port->hba_port; in _transport_delete_port()
507 mpt3sas_port->remote_identify.device_type; in _transport_delete_port()
509 dev_printk(KERN_INFO, &mpt3sas_port->port->dev, in _transport_delete_port()
513 ioc->logging_level |= MPT_DEBUG_TRANSPORT; in _transport_delete_port()
520 ioc->logging_level &= ~MPT_DEBUG_TRANSPORT; in _transport_delete_port()
524 * _transport_delete_phy - helper function to removing single phy from port
527 * @mpt3sas_phy: mpt3sas per phy object
533 u64 sas_address = mpt3sas_port->remote_identify.sas_address; in _transport_delete_phy()
535 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in _transport_delete_phy()
536 "remove: sas_addr(0x%016llx), phy(%d)\n", in _transport_delete_phy()
537 (unsigned long long) sas_address, mpt3sas_phy->phy_id); in _transport_delete_phy()
539 list_del(&mpt3sas_phy->port_siblings); in _transport_delete_phy()
540 mpt3sas_port->num_phys--; in _transport_delete_phy()
541 sas_port_delete_phy(mpt3sas_port->port, mpt3sas_phy->phy); in _transport_delete_phy()
542 mpt3sas_phy->phy_belongs_to_port = 0; in _transport_delete_phy()
546 * _transport_add_phy - helper function to adding single phy to port
549 * @mpt3sas_phy: mpt3sas per phy object
555 u64 sas_address = mpt3sas_port->remote_identify.sas_address; in _transport_add_phy()
557 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in _transport_add_phy()
558 "add: sas_addr(0x%016llx), phy(%d)\n", (unsigned long long) in _transport_add_phy()
559 sas_address, mpt3sas_phy->phy_id); in _transport_add_phy()
561 list_add_tail(&mpt3sas_phy->port_siblings, &mpt3sas_port->phy_list); in _transport_add_phy()
562 mpt3sas_port->num_phys++; in _transport_add_phy()
563 sas_port_add_phy(mpt3sas_port->port, mpt3sas_phy->phy); in _transport_add_phy()
564 mpt3sas_phy->phy_belongs_to_port = 1; in _transport_add_phy()
568 * mpt3sas_transport_add_phy_to_an_existing_port - adding new phy to existing port
571 * @mpt3sas_phy: mpt3sas per phy object
572 * @sas_address: sas address of device/expander were phy needs to be added to
583 if (mpt3sas_phy->phy_belongs_to_port == 1) in mpt3sas_transport_add_phy_to_an_existing_port()
589 list_for_each_entry(mpt3sas_port, &sas_node->sas_port_list, in mpt3sas_transport_add_phy_to_an_existing_port()
591 if (mpt3sas_port->remote_identify.sas_address != in mpt3sas_transport_add_phy_to_an_existing_port()
594 if (mpt3sas_port->hba_port != port) in mpt3sas_transport_add_phy_to_an_existing_port()
596 list_for_each_entry(phy_srch, &mpt3sas_port->phy_list, in mpt3sas_transport_add_phy_to_an_existing_port()
608 * mpt3sas_transport_del_phy_from_an_existing_port - delete phy from existing port
611 * @mpt3sas_phy: mpt3sas per phy object
620 if (mpt3sas_phy->phy_belongs_to_port == 0) in mpt3sas_transport_del_phy_from_an_existing_port()
623 list_for_each_entry_safe(mpt3sas_port, next, &sas_node->sas_port_list, in mpt3sas_transport_del_phy_from_an_existing_port()
625 list_for_each_entry(phy_srch, &mpt3sas_port->phy_list, in mpt3sas_transport_del_phy_from_an_existing_port()
632 * just delete phy. in mpt3sas_transport_del_phy_from_an_existing_port()
634 if (mpt3sas_port->num_phys == 1 && !ioc->shost_recovery) in mpt3sas_transport_del_phy_from_an_existing_port()
645 * _transport_sanity_check - sanity check when adding a new port
659 for (i = 0; i < sas_node->num_phys; i++) { in _transport_sanity_check()
660 if (sas_node->phy[i].remote_identify.sas_address != sas_address) in _transport_sanity_check()
662 if (sas_node->phy[i].port != port) in _transport_sanity_check()
664 if (sas_node->phy[i].phy_belongs_to_port == 1) in _transport_sanity_check()
666 sas_node, &sas_node->phy[i]); in _transport_sanity_check()
671 * mpt3sas_transport_port_add - insert port to the list
673 * @handle: handle of attached device
676 * Context: This function will acquire ioc->sas_node_lock.
678 * Adding new port object to the sas_node->sas_port_list.
683 mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle, in mpt3sas_transport_port_add() argument
710 INIT_LIST_HEAD(&mpt3sas_port->port_list); in mpt3sas_transport_port_add()
711 INIT_LIST_HEAD(&mpt3sas_port->phy_list); in mpt3sas_transport_port_add()
712 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
715 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
723 if ((_transport_set_identify(ioc, handle, in mpt3sas_transport_port_add()
724 &mpt3sas_port->remote_identify))) { in mpt3sas_transport_port_add()
730 if (mpt3sas_port->remote_identify.device_type == SAS_PHY_UNUSED) { in mpt3sas_transport_port_add()
736 mpt3sas_port->hba_port = hba_port; in mpt3sas_transport_port_add()
738 mpt3sas_port->remote_identify.sas_address, hba_port); in mpt3sas_transport_port_add()
740 for (i = 0; i < sas_node->num_phys; i++) { in mpt3sas_transport_port_add()
741 if (sas_node->phy[i].remote_identify.sas_address != in mpt3sas_transport_port_add()
742 mpt3sas_port->remote_identify.sas_address) in mpt3sas_transport_port_add()
744 if (sas_node->phy[i].port != hba_port) in mpt3sas_transport_port_add()
746 list_add_tail(&sas_node->phy[i].port_siblings, in mpt3sas_transport_port_add()
747 &mpt3sas_port->phy_list); in mpt3sas_transport_port_add()
748 mpt3sas_port->num_phys++; in mpt3sas_transport_port_add()
749 if (sas_node->handle <= ioc->sas_hba.num_phys) { in mpt3sas_transport_port_add()
750 if (!sas_node->phy[i].hba_vphy) { in mpt3sas_transport_port_add()
751 hba_port->phy_mask |= (1 << i); in mpt3sas_transport_port_add()
764 if (!mpt3sas_port->num_phys) { in mpt3sas_transport_port_add()
770 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
772 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
773 mpt3sas_port->hba_port); in mpt3sas_transport_port_add()
779 sas_device->pend_sas_rphy_add = 1; in mpt3sas_transport_port_add()
782 if (!sas_node->parent_dev) { in mpt3sas_transport_port_add()
787 port = sas_port_alloc_num(sas_node->parent_dev); in mpt3sas_transport_port_add()
794 list_for_each_entry(mpt3sas_phy, &mpt3sas_port->phy_list, in mpt3sas_transport_port_add()
796 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_port_add()
797 dev_printk(KERN_INFO, &port->dev, in mpt3sas_transport_port_add()
798 "add: handle(0x%04x), sas_addr(0x%016llx), phy(%d)\n", in mpt3sas_transport_port_add()
799 handle, (unsigned long long) in mpt3sas_transport_port_add()
800 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
801 mpt3sas_phy->phy_id); in mpt3sas_transport_port_add()
802 sas_port_add_phy(port, mpt3sas_phy->phy); in mpt3sas_transport_port_add()
803 mpt3sas_phy->phy_belongs_to_port = 1; in mpt3sas_transport_port_add()
804 mpt3sas_phy->port = hba_port; in mpt3sas_transport_port_add()
807 mpt3sas_port->port = port; in mpt3sas_transport_port_add()
808 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
810 sas_device->rphy = rphy; in mpt3sas_transport_port_add()
811 if (sas_node->handle <= ioc->sas_hba.num_phys) { in mpt3sas_transport_port_add()
813 hba_port->sas_address = in mpt3sas_transport_port_add()
814 sas_device->sas_address; in mpt3sas_transport_port_add()
816 vphy->sas_address = in mpt3sas_transport_port_add()
817 sas_device->sas_address; in mpt3sas_transport_port_add()
821 mpt3sas_port->remote_identify.device_type); in mpt3sas_transport_port_add()
822 if (sas_node->handle <= ioc->sas_hba.num_phys) in mpt3sas_transport_port_add()
823 hba_port->sas_address = in mpt3sas_transport_port_add()
824 mpt3sas_port->remote_identify.sas_address; in mpt3sas_transport_port_add()
827 rphy->identify = mpt3sas_port->remote_identify; in mpt3sas_transport_port_add()
834 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
835 sas_device->pend_sas_rphy_add = 0; in mpt3sas_transport_port_add()
839 dev_info(&rphy->dev, in mpt3sas_transport_port_add()
840 "add: handle(0x%04x), sas_addr(0x%016llx)\n", handle, in mpt3sas_transport_port_add()
841 (unsigned long long)mpt3sas_port->remote_identify.sas_address); in mpt3sas_transport_port_add()
843 mpt3sas_port->rphy = rphy; in mpt3sas_transport_port_add()
844 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
845 list_add_tail(&mpt3sas_port->port_list, &sas_node->sas_port_list); in mpt3sas_transport_port_add()
846 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
849 if (mpt3sas_port->remote_identify.device_type == in mpt3sas_transport_port_add()
851 mpt3sas_port->remote_identify.device_type == in mpt3sas_transport_port_add()
854 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
855 rphy_to_expander_device(rphy), hba_port->port_id); in mpt3sas_transport_port_add()
859 list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list, in mpt3sas_transport_port_add()
861 list_del(&mpt3sas_phy->port_siblings); in mpt3sas_transport_port_add()
867 * mpt3sas_transport_port_remove - remove port from the list
872 * Context: This function will acquire ioc->sas_node_lock.
875 * ioc->sas_port_list.
893 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
897 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
900 list_for_each_entry_safe(mpt3sas_port, next, &sas_node->sas_port_list, in mpt3sas_transport_port_remove()
902 if (mpt3sas_port->remote_identify.sas_address != sas_address) in mpt3sas_transport_port_remove()
904 if (mpt3sas_port->hba_port != port) in mpt3sas_transport_port_remove()
907 list_del(&mpt3sas_port->port_list); in mpt3sas_transport_port_remove()
912 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
916 if (sas_node->handle <= ioc->sas_hba.num_phys && in mpt3sas_transport_port_remove()
917 (ioc->multipath_on_hba)) { in mpt3sas_transport_port_remove()
918 if (port->vphys_mask) { in mpt3sas_transport_port_remove()
920 &port->vphys_list, list) { in mpt3sas_transport_port_remove()
921 if (vphy->sas_address != sas_address) in mpt3sas_transport_port_remove()
925 vphy, port, port->port_id); in mpt3sas_transport_port_remove()
926 port->vphys_mask &= ~vphy->phy_mask; in mpt3sas_transport_port_remove()
927 list_del(&vphy->list); in mpt3sas_transport_port_remove()
933 &ioc->port_table_list, list) { in mpt3sas_transport_port_remove()
938 * - hba_port object's sas address matches with current in mpt3sas_transport_port_remove()
941 * - Current removed device is a vSES device and in mpt3sas_transport_port_remove()
946 if ((hba_port->sas_address == sas_address || in mpt3sas_transport_port_remove()
947 !hba_port->sas_address) && !hba_port->vphys_mask) { in mpt3sas_transport_port_remove()
950 hba_port, hba_port->port_id); in mpt3sas_transport_port_remove()
951 list_del(&hba_port->list); in mpt3sas_transport_port_remove()
953 } else if (hba_port->sas_address == sas_address && in mpt3sas_transport_port_remove()
954 hba_port->vphys_mask) { in mpt3sas_transport_port_remove()
964 hba_port, hba_port->port_id); in mpt3sas_transport_port_remove()
965 port->sas_address = 0; in mpt3sas_transport_port_remove()
971 for (i = 0; i < sas_node->num_phys; i++) { in mpt3sas_transport_port_remove()
972 if (sas_node->phy[i].remote_identify.sas_address == sas_address) in mpt3sas_transport_port_remove()
973 memset(&sas_node->phy[i].remote_identify, 0 , in mpt3sas_transport_port_remove()
977 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
980 &mpt3sas_port->phy_list, port_siblings) { in mpt3sas_transport_port_remove()
981 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_port_remove()
982 dev_printk(KERN_INFO, &mpt3sas_port->port->dev, in mpt3sas_transport_port_remove()
983 "remove: sas_addr(0x%016llx), phy(%d)\n", in mpt3sas_transport_port_remove()
985 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_remove()
986 mpt3sas_phy->phy_id); in mpt3sas_transport_port_remove()
987 mpt3sas_phy->phy_belongs_to_port = 0; in mpt3sas_transport_port_remove()
988 if (!ioc->remove_host) in mpt3sas_transport_port_remove()
989 sas_port_delete_phy(mpt3sas_port->port, in mpt3sas_transport_port_remove()
990 mpt3sas_phy->phy); in mpt3sas_transport_port_remove()
991 list_del(&mpt3sas_phy->port_siblings); in mpt3sas_transport_port_remove()
993 if (!ioc->remove_host) in mpt3sas_transport_port_remove()
994 sas_port_delete(mpt3sas_port->port); in mpt3sas_transport_port_remove()
1001 * mpt3sas_transport_add_host_phy - report sas_host phy to transport
1003 * @mpt3sas_phy: mpt3sas per phy object
1004 * @phy_pg0: sas phy page 0
1007 * Return: 0 for success, non-zero for failure.
1013 struct sas_phy *phy; in mpt3sas_transport_add_host_phy() local
1014 int phy_index = mpt3sas_phy->phy_id; in mpt3sas_transport_add_host_phy()
1017 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings); in mpt3sas_transport_add_host_phy()
1018 phy = sas_phy_alloc(parent_dev, phy_index); in mpt3sas_transport_add_host_phy()
1019 if (!phy) { in mpt3sas_transport_add_host_phy()
1022 return -1; in mpt3sas_transport_add_host_phy()
1024 if ((_transport_set_identify(ioc, mpt3sas_phy->handle, in mpt3sas_transport_add_host_phy()
1025 &mpt3sas_phy->identify))) { in mpt3sas_transport_add_host_phy()
1028 sas_phy_free(phy); in mpt3sas_transport_add_host_phy()
1029 return -1; in mpt3sas_transport_add_host_phy()
1031 phy->identify = mpt3sas_phy->identify; in mpt3sas_transport_add_host_phy()
1032 mpt3sas_phy->attached_handle = le16_to_cpu(phy_pg0.AttachedDevHandle); in mpt3sas_transport_add_host_phy()
1033 if (mpt3sas_phy->attached_handle) in mpt3sas_transport_add_host_phy()
1034 _transport_set_identify(ioc, mpt3sas_phy->attached_handle, in mpt3sas_transport_add_host_phy()
1035 &mpt3sas_phy->remote_identify); in mpt3sas_transport_add_host_phy()
1036 phy->identify.phy_identifier = mpt3sas_phy->phy_id; in mpt3sas_transport_add_host_phy()
1037 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1039 phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1041 phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1043 phy->minimum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1045 phy->maximum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1047 phy->hostdata = mpt3sas_phy->port; in mpt3sas_transport_add_host_phy()
1049 if ((sas_phy_add(phy))) { in mpt3sas_transport_add_host_phy()
1052 sas_phy_free(phy); in mpt3sas_transport_add_host_phy()
1053 return -1; in mpt3sas_transport_add_host_phy()
1055 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_add_host_phy()
1056 dev_printk(KERN_INFO, &phy->dev, in mpt3sas_transport_add_host_phy()
1057 "add: handle(0x%04x), sas_addr(0x%016llx)\n" in mpt3sas_transport_add_host_phy()
1059 mpt3sas_phy->handle, (unsigned long long) in mpt3sas_transport_add_host_phy()
1060 mpt3sas_phy->identify.sas_address, in mpt3sas_transport_add_host_phy()
1061 mpt3sas_phy->attached_handle, in mpt3sas_transport_add_host_phy()
1063 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_add_host_phy()
1064 mpt3sas_phy->phy = phy; in mpt3sas_transport_add_host_phy()
1070 * mpt3sas_transport_add_expander_phy - report expander phy to transport
1072 * @mpt3sas_phy: mpt3sas per phy object
1076 * Return: 0 for success, non-zero for failure.
1083 struct sas_phy *phy; in mpt3sas_transport_add_expander_phy() local
1084 int phy_index = mpt3sas_phy->phy_id; in mpt3sas_transport_add_expander_phy()
1086 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings); in mpt3sas_transport_add_expander_phy()
1087 phy = sas_phy_alloc(parent_dev, phy_index); in mpt3sas_transport_add_expander_phy()
1088 if (!phy) { in mpt3sas_transport_add_expander_phy()
1091 return -1; in mpt3sas_transport_add_expander_phy()
1093 if ((_transport_set_identify(ioc, mpt3sas_phy->handle, in mpt3sas_transport_add_expander_phy()
1094 &mpt3sas_phy->identify))) { in mpt3sas_transport_add_expander_phy()
1097 sas_phy_free(phy); in mpt3sas_transport_add_expander_phy()
1098 return -1; in mpt3sas_transport_add_expander_phy()
1100 phy->identify = mpt3sas_phy->identify; in mpt3sas_transport_add_expander_phy()
1101 mpt3sas_phy->attached_handle = in mpt3sas_transport_add_expander_phy()
1103 if (mpt3sas_phy->attached_handle) in mpt3sas_transport_add_expander_phy()
1104 _transport_set_identify(ioc, mpt3sas_phy->attached_handle, in mpt3sas_transport_add_expander_phy()
1105 &mpt3sas_phy->remote_identify); in mpt3sas_transport_add_expander_phy()
1106 phy->identify.phy_identifier = mpt3sas_phy->phy_id; in mpt3sas_transport_add_expander_phy()
1107 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1110 phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1112 phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1114 phy->minimum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1116 phy->maximum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1118 phy->hostdata = mpt3sas_phy->port; in mpt3sas_transport_add_expander_phy()
1120 if ((sas_phy_add(phy))) { in mpt3sas_transport_add_expander_phy()
1123 sas_phy_free(phy); in mpt3sas_transport_add_expander_phy()
1124 return -1; in mpt3sas_transport_add_expander_phy()
1126 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_add_expander_phy()
1127 dev_printk(KERN_INFO, &phy->dev, in mpt3sas_transport_add_expander_phy()
1128 "add: handle(0x%04x), sas_addr(0x%016llx)\n" in mpt3sas_transport_add_expander_phy()
1130 mpt3sas_phy->handle, (unsigned long long) in mpt3sas_transport_add_expander_phy()
1131 mpt3sas_phy->identify.sas_address, in mpt3sas_transport_add_expander_phy()
1132 mpt3sas_phy->attached_handle, in mpt3sas_transport_add_expander_phy()
1134 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_add_expander_phy()
1135 mpt3sas_phy->phy = phy; in mpt3sas_transport_add_expander_phy()
1140 * mpt3sas_transport_update_links - refreshing phy link changes
1143 * @handle: attached device handle
1144 * @phy_number: phy number
1152 u64 sas_address, u16 handle, u8 phy_number, u8 link_rate, in mpt3sas_transport_update_links() argument
1160 if (ioc->shost_recovery || ioc->pci_error_recovery) in mpt3sas_transport_update_links()
1163 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1167 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1171 mpt3sas_phy = &sas_node->phy[phy_number]; in mpt3sas_transport_update_links()
1172 mpt3sas_phy->attached_handle = handle; in mpt3sas_transport_update_links()
1173 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1174 if (handle && (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5)) { in mpt3sas_transport_update_links()
1175 _transport_set_identify(ioc, handle, in mpt3sas_transport_update_links()
1176 &mpt3sas_phy->remote_identify); in mpt3sas_transport_update_links()
1177 if ((sas_node->handle <= ioc->sas_hba.num_phys) && in mpt3sas_transport_update_links()
1178 (ioc->multipath_on_hba)) { in mpt3sas_transport_update_links()
1180 &ioc->port_table_list, list) { in mpt3sas_transport_update_links()
1181 if (hba_port->sas_address == sas_address && in mpt3sas_transport_update_links()
1183 hba_port->phy_mask |= in mpt3sas_transport_update_links()
1184 (1 << mpt3sas_phy->phy_id); in mpt3sas_transport_update_links()
1188 mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address, in mpt3sas_transport_update_links()
1191 memset(&mpt3sas_phy->remote_identify, 0 , sizeof(struct in mpt3sas_transport_update_links()
1194 if (mpt3sas_phy->phy) in mpt3sas_transport_update_links()
1195 mpt3sas_phy->phy->negotiated_linkrate = in mpt3sas_transport_update_links()
1198 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_update_links()
1199 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in mpt3sas_transport_update_links()
1201 "\tlink_rate(0x%02x), phy(%d)\n" in mpt3sas_transport_update_links()
1204 link_rate, phy_number, handle, (unsigned long long) in mpt3sas_transport_update_links()
1205 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_update_links()
1209 phy_to_ioc(struct sas_phy *phy) in phy_to_ioc() argument
1211 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in phy_to_ioc()
1218 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); in rphy_to_ioc()
1222 /* report phy error log structure */
1233 /* report phy error log reply structure */
1250 * _transport_get_expander_phy_error_log - return expander counters
1252 * @phy: The sas phy object
1254 * Return: 0 for success, non-zero for failure.
1259 struct sas_phy *phy) in _transport_get_expander_phy_error_log() argument
1273 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_get_expander_phy_error_log()
1275 return -EFAULT; in _transport_get_expander_phy_error_log()
1278 mutex_lock(&ioc->transport_cmds.mutex); in _transport_get_expander_phy_error_log()
1280 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_get_expander_phy_error_log()
1282 rc = -EAGAIN; in _transport_get_expander_phy_error_log()
1285 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_get_expander_phy_error_log()
1291 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_get_expander_phy_error_log()
1294 rc = -EAGAIN; in _transport_get_expander_phy_error_log()
1299 ioc->transport_cmds.smid = smid; in _transport_get_expander_phy_error_log()
1303 data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma, in _transport_get_expander_phy_error_log()
1308 rc = -ENOMEM; in _transport_get_expander_phy_error_log()
1313 rc = -EINVAL; in _transport_get_expander_phy_error_log()
1316 phy_error_log_request->smp_frame_type = 0x40; in _transport_get_expander_phy_error_log()
1317 phy_error_log_request->function = 0x11; in _transport_get_expander_phy_error_log()
1318 phy_error_log_request->request_length = 2; in _transport_get_expander_phy_error_log()
1319 phy_error_log_request->allocated_response_length = 0; in _transport_get_expander_phy_error_log()
1320 phy_error_log_request->phy_identifier = phy->number; in _transport_get_expander_phy_error_log()
1323 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_get_expander_phy_error_log()
1324 mpi_request->PhysicalPort = _transport_get_port_id_by_sas_phy(phy); in _transport_get_expander_phy_error_log()
1325 mpi_request->VF_ID = 0; /* TODO */ in _transport_get_expander_phy_error_log()
1326 mpi_request->VP_ID = 0; in _transport_get_expander_phy_error_log()
1327 mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); in _transport_get_expander_phy_error_log()
1328 mpi_request->RequestDataLength = in _transport_get_expander_phy_error_log()
1330 psge = &mpi_request->SGL; in _transport_get_expander_phy_error_log()
1332 ioc->build_sg(ioc, psge, data_out_dma, in _transport_get_expander_phy_error_log()
1338 ioc_info(ioc, "phy_error_log - send to sas_addr(0x%016llx), phy(%d)\n", in _transport_get_expander_phy_error_log()
1339 (u64)phy->identify.sas_address, in _transport_get_expander_phy_error_log()
1340 phy->number)); in _transport_get_expander_phy_error_log()
1341 init_completion(&ioc->transport_cmds.done); in _transport_get_expander_phy_error_log()
1342 ioc->put_smid_default(ioc, smid); in _transport_get_expander_phy_error_log()
1343 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_get_expander_phy_error_log()
1345 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_get_expander_phy_error_log()
1349 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_get_expander_phy_error_log()
1354 dtransportprintk(ioc, ioc_info(ioc, "phy_error_log - complete\n")); in _transport_get_expander_phy_error_log()
1356 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_get_expander_phy_error_log()
1358 mpi_reply = ioc->transport_cmds.reply; in _transport_get_expander_phy_error_log()
1361 ioc_info(ioc, "phy_error_log - reply data transfer size(%d)\n", in _transport_get_expander_phy_error_log()
1362 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_get_expander_phy_error_log()
1364 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_get_expander_phy_error_log()
1372 ioc_info(ioc, "phy_error_log - function_result(%d)\n", in _transport_get_expander_phy_error_log()
1373 phy_error_log_reply->function_result)); in _transport_get_expander_phy_error_log()
1375 phy->invalid_dword_count = in _transport_get_expander_phy_error_log()
1376 be32_to_cpu(phy_error_log_reply->invalid_dword); in _transport_get_expander_phy_error_log()
1377 phy->running_disparity_error_count = in _transport_get_expander_phy_error_log()
1378 be32_to_cpu(phy_error_log_reply->running_disparity_error); in _transport_get_expander_phy_error_log()
1379 phy->loss_of_dword_sync_count = in _transport_get_expander_phy_error_log()
1380 be32_to_cpu(phy_error_log_reply->loss_of_dword_sync); in _transport_get_expander_phy_error_log()
1381 phy->phy_reset_problem_count = in _transport_get_expander_phy_error_log()
1382 be32_to_cpu(phy_error_log_reply->phy_reset_problem); in _transport_get_expander_phy_error_log()
1386 ioc_info(ioc, "phy_error_log - no reply\n")); in _transport_get_expander_phy_error_log()
1392 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_get_expander_phy_error_log()
1394 dma_free_coherent(&ioc->pdev->dev, sz, data_out, data_out_dma); in _transport_get_expander_phy_error_log()
1396 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_get_expander_phy_error_log()
1401 * _transport_get_linkerrors - return phy counters for both hba and expanders
1402 * @phy: The sas phy object
1404 * Return: 0 for success, non-zero for failure.
1408 _transport_get_linkerrors(struct sas_phy *phy) in _transport_get_linkerrors() argument
1410 struct MPT3SAS_ADAPTER *ioc = phy_to_ioc(phy); in _transport_get_linkerrors()
1414 struct hba_port *port = phy->hostdata; in _transport_get_linkerrors()
1415 int port_id = port->port_id; in _transport_get_linkerrors()
1417 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1419 phy->identify.sas_address, in _transport_get_linkerrors()
1421 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1422 return -EINVAL; in _transport_get_linkerrors()
1424 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1426 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_get_linkerrors()
1427 return _transport_get_expander_phy_error_log(ioc, phy); in _transport_get_linkerrors()
1429 /* get hba phy error logs */ in _transport_get_linkerrors()
1431 phy->number))) { in _transport_get_linkerrors()
1434 return -ENXIO; in _transport_get_linkerrors()
1438 ioc_info(ioc, "phy(%d), ioc_status (0x%04x), loginfo(0x%08x)\n", in _transport_get_linkerrors()
1439 phy->number, in _transport_get_linkerrors()
1443 phy->invalid_dword_count = le32_to_cpu(phy_pg1.InvalidDwordCount); in _transport_get_linkerrors()
1444 phy->running_disparity_error_count = in _transport_get_linkerrors()
1446 phy->loss_of_dword_sync_count = in _transport_get_linkerrors()
1448 phy->phy_reset_problem_count = in _transport_get_linkerrors()
1454 * _transport_get_enclosure_identifier -
1455 * @rphy: The sas phy object
1459 * Return: 0 for success, non-zero for failure.
1469 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_enclosure_identifier()
1472 *identifier = sas_device->enclosure_logical_id; in _transport_get_enclosure_identifier()
1477 rc = -ENXIO; in _transport_get_enclosure_identifier()
1480 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_enclosure_identifier()
1485 * _transport_get_bay_identifier -
1486 * @rphy: The sas phy object
1498 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_bay_identifier()
1501 rc = sas_device->slot; in _transport_get_bay_identifier()
1504 rc = -ENXIO; in _transport_get_bay_identifier()
1506 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_bay_identifier()
1510 /* phy control request structure */
1527 /* phy control reply structure */
1540 * _transport_expander_phy_control - expander phy control
1542 * @phy: The sas phy object
1545 * Return: 0 for success, non-zero for failure.
1550 struct sas_phy *phy, u8 phy_operation) in _transport_expander_phy_control() argument
1564 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_expander_phy_control()
1566 return -EFAULT; in _transport_expander_phy_control()
1569 mutex_lock(&ioc->transport_cmds.mutex); in _transport_expander_phy_control()
1571 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_expander_phy_control()
1573 rc = -EAGAIN; in _transport_expander_phy_control()
1576 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_expander_phy_control()
1582 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_expander_phy_control()
1585 rc = -EAGAIN; in _transport_expander_phy_control()
1590 ioc->transport_cmds.smid = smid; in _transport_expander_phy_control()
1594 data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma, in _transport_expander_phy_control()
1599 rc = -ENOMEM; in _transport_expander_phy_control()
1604 rc = -EINVAL; in _transport_expander_phy_control()
1607 phy_control_request->smp_frame_type = 0x40; in _transport_expander_phy_control()
1608 phy_control_request->function = 0x91; in _transport_expander_phy_control()
1609 phy_control_request->request_length = 9; in _transport_expander_phy_control()
1610 phy_control_request->allocated_response_length = 0; in _transport_expander_phy_control()
1611 phy_control_request->phy_identifier = phy->number; in _transport_expander_phy_control()
1612 phy_control_request->phy_operation = phy_operation; in _transport_expander_phy_control()
1613 phy_control_request->programmed_min_physical_link_rate = in _transport_expander_phy_control()
1614 phy->minimum_linkrate << 4; in _transport_expander_phy_control()
1615 phy_control_request->programmed_max_physical_link_rate = in _transport_expander_phy_control()
1616 phy->maximum_linkrate << 4; in _transport_expander_phy_control()
1619 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_expander_phy_control()
1620 mpi_request->PhysicalPort = _transport_get_port_id_by_sas_phy(phy); in _transport_expander_phy_control()
1621 mpi_request->VF_ID = 0; /* TODO */ in _transport_expander_phy_control()
1622 mpi_request->VP_ID = 0; in _transport_expander_phy_control()
1623 mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); in _transport_expander_phy_control()
1624 mpi_request->RequestDataLength = in _transport_expander_phy_control()
1626 psge = &mpi_request->SGL; in _transport_expander_phy_control()
1628 ioc->build_sg(ioc, psge, data_out_dma, in _transport_expander_phy_control()
1634 ioc_info(ioc, "phy_control - send to sas_addr(0x%016llx), phy(%d), opcode(%d)\n", in _transport_expander_phy_control()
1635 (u64)phy->identify.sas_address, in _transport_expander_phy_control()
1636 phy->number, phy_operation)); in _transport_expander_phy_control()
1637 init_completion(&ioc->transport_cmds.done); in _transport_expander_phy_control()
1638 ioc->put_smid_default(ioc, smid); in _transport_expander_phy_control()
1639 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_expander_phy_control()
1641 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_expander_phy_control()
1645 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_expander_phy_control()
1650 dtransportprintk(ioc, ioc_info(ioc, "phy_control - complete\n")); in _transport_expander_phy_control()
1652 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_expander_phy_control()
1654 mpi_reply = ioc->transport_cmds.reply; in _transport_expander_phy_control()
1657 ioc_info(ioc, "phy_control - reply data transfer size(%d)\n", in _transport_expander_phy_control()
1658 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_expander_phy_control()
1660 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_expander_phy_control()
1668 ioc_info(ioc, "phy_control - function_result(%d)\n", in _transport_expander_phy_control()
1669 phy_control_reply->function_result)); in _transport_expander_phy_control()
1674 ioc_info(ioc, "phy_control - no reply\n")); in _transport_expander_phy_control()
1680 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_expander_phy_control()
1682 dma_free_coherent(&ioc->pdev->dev, sz, data_out, in _transport_expander_phy_control()
1685 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_expander_phy_control()
1690 * _transport_phy_reset -
1691 * @phy: The sas phy object
1694 * Return: 0 for success, non-zero for failure.
1697 _transport_phy_reset(struct sas_phy *phy, int hard_reset) in _transport_phy_reset() argument
1699 struct MPT3SAS_ADAPTER *ioc = phy_to_ioc(phy); in _transport_phy_reset()
1702 struct hba_port *port = phy->hostdata; in _transport_phy_reset()
1703 int port_id = port->port_id; in _transport_phy_reset()
1706 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1708 phy->identify.sas_address, in _transport_phy_reset()
1710 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1711 return -EINVAL; in _transport_phy_reset()
1713 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1715 /* handle expander phys */ in _transport_phy_reset()
1716 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_phy_reset()
1717 return _transport_expander_phy_control(ioc, phy, in _transport_phy_reset()
1721 /* handle hba phys */ in _transport_phy_reset()
1726 mpi_request.PhyNum = phy->number; in _transport_phy_reset()
1731 return -ENXIO; in _transport_phy_reset()
1735 ioc_info(ioc, "phy(%d), ioc_status(0x%04x), loginfo(0x%08x)\n", in _transport_phy_reset()
1736 phy->number, le16_to_cpu(mpi_reply.IOCStatus), in _transport_phy_reset()
1743 * _transport_phy_enable - enable/disable phys
1744 * @phy: The sas phy object
1745 * @enable: enable phy when true
1748 * Return: 0 for success, non-zero for failure.
1751 _transport_phy_enable(struct sas_phy *phy, int enable) in _transport_phy_enable() argument
1753 struct MPT3SAS_ADAPTER *ioc = phy_to_ioc(phy); in _transport_phy_enable()
1762 struct hba_port *port = phy->hostdata; in _transport_phy_enable()
1763 int port_id = port->port_id; in _transport_phy_enable()
1765 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1767 phy->identify.sas_address, in _transport_phy_enable()
1769 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1770 return -EINVAL; in _transport_phy_enable()
1772 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1774 /* handle expander phys */ in _transport_phy_enable()
1775 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_phy_enable()
1776 return _transport_expander_phy_control(ioc, phy, in _transport_phy_enable()
1780 /* handle hba phys */ in _transport_phy_enable()
1783 sz = offsetof(Mpi2SasIOUnitPage0_t, PhyData) + (ioc->sas_hba.num_phys * in _transport_phy_enable()
1789 rc = -ENOMEM; in _transport_phy_enable()
1796 rc = -ENXIO; in _transport_phy_enable()
1804 rc = -EIO; in _transport_phy_enable()
1809 for (i = 0, discovery_active = 0; i < ioc->sas_hba.num_phys ; i++) { in _transport_phy_enable()
1810 if (sas_iounit_pg0->PhyData[i].PortFlags & in _transport_phy_enable()
1812 …ioc_err(ioc, "discovery is active on port = %d, phy = %d: unable to enable/disable phys, try again… in _transport_phy_enable()
1813 sas_iounit_pg0->PhyData[i].Port, i); in _transport_phy_enable()
1819 rc = -EAGAIN; in _transport_phy_enable()
1824 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _transport_phy_enable()
1830 rc = -ENOMEM; in _transport_phy_enable()
1837 rc = -ENXIO; in _transport_phy_enable()
1845 rc = -EIO; in _transport_phy_enable()
1850 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _transport_phy_enable()
1851 sas_iounit_pg1->PhyData[i].Port = in _transport_phy_enable()
1852 sas_iounit_pg0->PhyData[i].Port; in _transport_phy_enable()
1853 sas_iounit_pg1->PhyData[i].PortFlags = in _transport_phy_enable()
1854 (sas_iounit_pg0->PhyData[i].PortFlags & in _transport_phy_enable()
1856 sas_iounit_pg1->PhyData[i].PhyFlags = in _transport_phy_enable()
1857 (sas_iounit_pg0->PhyData[i].PhyFlags & in _transport_phy_enable()
1863 sas_iounit_pg1->PhyData[phy->number].PhyFlags in _transport_phy_enable()
1866 sas_iounit_pg1->PhyData[phy->number].PhyFlags in _transport_phy_enable()
1873 _transport_phy_reset(phy, 0); in _transport_phy_enable()
1882 * _transport_phy_speed - set phy min/max link rates
1883 * @phy: The sas phy object
1888 * Return: 0 for success, non-zero for failure.
1891 _transport_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates) in _transport_phy_speed() argument
1893 struct MPT3SAS_ADAPTER *ioc = phy_to_ioc(phy); in _transport_phy_speed()
1902 struct hba_port *port = phy->hostdata; in _transport_phy_speed()
1903 int port_id = port->port_id; in _transport_phy_speed()
1905 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1907 phy->identify.sas_address, in _transport_phy_speed()
1909 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1910 return -EINVAL; in _transport_phy_speed()
1912 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1914 if (!rates->minimum_linkrate) in _transport_phy_speed()
1915 rates->minimum_linkrate = phy->minimum_linkrate; in _transport_phy_speed()
1916 else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) in _transport_phy_speed()
1917 rates->minimum_linkrate = phy->minimum_linkrate_hw; in _transport_phy_speed()
1919 if (!rates->maximum_linkrate) in _transport_phy_speed()
1920 rates->maximum_linkrate = phy->maximum_linkrate; in _transport_phy_speed()
1921 else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) in _transport_phy_speed()
1922 rates->maximum_linkrate = phy->maximum_linkrate_hw; in _transport_phy_speed()
1924 /* handle expander phys */ in _transport_phy_speed()
1925 if (phy->identify.sas_address != ioc->sas_hba.sas_address) { in _transport_phy_speed()
1926 phy->minimum_linkrate = rates->minimum_linkrate; in _transport_phy_speed()
1927 phy->maximum_linkrate = rates->maximum_linkrate; in _transport_phy_speed()
1928 return _transport_expander_phy_control(ioc, phy, in _transport_phy_speed()
1932 /* handle hba phys */ in _transport_phy_speed()
1935 sz = offsetof(Mpi2SasIOUnitPage1_t, PhyData) + (ioc->sas_hba.num_phys * in _transport_phy_speed()
1941 rc = -ENOMEM; in _transport_phy_speed()
1948 rc = -ENXIO; in _transport_phy_speed()
1956 rc = -EIO; in _transport_phy_speed()
1960 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _transport_phy_speed()
1961 if (phy->number != i) { in _transport_phy_speed()
1962 sas_iounit_pg1->PhyData[i].MaxMinLinkRate = in _transport_phy_speed()
1963 (ioc->sas_hba.phy[i].phy->minimum_linkrate + in _transport_phy_speed()
1964 (ioc->sas_hba.phy[i].phy->maximum_linkrate << 4)); in _transport_phy_speed()
1966 sas_iounit_pg1->PhyData[i].MaxMinLinkRate = in _transport_phy_speed()
1967 (rates->minimum_linkrate + in _transport_phy_speed()
1968 (rates->maximum_linkrate << 4)); in _transport_phy_speed()
1976 rc = -ENXIO; in _transport_phy_speed()
1981 _transport_phy_reset(phy, 0); in _transport_phy_speed()
1983 /* read phy page 0, then update the rates in the sas transport phy */ in _transport_phy_speed()
1985 phy->number)) { in _transport_phy_speed()
1986 phy->minimum_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
1988 phy->maximum_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
1990 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
2005 if (buf->sg_cnt > 1) { in _transport_map_smp_buffer()
2006 *p = dma_alloc_coherent(dev, buf->payload_len, dma_addr, in _transport_map_smp_buffer()
2009 return -ENOMEM; in _transport_map_smp_buffer()
2010 *dma_len = buf->payload_len; in _transport_map_smp_buffer()
2012 if (!dma_map_sg(dev, buf->sg_list, 1, DMA_BIDIRECTIONAL)) in _transport_map_smp_buffer()
2013 return -ENOMEM; in _transport_map_smp_buffer()
2014 *dma_addr = sg_dma_address(buf->sg_list); in _transport_map_smp_buffer()
2015 *dma_len = sg_dma_len(buf->sg_list); in _transport_map_smp_buffer()
2027 dma_free_coherent(dev, buf->payload_len, p, dma_addr); in _transport_unmap_smp_buffer()
2029 dma_unmap_sg(dev, buf->sg_list, 1, DMA_BIDIRECTIONAL); in _transport_unmap_smp_buffer()
2033 * _transport_smp_handler - transport portal for smp passthru
2040 * smp_rep_general /sys/class/bsg/expander-5:0
2060 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_smp_handler()
2062 rc = -EFAULT; in _transport_smp_handler()
2066 rc = mutex_lock_interruptible(&ioc->transport_cmds.mutex); in _transport_smp_handler()
2070 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_smp_handler()
2073 rc = -EAGAIN; in _transport_smp_handler()
2076 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_smp_handler()
2078 rc = _transport_map_smp_buffer(&ioc->pdev->dev, &job->request_payload, in _transport_smp_handler()
2083 sg_copy_to_buffer(job->request_payload.sg_list, in _transport_smp_handler()
2084 job->request_payload.sg_cnt, addr_out, in _transport_smp_handler()
2085 job->request_payload.payload_len); in _transport_smp_handler()
2088 rc = _transport_map_smp_buffer(&ioc->pdev->dev, &job->reply_payload, in _transport_smp_handler()
2097 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_smp_handler()
2100 rc = -EAGAIN; in _transport_smp_handler()
2106 ioc->transport_cmds.smid = smid; in _transport_smp_handler()
2109 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_smp_handler()
2110 mpi_request->PhysicalPort = _transport_get_port_id_by_rphy(ioc, rphy); in _transport_smp_handler()
2111 mpi_request->SASAddress = (rphy) ? in _transport_smp_handler()
2112 cpu_to_le64(rphy->identify.sas_address) : in _transport_smp_handler()
2113 cpu_to_le64(ioc->sas_hba.sas_address); in _transport_smp_handler()
2114 mpi_request->RequestDataLength = cpu_to_le16(dma_len_out - 4); in _transport_smp_handler()
2115 psge = &mpi_request->SGL; in _transport_smp_handler()
2117 ioc->build_sg(ioc, psge, dma_addr_out, dma_len_out - 4, dma_addr_in, in _transport_smp_handler()
2118 dma_len_in - 4); in _transport_smp_handler()
2123 init_completion(&ioc->transport_cmds.done); in _transport_smp_handler()
2124 ioc->put_smid_default(ioc, smid); in _transport_smp_handler()
2125 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_smp_handler()
2127 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_smp_handler()
2131 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) { in _transport_smp_handler()
2133 rc = -ETIMEDOUT; in _transport_smp_handler()
2138 dtransportprintk(ioc, ioc_info(ioc, "%s - complete\n", __func__)); in _transport_smp_handler()
2140 if (!(ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID)) { in _transport_smp_handler()
2143 rc = -ENXIO; in _transport_smp_handler()
2147 mpi_reply = ioc->transport_cmds.reply; in _transport_smp_handler()
2152 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_smp_handler()
2154 memcpy(job->reply, mpi_reply, sizeof(*mpi_reply)); in _transport_smp_handler()
2155 job->reply_len = sizeof(*mpi_reply); in _transport_smp_handler()
2156 reslen = le16_to_cpu(mpi_reply->ResponseDataLength); in _transport_smp_handler()
2159 sg_copy_to_buffer(job->reply_payload.sg_list, in _transport_smp_handler()
2160 job->reply_payload.sg_cnt, addr_in, in _transport_smp_handler()
2161 job->reply_payload.payload_len); in _transport_smp_handler()
2166 _transport_unmap_smp_buffer(&ioc->pdev->dev, &job->reply_payload, in _transport_smp_handler()
2169 _transport_unmap_smp_buffer(&ioc->pdev->dev, &job->request_payload, in _transport_smp_handler()
2172 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_smp_handler()
2173 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_smp_handler()