Print this page
3500 Support LSI SAS2008 (Falcon) Skinny FW for mr_sas(7D)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/mr_sas/mr_sas.c
          +++ new/usr/src/uts/common/io/mr_sas/mr_sas.c
↓ open down ↓ 36 lines elided ↑ open up ↑
  37   37   * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  38   38   * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  39   39   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  40   40   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  41   41   * DAMAGE.
  42   42   */
  43   43  
  44   44  /*
  45   45   * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  46   46   * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
  47      - * Copyright 2012 Nexenta System, Inc. All rights reserved.
       47 + * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  48   48   */
  49   49  
  50   50  #include <sys/types.h>
  51   51  #include <sys/param.h>
  52   52  #include <sys/file.h>
  53   53  #include <sys/errno.h>
  54   54  #include <sys/open.h>
  55   55  #include <sys/cred.h>
  56   56  #include <sys/modctl.h>
  57   57  #include <sys/conf.h>
↓ open down ↓ 15 lines elided ↑ open up ↑
  73   73  #include "mr_sas.h"
  74   74  
  75   75  /*
  76   76   * FMA header files
  77   77   */
  78   78  #include <sys/ddifm.h>
  79   79  #include <sys/fm/protocol.h>
  80   80  #include <sys/fm/util.h>
  81   81  #include <sys/fm/io/ddi.h>
  82   82  
       83 +/* Macros to help Skinny and stock 2108/MFI live together. */
       84 +#define WR_IB_PICK_QPORT(addr, instance) \
       85 +        if ((instance)->skinny) { \
       86 +                WR_IB_LOW_QPORT((addr), (instance)); \
       87 +                WR_IB_HIGH_QPORT(0, (instance)); \
       88 +        } else { \
       89 +                WR_IB_QPORT((addr), (instance)); \
       90 +        }
       91 +
  83   92  /*
  84   93   * Local static data
  85   94   */
  86   95  static void     *mrsas_state = NULL;
  87   96  static volatile boolean_t       mrsas_relaxed_ordering = B_TRUE;
  88   97  volatile int    debug_level_g = CL_NONE;
  89   98  static volatile int     msi_enable = 1;
  90   99  static volatile int     ctio_enable = 1;
  91  100  
  92  101  /* Default Timeout value to issue online controller reset */
↓ open down ↓ 35 lines elided ↑ open up ↑
 128  137  static int      mrsas_tran_setcap(struct scsi_address *, char *, int, int);
 129  138  static void     mrsas_tran_destroy_pkt(struct scsi_address *,
 130  139                      struct scsi_pkt *);
 131  140  static void     mrsas_tran_dmafree(struct scsi_address *, struct scsi_pkt *);
 132  141  static void     mrsas_tran_sync_pkt(struct scsi_address *, struct scsi_pkt *);
 133  142  static int      mrsas_tran_quiesce(dev_info_t *dip);
 134  143  static int      mrsas_tran_unquiesce(dev_info_t *dip);
 135  144  static uint_t   mrsas_isr();
 136  145  static uint_t   mrsas_softintr();
 137  146  static void     mrsas_undo_resources(dev_info_t *, struct mrsas_instance *);
 138      -static struct mrsas_cmd *get_mfi_pkt(struct mrsas_instance *);
 139      -static void     return_mfi_pkt(struct mrsas_instance *,
 140      -                    struct mrsas_cmd *);
 141  147  
 142  148  static void     free_space_for_mfi(struct mrsas_instance *);
 143  149  static uint32_t read_fw_status_reg_ppc(struct mrsas_instance *);
 144  150  static void     issue_cmd_ppc(struct mrsas_cmd *, struct mrsas_instance *);
 145  151  static int      issue_cmd_in_poll_mode_ppc(struct mrsas_instance *,
 146  152                      struct mrsas_cmd *);
 147  153  static int      issue_cmd_in_sync_mode_ppc(struct mrsas_instance *,
 148  154                      struct mrsas_cmd *);
 149  155  static void     enable_intr_ppc(struct mrsas_instance *);
 150  156  static void     disable_intr_ppc(struct mrsas_instance *);
↓ open down ↓ 417 lines elided ↑ open up ↑
 568  574                  case PCI_DEVICE_ID_LSI_TBOLT:
 569  575                  case PCI_DEVICE_ID_LSI_INVADER:
 570  576                          con_log(CL_ANN, (CE_NOTE,
 571  577                              "mr_sas: 2208 T.B. device detected"));
 572  578  
 573  579                          instance->func_ptr =
 574  580                              &mrsas_function_template_fusion;
 575  581                          instance->tbolt = 1;
 576  582                          break;
 577  583  
      584 +                case PCI_DEVICE_ID_LSI_SKINNY:
      585 +                case PCI_DEVICE_ID_LSI_SKINNY_NEW:
      586 +                        /*
      587 +                         * FALLTHRU to PPC-style functions, but mark this
      588 +                         * instance as Skinny, because the register set is
      589 +                         * slightly different (See WR_IB_PICK_QPORT), and
      590 +                         * certain other features are available to a Skinny
      591 +                         * HBA.
      592 +                         */
      593 +                        instance->skinny = 1;
      594 +                        /* FALLTHRU */
      595 +
 578  596                  case PCI_DEVICE_ID_LSI_2108VDE:
 579  597                  case PCI_DEVICE_ID_LSI_2108V:
 580  598                          con_log(CL_ANN, (CE_NOTE,
 581  599                              "mr_sas: 2108 Liberator device detected"));
 582  600  
 583  601                          instance->func_ptr =
 584  602                              &mrsas_function_template_ppc;
 585  603                          break;
 586  604  
 587  605                  default:
↓ open down ↓ 220 lines elided ↑ open up ↑
 808  826                          goto fail_attach;
 809  827                  }
 810  828  
 811  829                  instance->tran = tran;
 812  830                  instance->unroll.tran = 1;
 813  831  
 814  832                  tran->tran_hba_private  = instance;
 815  833                  tran->tran_tgt_init     = mrsas_tran_tgt_init;
 816  834                  tran->tran_tgt_probe    = scsi_hba_probe;
 817  835                  tran->tran_tgt_free     = mrsas_tran_tgt_free;
 818      -                if (instance->tbolt) {
 819      -                        tran->tran_init_pkt     =
 820      -                            mrsas_tbolt_tran_init_pkt;
 821      -                        tran->tran_start        =
 822      -                            mrsas_tbolt_tran_start;
 823      -                } else {
 824      -                        tran->tran_init_pkt     = mrsas_tran_init_pkt;
 825      -                        tran->tran_start        = mrsas_tran_start;
 826      -                }
      836 +                tran->tran_init_pkt     = mrsas_tran_init_pkt;
      837 +                if (instance->tbolt)
      838 +                        tran->tran_start = mrsas_tbolt_tran_start;
      839 +                else
      840 +                        tran->tran_start = mrsas_tran_start;
 827  841                  tran->tran_abort        = mrsas_tran_abort;
 828  842                  tran->tran_reset        = mrsas_tran_reset;
 829  843                  tran->tran_getcap       = mrsas_tran_getcap;
 830  844                  tran->tran_setcap       = mrsas_tran_setcap;
 831  845                  tran->tran_destroy_pkt  = mrsas_tran_destroy_pkt;
 832  846                  tran->tran_dmafree      = mrsas_tran_dmafree;
 833  847                  tran->tran_sync_pkt     = mrsas_tran_sync_pkt;
 834  848                  tran->tran_quiesce      = mrsas_tran_quiesce;
 835  849                  tran->tran_unquiesce    = mrsas_tran_unquiesce;
 836  850                  tran->tran_bus_config   = mrsas_tran_bus_config;
