Print this page
9048 mpt_sas should not require targets to send SEP messages
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Approved by: Gordon Ross <gwr@nexenta.com>
NEX-17006 backport mpt_sas tri-mode parts support change
9044 Need support for mpt_sas tri-mode parts
9045 Clean up mpt_sas compiler warnings
9046 mptsas_handle_topo_change can return without its locks held
9047 workaround SAS3408 firmware issue
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
Reviewed by: Albert Lee <trisk@forkgnu.org>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Approved by: Richard Lowe <richlowe@richlowe.net>
NEX-16174 scsi error messages should go to system log only
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-14838 Support 24 port version of SAS adapters
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
NEX-1774 mptsas error stats are always zero
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>
NEX-2103 12G mpt_sas needs additional minor enhancements
NEX-2157 mpt_sas firmware update minor regression
NEX-1889 mpt_sas should support 12G HBAs
4500 mptsas_hash_traverse() is unsafe, leads to missing devices
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Approved by: Albert Lee <trisk@nexenta.com>
backout 4500 mptsas_hash_traverse() is unsafe, leads to missing devices
4403 mpt_sas panic when pulling a drive
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Andy Giles <illumos@ang.homedns.org>
Approved by: Robert Mustacchi <rm@joyent.com>
4500 mptsas_hash_traverse() is unsafe, leads to missing devices
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Approved by: Albert Lee <trisk@nexenta.com>
re #9636 rb2836 - mpt_sas should attempt an MUR reset at attach time.
--HG--
branch : stable-4.0
re #9636 rb2836 - mpt_sas should attempt an MUR reset at attach time.
re #6530 mpt_sas crash when more than 1 Initiator involved - ie HA

@@ -19,11 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
  * Copyright 2014 OmniTI Computer Consulting, Inc. All rights reserved.
  * Copyright (c) 2014, Tegile Systems Inc. All rights reserved.
  * Copyright (c) 2017, Joyent, Inc.
  */
 

@@ -543,11 +543,12 @@
                 iocstatus = MPTSAS_IOCSTATUS(iocstatus);
                 iocloginfo = ddi_get32(mpt->m_acc_reply_frame_hdl,
                     &reply->IOCLogInfo);
         }
 
-        if (callback(mpt, page_memp, accessp, iocstatus, iocloginfo, ap)) {
+        if (callback(mpt, page_memp, accessp, iocstatus, iocloginfo, ap)
+            != DDI_SUCCESS) {
                 rval = DDI_FAILURE;
                 goto page_done;
         }
 
         mptsas_fma_check(mpt, cmd);

@@ -1107,11 +1108,11 @@
         /*
          * Can't start another task management routine.
          */
         if (slots->m_slot[MPTSAS_TM_SLOT(mpt)] != NULL) {
                 mptsas_log(mpt, CE_WARN, "Can only start 1 task management"
-                    " command at a time\n");
+                    " command at a time");
                 return (FALSE);
         }
 
         cmd = &(mpt->m_event_task_mgmt.m_event_cmd);
         pkt = &(mpt->m_event_task_mgmt.m_event_pkt);

@@ -1318,18 +1319,18 @@
                  * The code is there but not tested yet.
                  * User has to know there are risks here.
                  */
                 mptsas_log(mpt, CE_WARN, "mptsas_update_flash(): "
                     "Updating firmware through MPI 2.5 has not been "
-                    "tested yet!\n"
-                    "To enable set mptsas_enable_mpi25_flashupdate to 1\n");
+                    "tested yet!  "
+                    "To enable set mptsas_enable_mpi25_flashupdate to 1.");
                 return (-1);
         } /* Otherwise, you pay your money and you take your chances. */
 
         if ((rvalue = (mptsas_request_from_pool(mpt, &cmd, &pkt))) == -1) {
                 mptsas_log(mpt, CE_WARN, "mptsas_update_flash(): allocation "
-                    "failed. event ack command pool is full\n");
+                    "failed. event ack command pool is full");
                 return (rvalue);
         }
 
         bzero((caddr_t)cmd, sizeof (*cmd));
         bzero((caddr_t)pkt, scsi_pkt_size());

@@ -1705,13 +1706,16 @@
 
         num_phys = ddi_get8(accessp, &sasioupage0->NumPhys);
         /*
          * ASSERT that the num_phys value in SAS IO Unit Page 0 is the same as
          * was initially set.  This should never change throughout the life of
-         * the driver.
+         * the driver.  Note, due to cases where we've seen page zero have more
+         * phys than the reported manufacturing information, we limit the number
+         * of phys here to what we got from the manufacturing information.
          */
