Print this page
NEX-5717 import QLogic 16G FC drivers
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
        
*** 17,41 ****
   * information: Portions Copyright [yyyy] [name of copyright owner]
   *
   * CDDL HEADER END
   */
  
! /* Copyright 2010 QLogic Corporation */
  
  /*
   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
   */
  
! #pragma ident   "Copyright 2010 QLogic Corporation; ql_hba_fru.c"
  
  /*
   * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
   *
   * ***********************************************************************
   * *                                                                    **
   * *                            NOTICE                                  **
!  * *            COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION              **
   * *                    ALL RIGHTS RESERVED                             **
   * *                                                                    **
   * ***********************************************************************
   *
   */
--- 17,41 ----
   * information: Portions Copyright [yyyy] [name of copyright owner]
   *
   * CDDL HEADER END
   */
  
! /* Copyright 2015 QLogic Corporation */
  
  /*
   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
   */
  
! #pragma ident   "Copyright 2015 QLogic Corporation; ql_hba_fru.c"
  
  /*
   * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
   *
   * ***********************************************************************
   * *                                                                    **
   * *                            NOTICE                                  **
!  * *            COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION              **
   * *                    ALL RIGHTS RESERVED                             **
   * *                                                                    **
   * ***********************************************************************
   *
   */
*** 237,247 ****
          uint16_t                model = ha->subsys_id;
          uint16_t                ssdevid = ha->subven_id;
          size_t                  vlen;
          int32_t                 i;
  
!         QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
  
          attrs = &port_info->pi_attrs;
  
          /* Constants */
          (void) snprintf(attrs->manufacturer, FCHBA_MANUFACTURER_LEN,
--- 237,247 ----
          uint16_t                model = ha->subsys_id;
          uint16_t                ssdevid = ha->subven_id;
          size_t                  vlen;
          int32_t                 i;
  
!         QL_PRINT_3(ha, "started\n");
  
          attrs = &port_info->pi_attrs;
  
          /* Constants */
          (void) snprintf(attrs->manufacturer, FCHBA_MANUFACTURER_LEN,
*** 260,271 ****
          /* Dynamic data */
          (void) snprintf(attrs->firmware_version, FCHBA_FIRMWARE_VERSION_LEN,
              "%02d.%02d.%02d", ha->fw_major_version, ha->fw_minor_version,
              ha->fw_subminor_version);
  
-         CACHE_LOCK(ha);
- 
          /* Report FCode / BIOS / EFI version(s). */
          if (ha->fcache != NULL) {
                  uint32_t        types = FTYPE_BIOS|FTYPE_FCODE|FTYPE_EFI;
                  ql_fcache_t     *fptr = ha->fcache;
                  int8_t          *orv = &*attrs->option_rom_version;
--- 260,269 ----
*** 298,315 ****
                                  types &= ~(fptr->type);
                          }
                  }
          }
  
-         CACHE_UNLOCK(ha);
- 
          if (strlen(attrs->option_rom_version) == 0) {
                  int             rval = -1;
                  uint32_t        i = 0;
                  caddr_t         fcode_ver_buf = NULL;
  
!                 if (CFG_IST(ha, CFG_CTRL_2200)) {
                          /*LINTED [Solaris DDI_DEV_T_ANY Lint warning]*/
                          rval = ddi_getlongprop(DDI_DEV_T_ANY, ha->dip,
                              DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, "version",
                              (caddr_t)&fcode_ver_buf, (int32_t *)&i);
                  }
--- 296,311 ----
                                  types &= ~(fptr->type);
                          }
                  }
          }
  
          if (strlen(attrs->option_rom_version) == 0) {
                  int             rval = -1;
                  uint32_t        i = 0;
                  caddr_t         fcode_ver_buf = NULL;
  
!                 if (CFG_IST(ha, CFG_CTRL_22XX)) {
                          /*LINTED [Solaris DDI_DEV_T_ANY Lint warning]*/
                          rval = ddi_getlongprop(DDI_DEV_T_ANY, ha->dip,
                              DDI_PROP_DONTPASS | DDI_PROP_CANSLEEP, "version",
                              (caddr_t)&fcode_ver_buf, (int32_t *)&i);
                  }
*** 324,343 ****
                  }
  
          }
  
          attrs->vendor_specific_id = ha->adapter_features;
