Lines Matching +full:per +full:- +full:port
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
67 * Return Port number
73 struct hba_port *port = phy->hostdata; in _transport_get_port_id_by_sas_phy() local
75 if (port) 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
83 * @ioc: per adapter object
85 * @port: hba port entry
86 * Context: Calling function should acquire ioc->sas_node_lock.
93 u64 sas_address, struct hba_port *port) in _transport_sas_node_find_by_sas_address() argument
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()
99 sas_address, port); in _transport_sas_node_find_by_sas_address()
103 * _transport_get_port_id_by_rphy - Get Port number from rphy object
104 * @ioc: per adapter object
107 * Returns Port number.
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
193 * @ioc: per adapter object
199 * Return: 0 for success, non-zero for failure.
210 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_set_identify()
212 return -EFAULT; in _transport_set_identify()
219 return -ENXIO; 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()
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.
280 * @ioc: per adapter object
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
343 * @ioc: per adapter object
346 * @port_id: Port ID number
348 * Fills in the sas_expander_device object when SMP port is created.
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
497 * @ioc: per adapter object
498 * @mpt3sas_port: mpt3sas per port object
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() local
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()
516 sas_address, port); in _transport_delete_port()
519 mpt3sas_expander_remove(ioc, sas_address, port); 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
525 * @ioc: per adapter object
526 * @mpt3sas_port: mpt3sas per port object
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()
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
547 * @ioc: per adapter object
548 * @mpt3sas_port: mpt3sas per port object
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()
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
569 * @ioc: per adapter object
571 * @mpt3sas_phy: mpt3sas per phy object
573 * @port: hba port entry
578 u64 sas_address, struct hba_port *port) in mpt3sas_transport_add_phy_to_an_existing_port() argument
583 if (mpt3sas_phy->phy_belongs_to_port == 1) in mpt3sas_transport_add_phy_to_an_existing_port()
586 if (!port) 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
609 * @ioc: per adapter object
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()
631 * Don't delete port during host reset, 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
646 * @ioc: per adapter object
649 * @port: hba port entry
655 u64 sas_address, struct hba_port *port) in _transport_sanity_check() argument
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
672 * @ioc: per adapter object
675 * @hba_port: hba port entry
676 * Context: This function will acquire ioc->sas_node_lock.
678 * Adding new port object to the sas_node->sas_port_list.
693 struct sas_port *port; in mpt3sas_transport_port_add() local
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()
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()
788 if (!port || (sas_port_add(port))) { 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()
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()
809 rphy = sas_end_device_alloc(port); 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()
820 rphy = sas_expander_alloc(port, 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()
833 rphy->identify = mpt3sas_port->remote_identify; in mpt3sas_transport_port_add()
843 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
844 sas_device->pend_sas_rphy_add = 0; in mpt3sas_transport_port_add()
848 dev_info(&rphy->dev, in mpt3sas_transport_port_add()
850 (unsigned long long)mpt3sas_port->remote_identify.sas_address); in mpt3sas_transport_port_add()
852 mpt3sas_port->rphy = rphy; in mpt3sas_transport_port_add()
853 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
854 list_add_tail(&mpt3sas_port->port_list, &sas_node->sas_port_list); in mpt3sas_transport_port_add()
855 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
858 if (mpt3sas_port->remote_identify.device_type == in mpt3sas_transport_port_add()
860 mpt3sas_port->remote_identify.device_type == in mpt3sas_transport_port_add()
863 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
864 rphy_to_expander_device(rphy), hba_port->port_id); in mpt3sas_transport_port_add()
868 sas_port_delete(port); in mpt3sas_transport_port_add()
871 list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list, in mpt3sas_transport_port_add()
873 list_del(&mpt3sas_phy->port_siblings); in mpt3sas_transport_port_add()
879 * mpt3sas_transport_port_remove - remove port from the list
880 * @ioc: per adapter object
883 * @port: hba port entry
884 * Context: This function will acquire ioc->sas_node_lock.
887 * ioc->sas_port_list.
891 u64 sas_address_parent, struct hba_port *port) in mpt3sas_transport_port_remove() argument
902 if (!port) in mpt3sas_transport_port_remove()
905 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
907 sas_address_parent, port); in mpt3sas_transport_port_remove()
909 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
912 list_for_each_entry_safe(mpt3sas_port, next, &sas_node->sas_port_list, in mpt3sas_transport_port_remove()
914 if (mpt3sas_port->remote_identify.sas_address != sas_address) in mpt3sas_transport_port_remove()
916 if (mpt3sas_port->hba_port != port) in mpt3sas_transport_port_remove()
919 list_del(&mpt3sas_port->port_list); in mpt3sas_transport_port_remove()
924 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
928 if (sas_node->handle <= ioc->sas_hba.num_phys && in mpt3sas_transport_port_remove()
929 (ioc->multipath_on_hba)) { in mpt3sas_transport_port_remove()
930 if (port->vphys_mask) { in mpt3sas_transport_port_remove()
932 &port->vphys_list, list) { in mpt3sas_transport_port_remove()
933 if (vphy->sas_address != sas_address) in mpt3sas_transport_port_remove()
936 "remove vphy entry: %p of port:%p,from %d port's vphys list\n", in mpt3sas_transport_port_remove()
937 vphy, port, port->port_id); in mpt3sas_transport_port_remove()
938 port->vphys_mask &= ~vphy->phy_mask; in mpt3sas_transport_port_remove()
939 list_del(&vphy->list); in mpt3sas_transport_port_remove()
945 &ioc->port_table_list, list) { in mpt3sas_transport_port_remove()
946 if (hba_port != port) in mpt3sas_transport_port_remove()
950 * - hba_port object's sas address matches with current in mpt3sas_transport_port_remove()
953 * - Current removed device is a vSES device and in mpt3sas_transport_port_remove()
955 * this vSES device's port number (hence hba_port in mpt3sas_transport_port_remove()
958 if ((hba_port->sas_address == sas_address || in mpt3sas_transport_port_remove()
959 !hba_port->sas_address) && !hba_port->vphys_mask) { in mpt3sas_transport_port_remove()
961 "remove hba_port entry: %p port: %d from hba_port list\n", in mpt3sas_transport_port_remove()
962 hba_port, hba_port->port_id); in mpt3sas_transport_port_remove()
963 list_del(&hba_port->list); in mpt3sas_transport_port_remove()
965 } else if (hba_port->sas_address == sas_address && in mpt3sas_transport_port_remove()
966 hba_port->vphys_mask) { in mpt3sas_transport_port_remove()
969 * and a vSES device has the same port number in mpt3sas_transport_port_remove()
970 * as of current device's port number. Hence in mpt3sas_transport_port_remove()
975 "clearing sas_address from hba_port entry: %p port: %d from hba_port list\n", in mpt3sas_transport_port_remove()
976 hba_port, hba_port->port_id); in mpt3sas_transport_port_remove()
977 port->sas_address = 0; in mpt3sas_transport_port_remove()
983 for (i = 0; i < sas_node->num_phys; i++) { in mpt3sas_transport_port_remove()
984 if (sas_node->phy[i].remote_identify.sas_address == sas_address) in mpt3sas_transport_port_remove()
985 memset(&sas_node->phy[i].remote_identify, 0 , in mpt3sas_transport_port_remove()
989 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
992 &mpt3sas_port->phy_list, port_siblings) { in mpt3sas_transport_port_remove()
993 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_port_remove()
994 dev_printk(KERN_INFO, &mpt3sas_port->port->dev, in mpt3sas_transport_port_remove()
997 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_remove()
998 mpt3sas_phy->phy_id); in mpt3sas_transport_port_remove()
999 mpt3sas_phy->phy_belongs_to_port = 0; in mpt3sas_transport_port_remove()
1000 if (!ioc->remove_host) in mpt3sas_transport_port_remove()
1001 sas_port_delete_phy(mpt3sas_port->port, in mpt3sas_transport_port_remove()
1002 mpt3sas_phy->phy); in mpt3sas_transport_port_remove()
1003 list_del(&mpt3sas_phy->port_siblings); in mpt3sas_transport_port_remove()
1005 if (!ioc->remove_host) in mpt3sas_transport_port_remove()
1006 sas_port_delete(mpt3sas_port->port); in mpt3sas_transport_port_remove()
1013 * mpt3sas_transport_add_host_phy - report sas_host phy to transport
1014 * @ioc: per adapter object
1015 * @mpt3sas_phy: mpt3sas per phy object
1019 * Return: 0 for success, non-zero for failure.
1026 int phy_index = mpt3sas_phy->phy_id; in mpt3sas_transport_add_host_phy()
1029 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings); in mpt3sas_transport_add_host_phy()
1034 return -1; in mpt3sas_transport_add_host_phy()
1036 if ((_transport_set_identify(ioc, mpt3sas_phy->handle, in mpt3sas_transport_add_host_phy()
1037 &mpt3sas_phy->identify))) { in mpt3sas_transport_add_host_phy()
1041 return -1; in mpt3sas_transport_add_host_phy()
1043 phy->identify = mpt3sas_phy->identify; in mpt3sas_transport_add_host_phy()
1044 mpt3sas_phy->attached_handle = le16_to_cpu(phy_pg0.AttachedDevHandle); in mpt3sas_transport_add_host_phy()
1045 if (mpt3sas_phy->attached_handle) in mpt3sas_transport_add_host_phy()
1046 _transport_set_identify(ioc, mpt3sas_phy->attached_handle, in mpt3sas_transport_add_host_phy()
1047 &mpt3sas_phy->remote_identify); in mpt3sas_transport_add_host_phy()
1048 phy->identify.phy_identifier = mpt3sas_phy->phy_id; in mpt3sas_transport_add_host_phy()
1049 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1051 phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1053 phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1055 phy->minimum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1057 phy->maximum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1059 phy->hostdata = mpt3sas_phy->port; in mpt3sas_transport_add_host_phy()
1065 return -1; in mpt3sas_transport_add_host_phy()
1067 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_add_host_phy()
1068 dev_printk(KERN_INFO, &phy->dev, in mpt3sas_transport_add_host_phy()
1071 mpt3sas_phy->handle, (unsigned long long) in mpt3sas_transport_add_host_phy()
1072 mpt3sas_phy->identify.sas_address, in mpt3sas_transport_add_host_phy()
1073 mpt3sas_phy->attached_handle, in mpt3sas_transport_add_host_phy()
1075 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_add_host_phy()
1076 mpt3sas_phy->phy = phy; in mpt3sas_transport_add_host_phy()
1082 * mpt3sas_transport_add_expander_phy - report expander phy to transport
1083 * @ioc: per adapter object
1084 * @mpt3sas_phy: mpt3sas per phy object
1088 * Return: 0 for success, non-zero for failure.
1096 int phy_index = mpt3sas_phy->phy_id; in mpt3sas_transport_add_expander_phy()
1098 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings); in mpt3sas_transport_add_expander_phy()
1103 return -1; in mpt3sas_transport_add_expander_phy()
1105 if ((_transport_set_identify(ioc, mpt3sas_phy->handle, in mpt3sas_transport_add_expander_phy()
1106 &mpt3sas_phy->identify))) { in mpt3sas_transport_add_expander_phy()
1110 return -1; in mpt3sas_transport_add_expander_phy()
1112 phy->identify = mpt3sas_phy->identify; in mpt3sas_transport_add_expander_phy()
1113 mpt3sas_phy->attached_handle = in mpt3sas_transport_add_expander_phy()
1115 if (mpt3sas_phy->attached_handle) in mpt3sas_transport_add_expander_phy()
1116 _transport_set_identify(ioc, mpt3sas_phy->attached_handle, in mpt3sas_transport_add_expander_phy()
1117 &mpt3sas_phy->remote_identify); in mpt3sas_transport_add_expander_phy()
1118 phy->identify.phy_identifier = mpt3sas_phy->phy_id; in mpt3sas_transport_add_expander_phy()
1119 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1122 phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1124 phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1126 phy->minimum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1128 phy->maximum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1130 phy->hostdata = mpt3sas_phy->port; in mpt3sas_transport_add_expander_phy()
1136 return -1; in mpt3sas_transport_add_expander_phy()
1138 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_add_expander_phy()
1139 dev_printk(KERN_INFO, &phy->dev, in mpt3sas_transport_add_expander_phy()
1142 mpt3sas_phy->handle, (unsigned long long) in mpt3sas_transport_add_expander_phy()
1143 mpt3sas_phy->identify.sas_address, in mpt3sas_transport_add_expander_phy()
1144 mpt3sas_phy->attached_handle, in mpt3sas_transport_add_expander_phy()
1146 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_add_expander_phy()
1147 mpt3sas_phy->phy = phy; in mpt3sas_transport_add_expander_phy()
1152 * mpt3sas_transport_update_links - refreshing phy link changes
1153 * @ioc: per adapter object
1158 * @port: hba port entry
1165 struct hba_port *port) in mpt3sas_transport_update_links() argument
1172 if (ioc->shost_recovery || ioc->pci_error_recovery) in mpt3sas_transport_update_links()
1175 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1177 sas_address, port); in mpt3sas_transport_update_links()
1179 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1183 mpt3sas_phy = &sas_node->phy[phy_number]; in mpt3sas_transport_update_links()
1184 mpt3sas_phy->attached_handle = handle; in mpt3sas_transport_update_links()
1185 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1188 &mpt3sas_phy->remote_identify); in mpt3sas_transport_update_links()
1189 if ((sas_node->handle <= ioc->sas_hba.num_phys) && in mpt3sas_transport_update_links()
1190 (ioc->multipath_on_hba)) { in mpt3sas_transport_update_links()
1192 &ioc->port_table_list, list) { in mpt3sas_transport_update_links()
1193 if (hba_port->sas_address == sas_address && in mpt3sas_transport_update_links()
1194 hba_port == port) in mpt3sas_transport_update_links()
1195 hba_port->phy_mask |= in mpt3sas_transport_update_links()
1196 (1 << mpt3sas_phy->phy_id); in mpt3sas_transport_update_links()
1200 mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address, in mpt3sas_transport_update_links()
1201 port); in mpt3sas_transport_update_links()
1203 memset(&mpt3sas_phy->remote_identify, 0 , sizeof(struct in mpt3sas_transport_update_links()
1206 if (mpt3sas_phy->phy) in mpt3sas_transport_update_links()
1207 mpt3sas_phy->phy->negotiated_linkrate = in mpt3sas_transport_update_links()
1210 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_update_links()
1211 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in mpt3sas_transport_update_links()
1217 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_update_links()
1223 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in phy_to_ioc()
1230 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); in rphy_to_ioc()
1262 * _transport_get_expander_phy_error_log - return expander counters
1263 * @ioc: per adapter object
1266 * Return: 0 for success, non-zero for failure.
1285 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_get_expander_phy_error_log()
1287 return -EFAULT; in _transport_get_expander_phy_error_log()
1290 mutex_lock(&ioc->transport_cmds.mutex); in _transport_get_expander_phy_error_log()
1292 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_get_expander_phy_error_log()
1294 rc = -EAGAIN; in _transport_get_expander_phy_error_log()
1297 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_get_expander_phy_error_log()
1303 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_get_expander_phy_error_log()
1306 rc = -EAGAIN; in _transport_get_expander_phy_error_log()
1311 ioc->transport_cmds.smid = smid; in _transport_get_expander_phy_error_log()
1315 data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma, in _transport_get_expander_phy_error_log()
1320 rc = -ENOMEM; in _transport_get_expander_phy_error_log()
1325 rc = -EINVAL; in _transport_get_expander_phy_error_log()
1328 phy_error_log_request->smp_frame_type = 0x40; in _transport_get_expander_phy_error_log()
1329 phy_error_log_request->function = 0x11; in _transport_get_expander_phy_error_log()
1330 phy_error_log_request->request_length = 2; in _transport_get_expander_phy_error_log()
1331 phy_error_log_request->allocated_response_length = 0; in _transport_get_expander_phy_error_log()
1332 phy_error_log_request->phy_identifier = phy->number; in _transport_get_expander_phy_error_log()
1335 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_get_expander_phy_error_log()
1336 mpi_request->PhysicalPort = _transport_get_port_id_by_sas_phy(phy); in _transport_get_expander_phy_error_log()
1337 mpi_request->VF_ID = 0; /* TODO */ in _transport_get_expander_phy_error_log()
1338 mpi_request->VP_ID = 0; in _transport_get_expander_phy_error_log()
1339 mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); in _transport_get_expander_phy_error_log()
1340 mpi_request->RequestDataLength = in _transport_get_expander_phy_error_log()
1342 psge = &mpi_request->SGL; in _transport_get_expander_phy_error_log()
1344 ioc->build_sg(ioc, psge, data_out_dma, in _transport_get_expander_phy_error_log()
1350 ioc_info(ioc, "phy_error_log - send to sas_addr(0x%016llx), phy(%d)\n", in _transport_get_expander_phy_error_log()
1351 (u64)phy->identify.sas_address, in _transport_get_expander_phy_error_log()
1352 phy->number)); in _transport_get_expander_phy_error_log()
1353 init_completion(&ioc->transport_cmds.done); in _transport_get_expander_phy_error_log()
1354 ioc->put_smid_default(ioc, smid); in _transport_get_expander_phy_error_log()
1355 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_get_expander_phy_error_log()
1357 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_get_expander_phy_error_log()
1361 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_get_expander_phy_error_log()
1366 dtransportprintk(ioc, ioc_info(ioc, "phy_error_log - complete\n")); in _transport_get_expander_phy_error_log()
1368 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_get_expander_phy_error_log()
1370 mpi_reply = ioc->transport_cmds.reply; in _transport_get_expander_phy_error_log()
1373 ioc_info(ioc, "phy_error_log - reply data transfer size(%d)\n", in _transport_get_expander_phy_error_log()
1374 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_get_expander_phy_error_log()
1376 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_get_expander_phy_error_log()
1384 ioc_info(ioc, "phy_error_log - function_result(%d)\n", in _transport_get_expander_phy_error_log()
1385 phy_error_log_reply->function_result)); in _transport_get_expander_phy_error_log()
1387 phy->invalid_dword_count = in _transport_get_expander_phy_error_log()
1388 be32_to_cpu(phy_error_log_reply->invalid_dword); in _transport_get_expander_phy_error_log()
1389 phy->running_disparity_error_count = in _transport_get_expander_phy_error_log()
1390 be32_to_cpu(phy_error_log_reply->running_disparity_error); in _transport_get_expander_phy_error_log()
1391 phy->loss_of_dword_sync_count = in _transport_get_expander_phy_error_log()
1392 be32_to_cpu(phy_error_log_reply->loss_of_dword_sync); in _transport_get_expander_phy_error_log()
1393 phy->phy_reset_problem_count = in _transport_get_expander_phy_error_log()
1394 be32_to_cpu(phy_error_log_reply->phy_reset_problem); in _transport_get_expander_phy_error_log()
1398 ioc_info(ioc, "phy_error_log - no reply\n")); in _transport_get_expander_phy_error_log()
1404 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_get_expander_phy_error_log()
1406 dma_free_coherent(&ioc->pdev->dev, sz, data_out, data_out_dma); in _transport_get_expander_phy_error_log()
1408 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_get_expander_phy_error_log()
1413 * _transport_get_linkerrors - return phy counters for both hba and expanders
1416 * Return: 0 for success, non-zero for failure.
1426 struct hba_port *port = phy->hostdata; in _transport_get_linkerrors() local
1427 int port_id = port->port_id; in _transport_get_linkerrors()
1429 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1431 phy->identify.sas_address, in _transport_get_linkerrors()
1433 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1434 return -EINVAL; in _transport_get_linkerrors()
1436 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1438 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_get_linkerrors()
1443 phy->number))) { in _transport_get_linkerrors()
1446 return -ENXIO; in _transport_get_linkerrors()
1451 phy->number, in _transport_get_linkerrors()
1455 phy->invalid_dword_count = le32_to_cpu(phy_pg1.InvalidDwordCount); in _transport_get_linkerrors()
1456 phy->running_disparity_error_count = in _transport_get_linkerrors()
1458 phy->loss_of_dword_sync_count = in _transport_get_linkerrors()
1460 phy->phy_reset_problem_count = in _transport_get_linkerrors()
1466 * _transport_get_enclosure_identifier -
1471 * Return: 0 for success, non-zero for failure.
1481 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_enclosure_identifier()
1484 *identifier = sas_device->enclosure_logical_id; in _transport_get_enclosure_identifier()
1489 rc = -ENXIO; in _transport_get_enclosure_identifier()
1492 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_enclosure_identifier()
1497 * _transport_get_bay_identifier -
1510 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_bay_identifier()
1513 rc = sas_device->slot; in _transport_get_bay_identifier()
1516 rc = -ENXIO; in _transport_get_bay_identifier()
1518 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_bay_identifier()
1552 * _transport_expander_phy_control - expander phy control
1553 * @ioc: per adapter object
1557 * Return: 0 for success, non-zero for failure.
1576 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_expander_phy_control()
1578 return -EFAULT; in _transport_expander_phy_control()
1581 mutex_lock(&ioc->transport_cmds.mutex); in _transport_expander_phy_control()
1583 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_expander_phy_control()
1585 rc = -EAGAIN; in _transport_expander_phy_control()
1588 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_expander_phy_control()
1594 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_expander_phy_control()
1597 rc = -EAGAIN; in _transport_expander_phy_control()
1602 ioc->transport_cmds.smid = smid; in _transport_expander_phy_control()
1606 data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma, in _transport_expander_phy_control()
1611 rc = -ENOMEM; in _transport_expander_phy_control()
1616 rc = -EINVAL; in _transport_expander_phy_control()
1619 phy_control_request->smp_frame_type = 0x40; in _transport_expander_phy_control()
1620 phy_control_request->function = 0x91; in _transport_expander_phy_control()
1621 phy_control_request->request_length = 9; in _transport_expander_phy_control()
1622 phy_control_request->allocated_response_length = 0; in _transport_expander_phy_control()
1623 phy_control_request->phy_identifier = phy->number; in _transport_expander_phy_control()
1624 phy_control_request->phy_operation = phy_operation; in _transport_expander_phy_control()
1625 phy_control_request->programmed_min_physical_link_rate = in _transport_expander_phy_control()
1626 phy->minimum_linkrate << 4; in _transport_expander_phy_control()
1627 phy_control_request->programmed_max_physical_link_rate = in _transport_expander_phy_control()
1628 phy->maximum_linkrate << 4; in _transport_expander_phy_control()
1631 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_expander_phy_control()
1632 mpi_request->PhysicalPort = _transport_get_port_id_by_sas_phy(phy); in _transport_expander_phy_control()
1633 mpi_request->VF_ID = 0; /* TODO */ in _transport_expander_phy_control()
1634 mpi_request->VP_ID = 0; in _transport_expander_phy_control()
1635 mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); in _transport_expander_phy_control()
1636 mpi_request->RequestDataLength = in _transport_expander_phy_control()
1638 psge = &mpi_request->SGL; in _transport_expander_phy_control()
1640 ioc->build_sg(ioc, psge, data_out_dma, in _transport_expander_phy_control()
1646 ioc_info(ioc, "phy_control - send to sas_addr(0x%016llx), phy(%d), opcode(%d)\n", in _transport_expander_phy_control()
1647 (u64)phy->identify.sas_address, in _transport_expander_phy_control()
1648 phy->number, phy_operation)); in _transport_expander_phy_control()
1649 init_completion(&ioc->transport_cmds.done); in _transport_expander_phy_control()
1650 ioc->put_smid_default(ioc, smid); in _transport_expander_phy_control()
1651 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_expander_phy_control()
1653 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_expander_phy_control()
1657 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_expander_phy_control()
1662 dtransportprintk(ioc, ioc_info(ioc, "phy_control - complete\n")); in _transport_expander_phy_control()
1664 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_expander_phy_control()
1666 mpi_reply = ioc->transport_cmds.reply; in _transport_expander_phy_control()
1669 ioc_info(ioc, "phy_control - reply data transfer size(%d)\n", in _transport_expander_phy_control()
1670 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_expander_phy_control()
1672 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_expander_phy_control()
1680 ioc_info(ioc, "phy_control - function_result(%d)\n", in _transport_expander_phy_control()
1681 phy_control_reply->function_result)); in _transport_expander_phy_control()
1686 ioc_info(ioc, "phy_control - no reply\n")); in _transport_expander_phy_control()
1692 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_expander_phy_control()
1694 dma_free_coherent(&ioc->pdev->dev, sz, data_out, in _transport_expander_phy_control()
1697 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_expander_phy_control()
1702 * _transport_phy_reset -
1706 * Return: 0 for success, non-zero for failure.
1714 struct hba_port *port = phy->hostdata; in _transport_phy_reset() local
1715 int port_id = port->port_id; in _transport_phy_reset()
1718 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1720 phy->identify.sas_address, in _transport_phy_reset()
1722 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1723 return -EINVAL; in _transport_phy_reset()
1725 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1728 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_phy_reset()
1738 mpi_request.PhyNum = phy->number; in _transport_phy_reset()
1743 return -ENXIO; in _transport_phy_reset()
1748 phy->number, le16_to_cpu(mpi_reply.IOCStatus), in _transport_phy_reset()
1755 * _transport_phy_enable - enable/disable phys
1760 * Return: 0 for success, non-zero for failure.
1774 struct hba_port *port = phy->hostdata; in _transport_phy_enable() local
1775 int port_id = port->port_id; in _transport_phy_enable()
1777 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1779 phy->identify.sas_address, in _transport_phy_enable()
1781 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1782 return -EINVAL; in _transport_phy_enable()
1784 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1787 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_phy_enable()
1795 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _transport_phy_enable()
1800 rc = -ENOMEM; in _transport_phy_enable()
1807 rc = -ENXIO; in _transport_phy_enable()
1815 rc = -EIO; in _transport_phy_enable()
1820 for (i = 0, discovery_active = 0; i < ioc->sas_hba.num_phys ; i++) { in _transport_phy_enable()
1821 if (sas_iounit_pg0->PhyData[i].PortFlags & in _transport_phy_enable()
1823 …ioc_err(ioc, "discovery is active on port = %d, phy = %d: unable to enable/disable phys, try again… in _transport_phy_enable()
1824 sas_iounit_pg0->PhyData[i].Port, i); in _transport_phy_enable()
1830 rc = -EAGAIN; in _transport_phy_enable()
1835 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _transport_phy_enable()
1840 rc = -ENOMEM; in _transport_phy_enable()
1847 rc = -ENXIO; in _transport_phy_enable()
1855 rc = -EIO; in _transport_phy_enable()
1859 /* copy Port/PortFlags/PhyFlags from page 0 */ in _transport_phy_enable()
1860 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _transport_phy_enable()
1861 sas_iounit_pg1->PhyData[i].Port = in _transport_phy_enable()
1862 sas_iounit_pg0->PhyData[i].Port; in _transport_phy_enable()
1863 sas_iounit_pg1->PhyData[i].PortFlags = in _transport_phy_enable()
1864 (sas_iounit_pg0->PhyData[i].PortFlags & in _transport_phy_enable()
1866 sas_iounit_pg1->PhyData[i].PhyFlags = in _transport_phy_enable()
1867 (sas_iounit_pg0->PhyData[i].PhyFlags & in _transport_phy_enable()
1873 sas_iounit_pg1->PhyData[phy->number].PhyFlags in _transport_phy_enable()
1876 sas_iounit_pg1->PhyData[phy->number].PhyFlags in _transport_phy_enable()
1892 * _transport_phy_speed - set phy min/max link rates
1898 * Return: 0 for success, non-zero for failure.
1912 struct hba_port *port = phy->hostdata; in _transport_phy_speed() local
1913 int port_id = port->port_id; in _transport_phy_speed()
1915 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1917 phy->identify.sas_address, in _transport_phy_speed()
1919 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1920 return -EINVAL; in _transport_phy_speed()
1922 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1924 if (!rates->minimum_linkrate) in _transport_phy_speed()
1925 rates->minimum_linkrate = phy->minimum_linkrate; in _transport_phy_speed()
1926 else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) in _transport_phy_speed()
1927 rates->minimum_linkrate = phy->minimum_linkrate_hw; in _transport_phy_speed()
1929 if (!rates->maximum_linkrate) in _transport_phy_speed()
1930 rates->maximum_linkrate = phy->maximum_linkrate; in _transport_phy_speed()
1931 else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) in _transport_phy_speed()
1932 rates->maximum_linkrate = phy->maximum_linkrate_hw; in _transport_phy_speed()
1935 if (phy->identify.sas_address != ioc->sas_hba.sas_address) { in _transport_phy_speed()
1936 phy->minimum_linkrate = rates->minimum_linkrate; in _transport_phy_speed()
1937 phy->maximum_linkrate = rates->maximum_linkrate; in _transport_phy_speed()
1945 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _transport_phy_speed()
1950 rc = -ENOMEM; in _transport_phy_speed()
1957 rc = -ENXIO; in _transport_phy_speed()
1965 rc = -EIO; in _transport_phy_speed()
1969 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _transport_phy_speed()
1970 if (phy->number != i) { in _transport_phy_speed()
1971 sas_iounit_pg1->PhyData[i].MaxMinLinkRate = in _transport_phy_speed()
1972 (ioc->sas_hba.phy[i].phy->minimum_linkrate + in _transport_phy_speed()
1973 (ioc->sas_hba.phy[i].phy->maximum_linkrate << 4)); in _transport_phy_speed()
1975 sas_iounit_pg1->PhyData[i].MaxMinLinkRate = in _transport_phy_speed()
1976 (rates->minimum_linkrate + in _transport_phy_speed()
1977 (rates->maximum_linkrate << 4)); in _transport_phy_speed()
1985 rc = -ENXIO; in _transport_phy_speed()
1994 phy->number)) { in _transport_phy_speed()
1995 phy->minimum_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
1997 phy->maximum_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
1999 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
2014 if (buf->sg_cnt > 1) { in _transport_map_smp_buffer()
2015 *p = dma_alloc_coherent(dev, buf->payload_len, dma_addr, in _transport_map_smp_buffer()
2018 return -ENOMEM; in _transport_map_smp_buffer()
2019 *dma_len = buf->payload_len; in _transport_map_smp_buffer()
2021 if (!dma_map_sg(dev, buf->sg_list, 1, DMA_BIDIRECTIONAL)) in _transport_map_smp_buffer()
2022 return -ENOMEM; in _transport_map_smp_buffer()
2023 *dma_addr = sg_dma_address(buf->sg_list); in _transport_map_smp_buffer()
2024 *dma_len = sg_dma_len(buf->sg_list); in _transport_map_smp_buffer()
2036 dma_free_coherent(dev, buf->payload_len, p, dma_addr); in _transport_unmap_smp_buffer()
2038 dma_unmap_sg(dev, buf->sg_list, 1, DMA_BIDIRECTIONAL); in _transport_unmap_smp_buffer()
2042 * _transport_smp_handler - transport portal for smp passthru
2049 * smp_rep_general /sys/class/bsg/expander-5:0
2069 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_smp_handler()
2071 rc = -EFAULT; in _transport_smp_handler()
2075 rc = mutex_lock_interruptible(&ioc->transport_cmds.mutex); in _transport_smp_handler()
2079 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_smp_handler()
2082 rc = -EAGAIN; in _transport_smp_handler()
2085 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_smp_handler()
2087 rc = _transport_map_smp_buffer(&ioc->pdev->dev, &job->request_payload, in _transport_smp_handler()
2092 sg_copy_to_buffer(job->request_payload.sg_list, in _transport_smp_handler()
2093 job->request_payload.sg_cnt, addr_out, in _transport_smp_handler()
2094 job->request_payload.payload_len); in _transport_smp_handler()
2097 rc = _transport_map_smp_buffer(&ioc->pdev->dev, &job->reply_payload, in _transport_smp_handler()
2106 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_smp_handler()
2109 rc = -EAGAIN; in _transport_smp_handler()
2115 ioc->transport_cmds.smid = smid; in _transport_smp_handler()
2118 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_smp_handler()
2119 mpi_request->PhysicalPort = _transport_get_port_id_by_rphy(ioc, rphy); in _transport_smp_handler()
2120 mpi_request->SASAddress = (rphy) ? in _transport_smp_handler()
2121 cpu_to_le64(rphy->identify.sas_address) : in _transport_smp_handler()
2122 cpu_to_le64(ioc->sas_hba.sas_address); in _transport_smp_handler()
2123 mpi_request->RequestDataLength = cpu_to_le16(dma_len_out - 4); in _transport_smp_handler()
2124 psge = &mpi_request->SGL; in _transport_smp_handler()
2126 ioc->build_sg(ioc, psge, dma_addr_out, dma_len_out - 4, dma_addr_in, in _transport_smp_handler()
2127 dma_len_in - 4); in _transport_smp_handler()
2132 init_completion(&ioc->transport_cmds.done); in _transport_smp_handler()
2133 ioc->put_smid_default(ioc, smid); in _transport_smp_handler()
2134 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_smp_handler()
2136 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_smp_handler()
2140 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) { in _transport_smp_handler()
2142 rc = -ETIMEDOUT; in _transport_smp_handler()
2147 dtransportprintk(ioc, ioc_info(ioc, "%s - complete\n", __func__)); in _transport_smp_handler()
2149 if (!(ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID)) { in _transport_smp_handler()
2152 rc = -ENXIO; in _transport_smp_handler()
2156 mpi_reply = ioc->transport_cmds.reply; in _transport_smp_handler()
2161 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_smp_handler()
2163 memcpy(job->reply, mpi_reply, sizeof(*mpi_reply)); in _transport_smp_handler()
2164 job->reply_len = sizeof(*mpi_reply); in _transport_smp_handler()
2165 reslen = le16_to_cpu(mpi_reply->ResponseDataLength); in _transport_smp_handler()
2168 sg_copy_to_buffer(job->reply_payload.sg_list, in _transport_smp_handler()
2169 job->reply_payload.sg_cnt, addr_in, in _transport_smp_handler()
2170 job->reply_payload.payload_len); in _transport_smp_handler()
2175 _transport_unmap_smp_buffer(&ioc->pdev->dev, &job->reply_payload, in _transport_smp_handler()
2178 _transport_unmap_smp_buffer(&ioc->pdev->dev, &job->request_payload, in _transport_smp_handler()
2181 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_smp_handler()
2182 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_smp_handler()