Lines Matching +full:port +full:- +full:expander

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
84 * @sas_address: sas address of expander or sas host
85 * @port: hba port entry
86 * Context: Calling function should acquire ioc->sas_node_lock.
88 * Search for either hba phys or expander device based on handle, then returns
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
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
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.
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
344 * @sas_address: expander sas address
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 memtostr(edev->vendor_id, manufacture_reply->vendor_id); in _transport_expander_report_manufacture()
462 memtostr(edev->product_id, manufacture_reply->product_id); in _transport_expander_report_manufacture()
463 memtostr(edev->product_rev, manufacture_reply->product_rev); in _transport_expander_report_manufacture()
464 edev->level = manufacture_reply->sas_format & 1; in _transport_expander_report_manufacture()
465 if (edev->level) { in _transport_expander_report_manufacture()
466 memtostr(edev->component_vendor_id, in _transport_expander_report_manufacture()
467 manufacture_reply->component_vendor_id); in _transport_expander_report_manufacture()
468 tmp = (u8 *)&manufacture_reply->component_id; in _transport_expander_report_manufacture()
469 edev->component_id = tmp[0] << 8 | tmp[1]; in _transport_expander_report_manufacture()
470 edev->component_revision_id = in _transport_expander_report_manufacture()
471 manufacture_reply->component_revision_id; in _transport_expander_report_manufacture()
475 ioc_info(ioc, "report_manufacture - no reply\n")); in _transport_expander_report_manufacture()
481 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_expander_report_manufacture()
483 dma_free_coherent(&ioc->pdev->dev, data_out_sz + data_in_sz, in _transport_expander_report_manufacture()
486 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_expander_report_manufacture()
492 * _transport_delete_port - helper function to removing a port
494 * @mpt3sas_port: mpt3sas per port object
500 u64 sas_address = mpt3sas_port->remote_identify.sas_address; in _transport_delete_port()
501 struct hba_port *port = mpt3sas_port->hba_port; in _transport_delete_port() local
503 mpt3sas_port->remote_identify.device_type; in _transport_delete_port()
505 dev_printk(KERN_INFO, &mpt3sas_port->port->dev, in _transport_delete_port()
509 ioc->logging_level |= MPT_DEBUG_TRANSPORT; in _transport_delete_port()
512 sas_address, port); in _transport_delete_port()
515 mpt3sas_expander_remove(ioc, sas_address, port); in _transport_delete_port()
516 ioc->logging_level &= ~MPT_DEBUG_TRANSPORT; in _transport_delete_port()
520 * _transport_delete_phy - helper function to removing single phy from port
522 * @mpt3sas_port: mpt3sas per port object
529 u64 sas_address = mpt3sas_port->remote_identify.sas_address; in _transport_delete_phy()
531 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in _transport_delete_phy()
533 (unsigned long long) sas_address, mpt3sas_phy->phy_id); in _transport_delete_phy()
535 list_del(&mpt3sas_phy->port_siblings); in _transport_delete_phy()
536 mpt3sas_port->num_phys--; in _transport_delete_phy()
537 sas_port_delete_phy(mpt3sas_port->port, mpt3sas_phy->phy); in _transport_delete_phy()
538 mpt3sas_phy->phy_belongs_to_port = 0; in _transport_delete_phy()
542 * _transport_add_phy - helper function to adding single phy to port
544 * @mpt3sas_port: mpt3sas per port object
551 u64 sas_address = mpt3sas_port->remote_identify.sas_address; in _transport_add_phy()
553 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in _transport_add_phy()
555 sas_address, mpt3sas_phy->phy_id); in _transport_add_phy()
557 list_add_tail(&mpt3sas_phy->port_siblings, &mpt3sas_port->phy_list); in _transport_add_phy()
558 mpt3sas_port->num_phys++; in _transport_add_phy()
559 sas_port_add_phy(mpt3sas_port->port, mpt3sas_phy->phy); in _transport_add_phy()
560 mpt3sas_phy->phy_belongs_to_port = 1; in _transport_add_phy()
564 * mpt3sas_transport_add_phy_to_an_existing_port - adding new phy to existing port
566 * @sas_node: sas node object (either expander or sas host)
568 * @sas_address: sas address of device/expander were phy needs to be added to
569 * @port: hba port entry
574 u64 sas_address, struct hba_port *port) in mpt3sas_transport_add_phy_to_an_existing_port() argument
579 if (mpt3sas_phy->phy_belongs_to_port == 1) in mpt3sas_transport_add_phy_to_an_existing_port()
582 if (!port) in mpt3sas_transport_add_phy_to_an_existing_port()
585 list_for_each_entry(mpt3sas_port, &sas_node->sas_port_list, in mpt3sas_transport_add_phy_to_an_existing_port()
587 if (mpt3sas_port->remote_identify.sas_address != in mpt3sas_transport_add_phy_to_an_existing_port()
590 if (mpt3sas_port->hba_port != port) in mpt3sas_transport_add_phy_to_an_existing_port()
592 list_for_each_entry(phy_srch, &mpt3sas_port->phy_list, in mpt3sas_transport_add_phy_to_an_existing_port()
604 * mpt3sas_transport_del_phy_from_an_existing_port - delete phy from existing port
606 * @sas_node: sas node object (either expander or sas host)
616 if (mpt3sas_phy->phy_belongs_to_port == 0) in mpt3sas_transport_del_phy_from_an_existing_port()
619 list_for_each_entry_safe(mpt3sas_port, next, &sas_node->sas_port_list, in mpt3sas_transport_del_phy_from_an_existing_port()
621 list_for_each_entry(phy_srch, &mpt3sas_port->phy_list, in mpt3sas_transport_del_phy_from_an_existing_port()
627 * Don't delete port during host reset, in mpt3sas_transport_del_phy_from_an_existing_port()
630 if (mpt3sas_port->num_phys == 1 && !ioc->shost_recovery) in mpt3sas_transport_del_phy_from_an_existing_port()
641 * _transport_sanity_check - sanity check when adding a new port
643 * @sas_node: sas node object (either expander or sas host)
645 * @port: hba port entry
651 u64 sas_address, struct hba_port *port) in _transport_sanity_check() argument
655 for (i = 0; i < sas_node->num_phys; i++) { in _transport_sanity_check()
656 if (sas_node->phy[i].remote_identify.sas_address != sas_address) in _transport_sanity_check()
658 if (sas_node->phy[i].port != port) in _transport_sanity_check()
660 if (sas_node->phy[i].phy_belongs_to_port == 1) in _transport_sanity_check()
662 sas_node, &sas_node->phy[i]); in _transport_sanity_check()
667 * mpt3sas_transport_port_add - insert port to the list
670 * @sas_address: sas address of parent expander or sas host
671 * @hba_port: hba port entry
672 * Context: This function will acquire ioc->sas_node_lock.
674 * Adding new port object to the sas_node->sas_port_list.
689 struct sas_port *port; in mpt3sas_transport_port_add() local
706 INIT_LIST_HEAD(&mpt3sas_port->port_list); in mpt3sas_transport_port_add()
707 INIT_LIST_HEAD(&mpt3sas_port->phy_list); in mpt3sas_transport_port_add()
708 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
711 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
720 &mpt3sas_port->remote_identify))) { in mpt3sas_transport_port_add()
726 if (mpt3sas_port->remote_identify.device_type == SAS_PHY_UNUSED) { in mpt3sas_transport_port_add()
732 mpt3sas_port->hba_port = hba_port; in mpt3sas_transport_port_add()
734 mpt3sas_port->remote_identify.sas_address, hba_port); in mpt3sas_transport_port_add()
736 for (i = 0; i < sas_node->num_phys; i++) { in mpt3sas_transport_port_add()
737 if (sas_node->phy[i].remote_identify.sas_address != in mpt3sas_transport_port_add()
738 mpt3sas_port->remote_identify.sas_address) in mpt3sas_transport_port_add()
740 if (sas_node->phy[i].port != hba_port) in mpt3sas_transport_port_add()
742 list_add_tail(&sas_node->phy[i].port_siblings, in mpt3sas_transport_port_add()
743 &mpt3sas_port->phy_list); in mpt3sas_transport_port_add()
744 mpt3sas_port->num_phys++; in mpt3sas_transport_port_add()
745 if (sas_node->handle <= ioc->sas_hba.num_phys) { in mpt3sas_transport_port_add()
746 if (!sas_node->phy[i].hba_vphy) { in mpt3sas_transport_port_add()
747 hba_port->phy_mask |= (1 << i); in mpt3sas_transport_port_add()
760 if (!mpt3sas_port->num_phys) { in mpt3sas_transport_port_add()
766 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
768 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
769 mpt3sas_port->hba_port); in mpt3sas_transport_port_add()
775 sas_device->pend_sas_rphy_add = 1; in mpt3sas_transport_port_add()
778 if (!sas_node->parent_dev) { in mpt3sas_transport_port_add()
783 port = sas_port_alloc_num(sas_node->parent_dev); in mpt3sas_transport_port_add()
784 if (!port || (sas_port_add(port))) { in mpt3sas_transport_port_add()
790 list_for_each_entry(mpt3sas_phy, &mpt3sas_port->phy_list, in mpt3sas_transport_port_add()
792 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_port_add()
793 dev_printk(KERN_INFO, &port->dev, in mpt3sas_transport_port_add()
796 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
797 mpt3sas_phy->phy_id); in mpt3sas_transport_port_add()
798 sas_port_add_phy(port, mpt3sas_phy->phy); in mpt3sas_transport_port_add()
799 mpt3sas_phy->phy_belongs_to_port = 1; in mpt3sas_transport_port_add()
800 mpt3sas_phy->port = hba_port; in mpt3sas_transport_port_add()
803 mpt3sas_port->port = port; in mpt3sas_transport_port_add()
804 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
805 rphy = sas_end_device_alloc(port); in mpt3sas_transport_port_add()
806 sas_device->rphy = rphy; in mpt3sas_transport_port_add()
807 if (sas_node->handle <= ioc->sas_hba.num_phys) { in mpt3sas_transport_port_add()
809 hba_port->sas_address = in mpt3sas_transport_port_add()
810 sas_device->sas_address; in mpt3sas_transport_port_add()
812 vphy->sas_address = in mpt3sas_transport_port_add()
813 sas_device->sas_address; in mpt3sas_transport_port_add()
816 rphy = sas_expander_alloc(port, in mpt3sas_transport_port_add()
817 mpt3sas_port->remote_identify.device_type); in mpt3sas_transport_port_add()
818 if (sas_node->handle <= ioc->sas_hba.num_phys) in mpt3sas_transport_port_add()
819 hba_port->sas_address = in mpt3sas_transport_port_add()
820 mpt3sas_port->remote_identify.sas_address; in mpt3sas_transport_port_add()
829 rphy->identify = mpt3sas_port->remote_identify; in mpt3sas_transport_port_add()
839 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) { in mpt3sas_transport_port_add()
840 sas_device->pend_sas_rphy_add = 0; in mpt3sas_transport_port_add()
844 dev_info(&rphy->dev, in mpt3sas_transport_port_add()
846 (unsigned long long)mpt3sas_port->remote_identify.sas_address); in mpt3sas_transport_port_add()
848 mpt3sas_port->rphy = rphy; in mpt3sas_transport_port_add()
849 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
850 list_add_tail(&mpt3sas_port->port_list, &sas_node->sas_port_list); in mpt3sas_transport_port_add()
851 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_add()
854 if (mpt3sas_port->remote_identify.device_type == in mpt3sas_transport_port_add()
856 mpt3sas_port->remote_identify.device_type == in mpt3sas_transport_port_add()
859 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_add()
860 rphy_to_expander_device(rphy), hba_port->port_id); in mpt3sas_transport_port_add()
864 sas_port_delete(port); in mpt3sas_transport_port_add()
867 list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list, in mpt3sas_transport_port_add()
869 list_del(&mpt3sas_phy->port_siblings); in mpt3sas_transport_port_add()
875 * mpt3sas_transport_port_remove - remove port from the list
878 * @sas_address_parent: sas address of parent expander or sas host
879 * @port: hba port entry
880 * Context: This function will acquire ioc->sas_node_lock.
883 * ioc->sas_port_list.
887 u64 sas_address_parent, struct hba_port *port) in mpt3sas_transport_port_remove() argument
898 if (!port) in mpt3sas_transport_port_remove()
901 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
903 sas_address_parent, port); in mpt3sas_transport_port_remove()
905 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
908 list_for_each_entry_safe(mpt3sas_port, next, &sas_node->sas_port_list, in mpt3sas_transport_port_remove()
910 if (mpt3sas_port->remote_identify.sas_address != sas_address) in mpt3sas_transport_port_remove()
912 if (mpt3sas_port->hba_port != port) in mpt3sas_transport_port_remove()
915 list_del(&mpt3sas_port->port_list); in mpt3sas_transport_port_remove()
920 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
924 if (sas_node->handle <= ioc->sas_hba.num_phys && in mpt3sas_transport_port_remove()
925 (ioc->multipath_on_hba)) { in mpt3sas_transport_port_remove()
926 if (port->vphys_mask) { in mpt3sas_transport_port_remove()
928 &port->vphys_list, list) { in mpt3sas_transport_port_remove()
929 if (vphy->sas_address != sas_address) in mpt3sas_transport_port_remove()
932 "remove vphy entry: %p of port:%p,from %d port's vphys list\n", in mpt3sas_transport_port_remove()
933 vphy, port, port->port_id); in mpt3sas_transport_port_remove()
934 port->vphys_mask &= ~vphy->phy_mask; in mpt3sas_transport_port_remove()
935 list_del(&vphy->list); in mpt3sas_transport_port_remove()
941 &ioc->port_table_list, list) { in mpt3sas_transport_port_remove()
942 if (hba_port != port) in mpt3sas_transport_port_remove()
946 * - hba_port object's sas address matches with current in mpt3sas_transport_port_remove()
949 * - Current removed device is a vSES device and in mpt3sas_transport_port_remove()
951 * this vSES device's port number (hence hba_port in mpt3sas_transport_port_remove()
954 if ((hba_port->sas_address == sas_address || in mpt3sas_transport_port_remove()
955 !hba_port->sas_address) && !hba_port->vphys_mask) { in mpt3sas_transport_port_remove()
957 "remove hba_port entry: %p port: %d from hba_port list\n", in mpt3sas_transport_port_remove()
958 hba_port, hba_port->port_id); in mpt3sas_transport_port_remove()
959 list_del(&hba_port->list); in mpt3sas_transport_port_remove()
961 } else if (hba_port->sas_address == sas_address && in mpt3sas_transport_port_remove()
962 hba_port->vphys_mask) { in mpt3sas_transport_port_remove()
965 * and a vSES device has the same port number in mpt3sas_transport_port_remove()
966 * as of current device's port number. Hence in mpt3sas_transport_port_remove()
971 "clearing sas_address from hba_port entry: %p port: %d from hba_port list\n", in mpt3sas_transport_port_remove()
972 hba_port, hba_port->port_id); in mpt3sas_transport_port_remove()
973 port->sas_address = 0; in mpt3sas_transport_port_remove()
979 for (i = 0; i < sas_node->num_phys; i++) { in mpt3sas_transport_port_remove()
980 if (sas_node->phy[i].remote_identify.sas_address == sas_address) in mpt3sas_transport_port_remove()
981 memset(&sas_node->phy[i].remote_identify, 0 , in mpt3sas_transport_port_remove()
985 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_port_remove()
988 &mpt3sas_port->phy_list, port_siblings) { in mpt3sas_transport_port_remove()
989 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_port_remove()
990 dev_printk(KERN_INFO, &mpt3sas_port->port->dev, in mpt3sas_transport_port_remove()
993 mpt3sas_port->remote_identify.sas_address, in mpt3sas_transport_port_remove()
994 mpt3sas_phy->phy_id); in mpt3sas_transport_port_remove()
995 mpt3sas_phy->phy_belongs_to_port = 0; in mpt3sas_transport_port_remove()
996 if (!ioc->remove_host) in mpt3sas_transport_port_remove()
997 sas_port_delete_phy(mpt3sas_port->port, in mpt3sas_transport_port_remove()
998 mpt3sas_phy->phy); in mpt3sas_transport_port_remove()
999 list_del(&mpt3sas_phy->port_siblings); in mpt3sas_transport_port_remove()
1001 if (!ioc->remove_host) in mpt3sas_transport_port_remove()
1002 sas_port_delete(mpt3sas_port->port); in mpt3sas_transport_port_remove()
1009 * mpt3sas_transport_add_host_phy - report sas_host phy to transport
1015 * Return: 0 for success, non-zero for failure.
1022 int phy_index = mpt3sas_phy->phy_id; in mpt3sas_transport_add_host_phy()
1025 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings); in mpt3sas_transport_add_host_phy()
1030 return -1; in mpt3sas_transport_add_host_phy()
1032 if ((_transport_set_identify(ioc, mpt3sas_phy->handle, in mpt3sas_transport_add_host_phy()
1033 &mpt3sas_phy->identify))) { in mpt3sas_transport_add_host_phy()
1037 return -1; in mpt3sas_transport_add_host_phy()
1039 phy->identify = mpt3sas_phy->identify; in mpt3sas_transport_add_host_phy()
1040 mpt3sas_phy->attached_handle = le16_to_cpu(phy_pg0.AttachedDevHandle); in mpt3sas_transport_add_host_phy()
1041 if (mpt3sas_phy->attached_handle) in mpt3sas_transport_add_host_phy()
1042 _transport_set_identify(ioc, mpt3sas_phy->attached_handle, in mpt3sas_transport_add_host_phy()
1043 &mpt3sas_phy->remote_identify); in mpt3sas_transport_add_host_phy()
1044 phy->identify.phy_identifier = mpt3sas_phy->phy_id; in mpt3sas_transport_add_host_phy()
1045 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1047 phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1049 phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1051 phy->minimum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1053 phy->maximum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_host_phy()
1055 phy->hostdata = mpt3sas_phy->port; in mpt3sas_transport_add_host_phy()
1061 return -1; in mpt3sas_transport_add_host_phy()
1063 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_add_host_phy()
1064 dev_printk(KERN_INFO, &phy->dev, in mpt3sas_transport_add_host_phy()
1067 mpt3sas_phy->handle, (unsigned long long) in mpt3sas_transport_add_host_phy()
1068 mpt3sas_phy->identify.sas_address, in mpt3sas_transport_add_host_phy()
1069 mpt3sas_phy->attached_handle, in mpt3sas_transport_add_host_phy()
1071 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_add_host_phy()
1072 mpt3sas_phy->phy = phy; in mpt3sas_transport_add_host_phy()
1078 * mpt3sas_transport_add_expander_phy - report expander phy to transport
1081 * @expander_pg1: expander page 1
1084 * Return: 0 for success, non-zero for failure.
1092 int phy_index = mpt3sas_phy->phy_id; in mpt3sas_transport_add_expander_phy()
1094 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings); in mpt3sas_transport_add_expander_phy()
1099 return -1; in mpt3sas_transport_add_expander_phy()
1101 if ((_transport_set_identify(ioc, mpt3sas_phy->handle, in mpt3sas_transport_add_expander_phy()
1102 &mpt3sas_phy->identify))) { in mpt3sas_transport_add_expander_phy()
1106 return -1; in mpt3sas_transport_add_expander_phy()
1108 phy->identify = mpt3sas_phy->identify; in mpt3sas_transport_add_expander_phy()
1109 mpt3sas_phy->attached_handle = in mpt3sas_transport_add_expander_phy()
1111 if (mpt3sas_phy->attached_handle) in mpt3sas_transport_add_expander_phy()
1112 _transport_set_identify(ioc, mpt3sas_phy->attached_handle, in mpt3sas_transport_add_expander_phy()
1113 &mpt3sas_phy->remote_identify); in mpt3sas_transport_add_expander_phy()
1114 phy->identify.phy_identifier = mpt3sas_phy->phy_id; in mpt3sas_transport_add_expander_phy()
1115 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1118 phy->minimum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1120 phy->maximum_linkrate_hw = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1122 phy->minimum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1124 phy->maximum_linkrate = _transport_convert_phy_link_rate( in mpt3sas_transport_add_expander_phy()
1126 phy->hostdata = mpt3sas_phy->port; in mpt3sas_transport_add_expander_phy()
1132 return -1; in mpt3sas_transport_add_expander_phy()
1134 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_add_expander_phy()
1135 dev_printk(KERN_INFO, &phy->dev, in mpt3sas_transport_add_expander_phy()
1138 mpt3sas_phy->handle, (unsigned long long) in mpt3sas_transport_add_expander_phy()
1139 mpt3sas_phy->identify.sas_address, in mpt3sas_transport_add_expander_phy()
1140 mpt3sas_phy->attached_handle, in mpt3sas_transport_add_expander_phy()
1142 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_add_expander_phy()
1143 mpt3sas_phy->phy = phy; in mpt3sas_transport_add_expander_phy()
1148 * mpt3sas_transport_update_links - refreshing phy link changes
1150 * @sas_address: sas address of parent expander or sas host
1154 * @port: hba port entry
1161 struct hba_port *port) in mpt3sas_transport_update_links() argument
1168 if (ioc->shost_recovery || ioc->pci_error_recovery) in mpt3sas_transport_update_links()
1171 spin_lock_irqsave(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1173 sas_address, port); in mpt3sas_transport_update_links()
1175 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1179 mpt3sas_phy = &sas_node->phy[phy_number]; in mpt3sas_transport_update_links()
1180 mpt3sas_phy->attached_handle = handle; in mpt3sas_transport_update_links()
1181 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in mpt3sas_transport_update_links()
1184 &mpt3sas_phy->remote_identify); in mpt3sas_transport_update_links()
1185 if ((sas_node->handle <= ioc->sas_hba.num_phys) && in mpt3sas_transport_update_links()
1186 (ioc->multipath_on_hba)) { in mpt3sas_transport_update_links()
1188 &ioc->port_table_list, list) { in mpt3sas_transport_update_links()
1189 if (hba_port->sas_address == sas_address && in mpt3sas_transport_update_links()
1190 hba_port == port) in mpt3sas_transport_update_links()
1191 hba_port->phy_mask |= in mpt3sas_transport_update_links()
1192 (1 << mpt3sas_phy->phy_id); in mpt3sas_transport_update_links()
1196 mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address, in mpt3sas_transport_update_links()
1197 port); in mpt3sas_transport_update_links()
1199 memset(&mpt3sas_phy->remote_identify, 0 , sizeof(struct in mpt3sas_transport_update_links()
1202 if (mpt3sas_phy->phy) in mpt3sas_transport_update_links()
1203 mpt3sas_phy->phy->negotiated_linkrate = in mpt3sas_transport_update_links()
1206 if ((ioc->logging_level & MPT_DEBUG_TRANSPORT)) in mpt3sas_transport_update_links()
1207 dev_printk(KERN_INFO, &mpt3sas_phy->phy->dev, in mpt3sas_transport_update_links()
1213 mpt3sas_phy->remote_identify.sas_address); in mpt3sas_transport_update_links()
1219 struct Scsi_Host *shost = dev_to_shost(phy->dev.parent); in phy_to_ioc()
1226 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent->parent); in rphy_to_ioc()
1258 * _transport_get_expander_phy_error_log - return expander counters
1262 * Return: 0 for success, non-zero for failure.
1281 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_get_expander_phy_error_log()
1283 return -EFAULT; in _transport_get_expander_phy_error_log()
1286 mutex_lock(&ioc->transport_cmds.mutex); in _transport_get_expander_phy_error_log()
1288 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_get_expander_phy_error_log()
1290 rc = -EAGAIN; in _transport_get_expander_phy_error_log()
1293 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_get_expander_phy_error_log()
1299 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_get_expander_phy_error_log()
1302 rc = -EAGAIN; in _transport_get_expander_phy_error_log()
1307 ioc->transport_cmds.smid = smid; in _transport_get_expander_phy_error_log()
1311 data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma, in _transport_get_expander_phy_error_log()
1316 rc = -ENOMEM; in _transport_get_expander_phy_error_log()
1321 rc = -EINVAL; in _transport_get_expander_phy_error_log()
1324 phy_error_log_request->smp_frame_type = 0x40; in _transport_get_expander_phy_error_log()
1325 phy_error_log_request->function = 0x11; in _transport_get_expander_phy_error_log()
1326 phy_error_log_request->request_length = 2; in _transport_get_expander_phy_error_log()
1327 phy_error_log_request->allocated_response_length = 0; in _transport_get_expander_phy_error_log()
1328 phy_error_log_request->phy_identifier = phy->number; in _transport_get_expander_phy_error_log()
1331 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_get_expander_phy_error_log()
1332 mpi_request->PhysicalPort = _transport_get_port_id_by_sas_phy(phy); in _transport_get_expander_phy_error_log()
1333 mpi_request->VF_ID = 0; /* TODO */ in _transport_get_expander_phy_error_log()
1334 mpi_request->VP_ID = 0; in _transport_get_expander_phy_error_log()
1335 mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); in _transport_get_expander_phy_error_log()
1336 mpi_request->RequestDataLength = in _transport_get_expander_phy_error_log()
1338 psge = &mpi_request->SGL; in _transport_get_expander_phy_error_log()
1340 ioc->build_sg(ioc, psge, data_out_dma, in _transport_get_expander_phy_error_log()
1346 ioc_info(ioc, "phy_error_log - send to sas_addr(0x%016llx), phy(%d)\n", in _transport_get_expander_phy_error_log()
1347 (u64)phy->identify.sas_address, in _transport_get_expander_phy_error_log()
1348 phy->number)); in _transport_get_expander_phy_error_log()
1349 init_completion(&ioc->transport_cmds.done); in _transport_get_expander_phy_error_log()
1350 ioc->put_smid_default(ioc, smid); in _transport_get_expander_phy_error_log()
1351 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_get_expander_phy_error_log()
1353 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_get_expander_phy_error_log()
1357 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_get_expander_phy_error_log()
1362 dtransportprintk(ioc, ioc_info(ioc, "phy_error_log - complete\n")); in _transport_get_expander_phy_error_log()
1364 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_get_expander_phy_error_log()
1366 mpi_reply = ioc->transport_cmds.reply; in _transport_get_expander_phy_error_log()
1369 ioc_info(ioc, "phy_error_log - reply data transfer size(%d)\n", in _transport_get_expander_phy_error_log()
1370 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_get_expander_phy_error_log()
1372 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_get_expander_phy_error_log()
1380 ioc_info(ioc, "phy_error_log - function_result(%d)\n", in _transport_get_expander_phy_error_log()
1381 phy_error_log_reply->function_result)); in _transport_get_expander_phy_error_log()
1383 phy->invalid_dword_count = in _transport_get_expander_phy_error_log()
1384 be32_to_cpu(phy_error_log_reply->invalid_dword); in _transport_get_expander_phy_error_log()
1385 phy->running_disparity_error_count = in _transport_get_expander_phy_error_log()
1386 be32_to_cpu(phy_error_log_reply->running_disparity_error); in _transport_get_expander_phy_error_log()
1387 phy->loss_of_dword_sync_count = in _transport_get_expander_phy_error_log()
1388 be32_to_cpu(phy_error_log_reply->loss_of_dword_sync); in _transport_get_expander_phy_error_log()
1389 phy->phy_reset_problem_count = in _transport_get_expander_phy_error_log()
1390 be32_to_cpu(phy_error_log_reply->phy_reset_problem); in _transport_get_expander_phy_error_log()
1394 ioc_info(ioc, "phy_error_log - no reply\n")); in _transport_get_expander_phy_error_log()
1400 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_get_expander_phy_error_log()
1402 dma_free_coherent(&ioc->pdev->dev, sz, data_out, data_out_dma); in _transport_get_expander_phy_error_log()
1404 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_get_expander_phy_error_log()
1409 * _transport_get_linkerrors - return phy counters for both hba and expanders
1412 * Return: 0 for success, non-zero for failure.
1422 struct hba_port *port = phy->hostdata; in _transport_get_linkerrors() local
1423 int port_id = port->port_id; in _transport_get_linkerrors()
1425 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1427 phy->identify.sas_address, in _transport_get_linkerrors()
1429 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1430 return -EINVAL; in _transport_get_linkerrors()
1432 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_get_linkerrors()
1434 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_get_linkerrors()
1439 phy->number))) { in _transport_get_linkerrors()
1442 return -ENXIO; in _transport_get_linkerrors()
1447 phy->number, in _transport_get_linkerrors()
1451 phy->invalid_dword_count = le32_to_cpu(phy_pg1.InvalidDwordCount); in _transport_get_linkerrors()
1452 phy->running_disparity_error_count = in _transport_get_linkerrors()
1454 phy->loss_of_dword_sync_count = in _transport_get_linkerrors()
1456 phy->phy_reset_problem_count = in _transport_get_linkerrors()
1462 * _transport_get_enclosure_identifier -
1466 * Obtain the enclosure logical id for an expander.
1467 * Return: 0 for success, non-zero for failure.
1477 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_enclosure_identifier()
1480 *identifier = sas_device->enclosure_logical_id; in _transport_get_enclosure_identifier()
1485 rc = -ENXIO; in _transport_get_enclosure_identifier()
1488 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_enclosure_identifier()
1493 * _transport_get_bay_identifier -
1506 spin_lock_irqsave(&ioc->sas_device_lock, flags); in _transport_get_bay_identifier()
1509 rc = sas_device->slot; in _transport_get_bay_identifier()
1512 rc = -ENXIO; in _transport_get_bay_identifier()
1514 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); in _transport_get_bay_identifier()
1548 * _transport_expander_phy_control - expander phy control
1553 * Return: 0 for success, non-zero for failure.
1572 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_expander_phy_control()
1574 return -EFAULT; in _transport_expander_phy_control()
1577 mutex_lock(&ioc->transport_cmds.mutex); in _transport_expander_phy_control()
1579 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_expander_phy_control()
1581 rc = -EAGAIN; in _transport_expander_phy_control()
1584 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_expander_phy_control()
1590 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_expander_phy_control()
1593 rc = -EAGAIN; in _transport_expander_phy_control()
1598 ioc->transport_cmds.smid = smid; in _transport_expander_phy_control()
1602 data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma, in _transport_expander_phy_control()
1607 rc = -ENOMEM; in _transport_expander_phy_control()
1612 rc = -EINVAL; in _transport_expander_phy_control()
1615 phy_control_request->smp_frame_type = 0x40; in _transport_expander_phy_control()
1616 phy_control_request->function = 0x91; in _transport_expander_phy_control()
1617 phy_control_request->request_length = 9; in _transport_expander_phy_control()
1618 phy_control_request->allocated_response_length = 0; in _transport_expander_phy_control()
1619 phy_control_request->phy_identifier = phy->number; in _transport_expander_phy_control()
1620 phy_control_request->phy_operation = phy_operation; in _transport_expander_phy_control()
1621 phy_control_request->programmed_min_physical_link_rate = in _transport_expander_phy_control()
1622 phy->minimum_linkrate << 4; in _transport_expander_phy_control()
1623 phy_control_request->programmed_max_physical_link_rate = in _transport_expander_phy_control()
1624 phy->maximum_linkrate << 4; in _transport_expander_phy_control()
1627 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_expander_phy_control()
1628 mpi_request->PhysicalPort = _transport_get_port_id_by_sas_phy(phy); in _transport_expander_phy_control()
1629 mpi_request->VF_ID = 0; /* TODO */ in _transport_expander_phy_control()
1630 mpi_request->VP_ID = 0; in _transport_expander_phy_control()
1631 mpi_request->SASAddress = cpu_to_le64(phy->identify.sas_address); in _transport_expander_phy_control()
1632 mpi_request->RequestDataLength = in _transport_expander_phy_control()
1634 psge = &mpi_request->SGL; in _transport_expander_phy_control()
1636 ioc->build_sg(ioc, psge, data_out_dma, in _transport_expander_phy_control()
1642 ioc_info(ioc, "phy_control - send to sas_addr(0x%016llx), phy(%d), opcode(%d)\n", in _transport_expander_phy_control()
1643 (u64)phy->identify.sas_address, in _transport_expander_phy_control()
1644 phy->number, phy_operation)); in _transport_expander_phy_control()
1645 init_completion(&ioc->transport_cmds.done); in _transport_expander_phy_control()
1646 ioc->put_smid_default(ioc, smid); in _transport_expander_phy_control()
1647 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_expander_phy_control()
1649 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_expander_phy_control()
1653 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) in _transport_expander_phy_control()
1658 dtransportprintk(ioc, ioc_info(ioc, "phy_control - complete\n")); in _transport_expander_phy_control()
1660 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) { in _transport_expander_phy_control()
1662 mpi_reply = ioc->transport_cmds.reply; in _transport_expander_phy_control()
1665 ioc_info(ioc, "phy_control - reply data transfer size(%d)\n", in _transport_expander_phy_control()
1666 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_expander_phy_control()
1668 if (le16_to_cpu(mpi_reply->ResponseDataLength) != in _transport_expander_phy_control()
1676 ioc_info(ioc, "phy_control - function_result(%d)\n", in _transport_expander_phy_control()
1677 phy_control_reply->function_result)); in _transport_expander_phy_control()
1682 ioc_info(ioc, "phy_control - no reply\n")); in _transport_expander_phy_control()
1688 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_expander_phy_control()
1690 dma_free_coherent(&ioc->pdev->dev, sz, data_out, in _transport_expander_phy_control()
1693 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_expander_phy_control()
1698 * _transport_phy_reset -
1702 * Return: 0 for success, non-zero for failure.
1710 struct hba_port *port = phy->hostdata; in _transport_phy_reset() local
1711 int port_id = port->port_id; in _transport_phy_reset()
1714 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1716 phy->identify.sas_address, in _transport_phy_reset()
1718 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1719 return -EINVAL; in _transport_phy_reset()
1721 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_reset()
1723 /* handle expander phys */ in _transport_phy_reset()
1724 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_phy_reset()
1734 mpi_request.PhyNum = phy->number; in _transport_phy_reset()
1739 return -ENXIO; in _transport_phy_reset()
1744 phy->number, le16_to_cpu(mpi_reply.IOCStatus), in _transport_phy_reset()
1751 * _transport_phy_enable - enable/disable phys
1756 * Return: 0 for success, non-zero for failure.
1770 struct hba_port *port = phy->hostdata; in _transport_phy_enable() local
1771 int port_id = port->port_id; in _transport_phy_enable()
1773 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1775 phy->identify.sas_address, in _transport_phy_enable()
1777 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1778 return -EINVAL; in _transport_phy_enable()
1780 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_enable()
1782 /* handle expander phys */ in _transport_phy_enable()
1783 if (phy->identify.sas_address != ioc->sas_hba.sas_address) in _transport_phy_enable()
1791 sz = struct_size(sas_iounit_pg0, PhyData, ioc->sas_hba.num_phys); in _transport_phy_enable()
1796 rc = -ENOMEM; in _transport_phy_enable()
1803 rc = -ENXIO; in _transport_phy_enable()
1811 rc = -EIO; in _transport_phy_enable()
1816 for (i = 0, discovery_active = 0; i < ioc->sas_hba.num_phys ; i++) { in _transport_phy_enable()
1817 if (sas_iounit_pg0->PhyData[i].PortFlags & in _transport_phy_enable()
1819 …ioc_err(ioc, "discovery is active on port = %d, phy = %d: unable to enable/disable phys, try again… in _transport_phy_enable()
1820 sas_iounit_pg0->PhyData[i].Port, i); in _transport_phy_enable()
1826 rc = -EAGAIN; in _transport_phy_enable()
1831 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _transport_phy_enable()
1836 rc = -ENOMEM; in _transport_phy_enable()
1843 rc = -ENXIO; in _transport_phy_enable()
1851 rc = -EIO; in _transport_phy_enable()
1855 /* copy Port/PortFlags/PhyFlags from page 0 */ in _transport_phy_enable()
1856 for (i = 0; i < ioc->sas_hba.num_phys ; i++) { in _transport_phy_enable()
1857 sas_iounit_pg1->PhyData[i].Port = in _transport_phy_enable()
1858 sas_iounit_pg0->PhyData[i].Port; in _transport_phy_enable()
1859 sas_iounit_pg1->PhyData[i].PortFlags = in _transport_phy_enable()
1860 (sas_iounit_pg0->PhyData[i].PortFlags & in _transport_phy_enable()
1862 sas_iounit_pg1->PhyData[i].PhyFlags = in _transport_phy_enable()
1863 (sas_iounit_pg0->PhyData[i].PhyFlags & in _transport_phy_enable()
1869 sas_iounit_pg1->PhyData[phy->number].PhyFlags in _transport_phy_enable()
1872 sas_iounit_pg1->PhyData[phy->number].PhyFlags in _transport_phy_enable()
1888 * _transport_phy_speed - set phy min/max link rates
1894 * Return: 0 for success, non-zero for failure.
1908 struct hba_port *port = phy->hostdata; in _transport_phy_speed() local
1909 int port_id = port->port_id; in _transport_phy_speed()
1911 spin_lock_irqsave(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1913 phy->identify.sas_address, in _transport_phy_speed()
1915 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1916 return -EINVAL; in _transport_phy_speed()
1918 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); in _transport_phy_speed()
1920 if (!rates->minimum_linkrate) in _transport_phy_speed()
1921 rates->minimum_linkrate = phy->minimum_linkrate; in _transport_phy_speed()
1922 else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) in _transport_phy_speed()
1923 rates->minimum_linkrate = phy->minimum_linkrate_hw; in _transport_phy_speed()
1925 if (!rates->maximum_linkrate) in _transport_phy_speed()
1926 rates->maximum_linkrate = phy->maximum_linkrate; in _transport_phy_speed()
1927 else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) in _transport_phy_speed()
1928 rates->maximum_linkrate = phy->maximum_linkrate_hw; in _transport_phy_speed()
1930 /* handle expander phys */ in _transport_phy_speed()
1931 if (phy->identify.sas_address != ioc->sas_hba.sas_address) { in _transport_phy_speed()
1932 phy->minimum_linkrate = rates->minimum_linkrate; in _transport_phy_speed()
1933 phy->maximum_linkrate = rates->maximum_linkrate; in _transport_phy_speed()
1941 sz = struct_size(sas_iounit_pg1, PhyData, ioc->sas_hba.num_phys); in _transport_phy_speed()
1946 rc = -ENOMEM; in _transport_phy_speed()
1953 rc = -ENXIO; in _transport_phy_speed()
1961 rc = -EIO; in _transport_phy_speed()
1965 for (i = 0; i < ioc->sas_hba.num_phys; i++) { in _transport_phy_speed()
1966 if (phy->number != i) { in _transport_phy_speed()
1967 sas_iounit_pg1->PhyData[i].MaxMinLinkRate = in _transport_phy_speed()
1968 (ioc->sas_hba.phy[i].phy->minimum_linkrate + in _transport_phy_speed()
1969 (ioc->sas_hba.phy[i].phy->maximum_linkrate << 4)); in _transport_phy_speed()
1971 sas_iounit_pg1->PhyData[i].MaxMinLinkRate = in _transport_phy_speed()
1972 (rates->minimum_linkrate + in _transport_phy_speed()
1973 (rates->maximum_linkrate << 4)); in _transport_phy_speed()
1981 rc = -ENXIO; in _transport_phy_speed()
1990 phy->number)) { in _transport_phy_speed()
1991 phy->minimum_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
1993 phy->maximum_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
1995 phy->negotiated_linkrate = _transport_convert_phy_link_rate( in _transport_phy_speed()
2010 if (buf->sg_cnt > 1) { in _transport_map_smp_buffer()
2011 *p = dma_alloc_coherent(dev, buf->payload_len, dma_addr, in _transport_map_smp_buffer()
2014 return -ENOMEM; in _transport_map_smp_buffer()
2015 *dma_len = buf->payload_len; in _transport_map_smp_buffer()
2017 if (!dma_map_sg(dev, buf->sg_list, 1, DMA_BIDIRECTIONAL)) in _transport_map_smp_buffer()
2018 return -ENOMEM; in _transport_map_smp_buffer()
2019 *dma_addr = sg_dma_address(buf->sg_list); in _transport_map_smp_buffer()
2020 *dma_len = sg_dma_len(buf->sg_list); in _transport_map_smp_buffer()
2032 dma_free_coherent(dev, buf->payload_len, p, dma_addr); in _transport_unmap_smp_buffer()
2034 dma_unmap_sg(dev, buf->sg_list, 1, DMA_BIDIRECTIONAL); in _transport_unmap_smp_buffer()
2038 * _transport_smp_handler - transport portal for smp passthru
2045 * smp_rep_general /sys/class/bsg/expander-5:0
2065 if (ioc->shost_recovery || ioc->pci_error_recovery) { in _transport_smp_handler()
2067 rc = -EFAULT; in _transport_smp_handler()
2071 rc = mutex_lock_interruptible(&ioc->transport_cmds.mutex); in _transport_smp_handler()
2075 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) { in _transport_smp_handler()
2078 rc = -EAGAIN; in _transport_smp_handler()
2081 ioc->transport_cmds.status = MPT3_CMD_PENDING; in _transport_smp_handler()
2083 rc = _transport_map_smp_buffer(&ioc->pdev->dev, &job->request_payload, in _transport_smp_handler()
2088 sg_copy_to_buffer(job->request_payload.sg_list, in _transport_smp_handler()
2089 job->request_payload.sg_cnt, addr_out, in _transport_smp_handler()
2090 job->request_payload.payload_len); in _transport_smp_handler()
2093 rc = _transport_map_smp_buffer(&ioc->pdev->dev, &job->reply_payload, in _transport_smp_handler()
2102 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx); in _transport_smp_handler()
2105 rc = -EAGAIN; in _transport_smp_handler()
2111 ioc->transport_cmds.smid = smid; in _transport_smp_handler()
2114 mpi_request->Function = MPI2_FUNCTION_SMP_PASSTHROUGH; in _transport_smp_handler()
2115 mpi_request->PhysicalPort = _transport_get_port_id_by_rphy(ioc, rphy); in _transport_smp_handler()
2116 mpi_request->SASAddress = (rphy) ? in _transport_smp_handler()
2117 cpu_to_le64(rphy->identify.sas_address) : in _transport_smp_handler()
2118 cpu_to_le64(ioc->sas_hba.sas_address); in _transport_smp_handler()
2119 mpi_request->RequestDataLength = cpu_to_le16(dma_len_out - 4); in _transport_smp_handler()
2120 psge = &mpi_request->SGL; in _transport_smp_handler()
2122 ioc->build_sg(ioc, psge, dma_addr_out, dma_len_out - 4, dma_addr_in, in _transport_smp_handler()
2123 dma_len_in - 4); in _transport_smp_handler()
2128 init_completion(&ioc->transport_cmds.done); in _transport_smp_handler()
2129 ioc->put_smid_default(ioc, smid); in _transport_smp_handler()
2130 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ); in _transport_smp_handler()
2132 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) { in _transport_smp_handler()
2136 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) { in _transport_smp_handler()
2138 rc = -ETIMEDOUT; in _transport_smp_handler()
2143 dtransportprintk(ioc, ioc_info(ioc, "%s - complete\n", __func__)); in _transport_smp_handler()
2145 if (!(ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID)) { in _transport_smp_handler()
2148 rc = -ENXIO; in _transport_smp_handler()
2152 mpi_reply = ioc->transport_cmds.reply; in _transport_smp_handler()
2157 le16_to_cpu(mpi_reply->ResponseDataLength))); in _transport_smp_handler()
2159 memcpy(job->reply, mpi_reply, sizeof(*mpi_reply)); in _transport_smp_handler()
2160 job->reply_len = sizeof(*mpi_reply); in _transport_smp_handler()
2161 reslen = le16_to_cpu(mpi_reply->ResponseDataLength); in _transport_smp_handler()
2164 sg_copy_to_buffer(job->reply_payload.sg_list, in _transport_smp_handler()
2165 job->reply_payload.sg_cnt, addr_in, in _transport_smp_handler()
2166 job->reply_payload.payload_len); in _transport_smp_handler()
2171 _transport_unmap_smp_buffer(&ioc->pdev->dev, &job->reply_payload, in _transport_smp_handler()
2174 _transport_unmap_smp_buffer(&ioc->pdev->dev, &job->request_payload, in _transport_smp_handler()
2177 ioc->transport_cmds.status = MPT3_CMD_NOT_USED; in _transport_smp_handler()
2178 mutex_unlock(&ioc->transport_cmds.mutex); in _transport_smp_handler()