!         attrs->max_frame_size = CFG_IST(ha, CFG_CTRL_24258081) ?
!             (ha->init_ctrl_blk.cb24.max_frame_length[1] << 8 |
!             ha->init_ctrl_blk.cb24.max_frame_length[0]) :
!             (ha->init_ctrl_blk.cb.max_frame_length[1] << 8 |
!             ha->init_ctrl_blk.cb.max_frame_length[0]);
          attrs->supported_cos = 0x10000000; /* Class 3 only */
  
          switch (chip & 0xFF00) {
          case 0x2200:
!                 attrs->supported_speed = FC_HBA_PORTSPEED_1GBIT;
                  break;
          case 0x2300:
                  attrs->supported_speed = FC_HBA_PORTSPEED_2GBIT |
                      FC_HBA_PORTSPEED_1GBIT;
                  break;
--- 320,340 ----
                  }
  
          }
  
          attrs->vendor_specific_id = ha->adapter_features;
!         attrs->max_frame_size = ha->loginparams.common_service.rx_bufsize;
          attrs->supported_cos = 0x10000000; /* Class 3 only */
  
          switch (chip & 0xFF00) {
+         case 0x2000:
+                 attrs->supported_speed = chip == 0x2071 ?
+                     FC_HBA_PORTSPEED_32GBIT : FC_HBA_PORTSPEED_16GBIT;
+                 break;
          case 0x2200:
!                 attrs->supported_speed = chip == 0x2261 ?
!                     FC_HBA_PORTSPEED_16GBIT : FC_HBA_PORTSPEED_1GBIT;
                  break;
          case 0x2300:
                  attrs->supported_speed = FC_HBA_PORTSPEED_2GBIT |
                      FC_HBA_PORTSPEED_1GBIT;
                  break;
*** 486,496 ****
          vlen = (strlen(QL_NAME) + 9 > FCHBA_SYMB_NAME_LEN ?
              FCHBA_SYMB_NAME_LEN : strlen(QL_NAME) + 9);
          (void) snprintf((int8_t *)attrs->sym_port_name, vlen,
              "%s(%d,%d)", QL_NAME, ha->instance, ha->vp_index);
  
!         QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
  }
  
  /*
   * ql_setup_fruinfo
   *      Generates common id's for instances on the same
--- 483,493 ----
          vlen = (strlen(QL_NAME) + 9 > FCHBA_SYMB_NAME_LEN ?
              FCHBA_SYMB_NAME_LEN : strlen(QL_NAME) + 9);
          (void) snprintf((int8_t *)attrs->sym_port_name, vlen,
              "%s(%d,%d)", QL_NAME, ha->instance, ha->vp_index);
  
!         QL_PRINT_3(ha, "done\n");
  }
  
  /*
   * ql_setup_fruinfo
   *      Generates common id's for instances on the same
*** 508,518 ****
  ql_setup_fruinfo(ql_adapter_state_t *ha)
  {
          uint32_t                mybasedev_len;
          ql_adapter_state_t      *base_ha = NULL;
  
!         QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
  
          /*
           * To generate common id for instances residing on the
           * the same HBA, the devpath for each instance is parsed
           * and those instances which have matching base devpaths are
--- 505,515 ----
  ql_setup_fruinfo(ql_adapter_state_t *ha)
  {
          uint32_t                mybasedev_len;
          ql_adapter_state_t      *base_ha = NULL;
  
!         QL_PRINT_3(ha, "started\n");
  
          /*
           * To generate common id for instances residing on the
           * the same HBA, the devpath for each instance is parsed
           * and those instances which have matching base devpaths are
*** 523,534 ****
          /*
           * Get this ha's basedev path and its port index
           */
          if (ql_get_basedev_len(ha, &mybasedev_len, &ha->fru_port_index) == 0) {
  
-                 GLOBAL_STATE_LOCK();
- 
                  /*
                   * Search for this basedev against all of the
                   * ha in the ql_hba global list. If found one
                   * then we are part of other adapter in the
                   * ql_hba list and hence use that ha's hba_index.
--- 520,529 ----
*** 535,565 ****
                   * If not create a new one from the global hba index.
                   */
                  base_ha = ql_search_basedev(ha, mybasedev_len);
                  if (base_ha != NULL && base_ha->fru_hba_index != 0) {
                          ha->fru_hba_index = base_ha->fru_hba_index;
                  } else {
                          ha->fru_hba_index = ql_gfru_hba_index++;
                  }
- 
-                 if (CFG_IST(ha, CFG_CTRL_8081)) {
-                         /*
-                          * The FC functions on 81xx hbas are functions 2 and 3
-                          * while the Nic functions occupy 0 and 1.  Adjust
-                          * fru port index to be like previous FCAs.
-                          */
-                         ha->fru_port_index = ha->flags & FUNCTION_1 ? 1 : 0;
-                 }
- 
-                 GLOBAL_STATE_UNLOCK();
- 
          } else {
                  ha->fru_hba_index = 0;
                  ha->fru_port_index = 0;
          }
  
