Print this page
NEX-8705 Drivers for ATTO Celerity FC-162E Gen 5 and Celerity FC-162P Gen 6 16GB FC cards support
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
NEX-4963 `fcadm force-lip wwn`: Failed to reinitialize the link of Emulex HBA
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Steve Peng <steve.peng@nexenta.com>
NEX-1878 update emlxs from source provided by Emulex


   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
   9  * http://www.opensource.org/licenses/cddl1.txt.
  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 (c) 2004-2012 Emulex. All rights reserved.
  24  * Use is subject to license terms.

  25  */
  26 
  27 #include <emlxs.h>
  28 
  29 #ifdef SFCT_SUPPORT
  30 
  31 
  32 /* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
  33 EMLXS_MSG_DEF(EMLXS_FCT_C);
  34 
  35 static void emlxs_fct_memseg_init(emlxs_hba_t *hba);
  36 
  37 static fct_status_t emlxs_fct_cmd_acquire(emlxs_port_t *port,
  38         fct_cmd_t *fct_cmd, uint16_t fct_state);
  39 static fct_status_t emlxs_fct_cmd_accept(emlxs_port_t *port,
  40         fct_cmd_t *fct_cmd, uint16_t fct_state);
  41 static void emlxs_fct_cmd_release(emlxs_port_t *port, fct_cmd_t *fct_cmd,
  42         uint16_t fct_state);
  43 
  44 static emlxs_buf_t *emlxs_fct_cmd_init(emlxs_port_t *port,


1354 
1355                 rval = FCT_FAILURE;
1356                 break;
1357 
1358         }
1359 
1360         return (rval);
1361 
1362 } /* emlxs_fct_port_info() */
1363 
1364 
1365 /* COMSTAR ENTER POINT */
1366 static void
1367 emlxs_fct_populate_hba_details(fct_local_port_t *fct_port,
1368     fct_port_attrs_t *port_attrs)
1369 {
1370         emlxs_port_t *port = (emlxs_port_t *)fct_port->port_fca_private;
1371         emlxs_hba_t *hba = HBA;
1372         emlxs_vpd_t *vpd = &VPD;
1373 
1374         (void) strncpy(port_attrs->manufacturer, "Emulex",

1375             (sizeof (port_attrs->manufacturer)-1));
1376         (void) strncpy(port_attrs->serial_number, vpd->serial_num,
1377             (sizeof (port_attrs->serial_number)-1));
1378         (void) strncpy(port_attrs->model, hba->model_info.model,
1379             (sizeof (port_attrs->model)-1));
1380         (void) strncpy(port_attrs->model_description,
1381             hba->model_info.model_desc,
1382             (sizeof (port_attrs->model_description)-1));
1383         (void) snprintf(port_attrs->hardware_version,
1384             (sizeof (port_attrs->hardware_version)-1),
1385             "%x", vpd->biuRev);
1386         (void) snprintf(port_attrs->driver_version,
1387             (sizeof (port_attrs->driver_version)-1),
1388             "%s (%s)", emlxs_version,
1389             emlxs_revision);
1390         (void) strncpy(port_attrs->option_rom_version, vpd->fcode_version,
1391             (sizeof (port_attrs->option_rom_version)-1));
1392         (void) snprintf(port_attrs->firmware_version,
1393             (sizeof (port_attrs->firmware_version)-1),
1394             "%s (%s)", vpd->fw_version,


1451         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1452             "Port attr: supported_speed    = 0x%x",
1453             port_attrs->supported_speed);
1454         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1455             "Port attr: max_frame_size     = 0x%x",
1456             port_attrs->max_frame_size);
1457 
1458         return;
1459 
1460 } /* emlxs_fct_populate_hba_details() */
1461 
1462 
1463 /* COMSTAR ENTER POINT */
1464 /* ARGSUSED */
1465 static void
1466 emlxs_fct_ctl(fct_local_port_t *fct_port, int cmd, void *arg)
1467 {
1468         emlxs_port_t *port = (emlxs_port_t *)fct_port->port_fca_private;
1469         emlxs_hba_t *hba = HBA;
1470         stmf_change_status_t st;

1471 
1472         st.st_completion_status = FCT_SUCCESS;
1473         st.st_additional_info = NULL;
1474 
1475         switch (cmd) {
1476         case FCT_CMD_PORT_ONLINE:
1477                 /* If the HBA is offline, we cannot bring the tgtport online */
1478                 if (hba->flag & (FC_OFFLINE_MODE | FC_OFFLINING_MODE)) {
1479                         st.st_completion_status = FCT_FAILURE;
1480                         MODSYM(fct_ctl) (fct_port->port_lport,
1481                             FCT_CMD_PORT_ONLINE_COMPLETE, &st);
1482                         break;
1483                 }
1484 
1485                 if (port->fct_flags & FCT_STATE_PORT_ONLINE) {
1486                         st.st_completion_status = STMF_ALREADY;
1487                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1488                             "STATE: ONLINE chk");
1489                 } else {
1490                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,


1541                     FCT_CMD_PORT_OFFLINE_COMPLETE, &st);
1542 
1543                 break;
1544 
1545         case FCT_ACK_PORT_OFFLINE_COMPLETE:
1546                 port->fct_flags &= ~FCT_STATE_NOT_ACKED;
1547                 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1548                     "STATE: OFFLINE ack");
1549                 break;
1550 
1551         case FCT_ACK_PORT_ONLINE_COMPLETE:
1552                 port->fct_flags &= ~FCT_STATE_NOT_ACKED;
1553                 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1554                     "STATE: ONLINE ack");
1555                 break;
1556 
1557         case FCT_CMD_FORCE_LIP:
1558                 if (port->mode == MODE_INITIATOR) {
1559                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1560                             "fct_ctl: FCT_CMD_FORCE_LIP.");

