Print this page
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-9450 NMI panic with SAS9305-16e HBA installed and JBOD connected
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
NEX-2103 12G mpt_sas needs additional minor enhancements
NEX-1889 mpt_sas should support 12G HBAs


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.

  25  * Copyright (c) 2014, Tegile Systems Inc. All rights reserved.
  26  * Copyright (c) 2017, Joyent, Inc.
  27  */
  28 
  29 /*
  30  * Copyright (c) 2000 to 2009, LSI Corporation.
  31  * All rights reserved.
  32  *
  33  * Redistribution and use in source and binary forms of all code within
  34  * this file that is exclusively owned by LSI, with or without
  35  * modification, is permitted provided that, in addition to the CDDL 1.0
  36  * License requirements, the following conditions are met:
  37  *
  38  *    Neither the name of the author nor the names of its contributors may be
  39  *    used to endorse or promote products derived from this software without
  40  *    specific prior written permission.
  41  *
  42  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  43  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  44  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS


 120         case MPI2_MFGPAGE_DEVID_SAS2208_1:
 121         case MPI2_MFGPAGE_DEVID_SAS2208_2:
 122         case MPI2_MFGPAGE_DEVID_SAS2208_3:
 123         case MPI2_MFGPAGE_DEVID_SAS2208_4:
 124         case MPI2_MFGPAGE_DEVID_SAS2208_5:
 125         case MPI2_MFGPAGE_DEVID_SAS2208_6:
 126                 return ("SAS2208");
 127         case MPI2_MFGPAGE_DEVID_SAS2308_1:
 128         case MPI2_MFGPAGE_DEVID_SAS2308_2:
 129         case MPI2_MFGPAGE_DEVID_SAS2308_3:
 130                 return ("SAS2308");
 131         case MPI25_MFGPAGE_DEVID_SAS3004:
 132                 return ("SAS3004");
 133         case MPI25_MFGPAGE_DEVID_SAS3008:
 134                 return ("SAS3008");
 135         case MPI25_MFGPAGE_DEVID_SAS3108_1:
 136         case MPI25_MFGPAGE_DEVID_SAS3108_2:
 137         case MPI25_MFGPAGE_DEVID_SAS3108_5:
 138         case MPI25_MFGPAGE_DEVID_SAS3108_6:
 139                 return ("SAS3108");






























 140         default:
 141                 return ("?");
 142         }
 143 }
 144 
 145 int
 146 mptsas_ioc_get_facts(mptsas_t *mpt)
 147 {
 148         /*
 149          * Send get facts messages
 150          */
 151         if (mptsas_do_dma(mpt, sizeof (MPI2_IOC_FACTS_REQUEST), NULL,
 152             mptsas_ioc_do_get_facts)) {
 153                 return (DDI_FAILURE);
 154         }
 155 
 156         /*
 157          * Get facts reply messages
 158          */
 159         if (mptsas_do_dma(mpt, sizeof (MPI2_IOC_FACTS_REPLY), NULL,


 202         uint_t                  iocstatus;
 203         char                    buf[32];
 204         uint16_t                numReplyFrames;
 205         uint16_t                queueSize, queueDiff;
 206         int                     simple_sge_main;
 207         int                     simple_sge_next;
 208         uint32_t                capabilities;
 209         uint16_t                msgversion;
 210 
 211         bzero(memp, sizeof (*factsreply));
 212         factsreply = (void *)memp;
 213         numbytes = sizeof (*factsreply);
 214 
 215         /*
 216          * get ioc facts reply message
 217          */
 218         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 219                 return (DDI_FAILURE);
 220         }
 221 
 222         if (iocstatus = ddi_get16(accessp, &factsreply->IOCStatus)) {
 223                 mptsas_log(mpt, CE_WARN, "mptsas_ioc_do_get_facts_reply: "
 224                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 225                     ddi_get32(accessp, &factsreply->IOCLogInfo));
 226                 return (DDI_FAILURE);
 227         }
 228 
 229         /*
 230          * store key values from reply to mpt structure
 231          */
 232         mpt->m_fwversion = ddi_get32(accessp, &factsreply->FWVersion.Word);
 233         mpt->m_productid = ddi_get16(accessp, &factsreply->ProductID);
 234 
 235 
 236         (void) sprintf(buf, "%u.%u.%u.%u",
 237             ddi_get8(accessp, &factsreply->FWVersion.Struct.Major),
 238             ddi_get8(accessp, &factsreply->FWVersion.Struct.Minor),
 239             ddi_get8(accessp, &factsreply->FWVersion.Struct.Unit),
 240             ddi_get8(accessp, &factsreply->FWVersion.Struct.Dev));
 241         mptsas_log(mpt, CE_NOTE, "?MPT Firmware version v%s (%s)\n",
 242             buf, mptsas_devid_type_string(mpt));
 243         (void) ddi_prop_update_string(DDI_DEV_T_NONE, mpt->m_dip,
 244             "firmware-version", buf);
 245 
 246         /*
 247          * Set up request info.
 248          */
 249         mpt->m_max_requests = ddi_get16(accessp,
 250             &factsreply->RequestCredit) - 1;
 251         mpt->m_req_frame_size = ddi_get16(accessp,
 252             &factsreply->IOCRequestFrameSize) * 4;
 253 
 254         /*
 255          * Size of reply free queue should be the number of requests
 256          * plus some additional for events (32).  Make sure number of
 257          * reply frames is not a multiple of 16 so that the queue sizes
 258          * are calculated correctly later to be a multiple of 16.
 259          */
 260         mpt->m_reply_frame_size = ddi_get8(accessp,
 261             &factsreply->ReplyFrameSize) * 4;


 291                 mpt->m_max_requests -= queueDiff;
 292                 mpt->m_max_replies -= queueDiff;
 293                 mpt->m_free_queue_depth -= queueDiff;
 294                 queueSize -= queueDiff;
 295         }
 296         mpt->m_post_queue_depth = queueSize;
 297 
 298         /*
 299          * Set up max chain depth.
 300          */
 301         mpt->m_max_chain_depth = ddi_get8(accessp,
 302             &factsreply->MaxChainDepth);
 303         mpt->m_ioc_capabilities = ddi_get32(accessp,
 304             &factsreply->IOCCapabilities);
 305 
 306         /*
 307          * Set flag to check for SAS3 support.
 308          */
 309         msgversion = ddi_get16(accessp, &factsreply->MsgVersion);
 310         if (msgversion >= MPI2_VERSION_02_05) {
 311                 mptsas_log(mpt, CE_NOTE, "?mpt_sas%d SAS 3 Supported\n",
 312                     mpt->m_instance);
 313                 mpt->m_MPI25 = TRUE;
 314         } else {
 315                 mptsas_log(mpt, CE_NOTE, "?mpt_sas%d MPI Version 0x%x\n",
 316                     mpt->m_instance, msgversion);
 317         }
 318 
 319         /*
 320          * Calculate max frames per request based on DMA S/G length.
 321          */
 322         simple_sge_main = MPTSAS_MAX_FRAME_SGES64(mpt) - 1;
 323         simple_sge_next = mpt->m_req_frame_size / MPTSAS_SGE_SIZE(mpt) - 1;
 324 
 325         mpt->m_max_request_frames = (MPTSAS_MAX_DMA_SEGS -
 326             simple_sge_main) / simple_sge_next + 1;
 327         if (((MPTSAS_MAX_DMA_SEGS - simple_sge_main) %
 328             simple_sge_next) > 1) {
 329                 mpt->m_max_request_frames++;
 330         }
 331 
 332         /*
 333          * Check if controller supports FW diag buffers and set flag to enable
 334          * each type.
 335          */
 336         capabilities = ddi_get32(accessp, &factsreply->IOCCapabilities);


 415     ddi_acc_handle_t accessp)
 416 {
 417 #ifndef __lock_lint
 418         _NOTE(ARGUNUSED(var))
 419 #endif
 420         pMpi2PortFactsReply_t   factsreply;
 421         int                     numbytes;
 422         uint_t                  iocstatus;
 423 
 424         bzero(memp, sizeof (*factsreply));
 425         factsreply = (void *)memp;
 426         numbytes = sizeof (*factsreply);
 427 
 428         /*
 429          * Get port facts reply message via handshake
 430          */
 431         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 432                 return (DDI_FAILURE);
 433         }
 434 
 435         if (iocstatus = ddi_get16(accessp, &factsreply->IOCStatus)) {
 436                 mptsas_log(mpt, CE_WARN, "mptsas_ioc_do_get_port_facts_reply: "
 437                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 438                     ddi_get32(accessp, &factsreply->IOCLogInfo));
 439                 return (DDI_FAILURE);
 440         }
 441 
 442         return (DDI_SUCCESS);
 443 }
 444 
 445 int
 446 mptsas_ioc_enable_port(mptsas_t *mpt)
 447 {
 448         /*
 449          * Send enable port message
 450          */
 451         if (mptsas_do_dma(mpt, sizeof (MPI2_PORT_ENABLE_REQUEST), 0,
 452             mptsas_ioc_do_enable_port)) {
 453                 return (DDI_FAILURE);
 454         }
 455 


 495 {
 496 #ifndef __lock_lint
 497         _NOTE(ARGUNUSED(var))
 498 #endif
 499 
 500         int                     numbytes;
 501         uint_t                  iocstatus;
 502         pMpi2PortEnableReply_t  portreply;
 503 
 504         numbytes = sizeof (MPI2_PORT_ENABLE_REPLY);
 505         bzero(memp, numbytes);
 506         portreply = (void *)memp;
 507 
 508         /*
 509          * Get message via handshake
 510          */
 511         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 512                 return (DDI_FAILURE);
 513         }
 514 
 515         if (iocstatus = ddi_get16(accessp, &portreply->IOCStatus)) {
 516                 mptsas_log(mpt, CE_WARN, "mptsas_ioc_do_enable_port_reply: "
 517                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 518                     ddi_get32(accessp, &portreply->IOCLogInfo));
 519                 return (DDI_FAILURE);
 520         }
 521 
 522         return (DDI_SUCCESS);
 523 }
 524 
 525 int
 526 mptsas_ioc_enable_event_notification(mptsas_t *mpt)
 527 {
 528         ASSERT(mutex_owned(&mpt->m_mutex));
 529 
 530         /*
 531          * Send enable event notification message
 532          */
 533         if (mptsas_do_dma(mpt, sizeof (MPI2_EVENT_NOTIFICATION_REQUEST), NULL,
 534             mptsas_ioc_do_enable_event_notification)) {
 535                 return (DDI_FAILURE);


 577     int var, ddi_acc_handle_t accessp)
 578 {
 579 #ifndef __lock_lint
 580         _NOTE(ARGUNUSED(var))
 581 #endif
 582         int                             numbytes;
 583         uint_t                          iocstatus;
 584         pMpi2EventNotificationReply_t   eventsreply;
 585 
 586         numbytes = sizeof (MPI2_EVENT_NOTIFICATION_REPLY);
 587         bzero(memp, numbytes);
 588         eventsreply = (void *)memp;
 589 
 590         /*
 591          * Get message via handshake
 592          */
 593         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 594                 return (DDI_FAILURE);
 595         }
 596 
 597         if (iocstatus = ddi_get16(accessp, &eventsreply->IOCStatus)) {
 598                 mptsas_log(mpt, CE_WARN,
 599                     "mptsas_ioc_do_enable_event_notification_reply: "
 600                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 601                     ddi_get32(accessp, &eventsreply->IOCLogInfo));
 602                 return (DDI_FAILURE);
 603         }
 604 
 605         return (DDI_SUCCESS);
 606 }
 607 
 608 int
 609 mptsas_ioc_init(mptsas_t *mpt)
 610 {
 611         /*
 612          * Send ioc init message
 613          */
 614         if (mptsas_do_dma(mpt, sizeof (MPI2_IOC_INIT_REQUEST), NULL,
 615             mptsas_do_ioc_init)) {
 616                 return (DDI_FAILURE);
 617         }


 704 {
 705 #ifndef __lock_lint
 706         _NOTE(ARGUNUSED(var))
 707 #endif
 708 
 709         pMpi2IOCInitReply_t     initreply;
 710         int                     numbytes;
 711         uint_t                  iocstatus;
 712 
 713         numbytes = sizeof (MPI2_IOC_INIT_REPLY);
 714         bzero(memp, numbytes);
 715         initreply = (void *)memp;
 716 
 717         /*
 718          * Get reply message via handshake
 719          */
 720         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 721                 return (DDI_FAILURE);
 722         }
 723 
 724         if (iocstatus = ddi_get16(accessp, &initreply->IOCStatus)) {
 725                 mptsas_log(mpt, CE_WARN, "mptsas_do_ioc_init_reply: "
 726                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 727                     ddi_get32(accessp, &initreply->IOCLogInfo));
 728                 return (DDI_FAILURE);
 729         }
 730 
 731         if ((ddi_get32(mpt->m_datap, &mpt->m_reg->Doorbell)) &
 732             MPI2_IOC_STATE_OPERATIONAL) {
 733                 mptsas_log(mpt, CE_NOTE,
 734                     "?mpt%d: IOC Operational.\n", mpt->m_instance);
 735         } else {
 736                 return (DDI_FAILURE);
 737         }
 738 
 739         return (DDI_SUCCESS);
 740 }


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
  26  * Copyright (c) 2014, Tegile Systems Inc. All rights reserved.
  27  * Copyright (c) 2017, Joyent, Inc.
  28  */
  29 
  30 /*
  31  * Copyright (c) 2000 to 2009, LSI Corporation.
  32  * All rights reserved.
  33  *
  34  * Redistribution and use in source and binary forms of all code within
  35  * this file that is exclusively owned by LSI, with or without
  36  * modification, is permitted provided that, in addition to the CDDL 1.0
  37  * License requirements, the following conditions are met:
  38  *
  39  *    Neither the name of the author nor the names of its contributors may be
  40  *    used to endorse or promote products derived from this software without
  41  *    specific prior written permission.
  42  *
  43  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS


 121         case MPI2_MFGPAGE_DEVID_SAS2208_1:
 122         case MPI2_MFGPAGE_DEVID_SAS2208_2:
 123         case MPI2_MFGPAGE_DEVID_SAS2208_3:
 124         case MPI2_MFGPAGE_DEVID_SAS2208_4:
 125         case MPI2_MFGPAGE_DEVID_SAS2208_5:
 126         case MPI2_MFGPAGE_DEVID_SAS2208_6:
 127                 return ("SAS2208");
 128         case MPI2_MFGPAGE_DEVID_SAS2308_1:
 129         case MPI2_MFGPAGE_DEVID_SAS2308_2:
 130         case MPI2_MFGPAGE_DEVID_SAS2308_3:
 131                 return ("SAS2308");
 132         case MPI25_MFGPAGE_DEVID_SAS3004:
 133                 return ("SAS3004");
 134         case MPI25_MFGPAGE_DEVID_SAS3008:
 135                 return ("SAS3008");
 136         case MPI25_MFGPAGE_DEVID_SAS3108_1:
 137         case MPI25_MFGPAGE_DEVID_SAS3108_2:
 138         case MPI25_MFGPAGE_DEVID_SAS3108_5:
 139         case MPI25_MFGPAGE_DEVID_SAS3108_6:
 140                 return ("SAS3108");
 141         case MPI26_MFGPAGE_DEVID_SAS3216:
 142         case MPI26_MFGPAGE_DEVID_SAS3316_1:
 143         case MPI26_MFGPAGE_DEVID_SAS3316_2:
 144         case MPI26_MFGPAGE_DEVID_SAS3316_3:
 145         case MPI26_MFGPAGE_DEVID_SAS3316_4:
 146                 return ("SAS3216");
 147         case MPI26_MFGPAGE_DEVID_SAS3224:
 148         case MPI26_MFGPAGE_DEVID_SAS3324_1:
 149         case MPI26_MFGPAGE_DEVID_SAS3324_2:
 150         case MPI26_MFGPAGE_DEVID_SAS3324_3:
 151         case MPI26_MFGPAGE_DEVID_SAS3324_4:
 152                 return ("SAS3224");
 153         case MPI26_MFGPAGE_DEVID_SAS3408:
 154                 return ("SAS3408");
 155         case MPI26_MFGPAGE_DEVID_SAS3416:
 156                 return ("SAS3416");
 157         case MPI26_MFGPAGE_DEVID_SAS3508:
 158         case MPI26_MFGPAGE_DEVID_SAS3508_1:
 159                 return ("SAS3508");
 160         case MPI26_MFGPAGE_DEVID_SAS3516:
 161         case MPI26_MFGPAGE_DEVID_SAS3516_1:
 162                 return ("SAS3516");
 163         case MPI26_MFGPAGE_DEVID_SAS3616:
 164                 return ("SAS3616");
 165         case MPI26_MFGPAGE_DEVID_SAS3708:
 166                 return ("SAS3708");
 167         case MPI26_MFGPAGE_DEVID_SAS3716:
 168                 return ("SAS3716");
 169         case MPI26_MFGPAGE_DEVID_SAS4008:
 170                 return ("SAS4008");
 171         default:
 172                 return ("?");
 173         }
 174 }
 175 
 176 int
 177 mptsas_ioc_get_facts(mptsas_t *mpt)
 178 {
 179         /*
 180          * Send get facts messages
 181          */
 182         if (mptsas_do_dma(mpt, sizeof (MPI2_IOC_FACTS_REQUEST), NULL,
 183             mptsas_ioc_do_get_facts)) {
 184                 return (DDI_FAILURE);
 185         }
 186 
 187         /*
 188          * Get facts reply messages
 189          */
 190         if (mptsas_do_dma(mpt, sizeof (MPI2_IOC_FACTS_REPLY), NULL,


 233         uint_t                  iocstatus;
 234         char                    buf[32];
 235         uint16_t                numReplyFrames;
 236         uint16_t                queueSize, queueDiff;
 237         int                     simple_sge_main;
 238         int                     simple_sge_next;
 239         uint32_t                capabilities;
 240         uint16_t                msgversion;
 241 
 242         bzero(memp, sizeof (*factsreply));
 243         factsreply = (void *)memp;
 244         numbytes = sizeof (*factsreply);
 245 
 246         /*
 247          * get ioc facts reply message
 248          */
 249         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 250                 return (DDI_FAILURE);
 251         }
 252 
 253         if ((iocstatus = ddi_get16(accessp, &factsreply->IOCStatus)) != 0) {
 254                 mptsas_log(mpt, CE_WARN, "mptsas_ioc_do_get_facts_reply: "
 255                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 256                     ddi_get32(accessp, &factsreply->IOCLogInfo));
 257                 return (DDI_FAILURE);
 258         }
 259 
 260         /*
 261          * store key values from reply to mpt structure
 262          */
 263         mpt->m_fwversion = ddi_get32(accessp, &factsreply->FWVersion.Word);
 264         mpt->m_productid = ddi_get16(accessp, &factsreply->ProductID);
 265 
 266 
 267         (void) sprintf(buf, "%u.%u.%u.%u",
 268             ddi_get8(accessp, &factsreply->FWVersion.Struct.Major),
 269             ddi_get8(accessp, &factsreply->FWVersion.Struct.Minor),
 270             ddi_get8(accessp, &factsreply->FWVersion.Struct.Unit),
 271             ddi_get8(accessp, &factsreply->FWVersion.Struct.Dev));
 272         mptsas_log(mpt, CE_NOTE, "MPT Firmware version v%s (%s)",
 273             buf, mptsas_devid_type_string(mpt));
 274         (void) ddi_prop_update_string(DDI_DEV_T_NONE, mpt->m_dip,
 275             "firmware-version", buf);
 276 
 277         /*
 278          * Set up request info.
 279          */
 280         mpt->m_max_requests = ddi_get16(accessp,
 281             &factsreply->RequestCredit) - 1;
 282         mpt->m_req_frame_size = ddi_get16(accessp,
 283             &factsreply->IOCRequestFrameSize) * 4;
 284 
 285         /*
 286          * Size of reply free queue should be the number of requests
 287          * plus some additional for events (32).  Make sure number of
 288          * reply frames is not a multiple of 16 so that the queue sizes
 289          * are calculated correctly later to be a multiple of 16.
 290          */
 291         mpt->m_reply_frame_size = ddi_get8(accessp,
 292             &factsreply->ReplyFrameSize) * 4;


 322                 mpt->m_max_requests -= queueDiff;
 323                 mpt->m_max_replies -= queueDiff;
 324                 mpt->m_free_queue_depth -= queueDiff;
 325                 queueSize -= queueDiff;
 326         }
 327         mpt->m_post_queue_depth = queueSize;
 328 
 329         /*
 330          * Set up max chain depth.
 331          */
 332         mpt->m_max_chain_depth = ddi_get8(accessp,
 333             &factsreply->MaxChainDepth);
 334         mpt->m_ioc_capabilities = ddi_get32(accessp,
 335             &factsreply->IOCCapabilities);
 336 
 337         /*
 338          * Set flag to check for SAS3 support.
 339          */
 340         msgversion = ddi_get16(accessp, &factsreply->MsgVersion);
 341         if (msgversion >= MPI2_VERSION_02_05) {
 342                 mptsas_log(mpt, CE_NOTE, "SAS 3 supported Version (0x%x)",
 343                     msgversion);
 344                 mpt->m_MPI25 = TRUE;
 345         } else {
 346                 mptsas_log(mpt, CE_NOTE, "MPI Version 0x%x", msgversion);

 347         }
 348 
 349         /*
 350          * Calculate max frames per request based on DMA S/G length.
 351          */
 352         simple_sge_main = MPTSAS_MAX_FRAME_SGES64(mpt) - 1;
 353         simple_sge_next = mpt->m_req_frame_size / MPTSAS_SGE_SIZE(mpt) - 1;
 354 
 355         mpt->m_max_request_frames = (MPTSAS_MAX_DMA_SEGS -
 356             simple_sge_main) / simple_sge_next + 1;
 357         if (((MPTSAS_MAX_DMA_SEGS - simple_sge_main) %
 358             simple_sge_next) > 1) {
 359                 mpt->m_max_request_frames++;
 360         }
 361 
 362         /*
 363          * Check if controller supports FW diag buffers and set flag to enable
 364          * each type.
 365          */
 366         capabilities = ddi_get32(accessp, &factsreply->IOCCapabilities);


 445     ddi_acc_handle_t accessp)
 446 {
 447 #ifndef __lock_lint
 448         _NOTE(ARGUNUSED(var))
 449 #endif
 450         pMpi2PortFactsReply_t   factsreply;
 451         int                     numbytes;
 452         uint_t                  iocstatus;
 453 
 454         bzero(memp, sizeof (*factsreply));
 455         factsreply = (void *)memp;
 456         numbytes = sizeof (*factsreply);
 457 
 458         /*
 459          * Get port facts reply message via handshake
 460          */
 461         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 462                 return (DDI_FAILURE);
 463         }
 464 
 465         if ((iocstatus = ddi_get16(accessp, &factsreply->IOCStatus)) != 0) {
 466                 mptsas_log(mpt, CE_WARN, "mptsas_ioc_do_get_port_facts_reply: "
 467                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 468                     ddi_get32(accessp, &factsreply->IOCLogInfo));
 469                 return (DDI_FAILURE);
 470         }
 471 
 472         return (DDI_SUCCESS);
 473 }
 474 
 475 int
 476 mptsas_ioc_enable_port(mptsas_t *mpt)
 477 {
 478         /*
 479          * Send enable port message
 480          */
 481         if (mptsas_do_dma(mpt, sizeof (MPI2_PORT_ENABLE_REQUEST), 0,
 482             mptsas_ioc_do_enable_port)) {
 483                 return (DDI_FAILURE);
 484         }
 485 


 525 {
 526 #ifndef __lock_lint
 527         _NOTE(ARGUNUSED(var))
 528 #endif
 529 
 530         int                     numbytes;
 531         uint_t                  iocstatus;
 532         pMpi2PortEnableReply_t  portreply;
 533 
 534         numbytes = sizeof (MPI2_PORT_ENABLE_REPLY);
 535         bzero(memp, numbytes);
 536         portreply = (void *)memp;
 537 
 538         /*
 539          * Get message via handshake
 540          */
 541         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 542                 return (DDI_FAILURE);
 543         }
 544 
 545         if ((iocstatus = ddi_get16(accessp, &portreply->IOCStatus)) != 0) {
 546                 mptsas_log(mpt, CE_WARN, "mptsas_ioc_do_enable_port_reply: "
 547                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 548                     ddi_get32(accessp, &portreply->IOCLogInfo));
 549                 return (DDI_FAILURE);
 550         }
 551 
 552         return (DDI_SUCCESS);
 553 }
 554 
 555 int
 556 mptsas_ioc_enable_event_notification(mptsas_t *mpt)
 557 {
 558         ASSERT(mutex_owned(&mpt->m_mutex));
 559 
 560         /*
 561          * Send enable event notification message
 562          */
 563         if (mptsas_do_dma(mpt, sizeof (MPI2_EVENT_NOTIFICATION_REQUEST), NULL,
 564             mptsas_ioc_do_enable_event_notification)) {
 565                 return (DDI_FAILURE);


 607     int var, ddi_acc_handle_t accessp)
 608 {
 609 #ifndef __lock_lint
 610         _NOTE(ARGUNUSED(var))
 611 #endif
 612         int                             numbytes;
 613         uint_t                          iocstatus;
 614         pMpi2EventNotificationReply_t   eventsreply;
 615 
 616         numbytes = sizeof (MPI2_EVENT_NOTIFICATION_REPLY);
 617         bzero(memp, numbytes);
 618         eventsreply = (void *)memp;
 619 
 620         /*
 621          * Get message via handshake
 622          */
 623         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 624                 return (DDI_FAILURE);
 625         }
 626 
 627         if ((iocstatus = ddi_get16(accessp, &eventsreply->IOCStatus)) != 0) {
 628                 mptsas_log(mpt, CE_WARN,
 629                     "mptsas_ioc_do_enable_event_notification_reply: "
 630                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 631                     ddi_get32(accessp, &eventsreply->IOCLogInfo));
 632                 return (DDI_FAILURE);
 633         }
 634 
 635         return (DDI_SUCCESS);
 636 }
 637 
 638 int
 639 mptsas_ioc_init(mptsas_t *mpt)
 640 {
 641         /*
 642          * Send ioc init message
 643          */
 644         if (mptsas_do_dma(mpt, sizeof (MPI2_IOC_INIT_REQUEST), NULL,
 645             mptsas_do_ioc_init)) {
 646                 return (DDI_FAILURE);
 647         }


 734 {
 735 #ifndef __lock_lint
 736         _NOTE(ARGUNUSED(var))
 737 #endif
 738 
 739         pMpi2IOCInitReply_t     initreply;
 740         int                     numbytes;
 741         uint_t                  iocstatus;
 742 
 743         numbytes = sizeof (MPI2_IOC_INIT_REPLY);
 744         bzero(memp, numbytes);
 745         initreply = (void *)memp;
 746 
 747         /*
 748          * Get reply message via handshake
 749          */
 750         if (mptsas_get_handshake_msg(mpt, memp, numbytes, accessp)) {
 751                 return (DDI_FAILURE);
 752         }
 753 
 754         if ((iocstatus = ddi_get16(accessp, &initreply->IOCStatus)) != 0) {
 755                 mptsas_log(mpt, CE_WARN, "mptsas_do_ioc_init_reply: "
 756                     "IOCStatus=0x%x, IOCLogInfo=0x%x", iocstatus,
 757                     ddi_get32(accessp, &initreply->IOCLogInfo));
 758                 return (DDI_FAILURE);
 759         }
 760 
 761         if ((ddi_get32(mpt->m_datap, &mpt->m_reg->Doorbell)) &
 762             MPI2_IOC_STATE_OPERATIONAL) {
 763                 mptsas_log(mpt, CE_NOTE, "IOC Operational");

 764         } else {
 765                 return (DDI_FAILURE);
 766         }
 767 
 768         return (DDI_SUCCESS);
 769 }