!         QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
  }
  
  /*
   *  ql_get_basedev_len
   *
--- 530,550 ----
                   * If not create a new one from the global hba index.
                   */
                  base_ha = ql_search_basedev(ha, mybasedev_len);
                  if (base_ha != NULL && base_ha->fru_hba_index != 0) {
                          ha->fru_hba_index = base_ha->fru_hba_index;
+                         ha->fru_port_index = base_ha->fru_port_index + 1;
                  } else {
                          ha->fru_hba_index = ql_gfru_hba_index++;
+                         ha->fru_port_index = 0;
                  }
          } else {
                  ha->fru_hba_index = 0;
                  ha->fru_port_index = 0;
          }
  
!         QL_PRINT_3(ha, "done\n");
  }
  
  /*
   *  ql_get_basedev_len
   *
*** 585,595 ****
  {
          int32_t         dev_off;
          int32_t         port_off;
          int8_t          *devstr;
  
!         QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
  
          if (ha->devpath == NULL) {
                  return ((uint32_t)-1);
          }
  
--- 570,580 ----
  {
          int32_t         dev_off;
          int32_t         port_off;
          int8_t          *devstr;
  
!         QL_PRINT_3(ha, "started\n");
  
          if (ha->devpath == NULL) {
                  return ((uint32_t)-1);
          }
  
*** 626,636 ****
                  }
  
                  *basedev_len = (uint32_t)(port_off - 1);
          }
  
!         QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
  
          return (0);
  }
  
  /*
--- 611,621 ----
                  }
  
                  *basedev_len = (uint32_t)(port_off - 1);
          }
  
!         QL_PRINT_3(ha, "done\n");
  
          return (0);
  }
  
  /*
*** 655,665 ****
  {
          ql_link_t               *link;
          ql_adapter_state_t      *ha;
          uint32_t                basedev_len, port_index;
  
!         QL_PRINT_3(CE_CONT, "(%d): started\n", myha->instance);
  
          for (link = ql_hba.first; link != NULL; link = link->next) {
  
                  ha = link->base_address;
  
--- 640,650 ----
  {
          ql_link_t               *link;
          ql_adapter_state_t      *ha;
          uint32_t                basedev_len, port_index;
  
!         QL_PRINT_3(myha, "started\n", myha->instance);
  
          for (link = ql_hba.first; link != NULL; link = link->next) {
  
                  ha = link->base_address;
  
*** 691,705 ****
                   */
                  if ((basedev_len == mybasedev_len) && (strncmp(myha->devpath,
                      ha->devpath, basedev_len) == 0)) {
  
                          /* We found the ha with same basedev */
!                         QL_PRINT_3(CE_CONT, "(%d): found, done\n",
                              myha->instance);
                          return (ha);
                  }
          }
  
!         QL_PRINT_3(CE_CONT, "(%d): not found, done\n", myha->instance);
  
          return (NULL);
  }
--- 676,690 ----
                   */
                  if ((basedev_len == mybasedev_len) && (strncmp(myha->devpath,
                      ha->devpath, basedev_len) == 0)) {
  
                          /* We found the ha with same basedev */
!                         QL_PRINT_3(myha, "found, done\n",
                              myha->instance);
                          return (ha);
                  }
          }
  
!         QL_PRINT_3(myha, "not found, done\n", myha->instance);
  
          return (NULL);
  }