↓ open down ↓ 96 lines elided ↑ open up ↑
 933  947                      DDI_SUCCESS) {
 934  948                          goto fail_attach;
 935  949                  }
 936  950  
 937  951                  instance->mr_ld_list =
 938  952                      kmem_zalloc(MRDRV_MAX_LD * sizeof (struct mrsas_ld),
 939  953                      KM_SLEEP);
 940  954                  instance->unroll.ldlist_buff = 1;
 941  955  
 942  956  #ifdef PDSUPPORT
 943      -                if (instance->tbolt) {
      957 +                if (instance->tbolt || instance->skinny) {
 944  958                          instance->mr_tbolt_pd_max = MRSAS_TBOLT_PD_TGT_MAX;
 945  959                          instance->mr_tbolt_pd_list =
 946  960                              kmem_zalloc(MRSAS_TBOLT_GET_PD_MAX(instance) *
 947  961                              sizeof (struct mrsas_tbolt_pd), KM_SLEEP);
 948  962                          ASSERT(instance->mr_tbolt_pd_list);
 949  963                          for (i = 0; i < instance->mr_tbolt_pd_max; i++) {
 950  964                                  instance->mr_tbolt_pd_list[i].lun_type =
 951  965                                      MRSAS_TBOLT_PD_LUN;
 952  966                                  instance->mr_tbolt_pd_list[i].dev_id =
 953  967                                      (uint8_t)i;
↓ open down ↓ 702 lines elided ↑ open up ↑
1656 1670                      strcmp(ddi_driver_name(sd->sd_dev), "sd") == 0) {
1657 1671                          mutex_enter(&instance->config_dev_mtx);
1658 1672                          instance->mr_ld_list[tgt].dip = tgt_dip;
1659 1673                          instance->mr_ld_list[tgt].lun_type = MRSAS_LD_LUN;
1660 1674                          instance->mr_ld_list[tgt].flag = MRDRV_TGT_VALID;
1661 1675                          mutex_exit(&instance->config_dev_mtx);
1662 1676                  }
1663 1677          }
1664 1678  
1665 1679  #ifdef PDSUPPORT
1666      -        else if (instance->tbolt) {
     1680 +        else if (instance->tbolt || instance->skinny) {
1667 1681                  if (instance->mr_tbolt_pd_list[tgt].dip == NULL) {
1668 1682                          mutex_enter(&instance->config_dev_mtx);
1669 1683                          instance->mr_tbolt_pd_list[tgt].dip = tgt_dip;
1670 1684                          instance->mr_tbolt_pd_list[tgt].flag =
1671 1685                              MRDRV_TGT_VALID;
1672 1686                          mutex_exit(&instance->config_dev_mtx);
1673 1687                          con_log(CL_ANN1, (CE_NOTE, "mrsas_tran_tgt_init:"
1674 1688                              "t%xl%x", tgt, lun));
1675 1689                  }
1676 1690          }
↓ open down ↓ 17 lines elided ↑ open up ↑
1694 1708  
1695 1709          if (tgt < MRDRV_MAX_LD && lun == 0) {
1696 1710                  if (instance->mr_ld_list[tgt].dip == tgt_dip) {
1697 1711                          mutex_enter(&instance->config_dev_mtx);
1698 1712                          instance->mr_ld_list[tgt].dip = NULL;
1699 1713                          mutex_exit(&instance->config_dev_mtx);
1700 1714                  }
1701 1715          }
1702 1716  
1703 1717  #ifdef PDSUPPORT
1704      -        else if (instance->tbolt) {
     1718 +        else if (instance->tbolt || instance->skinny) {
1705 1719                  mutex_enter(&instance->config_dev_mtx);
1706 1720                  instance->mr_tbolt_pd_list[tgt].dip = NULL;
1707 1721                  mutex_exit(&instance->config_dev_mtx);
1708 1722                  con_log(CL_ANN1, (CE_NOTE, "tgt_free: Setting dip = NULL"
1709 1723                      "for tgt:%x", tgt));
1710 1724          }
1711 1725  #endif
1712 1726  
1713 1727  }
1714 1728  
↓ open down ↓ 216 lines elided ↑ open up ↑
1931 1945          if (cmd == NULL) {
1932 1946                  return (TRAN_BUSY);
1933 1947          }
1934 1948  
1935 1949          if ((pkt->pkt_flags & FLAG_NOINTR) == 0) {
1936 1950                  if (instance->fw_outstanding > instance->max_fw_cmds) {
1937 1951                          con_log(CL_ANN, (CE_CONT, "mr_sas:Firmware busy"));
1938 1952                          DTRACE_PROBE2(start_tran_err,
1939 1953                              uint16_t, instance->fw_outstanding,
1940 1954                              uint16_t, instance->max_fw_cmds);
1941      -                        return_mfi_pkt(instance, cmd);
     1955 +                        mrsas_return_mfi_pkt(instance, cmd);
1942 1956                          return (TRAN_BUSY);
1943 1957                  }
1944 1958  
1945 1959                  /* Synchronize the Cmd frame for the controller */
1946 1960                  (void) ddi_dma_sync(cmd->frame_dma_obj.dma_handle, 0, 0,
1947 1961                      DDI_DMA_SYNC_FORDEV);
1948 1962                  con_log(CL_ANN, (CE_CONT, "issue_cmd_ppc: SCSI CDB[0]=0x%x"
1949 1963                      "cmd->index:%x\n", pkt->pkt_cdbp[0], cmd->index));
1950 1964                  instance->func_ptr->issue_cmd(cmd, instance);
1951 1965  
↓ open down ↓ 28 lines elided ↑ open up ↑
1980 1994                          pkt->pkt_statistics     = STAT_DISCON;
1981 1995                          break;
1982 1996  
1983 1997                  default:
1984 1998                          ((struct scsi_status *)pkt->pkt_scbp)->sts_busy = 1;
1985 1999                  }
1986 2000  
1987 2001                  (void) mrsas_common_check(instance, cmd);
1988 2002                  DTRACE_PROBE2(start_nointr_done, uint8_t, hdr->cmd,
1989 2003                      uint8_t, hdr->cmd_status);
1990      -                return_mfi_pkt(instance, cmd);
     2004 +                mrsas_return_mfi_pkt(instance, cmd);
1991 2005  
1992 2006                  if (pkt->pkt_comp) {
1993 2007                          (*pkt->pkt_comp)(pkt);
1994 2008                  }
1995 2009  
1996 2010          }
1997 2011  
1998 2012          return (TRAN_ACCEPT);
1999 2013  }
2000 2014  
↓ open down ↓ 453 lines elided ↑ open up ↑
2454 2468  /*
2455 2469   * get_mfi_pkt : Get a command from the free pool
2456 2470   * After successful allocation, the caller of this routine
2457 2471   * must clear the frame buffer (memset to zero) before
2458 2472   * using the packet further.
2459 2473   *
2460 2474   * ***** Note *****
2461 2475   * After clearing the frame buffer the context id of the
2462 2476   * frame buffer SHOULD be restored back.
2463 2477   */
2464      -static struct mrsas_cmd *
2465      -get_mfi_pkt(struct mrsas_instance *instance)
     2478 +struct mrsas_cmd *
     2479 +mrsas_get_mfi_pkt(struct mrsas_instance *instance)