-        ASSERT(num_phys == mpt->m_num_phys);
+        ASSERT3U(num_phys, >=, mpt->m_num_phys);
+        num_phys = mpt->m_num_phys;
         for (i = 0; i < num_phys; i++) {
                 cpdi[i] = ddi_get32(accessp,
                     &sasioupage0->PhyData[i].
                     ControllerPhyDeviceInfo);
                 port_flags = ddi_get8(accessp,

@@ -1769,15 +1773,18 @@
         }
 
         sasioupage1 = (pMpi2SasIOUnitPage1_t)page_memp;
         num_phys = ddi_get8(accessp, &sasioupage1->NumPhys);
         /*
-         * ASSERT that the num_phys value in SAS IO Unit Page 1 is the same as
+         * ASSERT that the num_phys value in SAS IO Unit Page 0 is the same as
          * was initially set.  This should never change throughout the life of
-         * the driver.
+         * the driver.  Note, due to cases where we've seen page zero have more
+         * phys than the reported manufacturing information, we limit the number
+         * of phys here to what we got from the manufacturing information.
          */
-        ASSERT(num_phys == mpt->m_num_phys);
+        ASSERT3U(num_phys, >=, mpt->m_num_phys);
+        num_phys = mpt->m_num_phys;
         for (i = 0; i < num_phys; i++) {
                 cpdi[i] = ddi_get32(accessp, &sasioupage1->PhyData[i].
                     ControllerPhyDeviceInfo);
                 port_flags = ddi_get8(accessp,
                     &sasioupage1->PhyData[i].PortFlags);

@@ -1930,11 +1937,11 @@
         pMpi2ConfigReply_t      configreply;
         pMpi2SasIOUnitPage0_t   sasioupage0;
         pMpi2SasIOUnitPage1_t   sasioupage1;
         int                     recv_numbytes;
         caddr_t                 recv_memp, page_memp;
-        int                     i, num_phys, start_phy = 0;
+        uint_t                  i, num_phys, start_phy = 0;
         int                     page0_size =
             sizeof (MPI2_CONFIG_PAGE_SASIOUNIT_0) +
             (sizeof (MPI2_SAS_IO_UNIT0_PHY_DATA) * (MPTSAS_MAX_PHYS - 1));
         int                     page1_size =
             sizeof (MPI2_CONFIG_PAGE_SASIOUNIT_1) +

@@ -2110,20 +2117,39 @@
                                 goto cleanup;
                         }
 
                         num_phys = ddi_get8(page_accessp,
                             &sasioupage0->NumPhys);
-                        ASSERT(num_phys == mpt->m_num_phys);
                         if (num_phys > MPTSAS_MAX_PHYS) {
                                 mptsas_log(mpt, CE_WARN, "Number of phys "
                                     "supported by HBA (%d) is more than max "
                                     "supported by driver (%d).  Driver will "
                                     "not attach.", num_phys,
                                     MPTSAS_MAX_PHYS);
                                 rval = DDI_FAILURE;
                                 goto cleanup;
                         }
+                        if (num_phys > mpt->m_num_phys) {
+                                mptsas_log(mpt, CE_WARN, "Number of phys "
+                                    "reported by HBA SAS IO Unit Page 0 (%u) "
+                                    "is greater than that reported by the "
+                                    "manufacturing information (%u). Driver "
+                                    "phy count limited to %u. Please contact "
+                                    "the firmware vendor about this.", num_phys,
+                                    mpt->m_num_phys, mpt->m_num_phys);
+                                num_phys = mpt->m_num_phys;
+                        } else if (num_phys < mpt->m_num_phys) {
+                                mptsas_log(mpt, CE_WARN, "Number of phys "
+                                    "reported by HBA SAS IO Unit Page 0 (%u) "
+                                    "is less than that reported by the "
+                                    "manufacturing information (%u). Driver "
+                                    "will not attach. Please contact the "
+                                    "firmware vendor about this.", num_phys,
+                                    mpt->m_num_phys);
+                                rval = DDI_FAILURE;
+                                goto cleanup;
+                        }
                         for (i = start_phy; i < num_phys; i++, start_phy = i) {
                                 cpdi[i] = ddi_get32(page_accessp,
                                     &sasioupage0->PhyData[i].
                                     ControllerPhyDeviceInfo);
                                 port_flags = ddi_get8(page_accessp,

@@ -2191,20 +2217,39 @@
                                 goto cleanup;
                         }
 
                         num_phys = ddi_get8(page_accessp,
                             &sasioupage1->NumPhys);
-                        ASSERT(num_phys == mpt->m_num_phys);
                         if (num_phys > MPTSAS_MAX_PHYS) {
                                 mptsas_log(mpt, CE_WARN, "Number of phys "
                                     "supported by HBA (%d) is more than max "
                                     "supported by driver (%d).  Driver will "
                                     "not attach.", num_phys,
                                     MPTSAS_MAX_PHYS);
                                 rval = DDI_FAILURE;
                                 goto cleanup;
                         }
+                        if (num_phys > mpt->m_num_phys) {
+                                mptsas_log(mpt, CE_WARN, "Number of phys "
+                                    "reported by HBA SAS IO Unit Page 1 (%u) "
+                                    "is greater than that reported by the "
+                                    "manufacturing information (%u). Limiting "
+                                    "phy count to %u. Please contact the "
+                                    "firmware vendor about this.", num_phys,
+                                    mpt->m_num_phys, mpt->m_num_phys);
+                                num_phys = mpt->m_num_phys;
+                        } else if (num_phys < mpt->m_num_phys) {
+                                mptsas_log(mpt, CE_WARN, "Number of phys "
+                                    "reported by HBA SAS IO Unit Page 1 (%u) "
+                                    "is less than that reported by the "
+                                    "manufacturing information (%u). Driver "
+                                    "will not attach. Please contact the "
+                                    "firmware vendor about this.", num_phys,
+                                    mpt->m_num_phys);
+                                rval = DDI_FAILURE;
+                                goto cleanup;
+                        }
                         for (i = 0; i < num_phys; i++) {
                                 cpdi[i] = ddi_get32(page_accessp,
                                     &sasioupage1->PhyData[i].
                                     ControllerPhyDeviceInfo);
                                 port_flags = ddi_get8(page_accessp,

@@ -2305,11 +2350,12 @@
             recv_accessp)) {
                 rval = DDI_FAILURE;
                 goto done;
         }
 
-        if (iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) {
+        if ((iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) !=
+            0) {
                 mptsas_log(mpt, CE_WARN, "mptsas_get_manufacture_page5 update: "
                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
                     ddi_get32(recv_accessp, &configreply->IOCLogInfo));
                 goto done;
         }

@@ -2365,11 +2411,12 @@
             recv_accessp)) {
                 rval = DDI_FAILURE;
                 goto done;
         }
 
-        if (iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) {
+        if ((iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) !=
+            0) {
                 mptsas_log(mpt, CE_WARN, "mptsas_get_manufacture_page5 config: "
                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
                     ddi_get32(recv_accessp, &configreply->IOCLogInfo));
                 goto done;
         }

@@ -2400,12 +2447,12 @@
             "num-phys", mpt->m_num_phys) != DDI_PROP_SUCCESS) {
                 NDBG2(("%s%d: failed to create num-phys property",
                     ddi_driver_name(mpt->m_dip), ddi_get_instance(mpt->m_dip)));
         }
 
-        mptsas_log(mpt, CE_NOTE, "!mpt%d: Initiator WWNs: 0x%016llx-0x%016llx",
-            mpt->m_instance, (unsigned long long)mpt->un.m_base_wwid,
+        mptsas_log(mpt, CE_NOTE, "Initiator WWNs: 0x%016llx-0x%016llx",
+            (unsigned long long)mpt->un.m_base_wwid,
             (unsigned long long)mpt->un.m_base_wwid + mpt->m_num_phys - 1);
 
         if ((mptsas_check_dma_handle(recv_dma_handle) != DDI_SUCCESS) ||
             (mptsas_check_dma_handle(page_dma_handle) != DDI_SUCCESS)) {
                 ddi_fm_service_impact(mpt->m_dip, DDI_SERVICE_UNAFFECTED);

@@ -2552,13 +2599,13 @@
         uint32_t                *phy_reset_problem_count;
         uint32_t                page_address;
 
         if ((iocstatus != MPI2_IOCSTATUS_SUCCESS) &&
             (iocstatus != MPI2_IOCSTATUS_CONFIG_INVALID_PAGE)) {
-                mptsas_log(mpt, CE_WARN, "mptsas_get_sas_expander_page1 "
+                mptsas_log(mpt, CE_WARN, "%s "
                     "config: IOCStatus=0x%x, IOCLogInfo=0x%x",
-                    iocstatus, iocloginfo);
+                    __func__, iocstatus, iocloginfo);
                 rval = DDI_FAILURE;
                 return (rval);
         }
         page_address = va_arg(ap, uint32_t);
         /*

@@ -2683,11 +2730,12 @@
             recv_accessp)) {
                 rval = DDI_FAILURE;
                 goto done;
         }
 
-        if (iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) {
+        if ((iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) !=
+            0) {
                 mptsas_log(mpt, CE_WARN, "mptsas_get_manufacture_page5 update: "
                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
                     ddi_get32(recv_accessp, &configreply->IOCLogInfo));
                 goto done;
         }

@@ -2741,11 +2789,12 @@
             recv_accessp)) {
                 rval = DDI_FAILURE;
                 goto done;
         }
 
-        if (iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) {
+        if ((iocstatus = ddi_get16(recv_accessp, &configreply->IOCStatus)) !=
+            0) {
                 mptsas_log(mpt, CE_WARN, "mptsas_get_manufacture_page0 config: "
                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
                     ddi_get32(recv_accessp, &configreply->IOCLogInfo));
                 goto done;
         }

@@ -2888,9 +2937,12 @@
             mptsas_enclosurepage_0_cb, page_address, &encpage);
 
         if (rval == DDI_SUCCESS) {
                 mep->me_enchdl = encpage.EnclosureHandle;
                 mep->me_flags = encpage.Flags;
+                mep->me_nslots = encpage.NumSlots;
+                mep->me_fslot = encpage.StartSlot;
+                mep->me_slotleds = NULL;
         }
 
         return (rval);
 }