1561                         break;
1562                 }
1563 
1564                 if (hba->fw_flag & FW_UPDATE_NEEDED) {
1565                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1566                             "fct_ctl: FCT_CMD_FORCE_LIP -> "
1567                             "FCT_CMD_RESET");
1568 
1569                         hba->fw_flag |= FW_UPDATE_KERNEL;
1570 
1571                         /* Reset the adapter */
1572                         (void) emlxs_reset(port, FC_FCA_RESET);
1573                 } else {
1574                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1575                             "fct_ctl: FCT_CMD_FORCE_LIP");
1576 
1577                         /* Reset the link */
1578                         (void) emlxs_reset(port, FC_FCA_LINK_RESET);
1579                 }


1580                 break;
1581         }
1582 
1583         return;
1584 
1585 } /* emlxs_fct_ctl() */
1586 
1587 
1588 extern int
1589 emlxs_fct_port_shutdown(emlxs_port_t *port)
1590 {
1591         fct_local_port_t *fct_port;
1592         int i;
1593 
1594         fct_port = port->fct_port;
1595         if (!fct_port) {
1596                 return (0);
1597         }
1598 
1599         port->fct_flags |= FCT_STATE_NOT_ACKED;


1989 
1990         switch (hba->linkspeed) {
1991         case LA_1GHZ_LINK:
1992                 link->port_speed = PORT_SPEED_1G;
1993                 break;
1994         case LA_2GHZ_LINK:
1995                 link->port_speed = PORT_SPEED_2G;
1996                 break;
1997         case LA_4GHZ_LINK:
1998                 link->port_speed = PORT_SPEED_4G;
1999                 break;
2000         case LA_8GHZ_LINK:
2001                 link->port_speed = PORT_SPEED_8G;
2002                 break;
2003         case LA_10GHZ_LINK:
2004                 link->port_speed = PORT_SPEED_10G;
2005                 break;
2006         case LA_16GHZ_LINK:
2007                 link->port_speed = PORT_SPEED_16G;
2008                 break;



2009         default:
2010                 link->port_speed = PORT_SPEED_UNKNOWN;
2011                 break;
2012         }
2013 
2014         link->portid = port->did;
2015         link->port_no_fct_flogi = 0;
2016         link->port_fca_flogi_done = 0;
2017         link->port_fct_flogi_done = 0;
2018 
2019         mutex_exit(&EMLXS_PORT_LOCK);
2020 
2021         return (FCT_SUCCESS);
2022 
2023 } /* emlxs_fct_get_link_info() */
2024 
2025 
2026 /* COMSTAR ENTER POINT */
2027 static fct_status_t
2028 emlxs_fct_register_remote_port(fct_local_port_t *fct_port,




   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
   9  * http://www.opensource.org/licenses/cddl1.txt.
  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 (c) 2004-2012 Emulex. All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 #include <emlxs.h>
  29 
  30 #ifdef SFCT_SUPPORT
  31 
  32 
  33 /* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
  34 EMLXS_MSG_DEF(EMLXS_FCT_C);
  35 
  36 static void emlxs_fct_memseg_init(emlxs_hba_t *hba);
  37 
  38 static fct_status_t emlxs_fct_cmd_acquire(emlxs_port_t *port,
  39         fct_cmd_t *fct_cmd, uint16_t fct_state);
  40 static fct_status_t emlxs_fct_cmd_accept(emlxs_port_t *port,
  41         fct_cmd_t *fct_cmd, uint16_t fct_state);
  42 static void emlxs_fct_cmd_release(emlxs_port_t *port, fct_cmd_t *fct_cmd,
  43         uint16_t fct_state);
  44 
  45 static emlxs_buf_t *emlxs_fct_cmd_init(emlxs_port_t *port,


1355 
1356                 rval = FCT_FAILURE;
1357                 break;
1358 
1359         }
1360 
1361         return (rval);
1362 
1363 } /* emlxs_fct_port_info() */
1364 
1365 
1366 /* COMSTAR ENTER POINT */
1367 static void
1368 emlxs_fct_populate_hba_details(fct_local_port_t *fct_port,
1369     fct_port_attrs_t *port_attrs)
1370 {
1371         emlxs_port_t *port = (emlxs_port_t *)fct_port->port_fca_private;
1372         emlxs_hba_t *hba = HBA;
1373         emlxs_vpd_t *vpd = &VPD;
1374 
1375         (void) strncpy(port_attrs->manufacturer,
1376             hba->model_info.manufacturer,
1377             (sizeof (port_attrs->manufacturer)-1));
1378         (void) strncpy(port_attrs->serial_number, vpd->serial_num,
1379             (sizeof (port_attrs->serial_number)-1));
1380         (void) strncpy(port_attrs->model, hba->model_info.model,
1381             (sizeof (port_attrs->model)-1));
1382         (void) strncpy(port_attrs->model_description,
1383             hba->model_info.model_desc,
1384             (sizeof (port_attrs->model_description)-1));
1385         (void) snprintf(port_attrs->hardware_version,
1386             (sizeof (port_attrs->hardware_version)-1),
1387             "%x", vpd->biuRev);
1388         (void) snprintf(port_attrs->driver_version,
1389             (sizeof (port_attrs->driver_version)-1),
1390             "%s (%s)", emlxs_version,
1391             emlxs_revision);
1392         (void) strncpy(port_attrs->option_rom_version, vpd->fcode_version,
1393             (sizeof (port_attrs->option_rom_version)-1));
1394         (void) snprintf(port_attrs->firmware_version,
1395             (sizeof (port_attrs->firmware_version)-1),
1396             "%s (%s)", vpd->fw_version,


1453         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1454             "Port attr: supported_speed    = 0x%x",
1455             port_attrs->supported_speed);
1456         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1457             "Port attr: max_frame_size     = 0x%x",
1458             port_attrs->max_frame_size);
1459 
1460         return;
1461 
1462 } /* emlxs_fct_populate_hba_details() */
1463 
1464 
1465 /* COMSTAR ENTER POINT */
1466 /* ARGSUSED */
1467 static void
1468 emlxs_fct_ctl(fct_local_port_t *fct_port, int cmd, void *arg)
1469 {
1470         emlxs_port_t *port = (emlxs_port_t *)fct_port->port_fca_private;
1471         emlxs_hba_t *hba = HBA;
1472         stmf_change_status_t st;
1473         int32_t rval;
1474 
1475         st.st_completion_status = FCT_SUCCESS;
1476         st.st_additional_info = NULL;
1477 
1478         switch (cmd) {
1479         case FCT_CMD_PORT_ONLINE:
1480                 /* If the HBA is offline, we cannot bring the tgtport online */
1481                 if (hba->flag & (FC_OFFLINE_MODE | FC_OFFLINING_MODE)) {
1482                         st.st_completion_status = FCT_FAILURE;
1483                         MODSYM(fct_ctl) (fct_port->port_lport,
1484                             FCT_CMD_PORT_ONLINE_COMPLETE, &st);
1485                         break;
1486                 }
1487 
1488                 if (port->fct_flags & FCT_STATE_PORT_ONLINE) {
1489                         st.st_completion_status = STMF_ALREADY;
1490                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1491                             "STATE: ONLINE chk");
1492                 } else {
1493                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,


1544                     FCT_CMD_PORT_OFFLINE_COMPLETE, &st);
1545 
1546                 break;
1547 
1548         case FCT_ACK_PORT_OFFLINE_COMPLETE:
1549                 port->fct_flags &= ~FCT_STATE_NOT_ACKED;
1550                 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1551                     "STATE: OFFLINE ack");
1552                 break;
1553 
1554         case FCT_ACK_PORT_ONLINE_COMPLETE:
1555                 port->fct_flags &= ~FCT_STATE_NOT_ACKED;
1556                 EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1557                     "STATE: ONLINE ack");
1558                 break;
1559 
1560         case FCT_CMD_FORCE_LIP:
1561                 if (port->mode == MODE_INITIATOR) {
1562                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1563                             "fct_ctl: FCT_CMD_FORCE_LIP.");
1564                         *((fct_status_t *)arg) = FCT_FAILURE;
1565                         break;
1566                 }
1567 
1568                 if (hba->fw_flag & FW_UPDATE_NEEDED) {
1569                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1570                             "fct_ctl: FCT_CMD_FORCE_LIP -> "
1571                             "FCT_CMD_RESET");
1572 
1573                         hba->fw_flag |= FW_UPDATE_KERNEL;
1574 
1575                         /* Reset the adapter */
1576                         rval = emlxs_reset(port, FC_FCA_RESET);
1577                 } else {
1578                         EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fct_detail_msg,
1579                             "fct_ctl: FCT_CMD_FORCE_LIP");
1580 
1581                         /* Reset the link */
1582                         rval = emlxs_reset(port, FC_FCA_LINK_RESET);
1583                 }
1584                 *((fct_status_t *)arg) = (rval == FC_SUCCESS) ? FCT_SUCCESS:
1585                     FCT_FAILURE;
1586                 break;
1587         }
1588 
1589         return;
1590 
1591 } /* emlxs_fct_ctl() */
1592 
1593 
1594 extern int
1595 emlxs_fct_port_shutdown(emlxs_port_t *port)
1596 {
1597         fct_local_port_t *fct_port;
1598         int i;
1599 
1600         fct_port = port->fct_port;
1601         if (!fct_port) {
1602                 return (0);
1603         }
1604 
1605         port->fct_flags |= FCT_STATE_NOT_ACKED;


1995 
1996         switch (hba->linkspeed) {
1997         case LA_1GHZ_LINK:
1998                 link->port_speed = PORT_SPEED_1G;
1999                 break;
2000         case LA_2GHZ_LINK:
2001                 link->port_speed = PORT_SPEED_2G;
2002                 break;
2003         case LA_4GHZ_LINK:
2004                 link->port_speed = PORT_SPEED_4G;
2005                 break;
2006         case LA_8GHZ_LINK:
2007                 link->port_speed = PORT_SPEED_8G;
2008                 break;
2009         case LA_10GHZ_LINK:
2010                 link->port_speed = PORT_SPEED_10G;
2011                 break;
2012         case LA_16GHZ_LINK:
2013                 link->port_speed = PORT_SPEED_16G;
2014                 break;
2015         case LA_32GHZ_LINK:
2016                 link->port_speed = PORT_SPEED_32G;
2017                 break;
2018         default:
2019                 link->port_speed = PORT_SPEED_UNKNOWN;
2020                 break;
2021         }
2022 
2023         link->portid = port->did;
2024         link->port_no_fct_flogi = 0;
2025         link->port_fca_flogi_done = 0;
2026         link->port_fct_flogi_done = 0;
2027 
2028         mutex_exit(&EMLXS_PORT_LOCK);
2029 
2030         return (FCT_SUCCESS);
2031 
2032 } /* emlxs_fct_get_link_info() */
2033 
2034 
2035 /* COMSTAR ENTER POINT */
2036 static fct_status_t
2037 emlxs_fct_register_remote_port(fct_local_port_t *fct_port,