2466 2480  {
2467 2481          mlist_t                 *head = &instance->cmd_pool_list;
2468 2482          struct mrsas_cmd        *cmd = NULL;
2469 2483  
2470 2484          mutex_enter(&instance->cmd_pool_mtx);
2471 2485  
2472 2486          if (!mlist_empty(head)) {
2473 2487                  cmd = mlist_entry(head->next, struct mrsas_cmd, list);
2474 2488                  mlist_del_init(head->next);
2475 2489          }
↓ open down ↓ 26 lines elided ↑ open up ↑
2502 2516                  cmd->drv_pkt_time = 0;
2503 2517          }
2504 2518  
2505 2519          mutex_exit(&instance->app_cmd_pool_mtx);
2506 2520  
2507 2521          return (cmd);
2508 2522  }
2509 2523  /*
2510 2524   * return_mfi_pkt : Return a cmd to free command pool
2511 2525   */
2512      -static void
2513      -return_mfi_pkt(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
     2526 +void
     2527 +mrsas_return_mfi_pkt(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
2514 2528  {
2515 2529          mutex_enter(&instance->cmd_pool_mtx);
2516 2530          /* use mlist_add_tail for debug assistance */
2517 2531          mlist_add_tail(&cmd->list, &instance->cmd_pool_list);
2518 2532  
2519 2533          mutex_exit(&instance->cmd_pool_mtx);
2520 2534  }
2521 2535  
2522 2536  static void
2523 2537  return_mfi_app_pkt(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
↓ open down ↓ 631 lines elided ↑ open up ↑
3155 3169                      kmem_zalloc(sizeof (struct mrsas_cmd), KM_SLEEP);
3156 3170                  ASSERT(instance->cmd_list[count]);
3157 3171          }
3158 3172  
3159 3173          /* add all the commands to command pool */
3160 3174  
3161 3175          INIT_LIST_HEAD(&instance->cmd_pool_list);
3162 3176          INIT_LIST_HEAD(&instance->cmd_pend_list);
3163 3177          INIT_LIST_HEAD(&instance->app_cmd_pool_list);
3164 3178  
3165      -        reserve_cmd = MRSAS_APP_RESERVED_CMDS;
     3179 +        /*
     3180 +         * When max_cmd is lower than MRSAS_APP_RESERVED_CMDS, how do I split
     3181 +         * into app_cmd and regular cmd?  For now, just take
     3182 +         * max(1/8th of max, 4);
     3183 +         */
     3184 +        reserve_cmd = min(MRSAS_APP_RESERVED_CMDS,
     3185 +            max(max_cmd >> 3, MRSAS_APP_MIN_RESERVED_CMDS));
3166 3186  
3167 3187          for (i = 0; i < reserve_cmd; i++) {
3168 3188                  cmd = instance->cmd_list[i];
3169 3189                  cmd->index = i;
3170 3190                  mlist_add_tail(&cmd->list, &instance->app_cmd_pool_list);
3171 3191          }
3172 3192  
3173 3193  
3174 3194          for (i = reserve_cmd; i < max_cmd; i++) {
3175 3195                  cmd = instance->cmd_list[i];
↓ open down ↓ 93 lines elided ↑ open up ↑
3269 3289  {
3270 3290          int     ret = 0;
3271 3291  
3272 3292          struct mrsas_cmd                *cmd;
3273 3293          struct mrsas_dcmd_frame *dcmd;
3274 3294          struct mrsas_ctrl_info  *ci;
3275 3295  
3276 3296          if (instance->tbolt) {
3277 3297                  cmd = get_raid_msg_mfi_pkt(instance);
3278 3298          } else {
3279      -                cmd = get_mfi_pkt(instance);
     3299 +                cmd = mrsas_get_mfi_pkt(instance);
3280 3300          }
3281 3301  
3282 3302          if (!cmd) {
3283 3303                  con_log(CL_ANN, (CE_WARN,
3284 3304                      "Failed to get a cmd for ctrl info"));
3285 3305                  DTRACE_PROBE2(info_mfi_err, uint16_t, instance->fw_outstanding,
3286 3306                      uint16_t, instance->max_fw_cmds);
3287 3307                  return (DDI_FAILURE);
3288 3308          }
3289 3309  
↓ open down ↓ 2 lines elided ↑ open up ↑
3292 3312          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
3293 3313              cmd->index);
3294 3314  
3295 3315          dcmd = &cmd->frame->dcmd;
3296 3316  
3297 3317          ci = (struct mrsas_ctrl_info *)instance->internal_buf;
3298 3318  
3299 3319          if (!ci) {
3300 3320                  cmn_err(CE_WARN,
3301 3321                      "Failed to alloc mem for ctrl info");
3302      -                return_mfi_pkt(instance, cmd);
     3322 +                mrsas_return_mfi_pkt(instance, cmd);
3303 3323                  return (DDI_FAILURE);
3304 3324          }
3305 3325  
3306 3326          (void) memset(ci, 0, sizeof (struct mrsas_ctrl_info));
3307 3327  
3308 3328          /* for( i = 0; i < DCMD_MBOX_SZ; i++ ) dcmd->mbox.b[i] = 0; */
3309 3329          (void) memset(dcmd->mbox.b, 0, DCMD_MBOX_SZ);
3310 3330  
3311 3331          ddi_put8(cmd->frame_dma_obj.acc_handle, &dcmd->cmd, MFI_CMD_OP_DCMD);
3312 3332          ddi_put8(cmd->frame_dma_obj.acc_handle, &dcmd->cmd_status,
↓ open down ↓ 38 lines elided ↑ open up ↑
3351 3371                  cmn_err(CE_WARN, "get_ctrl_info: Ctrl info failed");
3352 3372                  ret = -1;
3353 3373          }
3354 3374  
3355 3375          if (mrsas_common_check(instance, cmd) != DDI_SUCCESS) {
3356 3376                  ret = -1;
3357 3377          }
3358 3378          if (instance->tbolt) {
3359 3379                  return_raid_msg_mfi_pkt(instance, cmd);
3360 3380          } else {
3361      -                return_mfi_pkt(instance, cmd);
     3381 +                mrsas_return_mfi_pkt(instance, cmd);
3362 3382          }
3363 3383  
3364 3384          return (ret);
3365 3385  }
3366 3386  
3367 3387  /*
3368 3388   * abort_aen_cmd
3369 3389   */
3370 3390  static int
3371 3391  abort_aen_cmd(struct mrsas_instance *instance,
↓ open down ↓ 2 lines elided ↑ open up ↑
3374 3394          int     ret = 0;
3375 3395  
3376 3396          struct mrsas_cmd                *cmd;
3377 3397          struct mrsas_abort_frame        *abort_fr;
3378 3398  
3379 3399          con_log(CL_ANN1, (CE_NOTE, "chkpnt: abort_aen:%d", __LINE__));
3380 3400  
3381 3401          if (instance->tbolt) {
3382 3402                  cmd = get_raid_msg_mfi_pkt(instance);
3383 3403          } else {
3384      -                cmd = get_mfi_pkt(instance);
     3404 +                cmd = mrsas_get_mfi_pkt(instance);
3385 3405          }
3386 3406  
3387 3407          if (!cmd) {
3388 3408                  con_log(CL_ANN1, (CE_WARN,
3389 3409                      "abort_aen_cmd():Failed to get a cmd for abort_aen_cmd"));
3390 3410                  DTRACE_PROBE2(abort_mfi_err, uint16_t, instance->fw_outstanding,
3391 3411                      uint16_t, instance->max_fw_cmds);
3392 3412                  return (DDI_FAILURE);
3393 3413          }
3394 3414  
↓ open down ↓ 32 lines elided ↑ open up ↑
3427 3447          } else {
3428 3448                  ret = 0;
3429 3449          }
3430 3450  
3431 3451          instance->aen_cmd->abort_aen = 1;
3432 3452          instance->aen_cmd = 0;
3433 3453  
3434 3454          if (instance->tbolt) {
3435 3455                  return_raid_msg_mfi_pkt(instance, cmd);
3436 3456          } else {
3437      -                return_mfi_pkt(instance, cmd);
     3457 +                mrsas_return_mfi_pkt(instance, cmd);
3438 3458          }
3439 3459  
3440 3460          atomic_add_16(&instance->fw_outstanding, (-1));
3441 3461  
3442 3462          return (ret);
3443 3463  }
3444 3464  
3445 3465  
3446 3466  static int
3447 3467  mrsas_build_init_cmd(struct mrsas_instance *instance,
↓ open down ↓ 114 lines elided ↑ open up ↑
3562 3582           * allocate memory for mfi adapter(cmd pool, individual commands, mfi
3563 3583           * frames etc
3564 3584           */
3565 3585          if (alloc_space_for_mfi(instance) != DDI_SUCCESS) {
3566 3586                  con_log(CL_ANN, (CE_NOTE,
3567 3587                      "Error, failed to allocate memory for MFI adapter"));
3568 3588                  return (DDI_FAILURE);
3569 3589          }
3570 3590  
3571 3591          /* Build INIT command */
3572      -        cmd = get_mfi_pkt(instance);
     3592 +        cmd = mrsas_get_mfi_pkt(instance);
     3593 +        if (cmd == NULL) {
     3594 +                DTRACE_PROBE2(init_adapter_mfi_err, uint16_t,
     3595 +                    instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
     3596 +                return (DDI_FAILURE);
     3597 +        }
3573 3598  
3574 3599          if (mrsas_build_init_cmd(instance, &cmd) != DDI_SUCCESS) {
3575 3600                  con_log(CL_ANN,
3576 3601                      (CE_NOTE, "Error, failed to build INIT command"));
3577 3602  
3578 3603                  goto fail_undo_alloc_mfi_space;
3579 3604          }
3580 3605  
3581 3606          /*
3582 3607           * Disable interrupt before sending init frame ( see linux driver code)
3583 3608           * send INIT MFI frame in polled mode
3584 3609           */
3585 3610          if (instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) {
3586 3611                  con_log(CL_ANN, (CE_WARN, "failed to init firmware"));
3587 3612                  goto fail_fw_init;
3588 3613          }
3589 3614  
3590 3615          if (mrsas_common_check(instance, cmd) != DDI_SUCCESS)
3591 3616                  goto fail_fw_init;
3592      -        return_mfi_pkt(instance, cmd);
     3617 +        mrsas_return_mfi_pkt(instance, cmd);
3593 3618  
3594 3619          if (ctio_enable &&
3595 3620              (instance->func_ptr->read_fw_status_reg(instance) & 0x04000000)) {
3596 3621                  con_log(CL_ANN, (CE_NOTE, "mr_sas: IEEE SGL's supported"));
3597 3622                  instance->flag_ieee = 1;
3598 3623          } else {
3599 3624                  instance->flag_ieee = 0;
3600 3625          }
3601 3626  
     3627 +        ASSERT(!instance->skinny || instance->flag_ieee);
     3628 +
3602 3629          instance->unroll.alloc_space_mfi = 1;
3603 3630          instance->unroll.verBuff = 1;
3604 3631  
3605 3632          return (DDI_SUCCESS);
3606 3633  
3607 3634  
3608 3635  fail_fw_init:
3609 3636          (void) mrsas_free_dma_obj(instance, instance->drv_ver_dma_obj);
3610 3637  
3611 3638  fail_undo_alloc_mfi_space:
3612      -        return_mfi_pkt(instance, cmd);
     3639 +        mrsas_return_mfi_pkt(instance, cmd);
3613 3640          free_space_for_mfi(instance);
3614 3641  
3615 3642          return (DDI_FAILURE);
3616 3643  
3617 3644  }
3618 3645  
3619 3646  /*
3620 3647   * mrsas_init_adapter - Initialize adapter.
3621 3648   */
3622 3649  int
↓ open down ↓ 131 lines elided ↑ open up ↑
3754 3781          /* issue the init frame in polled mode */
3755 3782          if (instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) {
3756 3783                  con_log(CL_ANN1, (CE_WARN,
3757 3784                      "mrsas_issue_init_mfi():failed to "
3758 3785                      "init firmware"));
3759 3786                  return_mfi_app_pkt(instance, cmd);
3760 3787                  return (DDI_FAILURE);
3761 3788          }
3762 3789  
3763 3790          if (mrsas_common_check(instance, cmd) != DDI_SUCCESS) {
3764      -                return_mfi_pkt(instance, cmd);
     3791 +                return_mfi_app_pkt(instance, cmd);
3765 3792                  return (DDI_FAILURE);
3766 3793          }
3767 3794  
3768 3795          return_mfi_app_pkt(instance, cmd);
3769 3796          con_log(CL_ANN1, (CE_CONT, "mrsas_issue_init_mfi: Done"));
3770 3797  
3771 3798          return (DDI_SUCCESS);
3772 3799  }
3773 3800  /*
3774 3801   * mfi_state_transition_to_ready        : Move the FW to READY state
↓ open down ↓ 32 lines elided ↑ open up ↑
3807 3834                  case MFI_STATE_WAIT_HANDSHAKE:
3808 3835                          /* set the CLR bit in IMR0 */
3809 3836                          con_log(CL_ANN1, (CE_NOTE,
3810 3837                              "mr_sas: FW waiting for HANDSHAKE"));
3811 3838                          /*
3812 3839                           * PCI_Hot Plug: MFI F/W requires
3813 3840                           * (MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG)
3814 3841                           * to be set
3815 3842                           */
3816 3843                          /* WR_IB_MSG_0(MFI_INIT_CLEAR_HANDSHAKE, instance); */
3817      -                        if (!instance->tbolt) {
     3844 +                        if (!instance->tbolt && !instance->skinny) {
3818 3845                                  WR_IB_DOORBELL(MFI_INIT_CLEAR_HANDSHAKE |
3819 3846                                      MFI_INIT_HOTPLUG, instance);
3820 3847                          } else {
3821 3848                                  WR_RESERVED0_REGISTER(MFI_INIT_CLEAR_HANDSHAKE |
3822 3849                                      MFI_INIT_HOTPLUG, instance);
3823 3850                          }
3824 3851                          max_wait        = (instance->tbolt == 1) ? 180 : 2;
3825 3852                          cur_state       = MFI_STATE_WAIT_HANDSHAKE;
3826 3853                          break;
3827 3854                  case MFI_STATE_BOOT_MESSAGE_PENDING:
3828 3855                          /* set the CLR bit in IMR0 */
3829 3856                          con_log(CL_ANN1, (CE_NOTE,
3830 3857                              "mr_sas: FW state boot message pending"));
3831 3858                          /*
3832 3859                           * PCI_Hot Plug: MFI F/W requires
3833 3860                           * (MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG)
3834 3861                           * to be set
3835 3862                           */
3836      -                        if (!instance->tbolt) {
     3863 +                        if (!instance->tbolt && !instance->skinny) {
3837 3864                                  WR_IB_DOORBELL(MFI_INIT_HOTPLUG, instance);
3838 3865                          } else {
3839 3866                                  WR_RESERVED0_REGISTER(MFI_INIT_HOTPLUG,
3840 3867                                      instance);
3841 3868                          }
3842 3869                          max_wait        = (instance->tbolt == 1) ? 180 : 10;
3843 3870                          cur_state       = MFI_STATE_BOOT_MESSAGE_PENDING;
3844 3871                          break;
3845 3872                  case MFI_STATE_OPERATIONAL:
3846 3873                          /* bring it to READY state; assuming max wait 2 secs */
3847 3874                          instance->func_ptr->disable_intr(instance);
3848 3875                          con_log(CL_ANN1, (CE_NOTE,
3849 3876                              "mr_sas: FW in OPERATIONAL state"));
3850 3877                          /*
3851 3878                           * PCI_Hot Plug: MFI F/W requires
3852 3879                           * (MFI_INIT_READY | MFI_INIT_MFIMODE | MFI_INIT_ABORT)
3853 3880                           * to be set
3854 3881                           */
3855 3882                          /* WR_IB_DOORBELL(MFI_INIT_READY, instance); */
3856      -                        if (!instance->tbolt) {
     3883 +                        if (!instance->tbolt && !instance->skinny) {
3857 3884                                  WR_IB_DOORBELL(MFI_RESET_FLAGS, instance);
3858 3885                          } else {
3859 3886                                  WR_RESERVED0_REGISTER(MFI_RESET_FLAGS,
3860 3887                                      instance);
3861 3888  
3862 3889                                  for (i = 0; i < (10 * 1000); i++) {
3863 3890                                          status =
3864 3891                                              RD_RESERVED0_REGISTER(instance);
3865 3892                                          if (status & 1) {
3866 3893                                                  delay(1 *
↓ open down ↓ 63 lines elided ↑ open up ↑
3930 3957                  }
3931 3958  
3932 3959                  /* return error if fw_state hasn't changed after max_wait */
3933 3960                  if (fw_state == cur_state) {
3934 3961                          con_log(CL_ANN1, (CE_WARN,
3935 3962                              "FW state hasn't changed in %d secs", max_wait));
3936 3963                          return (ENODEV);
3937 3964                  }
3938 3965          };
3939 3966  
3940      -        if (!instance->tbolt) {
     3967 +        /* This may also need to apply to Skinny, but for now, don't worry. */
     3968 +        if (!instance->tbolt && !instance->skinny) {
3941 3969                  fw_ctrl = RD_IB_DOORBELL(instance);
3942 3970                  con_log(CL_ANN1, (CE_CONT,
3943 3971                      "mfi_state_transition_to_ready:FW ctrl = 0x%x", fw_ctrl));
3944 3972  
3945 3973                  /*
3946 3974                   * Write 0xF to the doorbell register to do the following.
3947 3975                   * - Abort all outstanding commands (bit 0).
3948 3976                   * - Transition from OPERATIONAL to READY state (bit 1).
3949 3977                   * - Discard (possible) low MFA posted in 64-bit mode (bit-2).
3950 3978                   * - Set to release FW to continue running (i.e. BIOS handshake
↓ open down ↓ 18 lines elided ↑ open up ↑
3969 3997  {
3970 3998          int     ret = DDI_SUCCESS;
3971 3999  
3972 4000          dma_obj_t                       dcmd_dma_obj;
3973 4001          struct mrsas_cmd                *cmd;
3974 4002          struct mrsas_dcmd_frame         *dcmd;
3975 4003          struct mrsas_evt_log_info *eli_tmp;
3976 4004          if (instance->tbolt) {
3977 4005                  cmd = get_raid_msg_mfi_pkt(instance);
3978 4006          } else {
3979      -                cmd = get_mfi_pkt(instance);
     4007 +                cmd = mrsas_get_mfi_pkt(instance);
3980 4008          }
3981 4009  
3982 4010          if (!cmd) {
3983 4011                  cmn_err(CE_WARN, "mr_sas: failed to get a cmd");
3984 4012                  DTRACE_PROBE2(seq_num_mfi_err, uint16_t,
3985 4013                      instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
3986 4014                  return (ENOMEM);
3987 4015          }
3988 4016  
3989 4017          /* Clear the frame buffer and assign back the context id */
↓ open down ↓ 55 lines elided ↑ open up ↑
4045 4073                      &eli_tmp->newest_seq_num);
4046 4074                  ret = DDI_SUCCESS;
4047 4075          }
4048 4076  
4049 4077          if (mrsas_free_dma_obj(instance, dcmd_dma_obj) != DDI_SUCCESS)
4050 4078                  ret = DDI_FAILURE;
4051 4079  
4052 4080          if (instance->tbolt) {
4053 4081                  return_raid_msg_mfi_pkt(instance, cmd);
4054 4082          } else {
4055      -                return_mfi_pkt(instance, cmd);
     4083 +                mrsas_return_mfi_pkt(instance, cmd);
4056 4084          }
4057 4085  
4058 4086          return (ret);
4059 4087  }
4060 4088  
4061 4089  /*
4062 4090   * start_mfi_aen
4063 4091   */
4064 4092  static int
4065 4093  start_mfi_aen(struct mrsas_instance *instance)
↓ open down ↓ 32 lines elided ↑ open up ↑
4098 4126   * flush_cache
4099 4127   */
4100 4128  static void
4101 4129  flush_cache(struct mrsas_instance *instance)
4102 4130  {
4103 4131          struct mrsas_cmd                *cmd = NULL;
4104 4132          struct mrsas_dcmd_frame         *dcmd;
4105 4133          if (instance->tbolt) {
4106 4134                  cmd = get_raid_msg_mfi_pkt(instance);
4107 4135          } else {
4108      -                cmd = get_mfi_pkt(instance);
     4136 +                cmd = mrsas_get_mfi_pkt(instance);
4109 4137          }
4110 4138  
4111 4139          if (!cmd) {
4112 4140                  con_log(CL_ANN1, (CE_WARN,
4113 4141                      "flush_cache():Failed to get a cmd for flush_cache"));
4114 4142                  DTRACE_PROBE2(flush_cache_err, uint16_t,
4115 4143                      instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
4116 4144                  return;
4117 4145          }
4118 4146  
↓ open down ↓ 25 lines elided ↑ open up ↑
4144 4172          }
4145 4173  
4146 4174          if (instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) {
4147 4175                  con_log(CL_ANN1, (CE_WARN,
4148 4176              "flush_cache: failed to issue MFI_DCMD_CTRL_CACHE_FLUSH"));
4149 4177          }
4150 4178          con_log(CL_ANN1, (CE_CONT, "flush_cache done"));
4151 4179          if (instance->tbolt) {
4152 4180                  return_raid_msg_mfi_pkt(instance, cmd);
4153 4181          } else {
4154      -                return_mfi_pkt(instance, cmd);
     4182 +                mrsas_return_mfi_pkt(instance, cmd);
4155 4183          }
4156 4184  
4157 4185  }
4158 4186  
4159 4187  /*
4160 4188   * service_mfi_aen-     Completes an AEN command
4161 4189   * @instance:                   Adapter soft state
4162 4190   * @cmd:                        Command to be completed
4163 4191   *
4164 4192   */
↓ open down ↓ 79 lines elided ↑ open up ↑
4244 4272                      MRSAS_EVT_CONFIG_TGT, NULL);
4245 4273                  con_log(CL_ANN1, (CE_WARN, "mr_sas: LD CREATED AEN rval = %d "
4246 4274                      "tgt id = %d index = %d", rval,
4247 4275                      ddi_get16(acc_handle, &evt_detail->args.ld.target_id),
4248 4276                      ddi_get8(acc_handle, &evt_detail->args.ld.ld_index)));
4249 4277                  break;
4250 4278          } /* End of MR_EVT_LD_CREATED */
4251 4279  
4252 4280  #ifdef PDSUPPORT
4253 4281          case MR_EVT_PD_REMOVED_EXT: {
4254      -                if (instance->tbolt) {
     4282 +                if (instance->tbolt || instance->skinny) {
4255 4283                          pd_addr = &evt_detail->args.pd_addr;
4256 4284                          dtype = pd_addr->scsi_dev_type;
4257 4285                          con_log(CL_DLEVEL1, (CE_NOTE,
4258 4286                              " MR_EVT_PD_REMOVED_EXT: dtype = %x,"
4259 4287                              " arg_type = %d ", dtype, evt_detail->arg_type));
4260 4288                          tgt = ddi_get16(acc_handle,
4261 4289                              &evt_detail->args.pd.device_id);
4262 4290                          mutex_enter(&instance->config_dev_mtx);
4263 4291                          instance->mr_tbolt_pd_list[tgt].flag =
4264 4292                              (uint8_t)~MRDRV_TGT_VALID;
↓ open down ↓ 3 lines elided ↑ open up ↑
4268 4296                              1, MRSAS_EVT_UNCONFIG_TGT, NULL);
4269 4297                          con_log(CL_ANN1, (CE_WARN, "mr_sas: PD_REMOVED:"
4270 4298                              "rval = %d tgt id = %d ", rval,
4271 4299                              ddi_get16(acc_handle,
4272 4300                              &evt_detail->args.pd.device_id)));
4273 4301                  }
4274 4302                  break;
4275 4303          } /* End of MR_EVT_PD_REMOVED_EXT */
4276 4304  
4277 4305          case MR_EVT_PD_INSERTED_EXT: {
4278      -                if (instance->tbolt) {
     4306 +                if (instance->tbolt || instance->skinny) {
4279 4307                          rval = mrsas_service_evt(instance,
4280 4308                              ddi_get16(acc_handle,
4281 4309                              &evt_detail->args.pd.device_id),
4282 4310                              1, MRSAS_EVT_CONFIG_TGT, NULL);
4283 4311                          con_log(CL_ANN1, (CE_WARN, "mr_sas: PD_INSERTEDi_EXT:"
4284 4312                              "rval = %d tgt id = %d ", rval,
4285 4313                              ddi_get16(acc_handle,
4286 4314                              &evt_detail->args.pd.device_id)));
4287 4315                  }
4288 4316                  break;
4289 4317          } /* End of MR_EVT_PD_INSERTED_EXT */
4290 4318  
4291 4319          case MR_EVT_PD_STATE_CHANGE: {
4292      -                if (instance->tbolt) {
     4320 +                if (instance->tbolt || instance->skinny) {
4293 4321                          tgt = ddi_get16(acc_handle,
4294 4322                              &evt_detail->args.pd.device_id);
4295 4323                          if ((evt_detail->args.pd_state.prevState ==
4296 4324                              PD_SYSTEM) &&
4297 4325                              (evt_detail->args.pd_state.newState != PD_SYSTEM)) {
4298 4326                                  mutex_enter(&instance->config_dev_mtx);
4299 4327                                  instance->mr_tbolt_pd_list[tgt].flag =
4300 4328                                      (uint8_t)~MRDRV_TGT_VALID;
4301 4329                                  mutex_exit(&instance->config_dev_mtx);
4302 4330                                  rval = mrsas_service_evt(instance,
↓ open down ↓ 215 lines elided ↑ open up ↑
4518 4546                              acmd->cmd_dmacount);
4519 4547  
4520 4548                          if (pkt->pkt_cdbp[0] == SCMD_INQUIRY) {
4521 4549                                  struct scsi_inquiry     *inq;
4522 4550  
4523 4551                                  if (acmd->cmd_dmacount != 0) {
4524 4552                                          bp_mapin(acmd->cmd_buf);
4525 4553                                          inq = (struct scsi_inquiry *)
4526 4554                                              acmd->cmd_buf->b_un.b_addr;
4527 4555  
     4556 +#ifdef PDSUPPORT
     4557 +                                        if (hdr->cmd_status == MFI_STAT_OK) {
     4558 +                                                display_scsi_inquiry(
     4559 +                                                    (caddr_t)inq);
     4560 +                                        }
     4561 +#else
4528 4562                                          /* don't expose physical drives to OS */
4529 4563                                          if (acmd->islogical &&
4530 4564                                              (hdr->cmd_status == MFI_STAT_OK)) {
4531 4565                                                  display_scsi_inquiry(
4532 4566                                                      (caddr_t)inq);
4533 4567                                          } else if ((hdr->cmd_status ==
4534 4568                                              MFI_STAT_OK) && inq->inq_dtype ==
4535 4569                                              DTYPE_DIRECT) {
4536 4570  
4537 4571                                                  display_scsi_inquiry(
4538 4572                                                      (caddr_t)inq);
4539 4573  
4540 4574                                                  /* for physical disk */
4541 4575                                                  hdr->cmd_status =
4542 4576                                                      MFI_STAT_DEVICE_NOT_FOUND;
4543 4577                                          }
     4578 +#endif /* PDSUPPORT */
4544 4579                                  }
4545 4580                          }
4546 4581  
4547 4582                          DTRACE_PROBE2(softintr_done, uint8_t, hdr->cmd,
4548 4583                              uint8_t, hdr->cmd_status);
4549 4584  
4550 4585                          switch (hdr->cmd_status) {
4551 4586                          case MFI_STAT_OK:
4552 4587                                  pkt->pkt_scbp[0] = STATUS_GOOD;
4553 4588                                  break;
↓ open down ↓ 88 lines elided ↑ open up ↑
4642 4677                          if (acmd->cmd_dmahandle) {
4643 4678                                  if (mrsas_check_dma_handle(
4644 4679                                      acmd->cmd_dmahandle) != DDI_SUCCESS) {
4645 4680                                          ddi_fm_service_impact(instance->dip,
4646 4681                                              DDI_SERVICE_UNAFFECTED);
4647 4682                                          pkt->pkt_reason = CMD_TRAN_ERR;
4648 4683                                          pkt->pkt_statistics = 0;
4649 4684                                  }
4650 4685                          }
4651 4686  
     4687 +                        mrsas_return_mfi_pkt(instance, cmd);
     4688 +
4652 4689                          /* Call the callback routine */
4653 4690                          if (((pkt->pkt_flags & FLAG_NOINTR) == 0) &&
4654 4691                              pkt->pkt_comp) {
4655      -
4656      -                                con_log(CL_DLEVEL1, (CE_NOTE, "mrsas_softintr: "
4657      -                                    "posting to scsa cmd %p index %x pkt %p "
4658      -                                    "time %llx", (void *)cmd, cmd->index,
4659      -                                    (void *)pkt, gethrtime()));
4660 4692                                  (*pkt->pkt_comp)(pkt);
4661      -
4662 4693                          }
4663 4694  
4664      -                        return_mfi_pkt(instance, cmd);
4665 4695                          break;
4666 4696  
4667 4697                  case MFI_CMD_OP_SMP:
4668 4698                  case MFI_CMD_OP_STP:
4669 4699                          complete_cmd_in_sync_mode(instance, cmd);
4670 4700                          break;
4671 4701  
4672 4702                  case MFI_CMD_OP_DCMD:
4673 4703                          /* see if got an event notification */
4674 4704                          if (ddi_get32(cmd->frame_dma_obj.acc_handle,
↓ open down ↓ 406 lines elided ↑ open up ↑
5081 5111          struct scsa_cmd                 *acmd = PKT2CMD(pkt);
5082 5112          struct mrsas_pthru_frame        *pthru;
5083 5113          struct mrsas_io_frame           *ldio;
5084 5114  
5085 5115          /* find out if this is logical or physical drive command.  */
5086 5116          acmd->islogical = MRDRV_IS_LOGICAL(ap);
5087 5117          acmd->device_id = MAP_DEVICE_ID(instance, ap);
5088 5118          *cmd_done = 0;
5089 5119  
5090 5120          /* get the command packet */
5091      -        if (!(cmd = get_mfi_pkt(instance))) {
     5121 +        if (!(cmd = mrsas_get_mfi_pkt(instance))) {
5092 5122                  DTRACE_PROBE2(build_cmd_mfi_err, uint16_t,
5093 5123                      instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
5094 5124                  return (NULL);
5095 5125          }
5096 5126  
5097 5127          acc_handle = cmd->frame_dma_obj.acc_handle;
5098 5128  
5099 5129          /* Clear the frame buffer and assign back the context id */
5100 5130          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
5101 5131          ddi_put32(acc_handle, &cmd->frame->hdr.context, cmd->index);
↓ open down ↓ 27 lines elided ↑ open up ↑
5129 5159          if (instance->flag_ieee) {
5130 5160                  flags |= MFI_FRAME_IEEE;
5131 5161          }
5132 5162          flags |= MFI_FRAME_SGL64;
5133 5163  
5134 5164          switch (pkt->pkt_cdbp[0]) {
5135 5165  
5136 5166          /*
5137 5167           * case SCMD_SYNCHRONIZE_CACHE:
5138 5168           *      flush_cache(instance);
5139      -         *      return_mfi_pkt(instance, cmd);
     5169 +         *      mrsas_return_mfi_pkt(instance, cmd);
5140 5170           *      *cmd_done = 1;
5141 5171           *
5142 5172           *      return (NULL);
5143 5173           */
5144 5174  
5145 5175          case SCMD_READ:
5146 5176          case SCMD_WRITE:
5147 5177          case SCMD_READ_G1:
5148 5178          case SCMD_WRITE_G1:
5149 5179          case SCMD_READ_G4:
↓ open down ↓ 88 lines elided ↑ open up ↑
5238 5268  
5239 5269                                  ddi_put32(acc_handle, &ldio->start_lba_hi, (
5240 5270                                      ((uint32_t)(pkt->pkt_cdbp[5])) |
5241 5271                                      ((uint32_t)(pkt->pkt_cdbp[4]) << 8) |
5242 5272                                      ((uint32_t)(pkt->pkt_cdbp[3]) << 16) |
5243 5273                                      ((uint32_t)(pkt->pkt_cdbp[2]) << 24)));
5244 5274                          }
5245 5275  
5246 5276                          break;
5247 5277                  }
5248      -                /* fall through For all non-rd/wr cmds */
     5278 +                /* fall through For all non-rd/wr and physical disk cmds */
5249 5279          default:
5250 5280  
5251 5281                  switch (pkt->pkt_cdbp[0]) {
5252 5282                  case SCMD_MODE_SENSE:
5253 5283                  case SCMD_MODE_SENSE_G1: {
5254 5284                          union scsi_cdb  *cdbp;
5255 5285                          uint16_t        page_code;
5256 5286  
5257 5287                          cdbp = (void *)pkt->pkt_cdbp;
5258 5288                          page_code = (uint16_t)cdbp->cdb_un.sg.scsi[0];
5259 5289                          switch (page_code) {
5260 5290                          case 0x3:
5261 5291                          case 0x4:
5262 5292                                  (void) mrsas_mode_sense_build(pkt);
5263      -                                return_mfi_pkt(instance, cmd);
     5293 +                                mrsas_return_mfi_pkt(instance, cmd);
5264 5294                                  *cmd_done = 1;
5265 5295                                  return (NULL);
5266 5296                          }
5267 5297                          break;
5268 5298                  }
5269 5299                  default:
5270 5300                          break;
5271 5301                  }
5272 5302  
5273 5303                  pthru   = (struct mrsas_pthru_frame *)cmd->frame;
↓ open down ↓ 1013 lines elided ↑ open up ↑
6287 6317      int mode)
6288 6318  {
6289 6319          int     rval = DDI_SUCCESS;
6290 6320  
6291 6321          struct mrsas_header     *hdr;
6292 6322          struct mrsas_cmd        *cmd;
6293 6323  
6294 6324          if (instance->tbolt) {
6295 6325                  cmd = get_raid_msg_mfi_pkt(instance);
6296 6326          } else {
6297      -                cmd = get_mfi_pkt(instance);
     6327 +                cmd = mrsas_get_mfi_pkt(instance);
6298 6328          }
6299 6329          if (!cmd) {
6300 6330                  con_log(CL_ANN, (CE_WARN, "mr_sas: "
6301 6331                      "failed to get a cmd packet"));
6302 6332                  DTRACE_PROBE2(mfi_ioctl_err, uint16_t,
6303 6333                      instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
6304 6334                  return (DDI_FAILURE);
6305 6335          }
6306 6336  
6307 6337          /* Clear the frame buffer and assign back the context id */
↓ open down ↓ 23 lines elided ↑ open up ↑
6331 6361                  rval = DDI_FAILURE;
6332 6362                  break;
6333 6363          }
6334 6364  
6335 6365          if (mrsas_common_check(instance, cmd) != DDI_SUCCESS)
6336 6366                  rval = DDI_FAILURE;
6337 6367  
6338 6368          if (instance->tbolt) {
6339 6369                  return_raid_msg_mfi_pkt(instance, cmd);
6340 6370          } else {
6341      -                return_mfi_pkt(instance, cmd);
     6371 +                mrsas_return_mfi_pkt(instance, cmd);
6342 6372          }
6343 6373  
6344 6374          return (rval);
6345 6375  }
6346 6376  
6347 6377  /*
6348 6378   * AEN
6349 6379   */
6350 6380  static int
6351 6381  handle_mfi_aen(struct mrsas_instance *instance, struct mrsas_aen *aen)
↓ open down ↓ 76 lines elided ↑ open up ↑
6428 6458                          }
6429 6459                  }
6430 6460          } else {
6431 6461                  curr_aen.word = LE_32(class_locale_word);
6432 6462                  curr_aen.members.locale = LE_16(curr_aen.members.locale);
6433 6463          }
6434 6464  
6435 6465          if (instance->tbolt) {
6436 6466                  cmd = get_raid_msg_mfi_pkt(instance);
6437 6467          } else {
6438      -                cmd = get_mfi_pkt(instance);
     6468 +                cmd = mrsas_get_mfi_pkt(instance);
6439 6469          }
6440 6470  
6441 6471          if (!cmd) {
6442 6472                  DTRACE_PROBE2(mfi_aen_err, uint16_t, instance->fw_outstanding,
6443 6473                      uint16_t, instance->max_fw_cmds);
6444 6474                  return (ENOMEM);
6445 6475          }
6446 6476  
6447 6477          /* Clear the frame buffer and assign back the context id */
6448 6478          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
↓ open down ↓ 272 lines elided ↑ open up ↑
6721 6751                  }
6722 6752  
6723 6753          } else {
6724 6754                  con_log(CL_DLEVEL1, (CE_NOTE, "%llx : issue_cmd_ppc:"
6725 6755                      "ISSUED CMD TO FW : called : cmd : %p, instance: %p"
6726 6756                      "(NO PKT)\n", gethrtime(), (void *)cmd, (void *)instance));
6727 6757          }
6728 6758  
6729 6759          mutex_enter(&instance->reg_write_mtx);
6730 6760          /* Issue the command to the FW */
6731      -        WR_IB_QPORT((cmd->frame_phys_addr) |
     6761 +        WR_IB_PICK_QPORT((cmd->frame_phys_addr) |
6732 6762              (((cmd->frame_count - 1) << 1) | 1), instance);
6733 6763          mutex_exit(&instance->reg_write_mtx);
6734 6764  
6735 6765  }
6736 6766  
6737 6767  /*
6738 6768   * issue_cmd_in_sync_mode
6739 6769   */
6740 6770  static int
6741 6771  issue_cmd_in_sync_mode_ppc(struct mrsas_instance *instance,
6742      -struct mrsas_cmd *cmd)
     6772 +    struct mrsas_cmd *cmd)
6743 6773  {
6744 6774          int     i;
6745      -        uint32_t        msecs = MFI_POLL_TIMEOUT_SECS * (10 * MILLISEC);
     6775 +        uint32_t        msecs = MFI_POLL_TIMEOUT_SECS * MILLISEC;
6746 6776          struct mrsas_header *hdr = &cmd->frame->hdr;
6747 6777  
6748 6778          con_log(CL_ANN1, (CE_NOTE, "issue_cmd_in_sync_mode_ppc: called"));
6749 6779  
6750 6780          if (instance->adapterresetinprogress) {
6751 6781                  cmd->drv_pkt_time = ddi_get16(
6752 6782                      cmd->frame_dma_obj.acc_handle, &hdr->timeout);
6753 6783                  if (cmd->drv_pkt_time < debug_timeout_g)
6754 6784                          cmd->drv_pkt_time = (uint16_t)debug_timeout_g;
6755 6785  
6756 6786                  con_log(CL_ANN1, (CE_NOTE, "sync_mode_ppc: "
6757 6787                      "issue and return in reset case\n"));
6758      -                WR_IB_QPORT((cmd->frame_phys_addr) |
     6788 +                WR_IB_PICK_QPORT((cmd->frame_phys_addr) |
6759 6789                      (((cmd->frame_count - 1) << 1) | 1), instance);
6760 6790  
6761 6791                  return (DDI_SUCCESS);
6762 6792          } else {
6763 6793                  con_log(CL_ANN1, (CE_NOTE, "sync_mode_ppc: pushing the pkt\n"));
6764 6794                  push_pending_mfi_pkt(instance, cmd);
6765 6795          }
6766 6796  
6767 6797          cmd->cmd_status = ENODATA;
6768 6798  
6769 6799          mutex_enter(&instance->reg_write_mtx);
6770 6800          /* Issue the command to the FW */
6771      -        WR_IB_QPORT((cmd->frame_phys_addr) |
     6801 +        WR_IB_PICK_QPORT((cmd->frame_phys_addr) |
6772 6802              (((cmd->frame_count - 1) << 1) | 1), instance);
6773 6803          mutex_exit(&instance->reg_write_mtx);
6774 6804  
6775 6805          mutex_enter(&instance->int_cmd_mtx);
6776 6806          for (i = 0; i < msecs && (cmd->cmd_status == ENODATA); i++) {
6777 6807                  cv_wait(&instance->int_cmd_cv, &instance->int_cmd_mtx);
6778 6808          }
6779 6809          mutex_exit(&instance->int_cmd_mtx);
6780 6810  
6781 6811          con_log(CL_ANN1, (CE_NOTE, "issue_cmd_in_sync_mode_ppc: done"));
↓ open down ↓ 21 lines elided ↑ open up ↑
6803 6833  
6804 6834          frame_hdr = (struct mrsas_header *)cmd->frame;
6805 6835          ddi_put8(cmd->frame_dma_obj.acc_handle, &frame_hdr->cmd_status,
6806 6836              MFI_CMD_STATUS_POLL_MODE);
6807 6837          flags = ddi_get16(cmd->frame_dma_obj.acc_handle, &frame_hdr->flags);
6808 6838          flags   |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
6809 6839  
6810 6840          ddi_put16(cmd->frame_dma_obj.acc_handle, &frame_hdr->flags, flags);
6811 6841  
6812 6842          /* issue the frame using inbound queue port */
6813      -        WR_IB_QPORT((cmd->frame_phys_addr) |
     6843 +        WR_IB_PICK_QPORT((cmd->frame_phys_addr) |
6814 6844              (((cmd->frame_count - 1) << 1) | 1), instance);
6815 6845  
6816 6846          /* wait for cmd_status to change from 0xFF */
6817 6847          for (i = 0; i < msecs && (
6818 6848              ddi_get8(cmd->frame_dma_obj.acc_handle, &frame_hdr->cmd_status)
6819 6849              == MFI_CMD_STATUS_POLL_MODE); i++) {
6820 6850                  drv_usecwait(MILLISEC); /* wait for 1000 usecs */
6821 6851          }
6822 6852  
6823 6853          if (ddi_get8(cmd->frame_dma_obj.acc_handle, &frame_hdr->cmd_status)
↓ open down ↓ 6 lines elided ↑ open up ↑
6830 6860          return (DDI_SUCCESS);
6831 6861  }
6832 6862  
6833 6863  static void
6834 6864  enable_intr_ppc(struct mrsas_instance *instance)
6835 6865  {
6836 6866          uint32_t        mask;
6837 6867  
6838 6868          con_log(CL_ANN1, (CE_NOTE, "enable_intr_ppc: called"));
6839 6869  
6840      -        /* WR_OB_DOORBELL_CLEAR(0xFFFFFFFF, instance); */
6841      -        WR_OB_DOORBELL_CLEAR(OB_DOORBELL_CLEAR_MASK, instance);
     6870 +        if (instance->skinny) {
     6871 +                /* For SKINNY, write ~0x1, from BSD's mfi driver. */
     6872 +                WR_OB_INTR_MASK(0xfffffffe, instance);
     6873 +        } else {
     6874 +                /* WR_OB_DOORBELL_CLEAR(0xFFFFFFFF, instance); */
     6875 +                WR_OB_DOORBELL_CLEAR(OB_DOORBELL_CLEAR_MASK, instance);
6842 6876  
6843      -        /* WR_OB_INTR_MASK(~0x80000000, instance); */
6844      -        WR_OB_INTR_MASK(~(MFI_REPLY_2108_MESSAGE_INTR_MASK), instance);
     6877 +                /* WR_OB_INTR_MASK(~0x80000000, instance); */
     6878 +                WR_OB_INTR_MASK(~(MFI_REPLY_2108_MESSAGE_INTR_MASK), instance);
     6879 +        }
6845 6880  
6846 6881          /* dummy read to force PCI flush */
6847 6882          mask = RD_OB_INTR_MASK(instance);
6848 6883  
6849 6884          con_log(CL_ANN1, (CE_NOTE, "enable_intr_ppc: "
6850 6885              "outbound_intr_mask = 0x%x", mask));
6851 6886  }
6852 6887  
6853 6888  static void
6854 6889  disable_intr_ppc(struct mrsas_instance *instance)
6855 6890  {
6856 6891          uint32_t        mask;
6857 6892  
6858 6893          con_log(CL_ANN1, (CE_NOTE, "disable_intr_ppc: called"));
6859 6894  
6860 6895          con_log(CL_ANN1, (CE_NOTE, "disable_intr_ppc: before : "
6861 6896              "outbound_intr_mask = 0x%x", RD_OB_INTR_MASK(instance)));
6862 6897  
6863      -        /* WR_OB_INTR_MASK(0xFFFFFFFF, instance); */
     6898 +        /* For now, assume there are no extras needed for Skinny support. */
     6899 +
6864 6900          WR_OB_INTR_MASK(OB_INTR_MASK, instance);
6865 6901  
6866 6902          con_log(CL_ANN1, (CE_NOTE, "disable_intr_ppc: after : "
6867 6903              "outbound_intr_mask = 0x%x", RD_OB_INTR_MASK(instance)));
6868 6904  
6869 6905          /* dummy read to force PCI flush */
6870 6906          mask = RD_OB_INTR_MASK(instance);
6871 6907  #ifdef lint
6872 6908          mask = mask;
6873 6909  #endif
↓ open down ↓ 5 lines elided ↑ open up ↑
6879 6915          uint32_t        status;
6880 6916          int ret = DDI_INTR_CLAIMED;
6881 6917  
6882 6918          con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: called"));
6883 6919  
6884 6920          /* check if it is our interrupt */
6885 6921          status = RD_OB_INTR_STATUS(instance);
6886 6922  
6887 6923          con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: status = 0x%x", status));
6888 6924  
     6925 +        /*
     6926 +         * NOTE:  Some drivers call out SKINNY here, but the return is the same
     6927 +         * for SKINNY and 2108.
     6928 +         */
6889 6929          if (!(status & MFI_REPLY_2108_MESSAGE_INTR)) {
6890 6930                  ret = DDI_INTR_UNCLAIMED;
6891 6931          }
6892 6932  
6893 6933          if (mrsas_check_acc_handle(instance->regmap_handle) != DDI_SUCCESS) {
6894 6934                  ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
6895 6935                  ret = DDI_INTR_UNCLAIMED;
6896 6936          }
6897 6937  
6898 6938          if (ret == DDI_INTR_UNCLAIMED) {
6899 6939                  return (ret);
6900 6940          }
6901      -        /* clear the interrupt by writing back the same value */
6902      -        WR_OB_DOORBELL_CLEAR(status, instance);
6903 6941  
     6942 +        /*
     6943 +         * Clear the interrupt by writing back the same value.
     6944 +         * Another case where SKINNY is slightly different.
     6945 +         */
     6946 +        if (instance->skinny) {
     6947 +                WR_OB_INTR_STATUS(status, instance);
     6948 +        } else {
     6949 +                WR_OB_DOORBELL_CLEAR(status, instance);
     6950 +        }
     6951 +
6904 6952          /* dummy READ */
6905 6953          status = RD_OB_INTR_STATUS(instance);
6906 6954  
6907 6955          con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: interrupt cleared"));
6908 6956  
6909 6957          return (ret);
6910 6958  }
6911 6959  
6912 6960  /*
6913 6961   * Marks HBA as bad. This will be called either when an
↓ open down ↓ 564 lines elided ↑ open up ↑
7478 7526                  ptr++;
7479 7527  
7480 7528                  if (mrsas_parse_devname(arg, &tgt, &lun) != 0) {
7481 7529                          rval = NDI_FAILURE;
7482 7530                          break;
7483 7531                  }
7484 7532  
7485 7533                  if (lun == 0) {
7486 7534                          rval = mrsas_config_ld(instance, tgt, lun, childp);
7487 7535  #ifdef PDSUPPORT
7488      -                } else if (instance->tbolt == 1 && lun != 0) {
     7536 +                } else if ((instance->tbolt || instance->skinny) && lun != 0) {
7489 7537                          rval = mrsas_tbolt_config_pd(instance,
7490 7538                              tgt, lun, childp);
7491 7539  #endif
7492 7540                  } else {
7493 7541                          rval = NDI_FAILURE;
7494 7542                  }
7495 7543  
7496 7544                  break;
7497 7545          }
7498 7546          case BUS_CONFIG_DRIVER:
↓ open down ↓ 22 lines elided ↑ open up ↑
7521 7569  {
7522 7570          int rval, tgt;
7523 7571  
7524 7572          for (tgt = 0; tgt < MRDRV_MAX_LD; tgt++) {
7525 7573                  (void) mrsas_config_ld(instance, tgt, 0, NULL);
7526 7574  
7527 7575          }
7528 7576  
7529 7577  #ifdef PDSUPPORT
7530 7578          /* Config PD devices connected to the card */
7531      -        if (instance->tbolt) {
     7579 +        if (instance->tbolt || instance->skinny) {
7532 7580                  for (tgt = 0; tgt < instance->mr_tbolt_pd_max; tgt++) {
7533 7581                          (void) mrsas_tbolt_config_pd(instance, tgt, 1, NULL);
7534 7582                  }
7535 7583          }
7536 7584  #endif
7537 7585  
7538 7586          rval = NDI_SUCCESS;
7539 7587          return (rval);
7540 7588  }
7541 7589  
↓ open down ↓ 233 lines elided ↑ open up ↑
7775 7823  
7776 7824          ndi_devi_enter(instance->dip, &circ1);
7777 7825          switch (mrevt->event) {
7778 7826          case MRSAS_EVT_CONFIG_TGT:
7779 7827                  if (dip == NULL) {
7780 7828  
7781 7829                          if (mrevt->lun == 0) {
7782 7830                                  (void) mrsas_config_ld(instance, mrevt->tgt,
7783 7831                                      0, NULL);
7784 7832  #ifdef PDSUPPORT
7785      -                        } else if (instance->tbolt) {
     7833 +                        } else if (instance->tbolt || instance->skinny) {
7786 7834                                  (void) mrsas_tbolt_config_pd(instance,
7787 7835                                      mrevt->tgt,
7788 7836                                      1, NULL);
7789 7837  #endif
7790 7838                          }
7791 7839                          con_log(CL_ANN1, (CE_NOTE,
7792 7840                              "mr_sas: EVT_CONFIG_TGT called:"
7793 7841                              " for tgt %d lun %d event %d",
7794 7842                              mrevt->tgt, mrevt->lun, mrevt->event));
7795 7843  
↓ open down ↓ 94 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX